summaryrefslogtreecommitdiff
path: root/libtemplate/xmlparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtemplate/xmlparser.c')
-rw-r--r--libtemplate/xmlparser.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/libtemplate/xmlparser.c b/libtemplate/xmlparser.c
index 0e2c132..4b8e85a 100644
--- a/libtemplate/xmlparser.c
+++ b/libtemplate/xmlparser.c
@@ -1,5 +1,6 @@
#include "xmlparser.h"
#include "../config.h"
+#include "../libcore/helpers.h"
using namespace std;
@@ -61,6 +62,33 @@ bool cXmlParser::ReadView(cTemplateView *view, string xmlFile) {
return true;
}
+bool cXmlParser::ReadPluginView(string plugName, int templateNumber, string templateName) {
+
+ string xmlPath = GetPath(templateName);
+
+ if (!FileExists(xmlPath) || ctxt == NULL) {
+ return false;
+ }
+ DeleteDocument();
+ doc = xmlCtxtReadFile(ctxt, xmlPath.c_str(), NULL, XML_PARSE_NOENT | XML_PARSE_DTDVALID);
+
+ if (doc == NULL) {
+ return false;
+ }
+ if (ctxt->valid == 0) {
+ esyslog("skindesigner: Failed to validate %s", xmlPath.c_str());
+ return false;
+ }
+
+ root = xmlDocGetRootElement(doc);
+
+ if (root == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
bool cXmlParser::ReadGlobals(cGlobals *globals, string xmlFile) {
this->globals = globals;
@@ -132,6 +160,42 @@ bool cXmlParser::ParseView(void) {
}
+bool cXmlParser::ParsePluginView(string plugName, int templateNumber) {
+
+ cTemplateView *plugView = new cTemplateViewMenu();
+ view->AddPluginView(plugName, templateNumber, plugView);
+
+ vector<pair<string, string> > attribs;
+ ParseAttributes(root->properties, root, attribs);
+
+ plugView->SetParameters(attribs);
+
+ xmlNodePtr childNode = root->xmlChildrenNode;
+
+ while (childNode != NULL) {
+
+ if (childNode->type != XML_ELEMENT_NODE) {
+ childNode = childNode->next;
+ continue;
+ }
+
+ if (plugView->ValidViewElement((const char*)childNode->name)) {
+ bool debugViewElement = DebugViewElement(childNode);
+ ParseViewElement(childNode->name, childNode->xmlChildrenNode, debugViewElement, plugView);
+ } else if (plugView->ValidViewList((const char*)childNode->name)) {
+ ParseViewList(childNode, plugView);
+ } else if (!xmlStrcmp(childNode->name, (const xmlChar *) "tab")) {
+ ParseViewTab(childNode, plugView);
+ } else {
+ return false;
+ }
+
+ childNode = childNode->next;
+ }
+
+ return true;
+}
+
bool cXmlParser::ParseGlobals(void) {
xmlNodePtr node = root->xmlChildrenNode;