mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 15:58:31 +00:00
introducing skin setups
This commit is contained in:
55
libcore/skinsetup.c
Normal file
55
libcore/skinsetup.c
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "skinsetup.h"
|
||||
#include "../libtemplate/xmlparser.h"
|
||||
|
||||
cSkinSetup::cSkinSetup(string skin) {
|
||||
this->skin = skin;
|
||||
}
|
||||
|
||||
void cSkinSetup::ReadFromXML(void) {
|
||||
esyslog("skindesigner: reading setup for skin %s", skin.c_str());
|
||||
string xmlFile = "setup.xml";
|
||||
cXmlParser parser;
|
||||
if (!parser.ReadSkinSetup(this, skin, xmlFile)) {
|
||||
esyslog("skindesigner: no setup file for skin %s found", skin.c_str());
|
||||
return;
|
||||
}
|
||||
parser.ParseSkinSetup(skin);
|
||||
}
|
||||
|
||||
void cSkinSetup::SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value) {
|
||||
if (!type || !name || !displayText || !value) {
|
||||
esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str());
|
||||
return;
|
||||
}
|
||||
eSetupParameterType paramType = sptUnknown;
|
||||
if (!xmlStrcmp(type, (const xmlChar *) "int")) {
|
||||
paramType = sptInt;
|
||||
} else if (!xmlStrcmp(type, (const xmlChar *) "bool")) {
|
||||
paramType = sptBool;
|
||||
}
|
||||
if (paramType == sptUnknown) {
|
||||
esyslog("skindesigner: invalid setup parameter for skin %s", skin.c_str());
|
||||
return;
|
||||
}
|
||||
cSkinSetupParameter param;
|
||||
param.type = paramType;
|
||||
param.name = (const char*)name;
|
||||
param.displayText = (const char*)displayText;
|
||||
|
||||
if (min && paramType == sptInt) {
|
||||
param.min = atoi((const char*)min);
|
||||
}
|
||||
if (max && paramType == sptInt) {
|
||||
param.max = atoi((const char*)max);
|
||||
}
|
||||
param.value = atoi((const char*)value);
|
||||
|
||||
parameters.push_back(param);
|
||||
}
|
||||
|
||||
|
||||
void cSkinSetup::Debug(void) {
|
||||
dsyslog("skindesigner: Skin \"%s\" Setup Parameters", skin.c_str());
|
||||
for (vector<cSkinSetupParameter>::iterator p = parameters.begin(); p != parameters.end(); p++)
|
||||
p->Debug();
|
||||
}
|
29
libcore/skinsetup.h
Normal file
29
libcore/skinsetup.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef __SKINSETUP_H
|
||||
#define __SKINSETUP_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <vdr/plugin.h>
|
||||
#include <libxml/xmlstring.h>
|
||||
#include "skinsetupparameter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// --- cSkinSetup -----------------------------------------------------------
|
||||
|
||||
class cSkinSetup {
|
||||
private:
|
||||
string skin;
|
||||
vector<cSkinSetupParameter> parameters;
|
||||
public:
|
||||
cSkinSetup(string skin);
|
||||
virtual ~cSkinSetup(void) {};
|
||||
void ReadFromXML(void);
|
||||
void SetParameter(xmlChar *type, xmlChar *name, xmlChar* displayText, xmlChar *min, xmlChar *max, xmlChar *value);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
#endif //__SKINSETUP_H
|
24
libcore/skinsetupparameter.c
Normal file
24
libcore/skinsetupparameter.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "skinsetupparameter.h"
|
||||
|
||||
cSkinSetupParameter::cSkinSetupParameter(void) {
|
||||
type = sptUnknown;
|
||||
name = "";
|
||||
displayText = "";
|
||||
min = 0;
|
||||
max = 1000;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
void cSkinSetupParameter::Debug(void) {
|
||||
if (type == sptBool)
|
||||
dsyslog("skindesigner: type bool");
|
||||
else if (type == sptInt)
|
||||
dsyslog("skindesigner: type integer");
|
||||
else
|
||||
dsyslog("skindesigner: type UNKNOWN");
|
||||
dsyslog("skindesigner: name %s", name.c_str());
|
||||
dsyslog("skindesigner: displayText %s", displayText.c_str());
|
||||
if (type == sptInt)
|
||||
dsyslog("skindesigner: min %d, max %d", min, max);
|
||||
dsyslog("skindesigner: Value %d", value);
|
||||
}
|
31
libcore/skinsetupparameter.h
Normal file
31
libcore/skinsetupparameter.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef __SKINSETUPPARAMETER_H
|
||||
#define __SKINSETUPPARAMETER_H
|
||||
|
||||
#include <string>
|
||||
#include <vdr/plugin.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum eSetupParameterType {
|
||||
sptInt,
|
||||
sptBool,
|
||||
sptUnknown
|
||||
};
|
||||
|
||||
// --- cSkinSetupParameter -----------------------------------------------------------
|
||||
|
||||
class cSkinSetupParameter {
|
||||
private:
|
||||
public:
|
||||
cSkinSetupParameter(void);
|
||||
virtual ~cSkinSetupParameter(void) {};
|
||||
eSetupParameterType type;
|
||||
string name;
|
||||
string displayText;
|
||||
int min;
|
||||
int max;
|
||||
int value;
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
#endif //__SKINSETUPPARAMETER_H
|
Reference in New Issue
Block a user