added possibility to detach viewelements

This commit is contained in:
louis 2015-03-28 12:00:19 +01:00
commit 3dc2313708
30 changed files with 1357 additions and 794 deletions

View File

@ -228,5 +228,13 @@ Version 0.3.1
Version 0.3.2 Version 0.3.2
<<<<<<< HEAD
- fixed crash in drawing devices - fixed crash in drawing devices
=======
- fixed crash if number of dvb devices changes
- added possibility to detach dedicated viewelements in displaychannel
and displaymenumain that they start in an own thread
- introduced background="true" attribute in viewelements. These areas
will only be drawn once.
>>>>>>> multithread

View File

@ -91,6 +91,7 @@ OBJS = $(PLUGIN).o \
views/view.o \ views/view.o \
views/viewgrid.o \ views/viewgrid.o \
views/viewhelpers.o \ views/viewhelpers.o \
views/displayviewelements.o \
views/displaychannelview.o \ views/displaychannelview.o \
views/displaymenurootview.o \ views/displaymenurootview.o \
views/displaymenuview.o \ views/displaymenuview.o \

View File

@ -86,30 +86,45 @@
<!ELEMENT devices (area|areascroll)*> <!ELEMENT devices (area|areascroll)*>
<!ATTLIST devices <!ATTLIST devices
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT currentweather (area|areascroll)*> <!ELEMENT currentweather (area|areascroll)*>
<!ATTLIST currentweather <!ATTLIST currentweather
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT scrapercontent (area|areascroll)*> <!ELEMENT scrapercontent (area|areascroll)*>
<!ATTLIST scrapercontent <!ATTLIST scrapercontent
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT datetime (area|areascroll)*> <!ELEMENT datetime (area|areascroll)*>
<!ATTLIST datetime <!ATTLIST datetime
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT time (area|areascroll)*> <!ELEMENT time (area|areascroll)*>
<!ATTLIST time <!ATTLIST time
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
@ -122,6 +137,9 @@
<!ELEMENT customtokens (area|areascroll)*> <!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens <!ATTLIST customtokens
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >

View File

@ -53,54 +53,81 @@
<!ELEMENT timers (area|areascroll)*> <!ELEMENT timers (area|areascroll)*>
<!ATTLIST timers <!ATTLIST timers
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT discusage (area|areascroll)*> <!ELEMENT discusage (area|areascroll)*>
<!ATTLIST discusage <!ATTLIST discusage
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT devices (area|areascroll)*> <!ELEMENT devices (area|areascroll)*>
<!ATTLIST devices <!ATTLIST devices
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT systemload (area|areascroll)*> <!ELEMENT systemload (area|areascroll)*>
<!ATTLIST systemload <!ATTLIST systemload
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT systemmemory (area|areascroll)*> <!ELEMENT systemmemory (area|areascroll)*>
<!ATTLIST systemmemory <!ATTLIST systemmemory
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT temperatures (area|areascroll)*> <!ELEMENT temperatures (area|areascroll)*>
<!ATTLIST temperatures <!ATTLIST temperatures
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT currentschedule (area|areascroll)*> <!ELEMENT currentschedule (area|areascroll)*>
<!ATTLIST currentschedule <!ATTLIST currentschedule
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT currentweather (area|areascroll)*> <!ELEMENT currentweather (area|areascroll)*>
<!ATTLIST currentweather <!ATTLIST currentweather
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >
<!ELEMENT customtokens (area|areascroll)*> <!ELEMENT customtokens (area|areascroll)*>
<!ATTLIST customtokens <!ATTLIST customtokens
detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED debug CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
> >

View File

@ -7,6 +7,7 @@
layer CDATA #REQUIRED layer CDATA #REQUIRED
transparency CDATA #IMPLIED transparency CDATA #IMPLIED
condition CDATA #IMPLIED condition CDATA #IMPLIED
background (true|false) #IMPLIED
debug (true|false) #IMPLIED debug (true|false) #IMPLIED
> >

View File

