diff options
author | louis <louis.braun@gmx.de> | 2015-02-12 18:50:58 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2015-02-12 18:50:58 +0100 |
commit | 4d7700aecedf475038d57e10f45ab2dd4bcf806f (patch) | |
tree | 2fefc56fe77c8f4137187515a5f2b57d78425fea /designer.c | |
parent | 00ac852820a09f676157a7b487acf51f4fe95ff4 (diff) | |
download | vdr-plugin-skindesigner-4d7700aecedf475038d57e10f45ab2dd4bcf806f.tar.gz vdr-plugin-skindesigner-4d7700aecedf475038d57e10f45ab2dd4bcf806f.tar.bz2 |
plugin interface
Diffstat (limited to 'designer.c')
-rw-r--r-- | designer.c | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -107,6 +107,22 @@ cSkinDisplayMessage *cSkinDesigner::DisplayMessage(void) { return displayMessage; } +cSkinDisplayPlugin *cSkinDesigner::DisplayPlugin(string pluginName, int viewID) { + currentMenu = NULL; + if (useBackupSkin) + return NULL; + Init(); + cSkinDisplayPlugin *displayPlugin = NULL; + map< string, map <int, cTemplate*> >::iterator hit = pluginTemplates.find(pluginName); + if (hit == pluginTemplates.end()) + return NULL; + map <int, cTemplate*>::iterator hit2 = (hit->second).find(viewID); + if (hit2 == (hit->second).end()) + return NULL; + return new cSkinDisplayPlugin(hit2->second); +} + + void cSkinDesigner::Reload(void) { dsyslog("skindesigner: forcing full reload of templates"); if (cOsd::IsOpen()) { @@ -236,6 +252,13 @@ void cSkinDesigner::DeleteTemplates(void) { delete audiotracksTemplate; audiotracksTemplate = NULL; } + for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs !=pluginTemplates.end(); plugs++) { + map <int, cTemplate*> plugTpls = plugs->second; + for (map <int, cTemplate*>::iterator tpl = plugTpls.begin(); tpl != plugTpls.end(); tpl++) { + delete tpl->second; + } + } + pluginTemplates.clear(); } bool cSkinDesigner::LoadTemplates(void) { @@ -316,6 +339,33 @@ bool cSkinDesigner::LoadTemplates(void) { } audiotracksTemplate->Translate(); + config.InitPluginViewIterator(); + map <int,string> *plugViews = NULL; + string plugName; + while ( plugViews = config.GetPluginViews(plugName) ) { + for (map <int,string>::iterator v = plugViews->begin(); v != plugViews->end(); v++) { + stringstream templateName; + templateName << "plug-" << plugName << "-" << v->second.c_str(); + cTemplate *plgTemplate = new cTemplate(vtDisplayPlugin, plugName, v->first); + plgTemplate->SetGlobals(globals); + ok = plgTemplate->ReadFromXML(templateName.str()); + if (!ok) { + esyslog("skindesigner: error reading plugin %s template", plugName.c_str()); + DeleteTemplates(); + return false; + } + plgTemplate->Translate(); + map< string, map <int, cTemplate*> >::iterator hit = pluginTemplates.find(plugName); + if (hit == pluginTemplates.end()) { + map <int, cTemplate*> plugTemplates; + plugTemplates.insert(pair<int, cTemplate*>(v->first, plgTemplate)); + pluginTemplates.insert(pair<string, map <int, cTemplate*> >(plugName, plugTemplates)); + } else { + (hit->second).insert(pair<int, cTemplate*>(v->first, plgTemplate)); + } + } + } + dsyslog("skindesigner: templates successfully validated and parsed"); return true; } @@ -327,6 +377,11 @@ void cSkinDesigner::CacheTemplates(void) { replayTemplate->PreCache(); volumeTemplate->PreCache(); audiotracksTemplate->PreCache(); + for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs != pluginTemplates.end(); plugs++) { + for (map <int, cTemplate*>::iterator plugTplts = plugs->second.begin(); plugTplts != plugs->second.end(); plugTplts++) { + (plugTplts->second)->PreCache(); + } + } dsyslog("skindesigner: templates cached"); fontManager->CacheFonts(channelTemplate); fontManager->CacheFonts(menuTemplate); @@ -344,6 +399,11 @@ void cSkinDesigner::CacheTemplates(void) { replayTemplate->CacheImages(); volumeTemplate->CacheImages(); audiotracksTemplate->CacheImages(); + for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs != pluginTemplates.end(); plugs++) { + for (map <int, cTemplate*>::iterator plugTplts = plugs->second.begin(); plugTplts != plugs->second.end(); plugTplts++) { + (plugTplts->second)->CacheImages(); + } + } imgCache->Debug(false); } |