diff options
author | louis <louis.braun@gmx.de> | 2015-01-19 09:23:15 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2015-01-19 09:23:15 +0100 |
commit | ac89503027f048d0fa34234ed5ac62725f3f68e4 (patch) | |
tree | 949b4bfa1af33571b746d86e636d3994fed5261a /libcore | |
parent | cb9044e5f6613d69db26bd0e81575db9c0ff5a25 (diff) | |
download | vdr-plugin-skindesigner-ac89503027f048d0fa34234ed5ac62725f3f68e4.tar.gz vdr-plugin-skindesigner-ac89503027f048d0fa34234ed5ac62725f3f68e4.tar.bz2 |
introducing skin setups
Diffstat (limited to 'libcore')
-rw-r--r-- | libcore/skinsetup.c | 55 | ||||
-rw-r--r-- | libcore/skinsetup.h | 29 | ||||
-rw-r--r-- | libcore/skinsetupparameter.c | 24 | ||||
-rw-r--r-- | libcore/skinsetupparameter.h | 31 |
4 files changed, 139 insertions, 0 deletions
diff --git a/libcore/skinsetup.c b/libcore/skinsetup.c new file mode 100644 index 0000000..c01f2d7 --- /dev/null +++ b/libcore/skinsetup.c @@ -0,0 +1,55 @@ +#include "skinsetup.h" +#include "../libtemplate/xmlparser.h" + +cSkinSetup::cSkinSetup(string skin) { + this->skin = skin; +} + +void cSkinSetup::ReadFromXML(void) { + esyslog("skindesigner: reading setup for skin %s", skin.c_str()); + string xmlFile = "setup.xml"; + cXmlParser parser; + if (!parser.ReadSkinSetup(this, skin, xmlFile)) { + esyslog("skindesigner: no setup file for skin %s found", skin.c_str()); + return; + } + parser.ParseSkinSetup(skin); +} + +void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value) { + if (!type || !name || !displayText || !value) { + esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str()); + return; + } + eSetupParameterType paramType = sptUnknown; + if (!xmlStrcmp(type, (const xmlChar *) "int")) { + paramType = sptInt; + } else if (!xmlStrcmp(type, (const xmlChar *) "bool")) { + paramType = sptBool; + } + if (paramType == sptUnknown) { + esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str()); + return; + } + cSkinSetupParameter param; + param.type = paramType; + param.name = (const char*)name; + param.displayText = (const char*)displayText; + + if (min && paramType == sptInt) { + param.min = atoi((const char*)min); + } + if (max && paramType == sptInt) { + param.max = atoi((const char*)max); + } + param.value = atoi((const char*)value); + + parameters.push_back(param); +} + + +void cSkinSetup::Debug(void) { + dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str()); + for (vector<cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++) + p->Debug(); +} diff --git a/libcore/skinsetup.h b/libcore/skinsetup.h new file mode 100644 index 0000000..4f8a93c --- /dev/null +++ b/libcore/skinsetup.h @@ -0,0 +1,29 @@ +#ifndef __SKINSETUP_H +#define __SKINSETUP_H + +#include <string> +#include <vector> +#include <map> +#include <set> +#include <sstream> +#include <vdr/plugin.h> +#include <libxml/xmlstring.h> +#include "skinsetupparameter.h" + +using namespace std; + +// --- cSkinSetup ----------------------------------------------------------- + +class cSkinSetup { +private: + string skin; + vector<cSkinSetupParameter> parameters; +public: + cSkinSetup(string skin); + virtual ~cSkinSetup(void) {}; + void ReadFromXML(void); + void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value); + void Debug(void); +}; + +#endif //__SKINSETUP_H
\ No newline at end of file diff --git a/libcore/skinsetupparameter.c b/libcore/skinsetupparameter.c new file mode 100644 index 0000000..6f142f6 --- /dev/null +++ b/libcore/skinsetupparameter.c @@ -0,0 +1,24 @@ +#include "skinsetupparameter.h" + +cSkinSetupParameter::cSkinSetupParameter(void) { + type = sptUnknown; + name = ""; + displayText = ""; + min = 0; + max = 1000; + value = 0; +} + +void cSkinSetupParameter::Debug(void) { + if (type == sptBool) + dsyslog("skindesigner: type bool"); + else if (type == sptInt) + dsyslog("skindesigner: type integer"); + else + dsyslog("skindesigner: type UNKNOWN"); + dsyslog("skindesigner: name %s", name.c_str()); + dsyslog("skindesigner: displayText %s", displayText.c_str()); + if (type == sptInt) + dsyslog("skindesigner: min %d, max %d", min, max); + dsyslog("skindesigner: Value %d", value); +}
\ No newline at end of file diff --git a/libcore/skinsetupparameter.h b/libcore/skinsetupparameter.h new file mode 100644 index 0000000..d038159 --- /dev/null +++ b/libcore/skinsetupparameter.h @@ -0,0 +1,31 @@ +#ifndef __SKINSETUPPARAMETER_H +#define __SKINSETUPPARAMETER_H + +#include <string> +#include <vdr/plugin.h> + +using namespace std; + +enum eSetupParameterType { + sptInt, + sptBool, + sptUnknown +}; + +// --- cSkinSetupParameter ----------------------------------------------------------- + +class cSkinSetupParameter { +private: +public: + cSkinSetupParameter(void); + virtual ~cSkinSetupParameter(void) {}; + eSetupParameterType type; + string name; + string displayText; + int min; + int max; + int value; + void Debug(void); +}; + +#endif //__SKINSETUPPARAMETER_H
\ No newline at end of file |