mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
added skinsetup to globals
This commit is contained in:
parent
f2f7246c0b
commit
f72a1856cb
19
config.c
19
config.c
@ -27,7 +27,9 @@ cDesignerConfig::cDesignerConfig() {
|
||||
}
|
||||
|
||||
cDesignerConfig::~cDesignerConfig() {
|
||||
esyslog("skindesigner: config destruktor");
|
||||
for (map < string, cSkinSetup* >::iterator it = skinSetups.begin(); it != skinSetups.end(); it++) {
|
||||
delete it->second;
|
||||
}
|
||||
}
|
||||
|
||||
void cDesignerConfig::SetPathes(void) {
|
||||
@ -78,8 +80,10 @@ void cDesignerConfig::ReadSkins(void) {
|
||||
|
||||
void cDesignerConfig::ReadSkinSetup(string skin) {
|
||||
cSkinSetup *skinSetup = new cSkinSetup(skin);
|
||||
skinSetup->ReadFromXML();
|
||||
skinSetup->Debug();
|
||||
if (skinSetup->ReadFromXML()) {
|
||||
//skinSetup->Debug();
|
||||
skinSetups.insert(pair<string, cSkinSetup* >(skin, skinSetup));
|
||||
}
|
||||
}
|
||||
|
||||
bool cDesignerConfig::GetSkin(string &skin) {
|
||||
@ -91,6 +95,15 @@ bool cDesignerConfig::GetSkin(string &skin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
cSkinSetup* cDesignerConfig::GetSkinSetup(string &skin) {
|
||||
map< string, cSkinSetup* >::iterator hit = skinSetups.find(skin);
|
||||
if (hit != skinSetups.end()) {
|
||||
return hit->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void cDesignerConfig::CheckDecimalPoint(void) {
|
||||
struct lconv *pLocInfo;
|
||||
pLocInfo = localeconv();
|
||||
|
2
config.h
2
config.h
@ -29,6 +29,7 @@ private:
|
||||
string osdLanguage;
|
||||
map < string, map < int, string > > plugins;
|
||||
map < string, map < int, string > >::iterator plugIt;
|
||||
map< string, cSkinSetup* > skinSetups;
|
||||
public:
|
||||
cDesignerConfig();
|
||||
~cDesignerConfig();
|
||||
@ -41,6 +42,7 @@ public:
|
||||
void ReadSkinSetup(string skin);
|
||||
void InitSkinIterator(void) { skinIterator = skins.begin(); };
|
||||
bool GetSkin(string &skin);
|
||||
cSkinSetup* GetSkinSetup(string &skin);
|
||||
void CheckDecimalPoint(void);
|
||||
void SetSkin(void);
|
||||
bool SkinChanged(void);
|
||||
|
11
designer.c
11
designer.c
@ -263,14 +263,11 @@ bool cSkinDesigner::LoadTemplates(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
cSkinSetup *skinSetups = new cSkinSetup();
|
||||
config.InitSkinIterator();
|
||||
string skin = "";
|
||||
while (config.GetSkin(skin)) {
|
||||
skinSetups->ReadFromXML(skin);
|
||||
cSkinSetup *skinSetup = config.GetSkinSetup(skin);
|
||||
if (skinSetup) {
|
||||
skinSetup->AddToGlobals(globals);
|
||||
}
|
||||
*/
|
||||
|
||||
DeleteTemplates();
|
||||
|
||||
channelTemplate = new cTemplate(vtDisplayChannel);
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?xml encoding="UTF-8"?>
|
||||
|
||||
<!ELEMENT setup (parameters)>
|
||||
<!ELEMENT setup (parameters,translations)>
|
||||
<!ELEMENT parameters (parameter)*>
|
||||
<!ELEMENT translations (token)*>
|
||||
|
||||
<!ELEMENT parameter (#PCDATA)>
|
||||
<!ATTLIST parameter
|
||||
@ -12,3 +13,10 @@
|
||||
displaytext CDATA #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT token (trans)+>
|
||||
<!ATTLIST token
|
||||
name CDATA #REQUIRED>
|
||||
|
||||
<!ELEMENT trans (#PCDATA)>
|
||||
<!ATTLIST trans
|
||||
lang NMTOKEN #REQUIRED>
|
||||
|
@ -5,15 +5,14 @@ cSkinSetup::cSkinSetup(string skin) {
|
||||
this->skin = skin;
|
||||
}
|
||||
|
||||
void cSkinSetup::ReadFromXML(void) {
|
||||
esyslog("skindesigner: reading setup for skin %s", skin.c_str());
|
||||
bool cSkinSetup::ReadFromXML(void) {
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
parser.ParseSkinSetup(skin);
|
||||
return true;
|
||||
}
|
||||
|
||||
void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value) {
|
||||
@ -44,12 +43,35 @@ void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText
|
||||
}
|
||||
param.value = atoi((const char*)value);
|
||||
|
||||
parameters.push_back(param);
|
||||
parameters.insert(pair<string, cSkinSetupParameter>(param.name, param));
|
||||
}
|
||||
|
||||
void cSkinSetup::SetTranslation(string translationToken, map < string, string > transl) {
|
||||
translations.insert(pair<string, map < string, string > >(translationToken, transl));
|
||||
}
|
||||
|
||||
void cSkinSetup::AddToGlobals(cGlobals *globals) {
|
||||
if (!globals)
|
||||
return;
|
||||
for (map<string, cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++) {
|
||||
string paramName = p->first;
|
||||
cSkinSetupParameter param = p->second;
|
||||
globals->intVars.erase(paramName);
|
||||
globals->intVars.insert(pair<string,int>(paramName, param.value));
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
for (map<string, cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++) {
|
||||
(p->second).Debug();
|
||||
}
|
||||
dsyslog("skindesigner: Skin \"%s\" Setup Parameter Translations", skin.c_str());
|
||||
for (map<string, map<string,string> >::iterator trans = translations.begin(); trans != translations.end(); trans++) {
|
||||
dsyslog("skindesigner: translation token %s", (trans->first).c_str());
|
||||
map<string,string> transValues = trans->second;
|
||||
for (map<string,string>::iterator trans2 = transValues.begin(); trans2 != transValues.end(); trans2++) {
|
||||
dsyslog("skindesigner: translation language %s value \"%s\"", (trans2->first).c_str(), (trans2->second).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <sstream>
|
||||
#include <vdr/plugin.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include "../libtemplate/globals.h"
|
||||
#include "skinsetupparameter.h"
|
||||
|
||||
using namespace std;
|
||||
@ -17,12 +18,15 @@ using namespace std;
|
||||
class cSkinSetup {
|
||||
private:
|
||||
string skin;
|
||||
vector<cSkinSetupParameter> parameters;
|
||||
map <string, cSkinSetupParameter> parameters;
|
||||
map <string, map< string, string > > translations;
|
||||
public:
|
||||
cSkinSetup(string skin);
|
||||
virtual ~cSkinSetup(void) {};
|
||||
void ReadFromXML(void);
|
||||
bool ReadFromXML(void);
|
||||
void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value);
|
||||
void SetTranslation(string translationToken, map < string, string > transl);
|
||||
void AddToGlobals(cGlobals *globals);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
|
@ -10,15 +10,12 @@ cSkinSetupParameter::cSkinSetupParameter(void) {
|
||||
}
|
||||
|
||||
void cSkinSetupParameter::Debug(void) {
|
||||
string sType = "unknown";
|
||||
if (type == sptBool)
|
||||
dsyslog("skindesigner: type bool");
|
||||
sType = "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());
|
||||
sType = "int";
|
||||
dsyslog("skindesigner: name \"%s\", type %s, displayText \"%s\", Value %d", name.c_str(), sType.c_str(), displayText.c_str(), value);
|
||||
if (type == sptInt)
|
||||
dsyslog("skindesigner: min %d, max %d", min, max);
|
||||
dsyslog("skindesigner: Value %d", value);
|
||||
}
|
@ -128,11 +128,8 @@ bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFil
|
||||
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;
|
||||
@ -151,12 +148,9 @@ bool cXmlParser::ReadSkinSetup(cSkinSetup *skinSetup, string skin, string xmlFil
|
||||
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;
|
||||
}
|
||||
@ -271,8 +265,6 @@ 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) {
|
||||
@ -284,6 +276,10 @@ bool cXmlParser::ParseSkinSetup(string skin) {
|
||||
ParseSetupParameter(node->xmlChildrenNode);
|
||||
node = node->next;
|
||||
continue;
|
||||
} else if (!xmlStrcmp(node->name, (const xmlChar *) "translations")) {
|
||||
ParseTranslations(node->xmlChildrenNode);
|
||||
node = node->next;
|
||||
continue;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
@ -610,7 +606,11 @@ void cXmlParser::ParseTranslations(xmlNodePtr node) {
|
||||
xmlFree(value);
|
||||
nodeTrans = nodeTrans->next;
|
||||
}
|
||||
globals->translations.insert(pair<string, map < string, string > >((const char*)tokenName, tokenTranslations));
|
||||
if (globals) {
|
||||
globals->translations.insert(pair<string, map < string, string > >((const char*)tokenName, tokenTranslations));
|
||||
} else if (skinSetup) {
|
||||
skinSetup->SetTranslation((const char*)tokenName, tokenTranslations);
|
||||
}
|
||||
xmlFree(tokenName);
|
||||
node = node->next;
|
||||
}
|
||||
|
@ -12,8 +12,26 @@
|
||||
"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>
|
||||
<parameter type="bool" name="showsignal" displaytext="tr(showsignaltext)">0</parameter>
|
||||
<parameter type="bool" name="showposter" displaytext="tr(showpostertext)">1</parameter>
|
||||
<parameter type="int" name="fadetime" min="0" max="1000" displaytext="tr(fadetext)">300</parameter>
|
||||
</parameters>
|
||||
|
||||
<!--
|
||||
translations of displaytexts
|
||||
-->
|
||||
<translations>
|
||||
<token name="tr(showsignaltext)">
|
||||
<trans lang="en_EN">Show Signalstrength and -quality when switching channel</trans>
|
||||
<trans lang="de_DE">Signalstärke und -qualität beim Umschalten anzeigen</trans>
|
||||
</token>
|
||||
<token name="tr(showpostertext)">
|
||||
<trans lang="en_EN">Show Poster when switching channel</trans>
|
||||
<trans lang="de_DE">Poster beim Umschalten anzeigen</trans>
|
||||
</token>
|
||||
<token name="tr(fadetext)">
|
||||
<trans lang="en_EN">Fade In and Out time in ms</trans>
|
||||
<trans lang="de_DE">Fade In and Out Zeit in ms</trans>
|
||||
</token>
|
||||
</translations>
|
||||
</setup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user