mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 17:58:31 +02:00
added support for custom tokens in dislaychannel
This commit is contained in:
parent
04340d11c9
commit
0e0f05cfcb
1
HISTORY
1
HISTORY
@ -19,3 +19,4 @@ Version 0.0.2
|
|||||||
- support for global variables type "double"
|
- support for global variables type "double"
|
||||||
- added setup options to configure rerun display behaviour
|
- added setup options to configure rerun display behaviour
|
||||||
- changed display of menu lists, do flush first after complete rendering
|
- changed display of menu lists, do flush first after complete rendering
|
||||||
|
- added support for custom tokens in dislaychannel
|
||||||
|
31
designer.c
31
designer.c
@ -170,6 +170,37 @@ void cSkinDesigner::ListAvailableFonts(void) {
|
|||||||
fontManager->ListAvailableFonts();
|
fontManager->ListAvailableFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cSkinDesigner::SetCustomToken(string option) {
|
||||||
|
splitstring s(option.c_str());
|
||||||
|
vector<string> flds = s.split('=', 0);
|
||||||
|
|
||||||
|
if (flds.size() != 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string key = trim(flds[0]);
|
||||||
|
string val = trim(flds[1]);
|
||||||
|
|
||||||
|
if (!globals)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
map<string, string>::iterator hit = globals->customTokens.find(key);
|
||||||
|
if (hit != globals->customTokens.end()) {
|
||||||
|
globals->customTokens.erase(key);
|
||||||
|
}
|
||||||
|
globals->customTokens.insert(pair<string,string>(key, val));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSkinDesigner::ListCustomTokens(void) {
|
||||||
|
if (!globals)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (map<string, string>::iterator it = globals->customTokens.begin(); it != globals->customTokens.end(); it++) {
|
||||||
|
dsyslog("skindesigner: custom token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
* PRIVATE FUNCTIONS
|
* PRIVATE FUNCTIONS
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
@ -49,6 +49,8 @@ public:
|
|||||||
void ActivateBackupSkin(void) { useBackupSkin = true; };
|
void ActivateBackupSkin(void) { useBackupSkin = true; };
|
||||||
void Reload(void);
|
void Reload(void);
|
||||||
void ListAvailableFonts(void);
|
void ListAvailableFonts(void);
|
||||||
|
bool SetCustomToken(string option);
|
||||||
|
void ListCustomTokens(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__SKINDESIGNER_H
|
#endif //__SKINDESIGNER_H
|
||||||
|
@ -163,6 +163,10 @@ void cSDDisplayChannel::Flush(void) {
|
|||||||
if (!doOutput)
|
if (!doOutput)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (initial) {
|
||||||
|
channelView->DrawCustomTokens();
|
||||||
|
}
|
||||||
|
|
||||||
if (initial || channelChange) {
|
if (initial || channelChange) {
|
||||||
channelView->DrawDate();
|
channelView->DrawDate();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<!ELEMENT displaychannel (background | channelinfo | epginfo | progressbar | progressbarback |
|
<!ELEMENT displaychannel (background | channelinfo | epginfo | progressbar | progressbarback |
|
||||||
statusinfo | screenresolution | channelgroup |
|
statusinfo | screenresolution | channelgroup |
|
||||||
signalquality | signalqualityback | scrapercontent |
|
signalquality | signalqualityback | scrapercontent |
|
||||||
datetime | message)* >
|
datetime | message | customtokens)* >
|
||||||
<!ATTLIST displaychannel
|
<!ATTLIST displaychannel
|
||||||
x CDATA #REQUIRED
|
x CDATA #REQUIRED
|
||||||
y CDATA #REQUIRED
|
y CDATA #REQUIRED
|
||||||
@ -83,4 +83,9 @@
|
|||||||
debug CDATA #IMPLIED
|
debug CDATA #IMPLIED
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<!ELEMENT customtokens (area|areascroll)*>
|
||||||
|
<!ATTLIST customtokens
|
||||||
|
debug CDATA #IMPLIED
|
||||||
|
>
|
||||||
|
|
||||||
%functions;
|
%functions;
|
||||||
|
@ -121,6 +121,24 @@ bool FirstFileInFolder(string &path, string &extension, string &fileName) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trim from start
|
||||||
|
string <rim(string &s) {
|
||||||
|
s.erase(s.begin(), find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace))));
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// trim from end
|
||||||
|
string &rtrim(string &s) {
|
||||||
|
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// trim from both ends
|
||||||
|
string &trim(string &s) {
|
||||||
|
return ltrim(rtrim(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// split: receives a char delimiter; returns a vector of strings
|
// split: receives a char delimiter; returns a vector of strings
|
||||||
// By default ignores repeated delimiters, unless argument rep == 1.
|
// By default ignores repeated delimiters, unless argument rep == 1.
|
||||||
vector<string>& splitstring::split(char delim, int rep) {
|
vector<string>& splitstring::split(char delim, int rep) {
|
||||||
|
@ -16,6 +16,10 @@ bool FileExists(const string &path, const string &name, const string &ext);
|
|||||||
bool FolderExists(const string &path);
|
bool FolderExists(const string &path);
|
||||||
bool FirstFileInFolder(string &path, string &extension, string &fileName);
|
bool FirstFileInFolder(string &path, string &extension, string &fileName);
|
||||||
|
|
||||||
|
string <rim(string &s);
|
||||||
|
string &rtrim(string &s);
|
||||||
|
string &trim(string &s);
|
||||||
|
|
||||||
class splitstring : public std::string {
|
class splitstring : public std::string {
|
||||||
std::vector<std::string> flds;
|
std::vector<std::string> flds;
|
||||||
public:
|
public:
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
map <string, string> stringVars;
|
map <string, string> stringVars;
|
||||||
map <string, string> fonts;
|
map <string, string> fonts;
|
||||||
map <string, map< string, string > > translations;
|
map <string, map< string, string > > translations;
|
||||||
|
map <string, string> customTokens;
|
||||||
bool ReadFromXML(void);
|
bool ReadFromXML(void);
|
||||||
bool Translate(string text, string &translation);
|
bool Translate(string text, string &translation);
|
||||||
void Debug(void);
|
void Debug(void);
|
||||||
|
@ -593,6 +593,7 @@ void cTemplateViewChannel::SetViewElements(void) {
|
|||||||
viewElementsAllowed.insert("scrapercontent");
|
viewElementsAllowed.insert("scrapercontent");
|
||||||
viewElementsAllowed.insert("datetime");
|
viewElementsAllowed.insert("datetime");
|
||||||
viewElementsAllowed.insert("message");
|
viewElementsAllowed.insert("message");
|
||||||
|
viewElementsAllowed.insert("customtokens");
|
||||||
}
|
}
|
||||||
|
|
||||||
string cTemplateViewChannel::GetViewElementName(eViewElement ve) {
|
string cTemplateViewChannel::GetViewElementName(eViewElement ve) {
|
||||||
@ -637,6 +638,9 @@ string cTemplateViewChannel::GetViewElementName(eViewElement ve) {
|
|||||||
case veMessage:
|
case veMessage:
|
||||||
name = "Message";
|
name = "Message";
|
||||||
break;
|
break;
|
||||||
|
case veCustomTokens:
|
||||||
|
name = "Custom Tokens";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
name = "Unknown";
|
name = "Unknown";
|
||||||
break;
|
break;
|
||||||
@ -673,6 +677,8 @@ void cTemplateViewChannel::AddPixmap(string sViewElement, cTemplatePixmap *pix,
|
|||||||
ve = veDateTime;
|
ve = veDateTime;
|
||||||
} else if (!sViewElement.compare("message")) {
|
} else if (!sViewElement.compare("message")) {
|
||||||
ve = veMessage;
|
ve = veMessage;
|
||||||
|
} else if (!sViewElement.compare("customtokens")) {
|
||||||
|
ve = veCustomTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ve == veUndefined) {
|
if (ve == veUndefined) {
|
||||||
|
@ -99,6 +99,7 @@ public:
|
|||||||
int GetNumPixmapsViewElement(eViewElement ve);
|
int GetNumPixmapsViewElement(eViewElement ve);
|
||||||
int GetNumListViewMenuItems(void);
|
int GetNumListViewMenuItems(void);
|
||||||
bool GetScalingWindow(cRect &scalingWindow);
|
bool GetScalingWindow(cRect &scalingWindow);
|
||||||
|
map<string,string> GetCustomTokens(void) { return globals->customTokens; };
|
||||||
//Checks for parsing template XML files
|
//Checks for parsing template XML files
|
||||||
bool ValidSubView(const char *subView);
|
bool ValidSubView(const char *subView);
|
||||||
bool ValidViewElement(const char *viewElement);
|
bool ValidViewElement(const char *viewElement);
|
||||||
|
@ -24,6 +24,7 @@ enum eViewElement {
|
|||||||
veBackground,
|
veBackground,
|
||||||
veDateTime,
|
veDateTime,
|
||||||
veMessage,
|
veMessage,
|
||||||
|
veCustomTokens,
|
||||||
//DisplayChannel ViewElements
|
//DisplayChannel ViewElements
|
||||||
veChannelInfo,
|
veChannelInfo,
|
||||||
veChannelGroup,
|
veChannelGroup,
|
||||||
|
@ -157,6 +157,10 @@ const char **cPluginSkinDesigner::SVDRPHelpPages(void) {
|
|||||||
static const char *HelpPages[] = {
|
static const char *HelpPages[] = {
|
||||||
"RELD\n"
|
"RELD\n"
|
||||||
" force reload of templates and caches",
|
" force reload of templates and caches",
|
||||||
|
"SCTK\n"
|
||||||
|
" Set custom Token name = value",
|
||||||
|
"LCTK\n"
|
||||||
|
" List custom Tokens",
|
||||||
"LSTF\n"
|
"LSTF\n"
|
||||||
" List available Fonts",
|
" List available Fonts",
|
||||||
0
|
0
|
||||||
@ -176,17 +180,39 @@ cString cPluginSkinDesigner::SVDRPCommand(const char *Command, const char *Optio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activeSkin)
|
if (!activeSkin) {
|
||||||
return NULL;
|
ReplyCode = 550;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
if (strcasecmp(Command, "RELD") == 0) {
|
if (strcasecmp(Command, "RELD") == 0) {
|
||||||
activeSkin->Reload();
|
activeSkin->Reload();
|
||||||
|
ReplyCode = 250;
|
||||||
return "SKINDESIGNER reload of templates and caches forced.";
|
return "SKINDESIGNER reload of templates and caches forced.";
|
||||||
} else if (strcasecmp(Command, "LSTF") == 0) {
|
} else if (strcasecmp(Command, "LSTF") == 0) {
|
||||||
activeSkin->ListAvailableFonts();
|
activeSkin->ListAvailableFonts();
|
||||||
|
ReplyCode = 250;
|
||||||
return "SKINDESIGNER available fonts listed in syslog.";
|
return "SKINDESIGNER available fonts listed in syslog.";
|
||||||
|
} else if (strcasecmp(Command, "SCTK") == 0) {
|
||||||
|
if (!Option) {
|
||||||
|
ReplyCode = 501;
|
||||||
|
return "SKINDESIGNER SCTK Error: no Token name = value set";
|
||||||
}
|
}
|
||||||
return NULL;
|
bool optionOk = activeSkin->SetCustomToken(Option);
|
||||||
|
if (optionOk) {
|
||||||
|
ReplyCode = 250;
|
||||||
|
return cString::sprintf("SKINDESIGNER Set custom Token %s", Option);
|
||||||
|
} else {
|
||||||
|
ReplyCode = 501;
|
||||||
|
return cString::sprintf("SKINDESIGNER Invalid custom Token %s", Option);
|
||||||
|
}
|
||||||
|
} else if (strcasecmp(Command, "LCTK") == 0) {
|
||||||
|
activeSkin->ListCustomTokens();
|
||||||
|
ReplyCode = 250;
|
||||||
|
return "SKINDESIGNER Custom Tokens listed in Log";
|
||||||
|
}
|
||||||
|
ReplyCode = 502;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
VDRPLUGINCREATOR(cPluginSkinDesigner); // Don't touch this!
|
VDRPLUGINCREATOR(cPluginSkinDesigner); // Don't touch this!
|
||||||
|
@ -219,4 +219,12 @@
|
|||||||
<drawtext align="center" valign="center" width="{areawidth} - 80" font="{light}" fontsize="40%" color="{clrWhite}" text="{text}" />
|
<drawtext align="center" valign="center" width="{areawidth} - 80" font="{light}" fontsize="40%" color="{clrWhite}" text="{text}" />
|
||||||
</area>
|
</area>
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<!-- Available Variables customtokens:
|
||||||
|
all custom tokens set by the svdrp command SCTK are available in this viewelement
|
||||||
|
For instance, use an appropriate script which runs periodically as cronjob and
|
||||||
|
sets these custom tokens with svdrpsend or dbus2vdr
|
||||||
|
-->
|
||||||
|
<customtokens>
|
||||||
|
</customtokens>
|
||||||
</displaychannel>
|
</displaychannel>
|
||||||
|
@ -132,4 +132,12 @@
|
|||||||
<message>
|
<message>
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<!-- Available Variables customtokens:
|
||||||
|
all custom tokens set by the svdrp command SCTK are available in this viewelement
|
||||||
|
For instance, use an appropriate script which runs periodically as cronjob and
|
||||||
|
sets these custom tokens with svdrpsend or dbus2vdr
|
||||||
|
-->
|
||||||
|
<customtokens>
|
||||||
|
</customtokens>
|
||||||
|
|
||||||
</displaychannel>
|
</displaychannel>
|
||||||
|
@ -479,6 +479,17 @@ void cDisplayChannelView::DisplayMessage(eMessageType Type, const char *Text) {
|
|||||||
DrawViewElement(veMessage, &stringTokens, &intTokens);
|
DrawViewElement(veMessage, &stringTokens, &intTokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cDisplayChannelView::DrawCustomTokens(void) {
|
||||||
|
if (!ViewElementImplemented(veCustomTokens)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!tmplView)
|
||||||
|
return;
|
||||||
|
map < string, string > stringTokens = tmplView->GetCustomTokens();
|
||||||
|
map < string, int > intTokens;
|
||||||
|
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
|
||||||
|
}
|
||||||
|
|
||||||
void cDisplayChannelView::Action(void) {
|
void cDisplayChannelView::Action(void) {
|
||||||
SetInitFinished();
|
SetInitFinished();
|
||||||
FadeIn();
|
FadeIn();
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
void DrawChannelGroups(const cChannel *Channel, cString ChannelName);
|
void DrawChannelGroups(const cChannel *Channel, cString ChannelName);
|
||||||
void ClearChannelGroups(void);
|
void ClearChannelGroups(void);
|
||||||
void DisplayMessage(eMessageType Type, const char *Text);
|
void DisplayMessage(eMessageType Type, const char *Text);
|
||||||
|
void DrawCustomTokens(void);
|
||||||
void DoStart(void) { Start(); };
|
void DoStart(void) { Start(); };
|
||||||
void Flush(void) { DoFlush(); };
|
void Flush(void) { DoFlush(); };
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user