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 | |
| parent | cb9044e5f6613d69db26bd0e81575db9c0ff5a25 (diff) | |
| download | vdr-plugin-skindesigner-ac89503027f048d0fa34234ed5ac62725f3f68e4.tar.gz vdr-plugin-skindesigner-ac89503027f048d0fa34234ed5ac62725f3f68e4.tar.bz2 | |
introducing skin setups
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | config.c | 7 | ||||
| -rw-r--r-- | config.h | 2 | ||||
| -rw-r--r-- | designer.c | 8 | ||||
| -rw-r--r-- | dtd/setup.dtd | 14 | ||||
| -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 | ||||
| -rw-r--r-- | libtemplate/globals.c | 2 | ||||
| -rw-r--r-- | libtemplate/xmlparser.c | 127 | ||||
| -rw-r--r-- | libtemplate/xmlparser.h | 5 | ||||
| -rw-r--r-- | skindesigner.c | 1 | ||||
| -rw-r--r-- | skins/blackhole/setup.xml | 19 |
14 files changed, 325 insertions, 1 deletions
@@ -71,6 +71,8 @@ OBJS = $(PLUGIN).o \ libcore/helpers.o \ libcore/imageloader.o \ libcore/recfolderinfo.o \ + libcore/skinsetupparameter.o \ + libcore/skinsetup.o \ libcore/extrecinfo.o \ libcore/timers.o \ libtemplate/globals.o \ @@ -27,6 +27,7 @@ cDesignerConfig::cDesignerConfig() { } cDesignerConfig::~cDesignerConfig() { + esyslog("skindesigner: config destruktor"); } void cDesignerConfig::SetPathes(void) { @@ -75,6 +76,12 @@ void cDesignerConfig::ReadSkins(void) { dsyslog("skindesigner %ld skins found in %s", skins.size(), *skinPath); } +void cDesignerConfig::ReadSkinSetup(string skin) { + cSkinSetup *skinSetup = new cSkinSetup(skin); + skinSetup->ReadFromXML(); + skinSetup->Debug(); +} + bool cDesignerConfig::GetSkin(string &skin) { if (skinIterator == skins.end()) { return false; @@ -10,6 +10,7 @@ #include "libcore/fontmanager.h" #include "libcore/imagecache.h" #include "libcore/recfolderinfo.h" +#include "libcore/skinsetup.h" #define SCRIPTOUTPUTPATH "/tmp/skindesigner" @@ -37,6 +38,7 @@ public: void SetLogoPath(cString path); void SetEpgImagePath(cString path); void ReadSkins(void); + void ReadSkinSetup(string skin); void InitSkinIterator(void) { skinIterator = skins.begin(); }; bool GetSkin(string &skin); void CheckDecimalPoint(void); @@ -263,6 +263,14 @@ bool cSkinDesigner::LoadTemplates(void) { return false; } +/* + cSkinSetup *skinSetups = new cSkinSetup(); + config.InitSkinIterator(); + string skin = ""; + while (config.GetSkin(skin)) { + skinSetups->ReadFromXML(skin); + } +*/ DeleteTemplates(); channelTemplate = new cTemplate(vtDisplayChannel); diff --git a/dtd/setup.dtd b/dtd/setup.dtd new file mode 100644 index 0000000..81a801b --- /dev/null +++ b/dtd/setup.dtd @@ -0,0 +1,14 @@ +<?xml encoding="UTF-8"?>
+
+<!ELEMENT setup (parameters)>
+<!ELEMENT parameters (parameter)*>
+
+<!ELEMENT parameter (#PCDATA)>
+<!ATTLIST parameter
+ name NMTOKEN #REQUIRED
+ type (int|bool) #REQUIRED
+ min NMTOKEN #IMPLIED
+ max NMTOKEN #IMPLIED
+ displaytext CDATA #REQUIRED
+ >
+
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 diff --git a/libtemplate/globals.c b/libtemplate/globals.c index 1896e7c..4faa710 100644 --- a/libtemplate/globals.c +++ b/libtemplate/globals.c @@ -11,7 +11,7 @@ cGlobals::cGlobals(void) { } bool cGlobals::ReadFromXML(void) { - std::string xmlFile = "globals.xml"; + string xmlFile = "globals.xml"; cXmlParser parser; if (!parser.ReadGlobals(this, xmlFile)) return false; diff --git a/libtemplate/xmlparser.c b/libtemplate/xmlparser.c index ce39dcc..dd93a0d 100644 --- a/libtemplate/xmlparser.c +++ b/libtemplate/xmlparser.c @@ -12,6 +12,8 @@ cXmlParser::cXmlParser(void) { doc = NULL; root = NULL; ctxt = NULL; + globals = NULL; + skinSetup = NULL; initGenericErrorDefaultFunc(NULL); xmlSetStructuredErrorFunc(NULL, SkinDesignerXMLErrorHandler); @@ -122,6 +124,47 @@ bool cXmlParser::ReadGlobals(cGlobals *globals, string xmlFile) { return true; } +bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFile) { + this->skinSetup = skinSetup; + string xmlPath = *cString::sprintf("%s%s/%s", *config.skinPath, skin.c_str(), xmlFile.c_str()); + + esyslog("skindesigner: reading skin setup %s", xmlPath.c_str()); + + if (!FileExists(xmlPath)) + return false; + + if (ctxt == NULL) { + esyslog("skindesigner: Failed to allocate parser context"); + return false; + } + + doc = xmlCtxtReadFile(ctxt, xmlPath.c_str(), NULL, XML_PARSE_NOENT | XML_PARSE_DTDVALID); + + if (doc == NULL ) { + esyslog("skindesigner: ERROR: skin setup %s not parsed successfully.", xmlPath.c_str()); + return false; + } + + root = xmlDocGetRootElement(doc); + + if (ctxt->valid == 0) { + esyslog("skindesigner: Failed to validate %s", xmlPath.c_str()); + return false; + } + + if (root == NULL) { + esyslog("skindesigner: ERROR: Skin Setup %s is empty", xmlPath.c_str()); + return false; + } + + if (xmlStrcmp(root->name, (const xmlChar *) "setup")) { + return false; + } + + return true; +} + + bool cXmlParser::ParseView(void) { vector<pair<string, string> > rootAttribs; ParseAttributes(root->properties, root, rootAttribs); @@ -227,6 +270,28 @@ bool cXmlParser::ParseGlobals(void) { } +bool cXmlParser::ParseSkinSetup(string skin) { + esyslog("skindesigner: parsing skinsetup from %s", skin.c_str()); + + xmlNodePtr node = root->xmlChildrenNode; + + while (node != NULL) { + if (node->type != XML_ELEMENT_NODE) { + node = node->next; + continue; + } + if (!xmlStrcmp(node->name, (const xmlChar *) "parameters")) { + ParseSetupParameter(node->xmlChildrenNode); + node = node->next; + continue; + } + node = node->next; + } + + return true; + +} + void cXmlParser::DeleteDocument(void) { if (doc) { xmlFreeDoc(doc); @@ -244,12 +309,74 @@ string cXmlParser::GetPath(string xmlFile) { string path = ""; if (!xmlFile.compare("globals.xml")) { path = *cString::sprintf("%s%s/themes/%s/%s", *config.skinPath, activeSkin.c_str(), activeTheme.c_str(), xmlFile.c_str()); + } else if (!xmlFile.compare("setup.xml")) { + path = *cString::sprintf("%s%s/%s", *config.skinPath, activeSkin.c_str(), xmlFile.c_str()); } else { path = *cString::sprintf("%s%s/xmlfiles/%s", *config.skinPath, activeSkin.c_str(), xmlFile.c_str()); } return path; } +void cXmlParser::ParseSetupParameter(xmlNodePtr node) { + if (!node) + return; + if (!skinSetup) + return; + + while (node != NULL) { + + if (node->type != XML_ELEMENT_NODE) { + node = node->next; + continue; + } + if (xmlStrcmp(node->name, (const xmlChar *) "parameter")) { + node = node->next; + continue; + } + xmlAttrPtr attr = node->properties; + if (attr == NULL) { + node = node->next; + continue; + } + xmlChar *paramType = NULL; + xmlChar *paramName = NULL; + xmlChar *paramDisplayText = NULL; + xmlChar *paramMin = NULL; + xmlChar *paramMax = NULL; + xmlChar *paramValue = NULL; + while (NULL != attr) { + if (!xmlStrcmp(attr->name, (const xmlChar *) "type")) { + paramType = xmlGetProp(node, attr->name); + } else if (!xmlStrcmp(attr->name, (const xmlChar *) "name")) { + paramName = xmlGetProp(node, attr->name); + } else if (!xmlStrcmp(attr->name, (const xmlChar *) "displaytext")) { + paramDisplayText = xmlGetProp(node, attr->name); + } else if (!xmlStrcmp(attr->name, (const xmlChar *) "min")) { + paramMin = xmlGetProp(node, attr->name); + } else if (!xmlStrcmp(attr->name, (const xmlChar *) "max")) { + paramMax = xmlGetProp(node, attr->name); + } + attr = attr->next; + } + paramValue = xmlNodeListGetString(doc, node->xmlChildrenNode, 1); + skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramMin, paramMax, paramValue); + + if (paramType) + xmlFree(paramType); + if (paramName) + xmlFree(paramName); + if (paramDisplayText) + xmlFree(paramDisplayText); + if (paramMin) + xmlFree(paramMin); + if (paramMax) + xmlFree(paramMax); + if (paramValue) + xmlFree(paramValue); + node = node->next; + } +} + void cXmlParser::ParseGlobalColors(xmlNodePtr node) { if (!node) return; diff --git a/libtemplate/xmlparser.h b/libtemplate/xmlparser.h index 5ff829f..0369622 100644 --- a/libtemplate/xmlparser.h +++ b/libtemplate/xmlparser.h @@ -16,6 +16,7 @@ #include "templateview.h" #include "templateviewlist.h" #include "templateviewtab.h" +#include "../libcore/skinsetup.h" using namespace std; @@ -25,10 +26,12 @@ class cXmlParser { private: cTemplateView *view; cGlobals *globals; + cSkinSetup *skinSetup; xmlParserCtxtPtr ctxt; xmlDocPtr doc; xmlNodePtr root; string GetPath(string xmlFile); + void ParseSetupParameter(xmlNodePtr node); void ParseGlobalColors(xmlNodePtr node); void InsertColor(string name, string value); void ParseGlobalVariables(xmlNodePtr node); @@ -48,9 +51,11 @@ public: bool ReadView(cTemplateView *view, string xmlFile); bool ReadPluginView(string plugName, int templateNumber, string templateName); bool ReadGlobals(cGlobals *globals, string xmlFile); + bool ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFile); bool ParseView(void); bool ParsePluginView(string plugName, int templateNumber); bool ParseGlobals(void); + bool ParseSkinSetup(string skin); void DeleteDocument(void); static void InitLibXML(); static void CleanupLibXML(); diff --git a/skindesigner.c b/skindesigner.c index 3b10108..b416a87 100644 --- a/skindesigner.c +++ b/skindesigner.c @@ -108,6 +108,7 @@ bool cPluginSkinDesigner::Start(void) { config.InitSkinIterator(); string skin = ""; while (config.GetSkin(skin)) { + config.ReadSkinSetup(skin); cSkinDesigner *newSkin = new cSkinDesigner(skin); skins.push_back(newSkin); if (!trueColorAvailable) { diff --git a/skins/blackhole/setup.xml b/skins/blackhole/setup.xml new file mode 100644 index 0000000..c75e183 --- /dev/null +++ b/skins/blackhole/setup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE setup SYSTEM "../../dtd/setup.dtd"> + +<setup> + <!-- + define all your parameters here which should be configurable via + OSD and the skindesigner setup menu. + Parameters must have type "bool" or "integer". For "bool" Parameters + a choice yes/no is shown in the setup menu, a "integer" parameter + can be configured to a value between "min" and "max". If "min" is not + set, "0" is the minimum, if "max" is not set, "1000" is maximum. + "displayname" is used to display the option in the setup menu. + --> + <parameters> + <parameter type="bool" name="showsignal" displaytext="Show Signalstrength and -quality when switching channel">0</parameter> + <parameter type="bool" name="showposter" displaytext="Show Poster when switching channel">1</parameter> + <parameter type="int" name="fadetime" min="0" max="1000" displaytext="Fade In and Out time in ms">300</parameter> + </parameters> +</setup> |
