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
<<<<<<< HEAD
- 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/viewgrid.o \
views/viewhelpers.o \
views/displayviewelements.o \
views/displaychannelview.o \
views/displaymenurootview.o \
views/displaymenuview.o \

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -221,6 +221,14 @@ bool cTemplateView::ExecuteView(eViewElement ve) {
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 numElements = 0;
cTemplateViewList *menuList = GetViewList(vlMenuItem);
@ -613,6 +621,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
string name = "viewelement";
set<string> attributes;
attributes.insert("debug");
attributes.insert("detached");
attributes.insert("delay");
attributes.insert("fadetime");
attributes.insert("name");
@ -629,6 +638,7 @@ void cTemplateView::SetFunctionDefinitions(void) {
attributes.insert("height");
attributes.insert("layer");
attributes.insert("transparency");
attributes.insert("background");
funcsAllowed.insert(pair< string, set<string> >(name, attributes));
name = "areascroll";

View File

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

View File

@ -124,6 +124,14 @@ bool cTemplateViewElement::Execute(void) {
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) {
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);
if (parameters)
parameters->Debug();
return;
for (vector<cTemplatePixmap*>::iterator it = viewPixmaps.begin(); it != viewPixmaps.end(); it++) {
(*it)->Debug();
}

View File

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

View File

@ -52,7 +52,7 @@
</area>
</scrollbar>
<currentweather>
<currentweather detached="true" delay="100" fadetime="0">
<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"/>
<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[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">
<drawtext align="center" valign="center" font="{semibold}" fontsize="40%" color="{clrWhite}" text="{tr(noactivetimers)}" />
</area>
@ -97,7 +97,7 @@
{discalert} true if disc usage is > 95%
{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">
<drawimage imagetype="skinpart" path="tachohands/perc_{usedpercent}" x="{areawidth}*0.025" y="5%" width="20%" height="{areawidth}*0.20"/>
</area>
@ -131,7 +131,7 @@
{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)
-->
<systemload>
<systemload detached="true" delay="100" fadetime="0">
<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"/>
</area>
@ -144,7 +144,7 @@
{cputemp} current cpu 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">
<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"/>

View File

@ -7,16 +7,6 @@
<area x="0" y="80%" width="100%" height="20%" layer="1">
<fill color="{clrTransBlack}" />
</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 -->
<area x="0" y="80%" width="20%" height="20%" layer="2">
<fill color="{clrTransBlueLight}" />
@ -196,8 +186,8 @@
{devices[channelid]} ID of the currently tuned channel
{devices[source]} source of the currently tuned channel
-->
<devices condition="{showdevices}" >
<area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1">
<devices condition="{showdevices}" detached="true" delay="100" fadetime="{fadetime}">
<area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1" background="true">
<fill color="{clrTransBlack}"/>
</area>
<area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="2">
@ -235,6 +225,10 @@
{ozone} ozone value in DU
-->
<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">
<drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.8" height="{areaheight}*0.8"/>
</area>
@ -284,6 +278,10 @@
{year} year in yyyy
-->
<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">
<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}" />

View File

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

View File

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

View File

@ -2,15 +2,13 @@
#include <vdr/menu.h>
#include "../services/scraper2vdr.h"
#include "displaychannelview.h"
#include "displayviewelements.h"
#include "../libcore/timers.h"
#include "../libcore/helpers.h"
cDisplayChannelView::cDisplayChannelView(cTemplateView *tmplView) : cView(tmplView) {
lastScreenWidth = 0;
lastScreenHeight = 0;
lastSignalDisplay = 0;
lastSignalStrength = 0;
lastSignalQuality = 0;
lastNumAudioTracks = 0;
lastAudioChannel = -1;
lastTracDesc = "";
@ -64,15 +62,27 @@ void cDisplayChannelView::DrawDate(void) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetDate(stringTokens, intTokens)) {
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, int > intTokens;
if (!SetDate(stringTokens, intTokens)) {
return;
}
ClearViewElement(veDateTime);
DrawViewElement(veDateTime, &stringTokens, &intTokens);
ClearViewElement(veDateTime);
DrawViewElement(veDateTime, &stringTokens, &intTokens);
}
}
void cDisplayChannelView::DrawTime(void) {
@ -80,14 +90,26 @@ void cDisplayChannelView::DrawTime(void) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
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, int > intTokens;
if (!SetTime(stringTokens, intTokens)) {
return;
}
ClearViewElement(veTime);
DrawViewElement(veTime, &stringTokens, &intTokens);
if (!SetTime(stringTokens, intTokens)) {
return;
}
ClearViewElement(veTime);
DrawViewElement(veTime, &stringTokens, &intTokens);
}
}
void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Current, int Total) {
@ -315,72 +337,22 @@ void cDisplayChannelView::DrawScraperContent(const cEvent *event) {
return;
}
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;
map < string, int > intTokens;
if (DetachViewElement(veScraperContent)) {
cViewElement *viewElement = GetViewElement(veScraperContent);
if (!viewElement) {
viewElement = new cViewElementScraperContent(event, ctPosterBanner, tmplView->GetViewElement(veScraperContent));
AddViewElement(veScraperContent, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens;
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(veScraperContent);
map < string, int > intTokens;
SetPosterBanner(event, stringTokens, intTokens);
ClearScraperContent();
DrawViewElement(veScraperContent, &stringTokens, &intTokens);
}
}
@ -393,35 +365,27 @@ void cDisplayChannelView::DrawSignal(void) {
if (!ExecuteViewElement(veSignalQuality)) {
return;
}
time_t Now = time(NULL);
if (Now != lastSignalDisplay) {
#ifdef DOPROFILE
cStopWatch watch("DrawSignal");
#endif
int SignalStrength = cDevice::ActualDevice()->SignalStrength();
#ifdef DOPROFILE
watch.Report("SignalStrength");
#endif
int SignalQuality = cDevice::ActualDevice()->SignalQuality();
#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);
if (DetachViewElement(veSignalQuality)) {
cViewElement *viewElement = GetViewElement(veSignalQuality);
if (!viewElement) {
viewElement = new cViewElementSignal(tmplView->GetViewElement(veSignalQuality));
AddViewElement(veSignalQuality, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
lastSignalStrength = SignalStrength;
lastSignalQuality = SignalQuality;
lastSignalDisplay = Now;
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
bool changed = SetSignal(intTokens);
if (!changed)
return;
ClearSignal();
DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
}
}
@ -445,19 +409,32 @@ void cDisplayChannelView::DrawDevices(bool initial) {
if (!ExecuteViewElement(veDevices)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
bool changed = SetDevices(initial, &intTokens, &devices);
if (!changed)
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, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
bool changed = SetDevices(initial, &intTokens, &devices);
if (!changed)
return;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearDevices();
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
}
}
void cDisplayChannelView::ClearDevices(void) {
@ -472,8 +449,8 @@ void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString Cha
bool separatorExists = imgCache->SeparatorLogoExists(*ChannelName);
string separatorPath = separatorExists ? *ChannelName : "";
std::string prevChannelSep = GetChannelSep(Channel, true);
std::string nextChannelSep = GetChannelSep(Channel, false);
string prevChannelSep = GetChannelSep(Channel, true);
string nextChannelSep = GetChannelSep(Channel, false);
bool prevAvailable = (prevChannelSep.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) {
std::string sepName = "";
string sepName = "";
const cChannel *sep = prev ? Channels.Prev(channel) :
Channels.Next(channel);
for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) {
@ -535,24 +512,49 @@ void cDisplayChannelView::DrawCustomTokens(void) {
}
if (!tmplView)
return;
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
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, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
}
}
void cDisplayChannelView::DrawCurrentWeather(void) {
if (!ExecuteViewElement(veCurrentWeather)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
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, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather);
return;
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
}

View File

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

View File

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

View File

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

View File

@ -1,12 +1,13 @@
#define __STL_CONFIG_H
#include <vdr/menu.h>
#include <vdr/videodir.h>
#include "displaymenurootview.h"
#include "displayviewelements.h"
#include "../config.h"
#include "../libcore/helpers.h"
cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) {
cat = mcUndefined;
menuTitle = "";
viewType = svUndefined;
subView = NULL;
subViewAvailable = false;
@ -479,37 +480,9 @@ void cDisplayMenuRootView::DrawHeader(void) {
if (!ExecuteViewElement(veHeader)) {
return;
}
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));
SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
ClearViewElement(veHeader);
DrawViewElement(veHeader, &stringTokens, &intTokens);
}

View File

@ -1,13 +1,10 @@
#define __STL_CONFIG_H
#include <fstream>
#include <iostream>
#include <sys/sysinfo.h>
#include <vdr/menu.h>
#include <vdr/videodir.h>
#include "displaymenuview.h"
#include "displayviewelements.h"
#include "../config.h"
#include "../libcore/helpers.h"
#include "../libcore/timers.h"
#include "../services/scraper2vdr.h"
cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cView(tmplView) {
@ -39,35 +36,9 @@ bool cDisplayMenuView::DrawHeader(void) {
if (!ExecuteViewElement(veHeader)) {
return false;
}
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));
SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
ClearViewElement(veHeader);
DrawViewElement(veHeader, &stringTokens, &intTokens);
return true;
@ -224,8 +195,6 @@ void cDisplayMenuView::Action(void) {
cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) {
initial = true;
lastSystemLoad = 0.0;
lastMemUsage = -1;
InitDevices();
}
@ -256,382 +225,215 @@ void cDisplayMenuMainView::DrawTimers(void) {
if (!ExecuteViewElement(veTimers)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > timerLoopTokens;
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));
if (DetachViewElement(veTimers)) {
cViewElement *viewElement = GetViewElement(veTimers);
if (!viewElement) {
viewElement = new cViewElementTimers(tmplView->GetViewElement(veTimers));
AddViewElement(veTimers, viewElement);
viewElement->Start();
} else {
intTokens.insert(pair<string, int>(name.str(), false));
if (!viewElement->Starting())
viewElement->Render();
}
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > timerLoopTokens;
vector< map< string, string > > timers;
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"));
SetTimers(&intTokens, &stringTokens, &timers);
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));
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
timers.push_back(timerVals);
}
timerLoopTokens.insert(pair< string, vector< map< string, string > > >("timers", timers));
ClearViewElement(veTimers);
DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens);
ClearViewElement(veTimers);
DrawViewElement(veTimers, &stringTokens, &intTokens, &timerLoopTokens);
}
}
void cDisplayMenuMainView::DrawDiscUsage(void) {
if (!ExecuteViewElement(veDiscUsage)) {
return;
}
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));
ClearViewElement(veDiscUsage);
DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
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, int > intTokens;
SetDiscUsage(stringTokens, intTokens);
ClearViewElement(veDiscUsage);
DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
}
}
bool cDisplayMenuMainView::DrawLoad(void) {
if (!ExecuteViewElement(veSystemLoad)) {
return false;
}
map < string, string > stringTokens;
map < string, int > intTokens;
double systemLoad;
if (getloadavg(&systemLoad, 1) > 0) {
if (lastSystemLoad == systemLoad) {
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();
}
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;
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
changed = SetSystemLoad(stringTokens, intTokens);
if (changed) {
ClearViewElement(veSystemLoad);
DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
}
stringTokens.insert(pair<string,string>("load", load));
intTokens.insert(pair<string,int>("loadhand", loadHandValue));
lastSystemLoad = systemLoad;
}
ClearViewElement(veSystemLoad);
DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
return true;
return changed;
}
bool cDisplayMenuMainView::DrawMemory(void) {
if (!ExecuteViewElement(veSystemMemory)) {
return false;
}
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;
bool changed = false;
if (DetachViewElement(veSystemMemory)) {
cViewElement *viewElement = GetViewElement(veSystemMemory);
if (!viewElement) {
viewElement = new cViewElementSystemMemory(tmplView->GetViewElement(veSystemMemory));
AddViewElement(veSystemMemory, viewElement);
viewElement->Start();
changed = true;
} else {
if (!viewElement->Starting())
changed = viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
changed = SetSystemMemory(stringTokens, intTokens);
if (changed) {
ClearViewElement(veSystemMemory);
DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
}
}
lastMemUsage = usedMemMB;
map < string, string > stringTokens;
map < string, int > intTokens;
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));
ClearViewElement(veSystemMemory);
DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
return true;
return changed;
}
void cDisplayMenuMainView::DrawTemperatures(void) {
if (!ExecuteViewElement(veTemperatures)) {
return;
}
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();
if (DetachViewElement(veTemperatures)) {
cViewElement *viewElement = GetViewElement(veTemperatures);
if (!viewElement) {
viewElement = new cViewElementTemperature(tmplView->GetViewElement(veTemperatures));
AddViewElement(veTemperatures, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
tempCPU = "0°C";
cpu = 0;
map < string, string > stringTokens;
map < string, int > intTokens;
bool changed = SetSystemTemperatures(stringTokens, intTokens);
if (changed) {
ClearViewElement(veTemperatures);
DrawViewElement(veTemperatures, &stringTokens, &intTokens);
}
}
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;
}
map < string, string > stringTokens;
map < string, int > intTokens;
intTokens.insert(pair<string,int>("cputemp", cpu));
intTokens.insert(pair<string,int>("gputemp", gpu));
ClearViewElement(veTemperatures);
DrawViewElement(veTemperatures, &stringTokens, &intTokens);
}
bool cDisplayMenuMainView::DrawDevices(void) {
if (!ExecuteViewElement(veDevices)) {
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, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > deviceLoopTokens;
vector< map< string, string > > devices;
changed = SetDevices(initial, &intTokens, &devices);
if (!changed)
return false;
bool changed = SetDevices(initial, &intTokens, &devices);
if (!changed)
return false;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
return true;
deviceLoopTokens.insert(pair< string, vector< map< string, string > > >("devices", devices));
ClearViewElement(veDevices);
DrawViewElement(veDevices, &stringTokens, &intTokens, &deviceLoopTokens);
}
return changed;
}
void cDisplayMenuMainView::DrawCurrentSchedule(void) {
if (!ExecuteViewElement(veCurrentSchedule)) {
return;
}
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;
map < string, string > stringTokens;
map < string, int > 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;
}
if (DetachViewElement(veCurrentSchedule)) {
cViewElement *viewElement = GetViewElement(veCurrentSchedule);
if (!viewElement) {
viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule));
AddViewElement(veCurrentSchedule, viewElement);
viewElement->Start();
} else {
if (!viewElement->Starting())
viewElement->Render();
}
} else {
map < string, string > stringTokens;
map < string, int > intTokens;
SetCurrentSchedule(stringTokens, intTokens);
ClearViewElement(veCurrentSchedule);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
}
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);
DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::DrawCurrentWeather(void) {
if (!ExecuteViewElement(veCurrentWeather)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
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, int > intTokens;
if (!SetCurrentWeatherTokens(stringTokens, intTokens)){
ClearViewElement(veCurrentWeather);
return;
}
ClearViewElement(veCurrentWeather);
return;
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
}
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
}
void cDisplayMenuMainView::DrawCustomTokens(void) {
@ -640,9 +442,22 @@ void cDisplayMenuMainView::DrawCustomTokens(void) {
}
if (!tmplView)
return;
map < string, string > stringTokens = tmplView->GetCustomStringTokens();
map < string, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
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, int > intTokens = tmplView->GetCustomIntTokens();
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
}
}
/************************************************************************

View File

@ -37,8 +37,6 @@ public:
class cDisplayMenuMainView : public cDisplayMenuView {
private:
bool initial;
double lastSystemLoad;
int lastMemUsage;
void DrawTimers(void);
void DrawDiscUsage(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) {
cDevice::PrimaryDevice()->ScaleVideo(scalingWindow);
}
tmplItem = NULL;
tmplViewElement = NULL;
tmplTab = NULL;
Init();
}
cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem ? tmplItem->GetNumPixmaps() : 0) {
this->tmplItem = tmplItem;
cView::cView(cTemplateViewElement *tmplViewElement) : cPixmapContainer(tmplViewElement ? tmplViewElement->GetNumPixmaps() : 0) {
this->tmplViewElement = tmplViewElement;
tmplView = NULL;
tmplTab = NULL;
tvScaled = false;
@ -27,7 +27,7 @@ cView::cView(cTemplateViewElement *tmplItem) : cPixmapContainer(tmplItem ? tmplI
cView::cView(cTemplateViewTab *tmplTab) : cPixmapContainer(1) {
this->tmplTab = tmplTab;
tmplView = NULL;
tmplItem = NULL;
tmplViewElement = NULL;
tvScaled = false;
Init();
}
@ -36,6 +36,10 @@ cView::~cView() {
if (tvScaled) {
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) {
@ -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) {
//setting correct ViewElement, depending which constructor was used
cTemplateViewElement *viewElement;
if (tmplItem && (ve == veMenuCurrentItemDetail || ve == veOnPause)) {
viewElement = tmplItem;
cTemplateViewElement *viewElement = NULL;
if (tmplViewElement) {
viewElement = tmplViewElement;
} else if (tmplView) {
viewElement = tmplView->GetViewElement(ve);
}
@ -91,6 +95,11 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
viewElement->InitIterator();
cTemplatePixmap *pix = NULL;
while(pix = viewElement->GetNextPixmap()) {
//check if already drawn background area, this can be skipped
if (PixmapExists(pixCurrent) && pix->BackgroundArea()) {
pixCurrent++;
continue;
}
//reset Template
pix->ClearDynamicParameters();
//create Pixmap if already fully parsed
@ -148,9 +157,12 @@ void cView::DrawViewElement(eViewElement ve, map <string,string> *stringTokens,
}
void cView::ClearViewElement(eViewElement ve) {
if (!tmplView)
return;
cTemplateViewElement *viewElement = tmplView->GetViewElement(ve);
cTemplateViewElement *viewElement = NULL;
if (tmplViewElement) {
viewElement = tmplViewElement;
} else if (tmplView) {
viewElement = tmplView->GetViewElement(ve);
}
if (!viewElement)
return;
int pixCurrent = viewElement->GetPixOffset();
@ -159,7 +171,9 @@ void cView::ClearViewElement(eViewElement ve) {
cTemplatePixmap *pix = NULL;
viewElement->InitIterator();
while(pix = viewElement->GetNextPixmap()) {
Fill(pixCurrent, clrTransparent);
if (!pix->BackgroundArea()) {
Fill(pixCurrent, clrTransparent);
}
pixCurrent++;
}
}
@ -206,12 +220,20 @@ void cView::ActivateScrolling(void) {
}
bool cView::ExecuteViewElement(eViewElement ve) {
if (!tmplView)
return false;
bool doExecute = tmplView->ExecuteView(ve);
if (!doExecute)
return false;
return tmplView->GetNumPixmapsViewElement(ve);
}
bool cView::DetachViewElement(eViewElement ve) {
if (!tmplView)
return false;
return tmplView->DetachViewElement(ve);
}
bool cView::ViewElementScrolls(eViewElement ve) {
if (scrollingPix < 0)
return false;
@ -227,6 +249,17 @@ bool cView::ViewElementScrolls(eViewElement ve) {
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) {
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
************************************************************************/
@ -824,18 +893,18 @@ cViewListItem::~cViewListItem() {
cRect cViewListItem::DrawListItem(map <string,string> *stringTokens, map <string,int> *intTokens) {
cRect posItem;
if (!tmplItem)
if (!tmplViewElement)
return posItem;
if (tmplItem->DebugTokens()) {
if (tmplViewElement->DebugTokens()) {
DebugTokens("ListItem", stringTokens, intTokens);
}
tmplItem->InitIterator();
tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL;
int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) {
while(pix = tmplViewElement->GetNextPixmap()) {
SetListElementPosition(pix);
if (pixCurrent == 0) {
posItem = pix->GetPixmapSize();
@ -980,13 +1049,13 @@ void cGrid::SetCurrent(bool current) {
}
void cGrid::Move(void) {
if (!tmplItem)
if (!tmplViewElement)
return;
tmplItem->InitIterator();
tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL;
int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) {
while(pix = tmplViewElement->GetNextPixmap()) {
PositionPixmap(pix);
cRect pixViewPort = pix->GetPixmapSize();
SetViewPort(pixCurrent, pixViewPort);
@ -998,17 +1067,17 @@ void cGrid::Move(void) {
}
void cGrid::Draw(void) {
if (!tmplItem)
if (!tmplViewElement)
return;
if (tmplItem->DebugTokens()) {
if (tmplViewElement->DebugTokens()) {
DebugTokens("Grid", &stringTokens, &intTokens);
}
tmplItem->InitIterator();
tmplViewElement->InitIterator();
cTemplatePixmap *pix = NULL;
int pixCurrent = 0;
while(pix = tmplItem->GetNextPixmap()) {
while(pix = tmplViewElement->GetNextPixmap()) {
PositionPixmap(pix);
if (!PixmapExists(pixCurrent)) {
pix->ParseDynamicParameters(&intTokens, true);

View File

@ -8,6 +8,8 @@
using namespace std;
class cViewElement;
class cView : public cPixmapContainer {
private:
void Init(void);
@ -23,8 +25,10 @@ private:
void ActivateScrolling(void);
protected:
cTemplateView *tmplView;
cTemplateViewElement *tmplItem;
cTemplateViewElement *tmplViewElement;
cTemplateViewTab *tmplTab;
//detached viewelements
map < eViewElement, cViewElement* > detachedViewElements;
//scaling window
cRect scalingWindow;
bool tvScaled;
@ -43,7 +47,10 @@ protected:
void ClearViewElement(eViewElement ve);
void DestroyViewElement(eViewElement ve);
bool ExecuteViewElement(eViewElement ve);
bool DetachViewElement(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 CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize);
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);
public:
cView(cTemplateView *tmplView);
cView(cTemplateViewElement *tmplItem);
cView(cTemplateViewElement *tmplViewElement);
cView(cTemplateViewTab *tmplTab);
virtual ~cView();
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 {
protected:
int pos;

View File

@ -1,15 +1,25 @@
#include <fstream>
#include <iostream>
#include <vdr/menu.h>
#include <vdr/videodir.h>
#include <sys/sysinfo.h>
#include "../services/scraper2vdr.h"
#include "../services/weatherforecast.h"
#include "../config.h"
#include "../libcore/timers.h"
#include "../libcore/helpers.h"
#include "viewhelpers.h"
cViewHelpers::cViewHelpers(void) {
numDevices = 0;
devicesInit = false;
lSignalDisplay = 0;
lSignalStrength = 0;
lSignalQuality = 0;
lastSecond = -1;
lastMinute = -1;
lastSystemLoad = 0.0;
lastMemUsage = -1;
}
cViewHelpers::~cViewHelpers() {
@ -141,6 +151,28 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
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) {
static cPlugin *pMailbox = cPluginManager::GetPlugin("mailbox");
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) {
time_t t = time(0); // get time now
struct tm * now = localtime(&t);
int sec = now->tm_sec;
if (sec == lastSecond)
if (sec == lastSecond) {
return false;
}
int min = now->tm_min;
int hour = now->tm_hour;
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));
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* lastSignalQuality;
bool* recDevices;
int lSignalDisplay;
int lSignalStrength;
int lSignalQuality;
int lastSecond;
int lastMinute;
double lastSystemLoad;
int lastMemUsage;
protected:
void InitDevices(void);
bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices);
bool SetSignal(map < string, int > &intTokens);
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 SetPosterBanner(const cEvent *event, 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 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:
cViewHelpers(void);
virtual ~cViewHelpers(void);