@ -63,6 +63,8 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
p.first = ptHeight; p.first = ptHeight;
} else if (!name.compare("menuitemwidth")) { } else if (!name.compare("menuitemwidth")) {
p.first = ptMenuItemWidth; p.first = ptMenuItemWidth;
} else if (!name.compare("detached")) {
p.first = ptDetached;
} else if (!name.compare("fadetime")) { } else if (!name.compare("fadetime")) {
p.first = ptFadeTime; p.first = ptFadeTime;
} else if (!name.compare("imagetype")) { } else if (!name.compare("imagetype")) {
@ -81,6 +83,8 @@ void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
p.first = ptLayer; p.first = ptLayer;
} else if (!name.compare("transparency")) { } else if (!name.compare("transparency")) {
p.first = ptTransparency; p.first = ptTransparency;
} else if (!name.compare("background")) {
p.first = ptBackground;
} else if (!name.compare("quadrant")) { } else if (!name.compare("quadrant")) {
p.first = ptQuadrant; p.first = ptQuadrant;
} else if (!name.compare("type")) { } else if (!name.compare("type")) {
@ -266,6 +270,12 @@ bool cTemplateFunction::CalculateParameters(void) {
case ptHideRoot: case ptHideRoot:
paramValid = SetHideRoot(value); paramValid = SetHideRoot(value);
break; break;
case ptDetached:
paramValid = SetDetached(value);
break;
case ptBackground:
paramValid = SetBackground(value);
break;
default: default:
paramValid = true; paramValid = true;
break; break;
@ -406,6 +416,10 @@ int cTemplateFunction::GetNumericParameter(eParamType type) {
return 0; return 0;
else if (type == ptHideRoot) else if (type == ptHideRoot)
return 0; return 0;
else if (type == ptDetached)
return 0;
else if (type == ptBackground)
return 0;
return -1; return -1;
} }
return hit->second; return hit->second;
@ -1062,6 +1076,22 @@ bool cTemplateFunction::SetHideRoot(string value) {
return true; return true;
} }
bool cTemplateFunction::SetDetached(string value) {
int detached = 0;
if (!value.compare("true"))
detached = 1;
numericParameters.insert(pair<eParamType, int>(ptDetached, detached));
return true;
}
bool cTemplateFunction::SetBackground(string value) {
int back = 0;
if (!value.compare("true"))
back = 1;
numericParameters.insert(pair<eParamType, int>(ptBackground, back));
return true;
}
void cTemplateFunction::ParseStringParameters(void) { void cTemplateFunction::ParseStringParameters(void) {
//first replace stringtokens in Text (drawText) //first replace stringtokens in Text (drawText)
stringstream text; stringstream text;
@ -1447,6 +1477,9 @@ string cTemplateFunction::GetParamName(eParamType pt) {
case ptMenuItemWidth: case ptMenuItemWidth:
name = "Menu Item Width"; name = "Menu Item Width";
break; break;
case ptDetached:
name = "Detached";
break;
case ptFadeTime: case ptFadeTime:
name = "Fade Time"; name = "Fade Time";
break; break;

View File

@ -45,6 +45,7 @@ enum eParamType {
ptWidth, ptWidth,
ptHeight, ptHeight,
ptMenuItemWidth, ptMenuItemWidth,
ptDetached,
ptFadeTime, ptFadeTime,
ptDelay, ptDelay,
ptImageType, ptImageType,
@ -55,6 +56,7 @@ enum eParamType {
ptText, ptText,
ptLayer, ptLayer,
ptTransparency, ptTransparency,
ptBackground,
ptQuadrant, ptQuadrant,
ptType, ptType,
ptAlign, ptAlign,
@ -152,6 +154,8 @@ protected:
bool SetFloating(string value); bool SetFloating(string value);
bool SetOverflow(string value); bool SetOverflow(string value);
bool SetHideRoot(string value); bool SetHideRoot(string value);
bool SetDetached(string value);
bool SetBackground(string value);
void ParseStringParameters(void); void ParseStringParameters(void);
void ParseNumericalParameters(void); void ParseNumericalParameters(void);
void CalculateAlign(int elementWidth, int elementHeight); void CalculateAlign(int elementWidth, int elementHeight);

View File

@ -12,6 +12,7 @@ cTemplatePixmap::cTemplatePixmap(void) {
containerHeight = 0; containerHeight = 0;
globals = NULL; globals = NULL;
scrolling = false; scrolling = false;
background = false;
} }
cTemplatePixmap::~cTemplatePixmap() { cTemplatePixmap::~cTemplatePixmap() {
@ -171,6 +172,8 @@ bool cTemplatePixmap::CalculateParameters(void) {
} }
} }
background = parameters->GetNumericParameter(ptBackground);
return paramsValid; return paramsValid;
} }

View File

@ -21,6 +21,7 @@ using namespace std;
class cTemplatePixmap { class cTemplatePixmap {
protected: protected:
bool scrolling; bool scrolling;
bool background;
cTemplateFunction *parameters; cTemplateFunction *parameters;
vector<cTemplateFunction*> functions; vector<cTemplateFunction*> functions;
vector<cTemplateFunction*>::iterator funcIt; vector<cTemplateFunction*>::iterator funcIt;
@ -76,6 +77,7 @@ public:
bool DoExecute(void) { return parameters->DoExecute(); }; bool DoExecute(void) { return parameters->DoExecute(); };
bool DoDebug(void) { return parameters->DoDebug(); }; bool DoDebug(void) { return parameters->DoDebug(); };
bool Ready(void); bool Ready(void);
bool BackgroundArea(void) { return background; };
//Traverse Functions //Traverse Functions
void InitIterator(void); void InitIterator(void);
cTemplateFunction *GetNextFunction(void); cTemplateFunction *GetNextFunction(void);

View File

@ -221,6 +221,14 @@ bool cTemplateView::ExecuteView(eViewElement ve) {
return viewElement->Execute(); return viewElement->Execute();
} }
bool cTemplateView::DetachViewElement(eViewElement ve) {
map < eViewElement, cTemplateViewElement* >::iterator hit = viewElements.find(ve);
if (hit == viewElements.end())
return false;
cTemplateViewElement *viewElement = hit->second;
return viewElement->Detach();
}
int cTemplateView::GetNumListViewMenuItems(void) { int cTemplateView::GetNumListViewMenuItems(void) {
int numElements = 0; int numElements = 0;
cTemplateViewList *menuList = GetViewList(vlMenuItem); cTemplateViewList *menuList = GetViewList(vlMenuItem);
@ -613,6 +621,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
string name = "viewelement"; string name = "viewelement";
set<string> attributes; set<string> attributes;
attributes.insert("debug"); attributes.insert("debug");
attributes.insert("detached");
attributes.insert("delay"); attributes.insert("delay");
attributes.insert("fadetime"); attributes.insert("fadetime");
attributes.insert("name"); attributes.insert("name");
@ -629,6 +638,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("height"); attributes.insert("height");
attributes.insert("layer"); attributes.insert("layer");
attributes.insert("transparency"); attributes.insert("transparency");
attributes.insert("background");
funcsAllowed.insert(pair< string, set<string> >(name, attributes)); funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "areascroll"; name = "areascroll";

View File

@ -114,6 +114,7 @@ public:
int GetNumPixmapsViewElement(eViewElement ve); int GetNumPixmapsViewElement(eViewElement ve);
bool HideView(void); bool HideView(void);
bool ExecuteView(eViewElement ve); bool ExecuteView(eViewElement ve);
bool DetachViewElement(eViewElement ve);
int GetNumListViewMenuItems(void); int GetNumListViewMenuItems(void);
bool GetScalingWindow(cRect &scalingWindow); bool GetScalingWindow(cRect &scalingWindow);
map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); };

View File

@ -124,6 +124,14 @@ bool cTemplateViewElement::Execute(void) {
return parameters->DoExecute(); return parameters->DoExecute();
} }
bool cTemplateViewElement::Detach(void) {
if (!parameters)
return false;
int detached = parameters->GetNumericParameter(ptDetached);
if (detached == 1)
return true;
return false;
}
bool cTemplateViewElement::DebugTokens(void) { bool cTemplateViewElement::DebugTokens(void) {
if (!parameters) if (!parameters)
@ -136,6 +144,7 @@ void cTemplateViewElement::Debug(void) {
esyslog("skindesigner: viewelement container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight); esyslog("skindesigner: viewelement container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight);
if (parameters) if (parameters)
parameters->Debug(); parameters->Debug();
return;
for (vector<cTemplatePixmap*>::iterator it = viewPixmaps.begin(); it != viewPixmaps.end(); it++) { for (vector<cTemplatePixmap*>::iterator it = viewPixmaps.begin(); it != viewPixmaps.end(); it++) {
(*it)->Debug(); (*it)->Debug();
} }

View File

@ -107,6 +107,7 @@ public:
cTemplatePixmap *GetNextPixmap(void); cTemplatePixmap *GetNextPixmap(void);
cTemplateFunction *GetFunction(string name); cTemplateFunction *GetFunction(string name);
bool Execute(void); bool Execute(void);
bool Detach(void);
bool DebugTokens(void); bool DebugTokens(void);
virtual void Debug(void); virtual void Debug(void);
}; };

View File

@ -52,7 +52,7 @@
</area> </area>
</scrollbar> </scrollbar>
<currentweather> <currentweather detached="true" delay="100" fadetime="0">
<area x="40%" y="0" width="15%" height="8%" layer="3"> <area x="40%" y="0" width="15%" height="8%" layer="3">
<drawimage name="weathericon" imagetype="icon" path="{icon}" align="right" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/> <drawimage name="weathericon" imagetype="icon" path="{icon}" align="right" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/>
<drawtext name="temperature" x="{areawidth} - {width(weathericon)} - {width(temperature)} - 10" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{temperature}°C" /> <drawtext name="temperature" x="{areawidth} - {width(weathericon)} - {width(temperature)} - 10" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{temperature}°C" />
@ -75,7 +75,7 @@
{timers[channelid]} ChannelID of channel {timers[channelid]} ChannelID of channel
{timers[channellogoexists]} true if channel logo exists {timers[channellogoexists]} true if channel logo exists
--> -->
<timers> <timers detached="true" delay="100" fadetime="0">
<area condition="not{numtimers}" x="55%" y="71%" width="44%" height="19%" layer="2"> <area condition="not{numtimers}" x="55%" y="71%" width="44%" height="19%" layer="2">
<drawtext align="center" valign="center" font="{semibold}" fontsize="40%" color="{clrWhite}" text="{tr(noactivetimers)}" /> <drawtext align="center" valign="center" font="{semibold}" fontsize="40%" color="{clrWhite}" text="{tr(noactivetimers)}" />
</area> </area>
@ -97,7 +97,7 @@
{discalert} true if disc usage is > 95% {discalert} true if disc usage is > 95%
{vdrusagestring} localized VDR internal usage string {vdrusagestring} localized VDR internal usage string
--> -->
<discusage> <discusage detached="true" delay="100" fadetime="0">
<area x="55%" y="51%" width="44%" height="19%" layer="5"> <area x="55%" y="51%" width="44%" height="19%" layer="5">
<drawimage imagetype="skinpart" path="tachohands/perc_{usedpercent}" x="{areawidth}*0.025" y="5%" width="20%" height="{areawidth}*0.20"/> <drawimage imagetype="skinpart" path="tachohands/perc_{usedpercent}" x="{areawidth}*0.025" y="5%" width="20%" height="{areawidth}*0.20"/>
</area> </area>
@ -131,7 +131,7 @@
{load} current system load {load} current system load
{loadhand} system load for tacho hand (between 0 and 2.5 in 0.025 steps multiplied by 1000, >2.5 is always 2525) {loadhand} system load for tacho hand (between 0 and 2.5 in 0.025 steps multiplied by 1000, >2.5 is always 2525)
--> -->
<systemload> <systemload detached="true" delay="100" fadetime="0">
<area x="55%" y="51%" width="44%" height="19%" layer="5"> <area x="55%" y="51%" width="44%" height="19%" layer="5">
<drawimage imagetype="skinpart" path="tachohands/load_{loadhand}" x="{areawidth}*0.28" y="5%" width="20%" height="{areawidth}*0.20"/> <drawimage imagetype="skinpart" path="tachohands/load_{loadhand}" x="{areawidth}*0.28" y="5%" width="20%" height="{areawidth}*0.20"/>
</area> </area>
@ -144,7 +144,7 @@
{cputemp} current cpu temperature in °C {cputemp} current cpu temperature in °C
{gputemp} current gpu temperature in °C {gputemp} current gpu temperature in °C
--> -->
<temperatures> <temperatures detached="true" delay="100" fadetime="0">
<area x="55%" y="51%" width="44%" height="19%" layer="5"> <area x="55%" y="51%" width="44%" height="19%" layer="5">
<drawimage condition="gt({cputemp}, 80)" imagetype="skinpart" path="tachohands/temp_81" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/> <drawimage condition="gt({cputemp}, 80)" imagetype="skinpart" path="tachohands/temp_81" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/>
<drawimage condition="lt({cputemp}, 81)" imagetype="skinpart" path="tachohands/temp_{cputemp}" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/> <drawimage condition="lt({cputemp}, 81)" imagetype="skinpart" path="tachohands/temp_{cputemp}" x="{areawidth}*0.53" y="5%" width="20%" height="{areawidth}*0.2"/>

View File

@ -7,16 +7,6 @@
<area x="0" y="80%" width="100%" height="20%" layer="1"> <area x="0" y="80%" width="100%" height="20%" layer="1">
<fill color="{clrTransBlack}" /> <fill color="{clrTransBlack}" />
</area> </area>
<!-- background datetime -->
<area x="70%" y="0" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<!-- background weather -->
<area x="70%" y="15%" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<!-- background channellogo --> <!-- background channellogo -->
<area x="0" y="80%" width="20%" height="20%" layer="2"> <area x="0" y="80%" width="20%" height="20%" layer="2">
<fill color="{clrTransBlueLight}" /> <fill color="{clrTransBlueLight}" />
@ -196,8 +186,8 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices condition="{showdevices}" > <devices condition="{showdevices}" detached="true" delay="100" fadetime="{fadetime}">
<area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1"> <area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1" background="true">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>
<area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="2"> <area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="2">
@ -235,6 +225,10 @@
{ozone} ozone value in DU {ozone} ozone value in DU
--> -->
<currentweather> <currentweather>
<area background="true" x="70%" y="15%" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<area x="70%" y="15%" width="13%" height="13%" layer="2"> <area x="70%" y="15%" width="13%" height="13%" layer="2">
<drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/> <drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/>
</area> </area>
@ -284,6 +278,10 @@
{year} year in yyyy {year} year in yyyy
--> -->
<datetime> <datetime>
<area background="true" x="70%" y="0" width="30%" height="13%" layer="1">
<fill color="{clrTransBlack}" />
<drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" />
</area>
<area x="70%" y="0" width="13%" height="13%" layer="2"> <area x="70%" y="0" width="13%" height="13%" layer="2">
<drawtext align="right" y="0" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname}" /> <drawtext align="right" y="0" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname}" />
<drawtext align="right" y="48%" font="{light}" fontsize="50%" color="{clrWhite}" text="{day}. {monthnameshort}" /> <drawtext align="right" y="48%" font="{light}" fontsize="50%" color="{clrWhite}" text="{day}. {monthnameshort}" />

View File

@ -120,7 +120,7 @@
{timers[channelid]} ChannelID of channel {timers[channelid]} ChannelID of channel
{timers[channellogoexists]} true if channel logo exists {timers[channellogoexists]} true if channel logo exists
--> -->
<timers> <timers detached="true" delay="100" fadetime="0">
<area x="0" y="75%" width="{areawidth}/8 - 5" height="25%" layer="1"> <area x="0" y="75%" width="{areawidth}/8 - 5" height="25%" layer="1">
<fill color="{clrTransBlack}" /> <fill color="{clrTransBlack}" />
</area> </area>
@ -174,8 +174,8 @@
{discalert} true if disc usage is > 95% {discalert} true if disc usage is > 95%
{vdrusagestring} localized VDR internal usage string {vdrusagestring} localized VDR internal usage string
--> -->
<discusage> <discusage detached="true" delay="100" fadetime="0">
<area x="75%" y="26%" width="25%" height="10%" layer="1"> <area background="true" x="75%" y="26%" width="25%" height="10%" layer="1">
<fill condition="not{discalert}" color="{clrTransBlack}"/> <fill condition="not{discalert}" color="{clrTransBlack}"/>
<fill condition="{discalert}" color="{clrRed}"/> <fill condition="{discalert}" color="{clrRed}"/>
</area> </area>
@ -206,7 +206,7 @@
{pressure} pressure in HPo {pressure} pressure in HPo
{ozone} ozone value in DU {ozone} ozone value in DU
--> -->
<currentweather> <currentweather detached="true" delay="100" fadetime="0">
<area x="75%" y="13%" width="25%" height="10%" layer="2"> <area x="75%" y="13%" width="25%" height="10%" layer="2">
<drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" /> <drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" />
<drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" /> <drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" />
@ -240,8 +240,8 @@
{devices[channelid]} ID of the currently tuned channel {devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel {devices[source]} source of the currently tuned channel
--> -->
<devices condition="{showdevices}"> <devices condition="{showdevices}" detached="true" delay="100" fadetime="0">
<area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="1"> <area background="true" x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="1">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>
<area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="2"> <area x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="2">
@ -261,8 +261,8 @@
<!-- Available Variables systemload: <!-- Available Variables systemload:
{load} current system load {load} current system load
--> -->
<systemload> <systemload detached="true" delay="100" fadetime="0">
<area x="75%" y="40%" width="25%" height="5%" layer="1"> <area background="true" x="75%" y="40%" width="25%" height="5%" layer="1">
<fill color="{clrTransBlack}"/> <fill color="{clrTransBlack}"/>
</area> </area>
<area x="75%" y="40%" width="25%" height="5%" layer="2"> <area x="75%" y="40%" width="25%" height="5%" layer="2">

View File

@ -28,7 +28,7 @@
{timers[channelid]} ChannelID of channel {timers[channelid]} ChannelID of channel
{timers[channellogoexists]} true if channel logo exists {timers[channellogoexists]} true if channel logo exists
--> -->
<timers> <timers detached="true" delay="100" fadetime="0">
<area x="85%" y="28%" width="14%" height="60%" layer="1"> <area x="85%" y="28%" width="14%" height="60%" layer="1">
<drawrectangle condition="gt({numtimers}, 0)" x="0" y="0" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" /> <drawrectangle condition="gt({numtimers}, 0)" x="0" y="0" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" />
<drawrectangle condition="gt({numtimers}, 1)" x="0" y="{areaheight} / 4" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" /> <drawrectangle condition="gt({numtimers}, 1)" x="0" y="{areaheight} / 4" width="{areawidth}" height="{areaheight} / 4 * 99 / 100" color="{clrTransBlack}" />
@ -61,8 +61,8 @@
{discalert} true if disc usage is > 95% {discalert} true if disc usage is > 95%
{vdrusagestring} localized VDR internal usage string {vdrusagestring} localized VDR internal usage string
--> -->
<discusage> <discusage detached="true" delay="100" fadetime="0">
<area x="89%" y="11%" width="10%" height="16%" layer="1"> <area background="true" x="89%" y="11%" width="10%" height="16%" layer="1">
<fill condition="lt({freepercent}, 6)" color="{clrTransRed}" /> <fill condition="lt({freepercent}, 6)" color="{clrTransRed}" />
<fill condition="gt({freepercent}, 5)" color="{clrBackground}" /> <fill condition="gt({freepercent}, 5)" color="{clrBackground}" />
<drawimage imagetype="skinpart" path="discpercent" x="0" y="82%" width="{areawidth}" height="18%"/> <drawimage imagetype="skinpart" path="discpercent" x="0" y="82%" width="{areawidth}" height="18%"/>
@ -75,8 +75,8 @@
</area> </area>
</discusage> </discusage>
<currentweather> <currentweather detached="true" delay="100" fadetime="0">
<area x="63%" y="11%" width="25%" height="16%" layer="1"> <area background="true" x="63%" y="11%" width="25%" height="16%" layer="1">
<fill color="{clrBackground}"/> <fill color="{clrBackground}"/>
</area> </area>
<area x="63%" y="11%" width="25%" height="16%" layer="2"> <area x="63%" y="11%" width="25%" height="16%" layer="2">

View File

@ -2,15 +2,13 @@
#include <vdr/menu.h> #include <vdr/menu.h>
#include "../services/scraper2vdr.h" #include "../services/scraper2vdr.h"
#include "displaychannelview.h" #include "displaychannelview.h"
#include "displayviewelements.h"
#include "../libcore/timers.h" #include "../libcore/timers.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplView) { cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplView) {
lastScreenWidth = 0; lastScreenWidth = 0;
lastScreenHeight = 0; lastScreenHeight = 0;
lastSignalDisplay = 0;
lastSignalStrength = 0;
lastSignalQuality = 0;
lastNumAudioTracks = 0; lastNumAudioTracks = 0;
lastAudioChannel = -1; lastAudioChannel = -1;
lastTracDesc = ""; lastTracDesc = "";
@ -64,6 +62,17 @@ void cDisplayChannelView::DrawDate(void) {
return; return;
} }
if (DetachViewElement(veDateTime)) {
cViewElement *viewElement = GetViewElement(veDateTime);
if (!viewElement) {
viewElement = new cViewElementDate(tmplView->GetViewElement(veDateTime));
AddViewElement(veDateTime, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
@ -74,12 +83,24 @@ void cDisplayChannelView::DrawDate(void) {
ClearViewElement(veDateTime); ClearViewElement(veDateTime);
DrawViewElement(veDateTime, &stringTokens, &intTokens); DrawViewElement(veDateTime, &stringTokens, &intTokens);
} }
}
void cDisplayChannelView::DrawTime(void) { void cDisplayChannelView::DrawTime(void) {
if (!ExecuteViewElement(veTime)) { if (!ExecuteViewElement(veTime)) {
return; return;
} }
if (DetachViewElement(veTime)) {
cViewElement *viewElement = GetViewElement(veTime);
if (!viewElement) {
viewElement = new cViewElementTime(tmplView->GetViewElement(veTime));
AddViewElement(veTime, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
@ -89,6 +110,7 @@ void cDisplayChannelView::DrawTime(void) {
ClearViewElement(veTime); ClearViewElement(veTime);
DrawViewElement(veTime, &stringTokens, &intTokens); DrawViewElement(veTime, &stringTokens, &intTokens);
} }
}
void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Current, int Total) { void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Current, int Total) {
if (!ExecuteViewElement(veProgressBar)) { if (!ExecuteViewElement(veProgressBar)) {
@ -315,72 +337,22 @@ void cDisplayChannelView::DrawScraperContent(const cEvent *event) {
return; return;
} }
static cPlugin *pScraper = GetScraperPlugin(); if (DetachViewElement(veScraperContent)) {
if (!pScraper) { cViewElement *viewElement = GetViewElement(veScraperContent);
return; if (!viewElement) {
viewElement = new cViewElementScraperContent(event, ctPosterBanner, tmplView->GetViewElement(veScraperContent));
AddViewElement(veScraperContent, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
} }
} else {
ScraperGetPosterBanner call;
call.event = event;
if (pScraper->Service("GetPosterBanner", &call)) {
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;
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 = NULL;
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;
} else
return;
map < string, int > intTokens;
map < string, string > stringTokens; map < string, string > stringTokens;
intTokens.insert(pair<string,int>("mediawidth", mediaWidth)); map < string, int > intTokens;
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner)); SetPosterBanner(event, stringTokens, intTokens);
stringTokens.insert(pair<string,string>("mediapath", mediaPath)); ClearScraperContent();
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
ClearViewElement(veScraperContent);
DrawViewElement(veScraperContent, &stringTokens, &intTokens); DrawViewElement(veScraperContent, &stringTokens, &intTokens);
} }
} }
@ -393,35 +365,27 @@ void cDisplayChannelView::DrawSignal(void) {
if (!ExecuteViewElement(veSignalQuality)) { if (!ExecuteViewElement(veSignalQuality)) {
return; return;
} }
time_t Now = time(NULL);
if (Now != lastSignalDisplay) { if (DetachViewElement(veSignalQuality)) {
#ifdef DOPROFILE cViewElement *viewElement = GetViewElement(veSignalQuality);
cStopWatch watch("DrawSignal"); if (!viewElement) {
#endif viewElement = new cViewElementSignal(tmplView->GetViewElement(veSignalQuality));
int SignalStrength = cDevice::ActualDevice()->SignalStrength(); AddViewElement(veSignalQuality, viewElement);
#ifdef DOPROFILE viewElement->Start();
watch.Report("SignalStrength"); } else {
#endif if (!viewElement->Starting())
int SignalQuality = cDevice::ActualDevice()->SignalQuality(); viewElement->Render();
#ifdef DOPROFILE
watch.Report("SignalQuality");
watch.Stop("DrawSignal");
#endif
if (SignalStrength < 0) SignalStrength = 0;
if (SignalQuality < 0) SignalQuality = 0;
if ((SignalStrength == 0)&&(SignalQuality==0))
return;
if ((lastSignalStrength != SignalStrength) || (lastSignalQuality != SignalQuality)) {
map < string, int > intTokens;
map < string, string > stringTokens;
intTokens.insert(pair<string,int>("signalstrength", SignalStrength));
intTokens.insert(pair<string,int>("signalquality", SignalQuality));
ClearViewElement(veSignalQuality);
DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
} }
lastSignalStrength = SignalStrength; } else {
lastSignalQuality = SignalQuality; map < string, string > stringTokens;
lastSignalDisplay = Now; map < string, int > intTokens;
bool changed = SetSignal(intTokens);
if (!changed)
return;
ClearSignal();
DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
} }
} }
@ -445,6 +409,18 @@ void cDisplayChannelView::DrawDevices(bool initial) {
if (!ExecuteViewElement(veDevices)) { if (!ExecuteViewElement(veDevices)) {
return; return;
} }
if (DetachViewElement(veDevices)) {
cViewElement *viewElement = GetViewElement(veDevices);
if (!viewElement) {
viewElement = new cViewElementDevices(tmplView->GetViewElement(veDevices));
AddViewElement(veDevices, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens; map < string, vector< map< string, string > > > deviceLoopTokens;
@ -456,9 +432,10 @@ void cDisplayChannelView::DrawDevices(bool initial) {
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices)); deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices); ClearDevices();
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens); DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
} }
}
void cDisplayChannelView::ClearDevices(void) { void cDisplayChannelView::ClearDevices(void) {
ClearViewElement(veDevices); ClearViewElement(veDevices);
@ -472,8 +449,8 @@ void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString Cha
bool separatorExists = imgCache->SeparatorLogoExists(*ChannelName); bool separatorExists = imgCache->SeparatorLogoExists(*ChannelName);
string separatorPath = separatorExists ? *ChannelName : ""; string separatorPath = separatorExists ? *ChannelName : "";
std::string prevChannelSep = GetChannelSep(Channel, true); string prevChannelSep = GetChannelSep(Channel, true);
std::string nextChannelSep = GetChannelSep(Channel, false); string nextChannelSep = GetChannelSep(Channel, false);
bool prevAvailable = (prevChannelSep.size() > 0)?true:false; bool prevAvailable = (prevChannelSep.size() > 0)?true:false;
bool nextAvailable = (nextChannelSep.size() > 0)?true:false; bool nextAvailable = (nextChannelSep.size() > 0)?true:false;
@ -497,7 +474,7 @@ void cDisplayChannelView::ClearChannelGroups(void) {
} }
string cDisplayChannelView::GetChannelSep(const cChannel *channel, bool prev) { string cDisplayChannelView::GetChannelSep(const cChannel *channel, bool prev) {
std::string sepName = ""; string sepName = "";
const cChannel *sep = prev ? Channels.Prev(channel) : const cChannel *sep = prev ? Channels.Prev(channel) :
Channels.Next(channel); Channels.Next(channel);
for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) { for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) {
@ -535,25 +512,50 @@ void cDisplayChannelView::DrawCustomTokens(void) {
} }
if (!tmplView) if (!tmplView)
return; return;
if (DetachViewElement(veCustomTokens)) {
cViewElement *viewElement = GetViewElement(veCustomTokens);
if (!viewElement) {
viewElement = new cViewElementCustomTokens(tmplView->GetViewElement(veCustomTokens), tmplView);
AddViewElement(veCustomTokens, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
} }
}
void cDisplayChannelView::DrawCurrentWeather(void) { void cDisplayChannelView::DrawCurrentWeather(void) {
if (!ExecuteViewElement(veCurrentWeather)) { if (!ExecuteViewElement(veCurrentWeather)) {
return; return;
} }
if (DetachViewElement(veCurrentWeather)) {
cViewElement *viewElement = GetViewElement(veCurrentWeather);
if (!viewElement) {
viewElement = new cViewElementWeather(tmplView->GetViewElement(veCurrentWeather));
AddViewElement(veCurrentWeather, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){ if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather); ClearViewElement(veCurrentWeather);
return; return;
} }
ClearViewElement(veCurrentWeather); ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens); DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
} }
}
void cDisplayChannelView::Action(void) { void cDisplayChannelView::Action(void) {

View File

@ -9,9 +9,6 @@ class cDisplayChannelView : public cView, public cViewHelpers {
private: private:
int lastScreenWidth; int lastScreenWidth;
int lastScreenHeight; int lastScreenHeight;
int lastSignalDisplay;
int lastSignalStrength;
int lastSignalQuality;
int lastNumAudioTracks; int lastNumAudioTracks;
int lastAudioChannel; int lastAudioChannel;
string lastTracDesc; string lastTracDesc;

View File

@ -5,13 +5,10 @@
#include "displaymenuitemcurrentview.h" #include "displaymenuitemcurrentview.h"
cDisplayMenuItemCurrentView::cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent) : cView(tmplCurrent) { cDisplayMenuItemCurrentView::cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent) : cViewElement(tmplCurrent) {
delay = tmplItem->GetNumericParameter(ptDelay);
SetFadeTime(tmplItem->GetNumericParameter(ptFadeTime));
} }
cDisplayMenuItemCurrentView::~cDisplayMenuItemCurrentView() { cDisplayMenuItemCurrentView::~cDisplayMenuItemCurrentView() {
CancelSave();
} }
void cDisplayMenuItemCurrentView::SetPosMenuItem(cRect &pos) { void cDisplayMenuItemCurrentView::SetPosMenuItem(cRect &pos) {
@ -65,39 +62,13 @@ cDisplayMenuItemCurrentMainView::cDisplayMenuItemCurrentMainView(cTemplateViewEl
this->icon = icon; this->icon = icon;
} }
cDisplayMenuItemCurrentMainView::~cDisplayMenuItemCurrentMainView() { bool cDisplayMenuItemCurrentMainView::Render(void) {
}
void cDisplayMenuItemCurrentMainView::Prepare(void) {
}
void cDisplayMenuItemCurrentMainView::Render(void) {
stringTokens.insert(pair<string,string>("number", number)); stringTokens.insert(pair<string,string>("number", number));
stringTokens.insert(pair<string,string>("label", label)); stringTokens.insert(pair<string,string>("label", label));
stringTokens.insert(pair<string,string>("icon", icon)); stringTokens.insert(pair<string,string>("icon", icon));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens);
} return true;
void cDisplayMenuItemCurrentMainView::Clear(void) {
}
void cDisplayMenuItemCurrentMainView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
} }
/************************************************************* /*************************************************************
@ -113,14 +84,7 @@ cDisplayMenuItemCurrentSchedulesView::cDisplayMenuItemCurrentSchedulesView(cTemp
this->isEpgSearchFav = isEpgSearchFav; this->isEpgSearchFav = isEpgSearchFav;
} }
cDisplayMenuItemCurrentSchedulesView::~cDisplayMenuItemCurrentSchedulesView() { bool cDisplayMenuItemCurrentSchedulesView::Render(void) {
}
void cDisplayMenuItemCurrentSchedulesView::Prepare(void) {
}
void cDisplayMenuItemCurrentSchedulesView::Render(void) {
intTokens.insert(pair<string,int>("whatson", (cat == mcSchedule)&&(!isEpgSearchFav) ? true: false)); intTokens.insert(pair<string,int>("whatson", (cat == mcSchedule)&&(!isEpgSearchFav) ? true: false));
intTokens.insert(pair<string,int>("whatsonnow", (cat == mcScheduleNow) ? true: false)); intTokens.insert(pair<string,int>("whatsonnow", (cat == mcScheduleNow) ? true: false));
intTokens.insert(pair<string,int>("whatsonnext", (cat == mcScheduleNext) ? true: false)); intTokens.insert(pair<string,int>("whatsonnext", (cat == mcScheduleNext) ? true: false));
@ -182,26 +146,7 @@ void cDisplayMenuItemCurrentSchedulesView::Render(void) {
loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens)); loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} return true;
void cDisplayMenuItemCurrentSchedulesView::Clear(void) {
}
void cDisplayMenuItemCurrentSchedulesView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
} }
void cDisplayMenuItemCurrentSchedulesView::ReadSchedules(vector< map<string,string> > *schedulesTokens) { void cDisplayMenuItemCurrentSchedulesView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
@ -236,16 +181,9 @@ cDisplayMenuItemCurrentChannelView::cDisplayMenuItemCurrentChannelView(cTemplate
this->channel = channel; this->channel = channel;
} }
cDisplayMenuItemCurrentChannelView::~cDisplayMenuItemCurrentChannelView() { bool cDisplayMenuItemCurrentChannelView::Render(void) {
}
void cDisplayMenuItemCurrentChannelView::Prepare(void) {
}
void cDisplayMenuItemCurrentChannelView::Render(void) {
if (!channel) if (!channel)
return; return false;
//general channel information //general channel information
intTokens.insert(pair<string,int>("number", channel->Number())); intTokens.insert(pair<string,int>("number", channel->Number()));
intTokens.insert(pair<string,int>("transponder", channel->Transponder())); intTokens.insert(pair<string,int>("transponder", channel->Transponder()));
@ -340,26 +278,7 @@ void cDisplayMenuItemCurrentChannelView::Render(void) {
loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens)); loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} return true;
void cDisplayMenuItemCurrentChannelView::Clear(void) {
}
void cDisplayMenuItemCurrentChannelView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
} }
void cDisplayMenuItemCurrentChannelView::ReadSchedules(vector< map<string,string> > *schedulesTokens) { void cDisplayMenuItemCurrentChannelView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
@ -398,16 +317,9 @@ cDisplayMenuItemCurrentTimerView::cDisplayMenuItemCurrentTimerView(cTemplateView
this->timer = timer; this->timer = timer;
} }
cDisplayMenuItemCurrentTimerView::~cDisplayMenuItemCurrentTimerView() { bool cDisplayMenuItemCurrentTimerView::Render(void) {
}
void cDisplayMenuItemCurrentTimerView::Prepare(void) {
}
void cDisplayMenuItemCurrentTimerView::Render(void) {
if (!timer) if (!timer)
return; return false;
intTokens.insert(pair<string,int>("flagactive", timer->HasFlags(tfActive))); intTokens.insert(pair<string,int>("flagactive", timer->HasFlags(tfActive)));
intTokens.insert(pair<string,int>("flaginstant", timer->HasFlags(tfInstant))); intTokens.insert(pair<string,int>("flaginstant", timer->HasFlags(tfInstant)));
intTokens.insert(pair<string,int>("flagvps", timer->HasFlags(tfVps))); intTokens.insert(pair<string,int>("flagvps", timer->HasFlags(tfVps)));
@ -489,26 +401,7 @@ void cDisplayMenuItemCurrentTimerView::Render(void) {
} }
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens);
} return true;
void cDisplayMenuItemCurrentTimerView::Clear(void) {
}
void cDisplayMenuItemCurrentTimerView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
} }
/************************************************************* /*************************************************************
@ -523,16 +416,9 @@ cDisplayMenuItemCurrentRecordingView::cDisplayMenuItemCurrentRecordingView(cTemp
this->newRecs = newRecs; this->newRecs = newRecs;
} }
cDisplayMenuItemCurrentRecordingView::~cDisplayMenuItemCurrentRecordingView() { bool cDisplayMenuItemCurrentRecordingView::Render(void) {
}
void cDisplayMenuItemCurrentRecordingView::Prepare(void) {
}
void cDisplayMenuItemCurrentRecordingView::Render(void) {
if (!recording) if (!recording)
return; return false;
map < string, vector< map< string, string > > > loopTokens; map < string, vector< map< string, string > > > loopTokens;
bool isFolder = (total > 0) ? true : false; bool isFolder = (total > 0) ? true : false;
@ -586,7 +472,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
const cRecordingInfo *info = usedRecording->Info(); const cRecordingInfo *info = usedRecording->Info();
if (!info) return; if (!info) return true;
bool extRecinfoAvailable = false; bool extRecinfoAvailable = false;
if (info->Aux()) { if (info->Aux()) {
@ -627,7 +513,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : "")); stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : ""));
const cEvent *event = info->GetEvent(); const cEvent *event = info->GetEvent();
if (!event) return; if (!event) return true;
string recDate = *(event->GetDateString()); string recDate = *(event->GetDateString());
string recTime = *(event->GetTimeString()); string recTime = *(event->GetTimeString());
@ -656,26 +542,7 @@ void cDisplayMenuItemCurrentRecordingView::Render(void) {
stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60))); stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} return true;
void cDisplayMenuItemCurrentRecordingView::Clear(void) {
}
void cDisplayMenuItemCurrentRecordingView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
} }
/************************************************************* /*************************************************************
@ -691,34 +558,8 @@ cDisplayMenuItemCurrentPluginView::cDisplayMenuItemCurrentPluginView(cTemplateVi
loopTokens = pluginLoopTokens; loopTokens = pluginLoopTokens;
} }
cDisplayMenuItemCurrentPluginView::~cDisplayMenuItemCurrentPluginView() { bool cDisplayMenuItemCurrentPluginView::Render(void) {
}
void cDisplayMenuItemCurrentPluginView::Prepare(void) {
}
void cDisplayMenuItemCurrentPluginView::Render(void) {
SetTokensPosMenuItem(); SetTokensPosMenuItem();
DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens); DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
} return true;
void cDisplayMenuItemCurrentPluginView::Clear(void) {
}
void cDisplayMenuItemCurrentPluginView::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
} }

View File

@ -4,12 +4,9 @@
#include "../libtemplate/template.h" #include "../libtemplate/template.h"
#include "view.h" #include "view.h"
class cDisplayMenuItemCurrentView : public cView { class cDisplayMenuItemCurrentView : public cViewElement {
private: private:
protected: protected:
int delay;
map < string, string > stringTokens;
map < string, int > intTokens;
cRect posMenuItem; cRect posMenuItem;
void SetTokensPosMenuItem(void); void SetTokensPosMenuItem(void);
void SetScraperPoster(const cEvent *event, const cRecording *recording=NULL); void SetScraperPoster(const cEvent *event, const cRecording *recording=NULL);
@ -17,9 +14,6 @@ public:
cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent); cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent);
virtual ~cDisplayMenuItemCurrentView(); virtual ~cDisplayMenuItemCurrentView();
void SetPosMenuItem(cRect &pos); void SetPosMenuItem(cRect &pos);
virtual void Prepare(void) {};
virtual void Render(void) {};
virtual void Clear(void) {};
}; };
class cDisplayMenuItemCurrentMainView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentMainView: public cDisplayMenuItemCurrentView {
@ -27,13 +21,10 @@ private:
string number; string number;
string label; string label;
string icon; string icon;
void Action(void);
public: public:
cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon); cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon);
virtual ~cDisplayMenuItemCurrentMainView(); virtual ~cDisplayMenuItemCurrentMainView() {};
void Prepare(void); bool Render(void);
void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentSchedulesView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentSchedulesView: public cDisplayMenuItemCurrentView {
@ -43,39 +34,30 @@ private:
eTimerMatch timerMatch; eTimerMatch timerMatch;
eMenuCategory cat; eMenuCategory cat;
bool isEpgSearchFav; bool isEpgSearchFav;
void Action(void);
void ReadSchedules(vector< map<string,string> > *schedulesTokens); void ReadSchedules(vector< map<string,string> > *schedulesTokens);
public: public:
cDisplayMenuItemCurrentSchedulesView(cTemplateViewElement *tmplCurrent, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav); cDisplayMenuItemCurrentSchedulesView(cTemplateViewElement *tmplCurrent, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav);
virtual ~cDisplayMenuItemCurrentSchedulesView(); virtual ~cDisplayMenuItemCurrentSchedulesView() {};
void Prepare(void); bool Render(void);
void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentChannelView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentChannelView: public cDisplayMenuItemCurrentView {
private: private:
const cChannel *channel; const cChannel *channel;
void Action(void);
void ReadSchedules(vector< map<string,string> > *schedulesTokens); void ReadSchedules(vector< map<string,string> > *schedulesTokens);
public: public:
cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel); cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel);
virtual ~cDisplayMenuItemCurrentChannelView(); virtual ~cDisplayMenuItemCurrentChannelView() {};
void Prepare(void); bool Render(void);
void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentTimerView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentTimerView: public cDisplayMenuItemCurrentView {
private: private:
const cTimer *timer; const cTimer *timer;
void Action(void);
public: public:
cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer); cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer);
virtual ~cDisplayMenuItemCurrentTimerView(); virtual ~cDisplayMenuItemCurrentTimerView() {};
void Prepare(void); bool Render(void);
void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentRecordingView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentRecordingView: public cDisplayMenuItemCurrentView {
@ -84,25 +66,19 @@ private:
int level; int level;
int total; int total;
int newRecs; int newRecs;
void Action(void);
public: public:
cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs); cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs);
virtual ~cDisplayMenuItemCurrentRecordingView(); virtual ~cDisplayMenuItemCurrentRecordingView() {};
void Prepare(void); bool Render(void);
void Render(void);
void Clear(void);
}; };
class cDisplayMenuItemCurrentPluginView: public cDisplayMenuItemCurrentView { class cDisplayMenuItemCurrentPluginView: public cDisplayMenuItemCurrentView {
private: private:
map<string,vector<map<string,string> > > loopTokens; map<string,vector<map<string,string> > > loopTokens;
void Action(void);
public: public:
cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens, map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens); cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens, map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens);
virtual ~cDisplayMenuItemCurrentPluginView(); virtual ~cDisplayMenuItemCurrentPluginView() {};
void Prepare(void); bool Render(void);
void Render(void);
void Clear(void);
}; };
#endif //__DISPLAYMENUITEMCURRENTVIEW_H #endif //__DISPLAYMENUITEMCURRENTVIEW_H

View File

@ -1,12 +1,13 @@
#define __STL_CONFIG_H #define __STL_CONFIG_H
#include <vdr/menu.h> #include <vdr/menu.h>
#include <vdr/videodir.h>
#include "displaymenurootview.h" #include "displaymenurootview.h"
#include "displayviewelements.h"
#include "../config.h" #include "../config.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) { cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) {
cat = mcUndefined; cat = mcUndefined;
menuTitle = "";
viewType = svUndefined; viewType = svUndefined;
subView = NULL; subView = NULL;
subViewAvailable = false; subViewAvailable = false;
@ -479,37 +480,9 @@ void cDisplayMenuRootView::DrawHeader(void) {
if (!ExecuteViewElement(veHeader)) { if (!ExecuteViewElement(veHeader)) {
return; return;
} }
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
stringTokens.insert(pair<string,string>("title", menuTitle));
stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
//check for standard menu entries
bool hasIcon = false;
string icon = imgCache->GetIconName(menuTitle, cat);
if (imgCache->MenuIconExists(icon))
hasIcon = true;
stringTokens.insert(pair<string,string>("icon", icon));
intTokens.insert(pair<string,int>("hasicon", hasIcon));
//Disc Usage
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
ClearViewElement(veHeader); ClearViewElement(veHeader);
DrawViewElement(veHeader, &stringTokens, &intTokens); DrawViewElement(veHeader, &stringTokens, &intTokens);
} }

View File

@ -1,13 +1,10 @@
#define __STL_CONFIG_H #define __STL_CONFIG_H
#include <fstream>
#include <iostream>
#include <sys/sysinfo.h>
#include <vdr/menu.h> #include <vdr/menu.h>
#include <vdr/videodir.h> #include <vdr/videodir.h>
#include "displaymenuview.h" #include "displaymenuview.h"
#include "displayviewelements.h"
#include "../config.h" #include "../config.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
#include "../libcore/timers.h"
#include "../services/scraper2vdr.h" #include "../services/scraper2vdr.h"
cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cView(tmplView) { cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cView(tmplView) {
@ -39,35 +36,9 @@ bool cDisplayMenuView::DrawHeader(void) {
if (!ExecuteViewElement(veHeader)) { if (!ExecuteViewElement(veHeader)) {
return false; return false;
} }
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
stringTokens.insert(pair<string,string>("title", menuTitle));
stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
//check for standard menu entries
bool hasIcon = false;
string icon = imgCache->GetIconName(menuTitle, cat);
if (imgCache->MenuIconExists(icon))
hasIcon = true;
stringTokens.insert(pair<string,string>("icon", icon));
intTokens.insert(pair<string,int>("hasicon", hasIcon));
//Disc Usage
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
ClearViewElement(veHeader); ClearViewElement(veHeader);
DrawViewElement(veHeader, &stringTokens, &intTokens); DrawViewElement(veHeader, &stringTokens, &intTokens);
return true; return true;
@ -224,8 +195,6 @@ void cDisplayMenuView::Action(void) {
cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) { cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) {
initial = true; initial = true;
lastSystemLoad = 0.0;
lastMemUsage = -1;
InitDevices(); InitDevices();
} }
@ -256,383 +225,216 @@ void cDisplayMenuMainView::DrawTimers(void) {
if (!ExecuteViewElement(veTimers)) { if (!ExecuteViewElement(veTimers)) {
return; return;
} }
if (DetachViewElement(veTimers)) {
cViewElement *viewElement = GetViewElement(veTimers);
if (!viewElement) {
viewElement = new cViewElementTimers(tmplView->GetViewElement(veTimers));
AddViewElement(veTimers, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
map < string, vector< map< string, string > > > timerLoopTokens; map < string, vector< map< string, string > > > timerLoopTokens;
vector< map< string, string > > timers; vector< map< string, string > > timers;
cGlobalSortedTimers SortedTimers;// local and remote timers SetTimers(&intTokens, &stringTokens, &timers);
int numTimers = SortedTimers.Size();
intTokens.insert(pair<string, int>("numtimers", numTimers));
int numTimerConflicts = SortedTimers.NumTimerConfilicts();
intTokens.insert(pair<string, int>("numtimerconflicts", numTimerConflicts));
for (int i=0; i<15; i++) {
stringstream name;
name << "timer" << i+1 << "exists";
if (i < numTimers) {
intTokens.insert(pair<string, int>(name.str(), true));
} else {
intTokens.insert(pair<string, int>(name.str(), false));
}
}
for (int i = 0; i < numTimers; i++) {
if (i >=15)
break;
map< string, string > timerVals;
const cTimer *Timer = SortedTimers[i];
const cEvent *event = Timer->Event();
if (event) {
timerVals.insert(pair< string, string >("timers[title]", event->Title()));
} else {
const char *File = Setup.FoldersInTimerMenu ? NULL : strrchr(Timer->File(), FOLDERDELIMCHAR);
if (File && strcmp(File + 1, TIMERMACRO_TITLE) && strcmp(File + 1, TIMERMACRO_EPISODE))
File++;
else
File = Timer->File();
timerVals.insert(pair< string, string >("timers[title]", File));
}
const cChannel *channel = Timer->Channel();
if (channel) {
timerVals.insert(pair< string, string >("timers[channelname]", channel->Name()));
stringstream chanNum;
chanNum << channel->Number();
timerVals.insert(pair< string, string >("timers[channelnumber]", chanNum.str()));
string channelID = *(channel->GetChannelID().ToString());
timerVals.insert(pair< string, string >("timers[channelid]", channelID));
bool logoExists = imgCache->LogoExists(channelID);
timerVals.insert(pair< string, string >("timers[channellogoexists]", logoExists ? "1" : "0"));
} else {
timerVals.insert(pair< string, string >("timers[channelname]", ""));
timerVals.insert(pair< string, string >("timers[channelnumber]", "0"));
timerVals.insert(pair< string, string >("timers[channelid]", ""));
timerVals.insert(pair< string, string >("timers[channellogoexists]", "0"));
}
timerVals.insert(pair< string, string >("timers[recording]", Timer->Recording() ? "1" : "0"));
cString timerDate("");
if (Timer->Recording()) {
timerDate = cString::sprintf("-%s", *TimeString(Timer->StopTime()));
} else {
time_t Now = time(NULL);
cString Today = WeekDayName(Now);
cString Time = TimeString(Timer->StartTime());
cString Day = WeekDayName(Timer->StartTime());
if (Timer->StartTime() > Now + 6 * SECSINDAY) {
time_t ttm = Timer->StartTime();
struct tm * timerTime = localtime(&ttm);
timerDate = cString::sprintf("%02d.%02d %s", timerTime->tm_mday, timerTime->tm_mon + 1, *Time);
} else if (strcmp(Day, Today) != 0)
timerDate = cString::sprintf("%s %s", *Day, *Time);
else
timerDate = Time;
if (Timer->Flags() & tfVps)
timerDate = cString::sprintf("VPS %s", *timerDate);
}
timerVals.insert(pair< string, string >("timers[datetime]", *timerDate));
timers.push_back(timerVals);
}
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers)); timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
ClearViewElement(veTimers); ClearViewElement(veTimers);
DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens); DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens);
} }
}
void cDisplayMenuMainView::DrawDiscUsage(void) { void cDisplayMenuMainView::DrawDiscUsage(void) {
if (!ExecuteViewElement(veDiscUsage)) { if (!ExecuteViewElement(veDiscUsage)) {
return; return;
} }
if (DetachViewElement(veDiscUsage)) {
cViewElement *viewElement = GetViewElement(veDiscUsage);
if (!viewElement) {
viewElement = new cViewElementDiscUsage(tmplView->GetViewElement(veDiscUsage));
AddViewElement(veDiscUsage, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
SetDiscUsage(stringTokens, intTokens);
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
ClearViewElement(veDiscUsage); ClearViewElement(veDiscUsage);
DrawViewElement(veDiscUsage, &stringTokens, &intTokens); DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
} }
}
bool cDisplayMenuMainView::DrawLoad(void) { bool cDisplayMenuMainView::DrawLoad(void) {
if (!ExecuteViewElement(veSystemLoad)) { if (!ExecuteViewElement(veSystemLoad)) {
return false; return false;
} }
bool changed = false;
if (DetachViewElement(veSystemLoad)) {
cViewElement *viewElement = GetViewElement(veSystemLoad);
if (!viewElement) {
viewElement = new cViewElementSystemLoad(tmplView->GetViewElement(veSystemLoad));
AddViewElement(veSystemLoad, viewElement);
viewElement->Start();
changed = true;
} else {
if (!viewElement->Starting())
changed = viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
changed = SetSystemLoad(stringTokens, intTokens);
double systemLoad; if (changed) {
if (getloadavg(&systemLoad, 1) > 0) {
if (lastSystemLoad == systemLoad) {
return false;
}
string load = *cString::sprintf("%.2f", systemLoad);
int loadHand = systemLoad * 1000;
int loadHandValue = 0;
if (loadHand > 2500)
loadHandValue = 2525;
else {
int loadHandDec = loadHand - (loadHand / 100) * 100;
if (loadHandDec <= 12)
loadHandDec = 0;
else if (loadHandDec <= 37)
loadHandDec = 25;
else if (loadHandDec <= 62)
loadHandDec = 50;
else if (loadHandDec <= 87)
loadHandDec = 75;
else
loadHandDec = 0;
loadHandValue = loadHand / 100 * 100 + loadHandDec;
}
stringTokens.insert(pair<string,string>("load", load));
intTokens.insert(pair<string,int>("loadhand", loadHandValue));
lastSystemLoad = systemLoad;
}
ClearViewElement(veSystemLoad); ClearViewElement(veSystemLoad);
DrawViewElement(veSystemLoad, &stringTokens, &intTokens); DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
}
return true; }
return changed;
} }
bool cDisplayMenuMainView::DrawMemory(void) { bool cDisplayMenuMainView::DrawMemory(void) {
if (!ExecuteViewElement(veSystemMemory)) { if (!ExecuteViewElement(veSystemMemory)) {
return false; return false;
} }
struct sysinfo memInfo; bool changed = false;
sysinfo (&memInfo); if (DetachViewElement(veSystemMemory)) {
cViewElement *viewElement = GetViewElement(veSystemMemory);
long long totalMem = memInfo.totalram; if (!viewElement) {
totalMem += memInfo.totalswap; viewElement = new cViewElementSystemMemory(tmplView->GetViewElement(veSystemMemory));
totalMem *= memInfo.mem_unit; AddViewElement(veSystemMemory, viewElement);
int totalMemMB = totalMem / 1024 / 1024; viewElement->Start();
changed = true;
long long usedMem = memInfo.totalram - memInfo.freeram; } else {
usedMem += memInfo.totalswap - memInfo.freeswap; if (!viewElement->Starting())
usedMem *= memInfo.mem_unit; changed = viewElement->Render();
int usedMemMB = usedMem / 1024 / 1024;
if (lastMemUsage == usedMemMB) {
return false;
} }
lastMemUsage = usedMemMB; } else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
intTokens.insert(pair<string,int>("totalmem", totalMemMB)); changed = SetSystemMemory(stringTokens, intTokens);
intTokens.insert(pair<string,int>("usedmem", usedMemMB)); if (changed) {
if (totalMemMB > 0)
intTokens.insert(pair<string,int>("usedmempercent", usedMemMB * 100 / totalMemMB));
ClearViewElement(veSystemMemory); ClearViewElement(veSystemMemory);
DrawViewElement(veSystemMemory, &stringTokens, &intTokens); DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
}
return true; }
return changed;
} }
void cDisplayMenuMainView::DrawTemperatures(void) { void cDisplayMenuMainView::DrawTemperatures(void) {
if (!ExecuteViewElement(veTemperatures)) { if (!ExecuteViewElement(veTemperatures)) {
return; return;
} }
cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/temperatures\"", SCRIPTFOLDER, SCRIPTFOLDER); if (DetachViewElement(veTemperatures)) {
system(*execCommand); cViewElement *viewElement = GetViewElement(veTemperatures);
if (!viewElement) {
string tempCPU, tempGPU; viewElement = new cViewElementTemperature(tmplView->GetViewElement(veTemperatures));
int cpu, gpu; AddViewElement(veTemperatures, viewElement);
viewElement->Start();
cString itemFilename = cString::sprintf("%s/cpu", SCRIPTOUTPUTPATH );
ifstream file(*itemFilename, ifstream::in);
if( file.is_open() ) {
std::getline(file, tempCPU);
if (tempCPU.size() > 2) {
cpu = atoi(tempCPU.substr(0,2).c_str());
} else
cpu = 0;
file.close();
} else { } else {
tempCPU = "0°C"; if (!viewElement->Starting())
cpu = 0; viewElement->Render();
} }
itemFilename = cString::sprintf("%s/gpu", SCRIPTOUTPUTPATH );
ifstream file2(*itemFilename, ifstream::in);
if( file2.is_open() ) {
std::getline(file2, tempGPU);
if (tempGPU.size() > 2) {
gpu = atoi(tempGPU.substr(0,2).c_str());
} else
gpu = 0;
file2.close();
} else { } else {
tempGPU = "0°C";
gpu = 0;
}
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
bool changed = SetSystemTemperatures(stringTokens, intTokens);
intTokens.insert(pair<string,int>("cputemp", cpu)); if (changed) {
intTokens.insert(pair<string,int>("gputemp", gpu));
ClearViewElement(veTemperatures); ClearViewElement(veTemperatures);
DrawViewElement(veTemperatures, &stringTokens, &intTokens); DrawViewElement(veTemperatures, &stringTokens, &intTokens);
} }
}
}
bool cDisplayMenuMainView::DrawDevices(void) { bool cDisplayMenuMainView::DrawDevices(void) {
if (!ExecuteViewElement(veDevices)) { if (!ExecuteViewElement(veDevices)) {
return false; return false;
} }
bool changed = false;
if (DetachViewElement(veDevices)) {
cViewElement *viewElement = GetViewElement(veDevices);
if (!viewElement) {
viewElement = new cViewElementDevices(tmplView->GetViewElement(veDevices));
AddViewElement(veDevices, viewElement);
viewElement->Start();
changed = true;
} else {
if (!viewElement->Starting())
changed = viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens; map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices; vector< map< string, string > > devices;
bool changed = SetDevices(initial, &intTokens, &devices); changed = SetDevices(initial, &intTokens, &devices);
if (!changed) if (!changed)
return false; return false;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices)); deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices); ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens); DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
return true; }
return changed;
} }
void cDisplayMenuMainView::DrawCurrentSchedule(void) { void cDisplayMenuMainView::DrawCurrentSchedule(void) {
if (!ExecuteViewElement(veCurrentSchedule)) { if (!ExecuteViewElement(veCurrentSchedule)) {
return; return;
} }
if (DetachViewElement(veCurrentSchedule)) {
cDevice *device = cDevice::PrimaryDevice(); cViewElement *viewElement = GetViewElement(veCurrentSchedule);
const cChannel *channel = NULL; if (!viewElement) {
if (!device->Replaying() || device->Transferring()) { viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule));
channel = Channels.GetByNumber(device->CurrentChannel()); AddViewElement(veCurrentSchedule, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
} }
if (!channel) } else {
return;
const cEvent *event = NULL;
cSchedulesLock SchedulesLock;
if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock))
if (const cSchedule *Schedule = Schedules->GetSchedule(channel))
event = Schedule->GetPresentEvent();
if (!event)
return;
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
SetCurrentSchedule(stringTokens, intTokens);
stringTokens.insert(pair<string,string>("title", (event->Title())?event->Title():""));
stringTokens.insert(pair<string,string>("subtitle", (event->ShortText())?event->ShortText():""));
stringTokens.insert(pair<string,string>("start", *event->GetTimeString()));
stringTokens.insert(pair<string,string>("stop", *event->GetEndTimeString()));
intTokens.insert(pair<string,int>("duration", event->Duration() / 60));
intTokens.insert(pair<string,int>("durationhours", event->Duration() / 3600));
stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", (event->Duration() / 60)%60)));
intTokens.insert(pair<string,int>("elapsed", (int)round((time(NULL) - event->StartTime())/60)));
intTokens.insert(pair<string,int>("remaining", (int)round((event->EndTime() - time(NULL))/60)));
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;
static cPlugin *pScraper = GetScraperPlugin();
if (pScraper) {
ScraperGetPosterBanner call;
call.event = event;
if (pScraper->Service("GetPosterBanner", &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 = NULL;
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;
}
}
}
intTokens.insert(pair<string,int>("mediawidth", mediaWidth));
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner));
stringTokens.insert(pair<string,string>("mediapath", mediaPath));
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
ClearViewElement(veCurrentSchedule); ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens); DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
} }
}
void cDisplayMenuMainView::DrawCurrentWeather(void) { void cDisplayMenuMainView::DrawCurrentWeather(void) {
if (!ExecuteViewElement(veCurrentWeather)) { if (!ExecuteViewElement(veCurrentWeather)) {
return; return;
} }
if (DetachViewElement(veCurrentWeather)) {
cViewElement *viewElement = GetViewElement(veCurrentWeather);
if (!viewElement) {
viewElement = new cViewElementWeather(tmplView->GetViewElement(veCurrentWeather));
AddViewElement(veCurrentWeather, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens; map < string, string > stringTokens;
map < string, int > intTokens; map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){ if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather); ClearViewElement(veCurrentWeather);
return; return;
} }
ClearViewElement(veCurrentWeather); ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens); DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
} }
}
void cDisplayMenuMainView::DrawCustomTokens(void) { void cDisplayMenuMainView::DrawCustomTokens(void) {
if (!ExecuteViewElement(veCustomTokens)) { if (!ExecuteViewElement(veCustomTokens)) {
@ -640,10 +442,23 @@ void cDisplayMenuMainView::DrawCustomTokens(void) {
} }
if (!tmplView) if (!tmplView)
return; return;
if (DetachViewElement(veCustomTokens)) {
cViewElement *viewElement = GetViewElement(veCustomTokens);
if (!viewElement) {
viewElement = new cViewElementCustomTokens(tmplView->GetViewElement(veCustomTokens), tmplView);
AddViewElement(veCustomTokens, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens = tmplView->GetCustomStringTokens(); map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens(); map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens); DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
} }
}
/************************************************************************ /************************************************************************
* cDisplayMenuSchedulesView * cDisplayMenuSchedulesView

View File

@ -37,8 +37,6 @@ public:
class cDisplayMenuMainView : public cDisplayMenuView { class cDisplayMenuMainView : public cDisplayMenuView {
private: private:
bool initial; bool initial;
double lastSystemLoad;
int lastMemUsage;
void DrawTimers(void); void DrawTimers(void);
void DrawDiscUsage(void); void DrawDiscUsage(void);
bool DrawLoad(void); bool DrawLoad(void);

207
views/displayviewelements.c Normal file
View File

@ -0,0 +1,207 @@
#include "displayviewelements.h"
cViewElementDevices::cViewElementDevices(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
init = true;
}
bool cViewElementDevices::Render(void) {
ClearTokens();
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
if (init)
InitDevices();
bool changed = SetDevices(init, &intTokens, &devices);
init = false;
if (!changed)
return false;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
return true;
}
/********************************************************************************************************************/
cViewElementSignal::cViewElementSignal(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementSignal::Render(void) {
ClearTokens();
bool changed = SetSignal(intTokens);
if (!changed)
return false;
ClearViewElement(veSignalQuality);
DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementWeather::cViewElementWeather(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementWeather::Render(void) {
ClearTokens();
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return false;
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementDate::cViewElementDate(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementDate::Render(void) {
ClearTokens();
if (!SetDate(stringTokens, intTokens)) {
return false;
}
ClearViewElement(veDateTime);
DrawViewElement(veDateTime, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementTime::cViewElementTime(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementTime::Render(void) {
ClearTokens();
if (!SetTime(stringTokens, intTokens)) {
return false;
}
ClearViewElement(veTime);
DrawViewElement(veTime, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementScraperContent::cViewElementScraperContent(const cEvent *event, ScraperContentType type, cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
this->event = event;
this->type = type;
}
bool cViewElementScraperContent::Render(void) {
ClearTokens();
SetPosterBanner(event, stringTokens, intTokens);
ClearViewElement(veScraperContent);
DrawViewElement(veScraperContent, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementCustomTokens::cViewElementCustomTokens(cTemplateViewElement *tmplViewElement, cTemplateView *tmplView) : cViewElement(tmplViewElement) {
this->tmplView = tmplView;
}
bool cViewElementCustomTokens::Render(void) {
ClearTokens();
if (!tmplView)
return false;
stringTokens = tmplView->GetCustomStringTokens();
intTokens = tmplView->GetCustomIntTokens();
ClearViewElement(veCustomTokens);
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementTimers::cViewElementTimers(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementTimers::Render(void) {
ClearTokens();
map < string, vector< map< string, string > > > timerLoopTokens;
vector< map< string, string > > timers;
SetTimers(&intTokens, &stringTokens, &timers);
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
ClearViewElement(veTimers);
DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens);
return true;
}
/********************************************************************************************************************/
cViewElementDiscUsage::cViewElementDiscUsage(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementDiscUsage::Render(void) {
ClearTokens();
SetDiscUsage(stringTokens, intTokens);
ClearViewElement(veDiscUsage);
DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementSystemLoad::cViewElementSystemLoad(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementSystemLoad::Render(void) {
ClearTokens();
if (!SetSystemLoad(stringTokens, intTokens))
return false;
ClearViewElement(veSystemLoad);
DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementSystemMemory::cViewElementSystemMemory(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementSystemMemory::Render(void) {
ClearTokens();
if (!SetSystemMemory(stringTokens, intTokens))
return false;
ClearViewElement(veSystemMemory);
DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementTemperature::cViewElementTemperature(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementTemperature::Render(void) {
ClearTokens();
if (!SetSystemTemperatures(stringTokens, intTokens))
return false;
ClearViewElement(veTemperatures);
DrawViewElement(veTemperatures, &stringTokens, &intTokens);
return true;
}
/********************************************************************************************************************/
cViewElementCurrentSchedule::cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
}
bool cViewElementCurrentSchedule::Render(void) {
ClearTokens();
SetCurrentSchedule(stringTokens, intTokens);
ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
return true;
}

121
views/displayviewelements.h Normal file
View File

@ -0,0 +1,121 @@
#ifndef __DISPLAYCHANNELVIEWELEMENTS_H
#define __DISPLAYCHANNELVIEWELEMENTS_H
#include "../libtemplate/template.h"
#include "view.h"
#include "viewhelpers.h"
class cViewElementDevices : public cViewElement, public cViewHelpers {
private:
bool init;
public:
cViewElementDevices(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDevices() {};
bool Render(void);
};
class cViewElementSignal : public cViewElement, public cViewHelpers {
private:
public:
cViewElementSignal(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementSignal() {};
bool Render(void);
};
class cViewElementWeather : public cViewElement, public cViewHelpers {
private:
public:
cViewElementWeather(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementWeather() {};
bool Render(void);
};
class cViewElementDate : public cViewElement, public cViewHelpers {
private:
public:
cViewElementDate(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDate() {};
bool Render(void);
};
class cViewElementTime : public cViewElement, public cViewHelpers {
private:
public:
cViewElementTime(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementTime() {};
bool Render(void);
};
enum ScraperContentType {
ctPosterBanner,
ctFull
};
class cViewElementScraperContent : public cViewElement, public cViewHelpers {
private:
ScraperContentType type;
const cEvent *event;
public:
cViewElementScraperContent(const cEvent *event, ScraperContentType type, cTemplateViewElement *tmplViewElement);
virtual ~cViewElementScraperContent() {};
bool Render(void);
};
class cViewElementCustomTokens : public cViewElement, public cViewHelpers {
private:
cTemplateView *tmplView;
public:
cViewElementCustomTokens(cTemplateViewElement *tmplViewElement, cTemplateView *tmplView);
virtual ~cViewElementCustomTokens() {};
bool Render(void);
};
class cViewElementTimers : public cViewElement, public cViewHelpers {
private:
public:
cViewElementTimers(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementTimers() {};
bool Render(void);
};
class cViewElementDiscUsage : public cViewElement, public cViewHelpers {
private:
public:
cViewElementDiscUsage(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementDiscUsage() {};
bool Render(void);
};
class cViewElementSystemLoad : public cViewElement, public cViewHelpers {
private:
public:
cViewElementSystemLoad(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementSystemLoad() {};
bool Render(void);
};
class cViewElementSystemMemory : public cViewElement, public cViewHelpers {
private:
public:
cViewElementSystemMemory(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementSystemMemory() {};
bool Render(void);
};
class cViewElementTemperature : public cViewElement, public cViewHelpers {
private:
public:
cViewElementTemperature(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementTemperature() {};
bool Render(void);
};
class cViewElementCurrentSchedule : public cViewElement, public cViewHelpers {
private:
public:
cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement);
virtual ~cViewElementCurrentSchedule() {};
bool Render(void);
};
#endif //__DISPLAYCHANNELVIEWELEMENTS_H

View File

@ -11,13 +11,13 @@ cView::cView(cTemplateView *tmplView) : cPixmapContainer(tmplView->GetNumPixmaps
if (tvScaled) { if (tvScaled) {
cDevice::PrimaryDevice()->ScaleVideo(scalingWindow); cDevice::PrimaryDevice()->ScaleVideo(scalingWindow);
} }
tmplItem = NULL; tmplViewElement = NULL;
tmplTab = NULL; tmplTab = NULL;
Init(); Init();
} }
cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem ? tmplItem->GetNumPixmaps() : 0) { cView::cView(cTemplateViewElement *tmplViewElement) : cPixmapContainer(tmplViewElement ? tmplViewElement->GetNumPixmaps() : 0) {
this->tmplItem = tmplItem; this->tmplViewElement = tmplViewElement;
tmplView = NULL; tmplView = NULL;
tmplTab = NULL; tmplTab = NULL;
tvScaled = false; tvScaled = false;
@ -27,7 +27,7 @@ cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem ? tmplI
cView::cView(cTemplateViewTab *tmplTab) : cPixmapContainer(1) { cView::cView(cTemplateViewTab *tmplTab) : cPixmapContainer(1) {
this->tmplTab = tmplTab; this->tmplTab = tmplTab;
tmplView = NULL; tmplView = NULL;
tmplItem = NULL; tmplViewElement = NULL;
tvScaled = false; tvScaled = false;
Init(); Init();
} }
@ -36,6 +36,10 @@ cView::~cView() {
if (tvScaled) { if (tvScaled) {
cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
} }
for (map<eViewElement,cViewElement*>::iterator dVeIt = detachedViewElements.begin(); dVeIt != detachedViewElements.end(); dVeIt++) {
cViewElement *ve = dVeIt->second;
delete ve;
}
} }
void cView::Init(void) { void cView::Init(void) {
@ -72,9 +76,9 @@ void cView::Stop(void) {
void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) { void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) {
//setting correct ViewElement, depending which constructor was used //setting correct ViewElement, depending which constructor was used
cTemplateViewElement *viewElement; cTemplateViewElement *viewElement = NULL;
if (tmplItem && (ve == veMenuCurrentItemDetail || ve == veOnPause)) { if (tmplViewElement) {
viewElement = tmplItem; viewElement = tmplViewElement;
} else if (tmplView) { } else if (tmplView) {
viewElement = tmplView->GetViewElement(ve); viewElement = tmplView->GetViewElement(ve);
} }
@ -91,6 +95,11 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
viewElement->InitIterator(); viewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
while(pix = viewElement->GetNextPixmap()) { while(pix = viewElement->GetNextPixmap()) {
//check if already drawn background area, this can be skipped
if (PixmapExists(pixCurrent) && pix->BackgroundArea()) {
pixCurrent++;
continue;
}
//reset Template //reset Template
pix->ClearDynamicParameters(); pix->ClearDynamicParameters();
//create Pixmap if already fully parsed //create Pixmap if already fully parsed
@ -148,9 +157,12 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
} }
void cView::ClearViewElement(eViewElement ve) { void cView::ClearViewElement(eViewElement ve) {
if (!tmplView) cTemplateViewElement *viewElement = NULL;
return; if (tmplViewElement) {
cTemplateViewElement *viewElement = tmplView->GetViewElement(ve); viewElement = tmplViewElement;
} else if (tmplView) {
viewElement = tmplView->GetViewElement(ve);
}
if (!viewElement) if (!viewElement)
return; return;
int pixCurrent = viewElement->GetPixOffset(); int pixCurrent = viewElement->GetPixOffset();
@ -159,7 +171,9 @@ void cView::ClearViewElement(eViewElement ve) {
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
viewElement->InitIterator(); viewElement->InitIterator();
while(pix = viewElement->GetNextPixmap()) { while(pix = viewElement->GetNextPixmap()) {
if (!pix->BackgroundArea()) {
Fill(pixCurrent, clrTransparent); Fill(pixCurrent, clrTransparent);
}
pixCurrent++; pixCurrent++;
} }
} }
@ -206,12 +220,20 @@ void cView::ActivateScrolling(void) {
} }
bool cView::ExecuteViewElement(eViewElement ve) { bool cView::ExecuteViewElement(eViewElement ve) {
if (!tmplView)
return false;
bool doExecute = tmplView->ExecuteView(ve); bool doExecute = tmplView->ExecuteView(ve);
if (!doExecute) if (!doExecute)
return false; return false;
return tmplView->GetNumPixmapsViewElement(ve); return tmplView->GetNumPixmapsViewElement(ve);
} }
bool cView::DetachViewElement(eViewElement ve) {
if (!tmplView)
return false;
return tmplView->DetachViewElement(ve);
}
bool cView::ViewElementScrolls(eViewElement ve) { bool cView::ViewElementScrolls(eViewElement ve) {
if (scrollingPix < 0) if (scrollingPix < 0)
return false; return false;
@ -227,6 +249,17 @@ bool cView::ViewElementScrolls(eViewElement ve) {
return false; return false;
} }
cViewElement *cView::GetViewElement(eViewElement ve) {
map < eViewElement, cViewElement* >::iterator hit = detachedViewElements.find(ve);
if (hit == detachedViewElements.end())
return NULL;
cViewElement *viewElement = hit->second;
return viewElement;
}
void cView::AddViewElement(eViewElement ve, cViewElement *viewElement) {
detachedViewElements.insert(pair< eViewElement, cViewElement* >(ve, viewElement));
}
void cView::CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size) { void cView::CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size) {
cRect pixSize; cRect pixSize;
@ -807,6 +840,42 @@ void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) {
} }
} }
/***********************************************************************
* cViewElement
************************************************************************/
cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
tmplViewElement->SetPixOffset(0);
delay = tmplViewElement->GetNumericParameter(ptDelay);
SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
}
cViewElement::~cViewElement() {
CancelSave();
}
void cViewElement::Action(void) {
SetInitFinished();
DoSleep(delay);
Render();
FadeIn();
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {
ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
}
}
}
void cViewElement::ClearTokens(void) {
stringTokens.clear();
intTokens.clear();
}
/*********************************************************************** /***********************************************************************
* cViewListItem * cViewListItem
************************************************************************/ ************************************************************************/
@ -824,18 +893,18 @@ cViewListItem::~cViewListItem() {
cRect cViewListItem::DrawListItem(map <string,string> *stringTokens, map <string,int> *intTokens) { cRect cViewListItem::DrawListItem(map <string,string> *stringTokens, map <string,int> *intTokens) {
cRect posItem; cRect posItem;
if (!tmplItem) if (!tmplViewElement)
return posItem; return posItem;
if (tmplItem->DebugTokens()) { if (tmplViewElement->DebugTokens()) {
DebugTokens("ListItem", stringTokens, intTokens); DebugTokens("ListItem", stringTokens, intTokens);
} }
tmplItem->InitIterator(); tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
int pixCurrent = 0; int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) { while(pix = tmplViewElement->GetNextPixmap()) {
SetListElementPosition(pix); SetListElementPosition(pix);
if (pixCurrent == 0) { if (pixCurrent == 0) {
posItem = pix->GetPixmapSize(); posItem = pix->GetPixmapSize();
@ -980,13 +1049,13 @@ void cGrid::SetCurrent(bool current) {
} }
void cGrid::Move(void) { void cGrid::Move(void) {
if (!tmplItem) if (!tmplViewElement)
return; return;
tmplItem->InitIterator(); tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
int pixCurrent = 0; int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) { while(pix = tmplViewElement->GetNextPixmap()) {
PositionPixmap(pix); PositionPixmap(pix);
cRect pixViewPort = pix->GetPixmapSize(); cRect pixViewPort = pix->GetPixmapSize();
SetViewPort(pixCurrent, pixViewPort); SetViewPort(pixCurrent, pixViewPort);
@ -998,17 +1067,17 @@ void cGrid::Move(void) {
} }
void cGrid::Draw(void) { void cGrid::Draw(void) {
if (!tmplItem) if (!tmplViewElement)
return; return;
if (tmplItem->DebugTokens()) { if (tmplViewElement->DebugTokens()) {
DebugTokens("Grid", &stringTokens, &intTokens); DebugTokens("Grid", &stringTokens, &intTokens);
} }
tmplItem->InitIterator(); tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL; cTemplatePixmap *pix = NULL;
int pixCurrent = 0; int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) { while(pix = tmplViewElement->GetNextPixmap()) {
PositionPixmap(pix); PositionPixmap(pix);
if (!PixmapExists(pixCurrent)) { if (!PixmapExists(pixCurrent)) {
pix->ParseDynamicParameters(&intTokens, true); pix->ParseDynamicParameters(&intTokens, true);

View File

@ -8,6 +8,8 @@
using namespace std; using namespace std;
class cViewElement;
class cView : public cPixmapContainer { class cView : public cPixmapContainer {
private: private:
void Init(void); void Init(void);
@ -23,8 +25,10 @@ private:
void ActivateScrolling(void); void ActivateScrolling(void);
protected: protected:
cTemplateView *tmplView; cTemplateView *tmplView;
cTemplateViewElement *tmplItem; cTemplateViewElement *tmplViewElement;
cTemplateViewTab *tmplTab; cTemplateViewTab *tmplTab;
//detached viewelements
map < eViewElement, cViewElement* > detachedViewElements;
//scaling window //scaling window
cRect scalingWindow; cRect scalingWindow;
bool tvScaled; bool tvScaled;
@ -43,7 +47,10 @@ protected:
void ClearViewElement(eViewElement ve); void ClearViewElement(eViewElement ve);
void DestroyViewElement(eViewElement ve); void DestroyViewElement(eViewElement ve);
bool ExecuteViewElement(eViewElement ve); bool ExecuteViewElement(eViewElement ve);
bool DetachViewElement(eViewElement ve);
bool ViewElementScrolls(eViewElement ve); bool ViewElementScrolls(eViewElement ve);
cViewElement *GetViewElement(eViewElement ve);
void AddViewElement(eViewElement ve, cViewElement *viewElement);
void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL); void CreateViewPixmap(int num, cTemplatePixmap *pix, cRect *size = NULL);
void CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize); void CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize);
void DrawPixmap(int num, cTemplatePixmap *pix, map < string, vector< map< string, string > > > *loopTokens = NULL, bool flushPerLoop = false); void DrawPixmap(int num, cTemplatePixmap *pix, map < string, vector< map< string, string > > > *loopTokens = NULL, bool flushPerLoop = false);
@ -52,12 +59,27 @@ protected:
virtual void Action(void); virtual void Action(void);
public: public:
cView(cTemplateView *tmplView); cView(cTemplateView *tmplView);
cView(cTemplateViewElement *tmplItem); cView(cTemplateViewElement *tmplViewElement);
cView(cTemplateViewTab *tmplTab); cView(cTemplateViewTab *tmplTab);
virtual ~cView(); virtual ~cView();
virtual void Stop(void); virtual void Stop(void);
}; };
class cViewElement : public cView {
private:
protected:
int delay;
map < string, string > stringTokens;
map < string, int > intTokens;
void Action(void);
void ClearTokens(void);
public:
cViewElement(cTemplateViewElement *tmplViewElement);
virtual ~cViewElement();
virtual bool Render(void) { return false; };
bool Starting(void) { return Running(); };
};
class cViewListItem : public cView { class cViewListItem : public cView {
protected: protected:
int pos; int pos;

View File

@ -1,15 +1,25 @@
#include <fstream>
#include <iostream>
#include <vdr/menu.h> #include <vdr/menu.h>
#include <vdr/videodir.h>
#include <sys/sysinfo.h>
#include "../services/scraper2vdr.h" #include "../services/scraper2vdr.h"
#include "../services/weatherforecast.h" #include "../services/weatherforecast.h"
#include "../config.h" #include "../config.h"
#include "../libcore/timers.h"
#include "../libcore/helpers.h" #include "../libcore/helpers.h"
#include "viewhelpers.h" #include "viewhelpers.h"
cViewHelpers::cViewHelpers(void) { cViewHelpers::cViewHelpers(void) {
numDevices = 0; numDevices = 0;
devicesInit = false; devicesInit = false;
lSignalDisplay = 0;
lSignalStrength = 0;
lSignalQuality = 0;
lastSecond = -1; lastSecond = -1;
lastMinute = -1; lastMinute = -1;
lastSystemLoad = 0.0;
lastMemUsage = -1;
} }
cViewHelpers::~cViewHelpers() { cViewHelpers::~cViewHelpers() {
@ -141,6 +151,28 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
return true; return true;
} }
bool cViewHelpers::SetSignal(map < string, int > &intTokens) {
bool done = false;
time_t Now = time(NULL);
if (Now != lSignalDisplay) {
int SignalStrength = cDevice::ActualDevice()->SignalStrength();
int SignalQuality = cDevice::ActualDevice()->SignalQuality();
if (SignalStrength < 0) SignalStrength = 0;
if (SignalQuality < 0) SignalQuality = 0;
if ((SignalStrength == 0)&&(SignalQuality==0))
return done;
if ((lSignalStrength != SignalStrength) || (lSignalQuality != SignalQuality)) {
intTokens.insert(pair<string,int>("signalstrength", SignalStrength));
intTokens.insert(pair<string,int>("signalquality", SignalQuality));
lSignalStrength = SignalStrength;
lSignalQuality = SignalQuality;
done = true;
}
lSignalDisplay = Now;
}
return done;
}
bool cViewHelpers::CheckNewMails(void) { bool cViewHelpers::CheckNewMails(void) {
static cPlugin *pMailbox = cPluginManager::GetPlugin("mailbox"); static cPlugin *pMailbox = cPluginManager::GetPlugin("mailbox");
if (!pMailbox) { if (!pMailbox) {
@ -359,13 +391,80 @@ void cViewHelpers::SetScraperTokens(const cEvent *event, const cRecording *recor
} }
void cViewHelpers::SetPosterBanner(const cEvent *event, map < string, string > &stringTokens, map < string, int > &intTokens) {
static cPlugin *pScraper = GetScraperPlugin();
if (!pScraper) {
return;
}
ScraperGetPosterBanner call;
call.event = event;
if (pScraper->Service("GetPosterBanner", &call)) {
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;
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 = NULL;
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;
} else
return;
intTokens.insert(pair<string,int>("mediawidth", mediaWidth));
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner));
stringTokens.insert(pair<string,string>("mediapath", mediaPath));
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
}
}
bool cViewHelpers::SetTime(map < string, string > &stringTokens, map < string, int > &intTokens) { bool cViewHelpers::SetTime(map < string, string > &stringTokens, map < string, int > &intTokens) {
time_t t = time(0); // get time now time_t t = time(0); // get time now
struct tm * now = localtime(&t); struct tm * now = localtime(&t);
int sec = now->tm_sec; int sec = now->tm_sec;
if (sec == lastSecond) if (sec == lastSecond) {
return false; return false;
}
int min = now->tm_min; int min = now->tm_min;
int hour = now->tm_hour; int hour = now->tm_hour;
int hourMinutes = hour%12 * 5 + min / 12; int hourMinutes = hour%12 * 5 + min / 12;
@ -433,3 +532,316 @@ bool cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens,
stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone)); stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone));
return true; return true;
} }
void cViewHelpers::SetTimers(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *timers) {
cGlobalSortedTimers SortedTimers;// local and remote timers
int numTimers = SortedTimers.Size();
intTokens->insert(pair<string, int>("numtimers", numTimers));
int numTimerConflicts = SortedTimers.NumTimerConfilicts();
intTokens->insert(pair<string, int>("numtimerconflicts", numTimerConflicts));
for (int i=0; i<15; i++) {
stringstream name;
name << "timer" << i+1 << "exists";
if (i < numTimers) {
intTokens->insert(pair<string, int>(name.str(), true));
} else {
intTokens->insert(pair<string, int>(name.str(), false));
}
}
for (int i = 0; i < numTimers; i++) {
if (i >=15)
break;
map< string, string > timerVals;
const cTimer *Timer = SortedTimers[i];
const cEvent *event = Timer->Event();
if (event) {
timerVals.insert(pair< string, string >("timers[title]", event->Title()));
} else {
const char *File = Setup.FoldersInTimerMenu ? NULL : strrchr(Timer->File(), FOLDERDELIMCHAR);
if (File && strcmp(File + 1, TIMERMACRO_TITLE) && strcmp(File + 1, TIMERMACRO_EPISODE))
File++;
else
File = Timer->File();
timerVals.insert(pair< string, string >("timers[title]", File));
}
const cChannel *channel = Timer->Channel();
if (channel) {
timerVals.insert(pair< string, string >("timers[channelname]", channel->Name()));
stringstream chanNum;
chanNum << channel->Number();
timerVals.insert(pair< string, string >("timers[channelnumber]", chanNum.str()));
string channelID = *(channel->GetChannelID().ToString());
timerVals.insert(pair< string, string >("timers[channelid]", channelID));
bool logoExists = imgCache->LogoExists(channelID);
timerVals.insert(pair< string, string >("timers[channellogoexists]", logoExists ? "1" : "0"));
} else {
timerVals.insert(pair< string, string >("timers[channelname]", ""));
timerVals.insert(pair< string, string >("timers[channelnumber]", "0"));
timerVals.insert(pair< string, string >("timers[channelid]", ""));
timerVals.insert(pair< string, string >("timers[channellogoexists]", "0"));
}
timerVals.insert(pair< string, string >("timers[recording]", Timer->Recording() ? "1" : "0"));
cString timerDate("");
if (Timer->Recording()) {
timerDate = cString::sprintf("-%s", *TimeString(Timer->StopTime()));
} else {
time_t Now = time(NULL);
cString Today = WeekDayName(Now);
cString Time = TimeString(Timer->StartTime());
cString Day = WeekDayName(Timer->StartTime());
if (Timer->StartTime() > Now + 6 * SECSINDAY) {
time_t ttm = Timer->StartTime();
struct tm * timerTime = localtime(&ttm);
timerDate = cString::sprintf("%02d.%02d %s", timerTime->tm_mday, timerTime->tm_mon + 1, *Time);
} else if (strcmp(Day, Today) != 0)
timerDate = cString::sprintf("%s %s", *Day, *Time);
else
timerDate = Time;
if (Timer->Flags() & tfVps)
timerDate = cString::sprintf("VPS %s", *timerDate);
}
timerVals.insert(pair< string, string >("timers[datetime]", *timerDate));
timers->push_back(timerVals);
}
}
void cViewHelpers::SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens) {
stringTokens.insert(pair<string,string>("title", menuTitle));
stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
//check for standard menu entries
bool hasIcon = false;
string icon = imgCache->GetIconName(menuTitle, cat);
if (imgCache->MenuIconExists(icon))
hasIcon = true;
stringTokens.insert(pair<string,string>("icon", icon));
intTokens.insert(pair<string,int>("hasicon", hasIcon));
//Disc Usage
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
}
void cViewHelpers::SetDiscUsage(map < string, string > &stringTokens, map < string, int > &intTokens) {
string vdrUsageString = *cVideoDiskUsage::String();
int discUsage = cVideoDiskUsage::UsedPercent();
bool discAlert = (discUsage > 95) ? true : false;
string freeTime = *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60);
int freeGB = cVideoDiskUsage::FreeMB() / 1024;
intTokens.insert(pair<string, int>("usedpercent", discUsage));
intTokens.insert(pair<string, int>("freepercent", 100-discUsage));
intTokens.insert(pair<string, int>("discalert", discAlert));
intTokens.insert(pair<string, int>("freegb", freeGB));
stringTokens.insert(pair<string,string>("freetime", freeTime));
stringTokens.insert(pair<string,string>("vdrusagestring", vdrUsageString));
}
bool cViewHelpers::SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens) {
double systemLoad;
if (getloadavg(&systemLoad, 1) > 0) {
if (lastSystemLoad == systemLoad) {
return false;
}
string load = *cString::sprintf("%.2f", systemLoad);
int loadHand = systemLoad * 1000;
int loadHandValue = 0;
if (loadHand > 2500)
loadHandValue = 2525;
else {
int loadHandDec = loadHand - (loadHand / 100) * 100;
if (loadHandDec <= 12)
loadHandDec = 0;
else if (loadHandDec <= 37)
loadHandDec = 25;
else if (loadHandDec <= 62)
loadHandDec = 50;
else if (loadHandDec <= 87)
loadHandDec = 75;
else
loadHandDec = 0;
loadHandValue = loadHand / 100 * 100 + loadHandDec;
}
stringTokens.insert(pair<string,string>("load", load));
intTokens.insert(pair<string,int>("loadhand", loadHandValue));
lastSystemLoad = systemLoad;
} else {
return false;
}
return true;
}
bool cViewHelpers::SetSystemMemory(map < string, string > &stringTokens, map < string, int > &intTokens) {
struct sysinfo memInfo;
sysinfo (&memInfo);
long long totalMem = memInfo.totalram;
totalMem += memInfo.totalswap;
totalMem *= memInfo.mem_unit;
int totalMemMB = totalMem / 1024 / 1024;
long long usedMem = memInfo.totalram - memInfo.freeram;
usedMem += memInfo.totalswap - memInfo.freeswap;
usedMem *= memInfo.mem_unit;
int usedMemMB = usedMem / 1024 / 1024;
if (lastMemUsage == usedMemMB) {
return false;
}
lastMemUsage = usedMemMB;
intTokens.insert(pair<string,int>("totalmem", totalMemMB));
intTokens.insert(pair<string,int>("usedmem", usedMemMB));
if (totalMemMB > 0)
intTokens.insert(pair<string,int>("usedmempercent", usedMemMB * 100 / totalMemMB));
return true;
}
bool cViewHelpers::SetSystemTemperatures(map < string, string > &stringTokens, map < string, int > &intTokens) {
cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/temperatures\"", SCRIPTFOLDER, SCRIPTFOLDER);
system(*execCommand);
string tempCPU, tempGPU;
int cpu, gpu;
cString itemFilename = cString::sprintf("%s/cpu", SCRIPTOUTPUTPATH );
ifstream file(*itemFilename, ifstream::in);
if( file.is_open() ) {
std::getline(file, tempCPU);
if (tempCPU.size() > 2) {
cpu = atoi(tempCPU.substr(0,2).c_str());
} else
cpu = 0;
file.close();
} else {
tempCPU = "0°C";
cpu = 0;
}
itemFilename = cString::sprintf("%s/gpu", SCRIPTOUTPUTPATH );
ifstream file2(*itemFilename, ifstream::in);
if( file2.is_open() ) {
std::getline(file2, tempGPU);
if (tempGPU.size() > 2) {
gpu = atoi(tempGPU.substr(0,2).c_str());
} else
gpu = 0;
file2.close();
} else {
tempGPU = "0°C";
gpu = 0;
}
intTokens.insert(pair<string,int>("cputemp", cpu));
intTokens.insert(pair<string,int>("gputemp", gpu));
return true;
}
void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map < string, int > &intTokens) {
cDevice *device = cDevice::PrimaryDevice();
const cChannel *channel = NULL;
if (!device->Replaying() || device->Transferring()) {
channel = Channels.GetByNumber(device->CurrentChannel());
}
if (!channel)
return;
const cEvent *event = NULL;
cSchedulesLock SchedulesLock;
if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock))
if (const cSchedule *Schedule = Schedules->GetSchedule(channel))
event = Schedule->GetPresentEvent();
if (!event)
return;
stringTokens.insert(pair<string,string>("title", (event->Title())?event->Title():""));
stringTokens.insert(pair<string,string>("subtitle", (event->ShortText())?event->ShortText():""));
stringTokens.insert(pair<string,string>("start", *event->GetTimeString()));
stringTokens.insert(pair<string,string>("stop", *event->GetEndTimeString()));
intTokens.insert(pair<string,int>("duration", event->Duration() / 60));
intTokens.insert(pair<string,int>("durationhours", event->Duration() / 3600));
stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", (event->Duration() / 60)%60)));
intTokens.insert(pair<string,int>("elapsed", (int)round((time(NULL) - event->StartTime())/60)));
intTokens.insert(pair<string,int>("remaining", (int)round((event->EndTime() - time(NULL))/60)));
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;
static cPlugin *pScraper = GetScraperPlugin();
if (pScraper) {
ScraperGetPosterBanner call;
call.event = event;
if (pScraper->Service("GetPosterBanner", &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 = NULL;
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;
}
}
}
intTokens.insert(pair<string,int>("mediawidth", mediaWidth));
intTokens.insert(pair<string,int>("mediaheight", mediaHeight));
intTokens.insert(pair<string,int>("isbanner", isBanner));
stringTokens.insert(pair<string,string>("mediapath", mediaPath));
intTokens.insert(pair<string,int>("posterwidth", posterWidth));
intTokens.insert(pair<string,int>("posterheight", posterHeight));
stringTokens.insert(pair<string,string>("posterpath", posterPath));
intTokens.insert(pair<string,int>("hasposter", hasPoster));
intTokens.insert(pair<string,int>("bannerwidth", bannerWidth));
intTokens.insert(pair<string,int>("bannerheight", bannerHeight));
stringTokens.insert(pair<string,string>("bannerpath", bannerPath));
intTokens.insert(pair<string,int>("hasbanner", hasBanner));
}

View File

@ -8,16 +8,30 @@ private:
int* lastSignalStrength; int* lastSignalStrength;
int* lastSignalQuality; int* lastSignalQuality;
bool* recDevices; bool* recDevices;
int lSignalDisplay;
int lSignalStrength;
int lSignalQuality;
int lastSecond; int lastSecond;
int lastMinute; int lastMinute;
double lastSystemLoad;
int lastMemUsage;
protected: protected:
void InitDevices(void); void InitDevices(void);
bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices); bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices);
bool SetSignal(map < string, int > &intTokens);
bool CheckNewMails(void); bool CheckNewMails(void);
void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens); void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens);
void SetPosterBanner(const cEvent *event, map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetTimers(map<string,int> *intTokens, map<string,string> *stringTokens, vector<map<string,string> > *timers);
void SetMenuHeader(eMenuCategory cat, string menuTitle, map < string, string > &stringTokens, map < string, int > &intTokens);
void SetDiscUsage(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemMemory(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetSystemTemperatures(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetCurrentSchedule(map < string, string > &stringTokens, map < string, int > &intTokens);
public: public:
cViewHelpers(void); cViewHelpers(void);
virtual ~cViewHelpers(void); virtual ~cViewHelpers(void);