summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2016-02-06 09:55:15 +0100
committerlouis <louis.braun@gmx.de>2016-02-06 09:55:15 +0100
commitac0e6dbc8d1ea8fd24712dd03fea154cea6a7135 (patch)
tree3f8ab3640f7c0645592c8bbd0d4ce34821816ad7 /extensions
parent8ef68f8ab82e511ad0df96a910daa1547923633b (diff)
downloadvdr-plugin-skindesigner-ac0e6dbc8d1ea8fd24712dd03fea154cea6a7135.tar.gz
vdr-plugin-skindesigner-ac0e6dbc8d1ea8fd24712dd03fea154cea6a7135.tar.bz2
fixed line breaks
Diffstat (limited to 'extensions')
-rw-r--r--extensions/libxmlwrapper.c378
-rw-r--r--extensions/libxmlwrapper.h90
-rw-r--r--extensions/pluginmanager.c602
-rw-r--r--extensions/pluginmanager.h142
-rw-r--r--extensions/scrapmanager.c716
-rw-r--r--extensions/scrapmanager.h54
6 files changed, 991 insertions, 991 deletions
diff --git a/extensions/libxmlwrapper.c b/extensions/libxmlwrapper.c
index 117815e..47bae91 100644
--- a/extensions/libxmlwrapper.c
+++ b/extensions/libxmlwrapper.c
@@ -1,189 +1,189 @@
-#include "helpers.h"
-#include "libxmlwrapper.h"
-
-void SkinDesignerXMLErrorHandler (void * userData, xmlErrorPtr error) {
- esyslog("skindesigner: Error in XML: %s", error->message);
-}
-
-cLibXMLWrapper::cLibXMLWrapper(void) {
- ctxt = NULL;
- doc = NULL;
- root = NULL;
-
- initGenericErrorDefaultFunc(NULL);
- xmlSetStructuredErrorFunc(NULL, SkinDesignerXMLErrorHandler);
- ctxt = xmlNewParserCtxt();
-}
-
-cLibXMLWrapper::~cLibXMLWrapper() {
- DeleteDocument();
- xmlFreeParserCtxt(ctxt);
-}
-
-void cLibXMLWrapper::InitLibXML() {
- xmlInitParser();
-}
-
-void cLibXMLWrapper::CleanupLibXML() {
- xmlCleanupParser();
-}
-
-void cLibXMLWrapper::DeleteDocument(void) {
- if (doc) {
- xmlFreeDoc(doc);
- doc = NULL;
- }
- while (!nodeStack.empty())
- nodeStack.pop();
-}
-
-bool cLibXMLWrapper::ReadXMLFile(const char *path, bool validate) {
- if (!ctxt) {
- esyslog("skindesigner: Failed to allocate parser context");
- return false;
- }
- if (!FileExists(path)) {
- dsyslog("skindesigner: reading XML Template %s failed", path);
- return false;
- }
- if (validate)
- doc = xmlCtxtReadFile(ctxt, path, NULL, XML_PARSE_NOENT | XML_PARSE_DTDVALID);
- else
- doc = xmlCtxtReadFile(ctxt, path, NULL, XML_PARSE_NOENT);
-
- if (!doc) {
- dsyslog("skindesigner: reading XML Template %s failed", path);
- return false;
- }
- return true;
-}
-
-bool cLibXMLWrapper::SetDocument(void) {
- if (!doc)
- return false;
- root = xmlDocGetRootElement(doc);
- nodeStack.push(root);
- if (root == NULL) {
- esyslog("skindesigner: ERROR: XML File is empty");
- return false;
- }
- return true;
-}
-
-bool cLibXMLWrapper::Validate(void) {
- if (!ctxt)
- return false;
- if (ctxt->valid == 0) {
- esyslog("skindesigner: Failed to validate XML File");
- return false;
- }
- return true;
-}
-
-bool cLibXMLWrapper::CheckNodeName(const char *name) {
- if (nodeStack.empty())
- return false;
- xmlNodePtr current = nodeStack.top();
- if (xmlStrcmp(current->name, (const xmlChar *) name)) {
- return false;
- }
- return true;
-}
-
-const char *cLibXMLWrapper::NodeName(void) {
- xmlNodePtr current = nodeStack.top();
- return (const char*)current->name;
-}
-
-vector<stringpair> cLibXMLWrapper::ParseAttributes(void) {
- vector<stringpair> attributes;
- if (nodeStack.empty())
- return attributes;
- xmlNodePtr current = nodeStack.top();
- xmlAttrPtr attrPtr = current->properties;
- if (attrPtr == NULL) {
- return attributes;
- }
- while (NULL != attrPtr) {
- string name = (const char*)attrPtr->name;
- xmlChar *value = NULL;
- value = xmlGetProp(current, attrPtr->name);
- if (value)
- attributes.push_back(stringpair((const char*)attrPtr->name, (const char*)value));
- attrPtr = attrPtr->next;
- if (value)
- xmlFree(value);
- }
- return attributes;
-}
-
-bool cLibXMLWrapper::LevelDown(void) {
- if (nodeStack.empty())
- return false;
- xmlNodePtr current = nodeStack.top();
- xmlNodePtr child = current->xmlChildrenNode;
- while (child && child->type != XML_ELEMENT_NODE) {
- child = child->next;
- }
- if (!child)
- return false;
- nodeStack.push(child);
- return true;
-}
-
-bool cLibXMLWrapper::LevelUp(void) {
- if (nodeStack.size() == 1)
- return false;
- nodeStack.pop();
- return true;
-}
-
-bool cLibXMLWrapper::NextNode(void) {
- xmlNodePtr current = nodeStack.top();
- current = current->next;
- while (current && current->type != XML_ELEMENT_NODE) {
- current = current->next;
- }
- if (!current)
- return false;
- nodeStack.pop();
- nodeStack.push(current);
- return true;
-}
-
-bool cLibXMLWrapper::GetAttribute(string &name, string &value) {
- bool ok = false;
- xmlNodePtr current = nodeStack.top();
- xmlAttrPtr attr = current->properties;
- if (attr == NULL) {
- return ok;
- }
- xmlChar *xmlValue = NULL;
- while (NULL != attr) {
- if (xmlStrcmp(attr->name, (const xmlChar *) name.c_str())) {
- attr = attr->next;
- continue;
- }
- ok = true;
- xmlValue = xmlGetProp(current, attr->name);
- if (xmlValue) {
- value = (const char*)xmlValue;
- xmlFree(xmlValue);
- }
- break;
- }
- return ok;
-}
-
-bool cLibXMLWrapper::GetNodeValue(string &value) {
- xmlChar *val = NULL;
- xmlNodePtr current = nodeStack.top();
- val = xmlNodeListGetString(doc, current->xmlChildrenNode, 1);
- if (val) {
- value = (const char*)val;
- xmlFree(val);
- return true;
- }
- value = "";
- return false;
-}
+#include "helpers.h"
+#include "libxmlwrapper.h"
+
+void SkinDesignerXMLErrorHandler (void * userData, xmlErrorPtr error) {
+ esyslog("skindesigner: Error in XML: %s", error->message);
+}
+
+cLibXMLWrapper::cLibXMLWrapper(void) {
+ ctxt = NULL;
+ doc = NULL;
+ root = NULL;
+
+ initGenericErrorDefaultFunc(NULL);
+ xmlSetStructuredErrorFunc(NULL, SkinDesignerXMLErrorHandler);
+ ctxt = xmlNewParserCtxt();
+}
+
+cLibXMLWrapper::~cLibXMLWrapper() {
+ DeleteDocument();
+ xmlFreeParserCtxt(ctxt);
+}
+
+void cLibXMLWrapper::InitLibXML() {
+ xmlInitParser();
+}
+
+void cLibXMLWrapper::CleanupLibXML() {
+ xmlCleanupParser();
+}
+
+void cLibXMLWrapper::DeleteDocument(void) {
+ if (doc) {
+ xmlFreeDoc(doc);
+ doc = NULL;
+ }
+ while (!nodeStack.empty())
+ nodeStack.pop();
+}
+
+bool cLibXMLWrapper::ReadXMLFile(const char *path, bool validate) {
+ if (!ctxt) {
+ esyslog("skindesigner: Failed to allocate parser context");
+ return false;
+ }
+ if (!FileExists(path)) {
+ dsyslog("skindesigner: reading XML Template %s failed", path);
+ return false;
+ }
+ if (validate)
+ doc = xmlCtxtReadFile(ctxt, path, NULL, XML_PARSE_NOENT | XML_PARSE_DTDVALID);
+ else
+ doc = xmlCtxtReadFile(ctxt, path, NULL, XML_PARSE_NOENT);
+
+ if (!doc) {
+ dsyslog("skindesigner: reading XML Template %s failed", path);
+ return false;
+ }
+ return true;
+}
+
+bool cLibXMLWrapper::SetDocument(void) {
+ if (!doc)
+ return false;
+ root = xmlDocGetRootElement(doc);
+ nodeStack.push(root);
+ if (root == NULL) {
+ esyslog("skindesigner: ERROR: XML File is empty");
+ return false;
+ }
+ return true;
+}
+
+bool cLibXMLWrapper::Validate(void) {
+ if (!ctxt)
+ return false;
+ if (ctxt->valid == 0) {
+ esyslog("skindesigner: Failed to validate XML File");
+ return false;
+ }
+ return true;
+}
+
+bool cLibXMLWrapper::CheckNodeName(const char *name) {
+ if (nodeStack.empty())
+ return false;
+ xmlNodePtr current = nodeStack.top();
+ if (xmlStrcmp(current->name, (const xmlChar *) name)) {
+ return false;
+ }
+ return true;
+}
+
+const char *cLibXMLWrapper::NodeName(void) {
+ xmlNodePtr current = nodeStack.top();
+ return (const char*)current->name;
+}
+
+vector<stringpair> cLibXMLWrapper::ParseAttributes(void) {
+ vector<stringpair> attributes;
+ if (nodeStack.empty())
+ return attributes;
+ xmlNodePtr current = nodeStack.top();
+ xmlAttrPtr attrPtr = current->properties;
+ if (attrPtr == NULL) {
+ return attributes;
+ }
+ while (NULL != attrPtr) {
+ string name = (const char*)attrPtr->name;
+ xmlChar *value = NULL;
+ value = xmlGetProp(current, attrPtr->name);
+ if (value)
+ attributes.push_back(stringpair((const char*)attrPtr->name, (const char*)value));
+ attrPtr = attrPtr->next;
+ if (value)
+ xmlFree(value);
+ }
+ return attributes;
+}
+
+bool cLibXMLWrapper::LevelDown(void) {
+ if (nodeStack.empty())
+ return false;
+ xmlNodePtr current = nodeStack.top();
+ xmlNodePtr child = current->xmlChildrenNode;
+ while (child && child->type != XML_ELEMENT_NODE) {
+ child = child->next;
+ }
+ if (!child)
+ return false;
+ nodeStack.push(child);
+ return true;
+}
+
+bool cLibXMLWrapper::LevelUp(void) {
+ if (nodeStack.size() == 1)
+ return false;
+ nodeStack.pop();
+ return true;
+}
+
+bool cLibXMLWrapper::NextNode(void) {
+ xmlNodePtr current = nodeStack.top();
+ current = current->next;
+ while (current && current->type != XML_ELEMENT_NODE) {
+ current = current->next;
+ }
+ if (!current)
+ return false;
+ nodeStack.pop();
+ nodeStack.push(current);
+ return true;
+}
+
+bool cLibXMLWrapper::GetAttribute(string &name, string &value) {
+ bool ok = false;
+ xmlNodePtr current = nodeStack.top();
+ xmlAttrPtr attr = current->properties;
+ if (attr == NULL) {
+ return ok;
+ }
+ xmlChar *xmlValue = NULL;
+ while (NULL != attr) {
+ if (xmlStrcmp(attr->name, (const xmlChar *) name.c_str())) {
+ attr = attr->next;
+ continue;
+ }
+ ok = true;
+ xmlValue = xmlGetProp(current, attr->name);
+ if (xmlValue) {
+ value = (const char*)xmlValue;
+ xmlFree(xmlValue);
+ }
+ break;
+ }
+ return ok;
+}
+
+bool cLibXMLWrapper::GetNodeValue(string &value) {
+ xmlChar *val = NULL;
+ xmlNodePtr current = nodeStack.top();
+ val = xmlNodeListGetString(doc, current->xmlChildrenNode, 1);
+ if (val) {
+ value = (const char*)val;
+ xmlFree(val);
+ return true;
+ }
+ value = "";
+ return false;
+}
diff --git a/extensions/libxmlwrapper.h b/extensions/libxmlwrapper.h
index 3971bb9..0838f52 100644
--- a/extensions/libxmlwrapper.h
+++ b/extensions/libxmlwrapper.h
@@ -1,46 +1,46 @@
-#ifndef __LIBXMLWRAPPER_H
-#define __LIBXMLWRAPPER_H
-
-#include <string>
-#include <vector>
-#include <map>
-#include <set>
-#include <utility>
-#include <stack>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xmlerror.h>
-#include <vdr/plugin.h>
-
-using namespace std;
-typedef pair<string,string> stringpair;
-typedef map<string,string> stringmap;
-
-class cLibXMLWrapper {
-private:
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
- xmlNodePtr root;
- xmlNodePtr current;
- stack<xmlNodePtr> nodeStack;
-protected:
- void DeleteDocument(void);
- bool ReadXMLFile(const char *path, bool validate = true);
- bool SetDocument(void);
- bool Validate(void);
- bool CheckNodeName(const char *name);
- const char *NodeName(void);
- vector<stringpair> ParseAttributes(void);
- bool LevelDown(void);
- bool LevelUp(void);
- bool NextNode(void);
- bool GetAttribute(string &name, string &value);
- bool GetNodeValue(string &value);
-public:
- cLibXMLWrapper(void);
- virtual ~cLibXMLWrapper(void);
- static void InitLibXML();
- static void CleanupLibXML();
-};
-
+#ifndef __LIBXMLWRAPPER_H
+#define __LIBXMLWRAPPER_H
+
+#include <string>
+#include <vector>
+#include <map>
+#include <set>
+#include <utility>
+#include <stack>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlerror.h>
+#include <vdr/plugin.h>
+
+using namespace std;
+typedef pair<string,string> stringpair;
+typedef map<string,string> stringmap;
+
+class cLibXMLWrapper {
+private:
+ xmlParserCtxtPtr ctxt;
+ xmlDocPtr doc;
+ xmlNodePtr root;
+ xmlNodePtr current;
+ stack<xmlNodePtr> nodeStack;
+protected:
+ void DeleteDocument(void);
+ bool ReadXMLFile(const char *path, bool validate = true);
+ bool SetDocument(void);
+ bool Validate(void);
+ bool CheckNodeName(const char *name);
+ const char *NodeName(void);
+ vector<stringpair> ParseAttributes(void);
+ bool LevelDown(void);
+ bool LevelUp(void);
+ bool NextNode(void);
+ bool GetAttribute(string &name, string &value);
+ bool GetNodeValue(string &value);
+public:
+ cLibXMLWrapper(void);
+ virtual ~cLibXMLWrapper(void);
+ static void InitLibXML();
+ static void CleanupLibXML();
+};
+
#endif //__LIBXMLWRAPPER_H \ No newline at end of file
diff --git a/extensions/pluginmanager.c b/extensions/pluginmanager.c
index 2f839f8..da55c93 100644
--- a/extensions/pluginmanager.c
+++ b/extensions/pluginmanager.c
@@ -1,301 +1,301 @@
-#include "pluginmanager.h"
-
-cSDPluginManager::cSDPluginManager(void) {
- lastId = 0;
- subviewsfound = false;
-}
-
-cSDPluginManager::~cSDPluginManager(void) {
-}
-
-void cSDPluginManager::Reset(void) {
- subViewMapping.clear();
-}
-
-void cSDPluginManager::RegisterBasicPlugin(skindesignerapi::cPluginStructure *plugStructure) {
- dsyslog("skindesigner: plugin %s uses libskindesigner API Version %s",
- plugStructure->name.c_str(),
- plugStructure->libskindesignerAPIVersion.c_str());
- plugStructure->id = lastId;
- registeredPlugins.insert(pair<int,string>(lastId, plugStructure->name));
- lastId++;
- map< int, skindesignerapi::sPlugMenu > menusNew;
- for (map< int, skindesignerapi::sPlugMenu >::iterator it = plugStructure->menus.begin(); it != plugStructure->menus.end(); it++) {
- int key = it->first;
- skindesignerapi::sPlugMenu menu = it->second;
- skindesignerapi::sPlugMenu menuNew;
- menuNew.type = menu.type;
- menuNew.tplname = menu.tplname;
- menuNew.tokenContainer = new skindesignerapi::cTokenContainer(*menu.tokenContainer);
- menusNew.insert(pair<int, skindesignerapi::sPlugMenu>(key, menuNew));
- }
- pluginMenus.insert(pair< int, map < int, skindesignerapi::sPlugMenu > >(plugStructure->id, menusNew));
-
- if (plugStructure->menus.size() > 0)
- dsyslog("skindesigner: plugin %s has registered %ld menus", plugStructure->name.c_str(), plugStructure->menus.size());
-
-}
-
-int cSDPluginManager::GetNumPluginMenus(void) {
- int numMenusTotal = 0;
- for (map < int, map < int, skindesignerapi::sPlugMenu > >::iterator it = pluginMenus.begin(); it != pluginMenus.end(); it++) {
- numMenusTotal += (it->second).size();
- }
- return numMenusTotal;
-}
-
-void cSDPluginManager::InitPluginMenuIterator(void) {
- plugMenuIt = pluginMenus.begin();
-}
-
-map <int,skindesignerapi::sPlugMenu> *cSDPluginManager::GetPluginMenus(string &name, int &id) {
- if (plugMenuIt == pluginMenus.end())
- return NULL;
- id = plugMenuIt->first;
- map<int,string>::iterator hit = registeredPlugins.find(id);
- if (hit != registeredPlugins.end())
- name = hit->second;
- map <int,skindesignerapi::sPlugMenu> *templates = &plugMenuIt->second;
- plugMenuIt++;
- return templates;
-}
-
-skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainer(int plugId, int plugMenuId) {
- map <int, map<int, skindesignerapi::sPlugMenu> >::iterator hit = pluginMenus.find(plugId);
- if (hit == pluginMenus.end())
- return NULL;
- map<int, skindesignerapi::sPlugMenu>::iterator hit2 = (hit->second).find(plugMenuId);
- if (hit2 == (hit->second).end())
- return NULL;
- skindesignerapi::cTokenContainer *tk = hit2->second.tokenContainer;
- return tk;
-}
-
-void cSDPluginManager::AddSubviewMapping(int plugId, int plugMenuId, int subViewId) {
- map <int, map<int,int> >::iterator hit = subViewMapping.find(plugId);
- if (hit == subViewMapping.end()) {
- map<int,int> menus;
- menus.insert(pair<int,int>(plugMenuId, subViewId));
- subViewMapping.insert(pair<int, map<int,int> >(plugId, menus));
- } else {
- (hit->second).insert(pair<int,int>(plugMenuId, subViewId));
- }
-}
-
-int cSDPluginManager::GetSubviewId(int plugId, int plugMenuId) {
- map <int, map<int,int> >::iterator hit = subViewMapping.find(plugId);
- if (hit == subViewMapping.end())
- return -1;
- map<int,int>::iterator hit2 = (hit->second).find(plugMenuId);
- if (hit2 == (hit->second).end())
- return -1;
- return hit2->second;
-}
-
-void cSDPluginManager::RegisterAdvancedPlugin(skindesignerapi::cPluginStructure *plugStructure) {
- dsyslog("skindesigner: plugin %s uses libskindesigner API Version %s",
- plugStructure->name.c_str(),
- plugStructure->libskindesignerAPIVersion.c_str());
- plugStructure->id = lastId;
- registeredPlugins.insert(pair<int,string>(lastId, plugStructure->name));
- lastId++;
-
- rootviews.insert(pair<int,string>(plugStructure->id, plugStructure->rootview));
- subviews.insert(pair<int,map<int,string> >(plugStructure->id, plugStructure->subviews));
-
- multimap< int, skindesignerapi::sPlugViewElement > viewelementsNew;
- for (map< int, skindesignerapi::sPlugViewElement >::iterator it = plugStructure->viewelements.begin(); it != plugStructure->viewelements.end(); it++) {
- int key = it->first;
- skindesignerapi::sPlugViewElement ve = it->second;
- skindesignerapi::sPlugViewElement veNew;
- veNew.id = ve.id;
- veNew.viewId = ve.viewId;
- veNew.name = ve.name;
- veNew.tokenContainer = new skindesignerapi::cTokenContainer(*ve.tokenContainer);
- viewelementsNew.insert(pair<int, skindesignerapi::sPlugViewElement>(key, veNew));
- }
- viewelements.insert(pair< int, multimap < int, skindesignerapi::sPlugViewElement > >(plugStructure->id, viewelementsNew));
-
- multimap< int, skindesignerapi::sPlugViewGrid > viewgridsNew;
- for (map< int, skindesignerapi::sPlugViewGrid >::iterator it = plugStructure->viewgrids.begin(); it != plugStructure->viewgrids.end(); it++) {
- int key = it->first;
- skindesignerapi::sPlugViewGrid vg = it->second;
- skindesignerapi::sPlugViewGrid vgNew;
- vgNew.id = vg.id;
- vgNew.viewId = vg.viewId;
- vgNew.name = vg.name;
- vgNew.tokenContainer = new skindesignerapi::cTokenContainer(*vg.tokenContainer);
- viewgridsNew.insert(pair<int, skindesignerapi::sPlugViewGrid>(key, vgNew));
- }
- viewgrids.insert(pair< int, multimap < int, skindesignerapi::sPlugViewGrid > >(plugStructure->id, viewgridsNew));
-
- map< int, skindesignerapi::cTokenContainer* > viewtabsNew;
- for (map<int,skindesignerapi::cTokenContainer*>::iterator it = plugStructure->viewtabs.begin(); it != plugStructure->viewtabs.end(); it++) {
- int id = it->first;
- skindesignerapi::cTokenContainer *tk = it->second;
- viewtabsNew.insert(pair<int,skindesignerapi::cTokenContainer*>(id, new skindesignerapi::cTokenContainer(*tk)));
- }
- viewtabs.insert(pair< int, map<int,skindesignerapi::cTokenContainer*> >(plugStructure->id, viewtabsNew));
-
- if (plugStructure->rootview.size() > 0)
- dsyslog("skindesigner: plugin %s has registered %ld views with %ld viewelements and %ld viewgrids",
- plugStructure->name.c_str(),
- 1 + plugStructure->subviews.size(),
- plugStructure->viewelements.size(),
- plugStructure->viewgrids.size());
-}
-
-void cSDPluginManager::InitPluginViewIterator(void) {
- rootViewsIt = rootviews.begin();
-}
-
-bool cSDPluginManager::GetNextPluginView(string &plugName, int &plugId, string &tplName) {
- if (rootViewsIt == rootviews.end())
- return false;
- plugId = rootViewsIt->first;
- tplName = rootViewsIt->second;
- map<int,string>::iterator hit = registeredPlugins.find(plugId);
- if (hit != registeredPlugins.end())
- plugName = hit->second;
- rootViewsIt++;
- return true;
-}
-
-int cSDPluginManager::GetNumSubviews(int plugId) {
- map< int, map< int, string > >::iterator hit = subviews.find(plugId);
- if (hit == subviews.end())
- return 0;
- return (hit->second).size();
-}
-
-void cSDPluginManager::InitPluginSubviewIterator(int plugId) {
- map< int, map< int, string > >::iterator hit = subviews.find(plugId);
- if (hit == subviews.end()) {
- subviewsfound = false;
- return;
- }
- subviewsCurrent = hit->second;
- subviewsfound = true;
- svIt = subviewsCurrent.begin();
-}
-
-bool cSDPluginManager::GetNextSubView(int &id, string &tplname) {
- if (!subviewsfound)
- return false;
- if( svIt == subviewsCurrent.end() ) {
- return false;
- }
- id = svIt->first;
- tplname = svIt->second;
- svIt++;
- return true;
-}
-
-int cSDPluginManager::GetNumViewElements(int plugId, int viewId) {
- map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
- if (hit == viewelements.end())
- return 0;
- multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
- pair<multimap<int, skindesignerapi::sPlugViewElement>::iterator, multimap<int, skindesignerapi::sPlugViewElement>::iterator> range;
- range = plugVEs->equal_range(viewId);
- int numVEs = 0;
- for (multimap<int, skindesignerapi::sPlugViewElement>::iterator it=range.first; it!=range.second; ++it) {
- numVEs++;
- }
- return numVEs;
-}
-
-void cSDPluginManager::InitViewElementIterator(int plugId, int viewId) {
- map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
- if (hit == viewelements.end())
- return;
- multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
- veRange = plugVEs->equal_range(viewId);
- veIt = veRange.first;
-}
-
-bool cSDPluginManager::GetNextViewElement(int &veId, string &veName) {
- if (veIt == veRange.second)
- return false;
- skindesignerapi::sPlugViewElement *ve = &veIt->second;
- veId = ve->id;
- veName = ve->name;
- veIt++;
- return true;
-}
-
-skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerVE(int plugId, int viewId, int veId) {
- map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
- if (hit == viewelements.end())
- return NULL;
- multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
- for (multimap<int, skindesignerapi::sPlugViewElement>::iterator it = plugVEs->begin(); it != plugVEs->end(); it++) {
- int view = it->first;
- if (view != viewId)
- continue;
- skindesignerapi::sPlugViewElement *ve = &it->second;
- if (ve->id == veId)
- return ve->tokenContainer;
- }
- return NULL;
-}
-
-int cSDPluginManager::GetNumViewGrids(int plugId, int viewId) {
- map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
- if (hit == viewgrids.end())
- return 0;
- multimap<int, skindesignerapi::sPlugViewGrid> *plugVGs = &hit->second;
- pair<multimap<int, skindesignerapi::sPlugViewGrid>::iterator, multimap<int, skindesignerapi::sPlugViewGrid>::iterator> range;
- range = plugVGs->equal_range(viewId);
- int numVGs = 0;
- for (multimap<int, skindesignerapi::sPlugViewGrid>::iterator it=range.first; it!=range.second; ++it) {
- numVGs++;
- }
- return numVGs;
-}
-
-void cSDPluginManager::InitViewGridIterator(int plugId, int viewId) {
- map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
- if (hit == viewgrids.end())
- return;
- multimap<int, skindesignerapi::sPlugViewGrid> *plugGEs = &hit->second;
- gRange = plugGEs->equal_range(viewId);
- gIt = gRange.first;
-}
-
-bool cSDPluginManager::GetNextViewGrid(int &gId, string &gName) {
- if (gIt == gRange.second)
- return false;
- skindesignerapi::sPlugViewGrid *ge = &gIt->second;
- gId = ge->id;
- gName = ge->name;
- gIt++;
- return true;
-}
-
-skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerGE(int plugId, int viewId, int gId) {
- map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
- if (hit == viewgrids.end())
- return NULL;
- multimap<int, skindesignerapi::sPlugViewGrid> *plugGEs = &hit->second;
- for (multimap<int, skindesignerapi::sPlugViewGrid>::iterator it = plugGEs->begin(); it != plugGEs->end(); it++) {
- int view = it->first;
- if (view != viewId)
- continue;
- skindesignerapi::sPlugViewGrid *g = &it->second;
- if (g->id == gId)
- return g->tokenContainer;
- }
- return NULL;
-}
-
-skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerTab(int plugId, int viewId) {
- map< int, map< int, skindesignerapi::cTokenContainer* > >::iterator hit = viewtabs.find(plugId);
- if (hit == viewtabs.end())
- return NULL;
- map< int, skindesignerapi::cTokenContainer* > *tabs = &hit->second;
- map< int, skindesignerapi::cTokenContainer* >::iterator hit2 = tabs->find(viewId);
- if (hit2 == tabs->end())
- return NULL;
- return (hit2->second);
-}
+#include "pluginmanager.h"
+
+cSDPluginManager::cSDPluginManager(void) {
+ lastId = 0;
+ subviewsfound = false;
+}
+
+cSDPluginManager::~cSDPluginManager(void) {
+}
+
+void cSDPluginManager::Reset(void) {
+ subViewMapping.clear();
+}
+
+void cSDPluginManager::RegisterBasicPlugin(skindesignerapi::cPluginStructure *plugStructure) {
+ dsyslog("skindesigner: plugin %s uses libskindesigner API Version %s",
+ plugStructure->name.c_str(),
+ plugStructure->libskindesignerAPIVersion.c_str());
+ plugStructure->id = lastId;
+ registeredPlugins.insert(pair<int,string>(lastId, plugStructure->name));
+ lastId++;
+ map< int, skindesignerapi::sPlugMenu > menusNew;
+ for (map< int, skindesignerapi::sPlugMenu >::iterator it = plugStructure->menus.begin(); it != plugStructure->menus.end(); it++) {
+ int key = it->first;
+ skindesignerapi::sPlugMenu menu = it->second;
+ skindesignerapi::sPlugMenu menuNew;
+ menuNew.type = menu.type;
+ menuNew.tplname = menu.tplname;
+ menuNew.tokenContainer = new skindesignerapi::cTokenContainer(*menu.tokenContainer);
+ menusNew.insert(pair<int, skindesignerapi::sPlugMenu>(key, menuNew));
+ }
+ pluginMenus.insert(pair< int, map < int, skindesignerapi::sPlugMenu > >(plugStructure->id, menusNew));
+
+ if (plugStructure->menus.size() > 0)
+ dsyslog("skindesigner: plugin %s has registered %ld menus", plugStructure->name.c_str(), plugStructure->menus.size());
+
+}
+
+int cSDPluginManager::GetNumPluginMenus(void) {
+ int numMenusTotal = 0;
+ for (map < int, map < int, skindesignerapi::sPlugMenu > >::iterator it = pluginMenus.begin(); it != pluginMenus.end(); it++) {
+ numMenusTotal += (it->second).size();
+ }
+ return numMenusTotal;
+}
+
+void cSDPluginManager::InitPluginMenuIterator(void) {
+ plugMenuIt = pluginMenus.begin();
+}
+
+map <int,skindesignerapi::sPlugMenu> *cSDPluginManager::GetPluginMenus(string &name, int &id) {
+ if (plugMenuIt == pluginMenus.end())
+ return NULL;
+ id = plugMenuIt->first;
+ map<int,string>::iterator hit = registeredPlugins.find(id);
+ if (hit != registeredPlugins.end())
+ name = hit->second;
+ map <int,skindesignerapi::sPlugMenu> *templates = &plugMenuIt->second;
+ plugMenuIt++;
+ return templates;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainer(int plugId, int plugMenuId) {
+ map <int, map<int, skindesignerapi::sPlugMenu> >::iterator hit = pluginMenus.find(plugId);
+ if (hit == pluginMenus.end())
+ return NULL;
+ map<int, skindesignerapi::sPlugMenu>::iterator hit2 = (hit->second).find(plugMenuId);
+ if (hit2 == (hit->second).end())
+ return NULL;
+ skindesignerapi::cTokenContainer *tk = hit2->second.tokenContainer;
+ return tk;
+}
+
+void cSDPluginManager::AddSubviewMapping(int plugId, int plugMenuId, int subViewId) {
+ map <int, map<int,int> >::iterator hit = subViewMapping.find(plugId);
+ if (hit == subViewMapping.end()) {
+ map<int,int> menus;
+ menus.insert(pair<int,int>(plugMenuId, subViewId));
+ subViewMapping.insert(pair<int, map<int,int> >(plugId, menus));
+ } else {
+ (hit->second).insert(pair<int,int>(plugMenuId, subViewId));
+ }
+}
+
+int cSDPluginManager::GetSubviewId(int plugId, int plugMenuId) {
+ map <int, map<int,int> >::iterator hit = subViewMapping.find(plugId);
+ if (hit == subViewMapping.end())
+ return -1;
+ map<int,int>::iterator hit2 = (hit->second).find(plugMenuId);
+ if (hit2 == (hit->second).end())
+ return -1;
+ return hit2->second;
+}
+
+void cSDPluginManager::RegisterAdvancedPlugin(skindesignerapi::cPluginStructure *plugStructure) {
+ dsyslog("skindesigner: plugin %s uses libskindesigner API Version %s",
+ plugStructure->name.c_str(),
+ plugStructure->libskindesignerAPIVersion.c_str());
+ plugStructure->id = lastId;
+ registeredPlugins.insert(pair<int,string>(lastId, plugStructure->name));
+ lastId++;
+
+ rootviews.insert(pair<int,string>(plugStructure->id, plugStructure->rootview));
+ subviews.insert(pair<int,map<int,string> >(plugStructure->id, plugStructure->subviews));
+
+ multimap< int, skindesignerapi::sPlugViewElement > viewelementsNew;
+ for (map< int, skindesignerapi::sPlugViewElement >::iterator it = plugStructure->viewelements.begin(); it != plugStructure->viewelements.end(); it++) {
+ int key = it->first;
+ skindesignerapi::sPlugViewElement ve = it->second;
+ skindesignerapi::sPlugViewElement veNew;
+ veNew.id = ve.id;
+ veNew.viewId = ve.viewId;
+ veNew.name = ve.name;
+ veNew.tokenContainer = new skindesignerapi::cTokenContainer(*ve.tokenContainer);
+ viewelementsNew.insert(pair<int, skindesignerapi::sPlugViewElement>(key, veNew));
+ }
+ viewelements.insert(pair< int, multimap < int, skindesignerapi::sPlugViewElement > >(plugStructure->id, viewelementsNew));
+
+ multimap< int, skindesignerapi::sPlugViewGrid > viewgridsNew;
+ for (map< int, skindesignerapi::sPlugViewGrid >::iterator it = plugStructure->viewgrids.begin(); it != plugStructure->viewgrids.end(); it++) {
+ int key = it->first;
+ skindesignerapi::sPlugViewGrid vg = it->second;
+ skindesignerapi::sPlugViewGrid vgNew;
+ vgNew.id = vg.id;
+ vgNew.viewId = vg.viewId;
+ vgNew.name = vg.name;
+ vgNew.tokenContainer = new skindesignerapi::cTokenContainer(*vg.tokenContainer);
+ viewgridsNew.insert(pair<int, skindesignerapi::sPlugViewGrid>(key, vgNew));
+ }
+ viewgrids.insert(pair< int, multimap < int, skindesignerapi::sPlugViewGrid > >(plugStructure->id, viewgridsNew));
+
+ map< int, skindesignerapi::cTokenContainer* > viewtabsNew;
+ for (map<int,skindesignerapi::cTokenContainer*>::iterator it = plugStructure->viewtabs.begin(); it != plugStructure->viewtabs.end(); it++) {
+ int id = it->first;
+ skindesignerapi::cTokenContainer *tk = it->second;
+ viewtabsNew.insert(pair<int,skindesignerapi::cTokenContainer*>(id, new skindesignerapi::cTokenContainer(*tk)));
+ }
+ viewtabs.insert(pair< int, map<int,skindesignerapi::cTokenContainer*> >(plugStructure->id, viewtabsNew));
+
+ if (plugStructure->rootview.size() > 0)
+ dsyslog("skindesigner: plugin %s has registered %ld views with %ld viewelements and %ld viewgrids",
+ plugStructure->name.c_str(),
+ 1 + plugStructure->subviews.size(),
+ plugStructure->viewelements.size(),
+ plugStructure->viewgrids.size());
+}
+
+void cSDPluginManager::InitPluginViewIterator(void) {
+ rootViewsIt = rootviews.begin();
+}
+
+bool cSDPluginManager::GetNextPluginView(string &plugName, int &plugId, string &tplName) {
+ if (rootViewsIt == rootviews.end())
+ return false;
+ plugId = rootViewsIt->first;
+ tplName = rootViewsIt->second;
+ map<int,string>::iterator hit = registeredPlugins.find(plugId);
+ if (hit != registeredPlugins.end())
+ plugName = hit->second;
+ rootViewsIt++;
+ return true;
+}
+
+int cSDPluginManager::GetNumSubviews(int plugId) {
+ map< int, map< int, string > >::iterator hit = subviews.find(plugId);
+ if (hit == subviews.end())
+ return 0;
+ return (hit->second).size();
+}
+
+void cSDPluginManager::InitPluginSubviewIterator(int plugId) {
+ map< int, map< int, string > >::iterator hit = subviews.find(plugId);
+ if (hit == subviews.end()) {
+ subviewsfound = false;
+ return;
+ }
+ subviewsCurrent = hit->second;
+ subviewsfound = true;
+ svIt = subviewsCurrent.begin();
+}
+
+bool cSDPluginManager::GetNextSubView(int &id, string &tplname) {
+ if (!subviewsfound)
+ return false;
+ if( svIt == subviewsCurrent.end() ) {
+ return false;
+ }
+ id = svIt->first;
+ tplname = svIt->second;
+ svIt++;
+ return true;
+}
+
+int cSDPluginManager::GetNumViewElements(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
+ if (hit == viewelements.end())
+ return 0;
+ multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
+ pair<multimap<int, skindesignerapi::sPlugViewElement>::iterator, multimap<int, skindesignerapi::sPlugViewElement>::iterator> range;
+ range = plugVEs->equal_range(viewId);
+ int numVEs = 0;
+ for (multimap<int, skindesignerapi::sPlugViewElement>::iterator it=range.first; it!=range.second; ++it) {
+ numVEs++;
+ }
+ return numVEs;
+}
+
+void cSDPluginManager::InitViewElementIterator(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
+ if (hit == viewelements.end())
+ return;
+ multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
+ veRange = plugVEs->equal_range(viewId);
+ veIt = veRange.first;
+}
+
+bool cSDPluginManager::GetNextViewElement(int &veId, string &veName) {
+ if (veIt == veRange.second)
+ return false;
+ skindesignerapi::sPlugViewElement *ve = &veIt->second;
+ veId = ve->id;
+ veName = ve->name;
+ veIt++;
+ return true;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerVE(int plugId, int viewId, int veId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
+ if (hit == viewelements.end())
+ return NULL;
+ multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
+ for (multimap<int, skindesignerapi::sPlugViewElement>::iterator it = plugVEs->begin(); it != plugVEs->end(); it++) {
+ int view = it->first;
+ if (view != viewId)
+ continue;
+ skindesignerapi::sPlugViewElement *ve = &it->second;
+ if (ve->id == veId)
+ return ve->tokenContainer;
+ }
+ return NULL;
+}
+
+int cSDPluginManager::GetNumViewGrids(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
+ if (hit == viewgrids.end())
+ return 0;
+ multimap<int, skindesignerapi::sPlugViewGrid> *plugVGs = &hit->second;
+ pair<multimap<int, skindesignerapi::sPlugViewGrid>::iterator, multimap<int, skindesignerapi::sPlugViewGrid>::iterator> range;
+ range = plugVGs->equal_range(viewId);
+ int numVGs = 0;
+ for (multimap<int, skindesignerapi::sPlugViewGrid>::iterator it=range.first; it!=range.second; ++it) {
+ numVGs++;
+ }
+ return numVGs;
+}
+
+void cSDPluginManager::InitViewGridIterator(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
+ if (hit == viewgrids.end())
+ return;
+ multimap<int, skindesignerapi::sPlugViewGrid> *plugGEs = &hit->second;
+ gRange = plugGEs->equal_range(viewId);
+ gIt = gRange.first;
+}
+
+bool cSDPluginManager::GetNextViewGrid(int &gId, string &gName) {
+ if (gIt == gRange.second)
+ return false;
+ skindesignerapi::sPlugViewGrid *ge = &gIt->second;
+ gId = ge->id;
+ gName = ge->name;
+ gIt++;
+ return true;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerGE(int plugId, int viewId, int gId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
+ if (hit == viewgrids.end())
+ return NULL;
+ multimap<int, skindesignerapi::sPlugViewGrid> *plugGEs = &hit->second;
+ for (multimap<int, skindesignerapi::sPlugViewGrid>::iterator it = plugGEs->begin(); it != plugGEs->end(); it++) {
+ int view = it->first;
+ if (view != viewId)
+ continue;
+ skindesignerapi::sPlugViewGrid *g = &it->second;
+ if (g->id == gId)
+ return g->tokenContainer;
+ }
+ return NULL;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerTab(int plugId, int viewId) {
+ map< int, map< int, skindesignerapi::cTokenContainer* > >::iterator hit = viewtabs.find(plugId);
+ if (hit == viewtabs.end())
+ return NULL;
+ map< int, skindesignerapi::cTokenContainer* > *tabs = &hit->second;
+ map< int, skindesignerapi::cTokenContainer* >::iterator hit2 = tabs->find(viewId);
+ if (hit2 == tabs->end())
+ return NULL;
+ return (hit2->second);
+}
diff --git a/extensions/pluginmanager.h b/extensions/pluginmanager.h
index a3790ad..337347f 100644
--- a/extensions/pluginmanager.h
+++ b/extensions/pluginmanager.h
@@ -1,71 +1,71 @@
-#ifndef __PLUGINMANAGER_H
-#define __PLUGINMANAGER_H
-
-#include <string>
-#include <map>
-#include "../libskindesignerapi/skindesignerapi.h"
-
-using namespace std;
-
-class cSDPluginManager {
-private:
- int lastId;
- //plugin id --> plugin name
- map < int, string > registeredPlugins;
- //Basic Plugin Interface
- //plugin id --> plugin definition
- map < int, map < int, skindesignerapi::sPlugMenu > > pluginMenus;
- map < int, map < int, skindesignerapi::sPlugMenu > >::iterator plugMenuIt;
- //plugin id - menuId --> subviewid
- map < int, map<int, int> > subViewMapping;
-
- //Advanced Plugin Interface
- //plugin id --> rootview templatename definition
- map< int, string > rootviews;
- map< int, string >::iterator rootViewsIt;
- //plugin id --> subviewid /templatename definition
- map< int, map< int, string > > subviews;
- map< int, string> subviewsCurrent;
- map< int, string>::iterator svIt;
- bool subviewsfound;
- //plugin id --> view id --> viewelement definition
- map< int, multimap< int, skindesignerapi::sPlugViewElement > > viewelements;
- pair<multimap<int, skindesignerapi::sPlugViewElement>::iterator, multimap<int, skindesignerapi::sPlugViewElement>::iterator> veRange;
- multimap<int, skindesignerapi::sPlugViewElement>::iterator veIt;
- //plugin id --> view id --> viewgrid definition
- map< int, multimap< int, skindesignerapi::sPlugViewGrid > > viewgrids;
- pair<multimap<int, skindesignerapi::sPlugViewGrid>::iterator, multimap<int, skindesignerapi::sPlugViewGrid>::iterator> gRange;
- multimap<int, skindesignerapi::sPlugViewGrid>::iterator gIt;
- //plugin id --> view id --> tokencontainer of detailedview definition
- map< int, map< int, skindesignerapi::cTokenContainer* > > viewtabs;
-public:
- cSDPluginManager(void);
- ~cSDPluginManager(void);
- void Reset(void);
- //Basic Plugin Interface
- void RegisterBasicPlugin(skindesignerapi::cPluginStructure *plugStructure);
- int GetNumPluginMenus(void);
- void InitPluginMenuIterator(void);
- map <int,skindesignerapi::sPlugMenu> *GetPluginMenus(string &name, int &id);
- skindesignerapi::cTokenContainer *GetTokenContainer(int plugId, int plugMenuId);
- void AddSubviewMapping(int plugId, int plugMenuId, int subViewId);
- int GetSubviewId(int plugId, int plugMenuId);
- //Advanced Plugin Interface
- void RegisterAdvancedPlugin(skindesignerapi::cPluginStructure *plugStructure);
- void InitPluginViewIterator(void);
- bool GetNextPluginView(string &plugName, int &plugId, string &tplName);
- int GetNumSubviews(int plugId);
- void InitPluginSubviewIterator(int plugId);
- bool GetNextSubView(int &id, string &tplname);
- int GetNumViewElements(int plugId, int viewId);
- void InitViewElementIterator(int plugId, int viewId);
- bool GetNextViewElement(int &veId, string &veName);
- skindesignerapi::cTokenContainer *GetTokenContainerVE(int plugId, int viewId, int veId);
- int GetNumViewGrids(int plugId, int viewId);
- void InitViewGridIterator(int plugId, int viewId);
- bool GetNextViewGrid(int &gId, string &gName);
- skindesignerapi::cTokenContainer *GetTokenContainerGE(int plugId, int viewId, int gId);
- skindesignerapi::cTokenContainer *GetTokenContainerTab(int plugId, int viewId);
-};
-
-#endif //__PLUGINMANAGER_H
+#ifndef __PLUGINMANAGER_H
+#define __PLUGINMANAGER_H
+
+#include <string>
+#include <map>
+#include "../libskindesignerapi/skindesignerapi.h"
+
+using namespace std;
+
+class cSDPluginManager {
+private:
+ int lastId;
+ //plugin id --> plugin name
+ map < int, string > registeredPlugins;
+ //Basic Plugin Interface
+ //plugin id --> plugin definition
+ map < int, map < int, skindesignerapi::sPlugMenu > > pluginMenus;
+ map < int, map < int, skindesignerapi::sPlugMenu > >::iterator plugMenuIt;
+ //plugin id - menuId --> subviewid
+ map < int, map<int, int> > subViewMapping;
+
+ //Advanced Plugin Interface
+ //plugin id --> rootview templatename definition
+ map< int, string > rootviews;
+ map< int, string >::iterator rootViewsIt;
+ //plugin id --> subviewid /templatename definition
+ map< int, map< int, string > > subviews;
+ map< int, string> subviewsCurrent;
+ map< int, string>::iterator svIt;
+ bool subviewsfound;
+ //plugin id --> view id --> viewelement definition
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > > viewelements;
+ pair<multimap<int, skindesignerapi::sPlugViewElement>::iterator, multimap<int, skindesignerapi::sPlugViewElement>::iterator> veRange;
+ multimap<int, skindesignerapi::sPlugViewElement>::iterator veIt;
+ //plugin id --> view id --> viewgrid definition
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > > viewgrids;
+ pair<multimap<int, skindesignerapi::sPlugViewGrid>::iterator, multimap<int, skindesignerapi::sPlugViewGrid>::iterator> gRange;
+ multimap<int, skindesignerapi::sPlugViewGrid>::iterator gIt;
+ //plugin id --> view id --> tokencontainer of detailedview definition
+ map< int, map< int, skindesignerapi::cTokenContainer* > > viewtabs;
+public:
+ cSDPluginManager(void);
+ ~cSDPluginManager(void);
+ void Reset(void);
+ //Basic Plugin Interface
+ void RegisterBasicPlugin(skindesignerapi::cPluginStructure *plugStructure);
+ int GetNumPluginMenus(void);
+ void InitPluginMenuIterator(void);
+ map <int,skindesignerapi::sPlugMenu> *GetPluginMenus(string &name, int &id);
+ skindesignerapi::cTokenContainer *GetTokenContainer(int plugId, int plugMenuId);
+ void AddSubviewMapping(int plugId, int plugMenuId, int subViewId);
+ int GetSubviewId(int plugId, int plugMenuId);
+ //Advanced Plugin Interface
+ void RegisterAdvancedPlugin(skindesignerapi::cPluginStructure *plugStructure);
+ void InitPluginViewIterator(void);
+ bool GetNextPluginView(string &plugName, int &plugId, string &tplName);
+ int GetNumSubviews(int plugId);
+ void InitPluginSubviewIterator(int plugId);
+ bool GetNextSubView(int &id, string &tplname);
+ int GetNumViewElements(int plugId, int viewId);
+ void InitViewElementIterator(int plugId, int viewId);
+ bool GetNextViewElement(int &veId, string &veName);
+ skindesignerapi::cTokenContainer *GetTokenContainerVE(int plugId, int viewId, int veId);
+ int GetNumViewGrids(int plugId, int viewId);
+ void InitViewGridIterator(int plugId, int viewId);
+ bool GetNextViewGrid(int &gId, string &gName);
+ skindesignerapi::cTokenContainer *GetTokenContainerGE(int plugId, int viewId, int gId);
+ skindesignerapi::cTokenContainer *GetTokenContainerTab(int plugId, int viewId);
+};
+
+#endif //__PLUGINMANAGER_H
diff --git a/extensions/scrapmanager.c b/extensions/scrapmanager.c
index 8452d75..c1fd69f 100644
--- a/extensions/scrapmanager.c
+++ b/extensions/scrapmanager.c
@@ -1,359 +1,359 @@
-#include "scrapmanager.h"
-#include "../coreengine/definitions.h"
-#include "helpers.h"
-
-cPlugin *cScrapManager::pScraper = NULL;
-
-cScrapManager::cScrapManager(void) {
- if (!pScraper) {
- pScraper = GetScraperPlugin();
- }
- movie = NULL;
- series = NULL;
-}
-
-cScrapManager::~cScrapManager(void) {
- delete movie;
- delete series;
-}
-
-bool cScrapManager::LoadFullScrapInfo(const cEvent *event, const cRecording *recording) {
- if (!pScraper) {
- return false;
- }
- delete movie;
- movie = NULL;
- delete series;
- series = NULL;
-
- ScraperGetEventType getType;
- getType.event = event;
- getType.recording = recording;
- if (!pScraper->Service("GetEventType", &getType)) {
- return false;
- }
- if (getType.type == tMovie) {
- movie = new cMovie();
- movie->movieId = getType.movieId;
- pScraper->Service("GetMovie", movie);
- return true;
- } else if (getType.type == tSeries) {
- series = new cSeries();
- series->seriesId = getType.seriesId;
- series->episodeId = getType.episodeId;
- pScraper->Service("GetSeries", series);
- return true;
- }
- return false;
-}
-
-void cScrapManager::SetFullScrapInfo(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
- if (series) {
- tk->AddIntToken((int)eScraperIT::ismovie, 0);
- tk->AddIntToken((int)eScraperIT::isseries, 1);
- SetSeries(tk, actorsIndex);
- } else if (movie) {
- tk->AddIntToken((int)eScraperIT::ismovie, 1);
- tk->AddIntToken((int)eScraperIT::isseries, 0);
- SetMovie(tk, actorsIndex);
- } else {
- tk->AddIntToken((int)eScraperIT::ismovie, 0);
- tk->AddIntToken((int)eScraperIT::isseries, 0);
- }
-}
-
-
-int cScrapManager::NumActors(void) {
- if (series) {
- return series->actors.size();
- } else if (movie) {
- return movie->actors.size();
- }
- return 0;
-}
-
-void cScrapManager::SetHeaderScrapInfo(skindesignerapi::cTokenContainer *tk) {
- if (series) {
- tk->AddIntToken((int)eScraperHeaderIT::ismovie, 0);
- tk->AddIntToken((int)eScraperHeaderIT::isseries, 1);
- vector<cTvMedia>::iterator poster = series->posters.begin();
- if (poster != series->posters.end()) {
- tk->AddIntToken((int)eScraperHeaderIT::posteravailable, true);
- tk->AddIntToken((int)eScraperHeaderIT::posterwidth, (*poster).width);
- tk->AddIntToken((int)eScraperHeaderIT::posterheight, (*poster).height);
- tk->AddStringToken((int)eScraperHeaderST::posterpath, (*poster).path.c_str());
- }
- vector<cTvMedia>::iterator banner = series->banners.begin();
- if (banner != series->banners.end()) {
- tk->AddIntToken((int)eScraperHeaderIT::banneravailable, true);
- tk->AddIntToken((int)eScraperHeaderIT::bannerwidth, (*banner).width);
- tk->AddIntToken((int)eScraperHeaderIT::bannerheight, (*banner).height);
- tk->AddStringToken((int)eScraperHeaderST::bannerpath, (*banner).path.c_str());
- }
- } else if (movie) {
- tk->AddIntToken((int)eScraperHeaderIT::ismovie, 1);
- tk->AddIntToken((int)eScraperHeaderIT::isseries, 0);
- tk->AddIntToken((int)eScraperHeaderIT::posteravailable, true);
- tk->AddIntToken((int)eScraperHeaderIT::banneravailable, false);
- tk->AddIntToken((int)eScraperHeaderIT::posterwidth, movie->poster.width);
- tk->AddIntToken((int)eScraperHeaderIT::posterheight, movie->poster.height);
- tk->AddStringToken((int)eScraperHeaderST::posterpath, movie->poster.path.c_str());
- } else {
- tk->AddIntToken((int)eScraperHeaderIT::ismovie, 0);
- tk->AddIntToken((int)eScraperHeaderIT::isseries, 0);
- }
-}
-
-void cScrapManager::SetScraperPosterBanner(skindesignerapi::cTokenContainer *tk) {
- if (movie) {
- tk->AddIntToken((int)eCeMenuSchedulesIT::hasposter, 1);
- tk->AddStringToken((int)eCeMenuSchedulesST::posterpath, movie->poster.path.c_str());
- tk->AddIntToken((int)eCeMenuSchedulesIT::posterwidth, movie->poster.width);
- tk->AddIntToken((int)eCeMenuSchedulesIT::posterheight, movie->poster.height);
- } else if (series) {
- vector<cTvMedia>::iterator poster = series->posters.begin();
- if (poster != series->posters.end()) {
- tk->AddIntToken((int)eCeMenuSchedulesIT::hasposter, 1);
- tk->AddIntToken((int)eCeMenuSchedulesIT::posterwidth, (*poster).width);
- tk->AddIntToken((int)eCeMenuSchedulesIT::posterheight, (*poster).height);
- tk->AddStringToken((int)eCeMenuSchedulesST::posterpath, (*poster).path.c_str());
- }
- vector<cTvMedia>::iterator banner = series->banners.begin();
- if (banner != series->banners.end()) {
- tk->AddIntToken((int)eCeMenuSchedulesIT::hasbanner, 1);
- tk->AddIntToken((int)eCeMenuSchedulesIT::bannerwidth, (*banner).width);
- tk->AddIntToken((int)eCeMenuSchedulesIT::bannerheight, (*banner).height);
- tk->AddStringToken((int)eCeMenuSchedulesST::bannerpath, (*banner).path.c_str());
- }
- }
-}
-
-void cScrapManager::SetScraperRecordingPoster(skindesignerapi::cTokenContainer *tk, const cRecording *recording, bool isListElement) {
- if (!pScraper) {
- return;
- }
- ScraperGetPosterThumb call;
- call.event = NULL;
- call.recording = recording;
- if (pScraper->Service("GetPosterThumb", &call)) {
- if (isListElement) {
- tk->AddIntToken((int)eLeMenuRecordingsIT::hasposterthumbnail, FileExists(call.poster.path));
- tk->AddIntToken((int)eLeMenuRecordingsIT::thumbnailwidth, call.poster.width);
- tk->AddIntToken((int)eLeMenuRecordingsIT::thumbnailheight, call.poster.height);
- tk->AddStringToken((int)eLeMenuRecordingsST::thumbnailpath, call.poster.path.c_str());
- } else {
- tk->AddIntToken((int)eCeMenuRecordingsIT::hasposterthumbnail, FileExists(call.poster.path));
- tk->AddIntToken((int)eCeMenuRecordingsIT::thumbnailwidth, call.poster.width);
- tk->AddIntToken((int)eCeMenuRecordingsIT::thumbnailheight, call.poster.height);
- tk->AddStringToken((int)eCeMenuRecordingsST::thumbnailpath, call.poster.path.c_str());
- }
- }
-
- ScraperGetPoster call2;
- call2.event = NULL;
- call2.recording = recording;
- if (pScraper->Service("GetPoster", &call2)) {
- if (isListElement) {
- tk->AddIntToken((int)eLeMenuRecordingsIT::hasposter, FileExists(call2.poster.path));
- tk->AddIntToken((int)eLeMenuRecordingsIT::posterwidth, call2.poster.width);
- tk->AddIntToken((int)eLeMenuRecordingsIT::posterheight, call2.poster.height);
- tk->AddStringToken((int)eLeMenuRecordingsST::posterpath, call2.poster.path.c_str());
- } else {
- tk->AddIntToken((int)eCeMenuRecordingsIT::hasposter, FileExists(call2.poster.path));
- tk->AddIntToken((int)eCeMenuRecordingsIT::posterwidth, call2.poster.width);
- tk->AddIntToken((int)eCeMenuRecordingsIT::posterheight, call2.poster.height);
- tk->AddStringToken((int)eCeMenuRecordingsST::posterpath, call2.poster.path.c_str());
- }
- }
-}
-
-cPlugin *cScrapManager::GetScraperPlugin(void) {
- static cPlugin *pScraper = cPluginManager::GetPlugin("scraper2vdr");
- if( !pScraper ) // if it doesn't exit, try tvscraper
- pScraper = cPluginManager::GetPlugin("tvscraper");
- return pScraper;
-}
-
-void cScrapManager::SetMovie(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
- tk->AddStringToken((int)eScraperST::movietitle, movie->title.c_str());
- tk->AddStringToken((int)eScraperST::movieoriginalTitle, movie->originalTitle.c_str());
- tk->AddStringToken((int)eScraperST::movietagline, movie->tagline.c_str());
- tk->AddStringToken((int)eScraperST::movieoverview, movie->overview.c_str());
- tk->AddStringToken((int)eScraperST::moviegenres, movie->genres.c_str());
- tk->AddStringToken((int)eScraperST::moviehomepage, movie->homepage.c_str());
- tk->AddStringToken((int)eScraperST::moviereleasedate, movie->releaseDate.c_str());
- tk->AddStringToken((int)eScraperST::moviepopularity, *cString::sprintf("%f", movie->popularity));
- tk->AddStringToken((int)eScraperST::movievoteaverage, *cString::sprintf("%f", movie->voteAverage));
- tk->AddStringToken((int)eScraperST::posterpath, movie->poster.path.c_str());
- tk->AddStringToken((int)eScraperST::fanartpath, movie->fanart.path.c_str());
- tk->AddStringToken((int)eScraperST::collectionposterpath, movie->collectionPoster.path.c_str());
- tk->AddStringToken((int)eScraperST::collectionfanartpath, movie->collectionFanart.path.c_str());
- tk->AddIntToken((int)eScraperIT::movieadult, movie->adult);
- tk->AddIntToken((int)eScraperIT::moviebudget, movie->budget);
- tk->AddIntToken((int)eScraperIT::movierevenue, movie->revenue);
- tk->AddIntToken((int)eScraperIT::movieruntime, movie->runtime);
- tk->AddIntToken((int)eScraperIT::posterwidth, movie->poster.width);
- tk->AddIntToken((int)eScraperIT::posterheight, movie->poster.height);
- tk->AddIntToken((int)eScraperIT::fanartwidth, movie->fanart.width);
- tk->AddIntToken((int)eScraperIT::fanartheight, movie->fanart.height);
- tk->AddIntToken((int)eScraperIT::collectionposterwidth, movie->collectionPoster.width);
- tk->AddIntToken((int)eScraperIT::collectionposterheight, movie->collectionPoster.height);
- tk->AddIntToken((int)eScraperIT::collectionfanartwidth, movie->collectionFanart.width);
- tk->AddIntToken((int)eScraperIT::collectionfanartheight, movie->collectionFanart.height);
- if (movie->collectionPoster.path.size() > 0)
- tk->AddIntToken((int)eScraperIT::movieiscollection, 1);
- int i=0;
- for (vector<cActor>::iterator act = movie->actors.begin(); act != movie->actors.end(); act++) {
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::name, (*act).name.c_str());
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::role, (*act).role.c_str());
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumb, (*act).actorThumb.path.c_str());
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbwidth, *cString::sprintf("%d", (*act).actorThumb.width));
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbheight, *cString::sprintf("%d", (*act).actorThumb.height));
- i++;
- }
-}
-
-void cScrapManager::SetSeries(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
- //Series Basics
- tk->AddStringToken((int)eScraperST::seriesname, series->name.c_str());
- tk->AddStringToken((int)eScraperST::seriesoverview, series->overview.c_str());
- tk->AddStringToken((int)eScraperST::seriesfirstaired, series->firstAired.c_str());
- tk->AddStringToken((int)eScraperST::seriesnetwork, series->network.c_str());
- tk->AddStringToken((int)eScraperST::seriesgenre, series->genre.c_str());
- tk->AddStringToken((int)eScraperST::seriesrating, *cString::sprintf("%f", series->rating));
- tk->AddStringToken((int)eScraperST::seriesstatus, series->status.c_str());
- //Episode Information
- tk->AddIntToken((int)eScraperIT::episodenumber, series->episode.number);
- tk->AddIntToken((int)eScraperIT::episodeseason, series->episode.season);
- tk->AddStringToken((int)eScraperST::episodetitle, series->episode.name.c_str());
- tk->AddStringToken((int)eScraperST::episodefirstaired, series->episode.firstAired.c_str());
- tk->AddStringToken((int)eScraperST::episodegueststars, series->episode.guestStars.c_str());
- tk->AddStringToken((int)eScraperST::episodeoverview, series->episode.overview.c_str());
- tk->AddStringToken((int)eScraperST::episoderating, *cString::sprintf("%f", series->episode.rating));
- tk->AddIntToken((int)eScraperIT::episodeimagewidth, series->episode.episodeImage.width);
- tk->AddIntToken((int)eScraperIT::episodeimageheight, series->episode.episodeImage.height);
- tk->AddStringToken((int)eScraperST::episodeimagepath, series->episode.episodeImage.path.c_str());
- //Seasonposter
- tk->AddIntToken((int)eScraperIT::seasonposterwidth, series->seasonPoster.width);
- tk->AddIntToken((int)eScraperIT::seasonposterheight, series->seasonPoster.height);
- tk->AddStringToken((int)eScraperST::seasonposterpath, series->seasonPoster.path.c_str());
- //Posters
- int indexInt = (int)eScraperIT::seriesposter1width;
- int indexStr = (int)eScraperST::seriesposter1path;
- for(vector<cTvMedia>::iterator poster = series->posters.begin(); poster != series->posters.end(); poster++) {
- tk->AddIntToken(indexInt, (*poster).width);
- tk->AddIntToken(indexInt+1, (*poster).height);
- tk->AddStringToken(indexStr, (*poster).path.c_str());
- indexInt += 2;
- indexStr++;
- }
- //Banners
- indexInt = (int)eScraperIT::seriesbanner1width;
- indexStr = (int)eScraperST::seriesbanner1path;
- for(vector<cTvMedia>::iterator banner = series->banners.begin(); banner != series->banners.end(); banner++) {
- tk->AddIntToken(indexInt, (*banner).width);
- tk->AddIntToken(indexInt+1, (*banner).height);
- tk->AddStringToken(indexStr, (*banner).path.c_str());
- indexInt += 2;
- indexStr++;
- }
- //Fanarts
- indexInt = (int)eScraperIT::seriesfanart1width;
- indexStr = (int)eScraperST::seriesfanart1path;
- for(vector<cTvMedia>::iterator fanart = series->fanarts.begin(); fanart != series->fanarts.end(); fanart++) {
- tk->AddIntToken(indexInt, (*fanart).width);
- tk->AddIntToken(indexInt+1, (*fanart).height);
- tk->AddStringToken(indexStr, (*fanart).path.c_str());
- indexInt += 2;
- indexStr++;
- }
- //Actors
- int i=0;
- for (vector<cActor>::iterator act = series->actors.begin(); act != series->actors.end(); act++) {
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::name, (*act).name.c_str());
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::role, (*act).role.c_str());
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumb, (*act).actorThumb.path.c_str());
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbwidth, *cString::sprintf("%d", (*act).actorThumb.width));
- tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbheight, *cString::sprintf("%d", (*act).actorThumb.height));
- i++;
- }
-}
-
-void cScrapManager::RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster) {
- if (!pScraper) {
- return;
- }
- ScraperGetPoster callPoster;
- callPoster.event = NULL;
- callPoster.recording = rec;
- if (pScraper->Service("GetPoster", &callPoster)) {
- posterWidth = callPoster.poster.width;
- posterHeight = callPoster.poster.height;
- path = callPoster.poster.path;
- if (path.size() > 0)
- hasPoster = true;
- }
-}
-
-void cScrapManager::SetPosterBanner(skindesignerapi::cTokenContainer *tk, const cEvent *event, const cRecording *recording) {
- if (!pScraper) {
- return;
- }
- int mediaWidth = 0;
- int mediaHeight = 0;
- string mediaPath = "";
- bool isBanner = false;
- int posterWidth = 0;
- int posterHeight = 0;
- string posterPath = "";
- bool hasPoster = false;
- int bannerWidth = 0;
- int bannerHeight = 0;
- string bannerPath = "";
- bool hasBanner = false;
-
- ScraperGetPosterBannerV2 call;
- call.event = event;
- call.recording = recording;
- if (pScraper->Service("GetPosterBannerV2", &call)) {
- if ((call.type == tSeries) && call.banner.path.size() > 0) {
- mediaWidth = call.banner.width;
- mediaHeight = call.banner.height;
- mediaPath = call.banner.path;
- isBanner = true;
- bannerWidth = mediaWidth;
- bannerHeight = mediaHeight;
- bannerPath = mediaPath;
- hasBanner = true;
- ScraperGetPoster callPoster;
- callPoster.event = event;
- callPoster.recording = recording;
- if (pScraper->Service("GetPoster", &callPoster)) {
- posterWidth = callPoster.poster.width;
- posterHeight = callPoster.poster.height;
- posterPath = callPoster.poster.path;
- hasPoster = true;
- }
- } else if (call.type == tMovie && call.poster.path.size() > 0 && call.poster.height > 0) {
- mediaWidth = call.poster.width;
- mediaHeight = call.poster.height;
- mediaPath = call.poster.path;
- posterWidth = call.poster.width;
- posterHeight = call.poster.height;
- posterPath = call.poster.path;
- hasPoster = true;
- }
- }
- tk->AddIntToken((int)eScraperPosterBannerIT::mediawidth, mediaWidth);
- tk->AddIntToken((int)eScraperPosterBannerIT::mediaheight, mediaHeight);
- tk->AddIntToken((int)eScraperPosterBannerIT::isbanner, isBanner);
- tk->AddStringToken((int)eScraperPosterBannerST::mediapath, mediaPath.c_str());
- tk->AddIntToken((int)eScraperPosterBannerIT::posterwidth, posterWidth);
- tk->AddIntToken((int)eScraperPosterBannerIT::posterheight, posterHeight);
- tk->AddStringToken((int)eScraperPosterBannerST::posterpath, posterPath.c_str());
- tk->AddIntToken((int)eScraperPosterBannerIT::hasposter, hasPoster);
- tk->AddIntToken((int)eScraperPosterBannerIT::bannerwidth, bannerWidth);
- tk->AddIntToken((int)eScraperPosterBannerIT::bannerheight, bannerHeight);
- tk->AddStringToken((int)eScraperPosterBannerST::bannerpath, bannerPath.c_str());
- tk->AddIntToken((int)eScraperPosterBannerIT::hasbanner, hasBanner);
+#include "scrapmanager.h"
+#include "../coreengine/definitions.h"
+#include "helpers.h"
+
+cPlugin *cScrapManager::pScraper = NULL;
+
+cScrapManager::cScrapManager(void) {
+ if (!pScraper) {
+ pScraper = GetScraperPlugin();
+ }
+ movie = NULL;
+ series = NULL;
+}
+
+cScrapManager::~cScrapManager(void) {
+ delete movie;
+ delete series;
+}
+
+bool cScrapManager::LoadFullScrapInfo(const cEvent *event, const cRecording *recording) {
+ if (!pScraper) {
+ return false;
+ }
+ delete movie;
+ movie = NULL;
+ delete series;
+ series = NULL;
+
+ ScraperGetEventType getType;
+ getType.event = event;
+ getType.recording = recording;
+ if (!pScraper->Service("GetEventType", &getType)) {
+ return false;
+ }
+ if (getType.type == tMovie) {
+ movie = new cMovie();
+ movie->movieId = getType.movieId;
+ pScraper->Service("GetMovie", movie);
+ return true;
+ } else if (getType.type == tSeries) {
+ series = new cSeries();
+ series->seriesId = getType.seriesId;
+ series->episodeId = getType.episodeId;
+ pScraper->Service("GetSeries", series);
+ return true;
+ }
+ return false;
+}
+
+void cScrapManager::SetFullScrapInfo(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
+ if (series) {
+ tk->AddIntToken((int)eScraperIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperIT::isseries, 1);
+ SetSeries(tk, actorsIndex);
+ } else if (movie) {
+ tk->AddIntToken((int)eScraperIT::ismovie, 1);
+ tk->AddIntToken((int)eScraperIT::isseries, 0);
+ SetMovie(tk, actorsIndex);
+ } else {
+ tk->AddIntToken((int)eScraperIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperIT::isseries, 0);
+ }
+}
+
+
+int cScrapManager::NumActors(void) {
+ if (series) {
+ return series->actors.size();
+ } else if (movie) {
+ return movie->actors.size();
+ }
+ return 0;
+}
+
+void cScrapManager::SetHeaderScrapInfo(skindesignerapi::cTokenContainer *tk) {
+ if (series) {
+ tk->AddIntToken((int)eScraperHeaderIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperHeaderIT::isseries, 1);
+ vector<cTvMedia>::iterator poster = series->posters.begin();
+ if (poster != series->posters.end()) {
+ tk->AddIntToken((int)eScraperHeaderIT::posteravailable, true);
+ tk->AddIntToken((int)eScraperHeaderIT::posterwidth, (*poster).width);
+ tk->AddIntToken((int)eScraperHeaderIT::posterheight, (*poster).height);
+ tk->AddStringToken((int)eScraperHeaderST::posterpath, (*poster).path.c_str());
+ }
+ vector<cTvMedia>::iterator banner = series->banners.begin();
+ if (banner != series->banners.end()) {
+ tk->AddIntToken((int)eScraperHeaderIT::banneravailable, true);
+ tk->AddIntToken((int)eScraperHeaderIT::bannerwidth, (*banner).width);
+ tk->AddIntToken((int)eScraperHeaderIT::bannerheight, (*banner).height);
+ tk->AddStringToken((int)eScraperHeaderST::bannerpath, (*banner).path.c_str());
+ }
+ } else if (movie) {
+ tk->AddIntToken((int)eScraperHeaderIT::ismovie, 1);
+ tk->AddIntToken((int)eScraperHeaderIT::isseries, 0);
+ tk->AddIntToken((int)eScraperHeaderIT::posteravailable, true);
+ tk->AddIntToken((int)eScraperHeaderIT::banneravailable, false);
+ tk->AddIntToken((int)eScraperHeaderIT::posterwidth, movie->poster.width);
+ tk->AddIntToken((int)eScraperHeaderIT::posterheight, movie->poster.height);
+ tk->AddStringToken((int)eScraperHeaderST::posterpath, movie->poster.path.c_str());
+ } else {
+ tk->AddIntToken((int)eScraperHeaderIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperHeaderIT::isseries, 0);
+ }
+}
+
+void cScrapManager::SetScraperPosterBanner(skindesignerapi::cTokenContainer *tk) {
+ if (movie) {
+ tk->AddIntToken((int)eCeMenuSchedulesIT::hasposter, 1);
+ tk->AddStringToken((int)eCeMenuSchedulesST::posterpath, movie->poster.path.c_str());
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterwidth, movie->poster.width);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterheight, movie->poster.height);
+ } else if (series) {
+ vector<cTvMedia>::iterator poster = series->posters.begin();
+ if (poster != series->posters.end()) {
+ tk->AddIntToken((int)eCeMenuSchedulesIT::hasposter, 1);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterwidth, (*poster).width);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterheight, (*poster).height);
+ tk->AddStringToken((int)eCeMenuSchedulesST::posterpath, (*poster).path.c_str());
+ }
+ vector<cTvMedia>::iterator banner = series->banners.begin();
+ if (banner != series->banners.end()) {
+ tk->AddIntToken((int)eCeMenuSchedulesIT::hasbanner, 1);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::bannerwidth, (*banner).width);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::bannerheight, (*banner).height);
+ tk->AddStringToken((int)eCeMenuSchedulesST::bannerpath, (*banner).path.c_str());
+ }
+ }
+}
+
+void cScrapManager::SetScraperRecordingPoster(skindesignerapi::cTokenContainer *tk, const cRecording *recording, bool isListElement) {
+ if (!pScraper) {
+ return;
+ }
+ ScraperGetPosterThumb call;
+ call.event = NULL;
+ call.recording = recording;
+ if (pScraper->Service("GetPosterThumb", &call)) {
+ if (isListElement) {
+ tk->AddIntToken((int)eLeMenuRecordingsIT::hasposterthumbnail, FileExists(call.poster.path));
+ tk->AddIntToken((int)eLeMenuRecordingsIT::thumbnailwidth, call.poster.width);
+ tk->AddIntToken((int)eLeMenuRecordingsIT::thumbnailheight, call.poster.height);
+ tk->AddStringToken((int)eLeMenuRecordingsST::thumbnailpath, call.poster.path.c_str());
+ } else {
+ tk->AddIntToken((int)eCeMenuRecordingsIT::hasposterthumbnail, FileExists(call.poster.path));
+ tk->AddIntToken((int)eCeMenuRecordingsIT::thumbnailwidth, call.poster.width);
+ tk->AddIntToken((int)eCeMenuRecordingsIT::thumbnailheight, call.poster.height);
+ tk->AddStringToken((int)eCeMenuRecordingsST::thumbnailpath, call.poster.path.c_str());
+ }
+ }
+
+ ScraperGetPoster call2;
+ call2.event = NULL;
+ call2.recording = recording;
+ if (pScraper->Service("GetPoster", &call2)) {
+ if (isListElement) {
+ tk->AddIntToken((int)eLeMenuRecordingsIT::hasposter, FileExists(call2.poster.path));
+ tk->AddIntToken((int)eLeMenuRecordingsIT::posterwidth, call2.poster.width);
+ tk->AddIntToken((int)eLeMenuRecordingsIT::posterheight, call2.poster.height);
+ tk->AddStringToken((int)eLeMenuRecordingsST::posterpath, call2.poster.path.c_str());
+ } else {
+ tk->AddIntToken((int)eCeMenuRecordingsIT::hasposter, FileExists(call2.poster.path));
+ tk->AddIntToken((int)eCeMenuRecordingsIT::posterwidth, call2.poster.width);
+ tk->AddIntToken((int)eCeMenuRecordingsIT::posterheight, call2.poster.height);
+ tk->AddStringToken((int)eCeMenuRecordingsST::posterpath, call2.poster.path.c_str());
+ }
+ }
+}
+
+cPlugin *cScrapManager::GetScraperPlugin(void) {
+ static cPlugin *pScraper = cPluginManager::GetPlugin("scraper2vdr");
+ if( !pScraper ) // if it doesn't exit, try tvscraper
+ pScraper = cPluginManager::GetPlugin("tvscraper");
+ return pScraper;
+}
+
+void cScrapManager::SetMovie(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
+ tk->AddStringToken((int)eScraperST::movietitle, movie->title.c_str());
+ tk->AddStringToken((int)eScraperST::movieoriginalTitle, movie->originalTitle.c_str());
+ tk->AddStringToken((int)eScraperST::movietagline, movie->tagline.c_str());
+ tk->AddStringToken((int)eScraperST::movieoverview, movie->overview.c_str());
+ tk->AddStringToken((int)eScraperST::moviegenres, movie->genres.c_str());
+ tk->AddStringToken((int)eScraperST::moviehomepage, movie->homepage.c_str());
+ tk->AddStringToken((int)eScraperST::moviereleasedate, movie->releaseDate.c_str());
+ tk->AddStringToken((int)eScraperST::moviepopularity, *cString::sprintf("%f", movie->popularity));
+ tk->AddStringToken((int)eScraperST::movievoteaverage, *cString::sprintf("%f", movie->voteAverage));
+ tk->AddStringToken((int)eScraperST::posterpath, movie->poster.path.c_str());
+ tk->AddStringToken((int)eScraperST::fanartpath, movie->fanart.path.c_str());
+ tk->AddStringToken((int)eScraperST::collectionposterpath, movie->collectionPoster.path.c_str());
+ tk->AddStringToken((int)eScraperST::collectionfanartpath, movie->collectionFanart.path.c_str());
+ tk->AddIntToken((int)eScraperIT::movieadult, movie->adult);
+ tk->AddIntToken((int)eScraperIT::moviebudget, movie->budget);
+ tk->AddIntToken((int)eScraperIT::movierevenue, movie->revenue);
+ tk->AddIntToken((int)eScraperIT::movieruntime, movie->runtime);
+ tk->AddIntToken((int)eScraperIT::posterwidth, movie->poster.width);
+ tk->AddIntToken((int)eScraperIT::posterheight, movie->poster.height);
+ tk->AddIntToken((int)eScraperIT::fanartwidth, movie->fanart.width);
+ tk->AddIntToken((int)eScraperIT::fanartheight, movie->fanart.height);
+ tk->AddIntToken((int)eScraperIT::collectionposterwidth, movie->collectionPoster.width);
+ tk->AddIntToken((int)eScraperIT::collectionposterheight, movie->collectionPoster.height);
+ tk->AddIntToken((int)eScraperIT::collectionfanartwidth, movie->collectionFanart.width);
+ tk->AddIntToken((int)eScraperIT::collectionfanartheight, movie->collectionFanart.height);
+ if (movie->collectionPoster.path.size() > 0)
+ tk->AddIntToken((int)eScraperIT::movieiscollection, 1);
+ int i=0;
+ for (vector<cActor>::iterator act = movie->actors.begin(); act != movie->actors.end(); act++) {
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::name, (*act).name.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::role, (*act).role.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumb, (*act).actorThumb.path.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbwidth, *cString::sprintf("%d", (*act).actorThumb.width));
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbheight, *cString::sprintf("%d", (*act).actorThumb.height));
+ i++;
+ }
+}
+
+void cScrapManager::SetSeries(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
+ //Series Basics
+ tk->AddStringToken((int)eScraperST::seriesname, series->name.c_str());
+ tk->AddStringToken((int)eScraperST::seriesoverview, series->overview.c_str());
+ tk->AddStringToken((int)eScraperST::seriesfirstaired, series->firstAired.c_str());
+ tk->AddStringToken((int)eScraperST::seriesnetwork, series->network.c_str());
+ tk->AddStringToken((int)eScraperST::seriesgenre, series->genre.c_str());
+ tk->AddStringToken((int)eScraperST::seriesrating, *cString::sprintf("%f", series->rating));
+ tk->AddStringToken((int)eScraperST::seriesstatus, series->status.c_str());
+ //Episode Information
+ tk->AddIntToken((int)eScraperIT::episodenumber, series->episode.number);
+ tk->AddIntToken((int)eScraperIT::episodeseason, series->episode.season);
+ tk->AddStringToken((int)eScraperST::episodetitle, series->episode.name.c_str());
+ tk->AddStringToken((int)eScraperST::episodefirstaired, series->episode.firstAired.c_str());
+ tk->AddStringToken((int)eScraperST::episodegueststars, series->episode.guestStars.c_str());
+ tk->AddStringToken((int)eScraperST::episodeoverview, series->episode.overview.c_str());
+ tk->AddStringToken((int)eScraperST::episoderating, *cString::sprintf("%f", series->episode.rating));
+ tk->AddIntToken((int)eScraperIT::episodeimagewidth, series->episode.episodeImage.width);
+ tk->AddIntToken((int)eScraperIT::episodeimageheight, series->episode.episodeImage.height);
+ tk->AddStringToken((int)eScraperST::episodeimagepath, series->episode.episodeImage.path.c_str());
+ //Seasonposter
+ tk->AddIntToken((int)eScraperIT::seasonposterwidth, series->seasonPoster.width);
+ tk->AddIntToken((int)eScraperIT::seasonposterheight, series->seasonPoster.height);
+ tk->AddStringToken((int)eScraperST::seasonposterpath, series->seasonPoster.path.c_str());
+ //Posters
+ int indexInt = (int)eScraperIT::seriesposter1width;
+ int indexStr = (int)eScraperST::seriesposter1path;
+ for(vector<cTvMedia>::iterator poster = series->posters.begin(); poster != series->posters.end(); poster++) {
+ tk->AddIntToken(indexInt, (*poster).width);
+ tk->AddIntToken(indexInt+1, (*poster).height);
+ tk->AddStringToken(indexStr, (*poster).path.c_str());
+ indexInt += 2;
+ indexStr++;
+ }
+ //Banners
+ indexInt = (int)eScraperIT::seriesbanner1width;
+ indexStr = (int)eScraperST::seriesbanner1path;
+ for(vector<cTvMedia>::iterator banner = series->banners.begin(); banner != series->banners.end(); banner++) {
+ tk->AddIntToken(indexInt, (*banner).width);
+ tk->AddIntToken(indexInt+1, (*banner).height);
+ tk->AddStringToken(indexStr, (*banner).path.c_str());
+ indexInt += 2;
+ indexStr++;
+ }
+ //Fanarts
+ indexInt = (int)eScraperIT::seriesfanart1width;
+ indexStr = (int)eScraperST::seriesfanart1path;
+ for(vector<cTvMedia>::iterator fanart = series->fanarts.begin(); fanart != series->fanarts.end(); fanart++) {
+ tk->AddIntToken(indexInt, (*fanart).width);
+ tk->AddIntToken(indexInt+1, (*fanart).height);
+ tk->AddStringToken(indexStr, (*fanart).path.c_str());
+ indexInt += 2;
+ indexStr++;
+ }
+ //Actors
+ int i=0;
+ for (vector<cActor>::iterator act = series->actors.begin(); act != series->actors.end(); act++) {
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::name, (*act).name.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::role, (*act).role.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumb, (*act).actorThumb.path.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbwidth, *cString::sprintf("%d", (*act).actorThumb.width));
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbheight, *cString::sprintf("%d", (*act).actorThumb.height));
+ i++;
+ }
+}
+
+void cScrapManager::RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster) {
+ if (!pScraper) {
+ return;
+ }
+ ScraperGetPoster callPoster;
+ callPoster.event = NULL;
+ callPoster.recording = rec;
+ if (pScraper->Service("GetPoster", &callPoster)) {
+ posterWidth = callPoster.poster.width;
+ posterHeight = callPoster.poster.height;
+ path = callPoster.poster.path;
+ if (path.size() > 0)
+ hasPoster = true;
+ }
+}
+
+void cScrapManager::SetPosterBanner(skindesignerapi::cTokenContainer *tk, const cEvent *event, const cRecording *recording) {
+ if (!pScraper) {
+ return;
+ }
+ int mediaWidth = 0;
+ int mediaHeight = 0;
+ string mediaPath = "";
+ bool isBanner = false;
+ int posterWidth = 0;
+ int posterHeight = 0;
+ string posterPath = "";
+ bool hasPoster = false;
+ int bannerWidth = 0;
+ int bannerHeight = 0;
+ string bannerPath = "";
+ bool hasBanner = false;
+
+ ScraperGetPosterBannerV2 call;
+ call.event = event;
+ call.recording = recording;
+ if (pScraper->Service("GetPosterBannerV2", &call)) {
+ if ((call.type == tSeries) && call.banner.path.size() > 0) {
+ mediaWidth = call.banner.width;
+ mediaHeight = call.banner.height;
+ mediaPath = call.banner.path;
+ isBanner = true;
+ bannerWidth = mediaWidth;
+ bannerHeight = mediaHeight;
+ bannerPath = mediaPath;
+ hasBanner = true;
+ ScraperGetPoster callPoster;
+ callPoster.event = event;
+ callPoster.recording = recording;
+ if (pScraper->Service("GetPoster", &callPoster)) {
+ posterWidth = callPoster.poster.width;
+ posterHeight = callPoster.poster.height;
+ posterPath = callPoster.poster.path;
+ hasPoster = true;
+ }
+ } else if (call.type == tMovie && call.poster.path.size() > 0 && call.poster.height > 0) {
+ mediaWidth = call.poster.width;
+ mediaHeight = call.poster.height;
+ mediaPath = call.poster.path;
+ posterWidth = call.poster.width;
+ posterHeight = call.poster.height;
+ posterPath = call.poster.path;
+ hasPoster = true;
+ }
+ }
+ tk->AddIntToken((int)eScraperPosterBannerIT::mediawidth, mediaWidth);
+ tk->AddIntToken((int)eScraperPosterBannerIT::mediaheight, mediaHeight);
+ tk->AddIntToken((int)eScraperPosterBannerIT::isbanner, isBanner);
+ tk->AddStringToken((int)eScraperPosterBannerST::mediapath, mediaPath.c_str());
+ tk->AddIntToken((int)eScraperPosterBannerIT::posterwidth, posterWidth);
+ tk->AddIntToken((int)eScraperPosterBannerIT::posterheight, posterHeight);
+ tk->AddStringToken((int)eScraperPosterBannerST::posterpath, posterPath.c_str());
+ tk->AddIntToken((int)eScraperPosterBannerIT::hasposter, hasPoster);
+ tk->AddIntToken((int)eScraperPosterBannerIT::bannerwidth, bannerWidth);
+ tk->AddIntToken((int)eScraperPosterBannerIT::bannerheight, bannerHeight);
+ tk->AddStringToken((int)eScraperPosterBannerST::bannerpath, bannerPath.c_str());
+ tk->AddIntToken((int)eScraperPosterBannerIT::hasbanner, hasBanner);
} \ No newline at end of file
diff --git a/extensions/scrapmanager.h b/extensions/scrapmanager.h
index 0e026fc..a1ff449 100644
--- a/extensions/scrapmanager.h
+++ b/extensions/scrapmanager.h
@@ -1,28 +1,28 @@
-#ifndef __SCRAPMANAGER_H
-#define __SCRAPMANAGER_H
-
-#include "../services/scraper2vdr.h"
-#include "../libskindesignerapi/tokencontainer.h"
-
-class cScrapManager {
-private:
- static cPlugin *pScraper;
- cMovie *movie;
- cSeries *series;
- cPlugin *GetScraperPlugin(void);
- void SetMovie(skindesignerapi::cTokenContainer *tk, int actorsIndex);
- void SetSeries(skindesignerapi::cTokenContainer *tk, int actorsIndex);
-protected:
- bool LoadFullScrapInfo(const cEvent *event, const cRecording *recording);
- void SetFullScrapInfo(skindesignerapi::cTokenContainer *tk, int actorsIndex);
- int NumActors(void);
- void SetHeaderScrapInfo(skindesignerapi::cTokenContainer *tk);
- void SetScraperPosterBanner(skindesignerapi::cTokenContainer *tk);
- void SetScraperRecordingPoster(skindesignerapi::cTokenContainer *tk, const cRecording *recording, bool isListElement);
- void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
- void SetPosterBanner(skindesignerapi::cTokenContainer *tk, const cEvent *event, const cRecording *recording);
-public:
- cScrapManager(void);
- virtual ~cScrapManager(void);
-};
+#ifndef __SCRAPMANAGER_H
+#define __SCRAPMANAGER_H
+
+#include "../services/scraper2vdr.h"
+#include "../libskindesignerapi/tokencontainer.h"
+
+class cScrapManager {
+private:
+ static cPlugin *pScraper;
+ cMovie *movie;
+ cSeries *series;
+ cPlugin *GetScraperPlugin(void);
+ void SetMovie(skindesignerapi::cTokenContainer *tk, int actorsIndex);
+ void SetSeries(skindesignerapi::cTokenContainer *tk, int actorsIndex);
+protected:
+ bool LoadFullScrapInfo(const cEvent *event, const cRecording *recording);
+ void SetFullScrapInfo(skindesignerapi::cTokenContainer *tk, int actorsIndex);
+ int NumActors(void);
+ void SetHeaderScrapInfo(skindesignerapi::cTokenContainer *tk);
+ void SetScraperPosterBanner(skindesignerapi::cTokenContainer *tk);
+ void SetScraperRecordingPoster(skindesignerapi::cTokenContainer *tk, const cRecording *recording, bool isListElement);
+ void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
+ void SetPosterBanner(skindesignerapi::cTokenContainer *tk, const cEvent *event, const cRecording *recording);
+public:
+ cScrapManager(void);
+ virtual ~cScrapManager(void);
+};
#endif //__SCRAPMANAGER_H \ No newline at end of file