summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2016-01-26 18:32:38 +0100
committerlouis <louis.braun@gmx.de>2016-01-26 18:32:38 +0100
commit809fbda03c5014ba9cd361f5113d1d717cd41ea6 (patch)
tree264bbc5640375f1bcb165fc7f4a3e595adcc26ca /views
parent196dd7eb9965a405bb16b51dc870fbbb31aeef87 (diff)
downloadvdr-plugin-skindesigner-809fbda03c5014ba9cd361f5113d1d717cd41ea6.tar.gz
vdr-plugin-skindesigner-809fbda03c5014ba9cd361f5113d1d717cd41ea6.tar.bz2
Version 0.8.0 beta
Diffstat (limited to 'views')
-rw-r--r--views/animation.c111
-rw-r--r--views/animation.h69
-rw-r--r--views/displayaudiotracksview.c72
-rw-r--r--views/displayaudiotracksview.h23
-rw-r--r--views/displaychannelview.c596
-rw-r--r--views/displaychannelview.h57
-rw-r--r--views/displaymenudetailview.c871
-rw-r--r--views/displaymenudetailview.h52
-rw-r--r--views/displaymenuitemcurrentview.c636
-rw-r--r--views/displaymenuitemcurrentview.h84
-rw-r--r--views/displaymenuitemview.c981
-rw-r--r--views/displaymenuitemview.h161
-rw-r--r--views/displaymenulistview.c274
-rw-r--r--views/displaymenulistview.h43
-rw-r--r--views/displaymenurootview.c732
-rw-r--r--views/displaymenurootview.h87
-rw-r--r--views/displaymenutabview.c125
-rw-r--r--views/displaymenutabview.h27
-rw-r--r--views/displaymenuview.c673
-rw-r--r--views/displaymenuview.h88
-rw-r--r--views/displaymessageview.c39
-rw-r--r--views/displaymessageview.h18
-rw-r--r--views/displaypluginview.c288
-rw-r--r--views/displaypluginview.h62
-rw-r--r--views/displayreplayonpauseview.c108
-rw-r--r--views/displayreplayonpauseview.h21
-rw-r--r--views/displayreplayview.c499
-rw-r--r--views/displayreplayview.h52
-rw-r--r--views/displayviewelements.c142
-rw-r--r--views/displayviewelements.h84
-rw-r--r--views/displayvolumeview.c45
-rw-r--r--views/displayvolumeview.h20
-rw-r--r--views/view.c1533
-rw-r--r--views/view.h155
-rw-r--r--views/viewgrid.c89
-rw-r--r--views/viewgrid.h28
-rw-r--r--views/viewhelpers.c1276
-rw-r--r--views/viewhelpers.h62
38 files changed, 0 insertions, 10283 deletions
diff --git a/views/animation.c b/views/animation.c
deleted file mode 100644
index d06a810..0000000
--- a/views/animation.c
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "animation.h"
-
-using namespace std;
-
-cAnimation::cAnimation(eAnimType animType, int animFreq, cRect &pos, int layer) : cPixmapContainer(1) {
- delay = 0;
- this->animType = animType;
- this->animFreq = animFreq;
- this->pos = pos;
- this->layer = layer;
- blinkOn = true;
-}
-
-cAnimation::~cAnimation() {
-}
-
-void cAnimation::Action(void) {
- CreatePixmap(0, layer+1, pos);
- bool init = true;
- DoSleep(delay);
- while (Running()) {
- if (animType == atBlink) {
- if (!blinkOn) {
- Fill(0, clrTransparent);
- blinkOn = true;
- } else {
- DrawBlink();
- }
- } else if (animType == atAnimated) {
- esyslog("skindesigner: animationType atAnimated not implemented");
- }
- if (init)
- FadeIn();
- init = false;
- DoFlush();
- DoSleep(animFreq);
- }
-}
-
-void cAnimation::Stop(void) {
- CancelSave();
-}
-
-/********************************************************************************************
-* cAnimatedImage
-********************************************************************************************/
-cAnimatedImage::cAnimatedImage(eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
- image = NULL;
-}
-
-cAnimatedImage::~cAnimatedImage() {
-}
-
-void cAnimatedImage::DrawBlink(void) {
- blinkOn = false;
- if (!image)
- return;
-
- cPoint posImage(0,0);
- if (Running())
- DrawImage(0, posImage, *image);
-}
-
-/********************************************************************************************
-* cAnimatedText
-********************************************************************************************/
-cAnimatedText::cAnimatedText(eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
- text = "";
- fontName = "";
- fontSize = 1;
- fontColor = clrTransparent;
-}
-
-cAnimatedText::~cAnimatedText() {
-}
-
-void cAnimatedText::DrawBlink(void) {
- blinkOn = false;
- if (text.size() == 0)
- return;
-
- cPoint posText(0,0);
- if (Running())
- DrawText(0, posText, text.c_str(), fontColor, clrTransparent, fontName, fontSize);
-}
-
-/********************************************************************************************
-* cAnimatedOsdObject
-********************************************************************************************/
-cAnimatedOsdObject::cAnimatedOsdObject(eFuncType type, eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
- this->type = type;
- color = 0x00000000;
- quadrant = 0;
-}
-
-cAnimatedOsdObject::~cAnimatedOsdObject() {
-}
-
-void cAnimatedOsdObject::DrawBlink(void) {
- blinkOn = false;
- cRect posObject(0, 0, pos.Width(), pos.Height());
- if (Running()) {
- if (type == ftDrawRectangle) {
- DrawRectangle(0, posObject, color);
- } else if (type == ftDrawEllipse) {
- DrawEllipse(0, posObject, color, quadrant);
- } else if (type == ftDrawSlope) {
- DrawSlope(0, posObject, color, quadrant);
- }
- }
-}
diff --git a/views/animation.h b/views/animation.h
deleted file mode 100644
index 743c002..0000000
--- a/views/animation.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef __ANIMATION_H
-#define __ANIMATION_H
-
-#include "string"
-#include "../libcore/pixmapcontainer.h"
-#include "../libtemplate/template.h"
-
-using namespace std;
-
-class cAnimation : public cPixmapContainer {
- int delay;
-protected:
- eAnimType animType;
- int animFreq;
- cRect pos;
- int layer;
- bool blinkOn;
- virtual void DrawBlink(void) {};
- virtual void Action(void);
-public:
- cAnimation(eAnimType animType, int animFreq, cRect &pos, int layer);
- virtual ~cAnimation();
- void SetDelay(int delay) { this->delay = delay; };
- virtual void Stop(void);
-};
-
-class cAnimatedImage : public cAnimation {
-private:
- cImage *image;
-protected:
- void DrawBlink(void);
-public:
- cAnimatedImage(eAnimType animType, int animFreq, cRect &pos, int layer);
- virtual ~cAnimatedImage();
- void SetImage(cImage *i) { image = i; };
-};
-
-class cAnimatedText : public cAnimation {
-private:
- string text;
- string fontName;
- int fontSize;
- tColor fontColor;
-protected:
- void DrawBlink(void);
-public:
- cAnimatedText(eAnimType animType, int animFreq, cRect &pos, int layer);
- virtual ~cAnimatedText();
- void SetText(string &t) { text = t; };
- void SetFont(string &font) { fontName = font; };
- void SetFontSize(int size) { fontSize = size; };
- void SetFontColor(tColor col) { fontColor = col; };
-};
-
-class cAnimatedOsdObject : public cAnimation {
-private:
- eFuncType type;
- tColor color;
- int quadrant;
-protected:
- void DrawBlink(void);
-public:
- cAnimatedOsdObject(eFuncType type, eAnimType animType, int animFreq, cRect &pos, int layer);
- virtual ~cAnimatedOsdObject();
- void SetColor(tColor col) { color = col; };
- void SetQuadrant(int q) { quadrant = q; };
-};
-
-#endif //__ANIMATION_H \ No newline at end of file
diff --git a/views/displayaudiotracksview.c b/views/displayaudiotracksview.c
deleted file mode 100644
index a24d331..0000000
--- a/views/displayaudiotracksview.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#define __STL_CONFIG_H
-#include <vdr/menu.h>
-#include "../displaymenu.h"
-#include "displayaudiotracksview.h"
-
-cDisplayAudiotracksView::cDisplayAudiotracksView(int numTracks, cTemplateView *tmplView) : cView(tmplView) {
- DeleteOsdOnExit();
-
- this->numTracks = numTracks;
-
- cTemplateViewList *tmplMenuItems = tmplView->GetViewList(vlMenuItem);
- listView = NULL;
- if (tmplMenuItems) {
- listView = new cDisplayMenuListView(tmplMenuItems, numTracks);
- }
-}
-
-cDisplayAudiotracksView::~cDisplayAudiotracksView() {
- if (listView)
- delete listView;
- CancelSave();
- FadeOut();
-}
-
-bool cDisplayAudiotracksView::createOsd(void) {
- cRect osdSize = tmplView->GetOsdSize();
- bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
- cOsd::OsdTop() + osdSize.Y(),
- osdSize.Width(),
- osdSize.Height());
- return ok;
-}
-
-void cDisplayAudiotracksView::DrawBackground(void) {
- if (!ExecuteViewElement(veBackground)) {
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- intTokens.insert(pair<string,int>("numtracks", numTracks));
-
- DrawViewElement(veBackground, &stringTokens, &intTokens);
-}
-
-void cDisplayAudiotracksView::DrawHeader(const char *title, int audioChannel) {
- if (!ExecuteViewElement(veHeader)) {
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- intTokens.insert(pair<string,int>("numtracks", numTracks));
- if (audioChannel < 0) {
- intTokens.insert(pair<string,int>("isac3", true));
- intTokens.insert(pair<string,int>("isstereo", false));
- } else {
- intTokens.insert(pair<string,int>("isac3", false));
- intTokens.insert(pair<string,int>("isstereo", true));
- }
- stringTokens.insert(pair<string,string>("title", title));
-
- ClearViewElement(veHeader);
- DrawViewElement(veHeader, &stringTokens, &intTokens);
-}
-
-void cDisplayAudiotracksView::RenderMenuItems(void) {
- if (listView)
- listView->Render();
-}
diff --git a/views/displayaudiotracksview.h b/views/displayaudiotracksview.h
deleted file mode 100644
index 1a2e4c0..0000000
--- a/views/displayaudiotracksview.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __DISPLAYAUDIOTRACKSVIEW_H
-#define __DISPLAYAUDIOTRACKSVIEW_H
-
-#include "../libtemplate/template.h"
-#include "displaymenulistview.h"
-
-class cDisplayAudiotracksView : public cView {
-protected:
- int numTracks;
- cDisplayMenuListView *listView;
-public:
- cDisplayAudiotracksView(int numTracks, cTemplateView *tmplView);
- virtual ~cDisplayAudiotracksView();
- bool createOsd(void);
- void DrawBackground(void);
- void DrawHeader(const char *title, int audioChannel);
- cDisplayMenuListView *GetListView(void) { return listView; };
- void DoFadeIn(void) { Start(); };
- void Flush(void) { DoFlush(); };
- void RenderMenuItems(void);
-};
-
-#endif //__DISPLAYAUDIOTRACKSVIEW_H
diff --git a/views/displaychannelview.c b/views/displaychannelview.c
deleted file mode 100644
index 06ebe88..0000000
--- a/views/displaychannelview.c
+++ /dev/null
@@ -1,596 +0,0 @@
-#define __STL_CONFIG_H
-#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;
- lastNumAudioTracks = 0;
- lastAudioChannel = -1;
- lastTracDesc = "";
- lastTrackLang = "";
- InitDevices();
- DeleteOsdOnExit();
-}
-
-cDisplayChannelView::~cDisplayChannelView() {
-}
-
-bool cDisplayChannelView::createOsd(void) {
- cRect osdSize = tmplView->GetOsdSize();
- bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
- cOsd::OsdTop() + osdSize.Y(),
- osdSize.Width(),
- osdSize.Height());
- return ok;
-}
-
-void cDisplayChannelView::DrawBackground(void) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- DrawViewElement(veBackground, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::DrawChannel(cString &number, cString &name, cString &id, bool switching) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- stringTokens.insert(pair<string,string>("channelname", *name));
- stringTokens.insert(pair<string,string>("channelnumber", *number));
- stringTokens.insert(pair<string,string>("channelid", *id));
-
- intTokens.insert(pair<string, int>("switching", switching));
- bool logoExisis = imgCache->LogoExists(*id);
- intTokens.insert(pair<string, int>("channellogoexists", logoExisis));
-
- DrawViewElement(veChannelInfo, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::ClearChannel(void) {
- ClearViewElement(veChannelInfo);
-}
-
-void cDisplayChannelView::DrawDate(void) {
- if (!ExecuteViewElement(veDateTime)) {
- return;
- }
- if (DetachViewElement(veDateTime)) {
- cViewElement *viewElement = GetViewElement(veDateTime);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veDateTime), this);
- viewElement->SetCallback(veDateTime, &cDisplayChannelView::SetDate);
- AddViewElement(veDateTime, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetDate(false, stringTokens, intTokens)) {
- return;
- }
-
- ClearViewElement(veDateTime);
- DrawViewElement(veDateTime, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayChannelView::DrawTime(void) {
- if (!ExecuteViewElement(veTime)) {
- return;
- }
- if (DetachViewElement(veTime)) {
- cViewElement *viewElement = GetViewElement(veTime);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veTime), this);
- viewElement->SetCallback(veTime, &cDisplayChannelView::SetTime);
- AddViewElement(veTime, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetTime(false, stringTokens, intTokens)) {
- return;
- }
- ClearViewElement(veTime);
- DrawViewElement(veTime, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayChannelView::DrawProgressBar(cString &start, cString &stop, int Current, int Total) {
- if (!ExecuteViewElement(veProgressBar)) {
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- stringTokens.insert(pair<string, string>("start", *start));
- stringTokens.insert(pair<string, string>("stop", *stop));
-
- intTokens.insert(pair<string, int>("duration", Total));
- intTokens.insert(pair<string, int>("elapsed", Current));
- intTokens.insert(pair<string, int>("remaining", Total - Current));
-
- int liveBuffer = GetLiveBuffer();
- if (liveBuffer >= 0) {
- intTokens.insert(pair<string, int>("permashift", 1));
- intTokens.insert(pair<string, int>("livebuffer", liveBuffer));
- } else {
- intTokens.insert(pair<string, int>("permashift", 0));
- intTokens.insert(pair<string, int>("livebuffer", 0));
- }
-
- ClearProgressBar();
- DrawViewElement(veProgressBar, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::ClearProgressBar(void) {
- ClearViewElement(veProgressBar);
-}
-
-void cDisplayChannelView::DrawProgressBarBack(void) {
- DrawViewElement(veProgressBarBack);
-}
-
-void cDisplayChannelView::ClearProgressBarBack(void) {
- ClearViewElement(veProgressBarBack);
-}
-
-void cDisplayChannelView::DrawEPGInfo(const cEvent *present, const cEvent *next, bool presentRecording, bool nextRecording) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (present) {
- stringTokens.insert(pair<string,string>("currenttitle", (present->Title())?present->Title():""));
- stringTokens.insert(pair<string,string>("currentsubtitle", (present->ShortText())?present->ShortText():""));
- stringTokens.insert(pair<string,string>("currentstart", *present->GetTimeString()));
- stringTokens.insert(pair<string,string>("currentstop", *present->GetEndTimeString()));
-
- intTokens.insert(pair<string,int>("currentduration", present->Duration() / 60));
- intTokens.insert(pair<string,int>("currentdurationhours", present->Duration() / 3600));
- stringTokens.insert(pair<string,string>("currentdurationminutes", *cString::sprintf("%.2d", (present->Duration() / 60)%60)));
- intTokens.insert(pair<string,int>("currentelapsed", (int)round((time(NULL) - present->StartTime())/60)));
- intTokens.insert(pair<string,int>("currentremaining", (int)round((present->EndTime() - time(NULL))/60)));
- intTokens.insert(pair<string,int>("currentrecording", presentRecording ? 1 : 0));
- intTokens.insert(pair<string,int>("hasVPS", (bool)present->Vps()));
- } else {
- stringTokens.insert(pair<string,string>("currenttitle", ""));
- stringTokens.insert(pair<string,string>("currentsubtitle", ""));
- stringTokens.insert(pair<string,string>("currentstart", ""));
- stringTokens.insert(pair<string,string>("currentstop", ""));
-
- intTokens.insert(pair<string,int>("currentduration", 0));
- intTokens.insert(pair<string,int>("currentdurationhours", 0));
- stringTokens.insert(pair<string,string>("currentdurationminutes", ""));
- intTokens.insert(pair<string,int>("currentelapsed", 0));
- intTokens.insert(pair<string,int>("currentremaining", 0));
- intTokens.insert(pair<string,int>("currentrecording", 0));
- intTokens.insert(pair<string,int>("hasVPS", 0));
- }
-
- if (next) {
- stringTokens.insert(pair<string,string>("nexttitle", (next->Title())?next->Title():""));
- stringTokens.insert(pair<string,string>("nextsubtitle", (next->ShortText())?next->ShortText():""));
- stringTokens.insert(pair<string,string>("nextstart", *next->GetTimeString()));
- stringTokens.insert(pair<string,string>("nextstop", *next->GetEndTimeString()));
-
- intTokens.insert(pair<string,int>("nextduration", next->Duration() / 60));
- intTokens.insert(pair<string,int>("nextdurationhours", next->Duration() / 3600));
- stringTokens.insert(pair<string,string>("nextdurationminutes", *cString::sprintf("%.2d", (next->Duration() / 60)%60)));
- intTokens.insert(pair<string,int>("nextrecording", nextRecording ? 1 : 0));
- } else {
- stringTokens.insert(pair<string,string>("nexttitle", ""));
- stringTokens.insert(pair<string,string>("nextsubtitle", ""));
- stringTokens.insert(pair<string,string>("nextstart", ""));
- stringTokens.insert(pair<string,string>("nextstop", ""));
-
- intTokens.insert(pair<string,int>("nextduration", 0));
- intTokens.insert(pair<string,int>("nextdurationhours", 0));
- stringTokens.insert(pair<string,string>("nextdurationminutes", ""));
- intTokens.insert(pair<string,int>("nextrecording", 0));
- }
- DrawViewElement(veEpgInfo, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::ClearEPGInfo(void) {
- ClearViewElement(veEpgInfo);
-}
-
-void cDisplayChannelView::DrawStatusIcons(const cChannel *Channel) {
- if (!ExecuteViewElement(veStatusInfo)) {
- return;
- }
-
- map < string, int > intTokens;
- map < string, string > stringTokens;
-
- bool isRadio = !Channel->Vpid() && Channel->Apid(0);
- bool hasVT = Channel->Vpid() && Channel->Tpid();
- bool isStereo = Channel->Apid(0);
- bool isDolby = Channel->Dpid(0);
- bool isEncrypted = Channel->Ca();
- bool isRecording = cRecordControls::Active();
- cGlobalSortedTimers SortedTimers;// local and remote timers
- for (int i = 0; i < SortedTimers.Size() && !isRecording; i++)
- if (const cTimer *Timer = SortedTimers[i])
- if (Timer->Recording())
- isRecording = true;
-
- intTokens.insert(pair<string,int>("isRadio", isRadio));
- intTokens.insert(pair<string,int>("hasVT", hasVT));
- intTokens.insert(pair<string,int>("isStereo", isStereo));
- intTokens.insert(pair<string,int>("isDolby", isDolby));
- intTokens.insert(pair<string,int>("isEncrypted", isEncrypted));
- intTokens.insert(pair<string,int>("isRecording", isRecording));
- intTokens.insert(pair<string,int>("newmails", CheckNewMails()));
-
- DrawViewElement(veStatusInfo, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::ClearStatusIcons(void) {
- ClearViewElement(veStatusInfo);
-}
-
-void cDisplayChannelView::DrawAudioInfo(void) {
- if (!ExecuteViewElement(veAudioInfo)) {
- return;
- }
-
- int numAudioTracks = 0;
- int audioChannel = -1;
- string trackDescription = "";
- string trackLanguage = "";
-
- cDevice *device = cDevice::PrimaryDevice();
- if (device) {
- numAudioTracks = device->NumAudioTracks();
- audioChannel = device->GetAudioChannel();
- if (numAudioTracks > 0) {
- const tTrackId *track = device->GetTrack(device->GetCurrentAudioTrack());
- if (track) {
- trackDescription = track->description ? track->description : "";
- trackLanguage = track->language ? track->language : "";
- }
- }
- }
- if (lastNumAudioTracks != numAudioTracks || lastAudioChannel != audioChannel || lastTracDesc.compare(trackDescription) || lastTrackLang.compare(trackLanguage)) {
- lastNumAudioTracks = numAudioTracks;
- lastAudioChannel = audioChannel;
- lastTracDesc = trackDescription;
- lastTrackLang = trackLanguage;
-
- map < string, int > intTokens;
- map < string, string > stringTokens;
- intTokens.insert(pair<string,int>("numaudiotracks", numAudioTracks));
- intTokens.insert(pair<string,int>("audiochannel", audioChannel));
- stringTokens.insert(pair<string,string>("trackdesc", trackDescription));
- stringTokens.insert(pair<string,string>("tracklang", trackLanguage));
-
- ClearAudioInfo();
- DrawViewElement(veAudioInfo, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayChannelView::ClearAudioInfo(void) {
- ClearViewElement(veAudioInfo);
-}
-
-void cDisplayChannelView::DrawEncryptionInfo(int channelSid) {
- if (!ExecuteViewElement(veEcmInfo)) {
- return;
- }
- map < string, int > intTokens;
- map < string, string > stringTokens;
-
- if (SetEcmInfos(channelSid, stringTokens, intTokens)) {
- ClearEncryptionInfo();
- DrawViewElement(veEcmInfo, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayChannelView::ClearEncryptionInfo(void) {
- ClearViewElement(veEcmInfo);
-}
-
-void cDisplayChannelView::DrawScreenResolution(void) {
- if (!ExecuteViewElement(veScreenResolution)) {
- return;
- }
-
- int screenWidth = 0;
- int screenHeight = 0;
- double aspect = 0;
-
- cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, aspect);
-
- if ((lastScreenWidth == screenWidth) && (lastScreenHeight == screenHeight))
- return;
-
- if ((screenWidth == 0) && (screenHeight == 0))
- return;
-
- lastScreenWidth = screenWidth;
- lastScreenHeight = screenHeight;
-
- bool isHD = false;
- string resName = GetScreenResolutionString(screenWidth, screenHeight, &isHD);
-
- bool isWideScreen = false;
- string aspectName = GetScreenAspectString(aspect, &isWideScreen);
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- intTokens.insert(pair<string,int>("screenwidth", screenWidth));
- intTokens.insert(pair<string,int>("screenheight", screenHeight));
- intTokens.insert(pair<string,int>("isHD", isHD));
- intTokens.insert(pair<string,int>("isWideScreen", isWideScreen));
- stringTokens.insert(pair<string,string>("resolution", resName));
- stringTokens.insert(pair<string,string>("aspect", aspectName));
-
- ClearViewElement(veScreenResolution);
- DrawViewElement(veScreenResolution, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::ClearScreenResolution(void) {
- ClearViewElement(veScreenResolution);
- lastScreenWidth = 0;
- lastScreenHeight = 0;
-}
-
-void cDisplayChannelView::DrawScraperContent(const cEvent *event) {
- if (!event) {
- return;
- }
-
- if (!ExecuteViewElement(veScraperContent)) {
- return;
- }
-
- if (DetachViewElement(veScraperContent)) {
- cViewElementScraperContent *viewElement = dynamic_cast<cViewElementScraperContent*>(GetViewElement(veScraperContent));
- if (!viewElement) {
- viewElement = new cViewElementScraperContent(event, NULL, tmplView->GetViewElement(veScraperContent));
- AddViewElement(veScraperContent, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting()) {
- viewElement->SetEvent(event);
- viewElement->Render();
- }
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- SetPosterBanner(event, stringTokens, intTokens);
- ClearScraperContent();
- DrawViewElement(veScraperContent, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayChannelView::ClearScraperContent(void) {
- ClearViewElement(veScraperContent);
-}
-
-void cDisplayChannelView::DrawSignal(void) {
- if (!ExecuteViewElement(veSignalQuality)) {
- return;
- }
-
- if (DetachViewElement(veSignalQuality)) {
- cViewElement *viewElement = GetViewElement(veSignalQuality);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veSignalQuality), this);
- viewElement->SetCallback(veSignalQuality, &cDisplayChannelView::SetSignal);
- AddViewElement(veSignalQuality, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- bool changed = SetSignal(false, stringTokens, intTokens);
- if (!changed)
- return;
-
- ClearSignal();
- DrawViewElement(veSignalQuality, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayChannelView::DrawSignalBackground(void) {
- if (!ExecuteViewElement(veSignalQualityBack)) {
- return;
- }
- DrawViewElement(veSignalQualityBack);
-}
-
-
-void cDisplayChannelView::ClearSignal(void) {
- ClearViewElement(veSignalQuality);
-}
-
-void cDisplayChannelView::ClearSignalBackground(void) {
- ClearViewElement(veSignalQualityBack);
-}
-
-void cDisplayChannelView::DrawDevices(bool initial) {
- if (!ExecuteViewElement(veDevices)) {
- return;
- }
- string mode = tmplView->GetViewElementMode(veDevices);
- bool light = false;
- if (!mode.compare("light")) {
- light = true;
- }
- if (DetachViewElement(veDevices)) {
- cViewElement *viewElement = GetViewElement(veDevices);
- if (!viewElement) {
- viewElement = new cViewElementDevices(light, 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;
-
- bool changed = SetDevices(initial, light, &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) {
- ClearViewElement(veDevices);
-}
-
-void cDisplayChannelView::DrawChannelGroups(const cChannel *Channel, cString ChannelName) {
- if (!ExecuteViewElement(veChannelGroup)) {
- return;
- }
-
- bool separatorExists = imgCache->SeparatorLogoExists(*ChannelName);
- string separatorPath = separatorExists ? *ChannelName : "";
-
- string prevChannelSep = GetChannelSep(Channel, true);
- string nextChannelSep = GetChannelSep(Channel, false);
- bool prevAvailable = (prevChannelSep.size() > 0)?true:false;
- bool nextAvailable = (nextChannelSep.size() > 0)?true:false;
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- intTokens.insert(pair<string,int>("sepexists", separatorExists));
- intTokens.insert(pair<string,int>("prevAvailable", prevAvailable));
- intTokens.insert(pair<string,int>("nextAvailable", nextAvailable));
- stringTokens.insert(pair<string,string>("group", *ChannelName));
- stringTokens.insert(pair<string,string>("nextgroup", nextChannelSep));
- stringTokens.insert(pair<string,string>("prevgroup", prevChannelSep));
- stringTokens.insert(pair<string,string>("seppath", separatorPath));
-
- ClearViewElement(veChannelGroup);
- DrawViewElement(veChannelGroup, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::ClearChannelGroups(void) {
- ClearViewElement(veChannelGroup);
-}
-
-string cDisplayChannelView::GetChannelSep(const cChannel *channel, bool prev) {
- string sepName = "";
- const cChannel *sep = prev ? Channels.Prev(channel) :
- Channels.Next(channel);
- for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) {
- if (sep->GroupSep()) {
- sepName = sep->Name();
- break;
- }
- }
- return sepName;
-}
-
-void cDisplayChannelView::DisplayMessage(eMessageType Type, const char *Text) {
- if (!Text) {
- ClearViewElement(veMessage);
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- stringTokens.insert(pair<string,string>("text", Text));
-
- intTokens.insert(pair<string,int>("status", (Type == mtStatus) ? true : false));
- intTokens.insert(pair<string,int>("info", (Type == mtInfo) ? true : false));
- intTokens.insert(pair<string,int>("warning", (Type == mtWarning) ? true : false));
- intTokens.insert(pair<string,int>("error", (Type == mtError) ? true : false));
-
- ClearViewElement(veMessage);
- DrawViewElement(veMessage, &stringTokens, &intTokens);
-}
-
-void cDisplayChannelView::DrawCustomTokens(void) {
- if (!ExecuteViewElement(veCustomTokens)) {
- return;
- }
- if (!tmplView)
- return;
-
- if (DetachViewElement(veCustomTokens)) {
- cViewElement *viewElement = GetViewElement(veCustomTokens);
- if (!viewElement) {
- viewElement = new cViewElementCustomTokens(tmplView->GetViewElement(veCustomTokens), tmplView);
- AddViewElement(veCustomTokens, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens = tmplView->GetCustomStringTokens();
- map < string, int > intTokens = tmplView->GetCustomIntTokens();
- ClearViewElement(veCustomTokens);
- DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
- }
-}
-
-bool cDisplayChannelView::CustomTokenChange(void) {
- if (!tmplView)
- return false;
- return tmplView->CustomTokenChange();
-}
-
-
-void cDisplayChannelView::DrawCurrentWeather(void) {
- if (!ExecuteViewElement(veCurrentWeather)) {
- return;
- }
-
- if (DetachViewElement(veCurrentWeather)) {
- cViewElement *viewElement = GetViewElement(veCurrentWeather);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veCurrentWeather), this);
- viewElement->SetCallback(veCurrentWeather, &cDisplayChannelView::SetCurrentWeatherTokens);
- AddViewElement(veCurrentWeather, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- ClearViewElement(veCurrentWeather);
- if (!SetCurrentWeatherTokens(false, stringTokens, intTokens)){
- return;
- }
- DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
- }
-}
diff --git a/views/displaychannelview.h b/views/displaychannelview.h
deleted file mode 100644
index 9468d7d..0000000
--- a/views/displaychannelview.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __DISPLAYCHANNELVIEW_H
-#define __DISPLAYCHANNELVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-#include "viewhelpers.h"
-
-class cDisplayChannelView : public cView, public cViewHelpers {
-private:
- int lastScreenWidth;
- int lastScreenHeight;
- int lastNumAudioTracks;
- int lastAudioChannel;
- string lastTracDesc;
- string lastTrackLang;
- string GetChannelSep(const cChannel *channel, bool prev);
-public:
- cDisplayChannelView(cTemplateView *tmplView);
- virtual ~cDisplayChannelView();
- bool createOsd(void);
- void DrawBackground(void);
- void DrawChannel(cString &number, cString &name, cString &id, bool switching);
- void ClearChannel(void);
- void DrawDate(void);
- void DrawTime(void);
- void DrawProgressBar(cString &start, cString &stop, int Current, int Total);
- void ClearProgressBar(void);
- void DrawProgressBarBack(void);
- void ClearProgressBarBack(void);
- void DrawEPGInfo(const cEvent *present, const cEvent *next, bool presentRecording, bool nextRecording);
- void ClearEPGInfo(void);
- void DrawStatusIcons(const cChannel *Channel);
- void ClearStatusIcons(void);
- void DrawAudioInfo(void);
- void ClearAudioInfo(void);
- void DrawEncryptionInfo(int channelSid);
- void ClearEncryptionInfo(void);
- void DrawScreenResolution(void);
- void ClearScreenResolution(void);
- void DrawScraperContent(const cEvent *event);
- void ClearScraperContent(void);
- void DrawSignal(void);
- void DrawSignalBackground(void);
- void ClearSignal(void);
- void ClearSignalBackground(void);
- void DrawDevices(bool initial);
- void ClearDevices(void);
- void DrawChannelGroups(const cChannel *Channel, cString ChannelName);
- void ClearChannelGroups(void);
- void DisplayMessage(eMessageType Type, const char *Text);
- void DrawCustomTokens(void);
- bool CustomTokenChange(void);
- void DrawCurrentWeather(void);
- void DoStart(void) { Start(); };
- void Flush(void) { DoFlush(); };
-};
-#endif //__DISPLAYCHANNELVIEW_H
diff --git a/views/displaymenudetailview.c b/views/displaymenudetailview.c
deleted file mode 100644
index a6e4c84..0000000
--- a/views/displaymenudetailview.c
+++ /dev/null
@@ -1,871 +0,0 @@
-#include "displaymenudetailview.h"
-#include "../libcore/helpers.h"
-#include "../services/scraper2vdr.h"
-#include "../services/epgsearch.h"
-
-cDisplayMenuDetailView::cDisplayMenuDetailView(cTemplateView *tmplDetailView) : cView(tmplDetailView) {
- event = NULL;
- recording = NULL;
- text = NULL;
- detailViewInit = true;
- isPluginTextView = false;
- currentTmplTab = NULL;
- tabView = NULL;
-}
-
-cDisplayMenuDetailView::~cDisplayMenuDetailView() {
- CancelSave();
- if (tabView)
- delete tabView;
-}
-
-void cDisplayMenuDetailView::SetPluginTokens(map<string,string> *plugStringTokens, map<string,int> *plugIntTokens, map<string,vector<map<string,string> > > *plugLoopTokens) {
- for (map<string,string>::iterator it = plugStringTokens->begin(); it != plugStringTokens->end(); it++) {
- stringTokens.insert(pair<string,string>(it->first, it->second));
- }
-
- for (map<string,int>::iterator it = plugIntTokens->begin(); it != plugIntTokens->end(); it++) {
- intTokens.insert(pair<string,int>(it->first, it->second));
- }
-
- for(map<string,vector<map<string,string> > >::iterator it = plugLoopTokens->begin(); it != plugLoopTokens->end(); it++) {
- loopTokens.insert(pair<string,vector<map<string,string> > >(it->first, it->second));
- }
- isPluginTextView = true;
-}
-
-void cDisplayMenuDetailView::Clear(void) {
- ClearViewElement(veDetailHeader);
- ClearViewElement(veScrollbar);
- ClearViewElement(veTabLabels);
-}
-
-void cDisplayMenuDetailView::Render(void) {
- if (detailViewInit) {
- DrawHeader();
- DoFlush();
- SetTokens();
- InitTabs();
- currentTmplTab = *atIt;
- detailViewInit = false;
- }
- if (!tabView) {
- tabView = new cDisplayMenuTabView(currentTmplTab);
- tabView->SetTokens(&intTokens, &stringTokens, &loopTokens);
- tabView->CreateTab();
- tabView->Start();
- }
- DrawScrollbar();
- DrawTabLabels();
-}
-
-void cDisplayMenuDetailView::KeyLeft(void) {
- if (activeTabs.size() > 1) {
- currentTmplTab = GetPrevTab();
- delete tabView;
- tabView = NULL;
- Render();
- DoFlush();
- } else {
- bool scrolled = tabView->KeyLeft();
- if (scrolled) {
- DrawScrollbar();
- DoFlush();
- }
- }
-}
-
-void cDisplayMenuDetailView::KeyRight(void) {
- if (activeTabs.size() > 1) {
- currentTmplTab = GetNextTab();
- delete tabView;
- tabView = NULL;
- Render();
- DoFlush();
- } else {
- bool scrolled = tabView->KeyRight();
- if (scrolled) {
- DrawScrollbar();
- DoFlush();
- }
- }
-}
-
-void cDisplayMenuDetailView::KeyUp(void) {
- if (!tabView)
- return;
- bool scrolled = tabView->KeyUp();
- if (scrolled) {
- DrawScrollbar();
- DoFlush();
- }
-}
-
-void cDisplayMenuDetailView::KeyDown(void) {
- if (!tabView)
- return;
- bool scrolled = tabView->KeyDown();
- if (scrolled) {
- DrawScrollbar();
- DoFlush();
- }
-}
-
-
-void cDisplayMenuDetailView::SetTokens(void) {
- if (event) {
- stringTokens.insert(pair<string,string>("title", event->Title() ? event->Title() : ""));
- stringTokens.insert(pair<string,string>("shorttext", event->ShortText() ? event->ShortText() : ""));
- stringTokens.insert(pair<string,string>("description", event->Description() ? event->Description() : ""));
- stringTokens.insert(pair<string,string>("start", *(event->GetTimeString())));
- stringTokens.insert(pair<string,string>("stop", *(event->GetEndTimeString())));
- time_t startTime = event->StartTime();
- stringTokens.insert(pair<string,string>("day", *WeekDayName(startTime)));
- stringTokens.insert(pair<string,string>("date", *ShortDateString(startTime)));
- struct tm * sStartTime = localtime(&startTime);
- intTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- intTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
-
- string channelID = *(event->ChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
-
- bool isRunning = false;
- time_t now = time(NULL);
- if ((now >= event->StartTime()) && (now <= event->EndTime()))
- isRunning = true;
- intTokens.insert(pair<string,int>("running", isRunning));
- if (isRunning) {
- intTokens.insert(pair<string,int>("elapsed", (now - event->StartTime())/60));
- } else {
- intTokens.insert(pair<string,int>("elapsed", 0));
- }
- 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)));
- if (event->Vps())
- stringTokens.insert(pair<string,string>("vps", *event->GetVpsString()));
- else
- stringTokens.insert(pair<string,string>("vps", ""));
-
- vector< map< string, string > > reruns;
- bool hasReruns = LoadReruns(&reruns);
- loopTokens.insert(pair<string, vector< map< string, string > > >("reruns", reruns));
-
- intTokens.insert(pair<string,int>("hasreruns", hasReruns));
-
- SetScraperTokens(event, recording, stringTokens, intTokens, loopTokens);
- SetEpgPictures(event->EventID());
-
- } else if (recording) {
- string name = recording->Name() ? recording->Name() : "";
- stringTokens.insert(pair<string,string>("name", name));
- intTokens.insert(pair<string,int>("cutted", recording->IsEdited()));
-
- const cRecordingInfo *info = recording->Info();
- if (info) {
- stringTokens.insert(pair<string,string>("epgname", info->Title() ? info->Title() : name));
- stringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : ""));
- stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : ""));
- const cEvent *event = info->GetEvent();
- if (event) {
- string recDate = *(event->GetDateString());
- string recTime = *(event->GetTimeString());
- if (recDate.find("1970") != string::npos) {
- time_t start = recording->Start();
- recDate = *DateString(start);
- recTime = *TimeString(start);
- }
- stringTokens.insert(pair<string,string>("date", recDate.c_str()));
- stringTokens.insert(pair<string,string>("time", recTime.c_str()));
- time_t startTime = event->StartTime();
- struct tm * sStartTime = localtime(&startTime);
- intTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- intTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
- int duration = event->Duration() / 60;
- int recDuration = recording->LengthInSeconds();
- recDuration = (recDuration>0)?(recDuration / 60):0;
- intTokens.insert(pair<string,int>("duration", recDuration));
- intTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- intTokens.insert(pair<string,int>("durationevent", duration));
- intTokens.insert(pair<string,int>("durationeventhours", duration / 60));
- stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
- }
- } else {
- stringTokens.insert(pair<string,string>("epgname", ""));
- stringTokens.insert(pair<string,string>("shorttext", ""));
- stringTokens.insert(pair<string,string>("description", ""));
- int recDuration = recording->LengthInSeconds();
- recDuration = (recDuration>0)?(recDuration / 60):0;
- stringTokens.insert(pair<string,string>("date", ""));
- stringTokens.insert(pair<string,string>("time", ""));
- intTokens.insert(pair<string,int>("duration", recDuration));
- intTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- intTokens.insert(pair<string,int>("durationevent", 0));
- intTokens.insert(pair<string,int>("durationeventhours", 0));
- stringTokens.insert(pair<string,string>("durationeventminutes", ""));
- }
- LoadRecordingInformation();
- SetScraperTokens(event, recording, stringTokens, intTokens, loopTokens);
- SetRecordingImages(recording->FileName());
- } else if (text) {
- stringTokens.insert(pair<string,string>("text", text));
- } else {
- intTokens.insert(pair<string,int>("running", false));
- intTokens.insert(pair<string,int>("hasreruns", false));
- }
-}
-
-void cDisplayMenuDetailView::InitTabs(void) {
- tmplView->InitViewTabIterator();
- cTemplateViewTab *tmplTab = NULL;
- while(tmplTab = tmplView->GetNextViewTab()) {
- tmplTab->ParseDynamicParameters(&stringTokens, &intTokens, true);
- tmplTab->ClearDynamicFunctionParameters();
- tmplTab->ParseDynamicFunctionParameters(&stringTokens, &intTokens, &loopTokens);
- if (tmplTab->DoExecute()) {
- activeTabs.push_back(tmplTab);
- }
- }
- atIt = activeTabs.begin();
-}
-
-bool cDisplayMenuDetailView::LoadReruns(vector< map< string, string > > *reruns) {
- if (!event)
- return false;
-
- cPlugin *epgSearchPlugin = cPluginManager::GetPlugin("epgsearch");
- if (!epgSearchPlugin)
- return false;
-
- if (isempty(event->Title()))
- return false;
-
- int maxNumReruns = config.rerunAmount;
- int rerunDistance = config.rerunDistance * 3600;
- int rerunNaxChannel = config.rerunMaxChannel;
-
- Epgsearch_searchresults_v1_0 data;
- string strQuery = (event->Title()) ? event->Title() : "";
- data.query = (char *)strQuery.c_str();
- data.mode = 0;
- data.channelNr = 0;
- data.useTitle = true;
- data.useSubTitle = true;
- data.useDescription = false;
-
- bool foundRerun = false;
- if (epgSearchPlugin->Service("Epgsearch-searchresults-v1.0", &data)) {
- cList<Epgsearch_searchresults_v1_0::cServiceSearchResult>* list = data.pResultList;
- if (list && (list->Count() > 1)) {
- foundRerun = true;
- int i = 0;
- for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = list->First(); r && i < maxNumReruns; r = list->Next(r)) {
- time_t eventStart = event->StartTime();
- time_t rerunStart = r->event->StartTime();
- cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true);
- //check for identical event
- if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart))
- continue;
- //check for timely distance
- if (rerunDistance > 0) {
- if (rerunStart - eventStart < rerunDistance) {
- continue;
- }
- }
- //check for maxchannel
- if (rerunNaxChannel > 0) {
- if (channel && channel->Number() > rerunNaxChannel) {
- continue;
- }
- }
- i++;
- map< string, string > rerun;
- rerun.insert(pair<string, string>("reruns[title]", r->event->Title() ? r->event->Title() : ""));
- rerun.insert(pair<string, string>("reruns[shorttext]", r->event->ShortText() ? r->event->ShortText() : ""));
- rerun.insert(pair<string, string>("reruns[start]", *(r->event->GetTimeString())));
- rerun.insert(pair<string, string>("reruns[start]", *(r->event->GetTimeString())));
- rerun.insert(pair<string, string>("reruns[stop]", *(r->event->GetEndTimeString())));
- rerun.insert(pair<string, string>("reruns[date]", *ShortDateString(r->event->StartTime())));
- rerun.insert(pair<string, string>("reruns[day]", *WeekDayName(r->event->StartTime())));
- string channelID = *(r->event->ChannelID().ToString());
- rerun.insert(pair<string, string>("reruns[channelid]", channelID));
- bool logoExists = imgCache->LogoExists(channelID);
- rerun.insert(pair<string, string>("reruns[channellogoexists]", logoExists ? "1" : "0"));
-
- if (channel) {
- stringstream channelNumber;
- channelNumber << channel->Number();
- rerun.insert(pair<string, string>("reruns[channelname]", channel->ShortName(true)));
- rerun.insert(pair<string, string>("reruns[channelnumber]", channelNumber.str()));
- } else {
- rerun.insert(pair<string, string>("reruns[channelname]", ""));
- rerun.insert(pair<string, string>("reruns[channelnumber]", ""));
- }
- reruns->push_back(rerun);
- }
- delete list;
- }
- }
- return foundRerun;
-}
-
-void cDisplayMenuDetailView::LoadRecordingInformation(void) {
- const cRecordingInfo *Info = recording->Info();
- if (!Info)
- return;
- unsigned long long nRecSize = -1;
- unsigned long long nFileSize[1000];
- nFileSize[0] = 0;
- int i = 0;
- struct stat filebuf;
- cString filename;
- int rc = 0;
- do {
- if (recording->IsPesRecording())
- filename = cString::sprintf("%s/%03d.vdr", recording->FileName(), ++i);
- else
- filename = cString::sprintf("%s/%05d.ts", recording->FileName(), ++i);
- rc = stat(filename, &filebuf);
- if (rc == 0)
- nFileSize[i] = nFileSize[i-1] + filebuf.st_size;
- else
- if (ENOENT != errno) {
- nRecSize = -1;
- }
- } while (i <= 999 && !rc);
- nRecSize = nFileSize[i-1];
-
- cMarks marks;
- bool fHasMarks = marks.Load(recording->FileName(), recording->FramesPerSecond(), recording->IsPesRecording()) && marks.Count();
- cIndexFile *index = new cIndexFile(recording->FileName(), false, recording->IsPesRecording());
-
- int nCutLength = 0;
- long nCutInFrame = 0;
- unsigned long long nRecSizeCut = nRecSize < 0 ? -1 : 0;
- unsigned long long nCutInOffset = 0;
-
- if (fHasMarks && index) {
- uint16_t FileNumber;
- off_t FileOffset;
-
- bool fCutIn = true;
- cMark *mark = marks.First();
- while (mark) {
- int pos = mark->Position();
- index->Get(pos, &FileNumber, &FileOffset); //TODO: will disc spin up?
- if (fCutIn) {
- nCutInFrame = pos;
- fCutIn = false;
- if (nRecSize >= 0)
- nCutInOffset = nFileSize[FileNumber-1] + FileOffset;
- } else {
- nCutLength += pos - nCutInFrame;
- fCutIn = true;
- if (nRecSize >= 0)
- nRecSizeCut += nFileSize[FileNumber-1] + FileOffset - nCutInOffset;
- }
- cMark *nextmark = marks.Next(mark);
- mark = nextmark;
- }
- if (!fCutIn) {
- nCutLength += index->Last() - nCutInFrame;
- index->Get(index->Last() - 1, &FileNumber, &FileOffset);
- if (nRecSize >= 0)
- nRecSizeCut += nFileSize[FileNumber-1] + FileOffset - nCutInOffset;
- }
- }
-
- if (nRecSize < 0) {
- if ((nRecSize = ReadSizeVdr(recording->FileName())) < 0) {
- nRecSize = DirSizeMB(recording->FileName());
- }
- }
- if (nRecSize >= 0) {
- cString strRecSize = "";
- cString strRecSizeCut = "";
-
- if (fHasMarks) {
- if (nRecSize > MEGABYTE(1023)) {
- strRecSize = cString::sprintf("%.2f GB", (float)nRecSize / MEGABYTE(1024));
- strRecSizeCut = cString::sprintf("%.2f GB", (float)nRecSizeCut / MEGABYTE(1024));
- } else {
- strRecSize = cString::sprintf("%lld MB", nRecSize / MEGABYTE(1));
- strRecSizeCut = cString::sprintf("%lld MB", nRecSizeCut / MEGABYTE(1));
- }
- } else {
- if (nRecSize > MEGABYTE(1023)) {
- strRecSize = cString::sprintf("%.2f GB", (float)nRecSize / MEGABYTE(1024));
- strRecSizeCut = strRecSize;
- } else {
- strRecSize = cString::sprintf("%lld MB", nRecSize / MEGABYTE(1));
- strRecSizeCut = strRecSize;
- }
- }
- stringTokens.insert(pair<string,string>("recordingsize", *strRecSize));
- stringTokens.insert(pair<string,string>("recordingsizecutted", *strRecSizeCut));
- } else {
- stringTokens.insert(pair<string,string>("recordingsize", ""));
- stringTokens.insert(pair<string,string>("recordingsizecutted", ""));
- }
-
- cChannel *channel = Channels.GetByChannelID(Info->ChannelID());
- if (channel) {
- stringTokens.insert(pair<string,string>("recchannelname", channel->Name()));
- stringTokens.insert(pair<string,string>("recchannelid", *channel->GetChannelID().ToString()));
- intTokens.insert(pair<string,int>("recchannelnumber", channel->Number()));
- } else {
- stringTokens.insert(pair<string,string>("recchannelname", ""));
- stringTokens.insert(pair<string,string>("recchannelid", ""));
- intTokens.insert(pair<string,int>("recchannelnumber", 0));
- }
-
- if (index) {
- int nLastIndex = index->Last();
- if (nLastIndex) {
- string strLength = *IndexToHMSF(nLastIndex, false, recording->FramesPerSecond());
- string strLengthCutted = "";
- if (fHasMarks) {
- strLengthCutted = *IndexToHMSF(nCutLength, false, recording->FramesPerSecond());
- } else {
- strLengthCutted = strLength;
- }
- string strBitrate = *cString::sprintf("%.2f MBit/s", (float)nRecSize / nLastIndex * recording->FramesPerSecond() * 8 / MEGABYTE(1));
- stringTokens.insert(pair<string,string>("recordinglength", strLength));
- stringTokens.insert(pair<string,string>("recordinglengthcutted", strLengthCutted));
- stringTokens.insert(pair<string,string>("recordingbitrate", strBitrate));
- }
- delete index;
- }
-
- string recFormat = recording->IsPesRecording() ? "PES" : "TS";
- stringTokens.insert(pair<string,string>("recordingformat", recFormat));
-
- bool searchTimerFound = false;
- if (Info) {
- const char *aux = NULL;
- aux = Info->Aux();
- if (aux) {
- string strAux = aux;
- string auxEpgsearch = StripXmlTag(strAux, "epgsearch");
- if (!auxEpgsearch.empty()) {
- string searchTimer = StripXmlTag(auxEpgsearch, "searchtimer");
- if (!searchTimer.empty()) {
- stringTokens.insert(pair<string,string>("searchtimer", searchTimer));
- searchTimerFound = true;
- }
- }
- }
- }
- if (!searchTimerFound)
- stringTokens.insert(pair<string,string>("searchtimer", "n.a."));
-}
-
-string cDisplayMenuDetailView::StripXmlTag(string &Line, const char *Tag) {
- // set the search strings
- stringstream strStart, strStop;
- strStart << "<" << Tag << ">";
- strStop << "</" << Tag << ">";
- // find the strings
- string::size_type locStart = Line.find(strStart.str());
- string::size_type locStop = Line.find(strStop.str());
- if (locStart == string::npos || locStop == string::npos)
- return "";
- // extract relevant text
- int pos = locStart + strStart.str().size();
- int len = locStop - pos;
- return len < 0 ? "" : Line.substr(pos, len);
-}
-
-
-int cDisplayMenuDetailView::ReadSizeVdr(const char *strPath) {
- int dirSize = -1;
- char buffer[20];
- char *strFilename = NULL;
- if (-1 != asprintf(&strFilename, "%s/size.vdr", strPath)) {
- struct stat st;
- if (stat(strFilename, &st) == 0) {
- int fd = open(strFilename, O_RDONLY);
- if (fd >= 0) {
- if (safe_read(fd, &buffer, sizeof(buffer)) >= 0) {
- dirSize = atoi(buffer);
- }
- close(fd);
- }
- }
- free(strFilename);
- }
- return dirSize;
-}
-
-void cDisplayMenuDetailView::SetEpgPictures(int eventId) {
- for (int i=0; i<3; i++) {
- stringstream picName;
- picName << eventId << "_" << i;
- bool epgPicAvailable = FileExists(*config.epgImagePath, picName.str(), "jpg");
- stringstream available;
- stringstream path;
- available << "epgpic" << i+1 << "avaialble";
- path << "epgpic" << i+1 << "path";
- if (epgPicAvailable) {
- intTokens.insert(pair<string,int>(available.str(), true));
- stringTokens.insert(pair<string,string>(path.str(), *cString::sprintf("%s%s.jpg", *config.epgImagePath, picName.str().c_str())));
- } else {
- intTokens.insert(pair<string,int>(available.str(), false));
- stringTokens.insert(pair<string,string>(path.str(), ""));
- }
- }
-}
-
-void cDisplayMenuDetailView::SetRecordingImages(const char *recPath) {
- if (!recPath) {
- intTokens.insert(pair<string,int>("recimg1avaialble", false));
- intTokens.insert(pair<string,int>("recimg2avaialble", false));
- intTokens.insert(pair<string,int>("recimg3avaialble", false));
- stringTokens.insert(pair<string,string>("recimg1path", ""));
- stringTokens.insert(pair<string,string>("recimg2path", ""));
- stringTokens.insert(pair<string,string>("recimg3path", ""));
- return;
- }
-
- string path = recPath;
- DIR *dirHandle;
- struct dirent *dirEntry;
- dirHandle = opendir(recPath);
- if (!dirHandle) {
- intTokens.insert(pair<string,int>("recimg1avaialble", false));
- intTokens.insert(pair<string,int>("recimg2avaialble", false));
- intTokens.insert(pair<string,int>("recimg3avaialble", false));
- stringTokens.insert(pair<string,string>("recimg1path", ""));
- stringTokens.insert(pair<string,string>("recimg2path", ""));
- stringTokens.insert(pair<string,string>("recimg3path", ""));
- return;
- }
-
- int picsFound = 0;
- while ( 0 != (dirEntry = readdir(dirHandle))) {
- if (endswith(dirEntry->d_name, "jpg")) {
- string fileName = dirEntry->d_name;
- stringstream available;
- available << "recimg" << picsFound+1 << "avaialble";
- stringstream path;
- path << "recimg" << picsFound+1 << "path";
- intTokens.insert(pair<string,int>(available.str(), true));
- stringTokens.insert(pair<string,string>(path.str(), *cString::sprintf("%s/%s", recPath, fileName.c_str())));
- picsFound++;
- }
- if (picsFound == 3) {
- break;
- }
- }
- for (int i=picsFound; i<3; i++) {
- stringstream available;
- available << "recimg" << i+1 << "avaialble";
- stringstream path;
- path << "recimg" << i+1 << "path";
- intTokens.insert(pair<string,int>(available.str(), false));
- stringTokens.insert(pair<string,string>(path.str(), ""));
- }
- closedir(dirHandle);
-}
-
-void cDisplayMenuDetailView::DrawHeader(void) {
- map < string, string > headerStringTokens;
- map < string, int > headerIntTokens;
-
- if (event || recording) {
- static cPlugin *pScraper = GetScraperPlugin();
- if (!pScraper) {
- headerIntTokens.insert(pair<string,int>("ismovie", false));
- headerIntTokens.insert(pair<string,int>("isseries", false));
- headerIntTokens.insert(pair<string,int>("posteravailable", false));
- headerIntTokens.insert(pair<string,int>("banneravailable", false));
- } else {
- ScraperGetEventType getType;
- getType.event = event;
- getType.recording = recording;
- if (!pScraper->Service("GetEventType", &getType)) {
- headerIntTokens.insert(pair<string,int>("ismovie", false));
- headerIntTokens.insert(pair<string,int>("isseries", false));
- headerIntTokens.insert(pair<string,int>("posteravailable", false));
- headerIntTokens.insert(pair<string,int>("banneravailable", false));
- } else {
- if (getType.type == tMovie) {
- cMovie movie;
- movie.movieId = getType.movieId;
- pScraper->Service("GetMovie", &movie);
- headerIntTokens.insert(pair<string,int>("ismovie", true));
- headerIntTokens.insert(pair<string,int>("isseries", false));
- headerIntTokens.insert(pair<string,int>("posteravailable", true));
- headerIntTokens.insert(pair<string,int>("banneravailable", false));
- headerStringTokens.insert(pair<string,string>("posterpath", movie.poster.path));
- headerIntTokens.insert(pair<string,int>("posterwidth", movie.poster.width));
- headerIntTokens.insert(pair<string,int>("posterheight", movie.poster.height));
- } else if (getType.type == tSeries) {
- cSeries series;
- series.seriesId = getType.seriesId;
- series.episodeId = getType.episodeId;
- pScraper->Service("GetSeries", &series);
- headerIntTokens.insert(pair<string,int>("ismovie", false));
- headerIntTokens.insert(pair<string,int>("isseries", true));
- vector<cTvMedia>::iterator poster = series.posters.begin();
- if (poster != series.posters.end()) {
- headerIntTokens.insert(pair<string,int>("posterwidth", (*poster).width));
- headerIntTokens.insert(pair<string,int>("posterheight", (*poster).height));
- headerStringTokens.insert(pair<string,string>("posterpath", (*poster).path));
- headerIntTokens.insert(pair<string,int>("posteravailable", true));
- } else {
- headerIntTokens.insert(pair<string,int>("posterwidth", 0));
- headerIntTokens.insert(pair<string,int>("posterheight", 0));
- headerStringTokens.insert(pair<string,string>("posterpath", ""));
- headerIntTokens.insert(pair<string,int>("posteravailable", false));
- }
- vector<cTvMedia>::iterator banner = series.banners.begin();
- if (banner != series.banners.end()) {
- headerIntTokens.insert(pair<string,int>("bannerwidth", (*banner).width));
- headerIntTokens.insert(pair<string,int>("bannerheight", (*banner).height));
- headerStringTokens.insert(pair<string,string>("bannerpath", (*banner).path));
- headerIntTokens.insert(pair<string,int>("banneravailable", true));
- } else {
- headerIntTokens.insert(pair<string,int>("bannerwidth", 0));
- headerIntTokens.insert(pair<string,int>("bannerheight", 0));
- headerStringTokens.insert(pair<string,string>("bannerpath", ""));
- headerIntTokens.insert(pair<string,int>("banneravailable", false));
- }
- } else {
- headerIntTokens.insert(pair<string,int>("ismovie", false));
- headerIntTokens.insert(pair<string,int>("isseries", false));
- headerIntTokens.insert(pair<string,int>("posteravailable", false));
- headerIntTokens.insert(pair<string,int>("banneravailable", false));
- }
- }
- }
- }
-
- if (event) {
- headerStringTokens.insert(pair<string,string>("title", event->Title() ? event->Title() : ""));
- headerStringTokens.insert(pair<string,string>("shorttext", event->ShortText() ? event->ShortText() : ""));
- headerStringTokens.insert(pair<string,string>("start", *(event->GetTimeString())));
- headerStringTokens.insert(pair<string,string>("stop", *(event->GetEndTimeString())));
-
- time_t startTime = event->StartTime();
- headerStringTokens.insert(pair<string,string>("day", *WeekDayName(startTime)));
- headerStringTokens.insert(pair<string,string>("date", *ShortDateString(startTime)));
- struct tm * sStartTime = localtime(&startTime);
- headerIntTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- headerIntTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- headerIntTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
-
- const cChannel *channel = Channels.GetByChannelID(event->ChannelID());
- if (channel) {
- headerStringTokens.insert(pair<string,string>("channelname", channel->Name() ? channel->Name() : ""));
- headerIntTokens.insert(pair<string, int>("channelnumber", channel->Number()));
- } else {
- headerStringTokens.insert(pair<string,string>("channelname", ""));
- headerIntTokens.insert(pair<string, int>("channelnumber", 0));
- }
- string channelID = *(channel->GetChannelID().ToString());
- headerStringTokens.insert(pair<string,string>("channelid", channelID));
- headerIntTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
-
- bool isRunning = false;
- time_t now = time(NULL);
- if ((now >= event->StartTime()) && (now <= event->EndTime()))
- isRunning = true;
- headerIntTokens.insert(pair<string,int>("running", isRunning));
- if (isRunning) {
- headerIntTokens.insert(pair<string,int>("elapsed", (now - event->StartTime())/60));
- } else {
- headerIntTokens.insert(pair<string,int>("elapsed", 0));
- }
- headerIntTokens.insert(pair<string,int>("duration", event->Duration() / 60));
- headerIntTokens.insert(pair<string,int>("durationhours", event->Duration() / 3600));
- headerStringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", (event->Duration() / 60)%60)));
- if (event->Vps())
- headerStringTokens.insert(pair<string,string>("vps", *event->GetVpsString()));
- else
- headerStringTokens.insert(pair<string,string>("vps", ""));
-
- stringstream epgImageName;
- epgImageName << event->EventID();
- bool epgPicAvailable = FileExists(*config.epgImagePath, epgImageName.str(), "jpg");
- if (epgPicAvailable) {
- headerIntTokens.insert(pair<string,int>("epgpicavailable", true));
- headerStringTokens.insert(pair<string,string>("epgpicpath", *cString::sprintf("%s%s.jpg", *config.epgImagePath, epgImageName.str().c_str())));
- } else {
- epgImageName << "_0";
- epgPicAvailable = FileExists(*config.epgImagePath, epgImageName.str(), "jpg");
- if (epgPicAvailable) {
- headerIntTokens.insert(pair<string,int>("epgpicavailable", true));
- headerStringTokens.insert(pair<string,string>("epgpicpath", *cString::sprintf("%s%s.jpg", *config.epgImagePath, epgImageName.str().c_str())));
- } else {
- headerIntTokens.insert(pair<string,int>("epgpicavailable", false));
- headerStringTokens.insert(pair<string,string>("epgpicpath", ""));
- }
- }
-
- DrawViewElement(veDetailHeader, &headerStringTokens, &headerIntTokens);
- return;
- } else if (recording) {
- string name = recording->Name() ? recording->Name() : "";
- headerStringTokens.insert(pair<string,string>("name", name));
-
- const cRecordingInfo *info = recording->Info();
- if (info) {
- headerStringTokens.insert(pair<string,string>("epgname", info->Title() ? info->Title() : name));
- headerStringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : ""));
- const cEvent *event = info->GetEvent();
- if (event) {
- string recDate = *(event->GetDateString());
- string recTime = *(event->GetTimeString());
- if (recDate.find("1970") != string::npos) {
- time_t start = recording->Start();
- recDate = *DateString(start);
- recTime = *TimeString(start);
- }
- int duration = event->Duration() / 60;
- int recDuration = recording->LengthInSeconds();
- recDuration = (recDuration>0)?(recDuration / 60):0;
- headerStringTokens.insert(pair<string,string>("date", recDate.c_str()));
- headerStringTokens.insert(pair<string,string>("time", recTime.c_str()));
- time_t startTime = event->StartTime();
- struct tm * sStartTime = localtime(&startTime);
- headerIntTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- headerIntTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- headerIntTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
- headerIntTokens.insert(pair<string,int>("duration", recDuration));
- headerIntTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- headerStringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- headerIntTokens.insert(pair<string,int>("durationevent", duration));
- headerIntTokens.insert(pair<string,int>("durationeventhours", duration / 60));
- headerStringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
- }
- cChannel *channel = Channels.GetByChannelID(info->ChannelID());
- if (channel) {
- headerStringTokens.insert(pair<string,string>("recchannelname", channel->Name()));
- headerStringTokens.insert(pair<string,string>("recchannelid", *channel->GetChannelID().ToString()));
- headerIntTokens.insert(pair<string,int>("recchannelnumber", channel->Number()));
- } else {
- headerStringTokens.insert(pair<string,string>("recchannelname", ""));
- headerStringTokens.insert(pair<string,string>("recchannelid", ""));
- headerIntTokens.insert(pair<string,int>("recchannelnumber", 0));
- }
- } else {
- headerStringTokens.insert(pair<string,string>("shorttext", ""));
- int recDuration = recording->LengthInSeconds();
- recDuration = (recDuration>0)?(recDuration / 60):0;
- headerStringTokens.insert(pair<string,string>("date", ""));
- headerStringTokens.insert(pair<string,string>("time", ""));
- headerIntTokens.insert(pair<string,int>("duration", recDuration));
- headerIntTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- headerStringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- headerIntTokens.insert(pair<string,int>("durationevent", 0));
- headerIntTokens.insert(pair<string,int>("durationeventhours", 0));
- headerStringTokens.insert(pair<string,string>("durationeventminutes", ""));
- headerStringTokens.insert(pair<string,string>("recchannelname", ""));
- headerStringTokens.insert(pair<string,string>("recchannelid", ""));
- headerIntTokens.insert(pair<string,int>("recchannelnumber", 0));
- }
-
- string recImage = "";
- string path = recording->FileName() ? recording->FileName() : "";
- string extension = ".jpg";
- if (FirstFileInFolder(path, extension, recImage)) {
- headerIntTokens.insert(pair<string,int>("recimgavailable", true));
- headerStringTokens.insert(pair<string,string>("recimgpath", *cString::sprintf("%s/%s", path.c_str(), recImage.c_str())));
- } else {
- headerIntTokens.insert(pair<string,int>("recimgavailable", false));
- headerStringTokens.insert(pair<string,string>("recimgpath", ""));
- }
- DrawViewElement(veDetailHeader, &headerStringTokens, &headerIntTokens);
- return;
- }
-
- if (isPluginTextView) {
- DrawViewElement(veDetailHeader, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayMenuDetailView::DrawScrollbar(void) {
- map < string, string > scrollbarStringTokens;
- map < string, int > scrollbarIntTokens;
-
- int barTop = 0;
- int barHeight = 0;
- tabView->GetScrollbarPosition(barTop, barHeight);
-
- scrollbarIntTokens.insert(pair<string,int>("height", barHeight));
- scrollbarIntTokens.insert(pair<string,int>("offset", barTop));
- ClearViewElement(veScrollbar);
- DrawViewElement(veScrollbar, &scrollbarStringTokens, &scrollbarIntTokens);
-}
-
-void cDisplayMenuDetailView::DrawTabLabels(void) {
- if (!ExecuteViewElement(veTabLabels)) {
- return;
- }
- map < string, string > labelStringTokens;
- map < string, int > labelIntTokens;
- map < string, vector< map< string, string > > > labelLoopTokens;
-
- string labelPrev = "";
- string labelPrevTemp = "";
- string labelCurrent = "";
- string labelNext = "";
- bool wasCurrent = false;
- vector< map< string, string > > tabLabels;
- for (list<cTemplateViewTab*>::iterator it = activeTabs.begin(); it != activeTabs.end(); it++) {
- cTemplateViewTab *tab = *it;
- map< string, string > tabLabel;
- tabLabel.insert(pair< string, string >("tabs[title]", tab->GetName()));
- if (wasCurrent) {
- labelNext = tab->GetName();
- }
- if (tab == currentTmplTab) {
- wasCurrent = true;
- labelCurrent = tab->GetName();
- labelPrev = labelPrevTemp;
- tabLabel.insert(pair< string, string >("tabs[current]", "1"));
- } else {
- wasCurrent = false;
- tabLabel.insert(pair< string, string >("tabs[current]", "0"));
- }
- labelPrevTemp = tab->GetName();
- tabLabels.push_back(tabLabel);
- }
- if (labelNext.size() == 0 && activeTabs.size() > 0) {
- cTemplateViewTab *firstTab = activeTabs.front();
- labelNext = firstTab->GetName();
- }
- if (labelPrev.size() == 0 && activeTabs.size() > 0) {
- cTemplateViewTab *lastTab = activeTabs.back();
- labelPrev = lastTab->GetName();
- }
- labelStringTokens.insert(pair< string, string >("currenttab", labelCurrent));
- labelStringTokens.insert(pair< string, string >("nexttab", labelNext));
- labelStringTokens.insert(pair< string, string >("prevtab", labelPrev));
- labelLoopTokens.insert(pair< string, vector< map< string, string > > >("tabs", tabLabels));
-
- ClearViewElement(veTabLabels);
- DrawViewElement(veTabLabels, &labelStringTokens, &labelIntTokens, &labelLoopTokens);
-}
-
-cTemplateViewTab *cDisplayMenuDetailView::GetPrevTab(void) {
- if (atIt == activeTabs.begin()) {
- atIt = activeTabs.end();
- }
- atIt--;
- return *atIt;
-}
-
-cTemplateViewTab *cDisplayMenuDetailView::GetNextTab(void) {
- atIt++;
- if (atIt == activeTabs.end()) {
- atIt = activeTabs.begin();
- }
- return *atIt;
-}
diff --git a/views/displaymenudetailview.h b/views/displaymenudetailview.h
deleted file mode 100644
index 1b43687..0000000
--- a/views/displaymenudetailview.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __DISPLAYMENUDETAILVIEW_H
-#define __DISPLAYMENUDETAILVIEW_H
-
-#include <list>
-#include "../libtemplate/template.h"
-#include "view.h"
-#include "viewhelpers.h"
-#include "displaymenutabview.h"
-
-class cDisplayMenuDetailView : public cView, public cViewHelpers {
-private:
- bool detailViewInit;
- bool isPluginTextView;
- const cEvent *event;
- const cRecording *recording;
- const char *text;
- cTemplateViewTab *currentTmplTab;
- list<cTemplateViewTab*> activeTabs;
- list<cTemplateViewTab*>::iterator atIt;
- cDisplayMenuTabView *tabView;
- map < string, string > stringTokens;
- map < string, int > intTokens;
- map < string, vector< map< string, string > > > loopTokens;
- void SetTokens(void);
- void InitTabs(void);
- bool LoadReruns(vector< map< string, string > > *reruns);
- void LoadRecordingInformation(void);
- void SetEpgPictures(int eventId);
- void SetRecordingImages(const char *recPath);
- string StripXmlTag(string &Line, const char *Tag);
- int ReadSizeVdr(const char *strPath);
- void DrawHeader(void);
- void DrawScrollbar(void);
- void DrawTabLabels(void);
- cTemplateViewTab *GetPrevTab(void);
- cTemplateViewTab *GetNextTab(void);
-public:
- cDisplayMenuDetailView(cTemplateView *tmplDetailView);
- virtual ~cDisplayMenuDetailView();
- void SetEvent(const cEvent *event) { this->event = event; };
- void SetRecording(const cRecording *recording) { this->recording = recording; };
- void SetText(const char *text) { this->text = text; };
- void SetPluginTokens(map<string,string> *plugStringTokens, map<string,int> *plugIntTokens, map<string,vector<map<string,string> > > *plugLoopTokens);
- void Clear(void);
- void Render(void);
- void KeyLeft(void);
- void KeyRight(void);
- void KeyUp(void);
- void KeyDown(void);
-};
-
-#endif //__DISPLAYMENUDETAILVIEW_H
diff --git a/views/displaymenuitemcurrentview.c b/views/displaymenuitemcurrentview.c
deleted file mode 100644
index 1b8d09e..0000000
--- a/views/displaymenuitemcurrentview.c
+++ /dev/null
@@ -1,636 +0,0 @@
-#include "../services/scraper2vdr.h"
-#include "../libcore/helpers.h"
-#include "../libcore/recfolderinfo.h"
-#include "../libcore/extrecinfo.h"
-#include "displaymenuitemcurrentview.h"
-
-
-cDisplayMenuItemCurrentView::cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent) : cViewElement(tmplCurrent) {
-}
-
-cDisplayMenuItemCurrentView::~cDisplayMenuItemCurrentView() {
-}
-
-void cDisplayMenuItemCurrentView::SetPosMenuItem(cRect &pos) {
- posMenuItem.SetX(pos.X());
- posMenuItem.SetY(pos.Y());
- posMenuItem.SetWidth(pos.Width());
- posMenuItem.SetHeight(pos.Height());
-}
-
-void cDisplayMenuItemCurrentView::SetTokensPosMenuItem(void) {
- intTokens.insert(pair<string,int>("menuitemx", posMenuItem.X()));
- intTokens.insert(pair<string,int>("menuitemy", posMenuItem.Y()));
- intTokens.insert(pair<string,int>("menuitemwidth", posMenuItem.Width()));
- intTokens.insert(pair<string,int>("menuitemheight", posMenuItem.Height()));
-}
-
-void cDisplayMenuItemCurrentView::SetScraperPoster(const cEvent *event, const cRecording *recording) {
- static cPlugin *pScraper = GetScraperPlugin();
- if (!pScraper || (!event && !recording)) {
- intTokens.insert(pair<string,int>("hasposter", false));
- intTokens.insert(pair<string,int>("posterwidth", -1));
- intTokens.insert(pair<string,int>("posterheight", -1));
- stringTokens.insert(pair<string,string>("posterpath", ""));
- intTokens.insert(pair<string,int>("hasbanner", false));
- intTokens.insert(pair<string,int>("bannerwidth", -1));
- intTokens.insert(pair<string,int>("bannerheight", -1));
- stringTokens.insert(pair<string,string>("bannerpath", ""));
- return;
- }
-
- ScraperGetEventType getType;
- getType.event = event;
- getType.recording = recording;
- if (!pScraper->Service("GetEventType", &getType)) {
- intTokens.insert(pair<string,int>("hasposter", false));
- intTokens.insert(pair<string,int>("posterwidth", -1));
- intTokens.insert(pair<string,int>("posterheight", -1));
- stringTokens.insert(pair<string,string>("posterpath", ""));
- intTokens.insert(pair<string,int>("hasbanner", false));
- intTokens.insert(pair<string,int>("bannerwidth", -1));
- intTokens.insert(pair<string,int>("bannerheight", -1));
- stringTokens.insert(pair<string,string>("bannerpath", ""));
- return;
- }
-
- if (getType.type == tMovie) {
- cMovie movie;
- movie.movieId = getType.movieId;
- pScraper->Service("GetMovie", &movie);
- intTokens.insert(pair<string,int>("hasposter", true));
- stringTokens.insert(pair<string,string>("posterpath", movie.poster.path));
- intTokens.insert(pair<string,int>("posterwidth", movie.poster.width));
- intTokens.insert(pair<string,int>("posterheight", movie.poster.height));
- intTokens.insert(pair<string,int>("hasbanner", false));
- intTokens.insert(pair<string,int>("bannerwidth", -1));
- intTokens.insert(pair<string,int>("bannerheight", -1));
- stringTokens.insert(pair<string,string>("bannerpath", ""));
- } else if (getType.type == tSeries) {
- cSeries series;
- series.seriesId = getType.seriesId;
- series.episodeId = getType.episodeId;
- pScraper->Service("GetSeries", &series);
- //Poster
- if (series.posters.size() > 0) {
- intTokens.insert(pair<string,int>("hasposter", true));
- intTokens.insert(pair<string,int>("posterwidth", series.posters[0].width));
- intTokens.insert(pair<string,int>("posterheight", series.posters[0].height));
- stringTokens.insert(pair<string,string>("posterpath", series.posters[0].path));
- } else {
- intTokens.insert(pair<string,int>("hasposter", false));
- intTokens.insert(pair<string,int>("posterwidth", -1));
- intTokens.insert(pair<string,int>("posterheight", -1));
- stringTokens.insert(pair<string,string>("posterpath", ""));
- }
-
- //Banners
- if (series.banners.size() > 0) {
- intTokens.insert(pair<string,int>("hasbanner", true));
- intTokens.insert(pair<string,int>("bannerwidth", series.banners[0].width));
- intTokens.insert(pair<string,int>("bannerheight", series.banners[0].height));
- stringTokens.insert(pair<string,string>("bannerpath", series.banners[0].path));
- } else {
- intTokens.insert(pair<string,int>("hasbanner", false));
- intTokens.insert(pair<string,int>("bannerwidth", -1));
- intTokens.insert(pair<string,int>("bannerheight", -1));
- stringTokens.insert(pair<string,string>("bannerpath", ""));
- }
- }
-}
-
-/*************************************************************
-* cDisplayMenuItemCurrentMainView
-*************************************************************/
-
-cDisplayMenuItemCurrentMainView::cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon)
- : cDisplayMenuItemCurrentView(tmplCurrent) {
- this->number = number;
- this->label = label;
- this->icon = icon;
-}
-
-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);
- return true;
-}
-
-/*************************************************************
-* cDisplayMenuItemCurrentSchedulesView
-*************************************************************/
-
-cDisplayMenuItemCurrentSchedulesView::cDisplayMenuItemCurrentSchedulesView(cTemplateViewElement *tmplCurrent, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav)
- : cDisplayMenuItemCurrentView(tmplCurrent) {
- this->event = event;
- this->channel = channel;
- this->timerMatch = timerMatch;
- this->cat = cat;
- this->isEpgSearchFav = isEpgSearchFav;
-}
-
-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));
- intTokens.insert(pair<string,int>("whatsonfavorites", isEpgSearchFav ? true: false));
- if (timerMatch == tmFull) {
- intTokens.insert(pair<string,int>("timerpartitial", false));
- intTokens.insert(pair<string,int>("timerfull", true));
- } else if (timerMatch == tmPartial) {
- intTokens.insert(pair<string,int>("timerpartitial", true));
- intTokens.insert(pair<string,int>("timerfull", false));
- } else {
- intTokens.insert(pair<string,int>("timerpartitial", false));
- intTokens.insert(pair<string,int>("timerfull", false));
- }
-
- if (event) {
- stringTokens.insert(pair<string,string>("title", event->Title() ? event->Title() : ""));
- stringTokens.insert(pair<string,string>("shorttext", event->ShortText() ? event->ShortText() : ""));
- stringTokens.insert(pair<string,string>("description", event->Description() ? event->Description() : ""));
- stringTokens.insert(pair<string,string>("start", *(event->GetTimeString())));
- stringTokens.insert(pair<string,string>("stop", *(event->GetEndTimeString())));
-
- time_t startTime = event->StartTime();
- stringTokens.insert(pair<string,string>("day", *WeekDayName(startTime)));
- stringTokens.insert(pair<string,string>("date", *ShortDateString(startTime)));
- struct tm * sStartTime = localtime(&startTime);
- intTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- intTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
-
- bool isRunning = false;
- time_t now = time(NULL);
- if ((now >= event->StartTime()) && (now <= event->EndTime()))
- isRunning = true;
- intTokens.insert(pair<string,int>("running", isRunning));
- if (isRunning) {
- intTokens.insert(pair<string,int>("elapsed", (now - event->StartTime())/60));
- } else {
- intTokens.insert(pair<string,int>("elapsed", 0));
- }
- 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)));
- SetScraperPoster(event);
- }
- if (channel) {
- stringTokens.insert(pair<string,string>("channelname", channel->Name() ? channel->Name() : ""));
- string channelID = *(channel->GetChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channelnumber", channel->Number()));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
- }
-
- vector< map<string,string> > schedulesTokens;
- if (cat == mcScheduleNow || cat == mcScheduleNext) {
- ReadSchedules(&schedulesTokens);
- }
- map < string, vector< map< string, string > > > loopTokens;
- loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens));
- SetTokensPosMenuItem();
- DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
- return true;
-}
-
-void cDisplayMenuItemCurrentSchedulesView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
- if (!event)
- return;
- const cSchedule *schedule = event->Schedule();
- const cEvent *curEvent = event;
- int num = 0;
- for (; curEvent; curEvent = schedule->Events()->Next(curEvent)) {
- if (num == 0) {
- num++;
- continue;
- }
- map<string,string> element;
- element.insert(pair<string,string>("schedule[start]", *(curEvent->GetTimeString())));
- element.insert(pair<string,string>("schedule[stop]", *(curEvent->GetEndTimeString())));
- element.insert(pair<string,string>("schedule[title]", curEvent->Title() ? curEvent->Title() : ""));
- element.insert(pair<string,string>("schedule[shorttext]", curEvent->ShortText() ? curEvent->ShortText() : ""));
- schedulesTokens->push_back(element);
- num++;
- if (num > 10)
- break;
- }
-}
-
-/*************************************************************
-* cDisplayMenuItemCurrentChannelView
-*************************************************************/
-
-cDisplayMenuItemCurrentChannelView::cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel)
- : cDisplayMenuItemCurrentView(tmplCurrent) {
- this->channel = channel;
-}
-
-bool cDisplayMenuItemCurrentChannelView::Render(void) {
- if (!channel)
- return false;
- //general channel information
- intTokens.insert(pair<string,int>("number", channel->Number()));
- intTokens.insert(pair<string,int>("transponder", channel->Transponder()));
- intTokens.insert(pair<string,int>("frequency", channel->Frequency()));
-
- stringTokens.insert(pair<string,string>("name", channel->Name() ? channel->Name() : ""));
- string channelID = *(channel->GetChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
-
- //Channel Source Information
- const cSource *source = Sources.Get(channel->Source());
- if (source) {
- stringTokens.insert(pair<string,string>("source", *cSource::ToString(source->Code())));
- stringTokens.insert(pair<string,string>("sourcedescription", source->Description() ? source->Description() : ""));
- stringTokens.insert(pair<string,string>("source", *cSource::ToString(source->Code())));
- intTokens.insert(pair<string,int>("isAtsc", source->IsAtsc(source->Code())));
- intTokens.insert(pair<string,int>("isCable", source->IsCable(source->Code())));
- intTokens.insert(pair<string,int>("isSat", source->IsSat(source->Code())));
- intTokens.insert(pair<string,int>("isTerr", source->IsTerr(source->Code())));
- }
-
- //current schedule
- cSchedulesLock schedulesLock;
- const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
- const cSchedule *schedule = NULL;
- schedule = schedules->GetSchedule(channel);
- if (schedule) {
- const cEvent *presentEvent = schedule->GetPresentEvent();
- if (presentEvent) {
- stringTokens.insert(pair<string,string>("presenteventtitle", presentEvent->Title() ? presentEvent->Title() : ""));
- stringTokens.insert(pair<string,string>("presenteventshorttext", presentEvent->ShortText() ? presentEvent->ShortText() : ""));
- stringTokens.insert(pair<string,string>("presenteventdescription", presentEvent->Description() ? presentEvent->Description() : ""));
- stringTokens.insert(pair<string,string>("presenteventstart", *presentEvent->GetTimeString()));
- stringTokens.insert(pair<string,string>("presenteventstop", *presentEvent->GetEndTimeString()));
- stringTokens.insert(pair<string,string>("presenteventday", *WeekDayName(presentEvent->StartTime())));
- stringTokens.insert(pair<string,string>("presenteventdate", *ShortDateString(presentEvent->StartTime())));
- intTokens.insert(pair<string,int>("presenteventelapsed", (time(0) - presentEvent->StartTime())/60));
- intTokens.insert(pair<string,int>("presenteventduration", presentEvent->Duration() / 60));
- intTokens.insert(pair<string,int>("presenteventdurationhours", presentEvent->Duration() / 3600));
- stringTokens.insert(pair<string,string>("presenteventdurationminutes", *cString::sprintf("%.2d", (presentEvent->Duration() / 60)%60)));
- SetScraperPoster(presentEvent);
- } else {
- stringTokens.insert(pair<string,string>("presenteventtitle", ""));
- stringTokens.insert(pair<string,string>("presenteventshorttext", ""));
- stringTokens.insert(pair<string,string>("presenteventdescription", ""));
- stringTokens.insert(pair<string,string>("presenteventstart", ""));
- stringTokens.insert(pair<string,string>("presenteventstop", ""));
- stringTokens.insert(pair<string,string>("presenteventday", ""));
- stringTokens.insert(pair<string,string>("presenteventdate", ""));
- intTokens.insert(pair<string,int>("presenteventelapsed", 0));
- intTokens.insert(pair<string,int>("presenteventduration", 0));
- intTokens.insert(pair<string,int>("presenteventdurationhours", 0));
- stringTokens.insert(pair<string,string>("presenteventdurationminutes", ""));
- }
- const cList<cEvent> *events = schedule->Events();
- bool inserted = false;
- if (events && presentEvent) {
- const cEvent *nextEvent = events->Next(presentEvent);
- if (nextEvent) {
- stringTokens.insert(pair<string,string>("nexteventtitle", nextEvent->Title() ? nextEvent->Title() : ""));
- stringTokens.insert(pair<string,string>("nexteventshorttext", nextEvent->ShortText() ? nextEvent->ShortText() : ""));
- stringTokens.insert(pair<string,string>("nexteventdescription", nextEvent->Description() ? nextEvent->Description() : ""));
- stringTokens.insert(pair<string,string>("nexteventstart", *nextEvent->GetTimeString()));
- stringTokens.insert(pair<string,string>("nexteventstop", *nextEvent->GetEndTimeString()));
- stringTokens.insert(pair<string,string>("nexteventday", *WeekDayName(nextEvent->StartTime())));
- stringTokens.insert(pair<string,string>("nexteventdate", *ShortDateString(nextEvent->StartTime())));
- intTokens.insert(pair<string,int>("nexteventduration", nextEvent->Duration() / 60));
- intTokens.insert(pair<string,int>("nexteventdurationhours", nextEvent->Duration() / 3600));
- stringTokens.insert(pair<string,string>("nexteventdurationminutes", *cString::sprintf("%.2d", (nextEvent->Duration() / 60)%60)));
- inserted = true;
- }
- }
- if (!inserted) {
- stringTokens.insert(pair<string,string>("nexteventtitle", ""));
- stringTokens.insert(pair<string,string>("nexteventshorttext", ""));
- stringTokens.insert(pair<string,string>("nexteventdescription", ""));
- stringTokens.insert(pair<string,string>("nexteventstart", ""));
- stringTokens.insert(pair<string,string>("nexteventstop", ""));
- stringTokens.insert(pair<string,string>("nexteventday", ""));
- stringTokens.insert(pair<string,string>("nexteventdate", ""));
- intTokens.insert(pair<string,int>("nexteventduration", 0));
- intTokens.insert(pair<string,int>("nexteventdurationhours", 0));
- stringTokens.insert(pair<string,string>("nexteventdurationminutes", ""));
- }
- }
-
- vector< map<string,string> > schedulesTokens;
- ReadSchedules(&schedulesTokens);
-
- map < string, vector< map< string, string > > > loopTokens;
- loopTokens.insert(pair<string, vector< map< string, string > > >("schedule", schedulesTokens));
- SetTokensPosMenuItem();
- DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
- return true;
-}
-
-void cDisplayMenuItemCurrentChannelView::ReadSchedules(vector< map<string,string> > *schedulesTokens) {
- cSchedulesLock schedulesLock;
- const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
- const cSchedule *schedule = NULL;
- schedule = schedules->GetSchedule(channel);
- if (!schedule) {
- return;
- }
- const cEvent *curEvent = schedule->GetPresentEvent();
- int num = 0;
- for (; curEvent; curEvent = schedule->Events()->Next(curEvent)) {
- if (num < 2) {
- num++;
- continue;
- }
- map<string,string> element;
- element.insert(pair<string,string>("schedule[start]", *(curEvent->GetTimeString())));
- element.insert(pair<string,string>("schedule[stop]", *(curEvent->GetEndTimeString())));
- element.insert(pair<string,string>("schedule[title]", curEvent->Title() ? curEvent->Title() : ""));
- element.insert(pair<string,string>("schedule[shorttext]", curEvent->ShortText() ? curEvent->ShortText() : ""));
- schedulesTokens->push_back(element);
- num++;
- if (num > 11)
- break;
- }
-}
-
-/*************************************************************
-* cDisplayMenuItemCurrentTimerView
-*************************************************************/
-
-cDisplayMenuItemCurrentTimerView::cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer)
- : cDisplayMenuItemCurrentView(tmplCurrent) {
- this->timer = timer;
-}
-
-bool cDisplayMenuItemCurrentTimerView::Render(void) {
- if (!timer)
- 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)));
- intTokens.insert(pair<string,int>("flagrecording", timer->Recording()));
- intTokens.insert(pair<string,int>("flagpending", timer->Pending()));
-
- 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();
- stringTokens.insert(pair<string,string>("title", file));
- stringTokens.insert(pair<string,string>("timerstart", *cString::sprintf("%02d:%02d", timer->Start() / 100, timer->Start() % 100)));
- stringTokens.insert(pair<string,string>("timerstop", *cString::sprintf("%02d:%02d", timer->Stop() / 100, timer->Stop() % 100)));
-
- string day = "";
- string dayName = "";
- if (timer->WeekDays())
- day = timer->PrintDay(0, timer->WeekDays(), false);
- else if (timer->Day() - time(NULL) < 28 * SECSINDAY) {
- day = itoa(timer->GetMDay(timer->Day()));
- dayName = WeekDayName(timer->Day());
- } else {
- struct tm tm_r;
- time_t Day = timer->Day();
- localtime_r(&Day, &tm_r);
- char buffer[16];
- strftime(buffer, sizeof(buffer), "%Y%m%d", &tm_r);
- day = buffer;
- }
-
- struct tm tm_r;
- time_t timerDate = timer->Day();
- localtime_r(&timerDate, &tm_r);
- char buffer[4];
- strftime(buffer, sizeof(buffer), "%m", &tm_r);
- int month = atoi(buffer);
- char buffer2[6];
- strftime(buffer2, sizeof(buffer2), "%b", &tm_r);
- string monthName = buffer2;
- char buffer3[6];
- strftime(buffer3, sizeof(buffer3), "%Y", &tm_r);
- int year = atoi(buffer3);
-
- stringTokens.insert(pair<string,string>("day", day));
- stringTokens.insert(pair<string,string>("dayname", dayName));
- intTokens.insert(pair<string,int>("month", month));
- stringTokens.insert(pair<string,string>("monthname", monthName));
- intTokens.insert(pair<string,int>("year", year));
-
- const cChannel *channel = timer->Channel();
- if (channel) {
- stringTokens.insert(pair<string,string>("channelname", channel->Name() ? channel->Name() : ""));
- string channelID = *(channel->GetChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
- intTokens.insert(pair<string,int>("channelnumber", channel->Number()));
- } else {
- stringTokens.insert(pair<string,string>("channelname", ""));
- stringTokens.insert(pair<string,string>("channelid", ""));
- intTokens.insert(pair<string, int>("channellogoexists", 0));
- intTokens.insert(pair<string,int>("channelnumber", 0));
- }
-
- const cEvent *event = timer->Event();
- if (event) {
- stringTokens.insert(pair<string,string>("eventtitle", event->Title() ? event->Title() : ""));
- stringTokens.insert(pair<string,string>("eventstart", *event->GetTimeString()));
- stringTokens.insert(pair<string,string>("eventstop", *event->GetEndTimeString()));
- stringTokens.insert(pair<string,string>("eventshorttext", event->ShortText() ? event->ShortText() : ""));
- stringTokens.insert(pair<string,string>("eventdescription", event->Description() ? event->Description() : ""));
- SetScraperPoster(event);
- } else {
- stringTokens.insert(pair<string,string>("eventtitle", ""));
- stringTokens.insert(pair<string,string>("eventstart", ""));
- stringTokens.insert(pair<string,string>("eventstop", ""));
- stringTokens.insert(pair<string,string>("eventshorttext", ""));
- stringTokens.insert(pair<string,string>("eventdescription", ""));
- }
- SetTokensPosMenuItem();
- DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens);
- return true;
-}
-
-/*************************************************************
-* cDisplayMenuItemCurrentRecordingView
-*************************************************************/
-
-cDisplayMenuItemCurrentRecordingView::cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs)
- : cDisplayMenuItemCurrentView(tmplCurrent) {
- this->recording = recording;
- this->level = level;
- this->total = total;
- this->newRecs = newRecs;
-}
-
-bool cDisplayMenuItemCurrentRecordingView::Render(void) {
- if (!recording)
- return false;
- map < string, vector< map< string, string > > > loopTokens;
-
- bool isFolder = (total > 0) ? true : false;
- intTokens.insert(pair<string,int>("folder", isFolder));
-
- string name = recording->Name() ? recording->Name() : "";
- string buffer = "";
- stringstream folderName;
- try {
- vector<string> tokens;
- istringstream f(name.c_str());
- string s;
- int i=0;
- while (getline(f, s, FOLDERDELIMCHAR)) {
- tokens.push_back(s);
- if (isFolder && i <= level) {
- if (i > 0)
- folderName << FOLDERDELIMCHAR;
- folderName << s;
- i++;
- }
- }
- buffer = tokens.at(level);
- if (!isFolder && recording->IsEdited()) {
- buffer = buffer.substr(1);
- }
- } catch (...) {
- buffer = name.c_str();
- }
-
- const cRecording *usedRecording = recording;
-
- if (isFolder) {
- cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName.str().c_str());
- if (folderInfo) {
- cRecording *newestRec = Recordings.GetByName(*folderInfo->LatestFileName);
- if (newestRec) {
- usedRecording = newestRec;
- }
- delete folderInfo;
- }
- }
-
- stringTokens.insert(pair<string,string>("name", buffer.c_str()));
- intTokens.insert(pair<string,int>("new", usedRecording->IsNew()));
- int percSeen = 0;
-#if APIVERSNUM < 20108
- percSeen = -1;
-#else
- percSeen = 0;
- int framesSeen = usedRecording->GetResume();
- int framesTotal = usedRecording->NumFrames();
- if (framesTotal > 0) {
- percSeen = (double)framesSeen / (double)framesTotal * 100;
- }
-#endif
- intTokens.insert(pair<string,int>("percentseen", percSeen));
- intTokens.insert(pair<string,int>("newrecordingsfolder", newRecs));
- intTokens.insert(pair<string,int>("numrecordingsfolder", total));
- intTokens.insert(pair<string,int>("cutted", usedRecording->IsEdited()));
- int recDuration = usedRecording->LengthInSeconds();
- bool watched = false;
- if (usedRecording->IsEdited()) {
- if (percSeen >= 85)
- watched = true;
- } else {
- int watchedLimit = recDuration * 85 / 100 - (Setup.MarginStop + 5)*60;
- int watchedTime = percSeen * recDuration / 100;
- if (watchedLimit > 0 && watchedTime > 0 && (watchedTime > watchedLimit))
- watched = true;
- }
- intTokens.insert(pair<string,int>("watched", watched));
-
- SetScraperPoster(NULL, usedRecording);
-
-
- const cRecordingInfo *info = usedRecording->Info();
- if (!info) return true;
-
- bool extRecinfoAvailable = false;
- if (info->Aux()) {
- cExtRecInfo extRecInfo(info->Aux());
- if (extRecInfo.Parse()) {
- extRecinfoAvailable = true;
- intTokens.insert(pair<string,int>("screenwidth", extRecInfo.resWidth));
- intTokens.insert(pair<string,int>("screenheight", extRecInfo.resHeight));
- intTokens.insert(pair<string,int>("isHD", extRecInfo.isHD));
- intTokens.insert(pair<string,int>("isWideScreen", extRecInfo.isWideScreen));
- intTokens.insert(pair<string,int>("isDolby", extRecInfo.isDolby));
- stringTokens.insert(pair<string,string>("resolution", extRecInfo.resString));
- stringTokens.insert(pair<string,string>("aspect", extRecInfo.aspectratio));
- stringTokens.insert(pair<string,string>("codec", extRecInfo.codec));
- stringTokens.insert(pair<string,string>("format", extRecInfo.format));
- stringTokens.insert(pair<string,string>("framerate", extRecInfo.framerate));
- stringTokens.insert(pair<string,string>("interlace", extRecInfo.interlace));
- intTokens.insert(pair<string,int>("numtracks", extRecInfo.tracks.size()));
- vector< map<string,string> > trackTokens;
- int trackNumber = 1;
- for (vector<tAudioTrack>::iterator track = extRecInfo.tracks.begin(); track != extRecInfo.tracks.end(); track++) {
- map<string,string> element;
- stringstream trackNum;
- trackNum << trackNumber++;
- element.insert(pair<string,string>("track[num]", trackNum.str()));
- element.insert(pair<string,string>("track[codec]", (*track).codec));
- element.insert(pair<string,string>("track[bitrate]", (*track).bitrate));
- element.insert(pair<string,string>("track[language]", (*track).language));
- trackTokens.push_back(element);
- }
- loopTokens.insert(pair<string, vector< map< string, string > > >("track", trackTokens));
- }
- }
- intTokens.insert(pair<string,int>("extrecinfoavailable", extRecinfoAvailable));
-
- stringTokens.insert(pair<string,string>("epgname", info->Title() ? info->Title() : buffer));
- stringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : ""));
- stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : ""));
-
- const cEvent *event = info->GetEvent();
- if (!event) return true;
-
- string recDate = *(event->GetDateString());
- string recTime = *(event->GetTimeString());
- if (recDate.find("1970") != string::npos) {
- time_t start = usedRecording->Start();
- recDate = *DateString(start);
- recTime = *TimeString(start);
- }
-
- time_t startTime = event->StartTime();
- struct tm * sStartTime = localtime(&startTime);
- intTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- intTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
-
- int duration = event->Duration() / 60;
- recDuration = (recDuration>0)?(recDuration / 60):0;
- stringTokens.insert(pair<string,string>("date", recDate.c_str()));
- stringTokens.insert(pair<string,string>("time", recTime.c_str()));
- intTokens.insert(pair<string,int>("duration", recDuration));
- intTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- intTokens.insert(pair<string,int>("durationevent", duration));
- intTokens.insert(pair<string,int>("durationeventhours", duration / 60));
- stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
- SetTokensPosMenuItem();
- DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
- return true;
-}
-
-/*************************************************************
-* cDisplayMenuItemCurrentPluginView
-*************************************************************/
-
-cDisplayMenuItemCurrentPluginView::cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens,
- map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens)
- : cDisplayMenuItemCurrentView(tmplCurrent) {
-
- stringTokens = plugStringTokens;
- intTokens = plugIntTokens;
- loopTokens = pluginLoopTokens;
-}
-
-bool cDisplayMenuItemCurrentPluginView::Render(void) {
- SetTokensPosMenuItem();
- DrawViewElement(veMenuCurrentItemDetail, &stringTokens, &intTokens, &loopTokens);
- return true;
-}
diff --git a/views/displaymenuitemcurrentview.h b/views/displaymenuitemcurrentview.h
deleted file mode 100644
index 810355d..0000000
--- a/views/displaymenuitemcurrentview.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef __DISPLAYMENUITEMCURRENTVIEW_H
-#define __DISPLAYMENUITEMCURRENTVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-
-class cDisplayMenuItemCurrentView : public cViewElement {
-private:
-protected:
- cRect posMenuItem;
- void SetTokensPosMenuItem(void);
- void SetScraperPoster(const cEvent *event, const cRecording *recording=NULL);
-public:
- cDisplayMenuItemCurrentView(cTemplateViewElement *tmplCurrent);
- virtual ~cDisplayMenuItemCurrentView();
- void SetPosMenuItem(cRect &pos);
-};
-
-class cDisplayMenuItemCurrentMainView: public cDisplayMenuItemCurrentView {
-private:
- string number;
- string label;
- string icon;
-public:
- cDisplayMenuItemCurrentMainView(cTemplateViewElement *tmplCurrent, string number, string label, string icon);
- virtual ~cDisplayMenuItemCurrentMainView() {};
- bool Render(void);
-};
-
-class cDisplayMenuItemCurrentSchedulesView: public cDisplayMenuItemCurrentView {
-private:
- const cEvent *event;
- const cChannel *channel;
- eTimerMatch timerMatch;
- eMenuCategory cat;
- bool isEpgSearchFav;
- 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() {};
- bool Render(void);
-};
-
-class cDisplayMenuItemCurrentChannelView: public cDisplayMenuItemCurrentView {
-private:
- const cChannel *channel;
- void ReadSchedules(vector< map<string,string> > *schedulesTokens);
-public:
- cDisplayMenuItemCurrentChannelView(cTemplateViewElement *tmplCurrent, const cChannel *channel);
- virtual ~cDisplayMenuItemCurrentChannelView() {};
- bool Render(void);
-};
-
-class cDisplayMenuItemCurrentTimerView: public cDisplayMenuItemCurrentView {
-private:
- const cTimer *timer;
-public:
- cDisplayMenuItemCurrentTimerView(cTemplateViewElement *tmplCurrent, const cTimer *timer);
- virtual ~cDisplayMenuItemCurrentTimerView() {};
- bool Render(void);
-};
-
-class cDisplayMenuItemCurrentRecordingView: public cDisplayMenuItemCurrentView {
-private:
- const cRecording *recording;
- int level;
- int total;
- int newRecs;
-public:
- cDisplayMenuItemCurrentRecordingView(cTemplateViewElement *tmplCurrent, const cRecording *recording, int level, int total, int newRecs);
- virtual ~cDisplayMenuItemCurrentRecordingView() {};
- bool Render(void);
-};
-
-class cDisplayMenuItemCurrentPluginView: public cDisplayMenuItemCurrentView {
-private:
- map<string,vector<map<string,string> > > loopTokens;
-public:
- cDisplayMenuItemCurrentPluginView(cTemplateViewElement *tmplCurrent, map <string,string> &plugStringTokens, map <string,int> &plugIntTokens, map<string,vector<map<string,string> > > &pluginLoopTokens);
- virtual ~cDisplayMenuItemCurrentPluginView() {};
- bool Render(void);
-};
-
-#endif //__DISPLAYMENUITEMCURRENTVIEW_H
diff --git a/views/displaymenuitemview.c b/views/displaymenuitemview.c
deleted file mode 100644
index 4f90f3a..0000000
--- a/views/displaymenuitemview.c
+++ /dev/null
@@ -1,981 +0,0 @@
-#include "displaymenuitemview.h"
-#include "../services/scraper2vdr.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-#include "../libcore/recfolderinfo.h"
-#include <sstream>
-#include <algorithm>
-
-/*************************************************************
-* cDisplayMenuItemView
-*************************************************************/
-
-cDisplayMenuItemView::cDisplayMenuItemView(cTemplateViewList *tmplList, bool current, bool selectable) : cViewListItem(tmplList->GetListElement()) {
- this->tmplList = tmplList;
- this->current = current;
- this->selectable = selectable;
- itemInit = true;
- dirty = true;
- num = 0;
- currentView = NULL;
-}
-
-cDisplayMenuItemView::~cDisplayMenuItemView() {
- if (currentView)
- delete currentView;
- CancelSave();
-}
-
-void cDisplayMenuItemView::SetCurrent(bool cur) {
- current = cur;
- intTokens.erase("current");
- intTokens.insert(pair<string,int>("current", current));
- dirty = true;
-};
-
-
-void cDisplayMenuItemView::ArrangeContainer(void) {
- if (pos > -1)
- return;
- SetInitFinished();
- pos = num;
- numTotal = tmplList->GetNumericParameter(ptNumElements);
- container.SetX(tmplList->GetNumericParameter(ptX));
- container.SetY(tmplList->GetNumericParameter(ptY));
- container.SetWidth(tmplList->GetNumericParameter(ptWidth));
- container.SetHeight(tmplList->GetNumericParameter(ptHeight));
- align = tmplList->GetNumericParameter(ptAlign);
- listOrientation = tmplList->GetNumericParameter(ptOrientation);
-}
-
-void cDisplayMenuItemView::Clear(void) {
- ClearListItem();
- if (currentView) {
- delete currentView;
- currentView = NULL;
- }
-}
-
-void cDisplayMenuItemView::PrepareScrolling(void) {
- currentlyScrolling = true;
- ClearListItem();
- DrawListItem(&stringTokens, &intTokens);
-}
-
-void cDisplayMenuItemView::EndScrolling(void) {
- const cPoint p(0,0);
- SetDrawPortPoint(scrollingPix, p);
- currentlyScrolling = false;
- ClearListItem();
- DrawListItem(&stringTokens, &intTokens);
-}
-
-void cDisplayMenuItemView::Action(void) {
- if (scrolling) {
- DoSleep(scrollDelay);
- if (!Running())
- return;
- PrepareScrolling();
- if (scrollOrientation == orHorizontal) {
- ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
- } else {
- ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
- }
- }
-}
-
-void cDisplayMenuItemView::Stop(void) {
- if (Running()) {
- CancelSave();
- EndScrolling();
- }
-}
-
-
-void cDisplayMenuItemView::Debug(void) {
- esyslog("skindesigner: current %d, selectable %d", current, selectable);
- esyslog("skindesigner: pos %d, numTotal %d", pos, numTotal);
- esyslog("skindesigner: container x = %d, y = %d, width = %d, height = %d", container.X(), container.Y(), container.Width(), container.Height());
-}
-
-/*************************************************************
-* cDisplayMenuItemDefaultView
-*************************************************************/
-
-cDisplayMenuItemDefaultView::cDisplayMenuItemDefaultView(cTemplateViewList *tmplList, string *tabTexts, int *tabs, int *tabWidths, bool current, bool selectable)
- : cDisplayMenuItemView(tmplList, current, selectable) {
- this->tabTexts = tabTexts;
- this->tabs = tabs;
- this->tabWidths = tabWidths;
- maxTabs = cSkinDisplayMenu::MaxTabs;
- menuCategory = "";
-}
-
-cDisplayMenuItemDefaultView::~cDisplayMenuItemDefaultView() {
- delete[] tabTexts;
-}
-
-void cDisplayMenuItemDefaultView::SetTabTexts(string *tabTexts) {
- delete[] this->tabTexts;
- this->tabTexts = tabTexts;
-}
-
-void cDisplayMenuItemDefaultView::SetTokens(void) {
- stringTokens.clear();
- intTokens.clear();
- for (int i=0; i<maxTabs; i++) {
- stringstream name;
- name << "column" << (i+1);
- stringstream nameUsed;
- nameUsed << name.str() << "set";
- stringstream nameX;
- nameX << name.str() << "x";
- stringstream nameWidth;
- nameWidth << name.str() << "width";
- stringTokens.insert(pair<string,string>(name.str(), tabTexts[i]));
- if (i>0)
- intTokens.insert(pair<string,int>(nameUsed.str(), (tabTexts[i].size() > 0) ? 1 : 0 ));
- intTokens.insert(pair<string,int>(nameX.str(), tabs[i]));
- intTokens.insert(pair<string,int>(nameWidth.str(), tabWidths[i]));
- //Progress Bar
- if (tabTexts[i].find("[") != string::npos & tabTexts[i].find("]") != string::npos) {
- stringstream nameProgressBar;
- nameProgressBar << name.str() << "pb";
- stringstream namePbTotal;
- namePbTotal << name.str() << "pbtotalsize";
- stringstream namePbSize;
- namePbSize << name.str() << "pbsize";
- intTokens.insert(pair<string,int>(nameProgressBar.str(), 1));
- intTokens.insert(pair<string,int>(namePbTotal.str(), tabTexts[i].size() - 2));
- intTokens.insert(pair<string,int>(namePbSize.str(), std::count(tabTexts[i].begin(), tabTexts[i].end(), '|')));
- }
- }
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("separator", !selectable));
- intTokens.insert(pair<string,int>("nummenuitem", num+1));
- if (menuCategory.size() > 0) {
- intTokens.insert(pair<string,int>(menuCategory, 1));
- }
-}
-
-void cDisplayMenuItemDefaultView::Prepare(void) {
- ArrangeContainer();
-}
-
-
-void cDisplayMenuItemDefaultView::Render(void) {
- DrawListItem(&stringTokens, &intTokens);
- dirty = false;
-}
-
-void cDisplayMenuItemDefaultView::Debug(void) {
- esyslog("skindesigner: Default Menu Item ---------------");
- cDisplayMenuItemView::Debug();
- for (int i=0; i<maxTabs; i++) {
- esyslog("skindesigner: tab %d: text: %s, x: %d", i, tabTexts[i].c_str(), tabs[i]);
- }
-}
-
-/*************************************************************
-* Private Functions
-*************************************************************/
-
-
-/*************************************************************
-* cDisplayMenuItemMainView
-*************************************************************/
-
-cDisplayMenuItemMainView::cDisplayMenuItemMainView(cTemplateViewList *tmplList, string itemText, bool current, bool selectable)
- : cDisplayMenuItemView(tmplList, current, selectable) {
- text = itemText;
- number = "";
- label = "";
- icon = "";
- isPlugin = false;
- plugName = "";
- SplitMenuText();
- CheckPlugins();
-}
-
-cDisplayMenuItemMainView::~cDisplayMenuItemMainView() {
-}
-
-void cDisplayMenuItemMainView::SetTokens(void) {
- if (!itemInit)
- return;
- itemInit = false;
- stringTokens.insert(pair<string,string>("number", number));
- stringTokens.insert(pair<string,string>("label", label));
- stringTokens.insert(pair<string,string>("icon", icon));
-
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("separator", !selectable));
- intTokens.insert(pair<string,int>("nummenuitem", num+1));
-}
-
-void cDisplayMenuItemMainView::Prepare(void) {
- ArrangeContainer();
- if (isPlugin) {
- icon = imgCache->GetIconName(label, mcUnknown, plugName);
- } else {
- icon = imgCache->GetIconName(label);
- }
-}
-
-
-void cDisplayMenuItemMainView::Render(void) {
-
- cRect pos = DrawListItem(&stringTokens, &intTokens);
-
- if (current) {
- cTemplateViewElement *tmplCurrent = tmplList->GetListElementCurrent();
- if (tmplCurrent && tmplCurrent->Execute()) {
- currentView = new cDisplayMenuItemCurrentMainView(tmplCurrent, number, label, icon);
- currentView->SetPosMenuItem(pos);
- currentView->Start();
- }
- }
-
- dirty = false;
-}
-
-string cDisplayMenuItemMainView::GetPluginName(void) {
- if (!isPlugin)
- return "";
- return plugName;
-}
-
-void cDisplayMenuItemMainView::Debug(void) {
- esyslog("skindesigner: Main Menu Item ---------------");
- cDisplayMenuItemView::Debug();
- esyslog("skindesigner: item Text: %s", text.c_str());
- esyslog("skindesigner: item Number: %s, Label: %s", number.c_str(), label.c_str());
- esyslog("skindesigner: Icon: %s", icon.c_str());
-}
-
-/*************************************************************
-* Private Functions
-*************************************************************/
-
-void cDisplayMenuItemMainView::SplitMenuText(void) {
- string textPlain = skipspace(text.c_str());
- bool found = false;
- bool doBreak = false;
- size_t i = 0;
- for (; i < textPlain.length(); i++) {
- char s = textPlain.at(i);
- if (i==0) {
- //if text directly starts with nonnumeric, break
- if (!(s >= '0' && s <= '9')) {
- break;
- }
- }
- if (found) {
- //if current char is not a figure anymore, break
- if (!(s >= '0' && s <= '9')) {
- //there has to be a space after the menu item number
- //plugins with figures in their name are eval :-)
- if (s != ' ')
- found = false;
- doBreak = true;
- }
- }
- if (s >= '0' && s <= '9') {
- found = true;
- }
- if (doBreak)
- break;
- if (i>4)
- break;
- }
- if (found) {
- number = skipspace(textPlain.substr(0,i).c_str());
- label = skipspace(textPlain.substr(i).c_str());
- } else {
- number = "";
- label = textPlain.c_str();
- }
-}
-
-void cDisplayMenuItemMainView::CheckPlugins(void) {
- for (int i = 0; ; i++) {
- cPlugin *p = cPluginManager::GetPlugin(i);
- if (p) {
- const char *mainMenuEntry = p->MainMenuEntry();
- if (mainMenuEntry) {
- string plugMainEntry = mainMenuEntry;
- if (label.substr(0, plugMainEntry.size()) == plugMainEntry) {
- isPlugin = true;
- plugName = p->Name() ? p->Name() : "";
- return;
- }
- }
- } else
- break;
- }
-}
-
-/*************************************************************
-* cDisplayMenuItemSchedulesView
-*************************************************************/
-
-cDisplayMenuItemSchedulesView::cDisplayMenuItemSchedulesView(cTemplateViewList *tmplList, const cEvent *event,
- const cChannel *channel, eTimerMatch timerMatch,
- eMenuCategory cat, bool isEpgSearchFav, bool current,
- bool selectable, string dayseparator)
- : cDisplayMenuItemView(tmplList, current, selectable) {
- this->event = event;
- this->channel = channel;
- this->dayseparator = dayseparator;
- this->timerMatch = timerMatch;
- this->cat = cat;
- this->isEpgSearchFav = isEpgSearchFav;
-}
-
-cDisplayMenuItemSchedulesView::~cDisplayMenuItemSchedulesView() {
-}
-
-void cDisplayMenuItemSchedulesView::SetTokens(void) {
- if (!itemInit)
- return;
- itemInit = false;
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("separator", !selectable));
- intTokens.insert(pair<string,int>("nummenuitem", num+1));
- 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));
- intTokens.insert(pair<string,int>("whatsonfavorites", isEpgSearchFav ? true: false));
- if (timerMatch == tmFull) {
- intTokens.insert(pair<string,int>("timerpartitial", false));
- intTokens.insert(pair<string,int>("timerfull", true));
- } else if (timerMatch == tmPartial) {
- intTokens.insert(pair<string,int>("timerpartitial", true));
- intTokens.insert(pair<string,int>("timerfull", false));
- } else {
- intTokens.insert(pair<string,int>("timerpartitial", false));
- intTokens.insert(pair<string,int>("timerfull", false));
- }
-
- if (event) {
- if (selectable) {
- stringTokens.insert(pair<string,string>("title", event->Title() ? event->Title() : ""));
- stringTokens.insert(pair<string,string>("shorttext", event->ShortText() ? event->ShortText() : ""));
- stringTokens.insert(pair<string,string>("start", *(event->GetTimeString())));
- stringTokens.insert(pair<string,string>("stop", *(event->GetEndTimeString())));
- time_t startTime = event->StartTime();
- stringTokens.insert(pair<string,string>("day", *WeekDayName(startTime)));
- stringTokens.insert(pair<string,string>("date", *ShortDateString(startTime)));
- struct tm * sStartTime = localtime(&startTime);
- intTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- intTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
-
- bool isRunning = false;
- time_t now = time(NULL);
- if ((now >= event->StartTime()) && (now <= event->EndTime()))
- isRunning = true;
- intTokens.insert(pair<string,int>("running", isRunning));
- if (isRunning) {
- intTokens.insert(pair<string,int>("elapsed", (now - event->StartTime())/60));
- intTokens.insert(pair<string,int>("startsin", 0));
- } else {
- intTokens.insert(pair<string,int>("elapsed", 0));
- intTokens.insert(pair<string,int>("startsin", (event->StartTime() - now)/60));
- }
- 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>("hasVPS", (bool)event->Vps()));
- } else {
- stringTokens.insert(pair<string,string>("title", event->Title() ? ParseSeparator(event->Title()) : ""));
- }
- } else if (!channel) {
- stringTokens.insert(pair<string,string>("title", dayseparator));
- }
- if (channel) {
- stringTokens.insert(pair<string,string>("channelname", channel->Name() ? channel->Name() : ""));
- string channelID = *(channel->GetChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channelnumber", channel->Number()));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
- if (!event && !selectable) {
- stringTokens.insert(pair<string,string>("title", channel->Name() ? ParseSeparator(channel->Name()) : ""));
- }
- } else {
- stringTokens.insert(pair<string,string>("channelname", ""));
- stringTokens.insert(pair<string,string>("channelid", ""));
- intTokens.insert(pair<string, int>("channelnumber", 0));
- intTokens.insert(pair<string, int>("channellogoexists", 0));
- }
-}
-
-
-void cDisplayMenuItemSchedulesView::Prepare(void) {
- ArrangeContainer();
-}
-
-void cDisplayMenuItemSchedulesView::Render(void) {
- DrawListItem(&stringTokens, &intTokens);
-
- if (current) {
- cTemplateViewElement *tmplCurrent = tmplList->GetListElementCurrent();
- if (tmplCurrent && tmplCurrent->Execute()) {
- currentView = new cDisplayMenuItemCurrentSchedulesView(tmplCurrent, event, channel, timerMatch, cat, isEpgSearchFav);
- currentView->Start();
- }
- }
-
- dirty = false;
-}
-
-void cDisplayMenuItemSchedulesView::Debug(void) {
- esyslog("skindesigner: Schedules Menu Item ---------------");
- cDisplayMenuItemView::Debug();
- esyslog("skindesigner: Event: %s", event ? event->Title() : "Event is NULL");
-}
-
-/*************************************************************
-* Private Functions
-*************************************************************/
-
-string cDisplayMenuItemSchedulesView::ParseSeparator(string sep) {
- string separator = sep;
- try {
- if (separator.find_first_not_of("-") > 0)
- separator.erase(0, separator.find_first_not_of("-")+1);
- if (separator.find_last_not_of("-") != string::npos)
- separator.erase(separator.find_last_not_of("-")+1);
- } catch (...) {}
- return separator;
-}
-
-/*************************************************************
-* cDisplayMenuItemChannelsView
-*************************************************************/
-
-cDisplayMenuItemChannelsView::cDisplayMenuItemChannelsView(cTemplateViewList *tmplList, const cChannel *channel,
- bool withProvider, bool current, bool selectable)
- : cDisplayMenuItemView(tmplList, current, selectable) {
- this->channel = channel;
- this->withProvider = withProvider;
-}
-
-cDisplayMenuItemChannelsView::~cDisplayMenuItemChannelsView() {
-}
-
-void cDisplayMenuItemChannelsView::SetTokens(void) {
- if (!itemInit)
- return;
- itemInit = false;
- if (!channel)
- return;
- //general channel information
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("separator", !selectable));
- intTokens.insert(pair<string,int>("nummenuitem", num+1));
- intTokens.insert(pair<string,int>("number", channel->Number()));
- intTokens.insert(pair<string,int>("transponder", channel->Transponder()));
- intTokens.insert(pair<string,int>("frequency", channel->Frequency()));
-
- stringTokens.insert(pair<string,string>("name", channel->Name() ? channel->Name() : ""));
- string channelID = *(channel->GetChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
-
- //Channel Source Information
- const cSource *source = Sources.Get(channel->Source());
- if (source) {
- stringTokens.insert(pair<string,string>("source", *cSource::ToString(source->Code())));
- stringTokens.insert(pair<string,string>("sourcedescription", source->Description() ? source->Description() : ""));
- stringTokens.insert(pair<string,string>("source", *cSource::ToString(source->Code())));
- intTokens.insert(pair<string,int>("isAtsc", source->IsAtsc(source->Code())));
- intTokens.insert(pair<string,int>("isCable", source->IsCable(source->Code())));
- intTokens.insert(pair<string,int>("isSat", source->IsSat(source->Code())));
- intTokens.insert(pair<string,int>("isTerr", source->IsTerr(source->Code())));
- }
-
- //current schedule
- cSchedulesLock schedulesLock;
- const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
- const cSchedule *schedule = NULL;
- schedule = schedules->GetSchedule(channel);
- bool inserted = false;
- if (schedule) {
- const cEvent *presentEvent = schedule->GetPresentEvent();
- if (presentEvent) {
- stringTokens.insert(pair<string,string>("presenteventtitle", presentEvent->Title() ? presentEvent->Title() : ""));
- stringTokens.insert(pair<string,string>("presenteventstart", *presentEvent->GetTimeString()));
- stringTokens.insert(pair<string,string>("presenteventstop", *presentEvent->GetEndTimeString()));
- inserted = true;
- }
- }
- if (!inserted) {
- stringTokens.insert(pair<string,string>("presenteventtitle", ""));
- stringTokens.insert(pair<string,string>("presenteventstart", ""));
- stringTokens.insert(pair<string,string>("presenteventstop", ""));
- }
-}
-
-
-void cDisplayMenuItemChannelsView::Prepare(void) {
- ArrangeContainer();
-}
-
-void cDisplayMenuItemChannelsView::Render(void) {
-
- DrawListItem(&stringTokens, &intTokens);
-
- if (current) {
- cTemplateViewElement *tmplCurrent = tmplList->GetListElementCurrent();
- if (tmplCurrent && tmplCurrent->Execute()) {
- currentView = new cDisplayMenuItemCurrentChannelView(tmplCurrent, channel);
- currentView->Start();
- }
- }
-
- dirty = false;
-}
-
-void cDisplayMenuItemChannelsView::Debug(void) {
- esyslog("skindesigner: Channels Menu Item ---------------");
- cDisplayMenuItemView::Debug();
- esyslog("skindesigner: Channel: %s", channel ? channel->Name() : "Channel is NULL");
-}
-
-/*************************************************************
-* Private Functions
-*************************************************************/
-
-/*************************************************************
-* cDisplayMenuItemTimersView
-*************************************************************/
-
-cDisplayMenuItemTimersView::cDisplayMenuItemTimersView(cTemplateViewList *tmplList, const cTimer *timer, bool current, bool selectable)
- : cDisplayMenuItemView(tmplList, current, selectable) {
- this->timer = timer;
-}
-
-cDisplayMenuItemTimersView::~cDisplayMenuItemTimersView() {
-}
-
-void cDisplayMenuItemTimersView::SetTokens(void) {
- if (!timer)
- return;
- if (!itemInit) {
- intTokens.erase("flagactive");
- intTokens.insert(pair<string,int>("flagactive", timer->HasFlags(tfActive)));
- return;
- }
- itemInit = false;
-
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("nummenuitem", num+1));
- 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)));
- intTokens.insert(pair<string,int>("flagrecording", timer->Recording()));
- intTokens.insert(pair<string,int>("flagpending", timer->Pending()));
-
-
- 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();
- stringTokens.insert(pair<string,string>("title", file));
- stringTokens.insert(pair<string,string>("timerstart", *cString::sprintf("%02d:%02d", timer->Start() / 100, timer->Start() % 100)));
- stringTokens.insert(pair<string,string>("timerstop", *cString::sprintf("%02d:%02d", timer->Stop() / 100, timer->Stop() % 100)));
-
- string day = "";
- string dayName = "";
- if (timer->WeekDays())
- day = timer->PrintDay(0, timer->WeekDays(), false);
- else if (timer->Day() - time(NULL) < 28 * SECSINDAY) {
- day = itoa(timer->GetMDay(timer->Day()));
- dayName = WeekDayName(timer->Day());
- } else {
- struct tm tm_r;
- time_t Day = timer->Day();
- localtime_r(&Day, &tm_r);
- char buffer[16];
- strftime(buffer, sizeof(buffer), "%Y%m%d", &tm_r);
- day = buffer;
- }
-
- struct tm tm_r;
- time_t timerDate = timer->Day();
- localtime_r(&timerDate, &tm_r);
- char buffer[4];
- strftime(buffer, sizeof(buffer), "%m", &tm_r);
- int month = atoi(buffer);
- char buffer2[6];
- strftime(buffer2, sizeof(buffer2), "%b", &tm_r);
- string monthName = buffer2;
- char buffer3[6];
- strftime(buffer3, sizeof(buffer3), "%Y", &tm_r);
- int year = atoi(buffer3);
-
- stringTokens.insert(pair<string,string>("day", day));
- stringTokens.insert(pair<string,string>("dayname", dayName));
- intTokens.insert(pair<string,int>("month", month));
- stringTokens.insert(pair<string,string>("monthname", monthName));
- intTokens.insert(pair<string,int>("year", year));
-
- const cChannel *channel = timer->Channel();
- if (channel) {
- stringTokens.insert(pair<string,string>("channelname", channel->Name() ? channel->Name() : ""));
- string channelID = *(channel->GetChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
- intTokens.insert(pair<string,int>("channelnumber", channel->Number()));
- } else {
- stringTokens.insert(pair<string,string>("channelname", ""));
- stringTokens.insert(pair<string,string>("channelid", ""));
- intTokens.insert(pair<string, int>("channellogoexists", 0));
- intTokens.insert(pair<string,int>("channelnumber", 0));
- }
-
- const cEvent *event = timer->Event();
- if (event) {
- stringTokens.insert(pair<string,string>("eventtitle", event->Title() ? event->Title() : ""));
- stringTokens.insert(pair<string,string>("eventstart", *event->GetTimeString()));
- stringTokens.insert(pair<string,string>("eventstop", *event->GetEndTimeString()));
- } else {
- stringTokens.insert(pair<string,string>("eventtitle", ""));
- stringTokens.insert(pair<string,string>("eventtitle", ""));
- stringTokens.insert(pair<string,string>("eventstop", ""));
- }
-}
-
-
-void cDisplayMenuItemTimersView::Prepare(void) {
- ArrangeContainer();
-}
-
-void cDisplayMenuItemTimersView::Render(void) {
-
- DrawListItem(&stringTokens, &intTokens);
-
- if (current) {
- cTemplateViewElement *tmplCurrent = tmplList->GetListElementCurrent();
- if (tmplCurrent && tmplCurrent->Execute()) {
- currentView = new cDisplayMenuItemCurrentTimerView(tmplCurrent, timer);
- currentView->Start();
- }
- }
-
- dirty = false;
-}
-
-void cDisplayMenuItemTimersView::Debug(void) {
- esyslog("skindesigner: Timers Menu Item ---------------");
- cDisplayMenuItemView::Debug();
- esyslog("skindesigner: Timer: %s", timer ? *(timer->ToDescr()) : "Timer is NULL");
-}
-
-/*************************************************************
-* Private Functions
-*************************************************************/
-
-
-/*************************************************************
-* cDisplayMenuItemRecordingView
-*************************************************************/
-
-cDisplayMenuItemRecordingView::cDisplayMenuItemRecordingView(cTemplateViewList *tmplList, const cRecording *recording, int level, int total, int newRecs, bool current, bool selectable)
- : cDisplayMenuItemView(tmplList, current, selectable) {
- this->recording = recording;
- this->level = level;
- this->total = total;
- this->newRecs = newRecs;
-}
-
-cDisplayMenuItemRecordingView::~cDisplayMenuItemRecordingView() {
-}
-
-void cDisplayMenuItemRecordingView::SetTokens(void) {
- if (!itemInit) return;
- itemInit = false;
- if (!recording) return;
-
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("nummenuitem", num+1));
- bool isFolder = (total > 0) ? true : false;
- intTokens.insert(pair<string,int>("folder", isFolder));
-
- string name = recording->Name() ? recording->Name() : "";
- string buffer = "";
- stringstream folderName;
- try {
- vector<string> tokens;
- istringstream f(name.c_str());
- string s;
- int i=0;
- while (getline(f, s, FOLDERDELIMCHAR)) {
- tokens.push_back(s);
- if (isFolder && i <= level) {
- if (i > 0)
- folderName << FOLDERDELIMCHAR;
- folderName << s;
- i++;
- }
- }
- buffer = tokens.at(level);
- if (!isFolder && recording->IsEdited()) {
- buffer = buffer.substr(1);
- }
- } catch (...) {
- buffer = name.c_str();
- }
-
- const cRecording *usedRecording = recording;
-
- if (isFolder) {
- cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName.str().c_str());
- if (folderInfo) {
- cRecording *newestRec = Recordings.GetByName(*folderInfo->LatestFileName);
- if (newestRec) {
- usedRecording = newestRec;
- }
- delete folderInfo;
- }
- }
-
- stringTokens.insert(pair<string,string>("name", buffer.c_str()));
- intTokens.insert(pair<string,int>("new", usedRecording->IsNew()));
-
- int percSeen = 0;
-#if APIVERSNUM < 20108
- percSeen = -1;
-#else
- percSeen = 0;
- int framesSeen = usedRecording->GetResume();
- int framesTotal = usedRecording->NumFrames();
- if (framesTotal > 0) {
- percSeen = (double)framesSeen / (double)framesTotal * 100;
- }
-#endif
- intTokens.insert(pair<string,int>("percentseen", percSeen));
- intTokens.insert(pair<string,int>("newrecordingsfolder", newRecs));
- intTokens.insert(pair<string,int>("numrecordingsfolder", total));
- intTokens.insert(pair<string,int>("cutted", usedRecording->IsEdited()));
-
- int recDuration = usedRecording->LengthInSeconds();
- bool watched = false;
- if (usedRecording->IsEdited()) {
- if (percSeen >= 85)
- watched = true;
- } else {
- int watchedLimit = recDuration * 85 / 100 - (Setup.MarginStop + 5)*60;
- int watchedTime = percSeen * recDuration / 100;
- if (watchedLimit > 0 && watchedTime > 0 && (watchedTime > watchedLimit))
- watched = true;
- }
- intTokens.insert(pair<string,int>("watched", watched));
-
- const cEvent *event = NULL;
- const cRecordingInfo *info = usedRecording->Info();
- if (!info) return;
- event = info->GetEvent();
- if (!event) return;
-
- string recDate = *(event->GetDateString());
- string recTime = *(event->GetTimeString());
- if (recDate.find("1970") != string::npos) {
- time_t start = usedRecording->Start();
- recDate = *DateString(start);
- recTime = *TimeString(start);
- }
-
- time_t startTime = event->StartTime();
- if (!startTime)
- startTime = usedRecording->Start();
- struct tm * sStartTime = localtime(&startTime);
- intTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- intTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
-
- int duration = event->Duration() / 60;
- recDuration = (recDuration>0)?(recDuration / 60):0;
- stringTokens.insert(pair<string,string>("date", recDate.c_str()));
- stringTokens.insert(pair<string,string>("time", recTime.c_str()));
- intTokens.insert(pair<string,int>("duration", recDuration));
- intTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- intTokens.insert(pair<string,int>("durationevent", duration));
- intTokens.insert(pair<string,int>("durationeventhours", duration / 60));
- stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
-
- stringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : ""));
- stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : ""));
-
- static cPlugin *pScraper = GetScraperPlugin();
- if (!pScraper || !usedRecording) {
- intTokens.insert(pair<string,int>("hasposterthumbnail", false));
- intTokens.insert(pair<string,int>("thumbnailbwidth", -1));
- intTokens.insert(pair<string,int>("thumbnailheight", -1));
- stringTokens.insert(pair<string,string>("thumbnailpath", ""));
- return;
- }
-
- ScraperGetPosterThumb call;
- call.event = NULL;
- call.recording = usedRecording;
- if (pScraper->Service("GetPosterThumb", &call)) {
- intTokens.insert(pair<string,int>("hasposterthumbnail", FileExists(call.poster.path)));
- intTokens.insert(pair<string,int>("thumbnailbwidth", call.poster.width));
- intTokens.insert(pair<string,int>("thumbnailheight", call.poster.height));
- stringTokens.insert(pair<string,string>("thumbnailpath", call.poster.path));
- } else {
- intTokens.insert(pair<string,int>("hasposterthumbnail", false));
- intTokens.insert(pair<string,int>("thumbnailbwidth", -1));
- intTokens.insert(pair<string,int>("thumbnailheight", -1));
- stringTokens.insert(pair<string,string>("thumbnailpath", ""));
- }
-
- if (!pScraper || !usedRecording) {
- intTokens.insert(pair<string,int>("hasposter", false));
- intTokens.insert(pair<string,int>("posterwidth", -1));
- intTokens.insert(pair<string,int>("posterheight", -1));
- stringTokens.insert(pair<string,string>("posterpath", ""));
- return;
- }
-
- ScraperGetPoster call2;
- call2.event = NULL;
- call2.recording = usedRecording;
- if (pScraper->Service("GetPoster", &call2)) {
- intTokens.insert(pair<string,int>("hasposter", FileExists(call2.poster.path)));
- intTokens.insert(pair<string,int>("posterwidth", call2.poster.width));
- intTokens.insert(pair<string,int>("posterheight", call2.poster.height));
- stringTokens.insert(pair<string,string>("posterpath", call2.poster.path));
- } else {
- intTokens.insert(pair<string,int>("hasposter", false));
- intTokens.insert(pair<string,int>("posterwidth", -1));
- intTokens.insert(pair<string,int>("posterheight", -1));
- stringTokens.insert(pair<string,string>("posterpath", ""));
- }
-}
-
-
-void cDisplayMenuItemRecordingView::Prepare(void) {
- ArrangeContainer();
-}
-
-void cDisplayMenuItemRecordingView::Render(void) {
-
- DrawListItem(&stringTokens, &intTokens);
-
- if (current) {
- cTemplateViewElement *tmplCurrent = tmplList->GetListElementCurrent();
- if (tmplCurrent && tmplCurrent->Execute()) {
- currentView = new cDisplayMenuItemCurrentRecordingView(tmplCurrent, recording, level, total, newRecs);
- currentView->Start();
- }
- }
-
- dirty = false;
-}
-
-void cDisplayMenuItemRecordingView::Debug(void) {
- esyslog("skindesigner: Recording Menu Item ---------------");
- cDisplayMenuItemView::Debug();
- esyslog("skindesigner: Recording: %s", recording ? recording->Title() : "Recording is NULL");
-}
-
-/*************************************************************
-* cDisplayMenuItemPluginView
-*************************************************************/
-
-cDisplayMenuItemPluginView::cDisplayMenuItemPluginView(cTemplateViewList *tmplList, map<string,string> *plugStringTokens, map<string,int> *plugIntTokens,
- map<string,vector<map<string,string> > > *pluginLoopTokens, int index, bool current, bool selectable)
- : cDisplayMenuItemView(tmplList, current, selectable) {
-
- for (map<string,string>::iterator it = plugStringTokens->begin(); it != plugStringTokens->end(); it++) {
- stringTokens.insert(pair<string,string>(it->first, it->second));
- }
-
- for (map<string,int>::iterator it = plugIntTokens->begin(); it != plugIntTokens->end(); it++) {
- intTokens.insert(pair<string,int>(it->first, it->second));
- }
-
- for(map<string,vector<map<string,string> > >::iterator it = pluginLoopTokens->begin(); it != pluginLoopTokens->end(); it++) {
- loopTokens.insert(pair<string,vector<map<string,string> > >(it->first, it->second));
- }
-}
-
-cDisplayMenuItemPluginView::~cDisplayMenuItemPluginView() {
-}
-
-void cDisplayMenuItemPluginView::SetTokens(void) {
- if (!itemInit) return;
- itemInit = false;
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("nummenuitem", num+1));
-}
-
-
-void cDisplayMenuItemPluginView::Prepare(void) {
- ArrangeContainer();
-}
-
-void cDisplayMenuItemPluginView::Render(void) {
-
- DrawListItem(&stringTokens, &intTokens);
-
- if (current) {
- cTemplateViewElement *tmplCurrent = tmplList->GetListElementCurrent();
- if (tmplCurrent && tmplCurrent->Execute()) {
- currentView = new cDisplayMenuItemCurrentPluginView(tmplCurrent, stringTokens, intTokens, loopTokens);
- currentView->Start();
- }
- }
-
- dirty = false;
-}
-
-void cDisplayMenuItemPluginView::Debug(void) {
- esyslog("skindesigner: Plugin Menu Item ---------------");
- cDisplayMenuItemView::Debug();
-}
-
-/*************************************************************
-* cDisplayMenuItemTrackView
-*************************************************************/
-
-cDisplayMenuItemTrackView::cDisplayMenuItemTrackView(cTemplateViewList *tmplList, const char *title, bool current, bool selectable, int numTracks)
- : cDisplayMenuItemView(tmplList, current, selectable) {
- this->title = title;
- this->numTracks = numTracks;
-}
-
-cDisplayMenuItemTrackView::~cDisplayMenuItemTrackView() {
-}
-
-void cDisplayMenuItemTrackView::SetTokens(void) {
- if (!itemInit) return;
- itemInit = false;
- if (!title) return;
-
- stringTokens.insert(pair<string,string>("title", title));
-}
-
-
-void cDisplayMenuItemTrackView::Prepare(void) {
- ArrangeContainer();
-}
-
-void cDisplayMenuItemTrackView::Render(void) {
-
- DrawListItem(&stringTokens, &intTokens);
-
- dirty = false;
-}
-
-void cDisplayMenuItemTrackView::Debug(void) {
- esyslog("skindesigner: Tracks Menu Item ---------------");
- cDisplayMenuItemView::Debug();
- esyslog("skindesigner: Title: %s", title);
-}
-
diff --git a/views/displaymenuitemview.h b/views/displaymenuitemview.h
deleted file mode 100644
index fb818b0..0000000
--- a/views/displaymenuitemview.h
+++ /dev/null
@@ -1,161 +0,0 @@
-#ifndef __DISPLAYMENUITEMVIEW_H
-#define __DISPLAYMENUITEMVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-#include "displaymenuitemcurrentview.h"
-
-class cDisplayMenuItemView : public cViewListItem {
-private:
-protected:
- bool itemInit;
- bool dirty;
- bool current;
- bool selectable;
- int num;
- cTemplateViewList *tmplList;
- map < string, string > stringTokens;
- map < string, int > intTokens;
- cDisplayMenuItemCurrentView *currentView;
- virtual void Action(void);
-public:
- cDisplayMenuItemView(cTemplateViewList *tmplList, bool current, bool selectable);
- virtual ~cDisplayMenuItemView();
- void SetCurrent(bool cur);
- void SetNumber(int n) { num = n; };
- void ArrangeContainer(void);
- bool Current(void) { return current; };
- void PrepareScrolling(void);
- void EndScrolling(void);
- virtual void SetTokens(void) {};
- virtual void Prepare(void) {};
- virtual void Render(void) {};
- virtual void Clear(void);
- bool Dirty(void) { return dirty; };
- void Stop(void);
- virtual void Debug(void);
-};
-
-class cDisplayMenuItemDefaultView: public cDisplayMenuItemView {
-private:
- int *tabs;
- int *tabWidths;
- string *tabTexts;
- int maxTabs;
- string menuCategory;
-public:
- cDisplayMenuItemDefaultView(cTemplateViewList *tmplList, string *tabTexts, int *tabs, int *tabWidths, bool current, bool selectable);
- virtual ~cDisplayMenuItemDefaultView();
- void SetTabTexts(string *tabTexts);
- void SetTokens(void);
- void SetMenuCategory(string cat) { menuCategory = cat; };
- void Prepare(void);
- void Render(void);
- void Debug(void);
-};
-
-class cDisplayMenuItemMainView: public cDisplayMenuItemView {
-private:
- bool isPlugin;
- string plugName;
- string text;
- string number;
- string label;
- string icon;
- void SplitMenuText(void);
- void CheckPlugins(void);
-public:
- cDisplayMenuItemMainView(cTemplateViewList *tmplList, string itemText, bool current, bool selectable);
- virtual ~cDisplayMenuItemMainView();
- void SetTokens(void);
- void Prepare(void);
- void Render(void);
- string GetPluginName(void);
- void Debug(void);
-};
-
-class cDisplayMenuItemSchedulesView: public cDisplayMenuItemView {
-private:
- const cEvent *event;
- const cChannel *channel;
- string dayseparator;
- eTimerMatch timerMatch;
- eMenuCategory cat;
- bool isEpgSearchFav;
- string ParseSeparator(string sep);
-public:
- cDisplayMenuItemSchedulesView(cTemplateViewList *tmplList, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch,
- eMenuCategory cat, bool isEpgSearchFav, bool current, bool selectable, string dayseparator);
- virtual ~cDisplayMenuItemSchedulesView();
- void SetTokens(void);
- void Prepare(void);
- void Render(void);
- void Debug(void);
-};
-
-class cDisplayMenuItemChannelsView: public cDisplayMenuItemView {
-private:
- const cChannel *channel;
- bool withProvider;
-public:
- cDisplayMenuItemChannelsView(cTemplateViewList *tmplList, const cChannel *channel, bool withProvider, bool current, bool selectable);
- virtual ~cDisplayMenuItemChannelsView();
- void SetTokens(void);
- void Prepare(void);
- void Render(void);
- void Debug(void);
-};
-
-class cDisplayMenuItemTimersView: public cDisplayMenuItemView {
-private:
- const cTimer *timer;
-public:
- cDisplayMenuItemTimersView(cTemplateViewList *tmplList, const cTimer *timer, bool current, bool selectable);
- virtual ~cDisplayMenuItemTimersView();
- void SetTokens(void);
- void Prepare(void);
- void Render(void);
- void Debug(void);
-};
-
-class cDisplayMenuItemRecordingView: public cDisplayMenuItemView {
-private:
- const cRecording *recording;
- int level;
- int total;
- int newRecs;
-public:
- cDisplayMenuItemRecordingView(cTemplateViewList *tmplList, const cRecording *recording, int level, int total, int newRecs, bool current, bool selectable);
- virtual ~cDisplayMenuItemRecordingView();
- void SetTokens(void);
- void Prepare(void);
- void Render(void);
- void Debug(void);
-};
-
-class cDisplayMenuItemPluginView: public cDisplayMenuItemView {
-private:
- map<string,vector<map<string,string> > > loopTokens;
-public:
- cDisplayMenuItemPluginView(cTemplateViewList *tmplList, map<string,string> *plugStringTokens, map<string,int> *plugIntTokens, map<string,vector<map<string,string> > > *pluginLoopTokens, int index, bool current, bool selectable);
- virtual ~cDisplayMenuItemPluginView();
- void SetTokens(void);
- void Prepare(void);
- void Render(void);
- void Debug(void);
-};
-
-class cDisplayMenuItemTrackView: public cDisplayMenuItemView {
-private:
- const char *title;
- int numTracks;
-public:
- cDisplayMenuItemTrackView(cTemplateViewList *tmplList, const char *title, bool current, bool selectable, int numTracks);
- virtual ~cDisplayMenuItemTrackView();
- void SetTokens(void);
- void Prepare(void);
- void Render(void);
- void Debug(void);
-};
-
-#endif //__DISPLAYMENUITEMVIEW_H
diff --git a/views/displaymenulistview.c b/views/displaymenulistview.c
deleted file mode 100644
index 7cc08c9..0000000
--- a/views/displaymenulistview.c
+++ /dev/null
@@ -1,274 +0,0 @@
-#include <vdr/menu.h>
-#include "../displaymenu.h"
-#include "displaymenulistview.h"
-
-
-cDisplayMenuListView::cDisplayMenuListView(cTemplateViewList *tmplList, int count, eMenuCategory cat, string currentPlug) {
- oneColumn = true;
- this->tmplList = tmplList;
- if (count < 0) {
- //if count is not set, the fixed number of items is configured in the template
- itemCount = tmplList->GetNumericParameter(ptNumElements);
- } else {
- //else use the actual numbers of elements
- itemCount = count;
- map < string, int > intTokens;
- intTokens.insert(pair<string,int>("numelements", count));
- tmplList->CalculateListParameters(&intTokens);
- }
- this->cat = cat;
- this->currentPlug = currentPlug;
- menuItems = new cDisplayMenuItemView*[itemCount];
- for (int i=0; i<itemCount; i++)
- menuItems[i] = NULL;
- tabs = new int[cSkinDisplayMenu::MaxTabs];
- for (int i=0; i<cSkinDisplayMenu::MaxTabs; i++)
- tabs[i] = 0;
- tabWidths = new int[cSkinDisplayMenu::MaxTabs];
- for (int i=0; i<cSkinDisplayMenu::MaxTabs; i++)
- tabWidths[i] = 0;
-}
-
-cDisplayMenuListView::~cDisplayMenuListView() {
- Clear();
- delete[] menuItems;
- delete[] tabs;
- delete[] tabWidths;
-}
-
-void cDisplayMenuListView::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
-
- int menuItemWidth = 1920;
- int averageFontWidth = 20;
- if (tmplList) {
- menuItemWidth = tmplList->GetMenuItemWidth();
- averageFontWidth = tmplList->GetAverageFontWidth();
- }
-
- if (!tab1) {
- tabs[0] = 0;
- tabWidths[0] = menuItemWidth;
- } else {
- tabs[0] = 0;
- if (!tab2) {
- tabs[1] = menuItemWidth/2;
- tabWidths[0] = tabs[1];
- tabWidths[1] = tabs[1];
- } else {
- tabs[0] = 0;
- tabs[1] = tab1 ? tabs[0] + tab1 : 0;
- tabs[2] = tab2 ? tabs[1] + tab2 : 0;
- tabs[3] = tab3 ? tabs[2] + tab3 : 0;
- tabs[4] = tab4 ? tabs[3] + tab4 : 0;
- tabs[5] = tab5 ? tabs[4] + tab5 : 0;
- for (int i = 1; i < cSkinDisplayMenu::MaxTabs; i++)
- tabs[i] *= averageFontWidth;
-
- for (int i = 0; i < cSkinDisplayMenu::MaxTabs; i++) {
- if (i == cSkinDisplayMenu::MaxTabs - 1) {
- tabWidths[i] = menuItemWidth - tabs[i];
- } else {
- tabWidths[i] = tabs[i+1] - tabs[i];
- }
- }
- }
- }
-}
-
-int cDisplayMenuListView::GetListWidth(void) {
- if (tmplList) {
- return tmplList->GetMenuItemWidth();
- }
- return 1920;
-}
-
-eMenuOrientation cDisplayMenuListView::MenuOrientation(void) {
- if (!tmplList) {
- return moVertical;
- }
- eOrientation orientation = tmplList->GetOrientation();
- if (orientation == orHorizontal)
- return moHorizontal;
- return moVertical;
-}
-
-void cDisplayMenuListView::Clear(void) {
- for (int i=0; i<itemCount; i++) {
- Lock();
- if (menuItems[i]) {
- delete menuItems[i];
- menuItems[i] = NULL;
- }
- Unlock();
- }
- oneColumn = true;
- for (int i=0; i<cSkinDisplayMenu::MaxTabs; i++) {
- tabs[i] = 0;
- tabWidths[i] = 0;
- }
-}
-
-void cDisplayMenuListView::AddDefaultMenuItem(int index, string *tabTexts, bool current, bool selectable) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- cDisplayMenuItemDefaultView *menuItem = dynamic_cast<cDisplayMenuItemDefaultView*>(menuItems[index]);
- if (!menuItem)
- return;
- menuItem->SetCurrent(current);
- menuItem->SetTabTexts(tabTexts);
- return;
- }
- for (int i=1; i<cSkinDisplayMenu::MaxTabs; i++) {
- if (tabTexts[i].size() > 0) {
- oneColumn = false;
- break;
- }
- }
- cDisplayMenuItemDefaultView *item = new cDisplayMenuItemDefaultView(tmplList, tabTexts, tabs, tabWidths, current, selectable);
- item->SetMenuCategory(GetDefaultMenuCategory());
- menuItems[index] = item;
-}
-
-string cDisplayMenuListView::AddMainMenuItem(int index, const char *itemText, bool current, bool selectable) {
- if (index >= itemCount)
- return "";
- if (menuItems[index]) {
- cDisplayMenuItemMainView *menuItem = dynamic_cast<cDisplayMenuItemMainView*>(menuItems[index]);
- if (!menuItem)
- return "";
- menuItem->SetCurrent(current);
- return menuItem->GetPluginName();
- }
- cDisplayMenuItemMainView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable);
- menuItems[index] = item;
- return item->GetPluginName();
-}
-
-void cDisplayMenuListView::AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- menuItems[index]->SetCurrent(current);
- return;
- }
- cDisplayMenuItemView *item = new cDisplayMenuItemMainView(tmplList, itemText, current, selectable);
- menuItems[index] = item;
-}
-
-void cDisplayMenuListView::AddSchedulesMenuItem(int index, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch,
- eMenuCategory cat, bool isEpgSearchFav, bool current, bool selectable, string dayseparator) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- menuItems[index]->SetCurrent(current);
- return;
- }
- cDisplayMenuItemView *item = new cDisplayMenuItemSchedulesView(tmplList, event, channel, timerMatch, cat, isEpgSearchFav, current, selectable, dayseparator);
- menuItems[index] = item;
-}
-
-void cDisplayMenuListView::AddChannelsMenuItem(int index, const cChannel *channel, bool withProvider, bool current, bool selectable) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- menuItems[index]->SetCurrent(current);
- return;
- }
- cDisplayMenuItemView *item = new cDisplayMenuItemChannelsView(tmplList, channel, withProvider, current, selectable);
- menuItems[index] = item;
-}
-
-void cDisplayMenuListView::AddTimersMenuItem(int index, const cTimer *timer, bool current, bool selectable) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- menuItems[index]->SetCurrent(current);
- return;
- }
- cDisplayMenuItemView *item = new cDisplayMenuItemTimersView(tmplList, timer, current, selectable);
- menuItems[index] = item;
-}
-
-void cDisplayMenuListView::AddRecordingMenuItem(int index, const cRecording *recording, int level, int total, int isNew, bool current, bool selectable) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- menuItems[index]->SetCurrent(current);
- return;
- }
- cDisplayMenuItemView *item = new cDisplayMenuItemRecordingView(tmplList, recording, level, total, isNew, current, selectable);
- menuItems[index] = item;
-}
-
-void cDisplayMenuListView::AddPluginMenuItem(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int index, bool current, bool selectable) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- menuItems[index]->SetCurrent(current);
- return;
- }
- cDisplayMenuItemView *item = new cDisplayMenuItemPluginView(tmplList, stringTokens, intTokens, loopTokens, index, current, selectable);
- menuItems[index] = item;
-}
-
-void cDisplayMenuListView::AddTracksMenuItem(int index, const char *title, bool current, bool selectable) {
- if (index >= itemCount)
- return;
- if (menuItems[index]) {
- menuItems[index]->SetCurrent(current);
- return;
- }
- cDisplayMenuItemView *item = new cDisplayMenuItemTrackView(tmplList, title, current, selectable, itemCount);
- menuItems[index] = item;
-}
-
-void cDisplayMenuListView::Render(void) {
- if (tabs[1] && oneColumn) {
- tabs[0] = 0;
- tabWidths[0] = tmplList->GetMenuItemWidth();
- for (int i=1; i<cSkinDisplayMenu::MaxTabs; i++) {
- tabs[i] = 0;
- tabWidths[i] = 0;
- }
- }
- int current = -1;
- for (int i=0; i<itemCount; i++) {
- Lock();
- if (menuItems[i] && menuItems[i]->Dirty()) {
- menuItems[i]->Clear();
- menuItems[i]->SetNumber(i);
- menuItems[i]->Prepare();
- menuItems[i]->SetTokens();
- menuItems[i]->Render();
- if (menuItems[i]->Current()) {
- current = i;
- } else {
- menuItems[i]->Stop();
- }
- }
- Unlock();
- }
- if (current > -1) {
- menuItems[current]->Start();
- }
-}
-
-void cDisplayMenuListView::Debug(void) {
- for (int i=0; i<itemCount; i++) {
- esyslog("skindesigner: item %d", i);
- if (menuItems[i]) {
- menuItems[i]->Debug();
- }
- }
-}
-
-string cDisplayMenuListView::GetDefaultMenuCategory(void) {
- if (cat == mcSchedule || cat == mcScheduleNow || cat == mcScheduleNext)
- return "schedule";
- else if (cat >= mcPluginSetup && cat <= mcSetupPlugins)
- return "setup";
- else if (cat == mcCommand)
- return "commands";
- return currentPlug;
-}
diff --git a/views/displaymenulistview.h b/views/displaymenulistview.h
deleted file mode 100644
index 3acba56..0000000
--- a/views/displaymenulistview.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef __DISPLAYMENULISTVIEW_H
-#define __DISPLAYMENULISTVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-#include "displaymenuitemview.h"
-
-class cDisplayMenuListView {
-private:
- cMutex mutex;
- cTemplateViewList *tmplList;
- eMenuCategory cat;
- string currentPlug;
- int itemCount;
- cDisplayMenuItemView **menuItems;
- int *tabs;
- int *tabWidths;
- bool oneColumn;
- string GetDefaultMenuCategory(void);
-public:
- cDisplayMenuListView(cTemplateViewList *tmplList, int count, eMenuCategory cat = mcUnknown, string currentPlug = "");
- virtual ~cDisplayMenuListView();
- void Lock(void) { mutex.Lock(); };
- void Unlock(void) { mutex.Unlock(); };
- void Clear(void);
- void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
- int GetMaxItems(void) { return itemCount; };
- int GetListWidth(void);
- eMenuOrientation MenuOrientation(void);
- void AddDefaultMenuItem(int index, string *tabTexts, bool current, bool selectable);
- string AddMainMenuItem(int index, const char *itemText, bool current, bool selectable);
- void AddSetupMenuItem(int index, const char *itemText, bool current, bool selectable);
- void AddSchedulesMenuItem(int index, const cEvent *event, const cChannel *channel, eTimerMatch timerMatch, eMenuCategory cat, bool isEpgSearchFav, bool current, bool selectable, string dayseparator);
- void AddChannelsMenuItem(int index, const cChannel *channel, bool withProvider, bool current, bool selectable);
- void AddTimersMenuItem(int index, const cTimer *timer, bool current, bool selectable);
- void AddRecordingMenuItem(int index, const cRecording *recording, int level, int total, int isNew, bool current, bool selectable);
- void AddPluginMenuItem(map<string,string> *stringTokens, map<string,int> *intTokens, map<string, vector<map<string,string> > > *loopTokens, int index, bool current, bool selectable);
- void AddTracksMenuItem(int index, const char *title, bool current, bool selectable);
- void Render(void);
- void Debug(void);
-};
-
-#endif //__DISPLAYMENULISTVIEW_H
diff --git a/views/displaymenurootview.c b/views/displaymenurootview.c
deleted file mode 100644
index 76d8b86..0000000
--- a/views/displaymenurootview.c
+++ /dev/null
@@ -1,732 +0,0 @@
-#define __STL_CONFIG_H
-#include <vdr/menu.h>
-#include "../displaymenu.h"
-#include "displaymenurootview.h"
-#include "displayviewelements.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-
-cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(rootView) {
- fadeOut = false;
- cat = mcUndefined;
- selectedPluginMainMenu = "";
- sortMode = msmUnknown;
- sortModeLast = msmUnknown;
- menuTitle = "";
- currentRecording = "";
- viewType = svUndefined;
- subView = NULL;
- subViewAvailable = false;
- subViewInit = true;
- pluginName = "";
- pluginMenu = -1;
- pluginMenuType = mtUnknown;
- pluginMenuChanged = false;
- view = NULL;
- listView = NULL;
- detailView = NULL;
- buttonTexts[0] = "";
- buttonTexts[1] = "";
- buttonTexts[2] = "";
- buttonTexts[3] = "";
- defaultBackgroundDrawn = false;
- defaultHeaderDrawn = false;
- defaultButtonsDrawn = false;
- defaultDateTimeDrawn = false;
- defaultTimeDrawn = false;
- defaultMessageDrawn = false;
- defaultSortmodeDrawn = false;
- DeleteOsdOnExit();
-}
-
-cDisplayMenuRootView::~cDisplayMenuRootView() {
- if (view) {
- delete view;
- view = NULL;
- }
- if (listView) {
- delete listView;
- listView = NULL;
- }
- if (detailView) {
- delete detailView;
- detailView = NULL;
- }
-}
-
-/*******************************************************************
-* Public Functions
-*******************************************************************/
-
-bool cDisplayMenuRootView::createOsd(void) {
- cRect osdSize = tmplView->GetOsdSize();
- bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
- cOsd::OsdTop() + osdSize.Y(),
- osdSize.Width(),
- osdSize.Height());
- return ok;
-}
-
-/* Categories:
--1 mcUndefined,
-0 mcUnknown,
-1 mcMain,
-2 mcSchedule,
-3 mcScheduleNow,
-4 mcScheduleNext,
-5 mcChannel,
-6 mcChannelEdit,
-7 mcTimer,
-8 mcTimerEdit,
-9 mcRecording,
-10 mcRecordingInfo,
-11 mcRecordingEdit,
-12 mcPlugin,
-13 mcPluginSetup,
-14 mcSetup,
-15 mcSetupOsd,
-16 mcSetupEpg,
-17 mcSetupDvb,
-18 mcSetupLnb,
-19 mcSetupCam,
-20 mcSetupRecord,
-21 mcSetupReplay,
-22 mcSetupMisc,
-23 mcSetupPlugins,
-24 mcCommand,
-25 mcEvent,
-26 mcText,
-27 mcFolder,
-28 mcCam
-*/
-
-void cDisplayMenuRootView::SetMenu(eMenuCategory menuCat, bool menuInit) {
- eSubView newViewType = svUndefined;
- cat = menuCat;
- subViewInit = true;
- bool isListView = true;
- if (menuCat != mcPlugin) {
- pluginName = "";
- pluginMenu = -1;
- pluginMenuType = mtUnknown;
- pluginMenuChanged = false;
- }
- switch (menuCat) {
- case mcMain:
- newViewType = svMenuMain;
- break;
- case mcSetup:
- newViewType = svMenuSetup;
- break;
- case mcSchedule:
- case mcScheduleNow:
- case mcScheduleNext:
- newViewType = svMenuSchedules;
- if (view)
- view->SetMenuCat(menuCat);
- break;
- case mcChannel:
- newViewType = svMenuChannels;
- break;
- case mcTimer:
- newViewType = svMenuTimers;
- break;
- case mcRecording:
- newViewType = svMenuRecordings;
- break;
- case mcEvent:
- newViewType = svMenuDetailedEpg;
- isListView = false;
- break;
- case mcRecordingInfo:
- newViewType = svMenuDetailedRecording;
- isListView = false;
- break;
- case mcText:
- newViewType = svMenuDetailedText;
- isListView = false;
- break;
- case mcPlugin:
- newViewType = svMenuPlugin;
- isListView = ( pluginMenuType == mtList ) ? true : false;
- break;
- default:
- newViewType = svMenuDefault;
- break;
- }
- if (newViewType != viewType || pluginMenuChanged) {
- if (newViewType == svMenuPlugin) {
- subView = tmplView->GetPluginView(pluginName, pluginMenu);
- if (!subView) {
- subViewAvailable = false;
- if (isListView)
- subView = tmplView->GetSubView(svMenuDefault);
- else
- subView = tmplView->GetSubView(svMenuDetailedText);
- } else {
- subViewAvailable = true;
- }
- } else {
- subView = tmplView->GetSubView(newViewType);
- if (!subView) {
- subViewAvailable = false;
- subView = tmplView->GetSubView(svMenuDefault);
- } else {
- subViewAvailable = true;
- }
- }
- //Cleanup
- if (view) {
- delete view;
- view = NULL;
- }
- if (listView) {
- delete listView;
- listView = NULL;
- }
- if (detailView) {
- delete detailView;
- detailView = NULL;
- }
- //Create new View
- switch (newViewType) {
- case svMenuMain:
- view = new cDisplayMenuMainView(subView, menuInit, currentRecording);
- break;
- case svMenuSchedules:
- if (subViewAvailable)
- view = new cDisplayMenuSchedulesView(subView, menuCat, menuInit);
- else
- view = new cDisplayMenuView(subView, menuInit);
- break;
- default:
- view = new cDisplayMenuView(subView, menuInit);
- }
- view->SetMenuCat(cat);
- view->SetButtonTexts(buttonTexts);
- //Cleanup root view
- ClearRootView();
- if (isListView) {
- //Create menu item list
- cTemplateViewList *tmplMenuItems = subView->GetViewList(vlMenuItem);
- if (!tmplMenuItems)
- return;
- listView = new cDisplayMenuListView(tmplMenuItems, -1, menuCat, selectedPluginMainMenu);
- } else {
- //Create detailed view
- detailView = new cDisplayMenuDetailView(subView);
- }
- viewType = newViewType;
- }
-}
-
-void cDisplayMenuRootView::SetSortMode(eMenuSortMode sortMode) {
- this->sortMode = sortMode;
- if (!view)
- return;
- view->SetSortMode(sortMode);
-}
-
-eMenuOrientation cDisplayMenuRootView::MenuOrientation(void) {
- if (!listView) {
- return moVertical;
- }
- return listView->MenuOrientation();
-}
-
-void cDisplayMenuRootView::CorrectDefaultMenu(void) {
- if (viewType > svMenuDefault && viewType != svMenuPlugin) {
- SetMenu(mcUnknown, true);
- }
-}
-
-void cDisplayMenuRootView::SetPluginMenu(string name, int menu, int type) {
- if (pluginName.compare(name) || menu != pluginMenu || type != pluginMenuType)
- pluginMenuChanged = true;
- else
- pluginMenuChanged = false;
- pluginName = name;
- pluginMenu = menu;
- pluginMenuType = (ePluginMenuType)type;
-}
-
-void cDisplayMenuRootView::SetTitle(const char *title) {
- menuTitle = title;
- if (view)
- view->SetTitle(title);
-}
-
-void cDisplayMenuRootView::SetButtonTexts(const char *Red, const char *Green, const char *Yellow, const char *Blue) {
- if (Red)
- buttonTexts[0] = Red;
- else
- buttonTexts[0] = "";
- if (Green)
- buttonTexts[1] = Green;
- else
- buttonTexts[1] = "";
- if (Yellow)
- buttonTexts[2] = Yellow;
- else
- buttonTexts[2] = "";
- if (Blue)
- buttonTexts[3] = Blue;
- else
- buttonTexts[3] = "";
- if (view)
- view->SetButtonTexts(buttonTexts);
-}
-
-void cDisplayMenuRootView::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
- if (listView) {
- listView->SetTabs(tab1, tab2, tab3, tab4, tab5);
- }
-}
-
-void cDisplayMenuRootView::SetMessage(eMessageType type, const char *text) {
- if (!view)
- return;
- if (!view->DrawMessage(type, text)) {
- defaultMessageDrawn = true;
- DrawMessage(type, text);
- } else {
- defaultMessageDrawn = false;
- }
-}
-
-void cDisplayMenuRootView::SetDetailedViewEvent(const cEvent *event) {
- if (!detailView) {
- if (viewType != svMenuDetailedEpg) {
- SetMenu(mcEvent, true);
- } else {
- detailView = new cDisplayMenuDetailView(subView);
- }
- }
- detailView->SetEvent(event);
-}
-
-void cDisplayMenuRootView::SetDetailedViewRecording(const cRecording *recording) {
- if (!detailView) {
- if (viewType != svMenuDetailedRecording) {
- SetMenu(mcRecordingInfo, true);
- } else {
- detailView = new cDisplayMenuDetailView(subView);
- }
- }
- detailView->SetRecording(recording);
-}
-
-void cDisplayMenuRootView::SetDetailedViewText(const char *text) {
- if (!detailView) {
- if (viewType != svMenuDetailedText) {
- SetMenu(mcText, true);
- } else {
- detailView = new cDisplayMenuDetailView(subView);
- }
- }
- detailView->SetText(text);
-}
-
-bool cDisplayMenuRootView::SetDetailedViewPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens) {
- if (!detailView) {
- SetMenu(mcPlugin, true);
- }
- if (!subViewAvailable) {
- return false;
- }
- detailView->SetPluginTokens(stringTokens, intTokens, loopTokens);
- return true;
-}
-
-void cDisplayMenuRootView::KeyInput(bool up, bool page) {
- if (!detailView)
- return;
-
- if (up && page) {
- detailView->KeyLeft();
- } else if (!up && page) {
- detailView->KeyRight();
- } else if (up && !page) {
- detailView->KeyUp();
- } else if (!up && !page) {
- detailView->KeyDown();
- }
-}
-
-void cDisplayMenuRootView::Clear(void) {
- if (view) {
- view->Lock();
- view->ClearChannel();
- view->ClearEpgSearchFavorite();
- view->Unlock();
- }
- if (listView) {
- listView->Lock();
- listView->Clear();
- listView->Unlock();
- }
- if (detailView) {
- delete detailView;
- detailView = NULL;
- }
-}
-
-void cDisplayMenuRootView::ClearRootView(void) {
- if (defaultBackgroundDrawn && view && view->BackgroundImplemented())
- ClearViewElement(veBackground);
- if (defaultHeaderDrawn)
- ClearViewElement(veHeader);
- if (defaultButtonsDrawn)
- ClearViewElement(veButtons);
- if (defaultDateTimeDrawn)
- ClearViewElement(veDateTime);
- if (defaultTimeDrawn)
- ClearViewElement(veTime);
- if (defaultMessageDrawn)
- ClearViewElement(veMessage);
- if (defaultSortmodeDrawn)
- ClearViewElement(veSortMode);
-}
-
-int cDisplayMenuRootView::GetMaxItems(void) {
- if (listView) {
- return listView->GetMaxItems();
- }
- //wrong menucat
- SetMenu(mcUnknown, true);
- return listView->GetMaxItems();
-}
-
-int cDisplayMenuRootView::GetListViewWidth(void) {
- if (listView) {
- return listView->GetListWidth();
- }
- return 0;
-}
-
-int cDisplayMenuRootView::GetTextAreaWidth(void) {
- if (!tmplView)
- return 1900;
- cTemplateView *tmplSubView = tmplView->GetSubView(svMenuDefault);
- if (!tmplSubView)
- return 1900;
- int areaWidth = tmplSubView->GetNumericParameter(ptWidth);
- if (areaWidth > 0)
- return areaWidth;
- return 1900;
-}
-
-cFont *cDisplayMenuRootView::GetTextAreaFont(void) {
- if (!tmplView)
- return NULL;
- cTemplateView *tmplSubViewDefault = tmplView->GetSubView(svMenuDefault);
- if (!tmplSubViewDefault)
- return NULL;
-
- cTemplateViewList *tmplViewList = tmplSubViewDefault->GetViewList(vlMenuItem);
- if (!tmplViewList)
- return NULL;
-
- return tmplViewList->GetTextAreaFont();
-}
-
-
-void cDisplayMenuRootView::Render(void) {
- if (!view)
- return;
- view->Lock();
- view->DrawDebugGrid();
- if (!view->DrawBackground()) {
- defaultBackgroundDrawn = true;
- DrawBackground();
- } else {
- defaultBackgroundDrawn = false;
- }
-
- if (!view->DrawHeader()) {
- defaultHeaderDrawn = true;
- DrawHeader();
- } else {
- defaultHeaderDrawn = false;
- }
-
- if (!view->DrawSortMode()) {
- defaultSortmodeDrawn = true;
- DrawSortMode();
- } else {
- defaultSortmodeDrawn = false;
- }
-
- if (!view->DrawColorButtons()) {
- defaultButtonsDrawn = true;
- DrawColorButtons();
- } else {
- defaultButtonsDrawn = false;
- }
-
- view->DrawStaticViewElements();
- view->DrawDynamicViewElements();
- view->Unlock();
-}
-
-void cDisplayMenuRootView::RenderMenuItems(void) {
- if (listView)
- listView->Render();
-}
-
-void cDisplayMenuRootView::RenderDetailView(void) {
- if (detailView)
- detailView->Render();
-}
-
-void cDisplayMenuRootView::RenderMenuScrollBar(int Total, int Offset) {
- if (!listView)
- return;
- view->DrawScrollbar(listView->GetMaxItems(), Total, Offset);
-}
-
-bool cDisplayMenuRootView::RenderDynamicElements(void) {
- if (!view)
- return false;
- bool updated = false;
- bool implemented = false;
- if (view->DrawTime(subViewInit, implemented)) {
- defaultTimeDrawn = false;
- updated = true;
- } else if (!implemented && DrawTime(subViewInit)) {
- defaultTimeDrawn = true;
- updated = true;
- }
-
- implemented = false;
- if (view->DrawDateTime(subViewInit, implemented)) {
- defaultDateTimeDrawn = false;
- } else if (!implemented) {
- DrawDateTime(subViewInit);
- defaultDateTimeDrawn = true;
- }
-
- if (view->DrawDynamicViewElements()) {
- updated = true;
- }
-
- if (subViewInit) {
- subViewInit = false;
- return true;
- }
- subViewInit = false;
- return updated;
-}
-
-/*******************************************************************
-* Private Functions
-*******************************************************************/
-
-void cDisplayMenuRootView::DrawBackground(void) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- DrawViewElement(veBackground, &stringTokens, &intTokens);
-}
-
-void cDisplayMenuRootView::DrawHeader(void) {
- if (!ExecuteViewElement(veHeader)) {
- return;
- }
- if (DetachViewElement(veHeader)) {
- cViewElement *viewElement = GetViewElement(veHeader);
- if (!viewElement) {
- viewElement = new cViewElementMenuHeader(tmplView->GetViewElement(veHeader), cat, menuTitle);
- AddViewElement(veHeader, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
- ClearViewElement(veHeader);
- DrawViewElement(veHeader, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayMenuRootView::DrawDateTime(bool forced) {
- if (!ExecuteViewElement(veDateTime)) {
- return;
- }
-
- if (DetachViewElement(veDateTime)) {
- cViewElement *viewElement = GetViewElement(veDateTime);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veDateTime), this);
- viewElement->SetCallback(veDateTime, &cDisplayMenuRootView::SetDate);
- AddViewElement(veDateTime, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetDate(forced, stringTokens, intTokens))
- return;
- ClearViewElement(veDateTime);
- DrawViewElement(veDateTime, &stringTokens, &intTokens);
- }
-}
-
-bool cDisplayMenuRootView::DrawTime(bool forced) {
- if (!ExecuteViewElement(veTime)) {
- return false;
- }
-
- if (DetachViewElement(veTime)) {
- cViewElement *viewElement = GetViewElement(veTime);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veTime), this);
- viewElement->SetCallback(veTime, &cDisplayMenuRootView::SetTime);
- AddViewElement(veTime, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- if (!viewElement->Render())
- return false;
- }
- } else {
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetTime(forced, stringTokens, intTokens)) {
- return false;
- }
-
- ClearViewElement(veTime);
- DrawViewElement(veTime, &stringTokens, &intTokens);
- }
- return true;
-}
-
-void cDisplayMenuRootView::DrawSortMode(void) {
- if (!ExecuteViewElement(veSortMode)) {
- return;
- }
- if (sortMode == msmUnknown) {
- if (sortModeLast != msmUnknown)
- ClearViewElement(veSortMode);
- sortModeLast = msmUnknown;
- return;
- }
- if (sortMode == sortModeLast) {
- return;
- }
- sortModeLast = sortMode;
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- bool sortNumber = (sortMode == msmNumber) ? true : false;
- bool sortName = (sortMode == msmName) ? true : false;
- bool sortTime = (sortMode == msmTime) ? true : false;
- bool sortProvider = (sortMode == msmProvider) ? true : false;
-
- intTokens.insert(pair<string, int>("sortnumber", sortNumber));
- intTokens.insert(pair<string, int>("sortname", sortName));
- intTokens.insert(pair<string, int>("sorttime", sortTime));
- intTokens.insert(pair<string, int>("sortprovider", sortProvider));
-
- ClearViewElement(veSortMode);
- DrawViewElement(veSortMode, &stringTokens, &intTokens);
- return;
-}
-
-void cDisplayMenuRootView::DrawColorButtons(void) {
- if (!ExecuteViewElement(veButtons)) {
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- stringTokens.insert(pair<string,string>("red", buttonTexts[0]));
- stringTokens.insert(pair<string,string>("green", buttonTexts[1]));
- stringTokens.insert(pair<string,string>("yellow", buttonTexts[2]));
- stringTokens.insert(pair<string,string>("blue", buttonTexts[3]));
-
- int colorKeys[4] = { Setup.ColorKey0, Setup.ColorKey1, Setup.ColorKey2, Setup.ColorKey3 };
-
- for (int button = 1; button < 5; button++) {
- string red = *cString::sprintf("red%d", button);
- string green = *cString::sprintf("green%d", button);
- string yellow = *cString::sprintf("yellow%d", button);
- string blue = *cString::sprintf("blue%d", button);
- bool isRed = false;
- bool isGreen = false;
- bool isYellow = false;
- bool isBlue = false;
- switch (colorKeys[button-1]) {
- case 0:
- isRed = true;
- break;
- case 1:
- isGreen = true;
- break;
- case 2:
- isYellow = true;
- break;
- case 3:
- isBlue = true;
- break;
- default:
- break;
- }
- intTokens.insert(pair<string, int>(red, isRed));
- intTokens.insert(pair<string, int>(green, isGreen));
- intTokens.insert(pair<string, int>(yellow, isYellow));
- intTokens.insert(pair<string, int>(blue, isBlue));
- }
-
- ClearViewElement(veButtons);
- DrawViewElement(veButtons, &stringTokens, &intTokens);
-}
-
-void cDisplayMenuRootView::DrawMessage(eMessageType type, const char *text) {
- if (!text) {
- if (DetachViewElement(veMessage))
- DestroyDetachedViewElement(veMessage);
- else
- ClearViewElement(veMessage);
- return;
- }
-
- if (DetachViewElement(veMessage)) {
- cViewElement *viewElement = GetViewElement(veMessage);
- if (!viewElement) {
- viewElement = new cViewElementMenuMessage(tmplView->GetViewElement(veMessage), type, text);
- AddViewElement(veMessage, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- SetMenuMessage(type, text, stringTokens, intTokens);
- ClearViewElement(veMessage);
- DrawViewElement(veMessage, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayMenuRootView::Action(void) {
- if (!view)
- return;
- SetInitFinished();
- Render();
- view->Start();
- FadeIn();
- DoFlush();
-}
diff --git a/views/displaymenurootview.h b/views/displaymenurootview.h
deleted file mode 100644
index 294b6ee..0000000
--- a/views/displaymenurootview.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef __DISPLAYMENUROOTVIEW_H
-#define __DISPLAYMENUROOTVIEW_H
-
-#include "../libtemplate/template.h"
-#include "displaymenuview.h"
-#include "displaymenulistview.h"
-#include "displaymenudetailview.h"
-
-enum ePluginMenuType {
- mtList,
- mtText,
- mtUnknown
-};
-
-class cDisplayMenuRootView : public cView, public cViewHelpers {
-private:
- eMenuCategory cat;
- string selectedPluginMainMenu;
- eMenuSortMode sortMode;
- eMenuSortMode sortModeLast;
- eSubView viewType;
- cTemplateView *subView;
- bool subViewAvailable;
- bool subViewInit;
- string pluginName;
- int pluginMenu;
- ePluginMenuType pluginMenuType;
- bool pluginMenuChanged;
- cDisplayMenuView *view;
- cDisplayMenuListView *listView;
- cDisplayMenuDetailView *detailView;
- string currentRecording;
- string menuTitle;
- string buttonTexts[4];
- bool defaultBackgroundDrawn;
- bool defaultHeaderDrawn;
- bool defaultButtonsDrawn;
- bool defaultDateTimeDrawn;
- bool defaultTimeDrawn;
- bool defaultMessageDrawn;
- bool defaultSortmodeDrawn;
- void DrawBackground(void);
- void DrawHeader(void);
- void DrawDateTime(bool forced);
- bool DrawTime(bool forced);
- void DrawSortMode(void);
- void DrawColorButtons(void);
- void DrawMessage(eMessageType type, const char *text);
- void ClearRootView(void);
- virtual void Action(void);
-public:
- cDisplayMenuRootView(cTemplateView *rootView);
- virtual ~cDisplayMenuRootView();
- bool createOsd(void);
- void SetMenu(eMenuCategory menuCat, bool menuInit);
- void SetSelectedPluginMainMenu(string name) { selectedPluginMainMenu = name; };
- void SetSortMode(eMenuSortMode sortMode);
- eMenuOrientation MenuOrientation(void);
- void SetCurrentRecording(string rec) { currentRecording = rec; };
- void CorrectDefaultMenu(void);
- void SetPluginMenu(string name, int menu, int type);
- void SetTitle(const char *title);
- void SetChannel(const cChannel *channel) { view->SetChannel(channel); };
- const cChannel *GetChannel(void) { return view->GetChannel(); };
- void SetEpgSearchFavorite(void) { if (view) view->SetEpgSearchFavorite(); };
- void SetButtonTexts(const char *Red, const char *Green, const char *Yellow, const char *Blue);
- void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
- void SetMessage(eMessageType type, const char *text);
- void SetDetailedViewEvent(const cEvent *event);
- void SetDetailedViewRecording(const cRecording *recording);
- void SetDetailedViewText(const char *text);
- bool SetDetailedViewPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens);
- void KeyInput(bool up, bool page);
- void Clear(void);
- int GetMaxItems(void);
- int GetListViewWidth(void);
- int GetTextAreaWidth(void);
- cFont *GetTextAreaFont(void);
- bool SubViewAvailable(void) { return subViewAvailable; };
- cDisplayMenuListView *GetListView(void) { return listView; };
- void Render(void);
- void RenderMenuItems(void);
- void RenderDetailView(void);
- void RenderMenuScrollBar(int Total, int Offset);
- bool RenderDynamicElements(void);
-};
-#endif //__DISPLAYMENUROOTVIEW_H
diff --git a/views/displaymenutabview.c b/views/displaymenutabview.c
deleted file mode 100644
index ebf0097..0000000
--- a/views/displaymenutabview.c
+++ /dev/null
@@ -1,125 +0,0 @@
-#include "displaymenutabview.h"
-
-
-cDisplayMenuTabView::cDisplayMenuTabView(cTemplateViewTab *tmplTab) : cView(tmplTab) {
-}
-
-cDisplayMenuTabView::~cDisplayMenuTabView() {
-}
-
-void cDisplayMenuTabView::SetTokens(map < string, int > *intTokens, map < string, string > *stringTokens, map < string, vector< map< string, string > > > *loopTokens) {
- this->intTokens = intTokens;
- this->stringTokens = stringTokens;
- this->loopTokens = loopTokens;
-}
-
-void cDisplayMenuTabView::Clear(void) {
- Fill(0, clrTransparent);
-}
-
-void cDisplayMenuTabView::CreateTab(void) {
- //Create Pixmap
- if (!PixmapExists(0)) {
- cSize drawportSize;
- scrolling = tmplTab->CalculateDrawPortSize(drawportSize, loopTokens);
- if (scrolling) {
- CreateScrollingPixmap(0, tmplTab, drawportSize);
- scrollingPix = 0;
- scrollOrientation = orVertical;
- scrollMode = smNone;
- } else {
- CreateViewPixmap(0, tmplTab);
- }
- }
-}
-
-
-void cDisplayMenuTabView::Render(void) {
- if (tmplTab->DoDebug()) {
- tmplTab->Debug();
- }
- //Draw Tab, flushing every loop
- DrawPixmap(0, tmplTab, loopTokens, true);
-}
-
-bool cDisplayMenuTabView::KeyUp(void) {
- if (!scrolling)
- return false;
- int scrollStep = tmplTab->GetScrollStep();
- int aktHeight = DrawportY(0);
- if (aktHeight >= 0) {
- return false;
- }
- int newY = aktHeight + scrollStep;
- if (newY > 0)
- newY = 0;
- SetDrawPortPoint(0, cPoint(0, newY));
- return true;
-}
-
-bool cDisplayMenuTabView::KeyDown(void) {
- if (!scrolling)
- return false;
-
- int scrollStep = tmplTab->GetScrollStep();
- int aktHeight = DrawportY(0);
- int totalHeight = DrawportHeight(0);
- int screenHeight = Height(0);
-
- if (totalHeight - ((-1)*aktHeight) == screenHeight) {
- return false;
- }
- int newY = aktHeight - scrollStep;
- if ((-1)*newY > totalHeight - screenHeight)
- newY = (-1)*(totalHeight - screenHeight);
- SetDrawPortPoint(0, cPoint(0, newY));
- return true;
-}
-
-bool cDisplayMenuTabView::KeyLeft(void) {
- if (!scrolling)
- return false;
- if (!PixmapExists(0))
- return false;
- int aktHeight = DrawportY(0);
- int screenHeight = Height(0);
- int newY = aktHeight + screenHeight;
- if (newY > 0)
- newY = 0;
- SetDrawPortPoint(0, cPoint(0, newY));
- return true;
-}
-
-bool cDisplayMenuTabView::KeyRight(void) {
- if (!scrolling)
- return false;
- if (!PixmapExists(0))
- return false;
- int aktHeight = DrawportY(0);
- int screenHeight = Height(0);
- int totalHeight = DrawportHeight(0);
- int newY = aktHeight - screenHeight;
- if ((-1)*newY > totalHeight - screenHeight)
- newY = (-1)*(totalHeight - screenHeight);
- SetDrawPortPoint(0, cPoint(0, newY));
- return true;
-}
-
-void cDisplayMenuTabView::GetScrollbarPosition(int &barTop, int &barHeight) {
- int y = (-1)*DrawportY(0);
- int totalHeight = DrawportHeight(0);
- int screenHeight = Height(0);
- if (totalHeight == 0)
- return;
- if (totalHeight <= screenHeight)
- barHeight = 1000;
- else {
- barHeight = (double)screenHeight / (double) totalHeight * 1000;
- }
- barTop = (double)y / (double) totalHeight * 1000;
-}
-
-void cDisplayMenuTabView::Action(void) {
- Render();
- DoFlush();
-} \ No newline at end of file
diff --git a/views/displaymenutabview.h b/views/displaymenutabview.h
deleted file mode 100644
index 70a7447..0000000
--- a/views/displaymenutabview.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __DISPLAYMENUTABVIEW_H
-#define __DISPLAYMENUTABVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-
-class cDisplayMenuTabView : public cView {
-private:
- map < string, string > *stringTokens;
- map < string, int > *intTokens;
- map < string, vector< map< string, string > > > *loopTokens;
- void Action(void);
-public:
- cDisplayMenuTabView(cTemplateViewTab *tmplTab);
- virtual ~cDisplayMenuTabView();
- void SetTokens(map < string, int > *intTokens, map < string, string > *stringTokens, map < string, vector< map< string, string > > > *loopTokens);
- void Clear(void);
- void CreateTab(void);
- void Render(void);
- bool KeyUp(void);
- bool KeyDown(void);
- bool KeyLeft(void);
- bool KeyRight(void);
- void GetScrollbarPosition(int &barTop, int &barHeight);
-};
-
-#endif //__DISPLAYMENUTABVIEW_H
diff --git a/views/displaymenuview.c b/views/displaymenuview.c
deleted file mode 100644
index d5abe7d..0000000
--- a/views/displaymenuview.c
+++ /dev/null
@@ -1,673 +0,0 @@
-#define __STL_CONFIG_H
-#include <vdr/menu.h>
-#include <vdr/videodir.h>
-#include "../displaymenu.h"
-#include "displaymenuview.h"
-#include "displayviewelements.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-#include "../services/scraper2vdr.h"
-
-cDisplayMenuView::cDisplayMenuView(cTemplateView *tmplView, bool menuInit) : cView(tmplView) {
- if (!menuInit)
- SetFadeTime(0);
- fadeOut = false;
- cat = mcUndefined;
- sortMode = msmUnknown;
- sortModeLast = msmUnknown;
- buttonTexts = NULL;
-}
-
-cDisplayMenuView::~cDisplayMenuView() {
-}
-
-bool cDisplayMenuView::DrawBackground(void) {
- if (!ExecuteViewElement(veBackground)) {
- return false;
- }
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- DrawViewElement(veBackground, &stringTokens, &intTokens);
- return true;
-}
-
-bool cDisplayMenuView::DrawHeader(void) {
- if (!ExecuteViewElement(veHeader)) {
- return false;
- }
- if (DetachViewElement(veHeader)) {
- cViewElement *viewElement = GetViewElement(veHeader);
- if (!viewElement) {
- viewElement = new cViewElementMenuHeader(tmplView->GetViewElement(veHeader), cat, menuTitle);
- AddViewElement(veHeader, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
- ClearViewElement(veHeader);
- DrawViewElement(veHeader, &stringTokens, &intTokens);
- }
- return true;
-}
-
-bool cDisplayMenuView::DrawDateTime(bool forced, bool &implemented) {
- if (!ExecuteViewElement(veDateTime)) {
- return false;
- }
- implemented = true;
- if (DetachViewElement(veDateTime)) {
- cViewElement *viewElement = GetViewElement(veDateTime);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veDateTime), this);
- viewElement->SetCallback(veDateTime, &cDisplayMenuView::SetDate);
- AddViewElement(veDateTime, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- if (!viewElement->Render())
- return false;
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetDate(forced, stringTokens, intTokens)) {
- return false;
- }
-
- ClearViewElement(veDateTime);
- DrawViewElement(veDateTime, &stringTokens, &intTokens);
- }
- return true;
-}
-
-bool cDisplayMenuView::DrawTime(bool forced, bool &implemented) {
- if (!ExecuteViewElement(veTime)) {
- return false;
- }
- implemented = true;
-
- if (DetachViewElement(veTime)) {
- cViewElement *viewElement = GetViewElement(veTime);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veTime), this);
- viewElement->SetCallback(veTime, &cDisplayMenuView::SetTime);
- AddViewElement(veTime, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- if (!viewElement->Render())
- return false;
- }
- } else {
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetTime(forced, stringTokens, intTokens)) {
- return false;
- }
-
- ClearViewElement(veTime);
- DrawViewElement(veTime, &stringTokens, &intTokens);
- }
- return true;
-}
-
-bool cDisplayMenuView::DrawColorButtons(void) {
- if (!ExecuteViewElement(veButtons)) {
- return false;
- }
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- stringTokens.insert(pair<string,string>("red", buttonTexts ? buttonTexts[0] : ""));
- stringTokens.insert(pair<string,string>("green", buttonTexts ? buttonTexts[1]: ""));
- stringTokens.insert(pair<string,string>("yellow", buttonTexts ? buttonTexts[2]: ""));
- stringTokens.insert(pair<string,string>("blue", buttonTexts ? buttonTexts[3] : ""));
-
- int colorKeys[4] = { Setup.ColorKey0, Setup.ColorKey1, Setup.ColorKey2, Setup.ColorKey3 };
-
- for (int button = 1; button < 5; button++) {
- string red = *cString::sprintf("red%d", button);
- string green = *cString::sprintf("green%d", button);
- string yellow = *cString::sprintf("yellow%d", button);
- string blue = *cString::sprintf("blue%d", button);
- bool isRed = false;
- bool isGreen = false;
- bool isYellow = false;
- bool isBlue = false;
- switch (colorKeys[button-1]) {
- case 0:
- isRed = true;
- break;
- case 1:
- isGreen = true;
- break;
- case 2:
- isYellow = true;
- break;
- case 3:
- isBlue = true;
- break;
- default:
- break;
- }
- intTokens.insert(pair<string, int>(red, isRed));
- intTokens.insert(pair<string, int>(green, isGreen));
- intTokens.insert(pair<string, int>(yellow, isYellow));
- intTokens.insert(pair<string, int>(blue, isBlue));
- }
-
- ClearViewElement(veButtons);
- DrawViewElement(veButtons, &stringTokens, &intTokens);
- return true;
-}
-
-bool cDisplayMenuView::DrawMessage(eMessageType type, const char *text) {
- if (!ExecuteViewElement(veMessage)) {
- return false;
- }
- if (!text) {
- if (DetachViewElement(veMessage))
- DestroyDetachedViewElement(veMessage);
- else
- ClearViewElement(veMessage);
- return true;
- }
-
- if (DetachViewElement(veMessage)) {
- cViewElement *viewElement = GetViewElement(veMessage);
- if (!viewElement) {
- viewElement = new cViewElementMenuMessage(tmplView->GetViewElement(veMessage), type, text);
- AddViewElement(veMessage, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- SetMenuMessage(type, text, stringTokens, intTokens);
- ClearViewElement(veMessage);
- DrawViewElement(veMessage, &stringTokens, &intTokens);
- }
- return true;
-}
-
-void cDisplayMenuView::DrawScrollbar(int numMax, int numDisplayed, int offset) {
- if (!ExecuteViewElement(veScrollbar)) {
- return;
- }
- map < string, string > stringTokens;
- map < string, int > intTokens;
- if (numDisplayed < 1)
- return;
-
- int barHeight = 0;
- if (numDisplayed < numMax)
- barHeight = 1000;
- else
- barHeight = (double)numMax * 1000 / (double)numDisplayed;
-
- int barOffset = (double)offset * 1000 / (double)numDisplayed;
-
- intTokens.insert(pair<string, int>("height", barHeight));
- intTokens.insert(pair<string, int>("offset", barOffset));
- intTokens.insert(pair<string, int>("hasprev", (offset == 0) ? 0 : 1));
- intTokens.insert(pair<string, int>("hasnext", (offset + numMax == numDisplayed) ? 0 : 1));
-
- ClearViewElement(veScrollbar);
- DrawViewElement(veScrollbar, &stringTokens, &intTokens);
-}
-
-bool cDisplayMenuView::DrawSortMode(void) {
- if (!ExecuteViewElement(veSortMode)) {
- return false;
- }
- if (sortMode == msmUnknown) {
- if (sortModeLast != msmUnknown)
- ClearViewElement(veSortMode);
- sortModeLast = msmUnknown;
- return true;
- }
- if (sortMode == sortModeLast)
- return true;
- sortModeLast = sortMode;
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- bool sortNumber = (sortMode == msmNumber) ? true : false;
- bool sortName = (sortMode == msmName) ? true : false;
- bool sortTime = (sortMode == msmTime) ? true : false;
- bool sortProvider = (sortMode == msmProvider) ? true : false;
-
- intTokens.insert(pair<string, int>("sortnumber", sortNumber));
- intTokens.insert(pair<string, int>("sortname", sortName));
- intTokens.insert(pair<string, int>("sorttime", sortTime));
- intTokens.insert(pair<string, int>("sortprovider", sortProvider));
-
- ClearViewElement(veSortMode);
- DrawViewElement(veSortMode, &stringTokens, &intTokens);
- return true;
-}
-
-bool cDisplayMenuView::BackgroundImplemented(void) {
- if (!ExecuteViewElement(veBackground)) {
- return false;
- }
- return true;
-}
-
-
-void cDisplayMenuView::Action(void) {
- SetInitFinished();
- FadeIn();
- DoFlush();
-}
-
-/************************************************************************
-* cDisplayMenuMainView
-************************************************************************/
-
-cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording) : cDisplayMenuView(tmplView, menuInit) {
- this->currentRecording = currentRecording;
- initial = true;
- InitDevices();
-}
-
-cDisplayMenuMainView::~cDisplayMenuMainView() {
- CancelSave();
-}
-
-void cDisplayMenuMainView::DrawStaticViewElements(void) {
- DrawTimers();
- DrawLastRecordings();
- DrawDiscUsage();
- DrawTemperatures();
- DrawCurrentSchedule();
- DrawCurrentWeather();
-}
-
-bool cDisplayMenuMainView::DrawDynamicViewElements(void) {
- bool loadChanged = DrawLoad();
- bool memChanged = DrawMemory();
- bool vdrChanged = DrawVdrStats();
- bool devicesChanged = DrawDevices();
- bool customTokensChanged = DrawCustomTokens();
- initial = false;
- return loadChanged || memChanged || vdrChanged || devicesChanged || customTokensChanged;
-}
-
-void cDisplayMenuMainView::DrawTimers(void) {
- if (!ExecuteViewElement(veTimers)) {
- return;
- }
- if (DetachViewElement(veTimers)) {
- cViewElement *viewElement = GetViewElement(veTimers);
- if (!viewElement) {
- viewElement = new cViewElementTimers(tmplView->GetViewElement(veTimers));
- AddViewElement(veTimers, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- 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);
- }
-}
-
-void cDisplayMenuMainView::DrawLastRecordings(void) {
- if (!ExecuteViewElement(veLastRecordings)) {
- return;
- }
-
- if (DetachViewElement(veLastRecordings)) {
- cViewElement *viewElement = GetViewElement(veLastRecordings);
- if (!viewElement) {
- viewElement = new cViewElementLastRecordings(tmplView->GetViewElement(veLastRecordings));
- AddViewElement(veLastRecordings, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- map < string, vector< map< string, string > > > recordingLoopTokens;
- vector< map< string, string > > lastRecordings;
-
- SetLastRecordings(&intTokens, &stringTokens, &lastRecordings);
- recordingLoopTokens.insert(pair< string, vector< map< string, string > > >("recordings", lastRecordings));
-
- ClearViewElement(veLastRecordings);
- DrawViewElement(veLastRecordings, &stringTokens, &intTokens, &recordingLoopTokens);
- }
-}
-
-void cDisplayMenuMainView::DrawDiscUsage(void) {
- if (!ExecuteViewElement(veDiscUsage)) {
- return;
- }
- if (DetachViewElement(veDiscUsage)) {
- cViewElement *viewElement = GetViewElement(veDiscUsage);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veDiscUsage), this);
- viewElement->SetCallback(veDiscUsage, &cDisplayMenuMainView::SetDiscUsage);
- AddViewElement(veDiscUsage, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- SetDiscUsage(false, stringTokens, intTokens);
- ClearViewElement(veDiscUsage);
- DrawViewElement(veDiscUsage, &stringTokens, &intTokens);
- }
-}
-
-bool cDisplayMenuMainView::DrawLoad(void) {
- if (!ExecuteViewElement(veSystemLoad)) {
- return false;
- }
- bool changed = false;
- if (DetachViewElement(veSystemLoad)) {
- cViewElement *viewElement = GetViewElement(veSystemLoad);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veSystemLoad), this);
- viewElement->SetCallback(veSystemLoad, &cDisplayMenuMainView::SetSystemLoad);
- AddViewElement(veSystemLoad, viewElement);
- viewElement->Start();
- changed = true;
- } else {
- if (!viewElement->Starting())
- changed = viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- changed = SetSystemLoad(false, stringTokens, intTokens);
- if (changed) {
- ClearViewElement(veSystemLoad);
- DrawViewElement(veSystemLoad, &stringTokens, &intTokens);
- }
- }
- return changed;
-}
-
-bool cDisplayMenuMainView::DrawMemory(void) {
- if (!ExecuteViewElement(veSystemMemory)) {
- return false;
- }
- bool changed = false;
- if (DetachViewElement(veSystemMemory)) {
- cViewElement *viewElement = GetViewElement(veSystemMemory);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veSystemMemory), this);
- viewElement->SetCallback(veSystemMemory, &cDisplayMenuMainView::SetSystemMemory);
- 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(false, stringTokens, intTokens);
- if (changed) {
- ClearViewElement(veSystemMemory);
- DrawViewElement(veSystemMemory, &stringTokens, &intTokens);
- }
- }
- return changed;
-}
-
-bool cDisplayMenuMainView::DrawVdrStats(void) {
- if (!ExecuteViewElement(veVDRStats)) {
- return false;
- }
- bool changed = false;
- if (DetachViewElement(veVDRStats)) {
- cViewElement *viewElement = GetViewElement(veVDRStats);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veVDRStats), this);
- viewElement->SetCallback(veVDRStats, &cDisplayMenuMainView::SetVDRStats);
- AddViewElement(veVDRStats, viewElement);
- viewElement->Start();
- changed = true;
- } else {
- if (!viewElement->Starting())
- changed = viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- changed = SetVDRStats(false, stringTokens, intTokens);
- if (changed) {
- ClearViewElement(veVDRStats);
- DrawViewElement(veVDRStats, &stringTokens, &intTokens);
- }
- }
- return changed;
-}
-
-void cDisplayMenuMainView::DrawTemperatures(void) {
- if (!ExecuteViewElement(veTemperatures)) {
- return;
- }
- if (DetachViewElement(veTemperatures)) {
- cViewElement *viewElement = GetViewElement(veTemperatures);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veTemperatures), this);
- viewElement->SetCallback(veTemperatures, &cDisplayMenuMainView::SetSystemTemperatures);
- AddViewElement(veTemperatures, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- bool changed = SetSystemTemperatures(false, stringTokens, intTokens);
- if (changed) {
- ClearViewElement(veTemperatures);
- DrawViewElement(veTemperatures, &stringTokens, &intTokens);
- }
- }
-}
-
-bool cDisplayMenuMainView::DrawDevices(void) {
- if (!ExecuteViewElement(veDevices)) {
- return false;
- }
- string mode = tmplView->GetViewElementMode(veDevices);
- bool light = false;
- if (!mode.compare("light")) {
- light = true;
- }
- bool changed = false;
- if (DetachViewElement(veDevices)) {
- cViewElement *viewElement = GetViewElement(veDevices);
- if (!viewElement) {
- viewElement = new cViewElementDevices(light, 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;
-
- changed = SetDevices(initial, light, &intTokens, &devices);
- if (!changed)
- return false;
-
- 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;
- }
- if (DetachViewElement(veCurrentSchedule)) {
- cViewElement *viewElement = GetViewElement(veCurrentSchedule);
- if (!viewElement) {
- viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule), currentRecording);
- AddViewElement(veCurrentSchedule, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- SetCurrentSchedule(currentRecording, stringTokens, intTokens);
- ClearViewElement(veCurrentSchedule);
- DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayMenuMainView::DrawCurrentWeather(void) {
- if (!ExecuteViewElement(veCurrentWeather)) {
- return;
- }
- if (DetachViewElement(veCurrentWeather)) {
- cViewElement *viewElement = GetViewElement(veCurrentWeather);
- if (!viewElement) {
- viewElement = new cViewElement(tmplView->GetViewElement(veCurrentWeather), this);
- viewElement->SetCallback(veCurrentWeather, &cDisplayMenuMainView::SetCurrentWeatherTokens);
- AddViewElement(veCurrentWeather, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting())
- viewElement->Render();
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- ClearViewElement(veCurrentWeather);
- if (!SetCurrentWeatherTokens(false, stringTokens, intTokens)){
- return;
- }
- DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
- }
-}
-
-bool cDisplayMenuMainView::DrawCustomTokens(void) {
- if (!ExecuteViewElement(veCustomTokens)) {
- return false;
- }
- if (!tmplView)
- return false;
-
- if (!initial && !tmplView->CustomTokenChange())
- return false;
-
- 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();
- ClearViewElement(veCustomTokens);
- DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
- }
- return true;
-}
-
-/************************************************************************
-* cDisplayMenuSchedulesView
-************************************************************************/
-
-cDisplayMenuSchedulesView::cDisplayMenuSchedulesView(cTemplateView *tmplView, eMenuCategory menuCat, bool menuInit) : cDisplayMenuView(tmplView, menuInit) {
- cat = menuCat;
- channel = NULL;
- isEpgSearchFavoritesMenu = false;
-}
-
-cDisplayMenuSchedulesView::~cDisplayMenuSchedulesView() {
- CancelSave();
-}
-
-bool cDisplayMenuSchedulesView::DrawHeader(void) {
- if (!ExecuteViewElement(veHeader)) {
- return false;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- intTokens.insert(pair<string,int>("whatson", (cat == mcSchedule)&&(!isEpgSearchFavoritesMenu) ? true: false));
- intTokens.insert(pair<string,int>("whatsonnow", (cat == mcScheduleNow) ? true: false));
- intTokens.insert(pair<string,int>("whatsonnext", (cat == mcScheduleNext) ? true: false));
- intTokens.insert(pair<string,int>("whatsonfavorites", isEpgSearchFavoritesMenu ? true: false));
-
- stringTokens.insert(pair<string,string>("title", menuTitle));
- stringTokens.insert(pair<string,string>("vdrversion", VDRVERSION));
- if (channel) {
- stringTokens.insert(pair<string,string>("channelnumber", *cString::sprintf("%d", channel->Number())));
- stringTokens.insert(pair<string,string>("channelname", channel->Name()));
- string channelID = *(channel->GetChannelID().ToString());
- stringTokens.insert(pair<string,string>("channelid", channelID));
- intTokens.insert(pair<string, int>("channellogoexists", imgCache->LogoExists(channelID)));
- } else {
- stringTokens.insert(pair<string,string>("channelnumber", ""));
- stringTokens.insert(pair<string,string>("channelname", ""));
- stringTokens.insert(pair<string,string>("channelid", ""));
- intTokens.insert(pair<string, int>("channellogoexists", 0));
- }
- bool hasIcon = false;
- string icon = imgCache->GetIconName(menuTitle, cat);
- if (icon.size() > 0)
- hasIcon = true;
-
- stringTokens.insert(pair<string,string>("icon", icon));
- intTokens.insert(pair<string,int>("hasicon", hasIcon));
- ClearViewElement(veHeader);
- DrawViewElement(veHeader, &stringTokens, &intTokens);
- return true;
-} \ No newline at end of file
diff --git a/views/displaymenuview.h b/views/displaymenuview.h
deleted file mode 100644
index 7fbd9a3..0000000
--- a/views/displaymenuview.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef __DISPLAYMENUVIEW_H
-#define __DISPLAYMENUVIEW_H
-
-#include "../libtemplate/template.h"
-#include "viewhelpers.h"
-#include "displaymenulistview.h"
-
-#if APIVERSNUM < 20107
-enum eMenuSortMode {
- msmUnknown = 0,
- msmNumber,
- msmName,
- msmTime,
- msmProvider
-};
-#endif
-
-class cDisplayMenuView : public cView, public cViewHelpers {
-protected:
- eMenuCategory cat;
- eMenuSortMode sortMode;
- eMenuSortMode sortModeLast;
- string menuTitle;
- string *buttonTexts;
- virtual void Action(void);
-public:
- cDisplayMenuView(cTemplateView *tmplView, bool menuInit);
- virtual ~cDisplayMenuView();
- void SetMenuCat(eMenuCategory newCat) { cat = newCat; };
- void SetSortMode(eMenuSortMode sortMode) { this->sortMode = sortMode; };
- void SetTitle(const char *title) {menuTitle = title; };
- virtual void SetChannel(const cChannel *channel) {};
- virtual const cChannel *GetChannel(void) { return NULL; };
- virtual void ClearChannel(void) {};
- virtual void SetEpgSearchFavorite(void) {};
- virtual void ClearEpgSearchFavorite(void) {};
- void SetButtonTexts(string *buttonTexts) { this->buttonTexts = buttonTexts; };
- bool DrawBackground(void);
- virtual bool DrawHeader(void);
- bool DrawDateTime(bool forced, bool &implemented);
- bool DrawTime(bool forced, bool &implemented);
- bool DrawColorButtons(void);
- bool DrawMessage(eMessageType type, const char *text);
- void DrawScrollbar(int numMax, int numDisplayed, int offset);
- bool DrawSortMode(void);
- virtual void DrawStaticViewElements(void) {};
- virtual bool DrawDynamicViewElements(void) { return false; };
- bool BackgroundImplemented(void);
-};
-
-class cDisplayMenuMainView : public cDisplayMenuView {
-private:
- bool initial;
- string currentRecording;
- void DrawTimers(void);
- void DrawLastRecordings(void);
- void DrawDiscUsage(void);
- bool DrawLoad(void);
- bool DrawMemory(void);
- bool DrawVdrStats(void);
- void DrawTemperatures(void);
- bool DrawDevices(void);
- void DrawCurrentSchedule(void);
- void DrawCurrentWeather(void);
- bool DrawCustomTokens(void);
-public:
- cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording);
- virtual ~cDisplayMenuMainView();
- void DrawStaticViewElements(void);
- bool DrawDynamicViewElements(void);
-};
-
-class cDisplayMenuSchedulesView : public cDisplayMenuView {
-private:
- const cChannel *channel;
- bool isEpgSearchFavoritesMenu;
-public:
- cDisplayMenuSchedulesView(cTemplateView *tmplView, eMenuCategory menuCat, bool menuInit);
- virtual ~cDisplayMenuSchedulesView();
- void SetChannel(const cChannel *channel) { if (channel) this->channel = channel; };
- const cChannel *GetChannel(void) { return channel; };
- void ClearChannel(void) { channel = NULL; };
- void SetEpgSearchFavorite(void) { isEpgSearchFavoritesMenu = true; };
- void ClearEpgSearchFavorite(void) { isEpgSearchFavoritesMenu = false; };
- bool DrawHeader(void);
-};
-
-#endif //__DISPLAYMENUVIEW_H
diff --git a/views/displaymessageview.c b/views/displaymessageview.c
deleted file mode 100644
index 6f92f5b..0000000
--- a/views/displaymessageview.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#define __STL_CONFIG_H
-#include <vdr/menu.h>
-#include "displaymessageview.h"
-
-cDisplayMessageView::cDisplayMessageView(cTemplateView *tmplView) : cView(tmplView) {
- DeleteOsdOnExit();
-}
-
-cDisplayMessageView::~cDisplayMessageView() {
-}
-
-bool cDisplayMessageView::createOsd(void) {
- cRect osdSize = tmplView->GetOsdSize();
- bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
- cOsd::OsdTop() + osdSize.Y(),
- osdSize.Width(),
- osdSize.Height());
- if (!ok) {
- DeleteOsdOnExit(false);
- }
- return ok;
-}
-
-void cDisplayMessageView::DrawBackground(void) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- DrawViewElement(veBackground, &stringTokens, &intTokens);
-}
-
-void cDisplayMessageView::DrawMessage(eMessageType type, const char *text) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- SetMenuMessage(type, text, stringTokens, intTokens);
- DrawViewElement(veMessage, &stringTokens, &intTokens);
-}
-
-void cDisplayMessageView::ClearMessage(void) {
- ClearViewElement(veMessage);
-}
diff --git a/views/displaymessageview.h b/views/displaymessageview.h
deleted file mode 100644
index bab15c6..0000000
--- a/views/displaymessageview.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __DISPLAYMESSAGEVIEW_H
-#define __DISPLAYMESSAGEVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-
-class cDisplayMessageView : public cView, public cViewHelpers {
-public:
- cDisplayMessageView(cTemplateView *tmplView);
- virtual ~cDisplayMessageView();
- bool createOsd(void);
- void DrawBackground(void);
- void DrawMessage(eMessageType type, const char *text);
- void ClearMessage(void);
- void DoFadeIn(void) { Start(); };
- void Flush(void) { DoFlush(); };
-};
-#endif //__DISPLAYMESSAGEVIEW_H
diff --git a/views/displaypluginview.c b/views/displaypluginview.c
deleted file mode 100644
index 6283cda..0000000
--- a/views/displaypluginview.c
+++ /dev/null
@@ -1,288 +0,0 @@
-#define __STL_CONFIG_H
-#include "displaypluginview.h"
-
-cDisplayPluginView::cDisplayPluginView(cTemplateView *tmplView, bool isRootView) : cView(tmplView) {
- fadeOut = false;
- init = true;
- tabInit = true;
- tabScrolled = true;
- hidden = false;
- intTokens = NULL;
- stringTokens = NULL;
- loopTokens = NULL;
- currentTmplTab = NULL;
- tabView = NULL;
- if (isRootView)
- DeleteOsdOnExit();
- SetFadeTime(tmplView->GetNumericParameter(ptFadeTime));
-}
-
-cDisplayPluginView::~cDisplayPluginView() {
- if (tabView)
- delete tabView;
-}
-
-bool cDisplayPluginView::createOsd(void) {
- cRect osdSize = tmplView->GetOsdSize();
- bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
- cOsd::OsdTop() + osdSize.Y(),
- osdSize.Width(),
- osdSize.Height());
- return ok;
-}
-
-void cDisplayPluginView::Deactivate(bool hide) {
- Stop();
- bool hideFromTemplate = tmplView->HideView();
- if (!hide && !hideFromTemplate)
- return;
- if (hideFromTemplate && tvScaled) {
- cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
- }
- HidePixmaps();
- HideAnimations();
- for (map< int, cViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
- cViewGrid *viewGrid = it->second;
- viewGrid->Hide();
- }
- hidden = true;
-}
-
-void cDisplayPluginView::Activate(void) {
- if (tvScaled) {
- cDevice::PrimaryDevice()->ScaleVideo(scalingWindow);
- }
- if (hidden) {
- ShowPixmaps();
- ShowAnimations();
- for (map< int, cViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) {
- cViewGrid *viewGrid = it->second;
- viewGrid->Show();
- }
- }
- Start();
-}
-
-void cDisplayPluginView::CleanViewElement(int id) {
- if (ViewElementScrolls((eViewElement)id)) {
- currentlyScrolling = false;
- if (Running())
- Stop();
- DestroyViewElement((eViewElement)id);
- } else {
- ClearViewElement((eViewElement)id);
- }
-}
-
-void cDisplayPluginView::DisplayViewElement(int id) {
- if (!intTokens || !stringTokens || !loopTokens)
- return;
- DrawViewElement((eViewElement)id, stringTokens, intTokens, loopTokens);
- if (!init && ViewElementScrolls((eViewElement)id))
- Start();
-}
-
-void cDisplayPluginView::InitGrids(int viewGridID) {
- map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
- if (hit != viewGrids.end()) {
- delete hit->second;
- viewGrids.erase(hit);
- }
- cTemplateViewGrid *tmplGrid = tmplView->GetViewGrid(viewGridID);
- cViewGrid *grid = new cViewGrid(tmplGrid);
- viewGrids.insert(pair< int, cViewGrid* >(viewGridID, grid));
-}
-
-void cDisplayPluginView::SetGrid(int viewGridID, long gridID,
- double x, double y, double width, double height,
- map<string,int> *intTokens, map<string,string> *stringTokens) {
- map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
- if (hit != viewGrids.end())
- (hit->second)->SetGrid(gridID, x, y, width, height, intTokens, stringTokens);
-}
-
-void cDisplayPluginView::SetGridCurrent(int viewGridID, long gridID, bool current) {
- map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
- if (hit != viewGrids.end())
- (hit->second)->SetCurrent(gridID, current);
-}
-
-void cDisplayPluginView::DeleteGrid(int viewGridID, long gridID) {
- map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
- if (hit == viewGrids.end())
- return;
- (hit->second)->Delete(gridID);
-}
-
-void cDisplayPluginView::DisplayGrids(int viewGridID) {
- map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
- if (hit == viewGrids.end())
- return;
- (hit->second)->Render();
-}
-
-void cDisplayPluginView::ClearGrids(int viewGridID) {
- map< int, cViewGrid* >::iterator hit = viewGrids.find(viewGridID);
- if (hit == viewGrids.end())
- return;
- (hit->second)->Clear();
-}
-
-void cDisplayPluginView::SetTabIntTokens(map<string,int> *intTokens) {
- tabIntTokens = *intTokens;
-}
-
-void cDisplayPluginView::SetTabStringTokens(map<string,string> *stringTokens) {
- tabStringTokens = *stringTokens;
-}
-
-void cDisplayPluginView::SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens) {
- tabLoopTokens = *loopTokens;
-}
-
-void cDisplayPluginView::SetTabs(void) {
- tmplView->InitViewTabIterator();
- cTemplateViewTab *tmplTab = NULL;
- while(tmplTab = tmplView->GetNextViewTab()) {
- tmplTab->ParseDynamicParameters(&tabStringTokens, &tabIntTokens, true);
- tmplTab->ClearDynamicFunctionParameters();
- tmplTab->ParseDynamicFunctionParameters(&tabStringTokens, &tabIntTokens, &tabLoopTokens);
- if (tmplTab->DoExecute()) {
- activeTabs.push_back(tmplTab);
- }
- }
- atIt = activeTabs.begin();
-}
-
-void cDisplayPluginView::TabLeft(void) {
- if (activeTabs.size() > 1) {
- currentTmplTab = GetPrevTab();
- delete tabView;
- tabView = NULL;
- tabScrolled = true;
- } else {
- tabScrolled = tabView->KeyLeft();
- }
-}
-
-void cDisplayPluginView::TabRight(void) {
- if (activeTabs.size() > 1) {
- currentTmplTab = GetNextTab();
- delete tabView;
- tabView = NULL;
- tabScrolled = true;
- } else {
- tabScrolled = tabView->KeyRight();
- }
-}
-
-void cDisplayPluginView::TabUp(void) {
- tabScrolled = tabView->KeyUp();
-}
-
-void cDisplayPluginView::TabDown(void) {
- tabScrolled = tabView->KeyDown();
-}
-
-void cDisplayPluginView::DisplayTab(void) {
- if (tabInit) {
- currentTmplTab = *atIt;
- tabInit = false;
- }
- if (!tabView) {
- tabView = new cDisplayMenuTabView(currentTmplTab);
- tabView->SetTokens(&tabIntTokens, &tabStringTokens, &tabLoopTokens);
- tabView->CreateTab();
- tabView->Start();
- DrawTabLabels();
- }
- if (tabScrolled) {
- DrawScrollbar();
- }
-}
-
-cTemplateViewTab *cDisplayPluginView::GetPrevTab(void) {
- if (atIt == activeTabs.begin()) {
- atIt = activeTabs.end();
- }
- atIt--;
- return *atIt;
-}
-
-cTemplateViewTab *cDisplayPluginView::GetNextTab(void) {
- atIt++;
- if (atIt == activeTabs.end()) {
- atIt = activeTabs.begin();
- }
- return *atIt;
-}
-
-void cDisplayPluginView::DrawScrollbar(void) {
- map < string, string > scrollbarStringTokens;
- map < string, int > scrollbarIntTokens;
-
- int barTop = 0;
- int barHeight = 0;
- tabView->GetScrollbarPosition(barTop, barHeight);
-
- scrollbarIntTokens.insert(pair<string,int>("height", barHeight));
- scrollbarIntTokens.insert(pair<string,int>("offset", barTop));
- ClearViewElement((eViewElement)pveScrollbar);
- DrawViewElement((eViewElement)pveScrollbar, &scrollbarStringTokens, &scrollbarIntTokens);
-}
-
-void cDisplayPluginView::DrawTabLabels(void) {
- if (!ExecuteViewElement((eViewElement)pveTablabels)) {
- return;
- }
- map < string, string > labelStringTokens;
- map < string, int > labelIntTokens;
- map < string, vector< map< string, string > > > labelLoopTokens;
-
- string labelPrev = "";
- string labelPrevTemp = "";
- string labelCurrent = "";
- string labelNext = "";
- bool wasCurrent = false;
- vector< map< string, string > > tabLabels;
- for (list<cTemplateViewTab*>::iterator it = activeTabs.begin(); it != activeTabs.end(); it++) {
- cTemplateViewTab *tab = *it;
- map< string, string > tabLabel;
- tabLabel.insert(pair< string, string >("tabs[title]", tab->GetName()));
- if (wasCurrent) {
- labelNext = tab->GetName();
- }
- if (tab == currentTmplTab) {
- wasCurrent = true;
- labelCurrent = tab->GetName();
- labelPrev = labelPrevTemp;
- tabLabel.insert(pair< string, string >("tabs[current]", "1"));
- } else {
- wasCurrent = false;
- tabLabel.insert(pair< string, string >("tabs[current]", "0"));
- }
- labelPrevTemp = tab->GetName();
- tabLabels.push_back(tabLabel);
- }
- if (labelNext.size() == 0 && activeTabs.size() > 0) {
- cTemplateViewTab *firstTab = activeTabs.front();
- labelNext = firstTab->GetName();
- }
- if (labelPrev.size() == 0 && activeTabs.size() > 0) {
- cTemplateViewTab *lastTab = activeTabs.back();
- labelPrev = lastTab->GetName();
- }
- labelStringTokens.insert(pair< string, string >("currenttab", labelCurrent));
- labelStringTokens.insert(pair< string, string >("nexttab", labelNext));
- labelStringTokens.insert(pair< string, string >("prevtab", labelPrev));
- labelLoopTokens.insert(pair< string, vector< map< string, string > > >("tabs", tabLabels));
-
- ClearViewElement((eViewElement)pveTablabels);
- DrawViewElement((eViewElement)pveTablabels, &labelStringTokens, &labelIntTokens, &labelLoopTokens);
-}
-
-void cDisplayPluginView::Action(void) {
- if (!init)
- SetFadeTime(0);
- cView::Action();
-} \ No newline at end of file
diff --git a/views/displaypluginview.h b/views/displaypluginview.h
deleted file mode 100644
index b3307a6..0000000
--- a/views/displaypluginview.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef __DISPLAYPLUGINVIEW_H
-#define __DISPLAYPLUGINVIEW_H
-
-#include <list>
-#include <vdr/thread.h>
-#include "../libtemplate/template.h"
-#include "view.h"
-#include "viewgrid.h"
-#include "displaymenutabview.h"
-
-class cDisplayPluginView : public cView {
-private:
- bool init;
- bool tabInit;
- bool tabScrolled;
- bool hidden;
- map<string,int> *intTokens;
- map<string,string> *stringTokens;
- map<string,vector<map<string,string> > > *loopTokens;
- map< int, cViewGrid* > viewGrids;
- map<string,int> tabIntTokens;
- map<string,string> tabStringTokens;
- map<string,vector<map<string,string> > > tabLoopTokens;
- cTemplateViewTab *currentTmplTab;
- list<cTemplateViewTab*> activeTabs;
- list<cTemplateViewTab*>::iterator atIt;
- cDisplayMenuTabView *tabView;
- cTemplateViewTab *GetPrevTab(void);
- cTemplateViewTab *GetNextTab(void);
- void DrawScrollbar(void);
- void DrawTabLabels(void);
- virtual void Action(void);
-public:
- cDisplayPluginView(cTemplateView *tmplView, bool isRootView);
- virtual ~cDisplayPluginView();
- bool createOsd(void);
- void Deactivate(bool hide);
- void Activate(void);
- void SetIntTokens(map<string,int> *intTokens) { this->intTokens = intTokens; };
- void SetStringTokens(map<string,string> *stringTokens) { this->stringTokens = stringTokens; };
- void SetLoopTokens(map<string,vector<map<string,string> > > *loopTokens) { this->loopTokens = loopTokens; };
- void CleanViewElement(int id);
- void DisplayViewElement(int id);
- void InitGrids(int viewGridID);
- void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens);
- void SetGridCurrent(int viewGridID, long gridID, bool current);
- void DeleteGrid(int viewGridID, long gridID);
- void DisplayGrids(int viewGridID);
- void ClearGrids(int viewGridID);
- void SetTabIntTokens(map<string,int> *intTokens);
- void SetTabStringTokens(map<string,string> *stringTokens);
- void SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens);
- void SetTabs(void);
- void TabLeft(void);
- void TabRight(void);
- void TabUp(void);
- void TabDown(void);
- void DisplayTab(void);
- void DoStart(void) { init = false; Start(); };
- void Flush(void) { DoFlush(); };
-};
-#endif //__DISPLAYPLUGINVIEW_H
diff --git a/views/displayreplayonpauseview.c b/views/displayreplayonpauseview.c
deleted file mode 100644
index 557a574..0000000
--- a/views/displayreplayonpauseview.c
+++ /dev/null
@@ -1,108 +0,0 @@
-#define __STL_CONFIG_H
-#include "displayreplayonpauseview.h"
-
-cDisplayReplayOnPauseView::cDisplayReplayOnPauseView(string recFileName, cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
- this->recFileName = recFileName;
- tmplViewElement->SetPixOffset(0);
- delay = tmplViewElement->GetNumericParameter(ptDelay) * 1000;
- SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
- resetSleep = false;
-}
-
-cDisplayReplayOnPauseView::~cDisplayReplayOnPauseView() {
- CancelSave();
- FadeOut();
-}
-
-void cDisplayReplayOnPauseView::Render(void) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- map < string, vector< map< string, string > > > loopTokens;
- if (recFileName.size() == 0)
- return;
- const cRecording *recording = new cRecording(recFileName.c_str());
-
- if (recording) {
- string name = recording->Name() ? recording->Name() : "";
- stringTokens.insert(pair<string,string>("name", name));
- const cRecordingInfo *info = recording->Info();
- if (info) {
- stringTokens.insert(pair<string,string>("shorttext", info->ShortText() ? info->ShortText() : ""));
- stringTokens.insert(pair<string,string>("description", info->Description() ? info->Description() : ""));
- const cEvent *event = info->GetEvent();
- if (event) {
- string recDate = *(event->GetDateString());
- string recTime = *(event->GetTimeString());
- if (recDate.find("1970") != string::npos) {
- time_t start = recording->Start();
- recDate = *DateString(start);
- recTime = *TimeString(start);
- }
- stringTokens.insert(pair<string,string>("date", recDate.c_str()));
- stringTokens.insert(pair<string,string>("time", recTime.c_str()));
- time_t startTime = event->StartTime();
- struct tm * sStartTime = localtime(&startTime);
- intTokens.insert(pair<string, int>("year", sStartTime->tm_year + 1900));
- intTokens.insert(pair<string, int>("daynumeric", sStartTime->tm_mday));
- intTokens.insert(pair<string, int>("month", sStartTime->tm_mon+1));
- int duration = event->Duration() / 60;
- int recDuration = recording->LengthInSeconds();
- recDuration = (recDuration>0)?(recDuration / 60):0;
- intTokens.insert(pair<string,int>("duration", recDuration));
- intTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- intTokens.insert(pair<string,int>("durationevent", duration));
- intTokens.insert(pair<string,int>("durationeventhours", duration / 60));
- stringTokens.insert(pair<string,string>("durationeventminutes", *cString::sprintf("%.2d", duration%60)));
- }
- } else {
- stringTokens.insert(pair<string,string>("shorttext", ""));
- stringTokens.insert(pair<string,string>("description", ""));
- int recDuration = recording->LengthInSeconds();
- recDuration = (recDuration>0)?(recDuration / 60):0;
- stringTokens.insert(pair<string,string>("date", ""));
- stringTokens.insert(pair<string,string>("time", ""));
- intTokens.insert(pair<string,int>("duration", recDuration));
- intTokens.insert(pair<string,int>("durationhours", recDuration / 60));
- stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", recDuration%60)));
- intTokens.insert(pair<string,int>("durationevent", 0));
- intTokens.insert(pair<string,int>("durationeventhours", 0));
- stringTokens.insert(pair<string,string>("durationeventminutes", ""));
- }
- } else {
- stringTokens.insert(pair<string,string>("name", ""));
- stringTokens.insert(pair<string,string>("shorttext", ""));
- stringTokens.insert(pair<string,string>("description", ""));
- stringTokens.insert(pair<string,string>("date", ""));
- stringTokens.insert(pair<string,string>("time", ""));
- stringTokens.insert(pair<string,string>("durationminutes", ""));
- stringTokens.insert(pair<string,string>("durationeventminutes", ""));
- }
- SetScraperTokens(NULL, recording, stringTokens, intTokens, loopTokens);
- DrawViewElement(veOnPause, &stringTokens, &intTokens, &loopTokens);
- if (recording)
- delete recording;
-}
-
-void cDisplayReplayOnPauseView::Action(void) {
- bool doContinue;
- int sleepSlice = 10;
- do {
- doContinue = false;
- for (int i = 0; Running() && (i*sleepSlice < delay); i++) {
- cCondWait::SleepMs(sleepSlice);
- if (resetSleep) {
- doContinue = true;
- resetSleep = false;
- break;
- }
- }
- } while (doContinue);
-
- if (!Running())
- return;
- Render();
- SetInitFinished();
- FadeIn();
- DoFlush();
-}
diff --git a/views/displayreplayonpauseview.h b/views/displayreplayonpauseview.h
deleted file mode 100644
index 09d2044..0000000
--- a/views/displayreplayonpauseview.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __DISPLAYREPLAYONPAUSEVIEW_H
-#define __DISPLAYREPLAYONPAUSEVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-#include "viewhelpers.h"
-
-class cDisplayReplayOnPauseView : public cView, public cViewHelpers {
-private:
- int delay;
- bool resetSleep;
- string recFileName;
- virtual void Action(void);
-public:
- cDisplayReplayOnPauseView(string recFileName, cTemplateViewElement *tmplViewElement);
- virtual ~cDisplayReplayOnPauseView();
- void ResetSleep(void) { resetSleep = true; };
- void Render(void);
- void Flush(void) { DoFlush(); };
-};
-#endif //__DISPLAYREPLAYONPAUSEVIEW_H
diff --git a/views/displayreplayview.c b/views/displayreplayview.c
deleted file mode 100644
index 22f1ee9..0000000
--- a/views/displayreplayview.c
+++ /dev/null
@@ -1,499 +0,0 @@
-#define __STL_CONFIG_H
-#include <vdr/menu.h>
-#include "../services/scraper2vdr.h"
-#include "displayviewelements.h"
-#include "displayreplayview.h"
-#include "../libcore/helpers.h"
-
-cDisplayReplayView::cDisplayReplayView(cTemplateView *tmplView) : cView(tmplView) {
- length = 0;
- timeShiftActive = false;
- timeShiftFramesTotal = 0;
- timeShiftLength = 1;
- timeShiftDuration = "";
- endLast = "";
- onPauseView = NULL;
- numMarksLast = 0;
- lastMarks = NULL;
- markActive = -1;
- DeleteOsdOnExit();
-}
-
-cDisplayReplayView::~cDisplayReplayView() {
- if (lastMarks) {
- delete[] lastMarks;
- }
- if (onPauseView) {
- delete onPauseView;
- }
-}
-
-bool cDisplayReplayView::createOsd(void) {
- cRect osdSize = tmplView->GetOsdSize();
- bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
- cOsd::OsdTop() + osdSize.Y(),
- osdSize.Width(),
- osdSize.Height());
- return ok;
-}
-
-void cDisplayReplayView::SetTimeShift(int framesTotal, int timeShiftLength) {
- timeShiftActive = true;
- timeShiftFramesTotal = framesTotal;
- this->timeShiftLength = timeShiftLength;
- int mins = (timeShiftLength / 60) % 60;
- int hours = (timeShiftLength / 3600) % 24;
- timeShiftDuration = *cString::sprintf("%d:%02d", hours, mins);
-}
-
-void cDisplayReplayView::DrawBackground(bool modeOnly) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- if (modeOnly)
- DrawViewElement(veBackgroundModeOnly, &stringTokens, &intTokens);
- else
- DrawViewElement(veBackground, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawDate(void) {
- if (!ExecuteViewElement(veDateTime)) {
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetDate(false, stringTokens, intTokens)) {
- return;
- }
- ClearViewElement(veDateTime);
- DrawViewElement(veDateTime, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawTime(void) {
- if (!ExecuteViewElement(veTime)) {
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- if (!SetTime(false, stringTokens, intTokens)) {
- return;
- }
- ClearViewElement(veTime);
- DrawViewElement(veTime, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawTitle(const cRecording *recording) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- const char *recName = NULL;
- const cRecordingInfo *recInfo = recording->Info();
- if (recInfo) {
- recName = recInfo->Title();
- }
- if (!recName)
- recName = recording->Name();
- string recShortText = recInfo->ShortText() ? recInfo->ShortText() : "";
- string recDate = *ShortDateString(recording->Start());
- string recTime = *TimeString(recording->Start());
-
- stringTokens.insert(pair<string,string>("rectitle", recName ? recName : ""));
- stringTokens.insert(pair<string,string>("recsubtitle", recShortText));
- stringTokens.insert(pair<string,string>("recdate", recDate));
- stringTokens.insert(pair<string,string>("rectime", recTime));
-
- DrawViewElement(veRecTitle, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawTitle(const char *title) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- stringTokens.insert(pair<string,string>("rectitle", title));
- stringTokens.insert(pair<string,string>("recsubtitle", ""));
- stringTokens.insert(pair<string,string>("recdate", ""));
- stringTokens.insert(pair<string,string>("rectime", ""));
-
- DrawViewElement(veRecTitle, &stringTokens, &intTokens);
-}
-
-
-void cDisplayReplayView::DrawRecordingInformation(const cRecording *recording) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- int screenWidth = 0;
- int screenHeight = 0;
- double aspect = 0;
- cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, aspect);
- bool isHD = false;
- string resName = GetScreenResolutionString(screenWidth, screenHeight, &isHD);
- bool isWideScreen = false;
- string aspectName = GetScreenAspectString(aspect, &isWideScreen);
-
- intTokens.insert(pair<string,int>("screenwidth", screenWidth));
- intTokens.insert(pair<string,int>("screenheight", screenHeight));
- intTokens.insert(pair<string,int>("isHD", isHD));
- intTokens.insert(pair<string,int>("isWideScreen", isWideScreen));
- stringTokens.insert(pair<string,string>("resolution", resName));
- stringTokens.insert(pair<string,string>("aspect", aspectName));
-
- ClearViewElement(veRecInfo);
- DrawViewElement(veRecInfo, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawScraperContent(const cRecording *recording) {
- if (!recording)
- return;
-
- if (!ExecuteViewElement(veScraperContent)) {
- return;
- }
-
- if (DetachViewElement(veScraperContent)) {
- cViewElementScraperContent *viewElement = dynamic_cast<cViewElementScraperContent*>(GetViewElement(veScraperContent));
- if (!viewElement) {
- viewElement = new cViewElementScraperContent(NULL, recording, tmplView->GetViewElement(veScraperContent));
- AddViewElement(veScraperContent, viewElement);
- viewElement->Start();
- } else {
- if (!viewElement->Starting()) {
- viewElement->SetRecording(recording);
- viewElement->Render();
- }
- }
- } else {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- SetPosterBannerV2(recording, stringTokens, intTokens);
- ClearViewElement(veScraperContent);
- DrawViewElement(veScraperContent, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayReplayView::DrawCurrent(const char *current) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- stringTokens.insert(pair<string,string>("reccurrent", current));
-
- ClearViewElement(veRecCurrent);
- DrawViewElement(veRecCurrent, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawTotal(const char *total) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- intTokens.insert(pair<string,int>("timeshift", timeShiftActive));
- stringTokens.insert(pair<string,string>("rectotal", total));
- stringTokens.insert(pair<string,string>("timeshifttotal", timeShiftDuration));
-
- ClearViewElement(veRecTotal);
- DrawViewElement(veRecTotal, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawEndTime(int current, int total) {
- if (!current)
- return;
- int totalLength = total;
- int recordingLength = length;
- if (timeShiftActive && timeShiftFramesTotal > 0) {
- totalLength = timeShiftFramesTotal;
- recordingLength = timeShiftLength;
- }
- double rest = (double)(totalLength - current) / (double)totalLength;
- time_t end = time(0) + rest*recordingLength;
- string endTime = *TimeString(end);
- if (!endTime.compare(endLast)) {
- return;
- }
- endLast = endTime;
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
- stringTokens.insert(pair<string,string>("recend", endTime));
-
- ClearViewElement(veRecEnd);
- DrawViewElement(veRecEnd, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawProgressBar(int current, int total) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("total", total));
- intTokens.insert(pair<string,int>("timeshift", timeShiftActive));
- if (timeShiftActive) {
- intTokens.insert(pair<string,int>("timeshifttotal", timeShiftFramesTotal));
- }
-
- ClearViewElement(veRecProgressBar);
- DrawViewElement(veRecProgressBar, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawMarks(const cMarks *marks, int current, int total) {
- if (!marks)
- return;
- if (!MarksChanged(marks, current))
- return;
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
- intTokens.insert(pair<string,int>("timeshift", timeShiftActive));
-
- map < string, vector< map< string, string > > > loopTokens;
- vector< map< string, string > > markTokens;
- stringstream tot;
- tot << total;
- stringstream timeshifttot;
- timeshifttot << timeShiftFramesTotal;
-
- bool isStartMark = true;
- for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
- map< string, string > markVals;
- stringstream pos;
- pos << m->Position();
- markVals.insert(pair< string, string >("marks[position]", pos.str()));
- markVals.insert(pair< string, string >("marks[total]", tot.str()));
- if (timeShiftActive) {
- markVals.insert(pair< string, string >("marks[timeshifttotal]", timeshifttot.str()));
- }
- markVals.insert(pair< string, string >("marks[startmark]", isStartMark ? "1" : "0"));
- markVals.insert(pair< string, string >("marks[active]", (m->Position() == current) ? "1" : "0"));
- const cMark *m2 = marks->Next(m);
- if (m2) {
- stringstream posNext;
- posNext << m2->Position();
- markVals.insert(pair< string, string >("marks[endposition]", posNext.str()));
- } else {
- markVals.insert(pair< string, string >("marks[endposition]", tot.str()));
- }
- isStartMark = !isStartMark;
- markTokens.push_back(markVals);
- }
- loopTokens.insert(pair< string, vector< map< string, string > > >("marks", markTokens));
-
- ClearViewElement(veCuttingMarks);
- DrawViewElement(veCuttingMarks, &stringTokens, &intTokens, &loopTokens);
-}
-
-void cDisplayReplayView::DrawControlIcons(bool play, bool forward, int speed, bool modeOnly) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- bool isPlay = false;
- bool isPause = false;
- bool isFF = false;
- bool isFF1x = false;
- bool isFF2x = false;
- bool isFF3x = false;
- bool isRew = false;
- bool isRew1x = false;
- bool isRew2x = false;
- bool isRew3x = false;
-
- if (speed == -1) {
- if (play) {
- isPlay = true;
- } else {
- isPause = true;
- }
- } else if (forward) {
- if (!play) {
- isPause = true;
- }
- if (speed == 1) {
- isFF1x = true;
- } else if (speed == 2) {
- isFF2x = true;
- } else if (speed == 3) {
- isFF3x = true;
- } else {
- isFF = true;
- }
- } else {
- if (!play) {
- isPause = true;
- }
- if (speed == 1) {
- isRew1x = true;
- } else if (speed == 2) {
- isRew2x = true;
- } else if (speed == 3) {
- isRew3x = true;
- } else {
- isRew = true;
- }
- }
- intTokens.insert(pair<string,int>("play", isPlay));
- intTokens.insert(pair<string,int>("pause", isPause));
- intTokens.insert(pair<string,int>("forward", isFF));
- intTokens.insert(pair<string,int>("forward1x", isFF1x));
- intTokens.insert(pair<string,int>("forward2x", isFF2x));
- intTokens.insert(pair<string,int>("forward3x", isFF3x));
- intTokens.insert(pair<string,int>("rewind", isRew));
- intTokens.insert(pair<string,int>("rewind1x", isRew1x));
- intTokens.insert(pair<string,int>("rewind2x", isRew2x));
- intTokens.insert(pair<string,int>("rewind3x", isRew3x));
-
- if (modeOnly) {
- ClearViewElement(veControlIconsModeOnly);
- DrawViewElement(veControlIconsModeOnly, &stringTokens, &intTokens);
- } else {
- ClearViewElement(veControlIcons);
- DrawViewElement(veControlIcons, &stringTokens, &intTokens);
- }
-}
-
-void cDisplayReplayView::DrawProgressModeOnly(double fps, int current, int total) {
- string cur = GetTimeString((double)current / fps);
- string tot = GetTimeString((double)total / fps);
- map < string, string > stringTokens;
- map < string, int > intTokens;
- intTokens.insert(pair<string,int>("current", current));
- intTokens.insert(pair<string,int>("total", total));
- stringTokens.insert(pair<string,string>("timecurrent", cur));
- stringTokens.insert(pair<string,string>("timetotal", tot));
- ClearViewElement(veProgressModeOnly);
- DrawViewElement(veProgressModeOnly, &stringTokens, &intTokens);
-}
-
-
-void cDisplayReplayView::DrawJump(const char *jump) {
- if (!jump) {
- ClearViewElement(veRecJump);
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
- stringTokens.insert(pair<string,string>("jump", jump));
-
- ClearViewElement(veRecJump);
- DrawViewElement(veRecJump, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawMessage(eMessageType type, const char *text) {
- if (!text) {
- ClearViewElement(veMessage);
- return;
- }
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- stringTokens.insert(pair<string,string>("text", text));
-
- intTokens.insert(pair<string,int>("status", (type == mtStatus) ? true : false));
- intTokens.insert(pair<string,int>("info", (type == mtInfo) ? true : false));
- intTokens.insert(pair<string,int>("warning", (type == mtWarning) ? true : false));
- intTokens.insert(pair<string,int>("error", (type == mtError) ? true : false));
-
- ClearViewElement(veMessage);
- DrawViewElement(veMessage, &stringTokens, &intTokens);
-}
-
-void cDisplayReplayView::DrawOnPause(string recFileName, bool modeOnly) {
- eViewElement veTmplOnPause = modeOnly ? veOnPauseModeOnly : veOnPause;
- cTemplateViewElement *tmplOnPause = tmplView->GetViewElement(veTmplOnPause);
- if (!tmplOnPause)
- return;
- onPauseView = new cDisplayReplayOnPauseView(recFileName, tmplOnPause);
- onPauseView->Start();
-}
-
-void cDisplayReplayView::ClearOnPause(void) {
- if (onPauseView) {
- delete onPauseView;
- onPauseView = NULL;
- }
-}
-
-void cDisplayReplayView::DelayOnPause(void) {
- if (onPauseView) {
- onPauseView->ResetSleep();
- }
-}
-
-void cDisplayReplayView::DrawCustomTokens(void) {
- if (!ExecuteViewElement(veCustomTokens)) {
- return;
- }
- if (!tmplView)
- return;
- map < string, string > stringTokens = tmplView->GetCustomStringTokens();
- map < string, int > intTokens = tmplView->GetCustomIntTokens();
- ClearViewElement(veCustomTokens);
- DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
-}
-
-bool cDisplayReplayView::CustomTokenChange(void) {
- if (!tmplView)
- return false;
- return tmplView->CustomTokenChange();
-}
-
-/****************************************************************************************
-* Private Functions
-*****************************************************************************************/
-
-bool cDisplayReplayView::MarksChanged(const cMarks *marks, int current) {
- if (!marks)
- return false;
-
- bool redraw = false;
- //if mark was active, we redraw always
- if (markActive >= 0) {
- markActive = -1;
- redraw = true;
- }
- //check if current position in recording hits mark exactly
- for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
- if (m->Position() == current) {
- markActive = current;
- redraw = true;
- break;
- }
- }
- if (redraw)
- return true;
- //if number of marks has changed, redraw
- int numMarks = marks->Count();
- if (numMarks != numMarksLast) {
- RememberMarks(marks);
- return true;
- }
- if (!lastMarks)
- return false;
- //if position has changed, redraw
- int i=0;
- for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
- if (m->Position() != lastMarks[i]) {
- RememberMarks(marks);
- return true;
- }
- i++;
- }
- return false;
-}
-
-void cDisplayReplayView::RememberMarks(const cMarks *marks) {
- if (!marks)
- return;
- numMarksLast = marks->Count();
- if (numMarksLast < 1)
- return;
- if (lastMarks) {
- delete[] lastMarks;
- }
- lastMarks = new int[numMarksLast];
- int i=0;
- for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
- lastMarks[i] = m->Position();
- i++;
- }
-}
diff --git a/views/displayreplayview.h b/views/displayreplayview.h
deleted file mode 100644
index 96255e9..0000000
--- a/views/displayreplayview.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __DISPLAYREPLAYVIEW_H
-#define __DISPLAYREPLAYVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-#include "displayreplayonpauseview.h"
-
-class cDisplayReplayView : public cView, public cViewHelpers {
-private:
- int length;
- bool timeShiftActive;
- int timeShiftFramesTotal;
- int timeShiftLength;
- string timeShiftDuration;
- string endLast;
- cDisplayReplayOnPauseView *onPauseView;
- int numMarksLast;
- int *lastMarks;
- int markActive;
- bool MarksChanged(const cMarks *marks, int current);
- void RememberMarks(const cMarks *marks);
-public:
- cDisplayReplayView(cTemplateView *tmplView);
- virtual ~cDisplayReplayView();
- bool createOsd(void);
- void SetRecordingLength(int length) { this->length = length; };
- void SetTimeShift(int framesTotal, int timeShiftLength);
- void DrawBackground(bool modeOnly);
- void DrawDate(void);
- void DrawTime(void);
- void DrawTitle(const cRecording *recording);
- void DrawTitle(const char *title);
- void DrawRecordingInformation(const cRecording *recording);
- void DrawScraperContent(const cRecording *recording);
- void DrawCurrent(const char *current);
- void DrawTotal(const char *total);
- void DrawEndTime(int current, int total);
- void DrawProgressBar(int current, int total);
- void DrawMarks(const cMarks *marks, int current, int total);
- void DrawControlIcons(bool play, bool forward, int speed, bool modeOnly);
- void DrawProgressModeOnly(double fps, int current, int total);
- void DrawJump(const char *jump);
- void DrawMessage(eMessageType type, const char *text);
- void DrawOnPause(string recFileName, bool modeOnly);
- void ClearOnPause(void);
- void DelayOnPause(void);
- void DrawCustomTokens(void);
- bool CustomTokenChange(void);
- void DoFadeIn(void) { Start(); };
- void Flush(void) { DoFlush(); };
-};
-#endif //__DISPLAYREPLAYVIEW_H
diff --git a/views/displayviewelements.c b/views/displayviewelements.c
deleted file mode 100644
index 1f60804..0000000
--- a/views/displayviewelements.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "displayviewelements.h"
-
-cViewElementDevices::cViewElementDevices(bool light, cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
- this->light = light;
- init = true;
-}
-
-bool cViewElementDevices::Render(void) {
- ClearTokens();
- map < string, vector<stringmap> > deviceLoopTokens;
- vector<stringmap> devices;
-
- if (init)
- InitDevices();
- bool changed = SetDevices(init, light, &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;
-}
-
-/********************************************************************************************************************/
-
-cViewElementScraperContent::cViewElementScraperContent(const cEvent *event, const cRecording *recording, cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
- this->event = event;
- this->recording = recording;
-}
-
-bool cViewElementScraperContent::Render(void) {
- ClearTokens();
- if (event)
- SetPosterBanner(event, stringTokens, intTokens);
- else if (recording)
- SetPosterBannerV2(recording, 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;
-}
-
-/********************************************************************************************************************/
-
-cViewElementLastRecordings::cViewElementLastRecordings(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) {
-}
-
-bool cViewElementLastRecordings::Render(void) {
- ClearTokens();
- map < string, vector< map< string, string > > > recordingLoopTokens;
- vector< map< string, string > > lastRecordings;
-
- SetLastRecordings(&intTokens, &stringTokens, &lastRecordings);
- recordingLoopTokens.insert(pair< string, vector< map< string, string > > >("recordings", lastRecordings));
-
- ClearViewElement(veLastRecordings);
- DrawViewElement(veLastRecordings, &stringTokens, &intTokens, &recordingLoopTokens);
- return true;
-}
-
-/********************************************************************************************************************/
-
-cViewElementCurrentSchedule::cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement, string currentRecording) : cViewElement(tmplViewElement) {
- this->currentRecording = currentRecording;
-}
-
-bool cViewElementCurrentSchedule::Render(void) {
- ClearTokens();
- SetCurrentSchedule(currentRecording, stringTokens, intTokens);
- ClearViewElement(veCurrentSchedule);
- DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens);
- return true;
-}
-
-/********************************************************************************************************************/
-
-cViewElementMenuHeader::cViewElementMenuHeader(cTemplateViewElement *tmplViewElement, eMenuCategory cat, string menuTitle) : cViewElement(tmplViewElement) {
- this->cat = cat;
- this->menuTitle = menuTitle;
-}
-
-bool cViewElementMenuHeader::Render(void) {
- ClearTokens();
- SetMenuHeader(cat, menuTitle, stringTokens, intTokens);
- ClearViewElement(veHeader);
- DrawViewElement(veHeader, &stringTokens, &intTokens);
- return true;
-}
-
-/********************************************************************************************************************/
-
-cViewElementMenuMessage::cViewElementMenuMessage(cTemplateViewElement *tmplViewElement, eMessageType type, string text) : cViewElement(tmplViewElement) {
- this->type = type;
- this->text = text;
-}
-
-bool cViewElementMenuMessage::Render(void) {
- ClearTokens();
- SetMenuMessage(type, text, stringTokens, intTokens);
- ClearViewElement(veMessage);
- DrawViewElement(veMessage, &stringTokens, &intTokens);
- return true;
-}
diff --git a/views/displayviewelements.h b/views/displayviewelements.h
deleted file mode 100644
index 72d31e9..0000000
--- a/views/displayviewelements.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#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;
- bool light;
-public:
- cViewElementDevices(bool light, cTemplateViewElement *tmplViewElement);
- virtual ~cViewElementDevices() {};
- bool Render(void);
-};
-
-class cViewElementScraperContent : public cViewElement, public cViewHelpers {
-private:
- const cEvent *event;
- const cRecording *recording;
-public:
- cViewElementScraperContent(const cEvent *event, const cRecording *recording, cTemplateViewElement *tmplViewElement);
- virtual ~cViewElementScraperContent() {};
- void SetEvent(const cEvent *event) { this->event = event; };
- void SetRecording(const cRecording *recording) { this->recording = recording; };
- 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 cViewElementLastRecordings : public cViewElement, public cViewHelpers {
-private:
-public:
- cViewElementLastRecordings(cTemplateViewElement *tmplViewElement);
- virtual ~cViewElementLastRecordings() {};
- bool Render(void);
-};
-
-class cViewElementCurrentSchedule : public cViewElement, public cViewHelpers {
-private:
- string currentRecording;
-public:
- cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement, string currentRecording);
- virtual ~cViewElementCurrentSchedule() {};
- bool Render(void);
-};
-
-class cViewElementMenuHeader : public cViewElement, public cViewHelpers {
-private:
- eMenuCategory cat;
- string menuTitle;
-public:
- cViewElementMenuHeader(cTemplateViewElement *tmplViewElement, eMenuCategory cat, string menuTitle);
- virtual ~cViewElementMenuHeader() {};
- bool Render(void);
-};
-
-class cViewElementMenuMessage : public cViewElement, public cViewHelpers {
-private:
- eMessageType type;
- string text;
-public:
- cViewElementMenuMessage(cTemplateViewElement *tmplViewElement, eMessageType type, string text);
- virtual ~cViewElementMenuMessage() {};
- bool Render(void);
-};
-
-#endif //__DISPLAYCHANNELVIEWELEMENTS_H \ No newline at end of file
diff --git a/views/displayvolumeview.c b/views/displayvolumeview.c
deleted file mode 100644
index e7c8b1b..0000000
--- a/views/displayvolumeview.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#define __STL_CONFIG_H
-#include <vdr/menu.h>
-#include "displayvolumeview.h"
-
-cDisplayVolumeView::cDisplayVolumeView(cTemplateView *tmplView) : cView(tmplView) {
- volumeLast = -1;
- muteLast = false;
- DeleteOsdOnExit();
-}
-
-cDisplayVolumeView::~cDisplayVolumeView() {
-}
-
-bool cDisplayVolumeView::createOsd(void) {
- cRect osdSize = tmplView->GetOsdSize();
- bool ok = CreateOsd(cOsd::OsdLeft() + osdSize.X(),
- cOsd::OsdTop() + osdSize.Y(),
- osdSize.Width(),
- osdSize.Height());
- return ok;
-}
-
-void cDisplayVolumeView::DrawBackground(void) {
- map < string, string > stringTokens;
- map < string, int > intTokens;
- DrawViewElement(veBackground, &stringTokens, &intTokens);
-}
-
-void cDisplayVolumeView::DrawVolume(int current, int total, bool mute) {
- if ((volumeLast == current) && (muteLast == mute))
- return;
- volumeLast = current;
- muteLast = mute;
-
- map < string, string > stringTokens;
- map < string, int > intTokens;
-
- intTokens.insert(pair<string,int>("volume", current));
- intTokens.insert(pair<string,int>("maxvolume", total));
- intTokens.insert(pair<string,int>("volpercent", (double)current *100 / (double)total));
- intTokens.insert(pair<string,int>("mute", mute));
-
- ClearViewElement(veVolume);
- DrawViewElement(veVolume, &stringTokens, &intTokens);
-}
diff --git a/views/displayvolumeview.h b/views/displayvolumeview.h
deleted file mode 100644
index 9ad9eab..0000000
--- a/views/displayvolumeview.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __DISPLAYVOLUMEVIEW_H
-#define __DISPLAYVOLUMEVIEW_H
-
-#include "../libtemplate/template.h"
-#include "view.h"
-
-class cDisplayVolumeView : public cView {
-private:
- int volumeLast;
- bool muteLast;
-public:
- cDisplayVolumeView(cTemplateView *tmplView);
- virtual ~cDisplayVolumeView();
- bool createOsd(void);
- void DrawBackground(void);
- void DrawVolume(int current, int total, bool mute);
- void DoFadeIn(void) { Start(); };
- void Flush(void) { DoFlush(); };
-};
-#endif //__DISPLAYVOLUMEVIEW_H
diff --git a/views/view.c b/views/view.c
deleted file mode 100644
index fe20054..0000000
--- a/views/view.c
+++ /dev/null
@@ -1,1533 +0,0 @@
-#include "view.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-#include "../libcore/imageloader.h"
-
-using namespace std;
-
-cView::cView(cTemplateView *tmplView) : cPixmapContainer(tmplView->DrawGebugGrid() ? tmplView->GetNumPixmaps() + 1 : tmplView->GetNumPixmaps()) {
- this->tmplView = tmplView;
- SetFadeTime(tmplView->GetNumericParameter(ptFadeTime));
- SetShiftTime(tmplView->GetNumericParameter(ptShiftTime));
- SetStartPos(tmplView->GetNumericParameter(ptStartX), tmplView->GetNumericParameter(ptStartY));
- SetShiftType(tmplView->GetNumericParameter(ptShiftType));
- SetShiftMode(tmplView->GetNumericParameter(ptShiftMode));
- tvScaled = tmplView->GetScalingWindow(scalingWindow);
- if (tvScaled) {
- cDevice::PrimaryDevice()->ScaleVideo(scalingWindow);
- }
- tmplViewElement = NULL;
- tmplTab = NULL;
- Init();
-}
-
-cView::cView(cTemplateViewElement *tmplViewElement) : cPixmapContainer(tmplViewElement ? tmplViewElement->GetNumPixmaps() : 0) {
- this->tmplViewElement = tmplViewElement;
- tmplView = NULL;
- tmplTab = NULL;
- tvScaled = false;
- Init();
-}
-
-cView::cView(cTemplateViewTab *tmplTab) : cPixmapContainer(1) {
- this->tmplTab = tmplTab;
- tmplView = NULL;
- tmplViewElement = NULL;
- tvScaled = false;
- Init();
-}
-
-cView::~cView() {
- CancelSave();
-
- if (tvScaled) {
- cDevice::PrimaryDevice()->ScaleVideo(cRect::Null);
- }
- //clear detached views
- Lock();
- for (map<eViewElement,cViewElement*>::iterator dVeIt = detachedViewElements.begin(); dVeIt != detachedViewElements.end(); dVeIt++) {
- cViewElement *ve = dVeIt->second;
- delete ve;
- }
- Unlock();
- //clear animations
- Lock();
- for (multimap<int, cAnimation*>::iterator animIt = animations.begin(); animIt != animations.end(); animIt++) {
- cAnimation *anim = animIt->second;
- anim->Stop();
- delete anim;
- }
- Unlock();
- //shift or fade out
- if (fadeOut) {
- if (IsAnimated())
- ShiftOut();
- else {
- FadeOut();
- }
- }
-}
-
-void cView::DrawDebugGrid(void) {
- if (tmplView && tmplView->DrawGebugGrid()) {
- DoDrawDebugGrid();
- }
-}
-
-void cView::Init(void) {
- fadeOut = true;
- viewInit = true;
- scrolling = false;
- veScroll = veUndefined;
- scrollingPix = -1;
- scrollOrientation = orHorizontal;
- scrollDelay = 0;
- scrollMode = smNone;
- scrollSpeed = ssMedium;
- animCat = 0;
- currentlyScrolling = false;
-}
-
-void cView::Action(void) {
- SetInitFinished();
- if (IsAnimated()) {
- ShiftIn();
- } else {
- FadeIn();
- }
- DoFlush();
- if (scrolling) {
- DoSleep(scrollDelay);
- if (!Running())
- return;
- if (scrollOrientation == orHorizontal) {
- ActivateScrolling();
- ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
- } else {
- ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
- }
- }
-}
-
-void cView::Stop(void) {
- CancelSave();
-}
-
-/********************************************************************************
-* Protected Functions
-********************************************************************************/
-
-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 = NULL;
- if (tmplViewElement) {
- viewElement = tmplViewElement;
- animCat = 0;
- } else if (tmplView) {
- viewElement = tmplView->GetViewElement(ve);
- animCat = ve;
- }
- if (!viewElement)
- return;
-
- if (viewElement->DebugTokens()) {
- DebugTokens(tmplView ? (tmplView->GetViewElementName(ve)) : "current view", stringTokens, intTokens, loopTokens);
- }
- //iterate through pixmaps of viewelement
- int pixCurrent = viewElement->GetPixOffset();
- if (pixCurrent < 0)
- return;
- viewElement->InitPixmapNodeIterator();
- cTemplatePixmapNode *pixNode = NULL;
- while(pixNode = viewElement->GetNextPixmapNode()) {
- cTemplatePixmap *pix = dynamic_cast<cTemplatePixmap*>(pixNode);
- if (pix) {
- bool draw = PreparePixmap(ve, pixCurrent, pix, stringTokens, intTokens, loopTokens);
- if (draw)
- DrawPixmap(pixCurrent, pix, loopTokens);
- pixCurrent++;
- } else {
- cTemplatePixmapContainer *pixContainer = dynamic_cast<cTemplatePixmapContainer*>(pixNode);
- pixContainer->ParseDynamicParameters(stringTokens, intTokens);
- if (pixContainer->DoDebug()) {
- pixContainer->Debug();
- }
- if (!pixContainer->DoExecute()) {
- pixCurrent += pixContainer->NumPixmaps();
- continue;
- }
- pixContainer->InitIterator();
- cTemplatePixmap *pix = NULL;
- while (pix = pixContainer->GetNextPixmap()) {
- bool draw = PreparePixmap(ve, pixCurrent, pix, stringTokens, intTokens, loopTokens);
- if (draw)
- DrawPixmap(pixCurrent, pix, loopTokens);
- pixCurrent++;
- }
- }
- }
-}
-
-bool cView::PreparePixmap(eViewElement ve, int num, cTemplatePixmap *pix, map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) {
- //check if already drawn background area, this can be skipped
- if (PixmapExists(num) && pix->BackgroundArea()) {
- return false;
- }
- //reset Template
- pix->ClearDynamicParameters();
- //create Pixmap if already fully parsed
- if (!PixmapExists(num) && pix->Ready() && pix->DoExecute() && !pix->Scrolling()) {
- CreateViewPixmap(num, pix);
- }
- //check if pixmap needs dynamic parameters
- if ((!pix->Ready() || !pix->DoExecute()) && !pix->Scrolling()) {
- //parse dynamic parameters and initiate functions
- pix->ParseDynamicParameters(stringTokens, intTokens, true);
- if (pix->Ready() && pix->DoExecute()) {
- CreateViewPixmap(num, pix);
- }
- } else {
- //parse dynamic parameters but not initiate functions
- pix->ParseDynamicParameters(stringTokens, intTokens, false);
- }
- //if pixmap still not valid, skip
- if (!pix->Ready() && !pix->Scrolling()) {
- return false;
- }
- //if condition for pixmap set, check if cond is true
- if (!pix->DoExecute()) {
- return false;
- }
- //parse dynamic tokens of pixmap functions
- pix->ClearDynamicFunctionParameters();
- pix->ParseDynamicFunctionParameters(stringTokens, intTokens, loopTokens);
-
- if (!PixmapExists(num) && pix->Scrolling()) {
- cSize drawportSize;
- scrolling = pix->CalculateDrawPortSize(drawportSize, loopTokens);
- if (scrolling) {
- CreateScrollingPixmap(num, pix, drawportSize);
- pix->SetScrollingTextWidth();
- veScroll = ve;
- scrollingPix = num;
- scrollOrientation = pix->GetNumericParameter(ptOrientation);
- scrollMode = pix->GetNumericParameter(ptScrollMode);
- scrollDelay = pix->GetNumericParameter(ptDelay);
- scrollSpeed = pix->GetNumericParameter(ptScrollSpeed);
- } else {
- CreateViewPixmap(num, pix);
- }
- }
- if (pix->DoDebug()) {
- pix->Debug();
- }
- return true;
-}
-
-void cView::ClearViewElement(eViewElement ve) {
- cViewElement *detachedVE = GetViewElement(ve);
- if (detachedVE) {
- detachedVE->Clear();
- return;
- } else {
- if (DetachViewElement(ve))
- return;
- }
- cTemplateViewElement *viewElement = NULL;
- int currentAnimCat = ve;
- if (tmplViewElement) {
- viewElement = tmplViewElement;
- currentAnimCat = 0;
- } else if (tmplView) {
- viewElement = tmplView->GetViewElement(ve);
- }
- if (!viewElement)
- return;
- int pixCurrent = viewElement->GetPixOffset();
- if (pixCurrent < 0)
- return;
- cTemplatePixmap *pix = NULL;
- viewElement->InitPixmapIterator();
- while(pix = viewElement->GetNextPixmap()) {
- if (!pix->BackgroundArea()) {
- Fill(pixCurrent, clrTransparent);
- }
- pixCurrent++;
- }
- ClearAnimations(currentAnimCat);
-}
-
-void cView::DestroyViewElement(eViewElement ve) {
- if (!tmplView)
- return;
- cTemplateViewElement *viewElement = tmplView->GetViewElement(ve);
- if (!viewElement)
- return;
- int pixCurrent = viewElement->GetPixOffset();
- if (pixCurrent < 0)
- return;
- cTemplatePixmap *pix = NULL;
- viewElement->InitPixmapIterator();
- while(pix = viewElement->GetNextPixmap()) {
- DestroyPixmap(pixCurrent);
- pixCurrent++;
- }
- ClearAnimations(ve);
-}
-
-void cView::DestroyDetachedViewElement(eViewElement ve) {
- map < eViewElement, cViewElement* >::iterator hit = detachedViewElements.find(ve);
- if (hit == detachedViewElements.end())
- return;
- cViewElement *viewElement = hit->second;
- delete viewElement;
- detachedViewElements.erase(hit);
-}
-
-void cView::ClearAnimations(int cat) {
- //stop and delete all animated elements from this viewelement
- if (animations.size() == 0)
- return;
- pair<multimap<int,cAnimation*>::iterator, multimap<int,cAnimation*>::iterator> rangeAnims;
- rangeAnims = animations.equal_range(cat);
- for (multimap<int,cAnimation*>::iterator it = rangeAnims.first; it!=rangeAnims.second; ++it) {
- cAnimation *anim = it->second;
- anim->Stop();
- delete anim;
- }
- animations.erase(cat);
-}
-
-void cView::HideAnimations(void) {
- for (multimap<int,cAnimation*>::iterator it = animations.begin(); it!=animations.end(); ++it) {
- cAnimation *anim = it->second;
- anim->HidePixmaps();
- }
-}
-
-void cView::ShowAnimations(void) {
- for (multimap<int,cAnimation*>::iterator it = animations.begin(); it!=animations.end(); ++it) {
- cAnimation *anim = it->second;
- anim->ShowPixmaps();
- }
-}
-
-void cView::ActivateScrolling(void) {
- if (veScroll == veUndefined)
- return;
- cTemplateViewElement *scrollViewElement = NULL;
- if (tmplView) {
- scrollViewElement = tmplView->GetViewElement(veScroll);
- }
- if (!scrollViewElement)
- return;
-
- ClearViewElement(veScroll);
- currentlyScrolling = true;
-
- int pixCurrent = scrollViewElement->GetPixOffset();
- if (pixCurrent < 0)
- return;
- scrollViewElement->InitPixmapIterator();
- cTemplatePixmap *pix = NULL;
- while(pix = scrollViewElement->GetNextPixmap()) {
- DrawPixmap(pixCurrent, pix);
- pixCurrent++;
- }
-}
-
-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;
- if (!tmplView)
- return false;
- cTemplateViewElement *viewElement = tmplView->GetViewElement(ve);
- if (!viewElement)
- return false;
- int pixStart = viewElement->GetPixOffset();
- int numPixmaps = viewElement->GetNumPixmaps();
- if ( (scrollingPix >= pixStart) && (scrollingPix < (pixStart + numPixmaps)) )
- return true;
- 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;
- if (size) {
- pixSize = *size;
- } else {
- pixSize = pix->GetPixmapSize();
- }
- int layer = pix->GetNumericParameter(ptLayer);
- int transparency = pix->GetNumericParameter(ptTransparency);
- SetTransparency(num, transparency);
- CreatePixmap(num, layer, pixSize);
-}
-
-void cView::CreateScrollingPixmap(int num, cTemplatePixmap *pix, cSize &drawportSize) {
- cRect pixViewPort = pix->GetPixmapSize();
- cRect drawPort;
- drawPort.SetX(0);
- drawPort.SetY(0);
- drawPort.SetWidth(drawportSize.Width());
- drawPort.SetHeight(drawportSize.Height());
- int layer = pix->GetNumericParameter(ptLayer);
- int transparency = pix->GetNumericParameter(ptTransparency);
- SetTransparency(num, transparency);
- CreatePixmap(num, layer, pixViewPort, drawPort);
-}
-
-void cView::DrawPixmap(int num, cTemplatePixmap *pix, map < string, vector< map< string, string > > > *loopTokens, bool flushPerLoop) {
- pix->InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = pix->GetNextFunction()) {
- eFuncType type = func->GetType();
- if (func->DoDebug()) {
- func->Debug();
- }
- if (!func->DoExecute()) {
- continue;
- }
- switch (type) {
- case ftFill:
- DoFill(num, func);
- break;
- case ftDrawText:
- DoDrawText(num, func);
- break;
- case ftDrawTextVertical:
- DoDrawTextVertical(num, func);
- break;
- case ftDrawTextBox: {
- int floating = func->GetNumericParameter(ptFloat);
- if (floating > flNone) {
- DoDrawFloatingTextBox(num, func);
- } else {
- DoDrawTextBox(num, func);
- }
- break; }
- case ftDrawRectangle:
- DoDrawRectangle(num, func);
- break;
- case ftDrawEllipse:
- DoDrawEllipse(num, func);
- break;
- case ftDrawSlope:
- DoDrawSlope(num, func);
- break;
- case ftDrawImage:
- DoDrawImage(num, func);
- break;
- case ftLoop:
- if (loopTokens)
- DrawLoop(num, func, loopTokens);
- break;
- default:
- break;
- }
- if (flushPerLoop) {
- DoFlush();
- }
- }
-}
-
-void cView::DrawLoop(int numPixmap, cTemplateFunction *func, map < string, vector< map< string, string > > > *loopTokens) {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(func);
- if (!loopFunc)
- return;
-
- int loopX0 = loopFunc->GetNumericParameter(ptX);
- if (loopX0 < 0) loopX0 = 0;
- int loopY0 = loopFunc->GetNumericParameter(ptY);
- if (loopY0 < 0) loopY0 = 0;
- int orientation = loopFunc->GetNumericParameter(ptOrientation);
- int loopWidth = loopFunc->GetNumericParameter(ptWidth);
- if (loopWidth <= 0)
- loopWidth = loopFunc->GetContainerWidth();
- int loopHeight = loopFunc->GetNumericParameter(ptHeight);
- if (loopHeight <= 0)
- loopHeight = loopFunc->GetContainerHeight();
- int columnWidth = loopFunc->GetNumericParameter(ptColumnWidth);
- int rowHeight = loopFunc->GetNumericParameter(ptRowHeight);
- int overflow = loopFunc->GetNumericParameter(ptOverflow);
-
- int x0 = loopX0;
- int y0 = loopY0;
-
- string loopTokenName = loopFunc->GetParameter(ptName);
-
- map < string, vector< map< string, string > > >::iterator hit = loopTokens->find(loopTokenName);
- if (hit == loopTokens->end())
- return;
- vector< map<string,string> > loopToken = hit->second;
- int lineNumber=0;
- for (vector< map<string,string> >::iterator line = loopToken.begin(); line != loopToken.end(); line++) {
- //check overflow behaviour
- if (overflow == otCut) {
- if (orientation == orHorizontal) {
- if (lineNumber * columnWidth > loopWidth) {
- return;
- }
- } else if (orientation == orVertical) {
- if (lineNumber * rowHeight > loopHeight) {
- return;
- }
- }
- } else if (overflow == otWrap && orientation == orHorizontal) {
- if (x0 + columnWidth > loopWidth) {
- x0 = loopX0;
- if (rowHeight > 0) {
- y0 += rowHeight;
- } else {
- y0 += loopFunc->GetLoopElementsHeight();
- }
- }
- }
- map<string,string> tokens = *line;
- loopFunc->ClearDynamicParameters();
- loopFunc->ParseDynamicParameters(&tokens);
- loopFunc->InitIterator();
- cTemplateFunction *func = NULL;
- while(func = loopFunc->GetNextFunction()) {
- //do debug?
- if (func->DoDebug())
- func->Debug();
- //check if set condition is true
- if (!func->DoExecute()) {
- continue;
- }
- //execute
- eFuncType type = func->GetType();
- switch (type) {
- case ftDrawText:
- DoDrawText(numPixmap, func, x0, y0);
- break;
- case ftDrawTextBox:
- DoDrawTextBox(numPixmap, func, x0, y0);
- break;
- case ftDrawRectangle:
- DoDrawRectangle(numPixmap, func, x0, y0);
- break;
- case ftDrawEllipse:
- DoDrawEllipse(numPixmap, func, x0, y0);
- break;
- case ftDrawSlope:
- DoDrawSlope(numPixmap, func, x0, y0);
- break;
- case ftDrawImage:
- DoDrawImage(numPixmap, func, x0, y0);
- break;
- default:
- break;
- }
- }
- //calculate position of next loop element
- if (orientation == orHorizontal) {
- if (columnWidth > 0) {
- x0 += columnWidth;
- } else {
- x0 += loopFunc->GetLoopElementsWidth();
- }
- } else if (orientation == orVertical) {
- if (rowHeight > 0) {
- y0 += rowHeight;
- } else {
- y0 += loopFunc->GetLoopElementsHeight();
- }
- }
- lineNumber++;
- //DoFlush();
- }
-}
-
-void cView::DebugTokens(string viewElement, map<string,string> *stringTokens, map<string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) {
- esyslog("skindesigner: ------------------------------ Tokens for %s:", viewElement.c_str());
- if (stringTokens) {
- for (map<string,string>::iterator st = stringTokens->begin(); st != stringTokens->end(); st++) {
- esyslog("skindesigner: string var \"%s\" = \"%s\"", (st->first).c_str(), (st->second).c_str());
- }
- }
- if (intTokens) {
- for (map<string,int>::iterator it = intTokens->begin(); it != intTokens->end(); it++) {
- esyslog("skindesigner: int var \"%s\" = %d", (it->first).c_str(), it->second);
- }
- }
- if (loopTokens) {
- for(map < string, vector< map< string, string > > >::iterator it1 = loopTokens->begin(); it1 != loopTokens->end(); it1++) {
- int line = 0;
- string tokenName = it1->first;
- vector< map<string,string> > tokens = it1->second;
- esyslog("skindesigner: loop token %s", tokenName.c_str());
- for (vector< map<string,string> >::iterator it2 = tokens.begin(); it2 != tokens.end(); it2++) {
- esyslog("skindesigner: loop tokens line %d:", line++);
- map<string,string> element = *it2;
- for (map<string,string>::iterator el = element.begin(); el != element.end(); el++) {
- esyslog("skindesigner: name: %s, value: %s", (el->first).c_str(), (el->second).c_str());
- }
- }
- }
- }
-}
-
-/*****************************************************************
-* Private Functions
-*****************************************************************/
-
-void cView::DoDrawDebugGrid(void) {
- int stepsX = tmplView->DebugGridX();
- int stepsY = tmplView->DebugGridY();
- cRect osdSize = tmplView->GetOsdSize();
- tColor col = tmplView->DebugGridColor();
- tColor colFont = tmplView->DebugGridFontColor();
-
- cRect size(0, 0, osdSize.Width(), osdSize.Height());
- //use last pixmap as grid pixmap
- int numGridPixmap = NumPixmaps() - 1;
- CreatePixmap(numGridPixmap, 7, size);
-
- int width = size.Width();
- int height = size.Height();
- float stepWidthX = (double)width / (double)stepsX;
- float stepWidthY = (double)height / (double)stepsY;
- int fontSize = height / stepsY / 5;
-
- for (int i = 0; i <= stepsX; i++) {
- int x = (float)i * stepWidthX;
- if (i==stepsX)
- x = x-1;
- cRect line(x, 0, 1, height);
- DrawRectangle(numGridPixmap, line, col);
- if (i==stepsX)
- continue;
- float percent = (float)i / (float)stepsX * 100.0;
- cPoint textPosPerc(x+2, 2);
- cPoint textPosAbs(x+2, fontSize + 4);
- DrawText(numGridPixmap, textPosPerc, *cString::sprintf("%.1f%%", percent), colFont, 0x00000000, "vdrOsd", fontSize);
- DrawText(numGridPixmap, textPosAbs, *cString::sprintf("%dpx", x), colFont, 0x00000000, "vdrOsd", fontSize);
- }
- for (int i = 0; i <= stepsY; i++) {
- int y = (float)i * stepWidthY;
- if (i==stepsY)
- y = y-1;
- cRect line(0, y, width, 1);
- DrawRectangle(numGridPixmap, line, col);
- if (i==0 || i==stepsY)
- continue;
- float percent = (float)i / (float)stepsY * 100.0;
- cPoint textPosPerc(2, y + 2);
- cPoint textPosAbs(2, y + fontSize + 4);
- DrawText(numGridPixmap, textPosPerc, *cString::sprintf("%.1f%%", percent), colFont, 0x00000000, "vdrOsd", fontSize);
- DrawText(numGridPixmap, textPosAbs, *cString::sprintf("%dpx", y), colFont, 0x00000000, "vdrOsd", fontSize);
- }
-}
-
-void cView::DoFill(int num, cTemplateFunction *func) {
- tColor col = func->GetColorParameter(ptColor);
- Fill(num, col);
-}
-
-void cView::DoDrawText(int num, cTemplateFunction *func, int x0, int y0) {
- int x = func->GetNumericParameter(ptX);
- if (x < 0) x = 0;
- x += x0;
- int y = func->GetNumericParameter(ptY);
- if (y < 0) y = 0;
- y += y0;
- cPoint pos(x,y);
- string fontName = func->GetFontName();
- int fontSize = func->GetNumericParameter(ptFontSize);
- tColor clr = func->GetColorParameter(ptColor);
- tColor clrBack = clrTransparent;
- string text = "";
- if (!currentlyScrolling) {
- text = func->GetText(true);
- } else {
- text = func->GetText(false);
- }
- if (func->IsAnimated()) {
- DrawAnimatedText(num, func, pos, text, clr, fontName, fontSize);
- } else {
- DrawText(num, pos, text.c_str(), clr, clrBack, fontName, fontSize);
- }
-}
-
-void cView::DoDrawTextVertical(int num, cTemplateFunction *func, int x0, int y0) {
- string fontName = func->GetFontName();
- int fontSize = func->GetNumericParameter(ptFontSize);
- int direction = func->GetNumericParameter(ptDirection);
- tColor clr = func->GetColorParameter(ptColor);
- string text = func->GetText(false);
- cImage *textVertical = imgCache->GetVerticalText(text, clr, fontName, fontSize, direction);
- if (!textVertical)
- return;
-
- //align has to be set here because here we know the image size
- int x = 0;
- int y = 0;
- int align = func->GetNumericParameter(ptAlign);
- if (align == alCenter) {
- int containerWidth = func->GetContainerWidth();
- x = (containerWidth - textVertical->Width()) / 2;
- } else if (align == alLeft) {
- x = 0;
- } else if (align == alRight) {
- int containerWidth = func->GetContainerWidth();
- x = (containerWidth - textVertical->Width());
- } else {
- x = func->GetNumericParameter(ptX);
- }
-
- int valign = func->GetNumericParameter(ptValign);
- if (valign == alCenter) {
- int containerHeight = func->GetContainerHeight();
- y = (containerHeight - textVertical->Height()) / 2;
- } else if (align == alTop) {
- y = 0;
- } else if (align == alBottom) {
- int containerHeight = func->GetContainerHeight();
- y = (containerHeight - textVertical->Height());
- } else {
- y = func->GetNumericParameter(ptY);
- }
- if (x < 0) x = 0;
- x += x0;
- if (y < 0) y = func->GetContainerHeight() - textVertical->Height() - 5;
- y += y0;
- cPoint pos(x,y);
-
- if (func->IsAnimated()) {
- cRect posAnim(x, y, textVertical->Width(), textVertical->Height());
- DrawAnimatedImage(num, func, posAnim, textVertical);
- } else {
- DrawImage(num, pos, *textVertical);
- }
-}
-
-void cView::DoDrawTextBox(int num, cTemplateFunction *func, int x0, int y0) {
- string text = func->GetText(false);
- if (text.size() < 3)
- return;
- int x = func->GetNumericParameter(ptX);
- int y = func->GetNumericParameter(ptY);
- if (x < 0) x = 0;
- x += x0;
- if (y < 0) y = 0;
- y += y0;
- int width = func->GetNumericParameter(ptWidth);
- int height = func->GetNumericParameter(ptHeight);
- string fontName = func->GetFontName();
- int fontSize = func->GetNumericParameter(ptFontSize);
- int align = func->GetNumericParameter(ptAlign);
- int valign = func->GetNumericParameter(ptValign);
- int maxLines = func->GetNumericParameter(ptMaxLines);
- tColor clr = func->GetColorParameter(ptColor);
- tColor clrBack = clrTransparent;
- const cFont *font = fontManager->Font(fontName, fontSize);
- if (!font)
- return;
- fontManager->Lock();
- cTextWrapper wrapper;
- wrapper.Set(text.c_str(), font, width);
- fontManager->Unlock();
- int fontHeight = fontManager->Height(fontName, fontSize);
- int lines = wrapper.Lines();
- int yLine = y;
-
- if (height > 0 && valign == alCenter) {
- int totalHeight = lines * fontHeight;
- if (totalHeight < height) {
- yLine += (height - totalHeight) / 2;
- }
- }
-
- for (int line=0; line < lines; line++) {
- int xLine = x;
- if (align == alCenter) {
- int textWidth = font->Width(wrapper.GetLine(line));
- xLine += (width - textWidth)/2;
- } else if (align == alRight) {
- int textWidth = font->Width(wrapper.GetLine(line));
- xLine += (width - textWidth);
- }
- cPoint pos(xLine, yLine);
- if (maxLines > 0 && line == maxLines-1) {
- string lastLine = wrapper.GetLine(line);
- if (lines > maxLines) {
- lastLine += "...";
- }
- DrawText(num, pos, lastLine.c_str(), clr, clrBack, fontName, fontSize);
- break;
- } else if (line != (lines-1) && height > 0 && yLine - y + 2*fontHeight > height) {
- DrawText(num, pos, "...", clr, clrBack, fontName, fontSize);
- break;
- }
- DrawText(num, pos, wrapper.GetLine(line), clr, clrBack, fontName, fontSize);
- yLine += fontHeight;
- }
-}
-
-void cView::DoDrawFloatingTextBox(int num, cTemplateFunction *func) {
- string text = func->GetText(false);
- if (text.size() < 3)
- return;
- int x = func->GetNumericParameter(ptX);
- int y = func->GetNumericParameter(ptY);
- if (x < 0) x = 0;
- if (y < 0) y = 0;
- int width = func->GetNumericParameter(ptWidth);
- int height = func->GetNumericParameter(ptHeight);
- string fontName = func->GetFontName();
- int fontSize = func->GetNumericParameter(ptFontSize);
- tColor clr = func->GetColorParameter(ptColor);
- tColor clrBack = clrTransparent;
- const cFont *font = fontManager->Font(fontName, fontSize);
- if (!font)
- return;
- int floatType = func->GetNumericParameter(ptFloat);
- int floatWidth = func->GetNumericParameter(ptFloatWidth);
- int floatHeight = func->GetNumericParameter(ptFloatHeight);
-
- cTextWrapper wTextTall;
- cTextWrapper wTextFull;
-
- int fontHeight = fontManager->Height(fontName, fontSize);
- int linesNarrow = floatHeight / fontHeight;
- int widthNarrow = width - floatWidth;
- int linesDrawn = 0;
- int curY = 0;
- bool drawNarrow = true;
-
- splitstring s(text.c_str());
- std::vector<std::string> flds = s.split('\n', 1);
-
- if (flds.size() < 1)
- return;
-
- std::stringstream sstrTextTall;
- std::stringstream sstrTextFull;
-
- for (int i=0; i < (int)flds.size(); i++) {
- if (!flds[i].size()) {
- //empty line
- linesDrawn++;
- curY += fontHeight;
- if (drawNarrow)
- sstrTextTall << "\n";
- else
- sstrTextFull << "\n";
- } else {
- cTextWrapper wrapper;
- if (drawNarrow) {
- fontManager->Lock();
- wrapper.Set((flds[i].c_str()), font, widthNarrow);
- fontManager->Unlock();
- int newLines = wrapper.Lines();
- //check if wrapper fits completely into narrow area
- if (linesDrawn + newLines < linesNarrow) {
- for (int line = 0; line < wrapper.Lines(); line++) {
- sstrTextTall << wrapper.GetLine(line) << " ";
- }
- sstrTextTall << "\n";
- linesDrawn += newLines;
- } else {
- //this wrapper has to be splitted
- for (int line = 0; line < wrapper.Lines(); line++) {
- if (line + linesDrawn < linesNarrow) {
- sstrTextTall << wrapper.GetLine(line) << " ";
- } else {
- sstrTextFull << wrapper.GetLine(line) << " ";
- }
- }
- sstrTextFull << "\n";
- drawNarrow = false;
- }
- } else {
- fontManager->Lock();
- wrapper.Set((flds[i].c_str()), font, width);
- fontManager->Unlock();
- for (int line = 0; line < wrapper.Lines(); line++) {
- sstrTextFull << wrapper.GetLine(line) << " ";
- }
- sstrTextFull << "\n";
- }
- }
- }
- //VDRs textwrapper swallows linebreaks at the end, so we have to fix that manually
- string textTall = sstrTextTall.str();
- size_t posLastCarriageReturn = textTall.find_last_not_of("\n");
-
- int numLinesToAddAtTall = 0;
- if (posLastCarriageReturn != string::npos && (posLastCarriageReturn < textTall.size() - 1)) {
- numLinesToAddAtTall = textTall.size() - posLastCarriageReturn - 2;
- }
- fontManager->Lock();
- wTextTall.Set(textTall.c_str(), font, widthNarrow);
- fontManager->Unlock();
- fontManager->Lock();
- wTextFull.Set(sstrTextFull.str().c_str(), font, width);
- fontManager->Unlock();
-
- int textLinesTall = wTextTall.Lines();
- int textLinesFull = wTextFull.Lines();
-
- int textXTall = x;
- if (floatType == flTopLeft)
- textXTall = x + floatWidth;
-
- int yLine = y;
- for (int line=0; line < textLinesTall; line++) {
- cPoint pos(textXTall, yLine);
- DrawText(num, pos, wTextTall.GetLine(line), clr, clrBack, fontName, fontSize);
- yLine += fontHeight;
- }
-
- if (numLinesToAddAtTall) {
- yLine += numLinesToAddAtTall * fontHeight;
- }
-
- for (int line=0; line < textLinesFull; line++) {
- cPoint pos(x, yLine);
- if (height > 0 && yLine - y + 2*fontHeight > height) {
- DrawText(num, pos, "...", clr, clrBack, fontName, fontSize);
- break;
- }
- DrawText(num, pos, wTextFull.GetLine(line), clr, clrBack, fontName, fontSize);
- yLine += fontHeight;
- }
-}
-
-void cView::DoDrawRectangle(int num, cTemplateFunction *func, int x0, int y0) {
- int x = func->GetNumericParameter(ptX);
- int y = func->GetNumericParameter(ptY);
- if (x < 0) x = 0;
- x += x0;
- if (y < 0) y = 0;
- y += y0;
- int w = func->GetNumericParameter(ptWidth);
- int h = func->GetNumericParameter(ptHeight);
- cRect size(x, y, w, h);
- tColor clr = func->GetColorParameter(ptColor);
-
- if (func->IsAnimated()) {
- DrawAnimatedOsdObject(num, func, size, clr, 0);
- } else {
- DrawRectangle(num, size, clr);
- }
-}
-
-void cView::DoDrawEllipse(int num, cTemplateFunction *func, int x0, int y0) {
- int x = func->GetNumericParameter(ptX);
- int y = func->GetNumericParameter(ptY);
- if (x < 0) x = 0;
- x += x0;
- if (y < 0) y = 0;
- y += y0;
- int w = func->GetNumericParameter(ptWidth);
- int h = func->GetNumericParameter(ptHeight);
- cRect size(x, y, w, h);
- tColor clr = func->GetColorParameter(ptColor);
- int quadrant = func->GetNumericParameter(ptQuadrant);
- if (quadrant < -4 || quadrant > 8) {
- esyslog("skindesigner: wrong quadrant %d for drawellipse, allowed values are from -4 to 8", quadrant);
- quadrant = 0;
- }
-
- if (func->IsAnimated()) {
- DrawAnimatedOsdObject(num, func, size, clr, quadrant);
- } else {
- DrawEllipse(num, size, clr, quadrant);
- }
-}
-
-void cView::DoDrawSlope(int num, cTemplateFunction *func, int x0, int y0) {
- int x = func->GetNumericParameter(ptX);
- int y = func->GetNumericParameter(ptY);
- if (x < 0) x = 0;
- x += x0;
- if (y < 0) y = 0;
- y += y0;
- int w = func->GetNumericParameter(ptWidth);
- int h = func->GetNumericParameter(ptHeight);
- cRect size(x, y, w, h);
- tColor clr = func->GetColorParameter(ptColor);
- int type = func->GetNumericParameter(ptType);
- if (type < 0 || type > 7) {
- esyslog("skindesigner: wrong type %d for drawslope, allowed values are from 0 to 7", type);
- type = 0;
- }
- if (func->IsAnimated()) {
- DrawAnimatedOsdObject(num, func, size, clr, type);
- } else {
- DrawSlope(num, size, clr, type);
- }
-}
-
-void cView::DoDrawImage(int num, cTemplateFunction *func, int x0, int y0) {
- int x = func->GetNumericParameter(ptX);
- int y = func->GetNumericParameter(ptY);
- if (x < 0) x = 0;
- x += x0;
- if (y < 0) y = 0;
- y += y0;
- cPoint pos(x,y);
- int width = func->GetNumericParameter(ptWidth);
- int height = func->GetNumericParameter(ptHeight);
- string path = func->GetImagePath();
- eImageType type = (eImageType)func->GetNumericParameter(ptImageType);
- switch (type) {
- case itChannelLogo: {
- cImage *logo = imgCache->GetLogo(path, width, height);
- if (logo) {
- if (func->IsAnimated()) {
- cRect posAnim(x, y, width, height);
- DrawAnimatedImage(num, func, posAnim, logo);
- } else {
- DrawImage(num, pos, *logo);
- }
- }
- break; }
- case itSepLogo: {
- cImage *sepLogo = imgCache->GetSeparatorLogo(path, width, height);
- if (sepLogo) {
- if (func->IsAnimated()) {
- cRect posAnim(x, y, width, height);
- DrawAnimatedImage(num, func, posAnim, sepLogo);
- } else {
- DrawImage(num, pos, *sepLogo);
- }
- }
- break; }
- case itSkinPart: {
- cImage *skinpart = imgCache->GetSkinpart(path, width, height);
- if (skinpart) {
- if (func->IsAnimated()) {
- cRect posAnim(x, y, width, height);
- DrawAnimatedImage(num, func, posAnim, skinpart);
- } else {
- DrawImage(num, pos, *skinpart);
- }
- }
- break; }
- case itIcon: {
- cImage *icon = imgCache->GetIcon(type, path, width, height);
- if (icon) {
- if (func->IsAnimated()) {
- cRect posAnim(x, y, width, height);
- DrawAnimatedImage(num, func, posAnim, icon);
- } else {
- DrawImage(num, pos, *icon);
- }
- }
- break; }
- case itMenuIcon: {
- cImage *icon = imgCache->GetIcon(type, path, width, height);
- if (icon) {
- if (func->IsAnimated()) {
- cRect posAnim(x, y, width, height);
- DrawAnimatedImage(num, func, posAnim, icon);
- } else {
- DrawImage(num, pos, *icon);
- }
- }
- break; }
- case itImage: {
- cImageLoader imgLoader;
- if (imgLoader.LoadImage(path.c_str())) {
- cImage *image = imgLoader.CreateImage(width, height);
- DrawImage(num, pos, *image);
- delete(image);
- }
- break; }
- default:
- break;
- }
-}
-
-void cView::DrawAnimatedImage(int numPix, cTemplateFunction *func, cRect &pos, cImage *image) {
- int layer = Layer(numPix);
- cRect posAnim = CalculateAnimationClip(numPix, pos);
- eAnimType animType = (eAnimType)func->GetNumericParameter(ptAnimType);
- int animFreq = func->GetNumericParameter(ptAnimFreq);
-
- cAnimatedImage *anim = new cAnimatedImage(animType, animFreq, posAnim, layer);
- animations.insert(pair<int, cAnimation*>(animCat, anim));
- anim->SetDelay(AnimationDelay());
- anim->SetImage(image);
- anim->Start();
-}
-
-void cView::DrawAnimatedText(int numPix, cTemplateFunction *func, cPoint &pos, string text, tColor col, string fontName, int fontSize) {
- int layer = Layer(numPix);
- int textWidth = fontManager->Width(fontName, fontSize, text.c_str());
- int textHeight = fontManager->Height(fontName, fontSize);
- cRect posOrig(pos.X(), pos.Y(), textWidth, textHeight);
- cRect posAnim = CalculateAnimationClip(numPix, posOrig);
- eAnimType animType = (eAnimType)func->GetNumericParameter(ptAnimType);
- int animFreq = func->GetNumericParameter(ptAnimFreq);
-
- cAnimatedText *anim = new cAnimatedText(animType, animFreq, posAnim, layer);
- animations.insert(pair<int, cAnimation*>(animCat, anim));
- anim->SetDelay(AnimationDelay());
- anim->SetText(text);
- anim->SetFont(fontName);
- anim->SetFontSize(fontSize);
- anim->SetFontColor(col);
- anim->Start();
-}
-
-void cView::DrawAnimatedOsdObject(int numPix, cTemplateFunction *func, cRect &pos, tColor col, int quadrant) {
- int layer = Layer(numPix);
- cRect posAnim = CalculateAnimationClip(numPix, pos);
- eFuncType funcType = func->GetType();
- eAnimType animType = (eAnimType)func->GetNumericParameter(ptAnimType);
- int animFreq = func->GetNumericParameter(ptAnimFreq);
-
- cAnimatedOsdObject *anim = new cAnimatedOsdObject(funcType, animType, animFreq, posAnim, layer);
- animations.insert(pair<int, cAnimation*>(animCat, anim));
- anim->SetDelay(AnimationDelay());
- anim->SetColor(col);
- anim->SetQuadrant(quadrant);
- anim->Start();
-}
-
-cRect cView::CalculateAnimationClip(int numPix, cRect &pos) {
- cPoint posPix;
- Pos(numPix, posPix);
- cRect posAnim;
- posAnim.SetX(posPix.X() + pos.X());
- posAnim.SetY(posPix.Y() + pos.Y());
- posAnim.SetWidth(pos.Width());
- posAnim.SetHeight(pos.Height());
- return posAnim;
-}
-
-/***********************************************************************
-* cViewElement
-************************************************************************/
-
-cViewElement::cViewElement(cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
- init = true;
- fadeOut = false;
- ve = veUndefined;
- helper = NULL;
- SetTokens = NULL;
- tmplViewElement->SetPixOffset(0);
- delay = tmplViewElement->GetNumericParameter(ptDelay);
- SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
- SetShiftTime(tmplViewElement->GetNumericParameter(ptShiftTime));
- SetStartPos(tmplViewElement->GetNumericParameter(ptStartX), tmplViewElement->GetNumericParameter(ptStartY));
- SetShiftType(tmplViewElement->GetNumericParameter(ptShiftType));
- SetShiftMode(tmplViewElement->GetNumericParameter(ptShiftMode));
-}
-
-cViewElement::cViewElement(cTemplateViewElement *tmplViewElement, cViewHelpers *helper) : cView(tmplViewElement) {
- init = true;
- fadeOut = false;
- ve = veUndefined;
- this->helper = helper;
- SetTokens = NULL;
- tmplViewElement->SetPixOffset(0);
- delay = tmplViewElement->GetNumericParameter(ptDelay);
- SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
- SetShiftTime(tmplViewElement->GetNumericParameter(ptShiftTime));
- SetStartPos(tmplViewElement->GetNumericParameter(ptStartX), tmplViewElement->GetNumericParameter(ptStartY));
- SetShiftType(tmplViewElement->GetNumericParameter(ptShiftType));
- SetShiftMode(tmplViewElement->GetNumericParameter(ptShiftMode));
-}
-
-cViewElement::~cViewElement() {
- CancelSave();
-}
-
-bool cViewElement::Render(void) {
- if (!helper || !SetTokens) {
- return false;
- }
- ClearTokens();
- bool done = (helper->*SetTokens)(init, stringTokens, intTokens);
- if (!done) {
- return false;
- }
- init = false;
- ClearViewElement(ve);
- DrawViewElement(ve, &stringTokens, &intTokens);
- return true;
-}
-
-void cViewElement::Clear(void) {
- ClearViewElement(ve);
-}
-
-void cViewElement::Action(void) {
- DoSleep(delay);
- if (!Running())
- return;
- Render();
- SetInitFinished();
- if (IsAnimated()) {
- ShiftIn();
- } else {
- FadeIn();
- }
- DoFlush();
- if (scrolling) {
- DoSleep(scrollDelay);
- if (!Running())
- return;
- if (scrollOrientation == orHorizontal) {
- ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
- } else {
- ScrollVertical(scrollingPix, scrollDelay, scrollSpeed);
- }
- }
-}
-
-void cViewElement::ClearTokens(void) {
- stringTokens.clear();
- intTokens.clear();
-}
-
-
-/***********************************************************************
-* cViewListItem
-************************************************************************/
-
-cViewListItem::cViewListItem(cTemplateViewElement *tmplItem) : cView(tmplItem) {
- fadeOut = false;
- pos = -1;
- numTotal = 0;
- align = alLeft;
- listOrientation = orVertical;
-}
-
-cViewListItem::~cViewListItem() {
-
-}
-
-cRect cViewListItem::DrawListItem(map <string,string> *stringTokens, map <string,int> *intTokens) {
- cRect posItem;
- if (!tmplViewElement)
- return posItem;
-
- if (tmplViewElement->DebugTokens()) {
- DebugTokens("ListItem", stringTokens, intTokens);
- }
-
- tmplViewElement->InitPixmapIterator();
- int pixCurrent = 0;
- cTemplatePixmapNode *pixNode = NULL;
- while(pixNode = tmplViewElement->GetNextPixmapNode()) {
- cTemplatePixmap *pix = dynamic_cast<cTemplatePixmap*>(pixNode);
- if (pix) {
- SetListElementPosition(pix);
- if (pixCurrent == 0) {
- posItem = pix->GetPixmapSize();
- }
- bool draw = PrepareListItemPixmap(pixCurrent, pix, stringTokens, intTokens);
- if (draw) {
- DrawPixmap(pixCurrent, pix);
- }
- pixCurrent++;
- } else {
- cTemplatePixmapContainer *pixContainer = dynamic_cast<cTemplatePixmapContainer*>(pixNode);
- pixContainer->ParseDynamicParameters(stringTokens, intTokens);
- if (pixContainer->DoDebug()) {
- pixContainer->Debug();
- }
- if (!pixContainer->DoExecute()) {
- pixCurrent += pixContainer->NumPixmaps();
- continue;
- }
- pixContainer->InitIterator();
- cTemplatePixmap *pix = NULL;
- while (pix = pixContainer->GetNextPixmap()) {
- SetListElementPosition(pix);
- bool draw = PrepareListItemPixmap(pixCurrent, pix, stringTokens, intTokens);
- if (draw) {
- DrawPixmap(pixCurrent, pix);
- }
- pixCurrent++;
- }
- }
- }
- return posItem;
-}
-
-bool cViewListItem::PrepareListItemPixmap(int num, cTemplatePixmap *pix, map <string,string> *stringTokens, map <string,int> *intTokens) {
- if (!PixmapExists(num)) {
- pix->ParseDynamicParameters(stringTokens, intTokens, true);
- } else {
- pix->ParseDynamicParameters(stringTokens, intTokens, false);
- }
- if (!PixmapExists(num) && pix->Ready() && pix->DoExecute() && !pix->Scrolling()) {
- CreateViewPixmap(num, pix);
- }
- //if pixmap still not valid, skip
- if (!pix->Ready() && !pix->Scrolling()) {
- return false;
- }
- //if condition for pixmap set, check if cond is true
- if (!pix->DoExecute()) {
- return false;
- }
-
- pix->ClearDynamicFunctionParameters();
- pix->ParseDynamicFunctionParameters(stringTokens, intTokens, NULL);
-
- if (!PixmapExists(num) && pix->Scrolling()) {
- cSize drawportSize;
- scrolling = pix->CalculateDrawPortSize(drawportSize);
- pix->SetScrollingTextWidth();
- if (scrolling) {
- CreateScrollingPixmap(num, pix, drawportSize);
- scrollingPix = num;
- scrollOrientation = pix->GetNumericParameter(ptOrientation);
- scrollMode = pix->GetNumericParameter(ptScrollMode);
- scrollDelay = pix->GetNumericParameter(ptDelay);
- scrollSpeed = pix->GetNumericParameter(ptScrollSpeed);
- } else {
- CreateViewPixmap(num, pix);
- }
- }
- if (pix->DoDebug()) {
- pix->Debug();
- }
- return true;
-}
-
-void cViewListItem::ClearListItem(void) {
- int pixMax = NumPixmaps();
- for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
- Fill(pixCurrent, clrTransparent);
- }
- ClearAnimations(0);
-}
-
-void cViewListItem::SetListElementPosition(cTemplatePixmap *pix) {
- int itemWidth = pix->GetNumericParameter(ptWidth);
- int itemHeight = pix->GetNumericParameter(ptHeight);
- int x = 0;
- int y = 0;
- if (listOrientation == orHorizontal) {
- x = container.X();
- int totalWidth = numTotal * itemWidth;
- if (align == alCenter) {
- y += (container.Width() - totalWidth) / 2;
- } else if (align == alBottom) {
- y += (container.Width() - totalWidth);
- }
- x += pos * itemWidth;
- y = pix->GetNumericParameter(ptY);
- } else if (listOrientation == orVertical) {
- y = container.Y();
- int totalHeight = numTotal * itemHeight;
- if (align == alCenter) {
- y += (container.Height() - totalHeight) / 2;
- } else if (align == alBottom) {
- y += (container.Height() - totalHeight);
- }
- y += pos * itemHeight;
- x = pix->GetNumericParameter(ptX);
- }
- pix->SetX(x);
- pix->SetY(y);
-}
-
-/***********************************************************************
-* cGrid
-************************************************************************/
-
-cGrid::cGrid(cTemplateViewElement *tmplGrid) : cView(tmplGrid) {
- fadeOut = false;
- dirty = true;
- moved = true;
- resized = true;
- current = false;
- x = 0.0;
- y = 0.0;
- width = 0.0;
- height = 0.0;
-}
-
-cGrid::~cGrid() {
-}
-
-void cGrid::Set(double x, double y, double width, double height,
- map <string,int> *intTokens, map <string,string> *stringTokens) {
-
- if ((width != this->width) || (height != this->height)) {
- this->width = width;
- this->height = height;
- resized = true;
- dirty = false;
- } else {
- resized = false;
- }
- if (this->x != x || this->y != y) {
- this->x = x;
- this->y = y;
- moved = true;
- } else {
- moved = false;
- }
- if (intTokens) {
- this->intTokens = *intTokens;
- SetCurrent(current);
- dirty = true;
- }
- if (stringTokens) {
- this->stringTokens = *stringTokens;
- dirty = true;
- }
-}
-
-void cGrid::SetCurrent(bool current) {
- this->current = current;
- if (!resized)
- dirty = true;
- intTokens.erase("current");
- intTokens.insert(pair<string,int>("current", current));
-}
-
-void cGrid::Move(void) {
- if (!tmplViewElement)
- return;
- tmplViewElement->InitPixmapIterator();
- cTemplatePixmap *pix = NULL;
- int pixCurrent = 0;
-
- while(pix = tmplViewElement->GetNextPixmap()) {
- PositionPixmap(pix);
- cRect pixViewPort = pix->GetPixmapSize();
- SetViewPort(pixCurrent, pixViewPort);
- pixCurrent++;
- }
- dirty = false;
- resized = false;
- moved = false;
-}
-
-void cGrid::Draw(void) {
- if (!tmplViewElement)
- return;
- if (tmplViewElement->DebugTokens()) {
- DebugTokens("Grid", &stringTokens, &intTokens);
- }
-
- tmplViewElement->InitPixmapIterator();
- int pixCurrent = 0;
- cTemplatePixmapNode *pixNode = NULL;
- while(pixNode = tmplViewElement->GetNextPixmapNode()) {
- cTemplatePixmap *pix = dynamic_cast<cTemplatePixmap*>(pixNode);
- if (pix) {
- PositionPixmap(pix);
- bool draw = PrepareGridPixmap(pixCurrent, pix);
- if (pix->DoDebug())
- pix->Debug();
- if (draw) {
- DrawPixmap(pixCurrent, pix);
- }
- pixCurrent++;
- } else {
- cTemplatePixmapContainer *pixContainer = dynamic_cast<cTemplatePixmapContainer*>(pixNode);
- pixContainer->ParseDynamicParameters(&stringTokens, &intTokens);
- if (pixContainer->DoDebug()) {
- pixContainer->Debug();
- }
- if (!pixContainer->DoExecute()) {
- pixCurrent += pixContainer->NumPixmaps();
- continue;
- }
- pixContainer->InitIterator();
- cTemplatePixmap *pix = NULL;
- while (pix = pixContainer->GetNextPixmap()) {
- PositionPixmap(pix);
- bool draw = PrepareGridPixmap(pixCurrent, pix);
- if (pix->DoDebug())
- pix->Debug();
- if (draw) {
- DrawPixmap(pixCurrent, pix);
- }
- pixCurrent++;
- }
-
-
- }
- }
- dirty = false;
- resized = false;
- moved = false;
-}
-
-bool cGrid::PrepareGridPixmap(int num, cTemplatePixmap *pix) {
- if (!PixmapExists(num)) {
- pix->ParseDynamicParameters(&stringTokens, &intTokens, true);
- } else {
- pix->ParseDynamicParameters(&stringTokens, &intTokens, false);
- }
- if (!PixmapExists(num) && pix->Ready() && pix->DoExecute() && !pix->Scrolling()) {
- CreateViewPixmap(num, pix);
- }
- //if pixmap still not valid, skip
- if (!pix->Ready() && !pix->Scrolling()) {
- return false;
- }
- //if condition for pixmap set, check if cond is true
- if (!pix->DoExecute()) {
- return false;
- }
- pix->ClearDynamicFunctionParameters();
- pix->ParseDynamicFunctionParameters(&stringTokens, &intTokens, NULL);
- return true;
-}
-
-void cGrid::Clear(void) {
- int pixMax = NumPixmaps();
- for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
- Fill(pixCurrent, clrTransparent);
- }
- ClearAnimations(0);
-}
-
-void cGrid::DeletePixmaps(void) {
- int pixMax = NumPixmaps();
- for (int pixCurrent = 0; pixCurrent < pixMax; pixCurrent++) {
- DestroyPixmap(pixCurrent);
- }
- ClearAnimations(0);
-}
-
-void cGrid::PositionPixmap(cTemplatePixmap *pix) {
- pix->SetXPercent(x);
- pix->SetYPercent(y);
- pix->SetWidthPercent(width);
- pix->SetHeightPercent(height);
- pix->CalculateParameters();
-}
diff --git a/views/view.h b/views/view.h
deleted file mode 100644
index d530f83..0000000
--- a/views/view.h
+++ /dev/null
@@ -1,155 +0,0 @@
-#ifndef __VIEW_H
-#define __VIEW_H
-
-#include "string"
-#include "map"
-#include "../libcore/pixmapcontainer.h"
-#include "../libtemplate/template.h"
-#include "viewhelpers.h"
-#include "animation.h"
-
-using namespace std;
-
-class cViewElement;
-
-class cView : public cPixmapContainer {
-private:
- cMutex mutex;
- void Init(void);
- void DoDrawDebugGrid(void);
- void DoFill(int num, cTemplateFunction *func);
- void DoDrawText(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
- void DoDrawTextVertical(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
- void DoDrawTextBox(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
- void DoDrawFloatingTextBox(int num, cTemplateFunction *func);
- void DoDrawRectangle(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
- void DoDrawEllipse(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
- void DoDrawSlope(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
- void DoDrawImage(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
- void DrawAnimatedImage(int numPix, cTemplateFunction *func, cRect &pos, cImage *image);
- void DrawAnimatedText(int numPix, cTemplateFunction *func, cPoint &pos, string text, tColor col, string fontName, int fontSize);
- void DrawAnimatedOsdObject(int numPix, cTemplateFunction *func, cRect &pos, tColor col, int quadrant);
- cRect CalculateAnimationClip(int numPix, cRect &pos);
- void ActivateScrolling(void);
-protected:
- cTemplateView *tmplView;
- cTemplateViewElement *tmplViewElement;
- cTemplateViewTab *tmplTab;
- //detached viewelements
- map < eViewElement, cViewElement* > detachedViewElements;
- //animated elements
- multimap < int, cAnimation* > animations;
- //scaling window
- cRect scalingWindow;
- bool tvScaled;
- bool viewInit;
- //do fadeout or shiftout only for views, not for childs
- bool fadeOut;
- //true if view is scrollable in general
- bool scrolling;
- //true if view is actually starting scrolling
- bool currentlyScrolling;
- eViewElement veScroll;
- int scrollingPix;
- int scrollOrientation;
- int scrollDelay;
- int scrollMode;
- int scrollSpeed;
- int animCat;
- void DrawViewElement(eViewElement ve, map <string,string> *stringTokens = NULL, map <string,int> *intTokens = NULL, map < string, vector< map< string, string > > > *loopTokens = NULL);
- bool PreparePixmap(eViewElement ve, int num, cTemplatePixmap *pix, map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens);
- void ClearViewElement(eViewElement ve);
- void DestroyViewElement(eViewElement ve);
- void DestroyDetachedViewElement(eViewElement ve);
- void ClearAnimations(int cat);
- 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);
- void DrawLoop(int numPixmap, cTemplateFunction *func, map < string, vector< map< string, string > > > *loopTokens);
- void DebugTokens(string viewElement, map<string,string> *stringTokens, map<string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens = NULL);
- virtual void Action(void);
-public:
- cView(cTemplateView *tmplView);
- cView(cTemplateViewElement *tmplViewElement);
- cView(cTemplateViewTab *tmplTab);
- virtual ~cView();
- void Lock(void) { mutex.Lock(); };
- void Unlock(void) { mutex.Unlock(); };
- void DrawDebugGrid(void);
- virtual void Stop(void);
- void HideAnimations(void);
- void ShowAnimations(void);
-};
-
-class cViewElement : public cView {
-private:
-protected:
- bool init;
- eViewElement ve;
- int delay;
- stringmap stringTokens;
- intmap intTokens;
- bool (cViewHelpers::*SetTokens)(bool, stringmap&, intmap&);
- cViewHelpers *helper;
- void Action(void);
- void ClearTokens(void);
-public:
- cViewElement(cTemplateViewElement *tmplViewElement);
- cViewElement(cTemplateViewElement *tmplViewElement, cViewHelpers *helper);
- virtual ~cViewElement();
- void SetCallback(eViewElement ve, bool (cViewHelpers::*SetTokens)(bool, stringmap&, intmap&)) { this->ve = ve; this->SetTokens = SetTokens; };
- virtual bool Render(void);
- void Clear(void);
- bool Starting(void) { return Running(); };
-};
-
-class cViewListItem : public cView {
-protected:
- int pos;
- int numTotal;
- cRect container;
- int align;
- int listOrientation;
- void SetListElementPosition(cTemplatePixmap *pix);
- bool PrepareListItemPixmap(int num, cTemplatePixmap *pix, map <string,string> *stringTokens, map <string,int> *intTokens);
-public:
- cViewListItem(cTemplateViewElement *tmplItem);
- virtual ~cViewListItem();
- cRect DrawListItem(map <string,string> *stringTokens, map <string,int> *intTokens);
- void ClearListItem(void);
-};
-
-class cGrid : public cView {
-protected:
- bool dirty;
- bool moved;
- bool resized;
- bool current;
- double x;
- double y;
- double width;
- double height;
- map <string,string> stringTokens;
- map <string,int> intTokens;
- void PositionPixmap(cTemplatePixmap *pix);
- bool PrepareGridPixmap(int num, cTemplatePixmap *pix);
-public:
- cGrid(cTemplateViewElement *tmplGrid);
- virtual ~cGrid();
- bool Dirty(void) { return dirty; };
- bool Moved(void) { return moved; };
- bool Resized(void) { return resized; };
- void Set(double x, double y, double width, double height, map <string,int> *intTokens, map <string,string> *stringTokens);
- void SetCurrent(bool current);
- void Move(void);
- void Draw(void);
- void Clear(void);
- void DeletePixmaps(void);
-};
-
-#endif //__VIEW_H \ No newline at end of file
diff --git a/views/viewgrid.c b/views/viewgrid.c
deleted file mode 100644
index 551fb9e..0000000
--- a/views/viewgrid.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "viewgrid.h"
-
-using namespace std;
-
-cViewGrid::cViewGrid(cTemplateViewGrid *tmplGrid) {
- this->tmplGrid = tmplGrid;
-}
-
-cViewGrid::~cViewGrid() {
- Clear();
-}
-
-void cViewGrid::SetGrid(long gridID,
- double x, double y, double width, double height,
- map<string,int> *intTokens, map<string,string> *stringTokens) {
- map < long, cGrid* >::iterator hit = grids.find(gridID);
- cGrid *grid;
- if (hit == grids.end()) {
- grid = new cGrid(tmplGrid);
- grid->Set(x, y, width, height, intTokens, stringTokens);
- grids.insert(pair<long,cGrid*>(gridID, grid));
- } else {
- (hit->second)->Set(x, y, width, height, intTokens, stringTokens);
- }
-}
-
-void cViewGrid::SetCurrent(long gridID, bool current) {
- map<long,cGrid*>::iterator hit = grids.find(gridID);
- if (hit != grids.end())
- (hit->second)->SetCurrent(current);
-}
-
-void cViewGrid::Delete(long gridID) {
- map<long,cGrid*>::iterator hit = grids.find(gridID);
- if (hit == grids.end())
- return;
- delete (hit->second);
- grids.erase(gridID);
-}
-
-void cViewGrid::Clear(void) {
- for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++)
- delete it->second;
- grids.clear();
-}
-
-void cViewGrid::Render(void) {
- for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
- cGrid *grid = it->second;
- if (grid->Dirty()) {
- if (grid->Moved()) {
- grid->Move();
- }
- grid->Clear();
- //esyslog("skindesigner: rendering grid %ld", it->first);
- grid->Draw();
- } else if (grid->Resized()) {
- //esyslog("skindesigner: resizing grid %ld", it->first);
- grid->DeletePixmaps();
- grid->Draw();
- } else if (grid->Moved()) {
- //esyslog("skindesigner: moving grid %ld", it->first);
- grid->Move();
- } else {
- //esyslog("skindesigner: skipping grid %ld", it->first);
- }
- }
-}
-
-void cViewGrid::Hide(void) {
- for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
- cGrid *grid = it->second;
- grid->HidePixmaps();
- grid->HideAnimations();
- }
-}
-
-void cViewGrid::Show(void) {
- for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
- cGrid *grid = it->second;
- grid->ShowPixmaps();
- grid->ShowAnimations();
- }
-}
-
-
-void cViewGrid::Debug(void) {
-
-} \ No newline at end of file
diff --git a/views/viewgrid.h b/views/viewgrid.h
deleted file mode 100644
index 0fc11f6..0000000
--- a/views/viewgrid.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __VIEWGRID_H
-#define __VIEWGRID_H
-
-#include "string"
-#include "map"
-#include "view.h"
-#include "../libtemplate/templateviewgrid.h"
-
-using namespace std;
-
-class cViewGrid {
-private:
- cTemplateViewGrid *tmplGrid;
- map < long, cGrid* > grids;
-public:
- cViewGrid(cTemplateViewGrid *tmplGrid);
- virtual ~cViewGrid();
- void SetGrid(long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens);
- void SetCurrent(long gridID, bool current);
- void Delete(long gridID);
- void Clear(void);
- void Render(void);
- void Hide(void);
- void Show(void);
- void Debug(void);
-};
-
-#endif //__DISPLAYMENULISTVIEW_H \ No newline at end of file
diff --git a/views/viewhelpers.c b/views/viewhelpers.c
deleted file mode 100644
index 45101d3..0000000
--- a/views/viewhelpers.c
+++ /dev/null
@@ -1,1276 +0,0 @@
-#include <fstream>
-#include <iostream>
-#include <list>
-#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;
- lastEcmInfo.hops = -1;
- lastEcmInfo.ecmtime = -1;
- lastEcmInfo.caid = -1;
- lastEcmInfo.pid = -1;
- lastEcmInfo.prid = -1;
- lastVdrCPU = "undefined";
- lastVdrMEM = "undefined";
-}
-
-cViewHelpers::~cViewHelpers() {
- if (devicesInit) {
- mutexDevices.Lock();
- delete[] lastSignalStrength;
- lastSignalStrength = NULL;
- delete[] lastSignalQuality;
- lastSignalQuality = NULL;
- delete[] recDevices;
- recDevices = NULL;
- mutexDevices.Unlock();
- }
-}
-
-/******************************************************************
-* Public Functions
-******************************************************************/
-bool cViewHelpers::SetDate(bool forced, stringmap &stringTokens, intmap &intTokens) {
- time_t t = time(0); // get time now
- struct tm * now = localtime(&t);
- int min = now->tm_min;
- if (!forced && min == lastMinute) {
- return false;
- }
- lastMinute = min;
-
- intTokens.insert(pair<string, int>("year", now->tm_year + 1900));
- intTokens.insert(pair<string, int>("day", now->tm_mday));
-
- char monthname[20];
- char monthshort[10];
- strftime(monthshort, sizeof(monthshort), "%b", now);
- strftime(monthname, sizeof(monthname), "%B", now);
-
- stringTokens.insert(pair<string,string>("monthname", monthname));
- stringTokens.insert(pair<string,string>("monthnameshort", monthshort));
- stringTokens.insert(pair<string,string>("month", *cString::sprintf("%02d", now->tm_mon + 1)));
- stringTokens.insert(pair<string,string>("dayleadingzero", *cString::sprintf("%02d", now->tm_mday)));
- stringTokens.insert(pair<string,string>("dayname", *WeekDayNameFull(now->tm_wday)));
- stringTokens.insert(pair<string,string>("daynameshort", *WeekDayName(now->tm_wday)));
- stringTokens.insert(pair<string,string>("time", *TimeString(t)));
-
- return true;
-}
-
-bool cViewHelpers::SetTime(bool forced, stringmap &stringTokens, intmap &intTokens) {
- time_t t = time(0); // get time now
- struct tm * now = localtime(&t);
- int sec = now->tm_sec;
- if (!forced && sec == lastSecond) {
- return false;
- }
- int min = now->tm_min;
- int hour = now->tm_hour;
- int hourMinutes = hour%12 * 5 + min / 12;
-
- intTokens.insert(pair<string, int>("sec", sec));
- intTokens.insert(pair<string, int>("min", min));
- intTokens.insert(pair<string, int>("hour", hour));
- intTokens.insert(pair<string, int>("hmins", hourMinutes));
-
- lastSecond = sec;
- return true;
-}
-
-bool cViewHelpers::SetSignal(bool forced, stringmap &stringTokens, intmap &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::SetCurrentWeatherTokens(bool forced, stringmap &stringTokens, intmap &intTokens) {
- static cPlugin *pWeatherForecast = cPluginManager::GetPlugin("weatherforecast");
- if (!pWeatherForecast)
- return false;
- cServiceCurrentWeather currentWeather;
- if (!pWeatherForecast->Service("GetCurrentWeather", &currentWeather)) {
- return false;
- }
- stringTokens.insert(pair<string,string>("timestamp", currentWeather.timeStamp));
- stringTokens.insert(pair<string,string>("temperature", currentWeather.temperature));
- stringTokens.insert(pair<string,string>("apparenttemperature", currentWeather.apparentTemperature));
- stringTokens.insert(pair<string,string>("mintemperature", currentWeather.minTemperature));
- stringTokens.insert(pair<string,string>("maxtemperature", currentWeather.maxTemperature));
- stringTokens.insert(pair<string,string>("summary", currentWeather.summary));
- stringTokens.insert(pair<string,string>("icon", currentWeather.icon));
- stringTokens.insert(pair<string,string>("precipitationintensity", currentWeather.precipitationIntensity));
- intTokens.insert(pair<string,int>("precipitationprobability", currentWeather.precipitationProbability));
- stringTokens.insert(pair<string,string>("precipitationtype", currentWeather.precipitationType));
- intTokens.insert(pair<string,int>("humidity", currentWeather.humidity));
- stringTokens.insert(pair<string,string>("windspeed", currentWeather.windSpeed));
- intTokens.insert(pair<string,int>("windbearing", currentWeather.windBearing));
- stringTokens.insert(pair<string,string>("windbearingstring", currentWeather.windBearingString));
- stringTokens.insert(pair<string,string>("visibility", currentWeather.visibility));
- intTokens.insert(pair<string,int>("cloudcover", currentWeather.cloudCover));
- stringTokens.insert(pair<string,string>("pressure", currentWeather.pressure));
- stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone));
- return true;
-}
-
-bool cViewHelpers::SetDiscUsage(bool forced, stringmap &stringTokens, intmap &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));
- return true;
-}
-
-bool cViewHelpers::SetSystemLoad(bool forced, stringmap &stringTokens, intmap &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(bool forced, stringmap &stringTokens, intmap &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(bool forced, stringmap &stringTokens, intmap &intTokens) {
- cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/temperatures\"", SCRIPTFOLDER, SCRIPTFOLDER);
- int ok = system(*execCommand);
- if (ok) {}
-
- 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;
-}
-
-bool cViewHelpers::SetVDRStats(bool forced, stringmap &stringTokens, intmap &intTokens) {
- cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/vdrstats\"", SCRIPTFOLDER, SCRIPTFOLDER);
- int ok = system(*execCommand);
- if (ok) {}
-
- string vdrCPU = "";
- string vdrMEM = "";
-
- cString itemFilename = cString::sprintf("%s/vdrcpu", SCRIPTOUTPUTPATH );
- ifstream file(*itemFilename, ifstream::in);
- if( file.is_open() ) {
- std::getline(file, vdrCPU);
- file.close();
- }
-
- itemFilename = cString::sprintf("%s/vdrmem", SCRIPTOUTPUTPATH );
- ifstream file2(*itemFilename, ifstream::in);
- if( file2.is_open() ) {
- std::getline(file2, vdrMEM);
- file2.close();
- }
-
- if (vdrCPU.size() == 0 || vdrMEM.size() == 0)
- return false;
-
- if (!lastVdrCPU.compare(vdrCPU) && !lastVdrMEM.compare(vdrMEM)) {
- return false;
- }
- lastVdrCPU = vdrCPU;
- lastVdrMEM = vdrMEM;
-
- stringTokens.insert(pair<string,string>("vdrcpu", vdrCPU));
- stringTokens.insert(pair<string,string>("vdrmem", vdrMEM));
- return true;
-}
-
-
-bool cViewHelpers::SetDummy(bool forced, stringmap &stringTokens, intmap &intTokens) {
- return true;
-}
-
-/******************************************************************
-* Protected Functions
-******************************************************************/
-void cViewHelpers::InitDevices(void) {
- numDevices = cDevice::NumDevices();
- lastSignalStrength = new int[numDevices];
- lastSignalQuality = new int[numDevices];
- recDevices = new bool[numDevices];
- mutexDevices.Lock();
- for (int i=0; i<numDevices; i++) {
- lastSignalStrength[i] = 0;
- lastSignalQuality[i] = 0;
- recDevices[i] = false;
- }
- mutexDevices.Unlock();
- devicesInit = true;
-}
-
-bool cViewHelpers::SetDevices(bool initial, bool light, intmap *intTokens, vector<stringmap> *devices) {
- if (!initial) {
- if (light)
- return false;
- //check if drawing is necessary
- bool changed = false;
- for (int i = 0; i < numDevices; i++) {
- const cDevice *device = cDevice::GetDevice(i);
- if (!device || !device->NumProvidedSystems()) {
- continue;
- }
- int signalStrength = device->SignalStrength();
- int signalQuality = device->SignalQuality();
- int lastSigStr = 0;
- int lastSigQual = 0;
- mutexDevices.Lock();
- if (lastSignalStrength && lastSignalQuality) {
- lastSigStr = lastSignalStrength[i];
- lastSigQual = lastSignalQuality[i];
- }
- mutexDevices.Unlock();
- if ((signalStrength != lastSigStr) || (signalQuality != lastSigQual)) {
- changed = true;
- break;
- }
- }
- if (!changed) {
- return false;
- }
- }
- //check device which currently displays live tv
- int deviceLiveTV = -1;
- cDevice *primaryDevice = cDevice::PrimaryDevice();
- if (primaryDevice) {
- if (!primaryDevice->Replaying() || primaryDevice->Transferring())
- deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
- else
- deviceLiveTV = primaryDevice->DeviceNumber();
- }
- //check currently recording devices
- for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
- if (!timer->Recording()) {
- continue;
- }
- if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) {
- const cDevice *recDevice = RecordControl->Device();
- if (recDevice) {
- mutexDevices.Lock();
- if (recDevices)
- recDevices[recDevice->DeviceNumber()] = true;
- mutexDevices.Unlock();
- }
- }
- }
- int actualNumDevices = 0;
- for (int i = 0; i < numDevices; i++) {
- const cDevice *device = cDevice::GetDevice(i);
- if (!device || !device->NumProvidedSystems()) {
- continue;
- }
-
- stringmap deviceVals;
- stringstream strNum;
- strNum << actualNumDevices;
- actualNumDevices++;
- deviceVals.insert(pair< string, string >("devices[num]", strNum.str()));
- deviceVals.insert(pair< string, string >("devices[type]", *(device->DeviceType())));
- cCamSlot *camSlot = device->CamSlot();
- int camNumber = -1;
- if (camSlot) {
- camNumber = camSlot->SlotNumber();
- deviceVals.insert(pair< string, string >("devices[hascam]", "1"));
- } else {
- deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
- }
- stringstream strCamNumber;
- strCamNumber << camNumber;
- deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
-
- int signalStrength = 0;
- int signalQuality = 0;
- if (!light) {
- signalStrength = device->SignalStrength();
- signalQuality = device->SignalQuality();
- }
- stringstream strStrength;
- strStrength << signalStrength;
- deviceVals.insert(pair< string, string >("devices[signalstrength]", strStrength.str()));
- stringstream strQuality;
- strQuality << signalQuality;
- deviceVals.insert(pair< string, string >("devices[signalquality]", strQuality.str()));
-
- deviceVals.insert(pair< string, string >("devices[livetv]", i == deviceLiveTV ? "1" : "0"));
- string isRecording = "0";
- mutexDevices.Lock();
- if (recDevices && recDevices[i])
- isRecording = "1";
- mutexDevices.Unlock();
- deviceVals.insert(pair< string, string >("devices[recording]", isRecording));
-
- const cChannel *channel = device->GetCurrentlyTunedTransponder();
- const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
- if (channel && channel->Number() > 0) {
- stringstream strChanNum;
- strChanNum << channel->Number();
- deviceVals.insert(pair< string, string >("devices[channelnumber]", strChanNum.str()));
- deviceVals.insert(pair< string, string >("devices[channelname]", channel->Name()));
- string channelID = *(channel->GetChannelID().ToString());
- deviceVals.insert(pair< string, string >("devices[channelid]", channelID));
- deviceVals.insert(pair< string, string >("devices[channellogoexists]", imgCache->LogoExists(channelID) ? "1" : "0"));
- deviceVals.insert(pair< string, string >("devices[istuned]", "1"));
- } else {
- deviceVals.insert(pair< string, string >("devices[channelnumber]", "0"));
- deviceVals.insert(pair< string, string >("devices[channelname]", ""));
- deviceVals.insert(pair< string, string >("devices[channelid]", ""));
- deviceVals.insert(pair< string, string >("devices[channellogoexists]", "0"));
- deviceVals.insert(pair< string, string >("devices[istuned]", "0"));
- }
-
- deviceVals.insert(pair< string, string >("devices[source]", source ? source->Description() : ""));
-
- devices->push_back(deviceVals);
-
- lastSignalStrength[i] = signalStrength;
- lastSignalQuality[i] = signalQuality;
- }
-
- intTokens->insert(pair<string, int>("numdevices", actualNumDevices));
- return true;
-}
-
-bool cViewHelpers::CheckNewMails(void) {
- static cPlugin *pMailbox = cPluginManager::GetPlugin("mailbox");
- if (!pMailbox) {
- return false;
- }
- bool newMail = false;
- if (pMailbox->Service("MailBox-HasNewMail-1.0", &newMail)) {
- return newMail;
- }
- return false;
-}
-
-int cViewHelpers::GetLiveBuffer(void) {
- static cPlugin *pPermashift = cPluginManager::GetPlugin("permashift");
- if (!pPermashift) {
- return -1;
- }
- int buffer = 0;
- if (pPermashift->Service("Permashift-GetUsedBufferSecs-v1", &buffer)) {
- return buffer;
- }
- return -1;
-}
-
-void cViewHelpers::SetScraperTokens(const cEvent *event, const cRecording *recording, stringmap &stringTokens, intmap &intTokens, map < string, vector<stringmap> > &loopTokens) {
- static cPlugin *pScraper = GetScraperPlugin();
- if (!pScraper || (!event && !recording)) {
- intTokens.insert(pair<string,int>("ismovie", false));
- intTokens.insert(pair<string,int>("isseries", false));
- return;
- }
-
- ScraperGetEventType getType;
- getType.event = event;
- getType.recording = recording;
- if (!pScraper->Service("GetEventType", &getType)) {
- intTokens.insert(pair<string,int>("ismovie", false));
- intTokens.insert(pair<string,int>("isseries", false));
- return;
- }
-
- if (getType.type == tMovie) {
- cMovie movie;
- movie.movieId = getType.movieId;
- pScraper->Service("GetMovie", &movie);
- intTokens.insert(pair<string,int>("ismovie", true));
- intTokens.insert(pair<string,int>("isseries", false));
-
- stringTokens.insert(pair<string,string>("movietitle", movie.title));
- stringTokens.insert(pair<string,string>("movieoriginalTitle", movie.originalTitle));
- stringTokens.insert(pair<string,string>("movietagline", movie.tagline));
- stringTokens.insert(pair<string,string>("movieoverview", movie.overview));
- stringTokens.insert(pair<string,string>("moviegenres", movie.genres));
- stringTokens.insert(pair<string,string>("moviehomepage", movie.homepage));
- stringTokens.insert(pair<string,string>("moviereleasedate", movie.releaseDate));
- stringstream pop;
- pop << movie.popularity;
- stringTokens.insert(pair<string,string>("moviepopularity", pop.str()));
- stringstream vote;
- vote << movie.voteAverage;
- stringTokens.insert(pair<string,string>("movievoteaverage", pop.str()));
- stringTokens.insert(pair<string,string>("posterpath", movie.poster.path));
- stringTokens.insert(pair<string,string>("fanartpath", movie.fanart.path));
- stringTokens.insert(pair<string,string>("collectionposterpath", movie.collectionPoster.path));
- stringTokens.insert(pair<string,string>("collectionfanartpath", movie.collectionFanart.path));
-
- intTokens.insert(pair<string,int>("movieadult", movie.adult));
- intTokens.insert(pair<string,int>("moviebudget", movie.budget));
- intTokens.insert(pair<string,int>("movierevenue", movie.revenue));
- intTokens.insert(pair<string,int>("movieruntime", movie.runtime));
- intTokens.insert(pair<string,int>("posterwidth", movie.poster.width));
- intTokens.insert(pair<string,int>("posterheight", movie.poster.height));
- intTokens.insert(pair<string,int>("fanartwidth", movie.fanart.width));
- intTokens.insert(pair<string,int>("fanartheight", movie.fanart.height));
- intTokens.insert(pair<string,int>("collectionposterwidth", movie.collectionPoster.width));
- intTokens.insert(pair<string,int>("collectionposterheight", movie.collectionPoster.height));
- intTokens.insert(pair<string,int>("collectionfanartwidth", movie.collectionFanart.width));
- intTokens.insert(pair<string,int>("collectionfanartheight", movie.collectionFanart.height));
-
- vector< map< string, string > > actors;
- for (vector<cActor>::iterator act = movie.actors.begin(); act != movie.actors.end(); act++) {
- map< string, string > actor;
- actor.insert(pair<string, string>("actors[name]", (*act).name));
- actor.insert(pair<string, string>("actors[role]", (*act).role));
- actor.insert(pair<string, string>("actors[thumb]", (*act).actorThumb.path));
- stringstream actWidth, actHeight;
- actWidth << (*act).actorThumb.width;
- actHeight << (*act).actorThumb.height;
- actor.insert(pair<string, string>("actors[thumbwidth]", actWidth.str()));
- actor.insert(pair<string, string>("actors[thumbheight]", actHeight.str()));
- actors.push_back(actor);
- }
- loopTokens.insert(pair<string, vector< map< string, string > > >("actors", actors));
-
- } else if (getType.type == tSeries) {
- cSeries series;
- series.seriesId = getType.seriesId;
- series.episodeId = getType.episodeId;
- pScraper->Service("GetSeries", &series);
- intTokens.insert(pair<string,int>("ismovie", false));
- intTokens.insert(pair<string,int>("isseries", true));
- //Series Basics
- stringTokens.insert(pair<string,string>("seriesname", series.name));
- stringTokens.insert(pair<string,string>("seriesoverview", series.overview));
- stringTokens.insert(pair<string,string>("seriesfirstaired", series.firstAired));
- stringTokens.insert(pair<string,string>("seriesnetwork", series.network));
- stringTokens.insert(pair<string,string>("seriesgenre", series.genre));
- stringstream rating;
- rating << series.rating;
- stringTokens.insert(pair<string,string>("seriesrating", rating.str()));
- stringTokens.insert(pair<string,string>("seriesstatus", series.status));
- //Episode Information
- intTokens.insert(pair<string,int>("episodenumber", series.episode.number));
- intTokens.insert(pair<string,int>("episodeseason", series.episode.season));
- stringTokens.insert(pair<string,string>("episodetitle", series.episode.name));
- stringTokens.insert(pair<string,string>("episodefirstaired", series.episode.firstAired));
- stringTokens.insert(pair<string,string>("episodegueststars", series.episode.guestStars));
- stringTokens.insert(pair<string,string>("episodeoverview", series.episode.overview));
- stringstream eprating;
- eprating << series.episode.rating;
- stringTokens.insert(pair<string,string>("episoderating", eprating.str()));
- intTokens.insert(pair<string,int>("episodeimagewidth", series.episode.episodeImage.width));
- intTokens.insert(pair<string,int>("episodeimageheight", series.episode.episodeImage.height));
- stringTokens.insert(pair<string,string>("episodeimagepath", series.episode.episodeImage.path));
- //Seasonposter
- intTokens.insert(pair<string,int>("seasonposterwidth", series.seasonPoster.width));
- intTokens.insert(pair<string,int>("seasonposterheight", series.seasonPoster.height));
- stringTokens.insert(pair<string,string>("seasonposterpath", series.seasonPoster.path));
-
- //Posters
- int current = 1;
- for(vector<cTvMedia>::iterator poster = series.posters.begin(); poster != series.posters.end(); poster++) {
- stringstream labelWidth, labelHeight, labelPath;
- labelWidth << "seriesposter" << current << "width";
- labelHeight << "seriesposter" << current << "height";
- labelPath << "seriesposter" << current << "path";
-
- intTokens.insert(pair<string,int>(labelWidth.str(), (*poster).width));
- intTokens.insert(pair<string,int>(labelHeight.str(), (*poster).height));
- stringTokens.insert(pair<string,string>(labelPath.str(), (*poster).path));
- current++;
- }
- if (current < 3) {
- for (; current < 4; current++) {
- stringstream labelWidth, labelHeight, labelPath;
- labelWidth << "seriesposter" << current << "width";
- labelHeight << "seriesposter" << current << "height";
- labelPath << "seriesposter" << current << "path";
-
- intTokens.insert(pair<string,int>(labelWidth.str(), 0));
- intTokens.insert(pair<string,int>(labelHeight.str(), 0));
- stringTokens.insert(pair<string,string>(labelPath.str(), ""));
- }
- }
-
- //Banners
- current = 1;
- for(vector<cTvMedia>::iterator banner = series.banners.begin(); banner != series.banners.end(); banner++) {
- stringstream labelWidth, labelHeight, labelPath;
- labelWidth << "seriesbanner" << current << "width";
- labelHeight << "seriesbanner" << current << "height";
- labelPath << "seriesbanner" << current << "path";
-
- intTokens.insert(pair<string,int>(labelWidth.str(), (*banner).width));
- intTokens.insert(pair<string,int>(labelHeight.str(), (*banner).height));
- stringTokens.insert(pair<string,string>(labelPath.str(), (*banner).path));
- current++;
- }
- if (current < 3) {
- for (; current < 4; current++) {
- stringstream labelWidth, labelHeight, labelPath;
- labelWidth << "seriesbanner" << current << "width";
- labelHeight << "seriesbanner" << current << "height";
- labelPath << "seriesbanner" << current << "path";
-
- intTokens.insert(pair<string,int>(labelWidth.str(), 0));
- intTokens.insert(pair<string,int>(labelHeight.str(), 0));
- stringTokens.insert(pair<string,string>(labelPath.str(), ""));
- }
- }
-
- //Fanarts
- current = 1;
- for(vector<cTvMedia>::iterator fanart = series.fanarts.begin(); fanart != series.fanarts.end(); fanart++) {
- stringstream labelWidth, labelHeight, labelPath;
- labelWidth << "seriesfanart" << current << "width";
- labelHeight << "seriesfanart" << current << "height";
- labelPath << "seriesfanart" << current << "path";
-
- intTokens.insert(pair<string,int>(labelWidth.str(), (*fanart).width));
- intTokens.insert(pair<string,int>(labelHeight.str(), (*fanart).height));
- stringTokens.insert(pair<string,string>(labelPath.str(), (*fanart).path));
- current++;
- }
- if (current < 3) {
- for (; current < 4; current++) {
- stringstream labelWidth, labelHeight, labelPath;
- labelWidth << "seriesfanart" << current << "width";
- labelHeight << "seriesfanart" << current << "height";
- labelPath << "seriesfanart" << current << "path";
-
- intTokens.insert(pair<string,int>(labelWidth.str(), 0));
- intTokens.insert(pair<string,int>(labelHeight.str(), 0));
- stringTokens.insert(pair<string,string>(labelPath.str(), ""));
- }
- }
-
- //Actors
- vector< map< string, string > > actors;
- for (vector<cActor>::iterator act = series.actors.begin(); act != series.actors.end(); act++) {
- map< string, string > actor;
- actor.insert(pair<string, string>("actors[name]", (*act).name));
- actor.insert(pair<string, string>("actors[role]", (*act).role));
- actor.insert(pair<string, string>("actors[thumb]", (*act).actorThumb.path));
- stringstream actWidth, actHeight;
- actWidth << (*act).actorThumb.width;
- actHeight << (*act).actorThumb.height;
- actor.insert(pair<string, string>("actors[thumbwidth]", actWidth.str()));
- actor.insert(pair<string, string>("actors[thumbheight]", actHeight.str()));
- actors.push_back(actor);
- }
- loopTokens.insert(pair<string, vector< map< string, string > > >("actors", actors));
-
- } else {
- intTokens.insert(pair<string,int>("ismovie", false));
- intTokens.insert(pair<string,int>("isseries", false));
- }
-
-}
-
-void cViewHelpers::SetPosterBanner(const cEvent *event, stringmap &stringTokens, intmap &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));
- }
-}
-
-void cViewHelpers::SetPosterBannerV2(const cRecording *recording, stringmap &stringTokens, intmap &intTokens) {
- static cPlugin *pScraper = GetScraperPlugin();
- if (!pScraper) {
- return;
- }
-
- 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;
-
- ScraperGetPosterBannerV2 call;
- call.event = NULL;
- call.recording = recording;
- if (pScraper->Service("GetPosterBannerV2", &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 = NULL;
- callPoster.recording = recording;
- 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));
-}
-
-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];
- string isRemoteTimer = SortedTimers.IsRemoteTimer(i) ? "1" : "0";
- 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));
- timerVals.insert(pair< string, string >("timers[isremotetimer]", isRemoteTimer));
-
- timers->push_back(timerVals);
- }
-}
-
-void cViewHelpers::SetLastRecordings(map<string,int> *intTokens, map<string,string> *stringTokens, vector<stringmap> *lastRecordings) {
-
- cGlobalSortedTimers SortedTimers;// local and remote timers
- int numTimers = SortedTimers.Size();
- //set number of timers so that it is possible to adapt this viewelement accordingly
- intTokens->insert(pair<string, int>("numtimers", numTimers));
-
- list<cRecording*> orderedRecs;
-
- for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) {
- if (orderedRecs.size() == 0) {
- orderedRecs.push_back(recording);
- continue;
- }
- bool inserted = false;
- for (list<cRecording*>::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) {
- const cRecording *orderedRec = *it;
- if (recording->Start() >= orderedRec->Start()) {
- orderedRecs.insert(it, recording);
- inserted = true;
- break;
- }
- }
- if (!inserted) {
- orderedRecs.push_back(recording);
- }
- }
-
- int found = 0;
- for (list<cRecording*>::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) {
- const cRecording *recording = *it;
-#if APIVERSNUM >= 20101
- if (recording->IsInUse()) {
- continue;
- }
-#endif
- map< string, string > recVals;
- string recFullPath = recording->Name() ? recording->Name() : "";
- string recName = "";
- string recPath = "";
- RecName(recFullPath, recName, recPath);
- stringstream recDuration;
- int dur = recording->LengthInSeconds()/60;
- recDuration << dur;
- string posterPath = "";
- int posterWidth = 0;
- int posterHeight = 0;
- bool hasPoster = false;
- RecPoster(recording, posterWidth, posterHeight, posterPath, hasPoster);
- stringstream sPosterWidth;
- sPosterWidth << posterWidth;
- stringstream sPosterHeight;
- sPosterHeight << posterHeight;
- string sHasPoster = hasPoster ? "1" : "0";
- recVals.insert(pair< string, string >("recordings[name]", recName));
- recVals.insert(pair< string, string >("recordings[seriesname]", recPath));
- recVals.insert(pair< string, string >("recordings[date]", *ShortDateString(recording->Start())));
- recVals.insert(pair< string, string >("recordings[time]", *TimeString(recording->Start())));
- recVals.insert(pair< string, string >("recordings[duration]", recDuration.str()));
- recVals.insert(pair< string, string >("recordings[hasposter]", sHasPoster));
- recVals.insert(pair< string, string >("recordings[posterpath]", posterPath));
- recVals.insert(pair< string, string >("recordings[posterwidth]", sPosterWidth.str()));
- recVals.insert(pair< string, string >("recordings[posterheight]", sPosterHeight.str()));
- lastRecordings->push_back(recVals);
- found++;
- if (found == 10)
- break;
- }
-}
-
-void cViewHelpers::SetMenuHeader(eMenuCategory cat, string menuTitle, stringmap &stringTokens, intmap &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::SetCurrentSchedule(string recName, stringmap &stringTokens, intmap &intTokens) {
- cDevice *device = cDevice::PrimaryDevice();
- const cChannel *channel = NULL;
- if (!device->Replaying() || device->Transferring()) {
- channel = Channels.GetByNumber(device->CurrentChannel());
- }
- if (channel) {
- SetCurrentScheduleFromChannel(channel, stringTokens, intTokens);
- } else {
- if (recName.size() == 0)
- return;
- const cRecording *recording = new cRecording(recName.c_str());
- if (recording) {
- SetCurrentScheduleFromRecording(recording, stringTokens, intTokens);
- delete recording;
- }
- }
-}
-
-bool cViewHelpers::SetEcmInfos(int channelSid, stringmap &stringTokens, intmap &intTokens) {
- static cPlugin *pDVBApi = cPluginManager::GetPlugin("dvbapi");
- if (!pDVBApi)
- return false;
-
- sDVBAPIEcmInfo ecmInfo;
- ecmInfo.sid = channelSid;
-
- if (!pDVBApi->Service("GetEcmInfo", &ecmInfo)) {
- return false;
- }
-
- if (ecmInfo.hops < 0 || ecmInfo.ecmtime <= 0 || ecmInfo.ecmtime > 100000)
- return false;
- if (CompareECMInfos(&ecmInfo))
- return false;
- lastEcmInfo = ecmInfo;
-
- intTokens.insert(pair<string,int>("caid", ecmInfo.caid));
- intTokens.insert(pair<string,int>("pid", ecmInfo.pid));
- intTokens.insert(pair<string,int>("prid", ecmInfo.prid));
- intTokens.insert(pair<string,int>("ecmtime", ecmInfo.ecmtime));
- intTokens.insert(pair<string,int>("hops", ecmInfo.hops));
-
- stringTokens.insert(pair<string,string>("cardsystem", *ecmInfo.cardsystem ? *ecmInfo.cardsystem : ""));
- stringTokens.insert(pair<string,string>("reader", *ecmInfo.reader ? *ecmInfo.reader : ""));
- stringTokens.insert(pair<string,string>("from", *ecmInfo.from ? *ecmInfo.from : ""));
- stringTokens.insert(pair<string,string>("protocol", *ecmInfo.protocol ? *ecmInfo.protocol : ""));
-
- return true;
-}
-
-/********************************************************************************
-* Private Functions
-********************************************************************************/
-
-void cViewHelpers::RecName(string &path, string &name, string &folder) {
- size_t delim = path.find_last_of('~');
- if (delim == string::npos) {
- name = path;
- if (name.find('%') == 0) {
- name = name.substr(1);
- }
- return;
- }
- name = path.substr(delim+1);
- if (name.find('%') == 0) {
- name = name.substr(1);
- }
- folder = path.substr(0, delim);
- size_t delim2 = folder.find_last_of('~');
- if (delim2 == string::npos) {
- return;
- }
- folder = folder.substr(delim2+1);
-}
-
-void cViewHelpers::RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster) {
- static cPlugin *pScraper = GetScraperPlugin();
- if (!pScraper)
- return;
- ScraperGetPoster callPoster;
- callPoster.event = NULL;
- callPoster.recording = rec;
- if (pScraper->Service("GetPoster", &callPoster)) {
- posterWidth = callPoster.poster.width;
- posterHeight = callPoster.poster.height;
- path = callPoster.poster.path;
- hasPoster = true;
- }
-}
-
-void cViewHelpers::SetCurrentScheduleFromChannel(const cChannel *channel, stringmap &stringTokens, intmap &intTokens) {
- 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;
-
- intTokens.insert(pair<string,int>("islivetv", 1));
- 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));
-}
-
-void cViewHelpers::SetCurrentScheduleFromRecording(const cRecording *recording, stringmap &stringTokens, intmap &intTokens) {
- intTokens.insert(pair<string,int>("islivetv", 0));
-
- string recFullName = recording->Name() ? recording->Name() : "";
- string recName = "";
- string recFolder = "";
- RecName(recFullName, recName, recFolder);
-
- stringTokens.insert(pair<string,string>("title", recName));
- const cRecordingInfo *info = recording->Info();
- if (info) {
- stringTokens.insert(pair<string,string>("subtitle", info->ShortText() ? info->ShortText() : ""));
- } else {
- stringTokens.insert(pair<string,string>("subtitle", recFolder));
- }
- stringTokens.insert(pair<string,string>("start", ""));
- stringTokens.insert(pair<string,string>("stop", ""));
- intTokens.insert(pair<string,int>("duration", recording->LengthInSeconds() / 60));
- intTokens.insert(pair<string,int>("durationhours", recording->LengthInSeconds() / 3600));
- stringTokens.insert(pair<string,string>("durationminutes", *cString::sprintf("%.2d", (recording->LengthInSeconds() / 60)%60)));
- intTokens.insert(pair<string,int>("elapsed", 0));
- intTokens.insert(pair<string,int>("remaining", 0));
-
- 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) {
- ScraperGetPosterBannerV2 call;
- call.event = NULL;
- call.recording = recording;
- if (pScraper->Service("GetPosterBannerV2", &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 = NULL;
- callPoster.recording = recording;
- 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));
-}
-
-bool cViewHelpers::CompareECMInfos(sDVBAPIEcmInfo *ecmInfo) {
- if (ecmInfo->caid != lastEcmInfo.caid)
- return false;
- if (ecmInfo->pid != lastEcmInfo.pid)
- return false;
- if (ecmInfo->prid != lastEcmInfo.prid)
- return false;
- if (ecmInfo->ecmtime != lastEcmInfo.ecmtime)
- return false;
- if (ecmInfo->hops != lastEcmInfo.hops)
- return false;
- return true;
-}
-
-void cViewHelpers::SetMenuMessage(eMessageType type, string text, stringmap &stringTokens, intmap &intTokens) {
- intTokens.insert(pair<string, int>("status", (type == mtStatus) ? true : false));
- intTokens.insert(pair<string, int>("info", (type == mtInfo) ? true : false));
- intTokens.insert(pair<string, int>("warning", (type == mtWarning) ? true : false));
- intTokens.insert(pair<string, int>("error", (type == mtError) ? true : false));
- stringTokens.insert(pair<string,string>("text", text));
-}
diff --git a/views/viewhelpers.h b/views/viewhelpers.h
deleted file mode 100644
index 1baf4e0..0000000
--- a/views/viewhelpers.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef __VIEWHELPERS_H
-#define __VIEWHELPERS_H
-
-#include "../services/dvbapi.h"
-
-typedef map<string,string> stringmap;
-typedef map<string,int> intmap;
-typedef pair<string,string> stringpair;
-
-class cViewHelpers {
-private:
- cMutex mutexDevices;
- int numDevices;
- bool devicesInit;
- int* lastSignalStrength;
- int* lastSignalQuality;
- bool* recDevices;
- int lSignalDisplay;
- int lSignalStrength;
- int lSignalQuality;
- int lastSecond;
- int lastMinute;
- double lastSystemLoad;
- int lastMemUsage;
- string lastVdrCPU;
- string lastVdrMEM;
- sDVBAPIEcmInfo lastEcmInfo;
- void RecName(string &path, string &name, string &folder);
- void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
- void SetCurrentScheduleFromChannel(const cChannel *channel, stringmap &stringTokens, intmap &intTokens);
- void SetCurrentScheduleFromRecording(const cRecording *recording, stringmap &stringTokens, intmap &intTokens);
- bool CompareECMInfos(sDVBAPIEcmInfo *ecmInfo);
-protected:
- void InitDevices(void);
- bool SetDevices(bool initial, bool light, intmap *intTokens, vector<stringmap> *devices);
- bool CheckNewMails(void);
- int GetLiveBuffer(void);
- void SetScraperTokens(const cEvent *event, const cRecording *recording, stringmap &stringTokens, intmap &intTokens, map < string, vector<stringmap> > &loopTokens);
- void SetPosterBanner(const cEvent *event, stringmap &stringTokens, intmap &intTokens);
- void SetPosterBannerV2(const cRecording *recording, stringmap &stringTokens, intmap &intTokens);
- void SetTimers(map<string,int> *intTokens, map<string,string> *stringTokens, vector<stringmap> *timers);
- void SetLastRecordings(map<string,int> *intTokens, map<string,string> *stringTokens, vector<stringmap> *lastRecordings);
- void SetMenuHeader(eMenuCategory cat, string menuTitle, stringmap &stringTokens, intmap &intTokens);
- void SetCurrentSchedule(string recName, stringmap &stringTokens, intmap &intTokens);
- bool SetEcmInfos(int channelSid, stringmap &stringTokens, intmap &intTokens);
- void SetMenuMessage(eMessageType type, string text, stringmap &stringTokens, intmap &intTokens);
-public:
- cViewHelpers(void);
- virtual ~cViewHelpers(void);
- bool SetDate (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetTime (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetSignal (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetCurrentWeatherTokens(bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetDiscUsage (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetSystemLoad (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetSystemMemory (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetSystemTemperatures (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetVDRStats (bool forced, stringmap &stringTokens, intmap &intTokens);
- bool SetDummy (bool forced, stringmap &stringTokens, intmap &intTokens);
-};
-
-#endif //__VIEWHELPERS_H \ No newline at end of file