diff options
author | louis <louis.braun@gmx.de> | 2016-01-26 18:32:38 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2016-01-26 18:32:38 +0100 |
commit | 809fbda03c5014ba9cd361f5113d1d717cd41ea6 (patch) | |
tree | 264bbc5640375f1bcb165fc7f4a3e595adcc26ca | |
parent | 196dd7eb9965a405bb16b51dc870fbbb31aeef87 (diff) | |
download | vdr-plugin-skindesigner-809fbda03c5014ba9cd361f5113d1d717cd41ea6.tar.gz vdr-plugin-skindesigner-809fbda03c5014ba9cd361f5113d1d717cd41ea6.tar.bz2 |
Version 0.8.0 beta
210 files changed, 24705 insertions, 20844 deletions
@@ -27,7 +27,7 @@ SKINDESIGNER_SCRIPTDIR ?= $(LIBDIR)/$(PLUGIN)/scripts ### The compiler options: export CFLAGS = $(call PKGCFG,cflags) export CXXFLAGS = $(call PKGCFG,cxxflags) - +CXXFLAGS += -std=c++11 ### Allow user defined options to overwrite defaults: -include $(PLGCFG) @@ -65,51 +65,49 @@ OBJS = $(PLUGIN).o \ displayreplay.o \ displaytracks.o \ displayvolume.o \ - displayplugin.o \ - libcore/cairoimage.o \ - libcore/curlfuncs.o \ - libcore/pixmapcontainer.o \ - libcore/fontmanager.o \ - libcore/imagecache.o \ - libcore/helpers.o \ - libcore/imageloader.o \ - libcore/libxmlwrapper.o \ - libcore/recfolderinfo.o \ - libcore/skinsetup.o \ - libcore/skinrepo.o \ - libcore/extrecinfo.o \ - libcore/timers.o \ - libtemplate/globals.o \ - libtemplate/parameter.o \ - libtemplate/template.o \ - libtemplate/templateview.o \ - libtemplate/templateviewelement.o \ - libtemplate/templateviewlist.o \ - libtemplate/templateviewgrid.o \ - libtemplate/templatepixmap.o \ - libtemplate/templateviewtab.o \ - libtemplate/templatefunction.o \ - libtemplate/templateloopfunction.o \ - libtemplate/xmlparser.o \ - views/animation.o \ - views/view.o \ - views/viewgrid.o \ - views/viewhelpers.o \ - views/displayviewelements.o \ - views/displaychannelview.o \ - views/displaymenurootview.o \ - views/displaymenuview.o \ - views/displaymenulistview.o \ - views/displaymenuitemview.o \ - views/displaymenuitemcurrentview.o \ - views/displaymenudetailview.o \ - views/displaymenutabview.o \ - views/displaymessageview.o \ - views/displayreplayview.o \ - views/displayreplayonpauseview.o \ - views/displayvolumeview.o \ - views/displayaudiotracksview.o \ - views/displaypluginview.o + extensions/cairoimage.o \ + extensions/curlfuncs.o \ + extensions/fontmanager.o \ + extensions/imagecache.o \ + extensions/helpers.o \ + extensions/imageloader.o \ + extensions/libxmlwrapper.o \ + extensions/pluginmanager.o \ + extensions/recfolderinfo.o \ + extensions/scrapmanager.o \ + extensions/skinsetup.o \ + extensions/skinrepo.o \ + extensions/extrecinfo.o \ + extensions/timers.o \ + coreengine/animation.o \ + coreengine/attribute.o \ + coreengine/attributes.o \ + coreengine/functions.o \ + coreengine/complextypes.o \ + coreengine/globals.o \ + coreengine/gridelement.o \ + coreengine/osdwrapper.o \ + coreengine/view.o \ + coreengine/viewdisplaychannel.o \ + coreengine/viewdisplaymenu.o \ + coreengine/viewdisplaymessage.o \ + coreengine/viewdisplayreplay.o \ + coreengine/viewdisplaytracks.o \ + coreengine/viewdisplayvolume.o \ + coreengine/viewdisplayplugin.o \ + coreengine/viewelement.o \ + coreengine/viewelementplugin.o \ + coreengine/viewelementscommon.o \ + coreengine/viewelementsdisplaychannel.o \ + coreengine/viewelementsdisplaymenu.o \ + coreengine/viewelementsdisplayreplay.o \ + coreengine/viewelementsdisplaytracks.o \ + coreengine/viewgrid.o \ + coreengine/viewlist.o \ + coreengine/viewdetail.o \ + coreengine/listelements.o \ + coreengine/area.o \ + coreengine/xmlparser.o ### The main target: @@ -138,7 +136,7 @@ $(SOFILE): SUB_LIBS = libskindesignerapi/libskindesignerapi.so.$(shell pkg-confi ### Implicit rules: %.o: %.c - $(CXX) $(CXXFLAGS) -c $(DEFINES) $(SUB_DEFINES) $(INCLUDES) -o $@ $< + $(CXX) $(CXXFLAGS) -std=c++11 -c $(DEFINES) $(SUB_DEFINES) $(INCLUDES) -o $@ $< ### Dependencies: @@ -178,7 +176,7 @@ install-i18n: $(I18Nmsgs) ### Targets: $(SOFILE): $(OBJS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) $(SUB_LIBS) -o $@ + $(CXX) $(CXXFLAGS) -std=c++11 $(LDFLAGS) -shared $(OBJS) $(LIBS) $(SUB_LIBS) -o $@ install-lib: $(SOFILE) install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION) @@ -209,4 +207,4 @@ dist: $(I18Npo) clean clean: clean-subprojects @-rm -f $(PODIR)/*.mo $(PODIR)/*.pot - @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ + @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz *~ @@ -1,6 +1,6 @@ #include "config.h" -#include "libcore/helpers.h" -#include "libcore/imageloader.h" +#include "extensions/helpers.h" +#include "extensions/imageloader.h" cDesignerConfig::cDesignerConfig() { tmplGlobals = NULL; @@ -9,6 +9,7 @@ cDesignerConfig::cDesignerConfig() { installerSkinPathSet = false; logoPathSet = false; //Common + cacheImagesInitial = 1; numLogosPerSizeInitial = 30; limitLogoCache = 1; numLogosMax = 200; @@ -18,11 +19,8 @@ cDesignerConfig::cDesignerConfig() { rerunAmount = 10; rerunDistance = 2; rerunMaxChannel = 0; - //menu display style, display menu items - //one after each other or in one step - blockFlush = 1; - //frames per second for fading and shifting - framesPerSecond = 40; + //max number of custom int and string tokens + numCustomTokens = 10; //remember current skin and theme, osd size and osd fonts SetSkin(); SetOSDSize(); @@ -475,98 +473,6 @@ cString cDesignerConfig::GetSkinRessourcePath(void) { return cString::sprintf("%s%s", *skinPath, osdSkin.c_str()); } -void cDesignerConfig::AddPluginMenus(string name, map< int, string > menus) { - pluginMenus.insert(pair< string, map < int, string > >(name, menus)); -} - -void cDesignerConfig::AddPluginViews(string name, - map< int, string > views, - multimap< int, pair <int, string> > subViews, - map< int, map <int, string> > viewElements, - map< int, map <int, string> > viewGrids) { - pluginViews.insert(pair< string, map < int, string > >(name, views)); - pluginSubViews.insert(pair< string, multimap< int, pair <int, string> > >(name, subViews)); - pluginViewElements.insert(pair< string, map< int, map <int, string> > >(name, viewElements)); - pluginViewGrids.insert(pair< string, map< int, map <int, string> > >(name, viewGrids)); -} - -void cDesignerConfig::InitPluginMenuIterator(void) { - plugMenuIt = pluginMenus.begin(); -} - -map <int,string> *cDesignerConfig::GetPluginTemplates(string &name) { - if (plugMenuIt == pluginMenus.end()) - return NULL; - name = plugMenuIt->first; - map <int,string> *templates = &plugMenuIt->second; - plugMenuIt++; - return templates; -} - -void cDesignerConfig::InitPluginViewIterator(void) { - plugViewIt = pluginViews.begin(); -} - -map <int,string> *cDesignerConfig::GetPluginViews(string &name) { - if (plugViewIt == pluginViews.end()) - return NULL; - name = plugViewIt->first; - map <int,string> *views = &plugViewIt->second; - plugViewIt++; - return views; -} - -map <int,string> cDesignerConfig::GetPluginSubViews(string name, int viewID) { - map <int,string> subViews; - - map < string, multimap< int, pair <int, string> > >::iterator hit = pluginSubViews.find(name); - if (hit == pluginSubViews.end()) - return subViews; - - multimap< int, pair<int, string> > subs = hit->second; - - pair < multimap< int, pair<int, string> >::iterator, multimap< int, pair<int, string> >::iterator> viewSubViews; - viewSubViews = subs.equal_range(viewID); - - for (multimap< int, pair<int, string> >::iterator it=viewSubViews.first; it!=viewSubViews.second; ++it) { - pair<int, string> subViewFound = it->second; - subViews.insert(pair<int,string>(subViewFound.first, subViewFound.second)); - } - return subViews; -} - -int cDesignerConfig::GetPluginViewElementID(string pluginName, string viewElementName, int viewID) { - map < string, map< int, map <int, string> > >::iterator hit = pluginViewElements.find(pluginName); - if (hit == pluginViewElements.end()) - return -1; - map< int, map <int, string> >::iterator hit2 = (hit->second).find(viewID); - if (hit2 == (hit->second).end()) - return -1; - - map <int, string> viewElements = hit2->second; - for (map <int, string>::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - if (!(it->second).compare(viewElementName)) - return it->first; - } - return -1; -} - -int cDesignerConfig::GetPluginViewGridID(string pluginName, string viewGridName, int viewID) { - map < string, map< int, map <int, string> > >::iterator hit = pluginViewGrids.find(pluginName); - if (hit == pluginViewGrids.end()) - return -1; - map< int, map <int, string> >::iterator hit2 = (hit->second).find(viewID); - if (hit2 == (hit->second).end()) - return -1; - - map <int, string> viewGrids = hit2->second; - for (map <int, string>::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) { - if (!(it->second).compare(viewGridName)) - return it->first; - } - return -1; -} - cString cDesignerConfig::CheckSlashAtEnd(std::string path) { try { if (!(path.at(path.size()-1) == '/')) @@ -578,14 +484,14 @@ cString cDesignerConfig::CheckSlashAtEnd(std::string path) { bool cDesignerConfig::SetupParse(const char *Name, const char *Value) { bool pluginSetupParam = true; if (!strcasecmp(Name, "DebugImageLoading")) debugImageLoading = atoi(Value); + else if (!strcasecmp(Name, "CacheImagesInitial")) cacheImagesInitial = atoi(Value); else if (!strcasecmp(Name, "LimitChannelLogoCache")) limitLogoCache = atoi(Value); else if (!strcasecmp(Name, "NumberLogosInitially")) numLogosPerSizeInitial = atoi(Value); else if (!strcasecmp(Name, "NumberLogosMax")) numLogosMax = atoi(Value); else if (!strcasecmp(Name, "RerunAmount")) rerunAmount = atoi(Value); else if (!strcasecmp(Name, "RerunDistance")) rerunDistance = atoi(Value); else if (!strcasecmp(Name, "RerunMaxChannel")) rerunMaxChannel = atoi(Value); - else if (!strcasecmp(Name, "BlockFlush")) blockFlush = atoi(Value); - else if (!strcasecmp(Name, "FramesPerSecond")) framesPerSecond = atoi(Value); + else if (!strcasecmp(Name, "NumCustomTokens")) numCustomTokens = atoi(Value); else pluginSetupParam = false; if (!pluginSetupParam) { @@ -8,11 +8,13 @@ #include <vdr/skins.h> #include <vdr/plugin.h> #include "designer.h" -#include "libcore/fontmanager.h" -#include "libcore/imagecache.h" -#include "libcore/recfolderinfo.h" -#include "libcore/skinsetup.h" -#include "libcore/skinrepo.h" +#include "extensions/pluginmanager.h" +#include "extensions/fontmanager.h" +#include "extensions/imagecache.h" +#include "extensions/recfolderinfo.h" +#include "extensions/skinsetup.h" +#include "extensions/skinrepo.h" +#include "libskindesignerapi/skindesignerapi.h" #define SCRIPTOUTPUTPATH "/tmp/skindesigner" @@ -32,13 +34,6 @@ private: string fontSml; string osdLanguage; cGlobals *tmplGlobals; - map < string, map < int, string > > pluginMenus; - map < string, map < int, string > >::iterator plugMenuIt; - map < string, map < int, string > > pluginViews; - map < string, map < int, string > >::iterator plugViewIt; - map < string, multimap< int, pair <int, string> > > pluginSubViews; - map < string, map< int, map <int, string> > > pluginViewElements; - map < string, map< int, map <int, string> > > pluginViewGrids; vector<cSkinDesigner*> skinRefs; vector<cSkinDesigner*>::iterator skinRefsIterator; vector<string> deliveredSkins; @@ -100,15 +95,6 @@ public: void SetOsdLanguage(void) { osdLanguage = Setup.OSDLanguage; }; bool OsdLanguageChanged(void); cString GetSkinRessourcePath(void); - void AddPluginMenus(string name, map< int, string > menus); - void AddPluginViews(string name, map< int, string > views, multimap< int, pair <int, string> > subViews, map< int, map <int, string> > viewElements, map< int, map <int, string> > viewGrids); - void InitPluginMenuIterator(void); - map <int,string> *GetPluginTemplates(string &name); - void InitPluginViewIterator(void); - map <int,string> *GetPluginViews(string &name); - map <int,string> GetPluginSubViews(string name, int viewID); - int GetPluginViewElementID(string pluginName, string viewElementName, int viewID); - int GetPluginViewGridID(string pluginName, string viewGridName, int viewID); cString skinPath; cString installerSkinPath; cString logoPath; @@ -117,6 +103,7 @@ public: bool replaceDecPoint; char decPoint; //Setup Parameter + int cacheImagesInitial; int numLogosPerSizeInitial; int limitLogoCache; int numLogosMax; @@ -124,20 +111,21 @@ public: int rerunAmount; int rerunDistance; int rerunMaxChannel; - int blockFlush; - int framesPerSecond; + int numCustomTokens; //TemplateReload on Setup Close bool setupCloseDoReload; }; #ifdef DEFINE_CONFIG cDesignerConfig config; + cSDPluginManager *plgManager = NULL; cFontManager *fontManager = NULL; cImageCache *imgCache = NULL; cTheme Theme; cRecordingsFolderInfo recFolderInfo(Recordings); #else extern cDesignerConfig config; + extern cSDPluginManager *plgManager; extern cFontManager *fontManager; extern cImageCache *imgCache; extern cTheme Theme; diff --git a/coreengine/animation.c b/coreengine/animation.c new file mode 100644 index 0000000..59f4388 --- /dev/null +++ b/coreengine/animation.c @@ -0,0 +1,347 @@ +#include "animation.h"
+#include <math.h>
+
+/******************************************************************
+* cAnimation
+******************************************************************/
+cAnimation::cAnimation(cScrollable *scrollable) : cThread("scroller") {
+ this->scrollable = scrollable;
+ this->detachable = NULL;
+ this->fadable = NULL;
+ this->shiftable = NULL;
+ this->blinkable = NULL;
+ waitOnWakeup = false;
+ doAnimation = true;
+ modeIn = false;
+ blinkFunc = -1;
+}
+
+cAnimation::cAnimation(cDetachable *detachable, bool wait, bool animation) : cThread("detached") {
+ this->scrollable = NULL;
+ this->detachable = detachable;
+ this->fadable = NULL;
+ this->shiftable = NULL;
+ this->blinkable = NULL;
+ waitOnWakeup = wait;
+ doAnimation = animation;
+ modeIn = false;
+ blinkFunc = -1;
+}
+
+cAnimation::cAnimation(cFadable *fadable, bool fadein) : cThread("fadable") {
+ this->scrollable = NULL;
+ this->detachable = NULL;
+ this->fadable = fadable;
+ this->shiftable = NULL;
+ this->blinkable = NULL;
+ waitOnWakeup = false;
+ doAnimation = true;
+ modeIn = fadein;
+ blinkFunc = -1;
+}
+
+cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin) : cThread("shiftable") {
+ this->scrollable = NULL;
+ this->detachable = NULL;
+ this->fadable = NULL;
+ this->shiftable = shiftable;
+ this->blinkable = NULL;
+ waitOnWakeup = false;
+ doAnimation = true;
+ modeIn = shiftin;
+ shiftstart = start;
+ shiftend = end;
+ blinkFunc = -1;
+}
+
+cAnimation::cAnimation(cBlinkable *blinkable, int func) : cThread("blinking") {
+ this->scrollable = NULL;
+ this->detachable = NULL;
+ this->fadable = NULL;
+ this->shiftable = NULL;
+ this->blinkable = blinkable;
+ waitOnWakeup = false;
+ doAnimation = true;
+ modeIn = false;
+ blinkFunc = func;
+}
+
+cAnimation::~cAnimation(void) {
+ sleepWait.Signal();
+ Cancel(2);
+}
+
+void cAnimation::WakeUp(void) {
+ sleepWait.Signal();
+}
+
+void cAnimation::Stop(bool deletePixmaps) {
+ sleepWait.Signal();
+ Cancel(2);
+ if (scrollable && deletePixmaps)
+ scrollable->StopScrolling();
+}
+
+void cAnimation::Action(void) {
+ if (scrollable) {
+ Scroll();
+ } else if (detachable) {
+ Detach();
+ } else if (fadable) {
+ Fade();
+ } else if (shiftable) {
+ Shift();
+ } else if (blinkable) {
+ Blink();
+ }
+}
+
+void cAnimation::Sleep(int duration) {
+ //sleep should wake up itself, so no infinit wait allowed
+ if (duration <= 0)
+ return;
+ sleepWait.Wait(duration);
+}
+
+void cAnimation::Wait(void) {
+ //wait has to be waked up from outside
+ sleepWait.Wait(0);
+}
+
+void cAnimation::Scroll(void) {
+ int delay = scrollable->ScrollDelay();
+ Sleep(delay);
+ if (!Running()) return;
+
+ eOrientation orientation = scrollable->ScrollOrientation();
+ int scrollTotal = 0;
+ if (orientation == eOrientation::horizontal) {
+ scrollTotal = scrollable->ScrollWidth();
+ } else if (orientation == eOrientation::vertical) {
+ scrollTotal = scrollable->ScrollHeight();
+ }
+
+ eScrollMode mode = scrollable->ScrollMode();
+ bool carriageReturn = (mode == eScrollMode::carriagereturn) ? true : false;
+
+ eScrollSpeed speed = scrollable->ScrollSpeed();
+ int frameTime = 30;
+ if (speed == eScrollSpeed::slow)
+ frameTime = 50;
+ else if (speed == eScrollSpeed::medium)
+ frameTime = 30;
+ else if (speed == eScrollSpeed::fast)
+ frameTime = 15;
+
+ if (!Running()) return;
+
+ scrollable->StartScrolling();
+
+ int drawPortX = 0;
+ int drawPortY = 0;
+ int scrollDelta = 1;
+
+ bool doSleep = false;
+ while (Running()) {
+ if (doSleep) {
+ Sleep(delay);
+ doSleep = false;
+ }
+ if (!Running()) return;
+ uint64_t now = cTimeMs::Now();
+
+ cPoint drawPortPoint(0,0);
+ if (orientation == eOrientation::horizontal) {
+
+ drawPortX -= scrollDelta;
+ if (abs(drawPortX) > scrollTotal) {
+ Sleep(delay);
+ if (carriageReturn) {
+ drawPortX = 0;
+ doSleep = true;
+ } else {
+ scrollDelta *= -1;
+ drawPortX -= scrollDelta;
+ }
+ }
+ drawPortPoint.SetX(drawPortX);
+
+ } else if (orientation == eOrientation::vertical) {
+
+ drawPortY -= scrollDelta;
+ if (abs(drawPortY) > scrollTotal) {
+ Sleep(delay);
+ drawPortY = 0;
+ doSleep = true;
+ }
+ drawPortPoint.SetY(drawPortY);
+
+ }
+
+ if (!Running()) return;
+ scrollable->SetDrawPort(drawPortPoint);
+
+ if (!Running()) return;
+ scrollable->Flush();
+
+ if (orientation == eOrientation::horizontal && !carriageReturn && (drawPortX == 0)) {
+ scrollDelta *= -1;
+ doSleep = true;
+ }
+
+ int delta = cTimeMs::Now() - now;
+ if (delta < frameTime)
+ Sleep(frameTime - delta);
+ }
+}
+
+void cAnimation::Detach(void) {
+ if (waitOnWakeup) {
+ Wait();
+ int delay = 100 + detachable->Delay();
+ Sleep(delay);
+ } else {
+ int delay = detachable->Delay();
+ Sleep(delay);
+ }
+ if (!Running()) return;
+ detachable->ParseDetached();
+ if (!Running()) return;
+ detachable->RenderDetached();
+ if (!Running()) return;
+ detachable->Flush();
+ if (!Running()) return;
+ if (doAnimation) {
+ detachable->StartAnimation();
+ }
+}
+
+void cAnimation::Fade(void) {
+ int fadetime = fadable->FadeTime();
+ int frametime = 1000 / FPS;
+ int step = 100.0f / ((double)fadetime / (double)frametime);
+ uint64_t start = cTimeMs::Now();
+ int transparency = 0;
+ if (modeIn) {
+ transparency = 100 - step;
+ } else {
+ transparency = step;
+ }
+ //wait configured delay if not already done by detacher
+ if (!fadable->Detached()) {
+ int delay = fadable->Delay();
+ if (delay > 0)
+ Sleep(delay);
+ }
+ while (Running() || !modeIn) {
+ uint64_t now = cTimeMs::Now();
+ if (Running() || !modeIn)
+ fadable->SetTransparency(transparency, !modeIn);
+ if (Running() || !modeIn)
+ fadable->Flush();
+ int delta = cTimeMs::Now() - now;
+ if ((Running() || !modeIn) && (delta < frametime)) {
+ Sleep(frametime - delta);
+ }
+ if ((int)(now - start) > fadetime) {
+ if ((Running() && modeIn) && transparency > 0) {
+ fadable->SetTransparency(0);
+ fadable->Flush();
+ } else if (!modeIn && transparency < 100) {
+ fadable->SetTransparency(100, true);
+ fadable->Flush();
+ }
+ break;
+ }
+ if (modeIn) {
+ transparency -= step;
+ if (transparency < 0)
+ transparency = 0;
+ } else {
+ transparency += step;
+ if (transparency > 100)
+ transparency = 100;
+ }
+ }
+}
+
+void cAnimation::Shift(void) {
+ int shifttime = shiftable->ShiftTime();
+ eShiftMode mode = (eShiftMode)shiftable->ShiftMode();
+ //in shiftmode slowedDown shifting is done starting with slowratio % faster
+ //at start. Then speed reduces linear to (100 - slowratio)% at end
+ //for me 60 is a nice value :-)
+ int slowRatio = 60;
+
+ int frametime = 1000 / FPS;
+ int steps = (double)shifttime / (double)frametime;
+ int stepXLinear = 0;
+ int stepYLinear = 0;
+ if (shiftstart.X() == shiftend.X()) {
+ stepYLinear = (shiftend.Y() - shiftstart.Y()) / steps;
+ } else if (shiftstart.Y() == shiftend.Y()) {
+ stepXLinear = (shiftend.X() - shiftstart.X()) / steps;
+ } else {
+ stepXLinear = (shiftend.X() - shiftstart.X()) / steps;
+ stepYLinear = (shiftend.Y() - shiftstart.Y()) / steps;
+ }
+ int stepX = stepXLinear;
+ int stepY = stepYLinear;
+
+ cPoint pos;
+ if (modeIn)
+ pos = shiftstart;
+ else
+ pos = shiftend;
+
+ //wait configured delay if not already done by detacher
+ if (!shiftable->Detached()) {
+ int delay = shiftable->Delay();
+ if (delay > 0)
+ Sleep(delay);
+ }
+ uint64_t start = cTimeMs::Now();
+ while (Running() || !modeIn) {
+ uint64_t now = cTimeMs::Now();
+ if (Running() || !modeIn)
+ shiftable->SetPosition(pos, shiftend);
+ if (Running() || !modeIn)
+ shiftable->Flush();
+ int delta = cTimeMs::Now() - now;
+ if ((Running() || !modeIn) && (delta < frametime)) {
+ cCondWait::SleepMs(frametime - delta);
+ }
+ if ((int)(now - start) > shifttime) {
+ if ((Running() && modeIn) && pos != shiftend) {
+ shiftable->SetPosition(shiftend, shiftend);
+ shiftable->Flush();
+ }
+ break;
+ }
+ if (mode == eShiftMode::slowedDown) {
+ double t = (double)(now - start) / (double)shifttime;
+ double factor = 1.0f + (double)slowRatio / 100.0f - 2.0f * ((double)slowRatio / 100.0f) * t;
+ stepX = stepXLinear * factor;
+ stepY = stepYLinear * factor;
+ }
+ if (modeIn) {
+ pos.Set(pos.X() + stepX, pos.Y() + stepY);
+ } else {
+ pos.Set(pos.X() - stepX, pos.Y() - stepY);
+ }
+ }
+
+}
+
+void cAnimation::Blink(void) {
+ int freq = blinkable->BlinkFreq(blinkFunc);
+ bool blinkOn = false;
+ while (Running()) {
+ Sleep(freq);
+ if (Running()) {
+ blinkable->DoBlink(blinkFunc, blinkOn);
+ blinkable->Flush();
+ }
+ blinkOn = !blinkOn;
+ }
+}
diff --git a/coreengine/animation.h b/coreengine/animation.h new file mode 100644 index 0000000..64f17ad --- /dev/null +++ b/coreengine/animation.h @@ -0,0 +1,126 @@ +#ifndef __ANIMATION_H
+#define __ANIMATION_H
+
+#include <vdr/skins.h>
+#include <vdr/thread.h>
+#include "definitions.h"
+
+#define FPS 50
+
+/******************************************************************
+* cScrollable
+******************************************************************/
+class cScrollable {
+protected:
+ cScrollable(void) {};
+ ~cScrollable(void) {};
+public:
+ virtual int ScrollDelay(void) = 0;
+ virtual int ScrollWidth(void) = 0;
+ virtual int ScrollHeight(void) = 0;
+ virtual eScrollMode ScrollMode(void) = 0;
+ virtual eScrollSpeed ScrollSpeed(void) = 0;
+ virtual eOrientation ScrollOrientation(void) = 0;
+ virtual void StartScrolling(void) = 0;
+ virtual void StopScrolling(void) = 0;
+ virtual void SetDrawPort(cPoint &point) = 0;
+ virtual void Flush(void) = 0;
+};
+
+/******************************************************************
+* cDetachable
+******************************************************************/
+class cDetachable {
+protected:
+ cDetachable(void) {};
+ ~cDetachable(void) {};
+public:
+ virtual int Delay(void) = 0;
+ virtual void ParseDetached(void) = 0;
+ virtual void RenderDetached(void) = 0;
+ virtual void StartAnimation(void) = 0;
+ virtual void Flush(void) = 0;
+};
+
+/******************************************************************
+* cFadable
+******************************************************************/
+class cFadable {
+protected:
+ cFadable(void) {};
+ ~cFadable(void) {};
+public:
+ virtual bool Detached(void) = 0;
+ virtual int Delay(void) = 0;
+ virtual int FadeTime(void) = 0;
+ virtual void SetTransparency(int transparency, bool force = false) = 0;
+ virtual void Flush(void) = 0;
+};
+
+/******************************************************************
+* cShiftable
+******************************************************************/
+class cShiftable {
+protected:
+ cShiftable(void) {};
+ ~cShiftable(void) {};
+public:
+ virtual bool Detached(void) = 0;
+ virtual int Delay(void) = 0;
+ virtual int ShiftTime(void) = 0;
+ virtual int ShiftMode(void) = 0;
+ virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false) = 0;
+ virtual void Flush(void) = 0;
+};
+
+/******************************************************************
+* cBlinkable
+******************************************************************/
+class cBlinkable {
+protected:
+ cBlinkable(void) {};
+ ~cBlinkable(void) {};
+public:
+ virtual int BlinkFreq(int func) = 0;
+ virtual void DoBlink(int func, bool on) = 0;
+ virtual void Flush(void) = 0;
+};
+
+/******************************************************************
+* cAnimation
+******************************************************************/
+class cAnimation : public cThread, public cListObject {
+private:
+ cCondWait sleepWait;
+ cScrollable *scrollable;
+ cDetachable *detachable;
+ cFadable *fadable;
+ cShiftable *shiftable;
+ cBlinkable *blinkable;
+ bool waitOnWakeup;
+ bool doAnimation;
+ bool modeIn;
+ int blinkFunc;
+ cPoint shiftstart;
+ cPoint shiftend;
+ void Sleep(int duration);
+ void Wait(void);
+ void Scroll(void);
+ void Detach(void);
+ void Blink(void);
+protected:
+ virtual void Action(void);
+public:
+ cAnimation(cScrollable *scrollable);
+ cAnimation(cDetachable *detachable, bool wait, bool animation);
+ cAnimation(cFadable *fadable, bool fadein);
+ cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin);
+ cAnimation(cBlinkable *blinkable, int func);
+ ~cAnimation(void);
+ void WakeUp(void);
+ void Fade(void);
+ void Shift(void);
+ void Stop(bool deletePixmaps);
+};
+
+#endif //__ANIMATION_H
\ No newline at end of file diff --git a/coreengine/area.c b/coreengine/area.c new file mode 100644 index 0000000..b961fd8 --- /dev/null +++ b/coreengine/area.c @@ -0,0 +1,767 @@ +#include "area.h"
+#include "../config.h"
+
+/******************************************************************
+* cAreaNode
+******************************************************************/
+cAreaNode::cAreaNode(void) {
+ globals = NULL;
+ isTab = false;
+ activeTab = false;
+}
+
+cAreaNode::~cAreaNode(void) {
+}
+
+void cAreaNode::SetContainer(int x, int y, int width, int height) {
+ container.SetX(x);
+ container.SetY(y);
+ container.SetWidth(width);
+ container.SetHeight(height);
+}
+
+/******************************************************************
+* cArea
+******************************************************************/
+cArea::cArea(void) {
+ sdOsd = NULL;
+ init = true;
+ isBackgroundArea = false;
+ attribs = new cAreaAttribs((int)eAreaAttribs::count);
+ scrolling = false;
+ isScrolling = false;
+ scrollFunc = NULL;
+ blinking = false;
+ areaContainer = NULL;
+ pix = NULL;
+}
+
+cArea::cArea(const cArea &other) {
+ sdOsd = other.sdOsd;
+ init = true;
+ isBackgroundArea = false;
+ pix = NULL;
+ globals = other.globals;
+ attribs = new cAreaAttribs(*other.attribs);
+ //area container is set from outside during cloning of areacontainer
+ areaContainer = NULL;
+ //scrolling is set from outside by ScrollFunc(), see below
+ scrolling = other.scrolling;
+ isScrolling = false;
+ blinking = false;
+ scrollFunc = NULL;
+
+ for (cFunction *func = other.functions.First(); func; func = other.functions.Next(func)) {
+ if (cFuncFill *f = dynamic_cast<cFuncFill*>(func)) {
+ cFuncFill *fFill = new cFuncFill(*f);
+ fFill->SetOwner(this);
+ functions.Add(fFill);
+ } else if (cFuncDrawRectangle *f = dynamic_cast<cFuncDrawRectangle*>(func)) {
+ cFuncDrawRectangle *fDrawRect = new cFuncDrawRectangle(*f);
+ fDrawRect->SetOwner(this);
+ functions.Add(fDrawRect);
+ } else if (cFuncDrawEllipse *f = dynamic_cast<cFuncDrawEllipse*>(func)) {
+ cFuncDrawEllipse *fDrawEllipse = new cFuncDrawEllipse(*f);
+ fDrawEllipse->SetOwner(this);
+ functions.Add(fDrawEllipse);
+ } else if (cFuncDrawSlope *f = dynamic_cast<cFuncDrawSlope*>(func)) {
+ cFuncDrawSlope *fDrawSlope = new cFuncDrawSlope(*f);
+ fDrawSlope->SetOwner(this);
+ functions.Add(fDrawSlope);
+ } else if (cFuncDrawText *f = dynamic_cast<cFuncDrawText*>(func)) {
+ cFuncDrawText *fDrawText = new cFuncDrawText(*f);
+ fDrawText->SetOwner(this);
+ functions.Add(fDrawText);
+ } else if (cFuncDrawTextVertical *f = dynamic_cast<cFuncDrawTextVertical*>(func)) {
+ cFuncDrawTextVertical *fDrawTextVertical = new cFuncDrawTextVertical(*f);
+ fDrawTextVertical->SetOwner(this);
+ functions.Add(fDrawTextVertical);
+ } else if (cFuncDrawTextBox *f = dynamic_cast<cFuncDrawTextBox*>(func)) {
+ cFuncDrawTextBox *fDrawTextBox = new cFuncDrawTextBox(*f);
+ fDrawTextBox->SetOwner(this);
+ functions.Add(fDrawTextBox);
+ } else if (cFuncDrawImage *f = dynamic_cast<cFuncDrawImage*>(func)) {
+ cFuncDrawImage *fDrawImage = new cFuncDrawImage(*f);
+ fDrawImage->SetOwner(this);
+ functions.Add(fDrawImage);
+ } else {
+ esyslog("skindesigner: ERROR: unknown function in area cloning!!!");
+ }
+ }
+
+ //func references have to be set from outside if already cached clone is wanted
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->CacheFuncReferences();
+ }
+ if (scrolling) {
+ SetScrollFunc();
+ }
+}
+
+cArea::~cArea(void) {
+ StopBlinkers();
+ delete attribs;
+}
+
+void cArea::SetGlobals(cGlobals *globals) {
+ this->globals = globals;
+ attribs->SetGlobals(globals);
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetGlobals(globals);
+ }
+}
+
+void cArea::SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {
+ attribs->SetTokenContainer(tokenContainer);
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cArea::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
+ attribs->SetTokenContainerDeep(tokenContainer);
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetTokenContainerDeep(tokenContainer);
+ }
+}
+
+void cArea::SetAttributes(vector<stringpair> &attributes) {
+ attribs->Set(attributes);
+}
+
+bool cArea::ValidFunction(const char *func) {
+ if (!strcmp(func, "fill")) return true;
+ if (!strcmp(func, "drawtext")) return true;
+ if (!strcmp(func, "drawtextbox")) return true;
+ if (!strcmp(func, "drawtextvertical")) return true;
+ if (!strcmp(func, "drawimage")) return true;
+ if (!strcmp(func, "drawrectangle")) return true;
+ if (!strcmp(func, "drawellipse")) return true;
+ if (!strcmp(func, "drawslope")) return true;
+ esyslog("skindesigner: unknown function \"%s\"", func);
+ return false;
+}
+
+cFunction *cArea::AddFunction(const char *name, vector<stringpair> attribs, cFuncLoop *loopFunc) {
+ cFunction *f = NULL;
+ if (!strcmp(name, "fill")) {
+ f = new cFuncFill(this, (int)eFillAttribs::count);
+ } else if (!strcmp(name, "drawrectangle")) {
+ f = new cFuncDrawRectangle(this, (int)eDrawRectangleAttribs::count);
+ } else if (!strcmp(name, "drawellipse")) {
+ f = new cFuncDrawEllipse(this, (int)eDrawEllipseAttribs::count);
+ } else if (!strcmp(name, "drawslope")) {
+ f = new cFuncDrawSlope(this, (int)eDrawSlopeAttribs::count);
+ } else if (!strcmp(name, "drawtext")) {
+ f = new cFuncDrawText(this, (int)eDrawTextAttribs::count);
+ } else if (!strcmp(name, "drawtextvertical")) {
+ f = new cFuncDrawTextVertical(this, (int)eDrawTextAttribs::count);
+ } else if (!strcmp(name, "drawtextbox")) {
+ f = new cFuncDrawTextBox(this, (int)eDrawTextBoxAttribs::count);
+ } else if (!strcmp(name, "drawimage")) {
+ f = new cFuncDrawImage(this, (int)eDrawImageAttribs::count);
+ } else if (!strcmp(name, "loop")) {
+ f = new cFuncLoop(this, (int)eLoopAttribs::count);
+ }
+ if (!f) {
+ esyslog("skindesigner: TODO: function \"%s\" not implemented", name);
+ return NULL;
+ }
+ f->Set(attribs);
+ if (!loopFunc)
+ functions.Add(f);
+ else
+ loopFunc->AddFunction(f);
+ return f;
+}
+
+cFunction *cArea::GetFunction(const char *name) {
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ const char *funcName = f->Name();
+ if (funcName && !strcmp(funcName, name)) {
+ return f;
+ }
+ cFuncLoop *loopFunc = dynamic_cast<cFuncLoop*>(f);
+ if (loopFunc) {
+ cFunction *lf = loopFunc->GetFunction(name);
+ if (lf)
+ return lf;
+ }
+ }
+ if (!areaContainer)
+ return NULL;
+ return areaContainer->GetFunction(name);
+}
+
+void cArea::SetX(int x) {
+ attribs->SetX(x);
+}
+
+void cArea::SetY(int y) {
+ attribs->SetY(y);
+}
+
+void cArea::SetWidth(int width) {
+ attribs->SetWidth(width);
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ }
+}
+
+void cArea::SetHeight(int height) {
+ attribs->SetHeight(height);
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ }
+}
+
+void cArea::Cache(void) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Cache();
+ attribs->CheckDynamic();
+ isBackgroundArea = attribs->BackgroundArea();
+
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (!attribs->Dynamic()) {
+ f->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ } else {
+ f->SetContainer(0, 0, -1, -1);
+ }
+ f->Cache();
+ }
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->CacheFuncReferences();
+ }
+ if (scrolling) {
+ SetScrollFunc();
+ }
+}
+
+void cArea::Close(void) {
+ StopBlinkers();
+ if (pix) {
+ sdOsd->DestroyPixmap(pix);
+ pix = NULL;
+ }
+ init = true;
+}
+
+void cArea::Clear(void) {
+ if (!init && isBackgroundArea) {
+ return;
+ }
+ if (pix) {
+ pix->Fill(clrTransparent);
+ }
+}
+
+void cArea::Hide(void) {
+ StopBlinkers();
+ if (pix) {
+ pix->SetLayer(-1);
+ }
+}
+
+void cArea::Show(void) {
+ StartBlinkers();
+ if (pix) {
+ pix->SetLayer(attribs->Layer());
+ }
+}
+
+void cArea::Render(void) {
+ if (attribs->DoDebug())
+ Debug();
+
+ if (init) {
+ InitFunctions();
+ init = false;
+ }
+
+ if (!isScrolling && scrollFunc && attribs->Orientation() == (int)eOrientation::horizontal) {
+ scrollFunc->Scrolling(false);
+ } else if (isScrolling && scrollFunc && attribs->Orientation() == (int)eOrientation::horizontal) {
+ scrollFunc->Scrolling(true);
+ }
+
+ if (!pix) {
+ if (!IsTab())
+ CreatePixmap();
+ else {
+ int overlap = ScrollHeight();
+ if (overlap > 0) {
+ cRect drawport;
+ drawport.SetX(0);
+ drawport.SetY(0);
+ drawport.SetWidth(attribs->Width());
+ drawport.SetHeight(overlap + attribs->Height());
+ CreatePixmap(drawport);
+ } else {
+ CreatePixmap();
+ }
+ }
+ }
+
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (f->DoDebug())
+ f->Debug();
+ if (!f->DoExecute())
+ continue;
+ if (pix) {
+ f->Render(pix);
+ }
+ }
+
+ StartBlinkers();
+}
+
+bool cArea::Execute(void) {
+ return attribs->DoExecute();
+}
+
+void cArea::SetTransparency(int transparency, bool absolute) {
+ if (transparency < 0 || transparency > 100)
+ return;
+ int alpha = (100 - transparency)*255/100;
+ if (!absolute) {
+ int pixTransparency = attribs->Transparency();
+ if (pixTransparency > 0) {
+ alpha = (100 - pixTransparency) * alpha / 100;
+ }
+ }
+ if (pix) {
+ pix->SetAlpha(alpha);
+ }
+}
+
+bool cArea::Scrolling(void) {
+ if (!scrolling)
+ return false;
+ if (!Execute())
+ return false;
+ if (ScrollOrientation() == eOrientation::horizontal) {
+ if (!scrollFunc)
+ return false;
+ if (scrollFunc->X() + scrollFunc->FuncWidth() > attribs->Width())
+ return true;
+ } else if (ScrollOrientation() == eOrientation::vertical) {
+ int maxHeight = 0;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ int funcHeight = f->FuncY() + f->FuncHeight();
+ if (funcHeight > maxHeight)
+ maxHeight = funcHeight;
+ }
+ if (maxHeight > attribs->Height())
+ return true;
+ }
+ return false;
+}
+
+int cArea::ScrollWidth(void) {
+ if (!scrollFunc)
+ return 0;
+ return scrollFunc->X() + scrollFunc->FuncWidth() + 10 - attribs->Width();
+}
+
+int cArea::ScrollHeight(void) {
+ int maxHeight = 0;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (!f->DoExecute())
+ continue;
+ int funcHeight = f->FuncY() + f->FuncHeight();
+ if (funcHeight > maxHeight)
+ maxHeight = funcHeight;
+ }
+ return maxHeight - attribs->Height();
+}
+
+int cArea::ScrollDelay(void) {
+ return attribs->Delay();
+}
+
+eScrollMode cArea::ScrollMode(void) {
+ return (eScrollMode)attribs->Mode();
+}
+
+eScrollSpeed cArea::ScrollSpeed(void) {
+ return (eScrollSpeed)attribs->ScrollSpeed();
+}
+
+eOrientation cArea::ScrollOrientation(void) {
+ return (eOrientation)attribs->Orientation();
+}
+
+void cArea::StartScrolling(void) {
+ cRect drawport;
+ drawport.SetX(0);
+ drawport.SetY(0);
+ if (ScrollOrientation() == eOrientation::horizontal) {
+ drawport.SetWidth(ScrollWidth() + attribs->Width());
+ drawport.SetHeight(attribs->Height());
+ } else if (ScrollOrientation() == eOrientation::vertical) {
+ drawport.SetWidth(attribs->Width());
+ drawport.SetHeight(ScrollHeight() + attribs->Height() + 10);
+ }
+ isScrolling = true;
+ CreatePixmap(drawport);
+ Render();
+}
+
+void cArea::StopScrolling(void) {
+ isScrolling = false;
+ if (pix && !(pix->ViewPort().Size() == pix->DrawPort().Size())) {
+ sdOsd->DestroyPixmap(pix);
+ pix = NULL;
+ }
+}
+
+void cArea::SetViewPort(cRect &vp) {
+ if (!pix)
+ return;
+ pix->SetViewPort(vp);
+}
+
+void cArea::SetPosition(cPoint &pos, cPoint &ref) {
+ if (!pix)
+ return;
+ int x = (attribs->X() - ref.X()) + pos.X();
+ int y = (attribs->Y() - ref.Y()) + pos.Y();
+ pix->SetViewPort(cRect(x, y, pix->ViewPort().Width(), pix->ViewPort().Height()));
+}
+
+void cArea::SetDrawPort(cPoint &point) {
+ if (!pix)
+ return;
+ pix->SetDrawPortPoint(point);
+}
+
+cRect cArea::ViewPort(void) {
+ if (!pix)
+ return cRect::Null;
+ cRect vp = pix->ViewPort();
+ return vp;
+}
+
+cRect cArea::CoveringArea(void) {
+ return ViewPort();
+}
+
+cRect cArea::DrawPort(void) {
+ if (!pix)
+ return cRect::Null;
+ cRect dp = pix->DrawPort();
+ return dp;
+}
+
+int cArea::BlinkFreq(int func) {
+ cFunction *blinkFunc = functions.Get(func);
+ if (!blinkFunc)
+ return -1;
+ return blinkFunc->BlinkFreq();
+}
+
+void cArea::DoBlink(int func, bool on) {
+ cFunction *blinker = functions.Get(func);
+ if (!blinker)
+ return;
+ if (on) {
+ if (pix) {
+ blinker->Render(pix);
+ }
+ } else {
+ cRect blinkRect = cRect(blinker->GetX((eAlign)blinker->Align(), 0, 0),
+ blinker->GetY((eAlign)blinker->Valign(), 0, 0),
+ blinker->FuncWidth(),
+ blinker->FuncHeight());
+ if (pix) {
+ pix->DrawRectangle(blinkRect, clrTransparent);
+ }
+ }
+}
+
+void cArea::Debug(bool full) {
+ esyslog("skindesigner: --> area");
+ esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Debug();
+ if (!full)
+ return;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->Debug();
+ }
+}
+
+void cArea::Flush(void) {
+ sdOsd->Flush();
+}
+/******************************************************************
+* Private Functions
+******************************************************************/
+void cArea::InitFunctions(void) {
+ if (!attribs->Dynamic())
+ return;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ }
+}
+
+void cArea::CreatePixmap(cRect drawPort) {
+ if (pix) {
+ sdOsd->DestroyPixmap(pix);
+ pix = NULL;
+ }
+ if (attribs->Width() <=0 || attribs->Height() <= 0) {
+ return;
+ }
+
+ int layer = attribs->Layer();
+ cRect viewPort(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ pix = sdOsd->CreatePixmap(layer, viewPort, drawPort);
+ if (pix)
+ pix->Clear();
+
+ int pixTransparency = attribs->Transparency();
+ if (pixTransparency > 0) {
+ SetTransparency(pixTransparency, true);
+ }
+}
+
+void cArea::SetScrollFunc(void) {
+ //if area has only one function, take this anyway
+ if (functions.Count() == 1) {
+ scrollFunc = functions.First();
+ return;
+ }
+ //else use scrollelement name
+ const char *scrollFuncName = attribs->GetScrollElement();
+ if (!scrollFuncName)
+ return;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (!f->Name())
+ continue;
+ if (!strcmp(f->Name(), scrollFuncName)) {
+ scrollFunc = f;
+ return;
+ }
+ }
+}
+
+void cArea::StartBlinkers(void) {
+ if (blinking)
+ return;
+ blinking = true;
+ int func = 0;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (!f->DoExecute()) {
+ func++;
+ continue;
+ }
+ if (f->Blinking()) {
+ cAnimation *blink = new cAnimation((cBlinkable*)this, func);
+ blinkers.Add(blink);
+ blink->Start();
+ }
+ func++;
+ }
+}
+
+void cArea::StopBlinkers(void) {
+ blinking = false;
+ blinkers.Clear();
+}
+
+/******************************************************************
+* cAreaContainer
+******************************************************************/
+cAreaContainer::cAreaContainer(void) {
+ attribs = new cAreaContainerAttribs((int)eAreaContainerAttribs::count);
+}
+
+cAreaContainer::cAreaContainer(const cAreaContainer &other) {
+ globals = other.globals;
+ attribs = new cAreaContainerAttribs(*other.attribs);
+ for (cArea *area = other.areas.First(); area; area = other.areas.Next(area)) {
+ cArea *a = new cArea(*area);
+ a->SetAreaContainer(this);
+ areas.Add(a);
+ }
+}
+
+cAreaContainer::~cAreaContainer(void) {
+ delete attribs;
+}
+
+void cAreaContainer::SetAttributes(vector<stringpair> &attributes) {
+ attribs->Set(attributes);
+}
+
+void cAreaContainer::SetGlobals(cGlobals *globals) {
+ this->globals = globals;
+ attribs->SetGlobals(globals);
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetGlobals(globals);
+ }
+}
+
+void cAreaContainer::SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {
+ attribs->SetTokenContainer(tokenContainer);
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cAreaContainer::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
+ attribs->SetTokenContainerDeep(tokenContainer);
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetTokenContainerDeep(tokenContainer);
+ }
+}
+
+void cAreaContainer::AddArea(cArea *area) {
+ area->SetAreaContainer(this);
+ areas.Add(area);
+}
+
+cFunction *cAreaContainer::GetFunction(const char *name) {
+ cFunction *fRef = NULL;
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ fRef = area->GetFunction(name);
+ if (fRef)
+ return fRef;
+ }
+ return NULL;
+}
+
+void cAreaContainer::SetX(int x) {
+ attribs->SetX(x);
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetX(x);
+ }
+}
+
+void cAreaContainer::SetY(int y) {
+ attribs->SetY(y);
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetY(y);
+ }
+}
+
+void cAreaContainer::SetWidth(int width) {
+ attribs->SetWidth(width);
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetWidth(width);
+ }
+}
+
+void cAreaContainer::SetHeight(int height) {
+ attribs->SetHeight(height);
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetHeight(height);
+ }
+}
+
+void cAreaContainer::Cache(void) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Cache();
+ int x = attribs->X() > -1 ? attribs->X() : container.X();
+ int y = attribs->Y() > -1 ? attribs->Y() : container.Y();
+ int width = attribs->Width() > -1 ? attribs->Width() : container.Width();
+ int height = attribs->Height() > -1 ? attribs->Height() : container.Height();
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetContainer(x, y, width, height);
+ if (attribs->Width() > -1) {
+ area->SetWidth(width);
+ }
+ if (attribs->Height() > -1) {
+ area->SetHeight(height);
+ }
+ area->Cache();
+ }
+}
+
+void cAreaContainer::Close(void) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->Close();
+ }
+}
+
+void cAreaContainer::Clear(void) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->Clear();
+ }
+}
+
+void cAreaContainer::Hide(void) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->Hide();
+ }
+}
+
+void cAreaContainer::Show(void) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->Show();
+ }
+}
+
+void cAreaContainer::Render(void) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ if (area->Execute())
+ area->Render();
+ }
+}
+
+bool cAreaContainer::Execute(void) {
+ return attribs->DoExecute();
+}
+
+void cAreaContainer::SetTransparency(int transparency, bool absolute) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetTransparency(transparency, absolute);
+ }
+}
+
+void cAreaContainer::SetViewPort(cRect &vp) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetViewPort(vp);
+ }
+}
+
+void cAreaContainer::SetPosition(cPoint &pos, cPoint &ref) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->SetPosition(pos, ref);
+ }
+}
+
+cRect cAreaContainer::CoveringArea(void) {
+ cRect unionArea;
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ unionArea.Combine(area->CoveringArea());
+ }
+ return unionArea;
+}
+
+bool cAreaContainer::Scrolling(void) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ if (area->Scrolling())
+ return true;
+ }
+ return false;
+}
+
+cArea *cAreaContainer::ScrollingArea(void) {
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ if (area->Execute() && area->Scrolling())
+ return area;
+ }
+ return NULL;
+}
+
+void cAreaContainer::Debug(bool full) {
+ esyslog("skindesigner: --> area container");
+ esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Debug();
+ if (!full)
+ return;
+ for (cArea *area = areas.First(); area; area = areas.Next(area)) {
+ area->Debug(full);
+ }
+}
diff --git a/coreengine/area.h b/coreengine/area.h new file mode 100644 index 0000000..e77b946 --- /dev/null +++ b/coreengine/area.h @@ -0,0 +1,178 @@ +#ifndef __TEMPLATEAREA_H
+#define __TEMPLATEAREA_H
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "osdwrapper.h"
+#include "definitions.h"
+#include "globals.h"
+#include "../libskindesignerapi/tokencontainer.h"
+#include "attributes.h"
+#include "functions.h"
+#include "animation.h"
+
+class cArea;
+/******************************************************************
+* cAreaNode
+******************************************************************/
+class cAreaNode : public cListObject {
+protected:
+ cGlobals *globals;
+ cRect container;
+ bool isTab;
+ bool activeTab;
+public:
+ cAreaNode(void);
+ virtual ~cAreaNode(void);
+ virtual void SetGlobals(cGlobals *globals) {};
+ virtual void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {};
+ virtual void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {};
+ void SetContainer(int x, int y, int width, int height);
+ virtual void SetAttributes(vector<stringpair> &attributes) {};
+ virtual void SetX(int x) {};
+ virtual void SetY(int y) {};
+ virtual void SetWidth(int width) {};
+ virtual void SetHeight(int height) {};
+ void SetTab(void) { isTab = true; };
+ bool IsTab(void) { return isTab; };
+ void SetActiveTab(bool active) { activeTab = active; };
+ bool ActiveTab(void) { return activeTab; };
+ virtual int GetWidth(void) { return 0; };
+ virtual void Cache(void) {};
+ virtual void Close(void) {};
+ virtual void Clear(void) {};
+ virtual void Hide(void) {};
+ virtual void Show(void) {};
+ virtual void Render(void) {};
+ virtual bool Execute(void) { return true; };
+ virtual void SetTransparency(int transparency, bool absolute = false) {};
+ virtual void SetViewPort(cRect &vp) {};
+ virtual void SetPosition(cPoint &pos, cPoint &ref) {};
+ virtual cRect CoveringArea(void) { return cRect::Null; };
+ virtual bool Scrolling(void) { return false; };
+ virtual cArea *ScrollingArea(void) { return NULL; };
+ virtual cFunction *GetFunction(const char *name) { return NULL; };
+ virtual const char *Name(void) { return NULL; };
+ virtual bool BackgroundArea(void) { return false; };
+ virtual void Debug(bool full = false) {};
+};
+
+class cAreaContainer;
+/******************************************************************
+* cArea
+******************************************************************/
+class cArea : public cAreaNode, public cScrollable, public cBlinkable {
+private:
+ cSdOsd *sdOsd;
+ bool init;
+ bool isBackgroundArea;
+ cPixmap *pix;
+ cAreaAttribs *attribs;
+ cAreaContainer *areaContainer;
+ cList<cFunction> functions;
+ bool scrolling;
+ bool isScrolling;
+ cFunction *scrollFunc;
+ cList<cAnimation> blinkers;
+ bool blinking;
+ void InitFunctions(void);
+ void CreatePixmap(cRect drawPort = cRect::Null);
+ void SetScrollFunc(void);
+ void StartBlinkers(void);
+ void StopBlinkers(void);
+public:
+ cArea(void);
+ cArea(const cArea &other);
+ virtual ~cArea(void);
+ void SetOsd(cSdOsd *osd) { sdOsd = osd; };
+ void SetGlobals(cGlobals *globals);
+ void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer);
+ void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
+ void SetAttributes(vector<stringpair> &attributes);
+ void SetScrolling(void) { scrolling = true; };
+ void SetAreaContainer(cAreaContainer *ac) { areaContainer = ac; };
+ bool ValidFunction(const char *func);
+ cFunction *AddFunction(const char *name, vector<stringpair> attribs, cFuncLoop *loopFunc = NULL);
+ cFunction *GetFunction(const char *name);
+ void SetX(int x);
+ void SetY(int y);
+ void SetWidth(int width);
+ void SetHeight(int height);
+ void Cache(void);
+ int GetWidth(void) { return attribs->Width(); };
+ void Close(void);
+ void Clear(void);
+ void Hide(void);
+ void Show(void);
+ void Render(void);
+ bool Execute(void);
+ void SetTransparency(int transparency, bool absolute = false);
+ cRect CoveringArea(void);
+ //Scrollable
+ bool Scrolling(void);
+ int ScrollWidth(void);
+ int ScrollHeight(void);
+ int ScrollDelay(void);
+ eScrollMode ScrollMode(void);
+ eScrollSpeed ScrollSpeed(void);
+ eOrientation ScrollOrientation(void);
+ cArea *ScrollingArea(void) { return this; };
+ void StartScrolling(void);
+ void StopScrolling(void);
+ cRect ViewPort(void);
+ void SetDrawPort(cPoint &point);
+ void SetViewPort(cRect &vp);
+ void SetPosition(cPoint &pos, cPoint &ref);
+ cRect DrawPort(void);
+ int ScrollStep(void) { return attribs->ScrollStep(); };
+ //Blinkable
+ int BlinkFreq(int func);
+ void DoBlink(int func, bool on);
+ //Common
+ const char *Name(void) { return attribs->Name(); };
+ bool BackgroundArea(void) { return attribs->BackgroundArea(); };
+ void Flush(void);
+ void Debug(bool full = false);
+};
+
+/******************************************************************
+* cAreaContainer
+******************************************************************/
+class cAreaContainer : public cAreaNode {
+private:
+ cAreaContainerAttribs *attribs;
+ cList<cArea> areas;
+public:
+ cAreaContainer(void);
+ cAreaContainer(const cAreaContainer &other);
+ virtual ~cAreaContainer(void);
+ void SetGlobals(cGlobals *globals);
+ void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer);
+ void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
+ void SetAttributes(vector<stringpair> &attributes);
+ void AddArea(cArea *area);
+ cFunction *GetFunction(const char *name);
+ void SetX(int x);
+ void SetY(int y);
+ void SetWidth(int width);
+ void SetHeight(int height);
+ void Cache(void);
+ void Close(void);
+ void Clear(void);
+ void Hide(void);
+ void Show(void);
+ void Render(void);
+ bool Execute(void);
+ void SetTransparency(int transparency, bool absolute = false);
+ void SetViewPort(cRect &vp);
+ void SetPosition(cPoint &pos, cPoint &ref);
+ cRect CoveringArea(void);
+ bool Scrolling(void);
+ cArea *ScrollingArea(void);
+ void Debug(bool full = false);
+};
+
+#endif //__TEMPLATEAREA_H
\ No newline at end of file diff --git a/coreengine/attribute.c b/coreengine/attribute.c new file mode 100644 index 0000000..06ea17e --- /dev/null +++ b/coreengine/attribute.c @@ -0,0 +1,478 @@ +#include "attribute.h"
+#include "../config.h"
+
+/***************************************************************************
+* cAttributes
+***************************************************************************/
+cAttributes::cAttributes(int numAttributes) {
+ globals = NULL;
+ tokenContainer = NULL;
+ numAttribs = (int)eCommonAttribs::count + numAttributes;
+ attribs = new int[numAttribs];
+ for (int i=0; i < numAttribs; i++)
+ attribs[i] = ATTR_UNKNOWN;
+ attribCtors = new cNumericExpr*[numAttribs];
+ for (int i=0; i < numAttribs; i++)
+ attribCtors[i] = NULL;
+ cond = NULL;
+ SetCommonAttributesDefs();
+}
+
+cAttributes::cAttributes(const cAttributes &other) : cAttributes(other.numAttribs - (int)eCommonAttribs::count){
+ globals = other.globals;
+ for (int i=0; i < numAttribs; i++) {
+ attribs[i] = other.attribs[i];
+ if (other.attribCtors[i]) {
+ attribCtors[i] = new cNumericExpr(*other.attribCtors[i]);
+ attribCtors[i]->SetContainer(&container);
+ }
+ }
+ cond = NULL;
+ if (other.cond) {
+ cond = new cCondition(*other.cond);
+ }
+ attribIDs = other.attribIDs;
+ attribNames = other.attribNames;
+}
+
+cAttributes::~cAttributes(void) {
+ delete[] attribs;
+ for (int i=0; i < numAttribs; i++) {
+ delete attribCtors[i];
+ }
+ delete[] attribCtors;
+ delete cond;
+}
+
+void cAttributes::SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {
+ this->tokenContainer = tokenContainer;
+}
+
+void cAttributes::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
+ this->tokenContainer = tokenContainer;
+ if (cond) {
+ cond->SetTokenContainer(tokenContainer);
+ }
+ for (int i=0; i < numAttribs; i++) {
+ if (!attribCtors[i])
+ continue;
+ attribCtors[i]->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cAttributes::SetContainer(int x, int y, int width, int height) {
+ container.SetX(x);
+ container.SetY(y);
+ container.SetWidth(width);
+ container.SetHeight(height);
+}
+
+void cAttributes::SetX(int x) {
+ attribs[(int)eCommonAttribs::x] = x;
+}
+
+void cAttributes::SetY(int y) {
+ attribs[(int)eCommonAttribs::y] = y;
+}
+
+void cAttributes::SetWidth(int width) {
+ attribs[(int)eCommonAttribs::width] = width;
+}
+
+void cAttributes::SetHeight(int height) {
+ attribs[(int)eCommonAttribs::height] = height;
+}
+
+void cAttributes::Cache(void) {
+ if (cond) {
+ cond->SetGlobals(globals);
+ cond->SetTokenContainer(tokenContainer);
+ cond->Prepare();
+ }
+ for (int i=0; i < numAttribs; i++) {
+ if (!attribCtors[i])
+ continue;
+ attribCtors[i]->SetContainer(&container);
+ attribCtors[i]->SetGlobals(globals);
+ attribCtors[i]->SetTokenContainer(tokenContainer);
+ if (attribCtors[i]->CacheStatic()) {
+ int val = attribCtors[i]->GetValue();
+ attribs[i] = val;
+ delete attribCtors[i];
+ attribCtors[i] = NULL;
+ } else {
+ attribCtors[i]->PrepareTokens();
+ }
+ }
+}
+
+int cAttributes::GetValue(int id) {
+ if (!attribCtors[id + (int)eCommonAttribs::count])
+ return attribs[(int)id + (int)eCommonAttribs::count];
+ return attribCtors[id + (int)eCommonAttribs::count]->Calculate();
+}
+
+
+int cAttributes::X(void) {
+ int x = 0;
+ if (!attribCtors[(int)eCommonAttribs::x])
+ x = attribs[(int)eCommonAttribs::x];
+ else
+ x = attribCtors[(int)eCommonAttribs::x]->Calculate();
+ x += container.X();
+ return x;
+}
+
+int cAttributes::Y(void) {
+ int y = 0;
+ if (!attribCtors[(int)eCommonAttribs::y])
+ y = attribs[(int)eCommonAttribs::y];
+ else
+ y = attribCtors[(int)eCommonAttribs::y]->Calculate();
+ y += container.Y();
+ return y;
+}
+
+int cAttributes::Width(void) {
+ if (!attribCtors[(int)eCommonAttribs::width])
+ return attribs[(int)eCommonAttribs::width];
+ return attribCtors[(int)eCommonAttribs::width]->Calculate();
+}
+
+int cAttributes::Height(void) {
+ if (!attribCtors[(int)eCommonAttribs::height])
+ return attribs[(int)eCommonAttribs::height];
+ return attribCtors[(int)eCommonAttribs::height]->Calculate();
+}
+
+bool cAttributes::DoExecute(void) {
+ if (!cond)
+ return true;
+ return cond->True();
+}
+
+
+void cAttributes::Debug(void) {
+ esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
+ for (int i=0; i < numAttribs; i++) {
+ if (attribs[i] != ATTR_UNKNOWN) {
+ if (i == (int)eCommonAttribs::debug)
+ continue;
+ const char *attName = "attribute";
+ if (i < (int)eCommonAttribs::count)
+ attName = CommonAttributeName(i);
+ else
+ attName = AttributeName(i - (int)eCommonAttribs::count);
+ dsyslog("skindesigner: fixed Value %s = %d", attName, attribs[i]);
+ }
+ if (attribCtors[i]) {
+ const char *attName = "attribute";
+ if (i < (int)eCommonAttribs::count)
+ attName = CommonAttributeName(i);
+ else
+ attName = AttributeName(i - (int)eCommonAttribs::count);
+ dsyslog("skindesigner: %s constructor:", attName);
+ attribCtors[i]->Debug();
+ }
+ }
+ if (cond) {
+ cond->Debug();
+ }
+}
+
+/***************************************************************************
+* Protected Functions
+***************************************************************************/
+int cAttributes::CommonAttributeId(const char *att) {
+ if (!strcmp(att, "condition"))
+ return ATTR_COND;
+ map<string, int>::iterator hit = commonAttribIDs.find(att);
+ if (hit != commonAttribIDs.end())
+ return hit->second;
+ return ATTR_UNKNOWN;
+}
+
+const char *cAttributes::CommonAttributeName(int id) {
+ if (id < 0 || id >= (int)eCommonAttribs::count)
+ return "";
+ map<int, string>::iterator hit = commonAttribNames.find(id);
+ if (hit != commonAttribNames.end())
+ return hit->second.c_str();
+ return "";
+}
+
+int cAttributes::AttributeId(const char *att) {
+ int id = CommonAttributeId(att);
+ if (id != ATTR_UNKNOWN)
+ return id;
+ map<string, int>::iterator hit = attribIDs.find(att);
+ if (hit != attribIDs.end())
+ id = (int)hit->second + (int)eCommonAttribs::count;
+ return id;
+}
+
+const char *cAttributes::AttributeName(int id) {
+ map<int, string>::iterator hit = attribNames.find(id);
+ if (hit != attribNames.end())
+ return hit->second.c_str();
+ return "";
+}
+
+bool cAttributes::SetCommon(int id, const char *val) {
+ if (id == ATTR_COND) {
+ cond = new cCondition(val);
+ return true;
+ }
+ if (id == (int)eCommonAttribs::debug) {
+ SetBool(id, val);
+ return true;
+ } else if (id == (int)eCommonAttribs::x || id == (int)eCommonAttribs::width) {
+ attribCtors[id] = new cNumericExpr(val);
+ return true;
+ } else if (id == (int)eCommonAttribs::y || id == (int)eCommonAttribs::height) {
+ attribCtors[id] = new cNumericExpr(val);
+ attribCtors[id]->SetVertical();
+ return true;
+ }
+ return false;
+}
+
+bool cAttributes::IdEqual(int id, int compId) {
+ if (compId + (int)eCommonAttribs::count == id)
+ return true;
+ return false;
+}
+
+
+void cAttributes::SetBool(int id, const char *val) {
+ if (!strcmp(val, "true")) {
+ attribs[id] = 1;
+ } else {
+ attribs[id] = 0;
+ }
+}
+
+void cAttributes::SetViewElementMode(int id, const char *val) {
+ eViewElementMode mode = eViewElementMode::regular;
+ if (!strcmp(val, "light"))
+ mode = eViewElementMode::light;
+ attribs[id] = (int)mode;
+}
+
+void cAttributes::SetShiftType(int id, const char *val) {
+ eShiftType shiftType = eShiftType::none;
+ if (!strcmp(val, "left"))
+ shiftType = eShiftType::left;
+ else if (!strcmp(val, "right"))
+ shiftType = eShiftType::right;
+ else if (!strcmp(val, "top"))
+ shiftType = eShiftType::top;
+ else if (!strcmp(val, "bottom"))
+ shiftType = eShiftType::bottom;
+ else {
+ esyslog("skindesigner: unknown shift type \"%s\"", val);
+ return;
+ }
+ attribs[id] = (int)shiftType;
+}
+
+void cAttributes::SetShiftMode(int id, const char *val) {
+ eShiftMode shiftMode = eShiftMode::linear;
+ if (!strcmp(val, "slowed"))
+ shiftMode = eShiftMode::slowedDown;
+ attribs[id] = (int)shiftMode;
+}
+
+void cAttributes::SetScrollMode(int id, const char *val) {
+ eScrollMode mode = eScrollMode::none;
+ if (!strcmp(val, "forthandback"))
+ mode = eScrollMode::forthandback;
+ else if (!strcmp(val, "carriagereturn"))
+ mode = eScrollMode::carriagereturn;
+ attribs[id] = (int)mode;
+}
+
+void cAttributes::SetScrollSpeed(int id, const char *val) {
+ eScrollSpeed speed = eScrollSpeed::medium;
+ if (!strcmp(val, "slow"))
+ speed = eScrollSpeed::slow;
+ else if (!strcmp(val, "fast"))
+ speed = eScrollSpeed::fast;
+ else if (!strcmp(val, "medium"))
+ speed = eScrollSpeed::medium;
+ attribs[id] = (int)speed;
+}
+
+void cAttributes::SetOrientation(int id, const char *val) {
+ eOrientation orientation = eOrientation::none;
+ if (!strcmp(val, "horizontal"))
+ orientation = eOrientation::horizontal;
+ else if (!strcmp(val, "vertical"))
+ orientation = eOrientation::vertical;
+ else if (!strcmp(val, "absolute"))
+ orientation = eOrientation::absolute;
+ attribs[id] = (int)orientation;
+}
+
+void cAttributes::SetAlign(int id, const char *val) {
+ eAlign align = eAlign::left;
+ if (!strcmp(val, "center")) {
+ align = eAlign::center;
+ } else if (!strcmp(val, "right")) {
+ align = eAlign::right;
+ } else if (!strcmp(val, "top")) {
+ align = eAlign::top;
+ } else if (!strcmp(val, "bottom")) {
+ align = eAlign::bottom;
+ } else if (!strcmp(val, "left")) {
+ align = eAlign::left;
+ }
+ attribs[id] = (int)align;
+}
+
+void cAttributes::SetDirection(int id, const char *val) {
+ eDirection direction = eDirection::none;
+ if (!strcmp(val, "bottomup"))
+ direction = eDirection::bottomup;
+ else if (!strcmp(val, "topdown"))
+ direction = eDirection::topdown;
+ attribs[id] = (int)direction;
+}
+
+/***************************************************************************
+* Private Functions
+***************************************************************************/
+void cAttributes::SetCommonAttributesDefs(void) {
+ commonAttribIDs.insert(pair<string, int>("x", (int)eCommonAttribs::x));
+ commonAttribIDs.insert(pair<string, int>("y", (int)eCommonAttribs::y));
+ commonAttribIDs.insert(pair<string, int>("width", (int)eCommonAttribs::width));
+ commonAttribIDs.insert(pair<string, int>("height", (int)eCommonAttribs::height));
+ commonAttribIDs.insert(pair<string, int>("debug", (int)eCommonAttribs::debug));
+ commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::x, "x"));
+ commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::y, "y"));
+ commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::width, "width"));
+ commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::height, "height"));
+ commonAttribNames.insert(pair<int, string>((int)eCommonAttribs::debug, "debug"));
+}
+
+/***************************************************************************
+* cFunction
+***************************************************************************/
+cFunction::cFunction(cArea *owner, int numAttributes) : cAttributes(numAttributes) {
+ funcType = "Unknown";
+ owningArea = owner;
+ color = NULL;
+ name = NULL;
+ scrolling = false;
+}
+
+cFunction::cFunction(const cFunction &other) : cAttributes(other) {
+ funcType = other.funcType;
+ owningArea = NULL;
+ color = NULL;
+ if (other.color)
+ color = new cColor(*other.color);
+ name = NULL;
+ if (other.name)
+ name = strdup(other.name);
+ scrolling = other.scrolling;
+}
+
+cFunction::~cFunction(void) {
+ delete color;
+ free(name);
+}
+
+void cFunction::SetLoopInfo(cLoopInfo *loopInfo) {
+ for (int i=0; i < numAttribs; i++) {
+ if (!attribCtors[i])
+ continue;
+ attribCtors[i]->SetLoopInfo(loopInfo);
+ }
+ if (cond)
+ cond->SetLoopInfo(loopInfo);
+}
+
+void cFunction::Cache(void) {
+ if (color) {
+ color->SetGlobals(globals);
+ color->Cache();
+ }
+ cAttributes::Cache();
+}
+
+void cFunction::CacheFuncReferences(void) {
+ for (int i=0; i < numAttribs; i++) {
+ if (!attribCtors[i])
+ continue;
+ vector<cFactor*> refFactors = attribCtors[i]->GetRefFactors();
+ for (vector<cFactor*>::iterator it = refFactors.begin(); it != refFactors.end(); it++) {
+ cFactor *f = *it;
+ if (!f->funcRefName)
+ continue;
+ cFunction *fRef = owningArea->GetFunction(f->funcRefName);
+ if (fRef) {
+ f->funcRef = fRef;
+ }
+ }
+ }
+}
+
+int cFunction::GetX(eAlign align, int x0, int colWidth) {
+ int containerWidth = colWidth > 0 ? colWidth : container.Width();
+ int x = x0 + X();
+ if (align == eAlign::right) {
+ x = x0 + containerWidth - FuncWidth();
+ } else if (align == eAlign::center) {
+ x = x0 + (containerWidth - FuncWidth()) / 2;
+ }
+ return x;
+}
+
+int cFunction::GetY(eAlign valign, int y0, int rowHeight) {
+ int containerHeight = rowHeight > 0 ? rowHeight : container.Height();
+ int y = y0 + Y();
+ if (valign == eAlign::bottom) {
+ y = y0 + containerHeight - FuncHeight();
+ } else if (valign == eAlign::center) {
+ y = y0 + (containerHeight - FuncHeight()) / 2;
+ }
+ return y;
+}
+
+void cFunction::Debug(void) {
+ esyslog("skindesigner: ---> Function %s", funcType);
+ cAttributes::Debug();
+ if (name) {
+ esyslog("skindesigner: name %s", name);
+ }
+ if (color) {
+ color->Debug();
+ }
+}
+
+/***************************************************************************
+* Protected Functions
+***************************************************************************/
+
+void cFunction::SetColor(const char *val) {
+ color = new cColor(val);
+}
+
+void cFunction::SetAnimType(int id, const char *val) {
+ eAnimType animType = eAnimType::none;
+ if (!strcmp(val, "blink"))
+ animType = eAnimType::blink;
+ else if (!strcmp(val, "animated"))
+ animType = eAnimType::animated;
+ attribs[id] = (int)animType;
+}
+
+void cFunction::SetOverflow(int id, const char *val) {
+ eOverflowType overflowType = eOverflowType::none;
+ if (!strcmp(val, "linewrap"))
+ overflowType = eOverflowType::wrap;
+ else if (!strcmp(val, "cut"))
+ overflowType = eOverflowType::cut;
+ attribs[id] = (int)overflowType;
+}
diff --git a/coreengine/attribute.h b/coreengine/attribute.h new file mode 100644 index 0000000..e9da37e --- /dev/null +++ b/coreengine/attribute.h @@ -0,0 +1,126 @@ +#ifndef __ATTRIBUTE_H
+#define __ATTRIBUTE_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+#include <map>
+#include <vector>
+#include <vdr/skins.h>
+#include "globals.h"
+#include "../libskindesignerapi/tokencontainer.h"
+#include "definitions.h"
+#include "complextypes.h"
+
+class cArea;
+/******************************************************************
+* cAttributes
+******************************************************************/
+class cAttributes {
+private:
+ map<string, int> commonAttribIDs;
+ map<int, string> commonAttribNames;
+ void SetCommonAttributesDefs(void);
+protected:
+ cGlobals *globals;
+ skindesignerapi::cTokenContainer *tokenContainer;
+ cRect container;
+ int numAttribs;
+ int *attribs;
+ cNumericExpr **attribCtors;
+ cCondition *cond;
+ map<string, int> attribIDs;
+ map<int, string> attribNames;
+ int CommonAttributeId(const char *att);
+ const char *CommonAttributeName(int id);
+ int AttributeId(const char *att);
+ const char *AttributeName(int id);
+ bool SetCommon(int id, const char *val);
+ virtual bool IdEqual(int id, int compId);
+ void SetBool(int id, const char *val);
+ void SetViewElementMode(int id, const char *val);
+ void SetShiftType(int id, const char *val);
+ void SetShiftMode(int id, const char *val);
+ void SetScrollMode(int id, const char *val);
+ void SetScrollSpeed(int id, const char *val);
+ void SetOrientation(int id, const char *val);
+ void SetDirection(int id, const char *val);
+ void SetAlign(int id, const char *val);
+public:
+ cAttributes(int numAttributes);
+ cAttributes(const cAttributes &other);
+ virtual ~cAttributes(void);
+ void SetGlobals(cGlobals *globals) { this->globals = globals; };
+ void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer);
+ virtual void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
+ virtual void SetContainer(int x, int y, int width, int height);
+ virtual void Set(vector<stringpair> &attributes) {};
+ void SetX(int width);
+ void SetY(int height);
+ void SetWidth(int width);
+ void SetHeight(int height);
+ virtual void Cache(void);
+ int GetValue(int id);
+ int X(void);
+ int Y(void);
+ int Width(void);
+ int Height(void);
+ int DoDebug(void) { return attribs[(int)eCommonAttribs::debug] == 1 ? true : false; };
+ bool DoExecute(void);
+ virtual void Debug(void);
+};
+/******************************************************************
+* cLoopInfo
+******************************************************************/
+class cLoopInfo {
+public:
+ int colWidth;
+ int rowHeight;
+ int index;
+ int row;
+ cLoopInfo(void) {
+ colWidth = 0;
+ rowHeight = 0;
+ index = 0;
+ row = 0;
+ };
+};
+/******************************************************************
+* cFunction
+******************************************************************/
+class cFunction : public cAttributes, public cListObject {
+private:
+ cArea *owningArea;
+protected:
+ const char *funcType;
+ cColor *color;
+ char *name;
+ bool scrolling;
+ void SetColor(const char *val);
+ void SetAnimType(int id, const char *val);
+ void SetOverflow(int id, const char *val);
+public:
+ cFunction(cArea *owner, int numAttributes);
+ cFunction(const cFunction &other);
+ virtual ~cFunction(void);
+ virtual void SetLoopInfo(cLoopInfo *loopInfo);
+ void SetOwner(cArea *owner) { owningArea = owner; };
+ const char *Name(void) { return name; };
+ virtual void Cache(void);
+ void CacheFuncReferences(void);
+ void Scrolling(bool scrolling) { this->scrolling = scrolling; };
+ virtual void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0) {};
+ virtual int FuncX(void) { return X(); };
+ virtual int FuncY(void) { return Y(); };
+ virtual int FuncWidth(void) { return Width(); };
+ virtual int FuncHeight(void) { return Height(); };
+ virtual int Align(void) { return (int)eAlign::left; };
+ virtual int Valign(void) { return (int)eAlign::top; };
+ int GetX(eAlign align, int x0, int colWidth);
+ int GetY(eAlign valign, int y0, int rowHeight);
+ virtual bool Blinking(void) { return false; };
+ virtual int BlinkFreq(void) { return -1; };
+ virtual void Debug(void);
+};
+
+#endif //__ATTRIBUTE_H
\ No newline at end of file diff --git a/coreengine/attributes.c b/coreengine/attributes.c new file mode 100644 index 0000000..97387d4 --- /dev/null +++ b/coreengine/attributes.c @@ -0,0 +1,447 @@ +#include "attributes.h"
+#include "../config.h"
+
+/***************************************************************************
+* cViewAttribs
+***************************************************************************/
+cViewAttribs::cViewAttribs(int numAttributes) : cAttributes(numAttributes) {
+ orientation = NULL;
+ SetAttributesDefs();
+}
+
+cViewAttribs::~cViewAttribs(void) {
+ delete orientation;
+}
+
+void cViewAttribs::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown view attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eViewAttribs::shifttype)) {
+ SetShiftType(id, attVal);
+ } else if (IdEqual(id, (int)eViewAttribs::shiftmode)) {
+ SetShiftMode(id, attVal);
+ } else if (IdEqual(id, (int)eViewAttribs::orientation)) {
+ SetOrientationDynamic(id, attVal);
+ } else if (IdEqual(id, (int)eViewAttribs::hideroot)) {
+ SetBool(id, attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ if ( (id == (int)eViewAttribs::starty + (int)eCommonAttribs::count) ||
+ (id == (int)eViewAttribs::scaletvy + (int)eCommonAttribs::count) ||
+ (id == (int)eViewAttribs::scaletvheight + (int)eCommonAttribs::count) ) {
+ attribCtors[id]->SetVertical();
+ }
+ }
+ }
+}
+
+void cViewAttribs::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("fadetime", (int)eViewAttribs::fadetime));
+ attribIDs.insert(pair<string, int>("shifttime", (int)eViewAttribs::shifttime));
+ attribIDs.insert(pair<string, int>("shifttype", (int)eViewAttribs::shifttype));
+ attribIDs.insert(pair<string, int>("shiftmode", (int)eViewAttribs::shiftmode));
+ attribIDs.insert(pair<string, int>("startx", (int)eViewAttribs::startx));
+ attribIDs.insert(pair<string, int>("starty", (int)eViewAttribs::starty));
+ attribIDs.insert(pair<string, int>("scaletvx", (int)eViewAttribs::scaletvx));
+ attribIDs.insert(pair<string, int>("scaletvy", (int)eViewAttribs::scaletvy));
+ attribIDs.insert(pair<string, int>("scaletvwidth", (int)eViewAttribs::scaletvwidth));
+ attribIDs.insert(pair<string, int>("scaletvheight", (int)eViewAttribs::scaletvheight));
+ attribIDs.insert(pair<string, int>("orientation", (int)eViewAttribs::orientation));
+ attribIDs.insert(pair<string, int>("debuggrid", (int)eViewAttribs::debuggrid));
+ attribIDs.insert(pair<string, int>("hideroot", (int)eViewAttribs::hideroot));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::fadetime, "fadetime"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::shifttime, "shifttime"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::shifttype, "shifttype"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::shiftmode, "shiftmode"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::startx, "startx"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::starty, "starty"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvx, "scaletvx"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvy, "scaletvy"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvwidth, "scaletvwidth"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::scaletvheight, "scaletvheight"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::orientation, "orientation"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::debuggrid, "debuggrid"));
+ attribNames.insert(pair<int, string>((int)eViewAttribs::hideroot, "hideroot"));
+}
+
+void cViewAttribs::Cache(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ cAttributes::Cache();
+ if (orientation) {
+ orientation->SetGlobals(globals);
+ orientation->SetTokenContainer(tokenContainer);
+ orientation->Cache();
+ char *res = orientation->DeterminateText();
+ if (res) {
+ SetOrientation((int)eViewAttribs::orientation + (int)eCommonAttribs::count, res);
+ }
+ free(res);
+ }
+}
+
+void cViewAttribs::Debug(void) {
+ esyslog("skindesigner: --> View Attribs");
+ cAttributes::Debug();
+}
+
+eOrientation cViewAttribs::Orientation(void) {
+ int orientation = GetValue((int)eViewAttribs::orientation);
+ if (orientation == -1)
+ return eOrientation::vertical;
+ if (orientation == (int)eOrientation::none)
+ return eOrientation::vertical;
+ return (eOrientation)orientation;
+}
+
+cRect cViewAttribs::TvFrame(void) {
+ int frameX = GetValue((int)eViewAttribs::scaletvx);
+ int frameY = GetValue((int)eViewAttribs::scaletvy);
+ int frameWidth = GetValue((int)eViewAttribs::scaletvwidth);
+ int frameHeight = GetValue((int)eViewAttribs::scaletvheight);
+ if (frameX < 0 || frameY < 0 || frameWidth <= 0 || frameHeight <= 0)
+ return cRect::Null;
+ frameX += cOsd::OsdLeft();
+ frameY += cOsd::OsdTop();
+ return cRect(frameX, frameY, frameWidth, frameHeight);
+}
+
+void cViewAttribs::SetOrientationDynamic(int id, const char *val) {
+ if (strchr(val, '{') && strchr(val, '}')) {
+ orientation = new cTextExpr(val);
+ } else {
+ SetOrientation(id, val);
+ }
+}
+
+/***************************************************************************
+* cViewElementAttribs
+***************************************************************************/
+cViewElementAttribs::cViewElementAttribs(int numAttributes) : cAttributes(numAttributes) {
+ name = NULL;
+ SetAttributesDefs();
+}
+
+cViewElementAttribs::cViewElementAttribs(const cViewElementAttribs &other) : cAttributes(other) {
+ name = NULL;
+}
+
+cViewElementAttribs::~cViewElementAttribs(void) {
+ free(name);
+}
+
+void cViewElementAttribs::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown view element attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eViewElementAttribs::mode)) {
+ SetViewElementMode(id, attVal);
+ } else if (IdEqual(id, (int)eViewElementAttribs::shifttype)) {
+ SetShiftType(id, attVal);
+ } else if (IdEqual(id, (int)eViewElementAttribs::shiftmode)) {
+ SetShiftMode(id, attVal);
+ } else if (IdEqual(id, (int)eViewElementAttribs::orientation)) {
+ SetOrientation(id, attVal);
+ } else if (IdEqual(id, (int)eViewElementAttribs::name)) {
+ name = strdup(attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ if (id == (int)eViewElementAttribs::starty + (int)eCommonAttribs::count) {
+ attribCtors[id]->SetVertical();
+ }
+ }
+ }
+}
+
+void cViewElementAttribs::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("delay", (int)eViewElementAttribs::delay));
+ attribIDs.insert(pair<string, int>("fadetime", (int)eViewElementAttribs::fadetime));
+ attribIDs.insert(pair<string, int>("shifttime", (int)eViewElementAttribs::shifttime));
+ attribIDs.insert(pair<string, int>("shifttype", (int)eViewElementAttribs::shifttype));
+ attribIDs.insert(pair<string, int>("shiftmode", (int)eViewElementAttribs::shiftmode));
+ attribIDs.insert(pair<string, int>("startx", (int)eViewElementAttribs::startx));
+ attribIDs.insert(pair<string, int>("starty", (int)eViewElementAttribs::starty));
+ attribIDs.insert(pair<string, int>("orientation", (int)eViewElementAttribs::orientation));
+ attribIDs.insert(pair<string, int>("mode", (int)eViewElementAttribs::mode));
+ attribIDs.insert(pair<string, int>("name", (int)eViewElementAttribs::name));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::delay, "delay"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::fadetime, "fadetime"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::shifttime, "shifttime"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::shifttype, "shifttype"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::shiftmode, "shiftmode"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::startx, "startx"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::starty, "starty"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::orientation, "orientation"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::mode, "mode"));
+ attribNames.insert(pair<int, string>((int)eViewElementAttribs::name, "name"));
+}
+
+eOrientation cViewElementAttribs::Orientation(void) {
+ int orientation = GetValue((int)eViewElementAttribs::orientation);
+ if (orientation == -1)
+ return eOrientation::vertical;
+ if (orientation == (int)eOrientation::none)
+ return eOrientation::vertical;
+ return (eOrientation)orientation;
+}
+
+void cViewElementAttribs::Debug(void) {
+ esyslog("skindesigner: ---> View Element Attribs");
+ cAttributes::Debug();
+}
+
+/***************************************************************************
+* cViewListAttribs
+***************************************************************************/
+cViewListAttribs::cViewListAttribs(int numAttributes) : cAttributes(numAttributes) {
+ determinateFont = NULL;
+ SetAttributesDefs();
+}
+
+cViewListAttribs::~cViewListAttribs(void) {
+ free(determinateFont);
+}
+
+void cViewListAttribs::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown view list attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eViewListAttribs::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eViewListAttribs::determinatefont)) {
+ determinateFont = strdup(attVal);
+ } else if (IdEqual(id, (int)eViewListAttribs::orientation)) {
+ SetOrientation(id, attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+int cViewListAttribs::NumListElements(void) {
+ return GetValue((int)eViewListAttribs::numlistelements);
+}
+
+int cViewListAttribs::MenuItemWidth(void) {
+ return GetValue((int)eViewListAttribs::menuitemwidth);
+}
+
+const char *cViewListAttribs::DeterminateFont(void) {
+ return determinateFont;
+}
+
+eAlign cViewListAttribs::Align(void) {
+ int align = GetValue((int)eViewListAttribs::align);
+ if (align < 0)
+ return eAlign::top;
+ return (eAlign)align;
+}
+
+eOrientation cViewListAttribs::Orientation(void) {
+ int orientation = GetValue((int)eViewListAttribs::orientation);
+ if (orientation < 0)
+ return eOrientation::vertical;
+ return (eOrientation)orientation;
+}
+
+void cViewListAttribs::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eViewListAttribs::align));
+ attribIDs.insert(pair<string, int>("menuitemwidth", (int)eViewListAttribs::menuitemwidth));
+ attribIDs.insert(pair<string, int>("determinatefont", (int)eViewListAttribs::determinatefont));
+ attribIDs.insert(pair<string, int>("numlistelements", (int)eViewListAttribs::numlistelements));
+ attribIDs.insert(pair<string, int>("orientation", (int)eViewListAttribs::orientation));
+ attribIDs.insert(pair<string, int>("condition", (int)eViewListAttribs::condition));
+ attribNames.insert(pair<int, string>((int)eViewListAttribs::align, "align"));
+ attribNames.insert(pair<int, string>((int)eViewListAttribs::menuitemwidth, "menuitemwidth"));
+ attribNames.insert(pair<int, string>((int)eViewListAttribs::determinatefont, "determinatefont"));
+ attribNames.insert(pair<int, string>((int)eViewListAttribs::numlistelements, "numlistelements"));
+ attribNames.insert(pair<int, string>((int)eViewListAttribs::orientation, "orientation"));
+ attribNames.insert(pair<int, string>((int)eViewListAttribs::condition, "condition"));
+}
+
+void cViewListAttribs::Debug(void) {
+ esyslog("skindesigner: ---> View List Attribs");
+ esyslog("skindesigner: DeterminateFont %s", determinateFont);
+ cAttributes::Debug();
+}
+
+/***************************************************************************
+* cAreaAttribs
+***************************************************************************/
+cAreaAttribs::cAreaAttribs(int numAttributes) : cAttributes(numAttributes) {
+ name = NULL;
+ scrollElement = NULL;
+ dynamic = false;
+ SetAttributesDefs();
+}
+
+cAreaAttribs::cAreaAttribs(const cAreaAttribs &other) : cAttributes(other) {
+ name = NULL;
+ if (other.name)
+ name = new cTextExpr(*other.name);
+ scrollElement = NULL;
+ if (other.scrollElement)
+ scrollElement = strdup(other.scrollElement);
+ dynamic = false;
+}
+
+cAreaAttribs::~cAreaAttribs(void) {
+ delete name;
+ free(scrollElement);
+}
+
+void cAreaAttribs::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown area attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eAreaAttribs::scrollelement)) {
+ scrollElement = strdup(attVal);
+ } else if (IdEqual(id, (int)eAreaAttribs::mode)) {
+ SetScrollMode(id, attVal);
+ } else if (IdEqual(id, (int)eAreaAttribs::orientation)) {
+ SetOrientation(id, attVal);
+ } else if (IdEqual(id, (int)eAreaAttribs::scrollspeed)) {
+ SetScrollSpeed(id, attVal);
+ } else if (IdEqual(id, (int)eAreaAttribs::background)) {
+ SetBool(id, attVal);
+ } else if (IdEqual(id, (int)eAreaAttribs::name)) {
+ name = new cTextExpr(attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+int cAreaAttribs::Layer(void) {
+ if (GetValue((int)eAreaAttribs::layer) > 0) {
+ return GetValue((int)eAreaAttribs::layer);
+ }
+ return 1;
+}
+
+bool cAreaAttribs::BackgroundArea(void) {
+ int isBackground = GetValue((int)eAreaAttribs::background);
+ if (isBackground == 1)
+ return true;
+ return false;
+}
+
+void cAreaAttribs::CheckDynamic(void) {
+ for (int i = (int)eCommonAttribs::x; i <= (int)eCommonAttribs::height; ++i ) {
+ if (attribCtors[i] && attribCtors[i]->Dynamic()) {
+ dynamic = true;
+ return;
+ }
+ }
+}
+
+const char *cAreaAttribs::Name(void) {
+ if (name)
+ return name->DeterminateText();
+ return NULL;
+}
+
+void cAreaAttribs::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("layer", (int)eAreaAttribs::layer));
+ attribIDs.insert(pair<string, int>("transparency", (int)eAreaAttribs::transparency));
+ attribIDs.insert(pair<string, int>("mode", (int)eAreaAttribs::mode));
+ attribIDs.insert(pair<string, int>("orientation", (int)eAreaAttribs::orientation));
+ attribIDs.insert(pair<string, int>("scrollelement", (int)eAreaAttribs::scrollelement));
+ attribIDs.insert(pair<string, int>("scrollspeed", (int)eAreaAttribs::scrollspeed));
+ attribIDs.insert(pair<string, int>("delay", (int)eAreaAttribs::delay));
+ attribIDs.insert(pair<string, int>("background", (int)eAreaAttribs::background));
+ attribIDs.insert(pair<string, int>("name", (int)eAreaAttribs::name));
+ attribIDs.insert(pair<string, int>("scrollheight", (int)eAreaAttribs::scrollheight));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::layer, "layer"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::transparency, "transparency"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::mode, "mode"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::orientation, "orientation"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::scrollelement, "scrollelement"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::scrollspeed, "scrollspeed"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::delay, "delay"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::background, "background"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eAreaAttribs::scrollheight, "scrollheight"));
+}
+
+void cAreaAttribs::Cache(void) {
+ cAttributes::Cache();
+ if (name) {
+ name->SetGlobals(globals);
+ name->SetTokenContainer(tokenContainer);
+ name->Cache();
+ }
+}
+
+void cAreaAttribs::Debug(void) {
+ if (!name) {
+ esyslog("skindesigner: ---> Area Attribs");
+ } else {
+ esyslog("skindesigner: ---> Tab %s Attribs", name->DeterminateText());
+ }
+ cAttributes::Debug();
+}
+
+/***************************************************************************
+* cAreaContainerAttribs
+***************************************************************************/
+cAreaContainerAttribs::cAreaContainerAttribs(int numAttributes) : cAttributes(numAttributes) {
+ SetAttributesDefs();
+}
+
+cAreaContainerAttribs::cAreaContainerAttribs(const cAreaContainerAttribs &other) : cAttributes(other) {
+}
+
+cAreaContainerAttribs::~cAreaContainerAttribs(void) {
+}
+
+void cAreaContainerAttribs::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown area container attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ }
+}
+
+void cAreaContainerAttribs::SetAttributesDefs(void) {
+}
+
+void cAreaContainerAttribs::Debug(void) {
+ esyslog("skindesigner: ---> Area Container Attribs");
+ cAttributes::Debug();
+}
+
diff --git a/coreengine/attributes.h b/coreengine/attributes.h new file mode 100644 index 0000000..5280db7 --- /dev/null +++ b/coreengine/attributes.h @@ -0,0 +1,111 @@ +#ifndef __ATTRIBUTES_H
+#define __ATTRIBUTES_H
+
+#include "attribute.h"
+/******************************************************************
+* cViewAttribs
+******************************************************************/
+class cViewAttribs : public cAttributes {
+private:
+ cTextExpr *orientation;
+ void SetAttributesDefs(void);
+ void SetOrientationDynamic(int id, const char *val);
+public:
+ cViewAttribs(int numAttributes);
+ virtual ~cViewAttribs(void);
+ void Set(vector<stringpair> &attributes);
+ eOrientation Orientation(void);
+ int FadeTime(void) { return GetValue((int)eViewAttribs::fadetime); };
+ int ShiftTime(void) { return GetValue((int)eViewAttribs::shifttime); };
+ cPoint ShiftStartpoint(void) { return cPoint(GetValue((int)eViewAttribs::startx), GetValue((int)eViewAttribs::starty)); };
+ int ShiftType(void) { return GetValue((int)eViewAttribs::shifttype); };
+ int ShiftMode(void) { return GetValue((int)eViewAttribs::shiftmode); };
+ cRect TvFrame(void);
+ void Cache(void);
+ void Debug(void);
+};
+/******************************************************************
+* cViewElementAttribs
+******************************************************************/
+class cViewElementAttribs : public cAttributes {
+private:
+ char *name;
+ void SetAttributesDefs(void);
+public:
+ cViewElementAttribs(int numAttributes);
+ cViewElementAttribs(const cViewElementAttribs &other);
+ virtual ~cViewElementAttribs(void);
+ void Set(vector<stringpair> &attributes);
+ int Mode(void) { return GetValue((int)eViewElementAttribs::mode); };
+ int Delay(void) { return GetValue((int)eViewElementAttribs::delay); };
+ eOrientation Orientation(void);
+ int FadeTime(void) { return GetValue((int)eViewElementAttribs::fadetime); };
+ int ShiftTime(void) { return GetValue((int)eViewElementAttribs::shifttime); };
+ cPoint ShiftStartpoint(void) { return cPoint(GetValue((int)eViewElementAttribs::startx), GetValue((int)eViewElementAttribs::starty)); };
+ int ShiftType(void) { return GetValue((int)eViewElementAttribs::shifttype); };
+ int ShiftMode(void) { return GetValue((int)eViewElementAttribs::shiftmode); };
+ const char *Name(void) { return name; };
+ void Debug(void);
+};
+/******************************************************************
+* cViewListAttribs
+******************************************************************/
+class cViewListAttribs : public cAttributes {
+private:
+ char *determinateFont;
+ void SetAttributesDefs(void);
+public:
+ cViewListAttribs(int numAttributes);
+ virtual ~cViewListAttribs(void);
+ void Set(vector<stringpair> &attributes);
+ int NumListElements(void);
+ int MenuItemWidth(void);
+ const char *DeterminateFont(void);
+ eAlign Align(void);
+ eOrientation Orientation(void);
+ void Debug(void);
+};
+/******************************************************************
+* cAreaAttribs
+******************************************************************/
+class cAreaAttribs : public cAttributes {
+private:
+ cTextExpr *name;
+ char *scrollElement;
+ void SetAttributesDefs(void);
+ bool dynamic;
+public:
+ cAreaAttribs(int numAttributes);
+ cAreaAttribs(const cAreaAttribs &other);
+ virtual ~cAreaAttribs(void);
+ void Set(vector<stringpair> &attributes);
+ const char *GetScrollElement(void) { return scrollElement; };
+ int Orientation(void) { return GetValue((int)eAreaAttribs::orientation); };
+ int Delay(void) { return GetValue((int)eAreaAttribs::delay); };
+ int Mode(void) { return GetValue((int)eAreaAttribs::mode); };
+ int ScrollSpeed(void) { return GetValue((int)eAreaAttribs::scrollspeed); };
+ int Transparency(void) { return GetValue((int)eAreaAttribs::transparency); };
+ int Layer(void);
+ int ScrollStep(void) { return GetValue((int)eAreaAttribs::scrollheight); };
+ bool BackgroundArea(void);
+ const char *Name(void);
+ void CheckDynamic(void);
+ bool Dynamic(void) {return dynamic; };
+ void Cache(void);
+ void Debug(void);
+};
+/******************************************************************
+* cAreaContainerAttribs
+******************************************************************/
+class cAreaContainerAttribs : public cAttributes {
+private:
+ void SetAttributesDefs(void);
+public:
+ cAreaContainerAttribs(int numAttributes);
+ cAreaContainerAttribs(const cAreaContainerAttribs &other);
+ virtual ~cAreaContainerAttribs(void);
+ void Set(vector<stringpair> &attributes);
+ void Debug(void);
+};
+
+#endif //__ATTRIBUTES_H
\ No newline at end of file diff --git a/coreengine/complextypes.c b/coreengine/complextypes.c new file mode 100644 index 0000000..ea15bf4 --- /dev/null +++ b/coreengine/complextypes.c @@ -0,0 +1,1605 @@ +#include "complextypes.h"
+#include "../config.h"
+
+/******************************************************************
+* helpers
+******************************************************************/
+char *RemoveSpace(char *e) {
+ if (!e)
+ return e;
+ int numSpaces = 0;
+ int exprLen = strlen(e);
+ for (int i = 0; i < exprLen; ++i) {
+ if (isspace(e[i]))
+ ++numSpaces;
+ }
+ if (numSpaces == 0)
+ return e;
+
+ char *replaced = (char*)malloc(exprLen - numSpaces + 1);
+ replaced[exprLen - numSpaces] = '\0';
+ int j = 0;
+ for (int i = 0; i < exprLen; ++i) {
+ if (!isspace(e[i])){
+ replaced[j++] = e[i];
+ }
+ }
+ free(e);
+ return replaced;
+}
+
+void ReplaceDecimalpoint(char *e) {
+ int size = (int)strlen(e);
+ for ( int i = 0; i < size; ++i ) {
+ if (e[i] == '.')
+ e[i] = config.decPoint;
+ }
+}
+
+void ReplaceStart(char *e, int num) {
+ int size = (int)strlen(e);
+ if (size <= num)
+ return;
+ for ( int i = 0; i < size; ++i ) {
+ if (i < size - num)
+ e[i] = e[i+num];
+ else e[i] = 0;
+ }
+}
+
+void ReplaceEnd(char *e, int num) {
+ int size = (int)strlen(e) - 1;
+ if (size <= num)
+ return;
+ for ( int i = size; i > size-num; --i ) {
+ e[i] = 0;
+ }
+}
+/******************************************************************
+* cCond
+******************************************************************/
+cCond::cCond(const char *expression) {
+ this->expr = strdup(expression);
+ operation = eCondOp::tAnd;
+ type = eCondType::token;
+ constant = false;
+ isTrue = false;
+ tokenIndex = -1;
+ compareValue = -1;
+ compareStrValue = NULL;
+}
+
+cCond::cCond(const cCond &other) {
+ expr = strdup(other.expr);
+ operation = other.operation;
+ type = other.type;
+ constant = other.constant;
+ tokenType = other.tokenType;
+ isTrue = other.isTrue;
+ tokenIndex = other.tokenIndex;
+ compareValue = other.compareValue;
+ compareStrValue = NULL;
+ if (other.compareStrValue)
+ compareStrValue = strdup(other.compareStrValue);
+}
+
+cCond::~cCond(void) {
+ free(expr);
+ free(compareStrValue);
+}
+
+void cCond::Debug(void) {
+ esyslog("skindesigner: cond %s, operation %s, type %d", expr,
+ (operation == eCondOp::tAnd) ? "++" : "||",
+ (int)type);
+ if (constant)
+ esyslog("skindesigner: constant cond: %s", isTrue ? "TRUE" : "FALSE");
+ if (tokenIndex >= 0)
+ esyslog("skindesigner: token index: %d", tokenIndex);
+ if (compareValue >= 0)
+ esyslog("skindesigner: compare value: %d", compareValue);
+ if (compareStrValue)
+ esyslog("skindesigner: compare string value: %d", compareStrValue);
+}
+
+/******************************************************************
+* cCondition
+******************************************************************/
+cCondition::cCondition(const char *expression) {
+ expr = strdup(expression);
+ globals = NULL;
+ tokenContainer = NULL;
+ loopInfo = NULL;
+}
+
+cCondition::cCondition(const cCondition &other) {
+ expr = strdup(other.expr);
+ globals = NULL;
+ tokenContainer = NULL;
+ loopInfo = NULL;
+ for (cCond *cond = other.conds.First(); cond; cond = other.conds.Next(cond))
+ conds.Add(new cCond(*cond));
+}
+
+cCondition::~cCondition(void) {
+ free(expr);
+}
+
+void cCondition::Prepare(void) {
+ expr = RemoveSpace(expr);
+ Tokenize();
+ PrepareTokens();
+}
+
+bool cCondition::True(void) {
+ if (conds.Count() == 0)
+ return true;
+ bool ok = true;
+ for (cCond *c = conds.First(); c; c = conds.Next(c)) {
+ bool condTrue = true;
+ //evaluate condition
+ if (c->constant)
+ {
+ condTrue = c->isTrue;
+ }
+ else if (c->type == eCondType::token)
+ {
+ if (c->tokenType == eCondTokenType::inttoken) {
+ int tokenVal = tokenContainer->IntToken(c->tokenIndex);
+ condTrue = (tokenVal > 0) ? true : false;
+ } else if (c->tokenType == eCondTokenType::stringtoken) {
+ char *tokenVal = tokenContainer->StringToken(c->tokenIndex);
+ if (tokenVal)
+ condTrue = (!strcmp(tokenVal, "1")) ? true : false;
+ } else if (c->tokenType == eCondTokenType::looptoken) {
+ if (loopInfo && loopInfo->row >= 0) {
+ char *tokenVal = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, c->tokenIndex);
+ if (tokenVal)
+ condTrue = (!strcmp(tokenVal, "1")) ? true : false;
+ }
+ }
+
+ }
+ else if (c->type == eCondType::negtoken)
+ {
+ if (c->tokenType == eCondTokenType::inttoken) {
+ int tokenVal = tokenContainer->IntToken(c->tokenIndex);
+ condTrue = (tokenVal > 0) ? false : true;
+ } else if (c->tokenType == eCondTokenType::stringtoken) {
+ char *tokenVal = tokenContainer->StringToken(c->tokenIndex);
+ if (tokenVal)
+ condTrue = (!strcmp(tokenVal, "1")) ? false : true;
+ } else if (c->tokenType == eCondTokenType::looptoken) {
+ if (loopInfo && loopInfo->row >= 0) {
+ char *tokenVal = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, c->tokenIndex);
+ if (tokenVal)
+ condTrue = (!strcmp(tokenVal, "1")) ? false : true;
+ }
+ }
+ }
+ else if (c->type == eCondType::lowerInt || c->type == eCondType::equalInt || c->type == eCondType::greaterInt)
+ {
+ if (c->tokenType == eCondTokenType::inttoken) {
+ int tokenVal = tokenContainer->IntToken(c->tokenIndex);
+ if (c->type == eCondType::lowerInt)
+ condTrue = (tokenVal < c->compareValue) ? true : false;
+ else if (c->type == eCondType::equalInt)
+ condTrue = (tokenVal == c->compareValue) ? true : false;
+ else if (c->type == eCondType::greaterInt)
+ condTrue = (tokenVal > c->compareValue) ? true : false;
+ } else if (c->tokenType == eCondTokenType::stringtoken) {
+ char *tokenVal = tokenContainer->StringToken(c->tokenIndex);
+ if (tokenVal) {
+ int intVal = atoi(tokenVal);
+ if (c->type == eCondType::lowerInt)
+ condTrue = (intVal < c->compareValue) ? true : false;
+ else if (c->type == eCondType::equalInt)
+ condTrue = (intVal == c->compareValue) ? true : false;
+ else if (c->type == eCondType::greaterInt)
+ condTrue = (intVal > c->compareValue) ? true : false;
+ }
+ } else if (c->tokenType == eCondTokenType::looptoken) {
+ if (loopInfo && loopInfo->row >= 0) {
+ char *tokenVal = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, c->tokenIndex);
+ if (tokenVal) {
+ int intVal = atoi(tokenVal);
+ if (c->type == eCondType::lowerInt)
+ condTrue = (intVal < c->compareValue) ? true : false;
+ else if (c->type == eCondType::equalInt)
+ condTrue = (intVal == c->compareValue) ? true : false;
+ else if (c->type == eCondType::greaterInt)
+ condTrue = (intVal > c->compareValue) ? true : false;
+ }
+ }
+ }
+ }
+ else if (c->type == eCondType::isset || c->type == eCondType::empty)
+ {
+ if (c->tokenType == eCondTokenType::stringtoken) {
+ char *tokenVal = tokenContainer->StringToken(c->tokenIndex);
+ if (tokenVal) {
+ if (c->type == eCondType::isset)
+ condTrue = strlen(tokenVal) > 0 ? true : false;
+ else if (c->type == eCondType::empty)
+ condTrue = strlen(tokenVal) == 0 ? true : false;
+ } else {
+ if (c->type == eCondType::isset)
+ condTrue = false;
+ else if (c->type == eCondType::empty)
+ condTrue = true;
+ }
+ } else if (c->tokenType == eCondTokenType::looptoken) {
+ if (loopInfo && loopInfo->row >= 0) {
+ char *tokenVal = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, c->tokenIndex);
+ if (tokenVal) {
+ if (c->type == eCondType::isset)
+ condTrue = strlen(tokenVal) > 0 ? true : false;
+ else if (c->type == eCondType::empty)
+ condTrue = strlen(tokenVal) == 0 ? true : false;
+ } else {
+ if (c->type == eCondType::isset)
+ condTrue = false;
+ else if (c->type == eCondType::empty)
+ condTrue = true;
+ }
+ }
+ }
+ }
+ else if (c->type == eCondType::equalString || c->type == eCondType::notEqualString || c->type == eCondType::contains || c->type == eCondType::notContains)
+ {
+ if (c->tokenType == eCondTokenType::stringtoken) {
+ char *tokenVal = tokenContainer->StringToken(c->tokenIndex);
+ if (tokenVal) {
+ if (c->type == eCondType::equalString)
+ condTrue = !strcmp(tokenVal, c->compareStrValue) ? true : false;
+ else if (c->type == eCondType::notEqualString)
+ condTrue = strcmp(tokenVal, c->compareStrValue) ? true : false;
+ else if (c->type == eCondType::contains)
+ condTrue = strstr(tokenVal, c->compareStrValue) ? true : false;
+ else if (c->type == eCondType::notContains)
+ condTrue = !strstr(tokenVal, c->compareStrValue) ? true : false;
+ }
+ } else if (c->tokenType == eCondTokenType::looptoken) {
+ if (loopInfo && loopInfo->row >= 0) {
+ char *tokenVal = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, c->tokenIndex);
+ if (tokenVal) {
+ if (c->type == eCondType::equalString)
+ condTrue = !strcmp(tokenVal, c->compareStrValue) ? true : false;
+ else if (c->type == eCondType::notEqualString)
+ condTrue = strcmp(tokenVal, c->compareStrValue) ? true : false;
+ else if (c->type == eCondType::contains)
+ condTrue = strstr(tokenVal, c->compareStrValue) ? true : false;
+ else if (c->type == eCondType::notContains)
+ condTrue = !strstr(tokenVal, c->compareStrValue) ? true : false;
+ }
+ }
+ }
+ } //link
+ if (c->operation == eCondOp::tAnd) {
+ ok = ok && condTrue;
+ } else if (c->operation == eCondOp::tOr) {
+ ok = ok || condTrue;
+ }
+ }
+ return ok;
+}
+
+void cCondition::Debug(void) {
+ esyslog("skindesigner: condition \"%s\"", expr);
+ for (cCond *c = conds.First(); c; c = conds.Next(c)) {
+ c->Debug();
+ }
+ esyslog("skindesigner: condition is %s", True() ? "TRUE" : "FALSE");
+}
+
+void cCondition::Tokenize(void) {
+ char *condition = strdup(expr);
+ char delimiter[] = "+|";
+ eCondOp operation = eCondOp::tAnd;
+
+ char *cond = strtok(condition, delimiter);
+ while (cond) {
+ eCondType type = eCondType::token;
+ if (startswith(cond, "{") && endswith(cond, "}")) {
+ type = eCondType::token;
+ } else if (startswith(cond, "not{") && endswith(cond, "}")) {
+ type = eCondType::negtoken;
+ } else if (startswith(cond, "lt({") && endswith(cond, ")")) {
+ type = eCondType::lowerInt;
+ } else if (startswith(cond, "eq({") && endswith(cond, ")")) {
+ type = eCondType::equalInt;
+ } else if (startswith(cond, "gt({") && endswith(cond, ")")) {
+ type = eCondType::greaterInt;
+ } else if (startswith(cond, "isset{") && endswith(cond, "}")) {
+ type = eCondType::isset;
+ } else if (startswith(cond, "empty{") && endswith(cond, "}")) {
+ type = eCondType::empty;
+ } else if (startswith(cond, "strequal({") && endswith(cond, ")")) {
+ type = eCondType::equalString;
+ } else if (startswith(cond, "strnotequal({") && endswith(cond, ")")) {
+ type = eCondType::notEqualString;
+ } else if (startswith(cond, "strcontains({") && endswith(cond, ")")) {
+ type = eCondType::contains;
+ } else if (startswith(cond, "strnotcontains({") && endswith(cond, ")")) {
+ type = eCondType::notContains;
+ } else {
+ esyslog("skindesigner: invalid condition term %s", cond);
+ cond = strtok(NULL, delimiter);
+ continue;
+ }
+ cCond *c = new cCond(cond);
+ c->operation = operation;
+ c->type = type;
+ conds.Add(c);
+ if (expr[cond - condition + strlen(cond)] == '+')
+ operation = eCondOp::tAnd;
+ else
+ operation = eCondOp::tOr;
+ cond = strtok(NULL, delimiter);
+ }
+ free(condition);
+}
+
+void cCondition::PrepareTokens(void) {
+ for (cCond *c = conds.First(); c; c = conds.Next(c)) {
+ switch (c->type) {
+ case eCondType::token:
+ case eCondType::negtoken:
+ SetTokenCond(c);
+ break;
+ case eCondType::lowerInt:
+ case eCondType::equalInt:
+ case eCondType::greaterInt:
+ SetIntegerCond(c);
+ break;
+ case eCondType::isset:
+ case eCondType::empty:
+ SetStringCond(c);
+ break;
+ case eCondType::equalString:
+ case eCondType::notEqualString:
+ case eCondType::contains:
+ case eCondType::notContains:
+ SetStringCompareCond(c);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void cCondition::SetTokenCond(cCond *c) {
+ if (c->type == eCondType::negtoken) {
+ ReplaceStart(c->expr, 3);
+ }
+ //check globals
+ int result = 0;
+ string tmp = c->expr;
+ tmp = tmp.substr(1, tmp.size()-2);
+ if (globals->GetInt(tmp, result)) {
+ c->constant = true;
+ if (result == 1 && c->type == eCondType::token)
+ c->isTrue = true;
+ if (result == 0 && c->type == eCondType::negtoken)
+ c->isTrue = true;
+ return;
+ }
+ SetTokenIndex(c, c->expr);
+}
+
+void cCondition::SetIntegerCond(cCond *c) {
+ char *tokenStart = strchr(c->expr, '{');
+ char *tokenEnd = strchr(c->expr, '}');
+ if (!tokenStart || !tokenEnd)
+ return;
+ char token[200] = "";
+ strncpy(token, tokenStart, tokenEnd - tokenStart + 1);
+
+ char *condStart = strchr(c->expr, ',');
+ char *condEnd = strchr(c->expr, ')');
+ char strCond[100] = "";
+ strncpy(strCond, condStart + 1, condEnd - condStart - 1);
+ c->compareValue = atoi(strCond);
+
+ //check globals
+ int result = 0;
+ if (globals->GetInt(token, result)) {
+ c->constant = true;
+ if (c->type == eCondType::lowerInt && result < c->compareValue)
+ c->isTrue = true;
+ else if (c->type == eCondType::equalInt && result == c->compareValue)
+ c->isTrue = true;
+ else if (c->type == eCondType::greaterInt && result > c->compareValue)
+ c->isTrue = true;
+ return;
+ }
+ SetTokenIndex(c, token);
+}
+
+void cCondition::SetStringCond(cCond *c) {
+ ReplaceStart(c->expr, 5);
+ SetTokenIndex(c, c->expr);
+}
+
+void cCondition::SetStringCompareCond(cCond *c) {
+ char *tokenStart = strchr(c->expr, '{');
+ char *tokenEnd = strchr(c->expr, '}');
+ if (!tokenStart || !tokenEnd)
+ return;
+ char token[200] = "";
+ strncpy(token, tokenStart, tokenEnd - tokenStart + 1);
+
+ char *condStart = strstr(c->expr, ",'");
+ char *condEnd = strstr(c->expr, "')");
+ char strCond[100] = "";
+ strncpy(strCond, condStart + 2, condEnd - condStart - 2);
+ c->compareStrValue = strdup(strCond);
+ SetTokenIndex(c, token);
+}
+
+void cCondition::SetTokenIndex(cCond *c, const char *token) {
+ int tokenIndex = tokenContainer->IntTokenIndex(token);
+ if (tokenIndex >= 0) {
+ c->tokenIndex = tokenIndex;
+ c->tokenType = eCondTokenType::inttoken;
+ return;
+ }
+ tokenIndex = tokenContainer->StringTokenIndex(token);
+ if (tokenIndex >= 0) {
+ c->tokenIndex = tokenIndex;
+ c->tokenType = eCondTokenType::stringtoken;
+ return;
+ }
+ tokenIndex = tokenContainer->LoopTokenIndex(token);
+ if (tokenIndex >= 0) {
+ c->tokenIndex = tokenIndex;
+ c->tokenType = eCondTokenType::looptoken;
+ }
+}
+/******************************************************************
+* cSummand
+******************************************************************/
+cSummand::cSummand(const char *summand) {
+ this->summand = strdup(summand);
+}
+
+cSummand::cSummand(const cSummand &other) {
+ summand = NULL;
+ if (other.summand)
+ summand = strdup(other.summand);
+ positive = other.positive;
+ for (cFactor *fac = other.factors.First(); fac; fac = other.factors.Next(fac)) {
+ factors.Add(new cFactor(*fac));
+ }
+}
+
+cSummand::~cSummand(void) {
+ free(summand);
+}
+
+void cSummand::Debug(void) {
+ esyslog("skindesigner: summand %s, positive: %d", summand, positive);
+ for (cFactor *f = factors.First(); f; f = factors.Next(f)) {
+ const char *link = f->multiplication ? "multiplication" : "division";
+ if (f->type == eFactorType::constant)
+ esyslog("skindesigner: constant factor %f, %s", f->constValue, link);
+ else if (f->type == eFactorType::inttoken)
+ esyslog("skindesigner: IntToken factor, index %d, %s", f->tokenIndex, link);
+ else if (f->type == eFactorType::stringtoken)
+ esyslog("skindesigner: StringToken factor, index %d, %s", f->tokenIndex, link);
+ else if (f->type == eFactorType::looptoken)
+ esyslog("skindesigner: LoopToken factor, index %d, %s", f->tokenIndex, link);
+ else if (f->type == eFactorType::xref)
+ esyslog("skindesigner: posx reference factor, %s, %p, %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncX());
+ else if (f->type == eFactorType::yref)
+ esyslog("skindesigner: posy reference factor, %s, %p, %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncY());
+ else if (f->type == eFactorType::widthref)
+ esyslog("skindesigner: width reference factor, %s, %p, %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncWidth());
+ else if (f->type == eFactorType::heightref)
+ esyslog("skindesigner: height reference factor, %s, %p %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncHeight());
+ else if (f->type == eFactorType::areawidth)
+ esyslog("skindesigner: {areawidth} factor, %s", link);
+ else if (f->type == eFactorType::areaheight)
+ esyslog("skindesigner: {areaheight} factor, %s", link);
+ else if (f->type == eFactorType::columnwidth)
+ esyslog("skindesigner: {columnwidth} factor, %s", link);
+ else if (f->type == eFactorType::rowheight)
+ esyslog("skindesigner: {rowheight} factor, %s", link);
+ }
+}
+
+/******************************************************************
+* cNumericExpr
+******************************************************************/
+cNumericExpr::cNumericExpr(const char *expression) {
+ expr = strdup(expression);
+ globals = NULL;
+ container = NULL;
+ tokenContainer = NULL;
+ loopInfo = NULL;
+ horizontal = true;
+ value = 0;
+ dynamic = false;
+}
+
+cNumericExpr::cNumericExpr(const cNumericExpr &other) {
+ expr = strdup(other.expr);
+ globals = other.globals;
+ container = NULL;
+ tokenContainer = NULL;
+ loopInfo = NULL;
+ horizontal = other.horizontal;
+ value = other.value;
+ dynamic = other.dynamic;
+ for (cSummand *s = other.summands.First(); s; s = other.summands.Next(s)) {
+ summands.Add(new cSummand(*s));
+ }
+}
+
+cNumericExpr::~cNumericExpr(void) {
+ free(expr);
+}
+
+/******************************************************************
+* Public Functions
+******************************************************************/
+bool cNumericExpr::CacheStatic(void) {
+ expr = RemoveSpace(expr);
+ if (config.replaceDecPoint)
+ ReplaceDecimalpoint(expr);
+
+ //first check if expression is already an valid integer
+ if (IsNumeric(expr)) {
+ value = atoi(expr);
+ return true;
+ }
+
+ //check if expression is a percent expression
+ if (PercentValue(expr)) {
+ return true;
+ }
+ //if areawidth or height unknown, percent values have to be replaced
+ expr = ReplacePercentValue(expr);
+ //replace {areawidth} and {areaheight}
+ if (container->Width() >= 0) {
+ //esyslog("skindesigner: replacing areawidth %s", expr);
+ expr = ReplaceTokens(expr, "{areawidth}", container->Width());
+ //esyslog("skindesigner: replaced areawidth %s", expr);
+ }
+ if (container->Height() >= 0)
+ expr = ReplaceTokens(expr, "{areaheight}", container->Height());
+
+ //replace globals
+ string tmp = expr;
+ globals->ReplaceIntVars(tmp);
+ globals->ReplaceDoubleVars(tmp);
+ free(expr);
+ expr = strdup(tmp.c_str());
+ if (IsNumeric(expr)) {
+ value = atoi(expr);
+ return true;
+ }
+ //check if all variables are eliminated
+ if (IsNumericExpression(expr)) {
+ value = EvaluateExpression(expr);
+ return true;
+ }
+ //now we have a expression with runtime variables
+ dynamic = true;
+ return false;
+}
+
+void cNumericExpr::PrepareTokens(void) {
+ CreateSummands();
+ CreateFactors();
+ ConsolidateFactors();
+ ConsolidateSummand();
+}
+
+vector<cFactor*> cNumericExpr::GetRefFactors(void) {
+ vector<cFactor*> refFactors;
+ for (cSummand *s = summands.First(); s; s = summands.Next(s)) {
+ for (cFactor* f = s->factors.First(); f; f = s->factors.Next(f)) {
+ if (f->type >= eFactorType::xref) {
+ refFactors.push_back(f);
+ }
+ }
+ }
+ return refFactors;
+}
+
+int cNumericExpr::Calculate(void) {
+ double result = 0.0f;
+ for (cSummand *s = summands.First(); s; s = summands.Next(s)) {
+ double factor = 1.0f;
+ for (cFactor *f = s->factors.First(); f; f = s->factors.Next(f)) {
+ double fac = 0.0f;
+ switch( f->type ) {
+ case eFactorType::constant:
+ fac = f->constValue;
+ break;
+ case eFactorType::stringtoken: {
+ char *val = tokenContainer->StringToken(f->tokenIndex);
+ if (val)
+ fac = atoi(val);
+ break; }
+ case eFactorType::inttoken:
+ fac = tokenContainer->IntToken(f->tokenIndex);
+ break;
+ case eFactorType::looptoken:
+ if (loopInfo && loopInfo->row >= 0) {
+ char *val = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, f->tokenIndex);
+ if (val)
+ fac = atoi(val);
+ }
+ break;
+ case eFactorType::xref:
+ if (f->funcRef)
+ fac = f->funcRef->FuncX();
+ break;
+ case eFactorType::yref:
+ if (f->funcRef)
+ fac = f->funcRef->FuncY();
+ break;
+ case eFactorType::widthref:
+ if (f->funcRef)
+ fac = f->funcRef->FuncWidth();
+ break;
+ case eFactorType::heightref:
+ if (f->funcRef)
+ fac = f->funcRef->FuncHeight();
+ break;
+ case eFactorType::areawidth:
+ fac = container->Width();
+ break;
+ case eFactorType::areaheight:
+ fac = container->Height();
+ break;
+ case eFactorType::columnwidth:
+ if (loopInfo)
+ fac = loopInfo->colWidth;
+ break;
+ case eFactorType::rowheight:
+ if (loopInfo)
+ fac = loopInfo->rowHeight;
+ break;
+ }
+ if (f->multiplication)
+ factor *= fac;
+ else if (fac)
+ factor /= fac;
+ }
+ if (s->positive)
+ result += factor;
+ else
+ result -= factor;
+ }
+ return (int)result;
+}
+
+
+void cNumericExpr::Debug(void) {
+ esyslog("skindesigner: Numeric Expression \"%s\", Result: %d", expr, Calculate());
+ for (cSummand *s = summands.First(); s; s = summands.Next(s)) {
+ s->Debug();
+ }
+}
+
+/******************************************************************
+* Private Functions
+******************************************************************/
+bool cNumericExpr::IsNumeric(const char *e) {
+ //negativ numbers
+ if (*e == '-')
+ ++e;
+ //empty
+ if (!*e)
+ return false;
+ while (*e) {
+ if (isdigit(*e) || *e == '.' || *e == ',')
+ ++e;
+ else
+ return false;
+ }
+ return true;
+}
+
+bool cNumericExpr::IsNumericExpression(const char *e) {
+ if (!*e)
+ return false;
+ while (*e) {
+ if (isdigit(*e) || *e == '.' || *e == ',' || *e == '+' || *e == '-' || *e == '*' || *e == '/')
+ ++e;
+ else
+ return false;
+ }
+ return true;
+}
+
+bool cNumericExpr::PercentValue(const char *e) {
+ const char *hit = strchr(e, '%');
+ if (!hit)
+ return false;
+ char buffer[20] = "";
+ if (strlen(e) > 20)
+ return false;
+ strncpy(buffer, e, strlen(e)-1);
+ buffer[strlen(e)-1] = '\0';
+ int val = atoi(buffer);
+ bool ok = false;
+ if (horizontal && container->Width() > 0) {
+ value = container->Width() * val / 100;
+ ok = true;
+ } else if (!horizontal && container->Height() > 0){
+ value = container->Height() * val / 100;
+ ok = true;
+ }
+ return ok;
+}
+
+char *cNumericExpr::ReplacePercentValue(char *e) {
+ const char *hit = strchr(e, '%');
+ if (!hit)
+ return e;
+ char buffer[20] = "";
+ if (strlen(e) > 20)
+ return e;
+ strncpy(buffer, e, strlen(e)-1);
+ buffer[strlen(e)-1] = '\0';
+ int val = atoi(buffer);
+ double percentVal = (double)val/100.0f;
+
+ char replacement[50] = "";
+ if (horizontal) {
+ sprintf(replacement, "%.5f*{areawidth}", percentVal);
+ } else {
+ sprintf(replacement, "%.5f*{areaheight}", percentVal);
+ }
+
+ int len = strlen(replacement) + 1;
+ char *replaced = (char*)malloc(len);
+ memset(replaced, 0, len);
+ strcpy(replaced, replacement);
+ free(expr);
+ return replaced;
+}
+
+char *cNumericExpr::ReplaceToken(char *e, const char* token, int val) {
+ char *tokenStart = strstr(e, token);
+ if (!tokenStart) {
+ return e;
+ }
+ char buffer[20] = "";
+ sprintf(buffer, "%d", val);
+ size_t newSize = strlen(e) - strlen(token) + strlen(buffer) + 1;
+ char *replaced = (char*)malloc(newSize);
+ memset(replaced, 0, newSize);
+ size_t beginning = strlen(e) - strlen(tokenStart);
+ if (beginning > 0)
+ strncpy(replaced, e, beginning);
+ strcat(replaced, buffer);
+ strcat(replaced, tokenStart + strlen(token));
+ free(e);
+ return replaced;
+}
+
+char *cNumericExpr::ReplaceTokens(char *e, const char* token, int val) {
+ if (!e)
+ return e;
+ while (true) {
+ char *tokenStart = strstr(e, token);
+ if (!tokenStart)
+ break;
+ e = ReplaceToken(e, token, val);
+ }
+ return e;
+}
+
+int cNumericExpr::EvaluateExpression(char* e) {
+ return round(ParseSummands(e));
+}
+
+double cNumericExpr::EvaluateExpressionDouble(char *e) {
+ return ParseSummands(e);
+}
+
+double cNumericExpr::ParseAtom(char*& e) {
+ // Read the number from string
+ char* end_ptr;
+ double res = strtod(e, &end_ptr);
+ // Advance the pointer and return the result
+ e = end_ptr;
+ return res;
+}
+
+// Parse multiplication and division
+double cNumericExpr::ParseFactors(char*& e) {
+ double num1 = ParseAtom(e);
+ for(;;) {
+ // Save the operation
+ char op = *e;
+ if(op != '/' && op != '*')
+ return num1;
+ e++;
+ double num2 = ParseAtom(e);
+ // Perform the saved operation
+ if(op == '/') {
+ if (num2 != 0) {
+ num1 /= num2;
+ }
+ } else
+ num1 *= num2;
+ }
+}
+
+// Parse addition and subtraction
+double cNumericExpr::ParseSummands(char*& e) {
+ double num1 = ParseFactors(e);
+ for(;;) {
+ char op = *e;
+ if(op != '-' && op != '+')
+ return num1;
+ e++;
+ double num2 = ParseFactors(e);
+ if(op == '-')
+ num1 -= num2;
+ else
+ num1 += num2;
+ }
+}
+
+void cNumericExpr::CreateSummands(void) {
+ char *sum = strdup(expr);
+ char delimiter[] = "+-";
+ bool positive = true;
+ if (sum && *sum && *sum == '-') {
+ positive = false;
+ }
+ char *summand = strtok(sum, delimiter);
+ while (summand) {
+ cSummand *s = new cSummand(summand);
+ s->positive = positive;
+ summands.Add(s);
+ //check next sign
+ if (expr[summand - sum + strlen(summand)] == '-')
+ positive = false;
+ else
+ positive = true;
+ summand = strtok(NULL, delimiter);
+ }
+ free(sum);
+}
+
+void cNumericExpr::CreateFactors(void) {
+ char delimiterFac[] = "*/";
+ for (cSummand *s = summands.First(); s; s = summands.Next(s)) {
+ char *sum = strdup(s->summand);
+ if (IsNumericExpression(sum)) {
+ cFactor *f = new cFactor();
+ f->constValue = EvaluateExpressionDouble(sum);
+ s->factors.Add(f);
+ free(sum);
+ continue;
+ }
+ bool multiplication = true;
+ char *fac = strtok(sum, delimiterFac);
+ while (fac) {
+ cFactor *f = new cFactor();
+ if (IsNumeric(fac)) {
+ f->constValue = atof(fac);
+ f->multiplication = multiplication;
+ s->factors.Add(f);
+ } else {
+ //factor has to be a token or a function reference now
+ if (SetTokenFactor(f, fac)) {
+ f->multiplication = multiplication;
+ s->factors.Add(f);
+ } else if (SetReferenceFactor(f, fac)) {
+ f->multiplication = multiplication;
+ s->factors.Add(f);
+ } else if (SetGeometryFactor(f, fac)) {
+ f->multiplication = multiplication;
+ s->factors.Add(f);
+ } else {
+ esyslog("skindesigner: invalid factor %s in expression \"%s\"", fac, expr);
+ delete f;
+ }
+ }
+ //check next sign
+ if (s->summand[fac - sum + strlen(fac)] == '/')
+ multiplication = false;
+ else
+ multiplication = true;
+ fac = strtok(NULL, delimiterFac);
+ }
+ free(sum);
+ }
+}
+
+bool cNumericExpr::SetTokenFactor(cFactor *f, char *tokenName) {
+ int tokenIndex = tokenContainer->IntTokenIndex(tokenName);
+ if (tokenIndex >= 0) {
+ f->tokenIndex = tokenIndex;
+ f->type = eFactorType::inttoken;
+ return true;
+ }
+ tokenIndex = tokenContainer->StringTokenIndex(tokenName);
+ if (tokenIndex >= 0) {
+ f->tokenIndex = tokenIndex;
+ f->type = eFactorType::stringtoken;
+ return true;
+ }
+ tokenIndex = tokenContainer->LoopTokenIndex(tokenName);
+ if (tokenIndex >= 0) {
+ f->tokenIndex = tokenIndex;
+ f->type = eFactorType::looptoken;
+ return true;
+ }
+ return false;
+}
+
+
+bool cNumericExpr::SetReferenceFactor(cFactor *f, char *tokenName) {
+ int start = 0;
+ if (startswith(tokenName, "{posx(") && endswith(tokenName, ")}")) {
+ start = 6;
+ f->type = eFactorType::xref;
+ } else if (startswith(tokenName, "{posy(") && endswith(tokenName, ")}")) {
+ start = 6;
+ f->type = eFactorType::yref;
+ } else if (startswith(tokenName, "{width(") && endswith(tokenName, ")}")) {
+ start = 7;
+ f->type = eFactorType::widthref;
+ } else if (startswith(tokenName, "{height(") && endswith(tokenName, ")}")) {
+ start = 8;
+ f->type = eFactorType::heightref;
+ }
+
+ if (start == 0)
+ return false;
+
+ tokenName += start;
+ f->funcRefName = strdup(tokenName);
+ ReplaceEnd(f->funcRefName, 2);
+
+ return true;
+}
+
+bool cNumericExpr::SetGeometryFactor(cFactor *f, char *tokenName) {
+ bool ok = false;
+ if (!strcmp(tokenName, "{areawidth}")) {
+ f->type = eFactorType::areawidth;
+ ok = true;
+ } else if (!strcmp(tokenName, "{areaheight}")) {
+ f->type = eFactorType::areaheight;
+ ok = true;
+ } else if (!strcmp(tokenName, "{columnwidth}")) {
+ f->type = eFactorType::columnwidth;
+ ok = true;
+ } else if (!strcmp(tokenName, "{rowheight}")) {
+ f->type = eFactorType::rowheight;
+ ok = true;
+ }
+ return ok;
+}
+
+void cNumericExpr::ConsolidateSummand(void) {
+ cSummand *constSummand = NULL;
+ for (cSummand *s = summands.First(); s; s = summands.Next(s)) {
+ if (s->factors.Count() == 1 && s->factors.First()->type == eFactorType::constant) {
+ if (!constSummand) {
+ constSummand = s;
+ } else {
+ if (s->positive)
+ constSummand->factors.First()->constValue += s->factors.First()->constValue;
+ else
+ constSummand->factors.First()->constValue -= s->factors.First()->constValue;
+ summands.Del(s);
+ s = constSummand;
+ }
+ }
+ }
+}
+
+void cNumericExpr::ConsolidateFactors(void) {
+ for (cSummand *s = summands.First(); s; s = summands.Next(s)) {
+ cFactor *constFactor = NULL;
+ for (cFactor *f = s->factors.First(); f; f = s->factors.Next(f)) {
+ if (f->type == eFactorType::constant) {
+ if (!constFactor) {
+ constFactor = f;
+ } else {
+ if (f->multiplication)
+ constFactor->constValue *= f->constValue;
+ else
+ constFactor->constValue /= f->constValue;
+ s->factors.Del(f);
+ f = constFactor;
+ }
+ }
+ }
+ }
+}
+
+/******************************************************************
+* cColor
+******************************************************************/
+cColor::cColor(const char *expression) {
+ globals = NULL;
+ expr = strdup(expression);
+ value = 0x00;
+}
+
+cColor::cColor(const cColor &other) {
+ globals = other.globals;
+ expr = strdup(other.expr);
+ value = other.value;
+}
+
+cColor::~cColor(void) {
+ free(expr);
+}
+
+void cColor::Cache(void) {
+ tColor colVal = 0x00;
+ string tmp = expr;
+ if (globals->GetColor(tmp, colVal)) {
+ value = colVal;
+ return;
+ }
+ if (strlen(expr) != 8)
+ return;
+ std::stringstream str;
+ str << tmp;
+ colVal = 0x00;
+ str >> std::hex >> colVal;
+ value = colVal;
+}
+
+tColor cColor::Color(void) {
+ return value;
+}
+
+void cColor::Debug(void) {
+ esyslog("skindesigner: Color \"%s\", Value %x", expr, value);
+}
+
+/******************************************************************
+* cTextExpr
+******************************************************************/
+cTextExpr::cTextExpr(const char *expression) {
+ globals = NULL;
+ expr = strdup(expression);
+ tokenContainer = NULL;
+ loopInfo = NULL;
+}
+
+cTextExpr::cTextExpr(const cTextExpr &other) {
+ globals = other.globals;
+ expr = strdup(other.expr);
+ tokenContainer = NULL;
+ loopInfo = NULL;
+ for (cTextToken* t = other.textTokens.First(); t; t = other.textTokens.Next(t)) {
+ textTokens.Add(new cTextToken(*t));
+ }
+}
+
+cTextExpr::~cTextExpr(void) {
+ free(expr);
+}
+
+void cTextExpr::CorrectImagePath(void) {
+ //no absolute pathes allowed
+ if (!startswith(expr, "{")) {
+ esyslog("skindesigner: no absolute pathes allowed for images - %s", expr);
+ }
+ if (startswith(expr, "{ressourcedir}")) {
+ string tmp = expr;
+ tmp = tmp.replace(0, 14, *config.GetSkinRessourcePath());
+ free(expr);
+ expr = strdup(tmp.c_str());
+ }
+}
+
+
+void cTextExpr::Cache(void) {
+ Translate();
+ Tokenize();
+ PrepareTokens();
+}
+
+char *cTextExpr::DeterminateText(void) {
+ //calculate length of complete new string
+ int textLength = 0;
+ for (cTextToken* t = textTokens.First(); t; t = textTokens.Next(t)) {
+ if (t->type == eTexttokenType::constant) {
+ textLength += strlen(t->constValue);
+ } else if (t->type == eTexttokenType::stringtoken) {
+ char *str = tokenContainer->StringToken(t->tokenIndex);
+ if (str)
+ textLength += strlen(str);
+ } else if (t->type == eTexttokenType::inttoken) {
+ int value = tokenContainer->IntToken(t->tokenIndex);
+ if (value >= 0) {
+ cString str = cString::sprintf("%d", value);
+ textLength += strlen(*str);
+ }
+ } else if (t->type == eTexttokenType::looptoken && loopInfo && loopInfo->row >= 0) {
+ char *str = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, t->tokenIndex);
+ if (str)
+ textLength += strlen(str);
+ } else if (t->type == eTexttokenType::printftoken) {
+ DeterminatePrintfToken(t);
+ if (t->printfResult)
+ textLength += strlen(t->printfResult);
+ } else if (t->type == eTexttokenType::condstringtoken) {
+ char *str = tokenContainer->StringToken(t->tokenIndex);
+ if (str) {
+ textLength += strlen(str);
+ if (t->condStart)
+ textLength += strlen(t->condStart);
+ if (t->condEnd)
+ textLength += strlen(t->condEnd);
+ }
+ } else if (t->type == eTexttokenType::condinttoken) {
+ int value = tokenContainer->IntToken(t->tokenIndex);
+ if (value >= 0) {
+ cString str = cString::sprintf("%d", value);
+ textLength += strlen(*str);
+ if (t->condStart)
+ textLength += strlen(t->condStart);
+ if (t->condEnd)
+ textLength += strlen(t->condEnd);
+ }
+ }
+ }
+
+ if (textLength <= 0)
+ return NULL;
+
+ char *retVal = (char*)malloc(textLength+1);
+ memset(retVal, 0, textLength);
+ bool first = true;
+ for (cTextToken* t = textTokens.First(); t; t = textTokens.Next(t)) {
+ if (first) {
+ first = false;
+ if (t->type == eTexttokenType::constant) {
+ strcpy(retVal, t->constValue);
+ } else if (t->type == eTexttokenType::stringtoken) {
+ char *str = tokenContainer->StringToken(t->tokenIndex);
+ if (str)
+ strcpy(retVal, str);
+ } else if (t->type == eTexttokenType::inttoken) {
+ int value = tokenContainer->IntToken(t->tokenIndex);
+ if (value >= 0) {
+ cString str = cString::sprintf("%d", value);
+ strcpy(retVal, *str);
+ }
+ } else if (t->type == eTexttokenType::looptoken && loopInfo && loopInfo->row >= 0) {
+ char *str = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, t->tokenIndex);
+ if (str)
+ strcpy(retVal, str);
+ } else if (t->type == eTexttokenType::printftoken) {
+ if (t->printfResult) {
+ strcpy(retVal, t->printfResult);
+ free(t->printfResult);
+ t->printfResult = NULL;
+ }
+ } else if (t->type == eTexttokenType::condstringtoken) {
+ char *str = tokenContainer->StringToken(t->tokenIndex);
+ if (str) {
+ if (t->condStart) {
+ strcpy(retVal, t->condStart);
+ strcat(retVal, str);
+ } else {
+ strcpy(retVal, str);
+ }
+ if (t->condEnd)
+ strcat(retVal, t->condEnd);
+ }
+ } else if (t->type == eTexttokenType::condinttoken) {
+ int value = tokenContainer->IntToken(t->tokenIndex);
+ if (value >= 0) {
+ cString str = cString::sprintf("%d", value);
+ if (t->condStart) {
+ strcpy(retVal, t->condStart);
+ strcat(retVal, *str);
+ } else {
+ strcpy(retVal, *str);
+ }
+ if (t->condEnd)
+ strcat(retVal, t->condEnd);
+ }
+ }
+ } else {
+ if (t->type == eTexttokenType::constant) {
+ strcat(retVal, t->constValue);
+ } else if (t->type == eTexttokenType::stringtoken) {
+ char *str = tokenContainer->StringToken(t->tokenIndex);
+ if (str)
+ strcat(retVal, str);
+ } else if (t->type == eTexttokenType::inttoken) {
+ int value = tokenContainer->IntToken(t->tokenIndex);
+ cString str = cString::sprintf("%d", value);
+ strcat(retVal, *str);
+ } else if (t->type == eTexttokenType::looptoken && loopInfo && loopInfo->row >= 0) {
+ char *str = tokenContainer->LoopToken(loopInfo->index, loopInfo->row, t->tokenIndex);
+ if (str)
+ strcat(retVal, str);
+ } else if (t->type == eTexttokenType::printftoken) {
+ if (t->printfResult) {
+ strcat(retVal, t->printfResult);
+ free(t->printfResult);
+ t->printfResult = NULL;
+ }
+ } else if (t->type == eTexttokenType::condstringtoken) {
+ char *str = tokenContainer->StringToken(t->tokenIndex);
+ if (str) {
+ if (t->condStart)
+ strcat(retVal, t->condStart);
+ strcat(retVal, str);
+ if (t->condEnd)
+ strcat(retVal, t->condEnd);
+ }
+ } else if (t->type == eTexttokenType::condinttoken) {
+ int value = tokenContainer->IntToken(t->tokenIndex);
+ if (value >= 0) {
+ cString str = cString::sprintf("%d", value);
+ if (t->condStart)
+ strcat(retVal, t->condStart);
+ strcat(retVal, *str);
+ if (t->condEnd)
+ strcat(retVal, t->condEnd);
+ }
+ }
+ }
+ }
+ return retVal;
+}
+
+
+void cTextExpr::Debug(const char *exprName) {
+ esyslog("skindesigner: TextExpr %s: \"%s\"", exprName, expr);
+ char *res = DeterminateText();
+ esyslog("skindesigner: Result: \"%s\"", res);
+ free(res);
+ for (cTextToken *t = textTokens.First(); t; t = textTokens.Next(t)) {
+ if (t->type == eTexttokenType::constant)
+ esyslog("skindesigner: constant token \"%s\"", t->constValue);
+ else if (t->type == eTexttokenType::stringtoken)
+ esyslog("skindesigner: string token %s, index %d", t->constValue, t->tokenIndex);
+ else if (t->type == eTexttokenType::inttoken)
+ esyslog("skindesigner: int token %s, index %d", t->constValue, t->tokenIndex);
+ else if (t->type == eTexttokenType::looptoken)
+ esyslog("skindesigner: loop token %s, index %d", t->constValue, t->tokenIndex);
+ else if (t->type == eTexttokenType::printftoken)
+ esyslog("skindesigner: printf token %s", t->constValue);
+ else if (t->type == eTexttokenType::condstringtoken || t->type == eTexttokenType::condinttoken)
+ esyslog("skindesigner: conditional token %s", t->constValue);
+ }
+}
+
+void cTextExpr::Translate(void) {
+ string translated = "";
+ if (!globals->Translate(expr, translated))
+ return;
+ free(expr);
+ expr = strdup(translated.c_str());
+}
+
+void cTextExpr::Tokenize(void) {
+ char *head = expr;
+ char *tail = expr;
+ while (*tail) {
+ if (*tail == '|') {
+ char *begin = CopyTextPart(head, tail, false);
+ if (begin) {
+ cTextToken *t = new cTextToken();
+ t->constValue = begin;
+ textTokens.Add(t);
+ }
+ head = tail;
+ tail++;
+ while (*tail) {
+ if (*tail == '|') {
+ char *token = CopyTextPart(head, tail);
+ cTextToken *t = new cTextToken();
+ t->type = eTexttokenType::condstringtoken;
+ t->constValue = token;
+ textTokens.Add(t);
+ head = tail+1;
+ break;
+ }
+ tail++;
+ }
+ } else if (*tail == '{') {
+ char *begin = CopyTextPart(head, tail, false);
+ if (begin) {
+ cTextToken *t = new cTextToken();
+ t->constValue = begin;
+ textTokens.Add(t);
+ }
+ head = tail;
+ tail++;
+ while (*tail) {
+ if (*tail == '}') {
+ char *token = CopyTextPart(head, tail);
+ cTextToken *t = new cTextToken();
+ t->type = eTexttokenType::stringtoken;
+ t->constValue = token;
+ textTokens.Add(t);
+ head = tail+1;
+ break;
+ }
+ tail++;
+ }
+ }
+ tail++;
+ }
+ char *end = CopyTextPart(head, tail, false);
+ if (end) {
+ cTextToken *t = new cTextToken();
+ t->constValue = end;
+ textTokens.Add(t);
+ }
+}
+
+void cTextExpr::PrepareTokens(void) {
+ bool error = false;
+ for (cTextToken *t = textTokens.First(); t; t = textTokens.Next(t)) {
+ if (t->type == eTexttokenType::condstringtoken) {
+ ParseCondToken(t);
+ continue;
+ } else if (t->type != eTexttokenType::stringtoken)
+ continue;
+ if (ParsePrintfToken(t)) {
+ continue;
+ }
+ if (CheckGlobals(t)) {
+ continue;
+ }
+ int tokenIndex = tokenContainer->IntTokenIndex(t->constValue);
+ if (tokenIndex >= 0) {
+ t->tokenIndex = tokenIndex;
+ t->type = eTexttokenType::inttoken;
+ continue;
+ }
+ tokenIndex = tokenContainer->StringTokenIndex(t->constValue);
+ if (tokenIndex >= 0) {
+ t->tokenIndex = tokenIndex;
+ t->type = eTexttokenType::stringtoken;
+ continue;
+ }
+ tokenIndex = tokenContainer->LoopTokenIndex(t->constValue);
+ if (tokenIndex >= 0) {
+ t->tokenIndex = tokenIndex;
+ t->type = eTexttokenType::looptoken;
+ continue;
+ }
+ esyslog("skindesigner: invalid text token %s in expression \"%s\"", t->constValue, expr);
+ error = true;
+ break;
+ }
+ if (error) {
+ textTokens.Clear();
+ }
+}
+
+bool cTextExpr::CheckGlobals(cTextToken *t) {
+ if (!globals || !t->constValue)
+ return false;
+
+ string name = t->constValue;
+ name = name.substr(1, name.size()-2);
+ string replacement = "";
+ if (globals->GetString(name, replacement)) {
+ free(t->constValue);
+ t->constValue = strdup(replacement.c_str());
+ t->type = eTexttokenType::constant;
+ return true;
+ }
+ int numReplacement = 0;
+ if (globals->GetInt(name, numReplacement)) {
+ free(t->constValue);
+ cString repl = cString::sprintf("%d", numReplacement);
+ t->constValue = strdup(*repl);
+ t->type = eTexttokenType::constant;
+ return true;
+ }
+ return false;
+}
+
+bool cTextExpr::ParsePrintfToken(cTextToken *t) {
+ //check valid printftoken
+ char *start = strstr(t->constValue, "printf(");
+ if (!start)
+ return false;
+ char *end = strchr(start, ')');
+ if (!end)
+ return false;
+ t->type = eTexttokenType::printftoken;
+
+ //find printf expression
+ char *startExpr = strchr(t->constValue, '\'');
+ if (!startExpr)
+ return false;
+ char *endExpr = strchr(startExpr + 1, '\'');
+ if (!endExpr)
+ return false;
+ int expLen = endExpr - startExpr - 1;
+ char buffer[100];
+ strncpy(buffer, startExpr+1, expLen);
+ buffer[expLen] = '\0';
+ t->printfExpr = strdup(buffer);
+
+ //find variables
+ char *startVar = strchr(t->constValue, ',');
+ if (!startVar)
+ return false;
+ startVar++;
+ vector<string> varTokens;
+ char *nextVar = NULL;
+ while (nextVar = strchr(startVar, ',')) {
+ while(isspace(*startVar))
+ startVar++;
+ int varLen = nextVar - startVar;
+ buffer[0] = '{';
+ strncpy((char*)buffer + 1, startVar, varLen);
+ buffer[varLen+1] = '}';
+ buffer[varLen+2] = '\0';
+ int i = 1;
+ while(isspace(buffer[varLen-i])) {
+ buffer[varLen-i] = '}';
+ buffer[varLen-i+1] = '\0';
+ i++;
+ }
+ varTokens.push_back(buffer);
+ startVar = nextVar + 1;
+ }
+ if (startVar+1) {
+ int varLen = end - startVar;
+ buffer[0] = '{';
+ strncpy((char*)buffer + 1, startVar + 1, varLen);
+ buffer[varLen] = '}';
+ buffer[varLen+1] = '\0';
+ varTokens.push_back(buffer);
+ }
+ //evaluate variables
+ bool ok = true;
+ for (size_t i=0; i < varTokens.size(); i++) {
+ sPrintfInfo info;
+ int tokenIndex = tokenContainer->IntTokenIndex(varTokens[i].c_str());
+ if (tokenIndex >= 0) {
+ info.type = ePrintfVarType::inttoken;
+ info.index = tokenIndex;
+ t->printfVarIndices.push_back(info);
+ continue;
+ }
+ tokenIndex = tokenContainer->StringTokenIndex(varTokens[i].c_str());
+ if (tokenIndex >= 0) {
+ info.type = ePrintfVarType::stringtoken;
+ info.index = tokenIndex;
+ t->printfVarIndices.push_back(info);
+ continue;
+ }
+ tokenIndex = tokenContainer->LoopTokenIndex(varTokens[i].c_str());
+ if (tokenIndex >= 0) {
+ info.type = ePrintfVarType::looptoken;
+ info.index = tokenIndex;
+ t->printfVarIndices.push_back(info);
+ continue;
+ }
+ ok = false;
+ }
+ return ok;
+}
+
+void cTextExpr::DeterminatePrintfToken(cTextToken *t) {
+ int numVars = t->printfVarIndices.size();
+ vector<int> results;
+ for (int i=0; i < numVars; i++) {
+ if (t->printfVarIndices[i].type == ePrintfVarType::inttoken) {
+ results.push_back(tokenContainer->IntToken(t->printfVarIndices[i].index));
+ } else if (t->printfVarIndices[i].type == ePrintfVarType::stringtoken) {
+ if (tokenContainer->StringToken(t->printfVarIndices[i].index)) {
+ results.push_back(atoi(tokenContainer->StringToken(t->printfVarIndices[i].index)));
+ }
+ } else if (t->printfVarIndices[i].type == ePrintfVarType::looptoken && loopInfo && loopInfo->row >= 0) {
+ if (tokenContainer->LoopToken(loopInfo->index, loopInfo->row, t->printfVarIndices[i].index)) {
+ results.push_back(atoi(tokenContainer->LoopToken(loopInfo->index, loopInfo->row, t->printfVarIndices[i].index)));
+ }
+ }
+ }
+
+ switch (numVars) {
+ case 1:
+ t->printfResult = strdup(*cString::sprintf(t->printfExpr, results[0]));
+ break;
+ case 2:
+ t->printfResult = strdup(*cString::sprintf(t->printfExpr, results[0], results[1]));
+ break;
+ case 3:
+ t->printfResult = strdup(*cString::sprintf(t->printfExpr, results[0], results[1], results[2]));
+ break;
+ case 4:
+ t->printfResult = strdup(*cString::sprintf(t->printfExpr, results[0], results[1], results[2], results[3]));
+ break;
+ case 5:
+ t->printfResult = strdup(*cString::sprintf(t->printfExpr, results[0], results[1], results[2], results[3], results[4]));
+ break;
+ case 6:
+ t->printfResult = strdup(*cString::sprintf(t->printfExpr, results[0], results[1], results[2], results[3], results[4], results[5]));
+ break;
+ default:
+ break;
+ }
+}
+
+void cTextExpr::ParseCondToken(cTextToken *t) {
+ char *head = t->constValue;
+ char *tail = t->constValue;
+ head++;
+ tail++;
+ char *token = NULL;
+ while (*tail) {
+ if (*tail == '{') {
+ t->condStart = CopyTextPart(head, tail, false);
+ head = tail;
+ tail++;
+ while (*tail) {
+ if (*tail == '}') {
+ token = CopyTextPart(head, tail);
+ head = tail+1;
+ break;
+ }
+ tail++;
+ }
+ }
+ tail++;
+ }
+ tail--;
+ t->condEnd = CopyTextPart(head, tail, false);
+ if (!token) {
+ esyslog("skindesigner: invalid conditional texttoken %s in expression \"%s\"", t->constValue, expr);
+ return;
+ }
+
+ int tokenIndex = tokenContainer->StringTokenIndex(token);
+ if (tokenIndex >= 0) {
+ t->tokenIndex = tokenIndex;
+ return;
+ }
+
+ tokenIndex = tokenContainer->IntTokenIndex(token);
+ if (tokenIndex >= 0) {
+ t->tokenIndex = tokenIndex;
+ t->type = eTexttokenType::condinttoken;
+ return;
+ }
+ esyslog("skindesigner: invalid token %s in expression\"%s\"", token, expr);
+}
+
+char *cTextExpr::CopyTextPart(char *start, char *stop, bool incLastChar) {
+ if (!start)
+ return NULL;
+ if (start >= stop)
+ return NULL;
+ char *val = NULL;
+ size_t len = 0;
+ if (stop) {
+ //defined end
+ len = stop - start + 1;
+ } else {
+ //search end of text
+ char *p = start;
+ while (*p)
+ len++; p++;
+ len++;
+ }
+ val = (char*)malloc(len+1);
+ memset(val, 0, len+1);
+ if (!incLastChar)
+ len--;
+ memcpy(val, start, len);
+ return val;
+}
diff --git a/coreengine/complextypes.h b/coreengine/complextypes.h new file mode 100644 index 0000000..7f03128 --- /dev/null +++ b/coreengine/complextypes.h @@ -0,0 +1,318 @@ +#ifndef __COMPLEXTYPES_H
+#define __COMPLEXTYPES_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+#include <vector>
+#include <vdr/skins.h>
+#include "globals.h"
+#include "../libskindesignerapi/tokencontainer.h"
+
+class cLoopInfo;
+class cFunction;
+/******************************************************************
+* helpers
+******************************************************************/
+char *RemoveSpace(char *e);
+void ReplaceDecimalpoint(char *e);
+void ReplaceStart(char *e, int num);
+void ReplaceEnd(char *e, int num);
+
+/******************************************************************
+* cCondition
+******************************************************************/
+enum class eCondOp {
+ tAnd,
+ tOr
+};
+
+enum class eCondType {
+ token,
+ negtoken,
+ lowerInt,
+ equalInt,
+ greaterInt,
+ isset,
+ empty,
+ equalString,
+ notEqualString,
+ contains,
+ notContains
+};
+
+enum class eCondTokenType {
+ inttoken,
+ stringtoken,
+ looptoken
+};
+
+class cCond : public cListObject {
+public:
+ cCond(const char *expression);
+ cCond(const cCond &other);
+ virtual ~cCond(void);
+ void Debug(void);
+ char *expr;
+ eCondOp operation;
+ eCondType type;
+ eCondTokenType tokenType;
+ bool constant;
+ bool isTrue;
+ int tokenIndex;
+ int compareValue;
+ char *compareStrValue;
+};
+
+class cCondition {
+private:
+ char *expr;
+ cGlobals *globals;
+ skindesignerapi::cTokenContainer *tokenContainer;
+ cLoopInfo *loopInfo;
+ cList<cCond> conds;
+ void Tokenize(void);
+ void PrepareTokens(void);
+ void SetTokenCond(cCond *c);
+ void SetIntegerCond(cCond *c);
+ void SetStringCond(cCond *c);
+ void SetStringCompareCond(cCond *c);
+ void SetTokenIndex(cCond *c, const char *token);
+public:
+ cCondition(const char *expression);
+ cCondition(const cCondition &other);
+ virtual ~cCondition(void);
+ void SetGlobals(cGlobals *globals) { this->globals = globals; };
+ void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) {this->tokenContainer = tokenContainer; };
+ void SetLoopInfo(cLoopInfo *loopInfo) { this->loopInfo = loopInfo; };
+ void Prepare(void);
+ bool True(void);
+ void Debug(void);
+};
+
+/******************************************************************
+* cNumericExpr
+******************************************************************/
+enum class eFactorType {
+ constant = 0,
+ stringtoken,
+ inttoken,
+ looptoken,
+ xref,
+ yref,
+ widthref,
+ heightref,
+ areawidth,
+ areaheight,
+ columnwidth,
+ rowheight
+};
+
+class cFactor: public cListObject {
+public:
+ cFactor(void) {
+ multiplication = true;
+ type = eFactorType::constant;
+ constValue = 1.0f;
+ tokenIndex = -1;
+ funcRefName = NULL;
+ funcRef = NULL;
+ };
+ cFactor(const cFactor &other) {
+ multiplication = other.multiplication;
+ type = other.type;
+ constValue = other.constValue;
+ tokenIndex = other.tokenIndex;
+ funcRefName = NULL;
+ if (other.funcRefName)
+ funcRefName = strdup(other.funcRefName);
+ funcRef = other.funcRef;
+ }
+ ~cFactor(void) {
+ free(funcRefName);
+ };
+ bool multiplication;
+ eFactorType type;
+ double constValue;
+ int tokenIndex;
+ char *funcRefName;
+ cFunction *funcRef;
+};
+
+class cSummand : public cListObject {
+public:
+ cSummand(const char *summand);
+ cSummand(const cSummand &other);
+ ~cSummand(void);
+ void Debug(void);
+ char *summand;
+ bool positive;
+ cList<cFactor> factors;
+};
+
+class cNumericExpr {
+private:
+ cGlobals *globals;
+ cRect *container;
+ skindesignerapi::cTokenContainer *tokenContainer;
+ cLoopInfo *loopInfo;
+ char *expr;
+ cList<cSummand> summands;
+ bool horizontal;
+ int value;
+ bool dynamic;
+ //common string functions
+ bool IsNumeric(const char *e);
+ bool IsNumericExpression(const char *e);
+ bool PercentValue(const char *e);
+ char *ReplacePercentValue(char *e);
+ char *ReplaceToken(char *e, const char* token, int value);
+ char *ReplaceTokens(char *e, const char* token, int value);
+ //calculate numeric expressions
+ int EvaluateExpression(char *e);
+ double EvaluateExpressionDouble(char *e);
+ double ParseAtom(char*& e);
+ double ParseFactors(char*& e);
+ double ParseSummands(char*& e);
+ //prepare expressions with tokens
+ void CreateSummands(void);
+ void CreateFactors(void);
+ bool SetTokenFactor(cFactor *f, char *tokenName);
+ bool SetReferenceFactor(cFactor *f, char *tokenName);
+ bool SetGeometryFactor(cFactor *f, char *tokenName);
+ void ConsolidateSummand(void);
+ void ConsolidateFactors(void);
+public:
+ cNumericExpr(const char *expression);
+ cNumericExpr(const cNumericExpr &other);
+ virtual ~cNumericExpr(void);
+ void SetContainer(cRect *container) { this->container = container; };
+ void SetGlobals(cGlobals *globals) { this->globals = globals; };
+ void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) { this->tokenContainer = tokenContainer; };
+ void SetLoopInfo(cLoopInfo *loopInfo) { this->loopInfo = loopInfo; };
+ void SetVertical(void) { horizontal = false; };
+ bool CacheStatic(void);
+ void PrepareTokens(void);
+ vector<cFactor*> GetRefFactors(void);
+ int GetValue(void) { return value; };
+ bool Dynamic(void) { return dynamic; };
+ int Calculate(void);
+ void Debug(void);
+};
+
+/******************************************************************
+* cColor
+******************************************************************/
+class cColor {
+private:
+ cGlobals *globals;
+ char *expr;
+ tColor value;
+public:
+ cColor(const char *expression);
+ cColor(const cColor &other);
+ virtual ~cColor(void);
+ void SetGlobals(cGlobals *globals) { this->globals = globals; };
+ void Cache(void);
+ tColor Color(void);
+ void Debug(void);
+};
+
+/******************************************************************
+* cTextExpr
+******************************************************************/
+enum class eTexttokenType {
+ constant = 0,
+ stringtoken,
+ inttoken,
+ looptoken,
+ printftoken,
+ condstringtoken,
+ condinttoken,
+};
+
+enum class ePrintfVarType {
+ stringtoken,
+ inttoken,
+ looptoken
+};
+
+struct sPrintfInfo {
+ ePrintfVarType type;
+ int index;
+};
+
+class cTextToken: public cListObject {
+public:
+ cTextToken(void) {
+ type = eTexttokenType::constant;
+ constValue = NULL;
+ printfExpr = NULL;
+ printfResult = NULL;
+ tokenIndex = -1;
+ condStart = NULL;
+ condEnd = NULL;
+ };
+ cTextToken(const cTextToken &other) {
+ type = other.type;
+ constValue = NULL;
+ if (other.constValue)
+ constValue = strdup(other.constValue);
+ printfExpr = NULL;
+ if (other.printfExpr)
+ printfExpr = strdup(other.printfExpr);
+ printfVarIndices = other.printfVarIndices;
+ printfResult = NULL;
+ if (other.printfResult)
+ printfResult = strdup(other.printfResult);
+ tokenIndex = other.tokenIndex;
+ condStart = NULL;
+ if (other.condStart)
+ condStart = strdup(other.condStart);
+ condEnd = NULL;
+ if (other.condEnd)
+ condEnd = strdup(other.condEnd);
+ };
+ ~cTextToken(void) {
+ free(constValue);
+ free(printfExpr);
+ };
+ eTexttokenType type;
+ char *constValue;
+ int tokenIndex;
+ char *printfExpr;
+ vector<sPrintfInfo> printfVarIndices;
+ char *printfResult;
+ char *condStart;
+ char *condEnd;
+};
+
+class cTextExpr {
+private:
+ cGlobals *globals;
+ skindesignerapi::cTokenContainer *tokenContainer;
+ cLoopInfo *loopInfo;
+ char *expr;
+ cList<cTextToken> textTokens;
+ void Translate(void);
+ void Tokenize(void);
+ void PrepareTokens(void);
+ bool CheckGlobals(cTextToken *t);
+ bool ParsePrintfToken(cTextToken *t);
+ void DeterminatePrintfToken(cTextToken *t);
+ void ParseCondToken(cTextToken *t);
+ char *CopyTextPart(char *start, char *stop, bool incLastChar= true);
+public:
+ cTextExpr(const char *expression);
+ cTextExpr(const cTextExpr &other);
+ virtual ~cTextExpr(void);
+ void SetGlobals(cGlobals *globals) { this->globals = globals; };
+ void SetTokenContainer(skindesignerapi::cTokenContainer *tokenContainer) { this->tokenContainer = tokenContainer; };
+ void SetLoopInfo(cLoopInfo *loopInfo) { this->loopInfo = loopInfo; };
+ void CorrectImagePath(void);
+ void Cache(void);
+ char *DeterminateText(void);
+ void Debug(const char *exprName);
+};
+
+#endif //__COMPLEXTYPES_H
\ No newline at end of file diff --git a/coreengine/definitions.h b/coreengine/definitions.h new file mode 100644 index 0000000..9490097 --- /dev/null +++ b/coreengine/definitions.h @@ -0,0 +1,1746 @@ +#ifndef __DEFINITIONS_H
+#define __DEFINITIONS_H
+
+#include <string>
+#include <map>
+
+using namespace std;
+
+typedef pair<string,string> stringpair;
+typedef map<string,string> stringmap;
+
+#define ATTR_UNKNOWN (-1)
+#define ATTR_COND (-2)
+
+/******************************************************************
+* Views
+*******************************************************************/
+enum class eViewType {
+ DisplayChannel,
+ DisplayMenu,
+ DisplayReplay,
+ DisplayVolume,
+ DisplayTracks,
+ DisplayMessage,
+ DisplayPlugin
+};
+/******************************************************************
+* ViewElements DisplayChannel
+*******************************************************************/
+enum class eVeDisplayChannel {
+ background = 0,
+ datetime,
+ time,
+ message,
+ devices,
+ currentweather,
+ customtokens,
+ channelinfo,
+ channelgroup,
+ epginfo,
+ progressbar,
+ statusinfo,
+ audioinfo,
+ screenresolution,
+ signalquality,
+ scrapercontent,
+ ecminfo,
+ count
+};
+/******************************************************************
+* ViewElements DisplayMenu
+*******************************************************************/
+enum class eVeDisplayMenu {
+ background = 0,
+ header,
+ datetime,
+ time,
+ sortmode,
+ colorbuttons,
+ message,
+ scrollbar,
+ count
+};
+
+enum class eVeDisplayMenuMain {
+ timers = eVeDisplayMenu::count,
+ devices,
+ currentweather,
+ currentschedule,
+ discusage,
+ systemload,
+ systemmemory,
+ temperatures,
+ vdrstatistics,
+ lastrecordings,
+ customtokens,
+ count
+};
+
+enum class eVeDisplayDetailedMenu {
+ detailheader = eVeDisplayMenu::count,
+ tablabels,
+ count
+};
+/******************************************************************
+* Subviews DisplayMenu
+*******************************************************************/
+enum class eSvDisplayMenu {
+ menudefault = 0,
+ main,
+ setup,
+ schedules,
+ channels,
+ timers,
+ recordings,
+ detailepg,
+ detailrec,
+ detailtext,
+ count
+};
+
+/******************************************************************
+* DisplayMessage
+*******************************************************************/
+enum class eVeDisplayMessage {
+ background = 0,
+ message,
+ count
+};
+
+/******************************************************************
+* DisplayReplay
+*******************************************************************/
+enum class eVeDisplayReplay {
+ background = 0,
+ backgroundmodeonly,
+ datetime,
+ time,
+ scrapercontent,
+ rectitle,
+ recinfo,
+ currenttime,
+ totaltime,
+ endtime,
+ progressbar,
+ cutmarks,
+ controlicons,
+ controliconsmodeonly,
+ progressmodeonly,
+ jump,
+ message,
+ onpause,
+ onpausemodeonly,
+ customtokens,
+ count
+};
+
+/******************************************************************
+* DisplayVolume
+*******************************************************************/
+enum class eVeDisplayVolume {
+ background = 0,
+ volume,
+ count
+};
+
+/******************************************************************
+* DisplayTracks
+*******************************************************************/
+enum class eVeDisplayTracks {
+ background = 0,
+ header,
+ count
+};
+
+/******************************************************************
+* Tokens common viewelements
+*******************************************************************/
+enum class eBackgroundST {
+ count
+};
+
+enum class eBackgroundIT {
+ count
+};
+
+enum class eDateTimeST {
+ time = 0,
+ dayleadingzero,
+ dayname,
+ daynameshort,
+ month,
+ monthname,
+ monthnameshort,
+ count
+};
+
+enum class eDateTimeIT {
+ day = 0,
+ year,
+ count
+};
+
+enum class eTimeST {
+ count = 0
+};
+
+enum class eTimeIT {
+ sec = 0,
+ min,
+ hour,
+ hmins,
+ count
+};
+
+enum class eMessageST {
+ text = 0,
+ count
+};
+
+enum class eMessageIT {
+ status = 0,
+ info,
+ warning,
+ error,
+ count
+};
+
+enum class eDevicesLT {
+ num = 0,
+ type,
+ istuned,
+ livetv,
+ recording,
+ hascam,
+ cam,
+ signalstrength,
+ signalquality,
+ channelnumber,
+ channelname,
+ channellogoexists,
+ channelid,
+ source,
+ count
+};
+
+enum class eDevicesIT {
+ numdevices = 0,
+ count
+};
+
+enum class eCurrentWeatherST {
+ timestamp = 0,
+ summary,
+ icon,
+ precipitationtype,
+ windbearingstring,
+ temperature,
+ apparenttemperature,
+ mintemperature,
+ maxtemperature,
+ precipitationintensity,
+ windspeed,
+ visibility,
+ pressure,
+ ozone,
+ count
+};
+
+enum class eCurrentWeatherIT {
+ precipitationprobability = 0,
+ humidity,
+ windbearing,
+ cloudcover,
+ count
+};
+
+enum class eScraperPosterBannerST {
+ posterpath = 0,
+ bannerpath,
+ mediapath,
+ count
+};
+
+enum class eScraperPosterBannerIT {
+ posterwidth = 0,
+ posterheight,
+ hasposter,
+ bannerwidth,
+ bannerheight,
+ hasbanner,
+ mediawidth,
+ mediaheight,
+ isbanner,
+ count
+};
+
+/******************************************************************
+* Tokens displaychannel viewelements
+*******************************************************************/
+enum class eDCChannelInfoST {
+ channelnumber = 0,
+ channelname,
+ channelid,
+ count
+};
+
+enum class eDCChannelInfoIT {
+ channellogoexists = 0,
+ switching,
+ count
+};
+
+enum class eDCEpgInfoST {
+ currenttitle = 0,
+ currentsubtitle,
+ currentstart,
+ currentstop,
+ nexttitle,
+ nextsubtitle,
+ nextstart,
+ nextstop,
+ count
+};
+
+enum class eDCEpgInfoIT {
+ currentduration = 0,
+ currentdurationhours,
+ currentdurationminutes,
+ currentelapsed,
+ currentremaining,
+ nextduration,
+ nextdurationhours,
+ nextdurationminutes,
+ nextrecording,
+ currentrecording,
+ hasVPS,
+ count
+};
+
+enum class eDCProgressBarST {
+ start = 0,
+ stop,
+ count
+};
+
+enum class eDCProgressBarIT {
+ duration = 0,
+ elapsed,
+ remaining,
+ permashift,
+ livebuffer,
+ count
+};
+
+enum class eDCStatusInfoST {
+ count
+};
+
+enum class eDCStatusInfoIT {
+ isRadio = 0,
+ hasVT,
+ isStereo,
+ isDolby,
+ isEncrypted,
+ isRecording,
+ newmails,
+ count
+};
+
+enum class eDCAudioInfoST {
+ trackdesc = 0,
+ tracklang,
+ count
+};
+
+enum class eDCAudioInfoIT {
+ numaudiotracks = 0,
+ audiochannel,
+ count
+};
+
+enum class eDCEcmInfoST {
+ cardsystem = 0,
+ reader,
+ from,
+ protocol,
+ count
+};
+
+enum class eDCEcmInfoIT {
+ caid = 0,
+ pid,
+ prid,
+ ecmtime,
+ hops,
+ count
+};
+
+enum class eDCScreenResolutionST {
+ resolution = 0,
+ aspect,
+ count
+};
+
+enum class eDCScreenResolutionIT {
+ screenwidth = 0,
+ screenheight,
+ isHD,
+ isWideScreen,
+ count
+};
+
+enum class eDCChannelGroupST {
+ group = 0,
+ nextgroup,
+ prevgroup,
+ seppath,
+ count
+};
+
+enum class eDCChannelGroupIT {
+ prevAvailable = 0,
+ nextAvailable,
+ sepexists,
+ count
+};
+
+enum class eDCSignalQualityST {
+ count = 0
+};
+
+enum class eDCSignalQualityIT {
+ signalstrength = 0,
+ signalquality,
+ count
+};
+
+/******************************************************************
+* Tokens displaymenu viewelements
+*******************************************************************/
+enum class eDMHeaderST {
+ title = 0,
+ vdrversion,
+ icon,
+ freetime,
+ vdrusagestring,
+ channelname,
+ channelid,
+ count
+};
+
+enum class eDMHeaderIT {
+ hasicon = 0,
+ freepercent,
+ usedpercent,
+ freegb,
+ discalert,
+ channelnumber,
+ channellogoexists,
+ whatson,
+ whatsonnow,
+ whatsonnext,
+ whatsonfavorites,
+ count
+};
+
+enum class eDMSortmodeST {
+ count = 0
+};
+
+enum class eDMSortmodeIT {
+ sortnumber = 0,
+ sortname,
+ sorttime,
+ sortprovider,
+ count
+};
+
+enum class eDMColorbuttonsST {
+ red = 0,
+ green,
+ yellow,
+ blue,
+ count
+};
+
+enum class eDMColorbuttonsIT {
+ red1 = 0, red2, red3, red4,
+ green1, green2, green3, green4,
+ yellow1, yellow2, yellow3, yellow4,
+ blue1, blue2, blue3, blue4,
+ count
+};
+
+enum class eDMScrollbarST {
+ count = 0
+};
+
+enum class eDMScrollbarIT {
+ height = 0,
+ offset,
+ hasprev,
+ hasnext,
+ count
+};
+
+enum class eDMTimersIT {
+ numtimers = 0,
+ numtimerconflicts,
+ timer1exists, timer2exists, timer3exists, timer4exists, timer5exists,
+ timer6exists, timer7exists, timer8exists, timer9exists, timer10exists,
+ timer11exists, timer12exists, timer13exists, timer14exists, timer15exists,
+ count
+};
+
+enum class eDMTimersLT {
+ title = 0,
+ datetime,
+ recording,
+ channelname,
+ channelnumber,
+ channelid,
+ channellogoexists,
+ isremotetimer,
+ count
+};
+
+enum class eDMCurrentscheduleIT {
+ islivetv = eScraperPosterBannerIT::count,
+ duration,
+ durationhours,
+ minutes,
+ elapsed,
+ remaining,
+ count
+};
+
+enum class eDMCurrentscheduleST {
+ title = eScraperPosterBannerST::count,
+ subtitle,
+ start,
+ stop,
+ durationminutes,
+ count
+};
+
+enum class eDMLastrecordingsIT {
+ numtimers = 0,
+ count
+};
+
+enum class eDMLastrecordingsLT {
+ name = 0,
+ seriesname,
+ date,
+ time,
+ duration,
+ hasposter,
+ posterpath,
+ posterwidth,
+ posterheight,
+ count
+};
+
+enum class eDMDiscusageST {
+ freetime = 0,
+ vdrusagestring,
+ count
+};
+
+enum class eDMDiscusageIT {
+ freepercent = 0,
+ usedpercent,
+ freegb,
+ discalert,
+ count
+};
+
+enum class eDMSystemloadST {
+ load = 0,
+ count
+};
+
+enum class eDMSystemloadIT {
+ loadhand = 0,
+ count
+};
+
+enum class eDMSystemmemoryST {
+ count = 0
+};
+
+enum class eDMSystemmemoryIT {
+ totalmem = 0,
+ usedmem,
+ usedmempercent,
+ count
+};
+
+enum class eDMVdrstatisticsST {
+ vdrcpu = 0,
+ vdrmem,
+ count
+};
+
+enum class eDMVdrstatisticsIT {
+ count = 0
+};
+
+enum class eDMTemperaturesST {
+ count = 0
+};
+
+enum class eDMTemperaturesIT {
+ cputemp = 0,
+ gputemp,
+ count
+};
+
+/******************************************************************
+* Tokens displaymenu listelements
+*******************************************************************/
+enum class eLeMenuDefaultST {
+ column1 = 0,
+ column2,
+ column3,
+ column4,
+ column5,
+ column6,
+ count
+};
+
+enum class eLeMenuDefaultIT {
+ nummenuitem = 0,
+ current,
+ separator,
+ column2set,
+ column3set,
+ column4set,
+ column5set,
+ column6set,
+ column1x,
+ column2x,
+ column3x,
+ column4x,
+ column5x,
+ column6x,
+ column1width,
+ column2width,
+ column3width,
+ column4width,
+ column5width,
+ column6width,
+ column1pb,
+ column2pb,
+ column3pb,
+ column4pb,
+ column5pb,
+ column6pb,
+ column1pbtotalsize,
+ column2pbtotalsize,
+ column3pbtotalsize,
+ column4pbtotalsize,
+ column5pbtotalsize,
+ column6pbtotalsize,
+ column1pbsize,
+ column2pbsize,
+ column3pbsize,
+ column4pbsize,
+ column5pbsize,
+ column6pbsize,
+ setup,
+ commands,
+ fritzbox,
+ systeminfo,
+ mailbox,
+ neutrinoepg,
+ remotetimers,
+ count
+};
+
+enum class eLeMenuMainST {
+ label = 0,
+ number,
+ icon,
+ count
+};
+
+enum class eLeMenuMainIT {
+ nummenuitem = 0,
+ current,
+ separator,
+ count
+};
+
+enum class eCeMenuMainST {
+ label = 0,
+ number,
+ icon,
+ count
+};
+
+enum class eCeMenuMainIT {
+ menuitemx = 0,
+ menuitemy,
+ menuitemwidth,
+ menuitemheight,
+ count
+};
+
+enum class eLeMenuSchedulesST {
+ title = 0,
+ shorttext,
+ start,
+ stop,
+ day,
+ date,
+ durationminutes,
+ channelname,
+ channelid,
+ count
+};
+
+enum class eLeMenuSchedulesIT {
+ nummenuitem = 0,
+ current,
+ separator,
+ daynumeric,
+ month,
+ year,
+ running,
+ elapsed,
+ startsin,
+ duration,
+ durationhours,
+ channelnumber,
+ channellogoexists,
+ whatson,
+ whatsonnow,
+ whatsonnext,
+ whatsonfavorites,
+ timerpartitial,
+ timerfull,
+ hasVPS,
+ count
+};
+
+enum class eCeMenuSchedulesST {
+ title = 0,
+ shorttext,
+ description,
+ start,
+ stop,
+ day,
+ date,
+ channelname,
+ channelid,
+ posterpath,
+ bannerpath,
+ count
+};
+
+enum class eCeMenuSchedulesLT {
+ title = 0,
+ shorttext,
+ start,
+ stop,
+ count
+};
+
+enum class eCeMenuSchedulesIT {
+ menuitemx = 0,
+ menuitemy,
+ menuitemwidth,
+ menuitemheight,
+ daynumeric,
+ month,
+ year,
+ running,
+ elapsed,
+ duration,
+ durationhours,
+ durationminutes,
+ channelnumber,
+ channellogoexists,
+ hasposter,
+ posterwidth,
+ posterheight,
+ hasbanner,
+ bannerwidth,
+ bannerheight,
+ whatson,
+ whatsonnow,
+ whatsonnext,
+ whatsonfavorites,
+ timerpartitial,
+ timerfull,
+ count
+};
+
+enum class eLeMenuChannelsST {
+ name = 0,
+ channelid,
+ source,
+ sourcedescription,
+ position,
+ presenteventtitle,
+ presenteventstart,
+ presenteventstop,
+ count
+};
+
+enum class eLeMenuChannelsIT {
+ nummenuitem = 0,
+ current,
+ separator,
+ number,
+ transponder,
+ frequency,
+ channellogoexists,
+ isAtsc,
+ isCable,
+ isSat,
+ isTerr,
+ count
+};
+
+enum class eCeMenuChannelsST {
+ name = 0,
+ channelid,
+ source,
+ sourcedescription,
+ position,
+ presenteventtitle,
+ presenteventstart,
+ presenteventstop,
+ presenteventshorttext,
+ presenteventdescription,
+ presenteventday,
+ presenteventdate,
+ presenteventdurationminutes,
+ posterpath,
+ nexteventtitle,
+ nexteventstart,
+ nexteventstop,
+ nexteventshorttext,
+ nexteventdescription,
+ nexteventday,
+ nexteventdate,
+ nexteventdurationminutes,
+ count
+};
+
+enum class eCeMenuChannelsIT {
+ menuitemx = 0,
+ menuitemy,
+ menuitemwidth,
+ menuitemheight,
+ number,
+ transponder,
+ frequency,
+ channellogoexists,
+ isAtsc,
+ isCable,
+ isSat,
+ isTerr,
+ presenteventduration,
+ presenteventdurationhours,
+ presenteventelapsed,
+ hasposter,
+ posterwidth,
+ posterheight,
+ nexteventduration,
+ nexteventdurationhours,
+ count
+};
+
+enum class eCeMenuChannelsLT {
+ title = 0,
+ shorttext,
+ start,
+ stop,
+ count
+};
+
+enum class eLeMenuTimersST {
+ title = 0,
+ timerstart,
+ timerstop,
+ day,
+ dayname,
+ monthname,
+ channelname,
+ channelid,
+ eventtitle,
+ eventstart,
+ eventstop,
+ count
+};
+
+enum class eLeMenuTimersIT {
+ nummenuitem = 0,
+ current,
+ separator,
+ month,
+ year,
+ channellogoexists,
+ channelnumber,
+ flagactive,
+ flaginstant,
+ flagvps,
+ flagrecording,
+ flagpending,
+ count
+};
+
+enum class eCeMenuTimersST {
+ title = 0,
+ timerstart,
+ timerstop,
+ day,
+ dayname,
+ monthname,
+ channelname,
+ channelid,
+ eventtitle,
+ eventstart,
+ eventstop,
+ eventshorttext,
+ eventdescription,
+ posterpath,
+ count
+};
+
+enum class eCeMenuTimersIT {
+ menuitemx = 0,
+ menuitemy,
+ menuitemwidth,
+ menuitemheight,
+ month,
+ year,
+ channellogoexists,
+ channelnumber,
+ flagactive,
+ flaginstant,
+ flagvps,
+ flagrecording,
+ flagpending,
+ hasposter,
+ posterwidth,
+ posterheight,
+ count
+};
+
+enum class eLeMenuRecordingsST {
+ name = 0,
+ epgname,
+ shorttext,
+ description,
+ date,
+ time,
+ durationminutes,
+ durationeventminutes,
+ thumbnailpath,
+ posterpath,
+ count
+};
+
+enum class eLeMenuRecordingsIT {
+ nummenuitem = 0,
+ current,
+ isnew,
+ percentseen,
+ watched,
+ cutted,
+ folder,
+ daynumeric,
+ month,
+ year,
+ duration,
+ durationhours,
+ durationevent,
+ durationeventhours,
+ numrecordingsfolder,
+ newrecordingsfolder,
+ hasposterthumbnail,
+ thumbnailwidth,
+ thumbnailheight,
+ hasposter,
+ posterwidth,
+ posterheight,
+ count
+};
+
+enum class eCeMenuRecordingsST {
+ name = 0,
+ epgname,
+ shorttext,
+ description,
+ date,
+ time,
+ durationminutes,
+ durationeventminutes,
+ thumbnailpath,
+ posterpath,
+ count
+};
+
+enum class eCeMenuRecordingsIT {
+ menuitemx = 0,
+ menuitemy,
+ menuitemwidth,
+ menuitemheight,
+ isnew,
+ percentseen,
+ watched,
+ cutted,
+ folder,
+ daynumeric,
+ month,
+ year,
+ duration,
+ durationhours,
+ durationevent,
+ durationeventhours,
+ numrecordingsfolder,
+ newrecordingsfolder,
+ hasposterthumbnail,
+ thumbnailwidth,
+ thumbnailheight,
+ hasposter,
+ posterwidth,
+ posterheight,
+ count
+};
+
+/******************************************************************
+* Tokens displaymenu detailed views
+*******************************************************************/
+enum class eScraperHeaderST {
+ posterpath = 0,
+ bannerpath,
+ count
+};
+
+enum class eScraperHeaderIT {
+ ismovie = 0,
+ isseries,
+ posteravailable,
+ posterwidth,
+ posterheight,
+ banneravailable,
+ bannerwidth,
+ bannerheight,
+ count
+};
+
+enum class eDmDetailedHeaderEpgST {
+ title = eScraperHeaderST::count,
+ shorttext,
+ start,
+ stop,
+ day,
+ date,
+ durationminutes,
+ vps,
+ channelname,
+ channelid,
+ epgpicpath,
+ count
+};
+
+enum class eDmDetailedHeaderEpgIT {
+ daynumeric = eScraperHeaderIT::count,
+ month,
+ year,
+ running,
+ elapsed,
+ duration,
+ durationhours,
+ channelnumber,
+ channellogoexists,
+ epgpicavailable,
+ count
+};
+
+enum class eDmDetailedHeaderRecST {
+ name = eScraperHeaderST::count,
+ epgname,
+ shorttext,
+ date,
+ time,
+ recimgpath,
+ recchannelname,
+ recchannelid,
+ durationminutes,
+ durationeventminutes,
+ count
+};
+
+enum class eDmDetailedHeaderRecIT {
+ daynumeric = eScraperHeaderIT::count,
+ month,
+ year,
+ duration,
+ durationhours,
+ durationevent,
+ durationeventhours,
+ recimgavailable,
+ recchannelnumber,
+ count
+};
+
+enum class eDmTabsIT {
+ count = 0,
+};
+
+enum class eDmTabsST {
+ currenttab = 0,
+ prevtab,
+ nexttab,
+ count
+};
+
+enum class eDmTabsLT {
+ title = 0,
+ current,
+ count
+};
+
+enum class eScraperST {
+ movietitle = 0,
+ movieoriginalTitle,
+ movietagline,
+ movieoverview,
+ moviegenres,
+ moviehomepage,
+ moviereleasedate,
+ moviepopularity,
+ movievoteaverage,
+ posterpath,
+ fanartpath,
+ moviecollectionName,
+ collectionposterpath,
+ collectionfanartpath,
+ seriesname,
+ seriesoverview,
+ seriesfirstaired,
+ seriesnetwork,
+ seriesgenre,
+ seriesrating,
+ seriesstatus,
+ episodetitle,
+ episodefirstaired,
+ episodegueststars,
+ episodeoverview,
+ episoderating,
+ episodeimagepath,
+ seasonposterpath,
+ seriesposter1path,
+ seriesposter2path,
+ seriesposter3path,
+ seriesfanart1path,
+ seriesfanart2path,
+ seriesfanart3path,
+ seriesbanner1path,
+ seriesbanner2path,
+ seriesbanner3path,
+ count
+};
+
+enum class eScraperIT {
+ ismovie = 0,
+ moviebudget,
+ movierevenue,
+ movieadult,
+ movieruntime,
+ isseries,
+ posterwidth,
+ posterheight,
+ fanartwidth,
+ fanartheight,
+ movieiscollection,
+ collectionposterwidth,
+ collectionposterheight,
+ collectionfanartwidth,
+ collectionfanartheight,
+ epgpicavailable,
+ episodenumber,
+ episodeseason,
+ episodeimagewidth,
+ episodeimageheight,
+ seasonposterwidth,
+ seasonposterheight,
+ seriesposter1width,
+ seriesposter1height,
+ seriesposter2width,
+ seriesposter2height,
+ seriesposter3width,
+ seriesposter3height,
+ seriesfanart1width,
+ seriesfanart1height,
+ seriesfanart2width,
+ seriesfanart2height,
+ seriesfanart3width,
+ seriesfanart3height,
+ seriesbanner1width,
+ seriesbanner1height,
+ seriesbanner2width,
+ seriesbanner2height,
+ seriesbanner3width,
+ seriesbanner3height,
+ count
+};
+
+enum class eScraperLT {
+ //actors
+ name = 0,
+ role,
+ thumb,
+ thumbwidth,
+ thumbheight,
+ count
+};
+
+enum class eDmDetailedEpgST {
+ title = eScraperST::count,
+ shorttext,
+ description,
+ start,
+ stop,
+ day,
+ date,
+ durationminutes,
+ vps,
+ channelname,
+ channelid,
+ epgpic1path,
+ epgpic2path,
+ epgpic3path,
+ count
+};
+
+enum class eDmDetailedEpgIT {
+ daynumeric = eScraperIT::count,
+ month,
+ year,
+ running,
+ elapsed,
+ duration,
+ durationhours,
+ channelnumber,
+ channellogoexists,
+ hasreruns,
+ epgpic1avaialble,
+ epgpic2avaialble,
+ epgpic3avaialble,
+ count
+};
+
+enum class eRerunsLT {
+ title = 0,
+ shorttext,
+ date,
+ day,
+ start,
+ stop,
+ channelname,
+ channelnumber,
+ channelid,
+ channellogoexists,
+ count
+};
+
+enum class eDmDetailedRecST {
+ name = eScraperST::count,
+ epgname,
+ shorttext,
+ description,
+ day,
+ date,
+ time,
+ durationminutes,
+ durationeventminutes,
+ recordingsize,
+ recordingsizecutted,
+ recordinglength,
+ recordinglengthcutted,
+ recordingbitrate,
+ recordingformat,
+ recchannelname,
+ recchannelid,
+ searchtimer,
+ recimg1path,
+ recimg2path,
+ recimg3path,
+ count
+};
+
+enum class eDmDetailedRecIT {
+ daynumeric = eScraperIT::count,
+ month,
+ year,
+ duration,
+ durationhours,
+ durationevent,
+ durationeventhours,
+ cutted,
+ recchannelnumber,
+ recimg1avaialble,
+ recimg2avaialble,
+ recimg3avaialble,
+ count
+};
+
+enum class eDmDetailedTextST {
+ text = 0,
+ count
+};
+
+enum class eDmSkinPreviewST {
+ menuheader = 0,
+ skinname,
+ author,
+ count
+};
+
+enum class eDmSkinPreviewFontsLT {
+ name = 0,
+ installed,
+ count
+};
+
+enum class eDmSkinPreviewPluginsLT {
+ name = 0,
+ count
+};
+
+enum class eDmSkinPreviewScreenshotsLT {
+ desc = 0,
+ path,
+ count
+};
+/******************************************************************
+* Tokens DisplayReplay Viewelements
+*******************************************************************/
+enum class eDRRecTitleST {
+ rectitle = 0,
+ recsubtitle,
+ recdate,
+ rectime,
+ count
+};
+
+enum class eDRRecInfoST {
+ resolution = 0,
+ aspect,
+ count
+};
+
+enum class eDRRecInfoIT {
+ screenwidth = 0,
+ screenheight,
+ isHD,
+ isWideScreen,
+ count
+};
+
+enum class eDRCurrentTimeST {
+ reccurrent = 0,
+ count
+};
+
+enum class eDRTotalTimeST {
+ rectotal = 0,
+ timeshifttotal,
+ count
+};
+
+enum class eDRTotalTimeIT {
+ timeshift = 0,
+ count
+};
+
+enum class eDREndTimeST {
+ recend = 0,
+ count
+};
+
+enum class eDRProgressbarIT {
+ current = 0,
+ total,
+ timeshift,
+ timeshifttotal,
+ count
+};
+
+enum class eDRCutmarksIT {
+ timeshift = 0,
+ count
+};
+
+enum class eDRCutmarksLT {
+ position = 0,
+ endposition,
+ total,
+ timeshifttotal,
+ active,
+ startmark,
+ count
+};
+
+enum class eDRControlIconsIT {
+ play = 0,
+ pause,
+ forward,
+ forward1x,
+ forward2x,
+ forward3x,
+ rewind,
+ rewind1x,
+ rewind2x,
+ rewind3x,
+ count
+};
+
+enum class eDRProgressModeonlyIT {
+ current = 0,
+ total,
+ count
+};
+
+enum class eDRProgressModeonlyST {
+ timecurrent = 0,
+ timetotal,
+ count
+};
+
+enum class eDRJumpST {
+ jump = 0,
+ count
+};
+
+enum class eDROnpauseST {
+ name = eScraperST::count,
+ shorttext,
+ description,
+ date,
+ time,
+ durationminutes,
+ durationeventminutes,
+ count
+};
+
+enum class eDROnpauseIT {
+ daynumeric = eScraperIT::count,
+ month,
+ year,
+ duration,
+ durationhours,
+ durationevent,
+ durationeventhours,
+ count
+};
+
+/******************************************************************
+* Tokens DisplayVolume Viewelements
+*******************************************************************/
+enum class eDVVolumeIT {
+ volume = 0,
+ volpercent,
+ maxvolume,
+ mute,
+ count
+};
+
+/******************************************************************
+* Tokens DisplayTracks Viewelements
+*******************************************************************/
+enum class eDTBackgroundIT {
+ numtracks = 0,
+ count
+};
+
+enum class eDTHeaderIT {
+ numtracks = 0,
+ isstereo,
+ isac3,
+ count
+};
+
+enum class eDTHeaderST {
+ title = 0,
+ count
+};
+
+enum class eLeDisplayTracksIT {
+ nummenuitem = 0,
+ current,
+ count
+};
+
+enum class eLeDisplayTracksST {
+ title = 0,
+ count
+};
+/******************************************************************
+* Attributes
+*******************************************************************/
+enum class eCommonAttribs {
+ x = 0,
+ y,
+ width,
+ height,
+ debug,
+ count
+};
+
+enum class eViewAttribs {
+ fadetime = 0,
+ shifttime,
+ shifttype,
+ shiftmode,
+ startx,
+ starty,
+ scaletvx,
+ scaletvy,
+ scaletvwidth,
+ scaletvheight,
+ orientation,
+ debuggrid,
+ hideroot,
+ count
+};
+
+enum class eViewElementAttribs {
+ delay = 0,
+ fadetime,
+ shifttime,
+ shifttype,
+ shiftmode,
+ startx,
+ starty,
+ mode,
+ orientation,
+ name,
+ count
+};
+
+enum class eViewListAttribs {
+ align = 0,
+ menuitemwidth,
+ determinatefont,
+ numlistelements,
+ orientation,
+ condition,
+ count
+};
+
+enum class eAreaAttribs {
+ layer = 0,
+ transparency,
+ mode,
+ orientation,
+ scrollelement,
+ scrollspeed,
+ delay,
+ background,
+ name,
+ scrollheight,
+ count
+};
+
+enum class eAreaContainerAttribs {
+ count = 0
+};
+
+/******************************************************************
+* Functions
+*******************************************************************/
+enum class eFillAttribs {
+ color = 0,
+ count
+};
+
+enum class eDrawRectangleAttribs {
+ align = 0,
+ valign,
+ color,
+ name,
+ animtype,
+ animfreq,
+ count
+};
+
+enum class eDrawEllipseAttribs {
+ align = 0,
+ valign,
+ color,
+ name,
+ quadrant,
+ animtype,
+ animfreq,
+ count
+};
+
+enum class eDrawSlopeAttribs {
+ align = 0,
+ valign,
+ color,
+ name,
+ type,
+ animtype,
+ animfreq,
+ count
+};
+
+enum class eDrawTextAttribs {
+ align = 0,
+ valign,
+ color,
+ font,
+ fontsize,
+ name,
+ text,
+ animtype,
+ animfreq,
+ count
+};
+
+enum class eDrawTextAttribsVertical {
+ align = 0,
+ valign,
+ direction,
+ color,
+ font,
+ fontsize,
+ name,
+ text,
+ animtype,
+ animfreq,
+ count
+};
+
+enum class eDrawTextBoxAttribs {
+ align = 0,
+ valign,
+ maxlines,
+ floatwidth,
+ floatheight,
+ floatmode,
+ color,
+ font,
+ fontsize,
+ name,
+ text,
+ count
+};
+
+enum class eDrawImageAttribs {
+ align = 0,
+ valign,
+ imagetype,
+ name,
+ cache,
+ path,
+ animtype,
+ animfreq,
+ count
+};
+
+enum class eLoopAttribs {
+ columnwidth = 0,
+ rowheight,
+ name,
+ orientation,
+ overflow,
+ maxitems,
+ count
+};
+
+/******************************************************************
+* Common Parameters
+*******************************************************************/
+enum class eViewElementMode {
+ regular,
+ light
+};
+
+enum class eShiftType {
+ none = -1,
+ left,
+ right,
+ top,
+ bottom
+};
+
+enum class eShiftMode {
+ linear,
+ slowedDown
+};
+
+enum class eScrollMode {
+ none,
+ carriagereturn,
+ forthandback
+};
+
+enum class eScrollSpeed {
+ none,
+ slow,
+ medium,
+ fast
+};
+
+enum class eOrientation {
+ none,
+ horizontal,
+ vertical,
+ absolute
+};
+
+enum class eAlign {
+ left,
+ center,
+ right,
+ top,
+ bottom
+};
+
+enum class eAnimType {
+ none,
+ blink,
+ animated
+};
+
+enum class eImageType {
+ channellogo,
+ seplogo,
+ skinpart,
+ menuicon,
+ icon,
+ image
+};
+
+enum class eOverflowType {
+ none,
+ wrap,
+ cut
+};
+
+enum class eFloatMode {
+ none = -1,
+ topleft,
+ topright
+};
+
+enum class eDirection {
+ none = -1,
+ bottomup,
+ topdown
+};
+
+
+#endif //__DEFINITIONS_H
\ No newline at end of file diff --git a/coreengine/functions.c b/coreengine/functions.c new file mode 100644 index 0000000..f8b8d47 --- /dev/null +++ b/coreengine/functions.c @@ -0,0 +1,1565 @@ +#define __STL_CONFIG_H
+#include "attribute.h"
+#include "../config.h"
+
+/***************************************************************************
+* cFuncFill
+***************************************************************************/
+cFuncFill::cFuncFill(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "Fill";
+ SetAttributesDefs();
+}
+
+cFuncFill::cFuncFill(const cFuncFill &other) : cFunction(other) {
+ funcType = other.funcType;
+}
+
+cFuncFill::~cFuncFill(void) {
+}
+
+void cFuncFill::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func Fill attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eFillAttribs::color)) {
+ SetColor(attVal);
+ }
+ }
+}
+
+void cFuncFill::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("color", (int)eFillAttribs::color));
+ attribNames.insert(pair<int, string>((int)eFillAttribs::color, "color"));
+}
+
+void cFuncFill::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ if (!color)
+ return;
+ p->Fill(color->Color());
+}
+
+/***************************************************************************
+* cFuncDrawRectangle
+***************************************************************************/
+cFuncDrawRectangle::cFuncDrawRectangle(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "DrawRectangle";
+ SetAttributesDefs();
+}
+
+cFuncDrawRectangle::cFuncDrawRectangle(const cFuncDrawRectangle &other) : cFunction(other) {
+ funcType = other.funcType;
+}
+
+cFuncDrawRectangle::~cFuncDrawRectangle(void) {
+}
+
+void cFuncDrawRectangle::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func DrawRectangle attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eDrawRectangleAttribs::color)) {
+ SetColor(attVal);
+ } else if (IdEqual(id, (int)eDrawRectangleAttribs::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawRectangleAttribs::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawRectangleAttribs::valign)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawRectangleAttribs::animtype)) {
+ SetAnimType(id, attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncDrawRectangle::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eDrawRectangleAttribs::align));
+ attribIDs.insert(pair<string, int>("valign", (int)eDrawRectangleAttribs::valign));
+ attribIDs.insert(pair<string, int>("color", (int)eDrawRectangleAttribs::color));
+ attribIDs.insert(pair<string, int>("name", (int)eDrawRectangleAttribs::name));
+ attribIDs.insert(pair<string, int>("animtype", (int)eDrawRectangleAttribs::animtype));
+ attribIDs.insert(pair<string, int>("animfreq", (int)eDrawRectangleAttribs::animfreq));
+ attribNames.insert(pair<int, string>((int)eDrawRectangleAttribs::align, "align"));
+ attribNames.insert(pair<int, string>((int)eDrawRectangleAttribs::valign, "valign"));
+ attribNames.insert(pair<int, string>((int)eDrawRectangleAttribs::color, "color"));
+ attribNames.insert(pair<int, string>((int)eDrawRectangleAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eDrawRectangleAttribs::animtype, "animtype"));
+ attribNames.insert(pair<int, string>((int)eDrawRectangleAttribs::animfreq, "animfreq"));
+}
+
+void cFuncDrawRectangle::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ eAlign align = (eAlign)GetValue((int)eDrawRectangleAttribs::align);
+ eAlign valign = (eAlign)GetValue((int)eDrawRectangleAttribs::valign);
+ int x = GetX(align, x0, colWidth);
+ int y = GetY(valign, y0, rowHeight);
+ cRect rect(x, y, Width(), Height());
+ p->DrawRectangle(rect, color->Color());
+}
+
+/***************************************************************************
+* cFuncDrawEllipse
+***************************************************************************/
+cFuncDrawEllipse::cFuncDrawEllipse(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "DrawEllipse";
+ SetAttributesDefs();
+}
+
+cFuncDrawEllipse::cFuncDrawEllipse(const cFuncDrawEllipse &other) : cFunction(other) {
+ funcType = other.funcType;
+}
+
+cFuncDrawEllipse::~cFuncDrawEllipse(void) {
+}
+
+void cFuncDrawEllipse::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func DrawEllipse attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eDrawEllipseAttribs::color)) {
+ SetColor(attVal);
+ } else if (IdEqual(id, (int)eDrawEllipseAttribs::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawEllipseAttribs::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawEllipseAttribs::valign)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawEllipseAttribs::animtype)) {
+ SetAnimType(id, attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncDrawEllipse::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eDrawEllipseAttribs::align));
+ attribIDs.insert(pair<string, int>("valign", (int)eDrawEllipseAttribs::valign));
+ attribIDs.insert(pair<string, int>("color", (int)eDrawEllipseAttribs::color));
+ attribIDs.insert(pair<string, int>("name", (int)eDrawEllipseAttribs::name));
+ attribIDs.insert(pair<string, int>("quadrant", (int)eDrawEllipseAttribs::quadrant));
+ attribIDs.insert(pair<string, int>("animtype", (int)eDrawEllipseAttribs::animtype));
+ attribIDs.insert(pair<string, int>("animfreq", (int)eDrawEllipseAttribs::animfreq));
+ attribNames.insert(pair<int, string>((int)eDrawEllipseAttribs::align, "align"));
+ attribNames.insert(pair<int, string>((int)eDrawEllipseAttribs::valign, "valign"));
+ attribNames.insert(pair<int, string>((int)eDrawEllipseAttribs::color, "color"));
+ attribNames.insert(pair<int, string>((int)eDrawEllipseAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eDrawEllipseAttribs::quadrant, "quadrant"));
+ attribNames.insert(pair<int, string>((int)eDrawEllipseAttribs::animtype, "animtype"));
+ attribNames.insert(pair<int, string>((int)eDrawEllipseAttribs::animfreq, "animfreq"));
+}
+
+void cFuncDrawEllipse::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ eAlign align = (eAlign)GetValue((int)eDrawEllipseAttribs::align);
+ eAlign valign = (eAlign)GetValue((int)eDrawEllipseAttribs::valign);
+ int x = GetX(align, x0, colWidth);
+ int y = GetY(valign, y0, rowHeight);
+ cRect rect(x, y, Width(), Height());
+ int quadrant = GetValue((int)eDrawEllipseAttribs::quadrant);
+ p->DrawEllipse(rect, color->Color(), quadrant);
+}
+
+/***************************************************************************
+* cFuncDrawSlope
+***************************************************************************/
+cFuncDrawSlope::cFuncDrawSlope(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "DrawSlope";
+ SetAttributesDefs();
+}
+
+cFuncDrawSlope::cFuncDrawSlope(const cFuncDrawSlope &other) : cFunction(other) {
+ funcType = other.funcType;
+}
+
+cFuncDrawSlope::~cFuncDrawSlope(void) {
+}
+
+void cFuncDrawSlope::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func DrawSlope attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eDrawSlopeAttribs::color)) {
+ SetColor(attVal);
+ } else if (IdEqual(id, (int)eDrawSlopeAttribs::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawSlopeAttribs::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawSlopeAttribs::valign)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawSlopeAttribs::animtype)) {
+ SetAnimType(id, attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncDrawSlope::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eDrawSlopeAttribs::align));
+ attribIDs.insert(pair<string, int>("valign", (int)eDrawSlopeAttribs::valign));
+ attribIDs.insert(pair<string, int>("color", (int)eDrawSlopeAttribs::color));
+ attribIDs.insert(pair<string, int>("name", (int)eDrawSlopeAttribs::name));
+ attribIDs.insert(pair<string, int>("type", (int)eDrawSlopeAttribs::type));
+ attribIDs.insert(pair<string, int>("animtype", (int)eDrawSlopeAttribs::animtype));
+ attribIDs.insert(pair<string, int>("animfreq", (int)eDrawSlopeAttribs::animfreq));
+ attribNames.insert(pair<int, string>((int)eDrawSlopeAttribs::align, "align"));
+ attribNames.insert(pair<int, string>((int)eDrawSlopeAttribs::valign, "valign"));
+ attribNames.insert(pair<int, string>((int)eDrawSlopeAttribs::color, "color"));
+ attribNames.insert(pair<int, string>((int)eDrawSlopeAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eDrawSlopeAttribs::type, "type"));
+ attribNames.insert(pair<int, string>((int)eDrawSlopeAttribs::animtype, "animtype"));
+ attribNames.insert(pair<int, string>((int)eDrawSlopeAttribs::animfreq, "animfreq"));
+}
+
+void cFuncDrawSlope::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ eAlign align = (eAlign)GetValue((int)eDrawSlopeAttribs::align);
+ eAlign valign = (eAlign)GetValue((int)eDrawSlopeAttribs::valign);
+ int x = GetX(align, x0, colWidth);
+ int y = GetY(valign, y0, rowHeight);
+ cRect rect(x, y, Width(), Height());
+ int type = GetValue((int)eDrawSlopeAttribs::type);
+ p->DrawSlope(rect, color->Color(), type);
+}
+
+/***************************************************************************
+* cTextDrawer
+***************************************************************************/
+cMutex cTextDrawer::fontLock;
+
+cTextDrawer::cTextDrawer(void) {
+ font = NULL;
+ fontName = NULL;
+ fontSize = 0;
+}
+
+cTextDrawer::~cTextDrawer(void) {
+ free(fontName);
+}
+
+void cTextDrawer::CacheFont(cGlobals *globals, int size) {
+ //check if font name is a global token
+ if (startswith(fontName, "{") && endswith(fontName, "}")) {
+ string tmpFontName = "";
+ if (globals->GetFont(fontName, tmpFontName)) {
+ free(fontName);
+ fontName = strdup(tmpFontName.c_str());
+ } else {
+ esyslog("skindesigner: unknown font %s", fontName);
+ return;
+ }
+ }
+ if (size > 0)
+ LoadFont(size);
+}
+
+void cTextDrawer::LoadFont(int size) {
+ if (!fontName)
+ return;
+ if (size <= 0)
+ return;
+ font = fontManager->Font(fontName, size);
+ if (font)
+ fontSize = size;
+}
+
+int cTextDrawer::TextWidth(const char *text) {
+ int textWidth = 0;
+ fontLock.Lock();
+ textWidth = font->Width(text);
+ fontLock.Unlock();
+ return textWidth;
+}
+
+int cTextDrawer::FontHeight(void) {
+ int fontHeight = 0;
+ fontLock.Lock();
+ fontHeight = font->Height();
+ fontLock.Unlock();
+ return fontHeight;
+}
+/***************************************************************************
+* cFuncDrawText
+***************************************************************************/
+cFuncDrawText::cFuncDrawText(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "DrawText";
+ text = NULL;
+ SetAttributesDefs();
+}
+
+cFuncDrawText::cFuncDrawText(const cFuncDrawText &other) : cFunction(other) {
+ funcType = other.funcType;
+ fontName = NULL;
+ if (other.fontName)
+ fontName = strdup(other.fontName);
+ font = other.font;
+ text = NULL;
+ if (other.text)
+ text = new cTextExpr(*other.text);
+}
+
+cFuncDrawText::~cFuncDrawText(void) {
+ delete text;
+}
+
+void cFuncDrawText::SetLoopInfo(cLoopInfo *loopInfo) {
+ cFunction::SetLoopInfo(loopInfo);
+ if (text)
+ text->SetLoopInfo(loopInfo);
+}
+
+void cFuncDrawText::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
+ cAttributes::SetTokenContainerDeep(tokenContainer);
+ if (text) {
+ text->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cFuncDrawText::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func DrawText attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eDrawTextAttribs::color)) {
+ SetColor(attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribs::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribs::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribs::valign)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribs::animtype)) {
+ SetAnimType(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribs::font)) {
+ fontName = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribs::text)) {
+ text = new cTextExpr(attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribs::fontsize)) {
+ attribCtors[id] = new cNumericExpr(attVal);
+ attribCtors[id]->SetVertical();
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncDrawText::Cache(void) {
+ cFunction::Cache();
+ if (text) {
+ text->SetTokenContainer(tokenContainer);
+ text->SetGlobals(globals);
+ text->Cache();
+ }
+ if (fontName) {
+ CacheFont(globals, GetValue((int)eDrawTextAttribs::fontsize));
+ }
+}
+
+void cFuncDrawText::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ if (!font) {
+ LoadFont(GetValue((int)eDrawTextAttribs::fontsize));
+ if (!font)
+ return;
+ }
+ char *funcText = NULL;
+ if (text)
+ funcText = text->DeterminateText();
+ if (!funcText)
+ return;
+ int maxTextWidth = Width();
+ if (maxTextWidth > 0 && !scrolling) {
+ if (TextWidth(funcText) > maxTextWidth) {
+ funcText = Cut(funcText, maxTextWidth);
+ }
+ } else if (!scrolling) {
+ maxTextWidth = container.Width() - X();
+ if (TextWidth(funcText) > maxTextWidth) {
+ funcText = Cut(funcText, maxTextWidth);
+ }
+ }
+
+ eAlign horAlign = (eAlign)GetValue((int)eDrawTextAttribs::align);
+ eAlign verAlign = (eAlign)GetValue((int)eDrawTextAttribs::valign);
+
+ int contWidth = colWidth > 0 ? colWidth : container.Width();
+ int x = X() + x0;
+ if (horAlign == eAlign::right) {
+ x = x0 + contWidth - TextWidth(funcText);
+ } else if (horAlign == eAlign::center) {
+ x = x0 + (contWidth - TextWidth(funcText)) / 2;
+ }
+
+ int contHeight = rowHeight > 0 ? rowHeight : container.Height();
+ int y = Y() + y0;
+ if (verAlign == eAlign::bottom) {
+ y = y0 + contHeight - FontHeight();
+ } else if (verAlign == eAlign::center) {
+ y = y0 + (contHeight - FontHeight()) / 2;
+ }
+
+ p->DrawText(cPoint(x, y), funcText, color->Color(), clrTransparent, font);
+ free(funcText);
+}
+
+int cFuncDrawText::FuncX(void) {
+ if (!font)
+ return 0;
+ char *funcText = NULL;
+ if (text)
+ funcText = text->DeterminateText();
+ if (!funcText)
+ return 0;
+ eAlign horAlign = (eAlign)GetValue((int)eDrawTextAttribs::align);
+ int x = X();
+ if (horAlign == eAlign::right) {
+ x = container.Width() - TextWidth(funcText);
+ } else if (horAlign == eAlign::center) {
+ x = (container.Width() - TextWidth(funcText)) / 2;
+ }
+ return x;
+}
+
+int cFuncDrawText::FuncY(void) {
+ if (!font)
+ return 0;
+ eAlign verAlign = (eAlign)GetValue((int)eDrawTextAttribs::valign);
+ int y = Y();
+ if (verAlign == eAlign::bottom) {
+ y = container.Height() - FontHeight();
+ } else if (verAlign == eAlign::center) {
+ y = (container.Height() - FontHeight()) / 2;
+ }
+ return y;
+}
+
+int cFuncDrawText::FuncWidth(void) {
+ if (!font)
+ return 0;
+ char *funcText = NULL;
+ if (text)
+ funcText = text->DeterminateText();
+ if (!funcText)
+ return 0;
+ int textWidth = TextWidth(funcText);
+ free(funcText);
+ return textWidth;
+}
+
+int cFuncDrawText::FuncHeight(void) {
+ if (!font)
+ return 0;
+ return FontHeight();
+}
+
+int cFuncDrawText::AvrgFontWidth(void) {
+ if (!font)
+ return 20;
+ return TextWidth("x")+3;
+}
+
+const cFont *cFuncDrawText::GetFont(void) {
+ return font;
+}
+
+void cFuncDrawText::Debug(void) {
+ cFunction::Debug();
+ if (fontName)
+ esyslog("skindesigner: fontname: \"%s\"", fontName);
+ if (font)
+ esyslog("skindesigner: cached font name: \"%s\", size %d", font->FontName(), font->Height());
+ if (text)
+ text->Debug("draw text");
+}
+
+void cFuncDrawText::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eDrawTextAttribs::align));
+ attribIDs.insert(pair<string, int>("valign", (int)eDrawTextAttribs::valign));
+ attribIDs.insert(pair<string, int>("color", (int)eDrawTextAttribs::color));
+ attribIDs.insert(pair<string, int>("font", (int)eDrawTextAttribs::font));
+ attribIDs.insert(pair<string, int>("fontsize", (int)eDrawTextAttribs::fontsize));
+ attribIDs.insert(pair<string, int>("name", (int)eDrawTextAttribs::name));
+ attribIDs.insert(pair<string, int>("text", (int)eDrawTextAttribs::text));
+ attribIDs.insert(pair<string, int>("animtype", (int)eDrawTextAttribs::animtype));
+ attribIDs.insert(pair<string, int>("animfreq", (int)eDrawTextAttribs::animfreq));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::align, "align"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::valign, "valign"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::color, "color"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::font, "font"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::fontsize, "fontsize"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::text, "text"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::animtype, "animtype"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribs::animfreq, "animfreq"));
+}
+
+char *cFuncDrawText::Cut(char *expr, int width) {
+ char *cutted = NULL;
+ int w = 3 * font->Width(".");
+ for (char *p = expr; *p; ) {
+ int sl = Utf8CharLen(p);
+ uint sym = Utf8CharGet(p, sl);
+ w += font->Width(sym);
+ if( w >= width ) {
+ cutted = (char*)malloc(p - expr + 4);
+ memset(cutted, 0, p - expr + 4);
+ strncpy(cutted, expr, p - expr);
+ cutted[p - expr] = '.';
+ cutted[p - expr + 1] = '.';
+ cutted[p - expr + 2] = '.';
+ break;
+ }
+ p += sl;
+ }
+ if (cutted) {
+ free(expr);
+ return cutted;
+ }
+ return expr;
+}
+
+/***************************************************************************
+* cFuncDrawTextVertical
+***************************************************************************/
+cFuncDrawTextVertical::cFuncDrawTextVertical(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "DrawTextVertical";
+ text = NULL;
+ SetAttributesDefs();
+}
+
+cFuncDrawTextVertical::cFuncDrawTextVertical(const cFuncDrawTextVertical &other) : cFunction(other) {
+ funcType = other.funcType;
+ fontName = NULL;
+ if (other.fontName)
+ fontName = strdup(other.fontName);
+ text = NULL;
+ if (other.text)
+ text = new cTextExpr(*other.text);
+}
+
+cFuncDrawTextVertical::~cFuncDrawTextVertical(void) {
+ delete text;
+}
+
+void cFuncDrawTextVertical::SetLoopInfo(cLoopInfo *loopInfo) {
+ cFunction::SetLoopInfo(loopInfo);
+ if (text)
+ text->SetLoopInfo(loopInfo);
+}
+
+void cFuncDrawTextVertical::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
+ cAttributes::SetTokenContainerDeep(tokenContainer);
+ if (text) {
+ text->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cFuncDrawTextVertical::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func DrawTextVertical attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eDrawTextAttribsVertical::color)) {
+ SetColor(attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribsVertical::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribsVertical::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribsVertical::direction)) {
+ SetDirection(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribsVertical::valign)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribsVertical::animtype)) {
+ SetAnimType(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribsVertical::font)) {
+ fontName = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawTextAttribsVertical::text)) {
+ text = new cTextExpr(attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncDrawTextVertical::Cache(void) {
+ cFunction::Cache();
+ if (text) {
+ text->SetTokenContainer(tokenContainer);
+ text->SetGlobals(globals);
+ text->Cache();
+ }
+ if (fontName) {
+ CacheFont(globals, 0);
+ }
+}
+
+void cFuncDrawTextVertical::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ char *funcText = NULL;
+ if (text)
+ funcText = text->DeterminateText();
+ if (!funcText)
+ return;
+ int fontSize = GetValue((int)eDrawTextAttribsVertical::fontsize);
+ int direction = GetValue((int)eDrawTextAttribsVertical::direction);
+ tColor clr = color->Color();
+ cImage *textVertical = imgCache->GetVerticalText(funcText, clr, fontName, fontSize, direction);
+ if (!textVertical)
+ return;
+
+ eAlign horAlign = (eAlign)GetValue((int)eDrawTextAttribsVertical::align);
+ eAlign verAlign = (eAlign)GetValue((int)eDrawTextAttribsVertical::valign);
+ int x = 0;
+ int y = 0;
+ if (horAlign == eAlign::center) {
+ x = (container.Width() - textVertical->Width()) / 2;
+ } else if (horAlign == eAlign::right) {
+ x = container.Width() - textVertical->Width();
+ }
+ if (verAlign == eAlign::center) {
+ y = (container.Height() - textVertical->Height()) / 2;
+ } else if (horAlign == eAlign::bottom) {
+ y = container.Height() - textVertical->Height();
+ }
+ cPoint pos(x, y);
+ p->DrawImage(pos, *textVertical);
+ free(funcText);
+}
+
+int cFuncDrawTextVertical::FuncWidth(void) {
+ char *funcText = NULL;
+ if (text)
+ funcText = text->DeterminateText();
+ if (!funcText)
+ return 0;
+ int fontSize = GetValue((int)eDrawTextAttribsVertical::fontsize);
+ int direction = GetValue((int)eDrawTextAttribsVertical::direction);
+ tColor clr = color->Color();
+ cImage *textVertical = imgCache->GetVerticalText(funcText, clr, fontName, fontSize, direction);
+ if (!textVertical)
+ return 0;
+ return textVertical->Width();
+}
+
+int cFuncDrawTextVertical::FuncHeight(void) {
+ char *funcText = NULL;
+ if (text)
+ funcText = text->DeterminateText();
+ if (!funcText)
+ return 0;
+ int fontSize = GetValue((int)eDrawTextAttribsVertical::fontsize);
+ int direction = GetValue((int)eDrawTextAttribsVertical::direction);
+ tColor clr = color->Color();
+ cImage *textVertical = imgCache->GetVerticalText(funcText, clr, fontName, fontSize, direction);
+ if (!textVertical)
+ return 0;
+ return textVertical->Height();
+}
+
+void cFuncDrawTextVertical::Debug(void) {
+ cFunction::Debug();
+ if (fontName)
+ esyslog("skindesigner: fontname: \"%s\"", fontName);
+ if (text)
+ text->Debug("draw text");
+}
+
+void cFuncDrawTextVertical::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eDrawTextAttribsVertical::align));
+ attribIDs.insert(pair<string, int>("valign", (int)eDrawTextAttribsVertical::valign));
+ attribIDs.insert(pair<string, int>("direction", (int)eDrawTextAttribsVertical::direction));
+ attribIDs.insert(pair<string, int>("color", (int)eDrawTextAttribsVertical::color));
+ attribIDs.insert(pair<string, int>("font", (int)eDrawTextAttribsVertical::font));
+ attribIDs.insert(pair<string, int>("fontsize", (int)eDrawTextAttribsVertical::fontsize));
+ attribIDs.insert(pair<string, int>("name", (int)eDrawTextAttribsVertical::name));
+ attribIDs.insert(pair<string, int>("text", (int)eDrawTextAttribsVertical::text));
+ attribIDs.insert(pair<string, int>("animtype", (int)eDrawTextAttribsVertical::animtype));
+ attribIDs.insert(pair<string, int>("animfreq", (int)eDrawTextAttribsVertical::animfreq));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::align, "align"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::valign, "valign"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::direction, "direction"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::color, "color"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::font, "font"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::fontsize, "fontsize"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::name, "name"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::text, "text"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::animtype, "animtype"));
+ attribNames.insert(pair<int, string>((int)eDrawTextAttribsVertical::animfreq, "animfreq"));
+}
+
+/***************************************************************************
+* cFuncDrawTextBox
+***************************************************************************/
+cFuncDrawTextBox::cFuncDrawTextBox(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "DrawTextBox";
+ text = NULL;
+ floater = NULL;
+ SetAttributesDefs();
+}
+
+cFuncDrawTextBox::cFuncDrawTextBox(const cFuncDrawTextBox &other) : cFunction(other) {
+ funcType = other.funcType;
+ fontName = NULL;
+ if (other.fontName)
+ fontName = strdup(other.fontName);
+ font = other.font;
+ text = NULL;
+ if (other.text)
+ text = new cTextExpr(*other.text);
+ floater = NULL;
+}
+
+cFuncDrawTextBox::~cFuncDrawTextBox(void) {
+ delete text;
+ delete floater;
+}
+
+void cFuncDrawTextBox::SetLoopInfo(cLoopInfo *loopInfo) {
+ cFunction::SetLoopInfo(loopInfo);
+ if (text)
+ text->SetLoopInfo(loopInfo);
+}
+
+void cFuncDrawTextBox::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
+ cAttributes::SetTokenContainerDeep(tokenContainer);
+ if (text) {
+ text->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cFuncDrawTextBox::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func DrawTextBox attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eDrawTextBoxAttribs::color)) {
+ SetColor(attVal);
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::valign)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::floatmode)) {
+ SetFloatMode(id, attVal);
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::floatheight)) {
+ attribCtors[id] = new cNumericExpr(attVal);
+ attribCtors[id]->SetVertical();
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::font)) {
+ fontName = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::text)) {
+ text = new cTextExpr(attVal);
+ } else if (IdEqual(id, (int)eDrawTextBoxAttribs::fontsize)) {
+ attribCtors[id] = new cNumericExpr(attVal);
+ attribCtors[id]->SetVertical();
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncDrawTextBox::Cache(void) {
+ cFunction::Cache();
+ if (text) {
+ text->SetTokenContainer(tokenContainer);
+ text->SetGlobals(globals);
+ text->Cache();
+ }
+ if (fontName) {
+ CacheFont(globals, GetValue((int)eDrawTextBoxAttribs::fontsize));
+ }
+}
+
+void cFuncDrawTextBox::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ if (!font) {
+ LoadFont(GetValue((int)eDrawTextBoxAttribs::fontsize));
+ if (!font)
+ return;
+ }
+ SetFloater();
+ eFloatMode mode = (eFloatMode)GetValue((int)eDrawTextBoxAttribs::floatmode);
+ int fontHeight = FontHeight();
+ int lines = floater->Lines();
+ eAlign align = (eAlign)GetValue((int)eDrawTextBoxAttribs::align);
+ int boxX = X() + x0;
+ int floatHeight = 0;
+ if ( mode == eFloatMode::topleft ) {
+ boxX += GetValue((int)eDrawTextBoxAttribs::floatwidth);
+ floatHeight = GetValue((int)eDrawTextBoxAttribs::floatheight);
+ }
+ eAlign valign = (eAlign)GetValue((int)eDrawTextBoxAttribs::valign);
+ int height = Height();
+ if (height <= 0)
+ height = container.Height();
+ int y = Y() + y0;
+ if (valign == eAlign::center) {
+ y = y0 + (height - fontHeight * lines) / 2;
+ } else if (valign == eAlign::bottom) {
+ y = y0 + height - fontHeight * lines;
+ }
+ int x = boxX;
+ for (int line=0; line < lines; line++) {
+ const char *lineText = floater->GetLine(line);
+ if (!lineText)
+ break;
+ if (align == eAlign::center) {
+ x = boxX + (Width() - TextWidth(lineText)) / 2;
+ } else if (align == eAlign::right) {
+ x = boxX + Width() - TextWidth(lineText);
+ }
+ p->DrawText(cPoint(x, y), lineText, color->Color(), clrTransparent, font);
+ y += fontHeight;
+ if ( mode == eFloatMode::topleft ) {
+ if ((line+1) * fontHeight >= floatHeight)
+ x = X() + x0;
+ }
+ }
+}
+
+int cFuncDrawTextBox::FuncWidth(void) {
+ return Width();
+}
+
+int cFuncDrawTextBox::FuncHeight(void) {
+ if (!font)
+ return 0;
+ int boxHeight = Height();
+ if (boxHeight > 0)
+ return boxHeight;
+ SetFloater();
+ int lines = floater->Lines();
+ return lines * FontHeight();
+}
+
+void cFuncDrawTextBox::Debug(void) {
+ cFunction::Debug();
+ if (fontName)
+ esyslog("skindesigner: fontname: \"%s\"", fontName);
+ if (font)
+ esyslog("skindesigner: cached font name: \"%s\", size %d", font->FontName(), font->Height());
+ if (text)
+ text->Debug("draw textbox");
+}
+
+void cFuncDrawTextBox::SetFloater(void) {
+ char *funcText = NULL;
+ if (text)
+ funcText = text->DeterminateText();
+ int boxWidth = Width();
+ int boxHeight = Height();
+ int floatWidth = GetValue((int)eDrawTextBoxAttribs::floatwidth);
+ int floatHeight = GetValue((int)eDrawTextBoxAttribs::floatheight);
+ int maxLines = GetValue((int)eDrawTextBoxAttribs::maxlines);
+ delete floater;
+ floater = new cTextFloater();
+ floater->Set(funcText, font, boxWidth, boxHeight, floatWidth, floatHeight, maxLines);
+ free(funcText);
+}
+
+void cFuncDrawTextBox::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eDrawTextBoxAttribs::align));
+ attribIDs.insert(pair<string, int>("valign", (int)eDrawTextBoxAttribs::valign));
+ attribIDs.insert(pair<string, int>("maxlines", (int)eDrawTextBoxAttribs::maxlines));
+ attribIDs.insert(pair<string, int>("floatwidth", (int)eDrawTextBoxAttribs::floatwidth));
+ attribIDs.insert(pair<string, int>("floatheight", (int)eDrawTextBoxAttribs::floatheight));
+ attribIDs.insert(pair<string, int>("float", (int)eDrawTextBoxAttribs::floatmode));
+ attribIDs.insert(pair<string, int>("color", (int)eDrawTextBoxAttribs::color));
+ attribIDs.insert(pair<string, int>("font", (int)eDrawTextBoxAttribs::font));
+ attribIDs.insert(pair<string, int>("fontsize", (int)eDrawTextBoxAttribs::fontsize));
+ attribIDs.insert(pair<string, int>("name", (int)eDrawTextBoxAttribs::name));
+ attribIDs.insert(pair<string, int>("text", (int)eDrawTextBoxAttribs::text));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::align, "align"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::valign, "valign"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::maxlines, "maxlines"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::floatwidth, "floatwidth"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::floatheight, "floatheight"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::floatmode, "float"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::color, "color"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::font, "font"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::fontsize, "fontsize"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eDrawTextBoxAttribs::text, "text"));
+}
+
+void cFuncDrawTextBox::SetFloatMode(int id, const char *val) {
+ eFloatMode mode = eFloatMode::none;
+ if (!strcmp(val, "topleft"))
+ mode = eFloatMode::topleft;
+ else if (!strcmp(val, "topright"))
+ mode = eFloatMode::topright;
+ attribs[id] = (int)mode;
+}
+
+/***************************************************************************
+* cFuncDrawImage
+***************************************************************************/
+cFuncDrawImage::cFuncDrawImage(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "DrawImage";
+ path = NULL;
+ SetAttributesDefs();
+}
+
+cFuncDrawImage::cFuncDrawImage(const cFuncDrawImage &other) : cFunction(other) {
+ funcType = other.funcType;
+ path = NULL;
+ if (other.path)
+ path = new cTextExpr(*other.path);
+}
+
+cFuncDrawImage::~cFuncDrawImage(void) {
+ delete path;
+}
+
+void cFuncDrawImage::SetLoopInfo(cLoopInfo *loopInfo) {
+ cFunction::SetLoopInfo(loopInfo);
+ if (path)
+ path->SetLoopInfo(loopInfo);
+}
+
+void cFuncDrawImage::SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer) {
+ cAttributes::SetTokenContainerDeep(tokenContainer);
+ if (path) {
+ path->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cFuncDrawImage::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown func DrawText attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eDrawImageAttribs::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eDrawImageAttribs::path)) {
+ path = new cTextExpr(attVal);
+ } else if (IdEqual(id, (int)eDrawImageAttribs::align)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawImageAttribs::valign)) {
+ SetAlign(id, attVal);
+ } else if (IdEqual(id, (int)eDrawImageAttribs::imagetype)) {
+ SetImageType(id, attVal);
+ } else if (IdEqual(id, (int)eDrawImageAttribs::animtype)) {
+ SetAnimType(id, attVal);
+ } else if (IdEqual(id, (int)eDrawImageAttribs::cache)) {
+ SetBool(id, attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncDrawImage::Debug(void) {
+ cFunction::Debug();
+ if (path)
+ path->Debug("image path");
+}
+
+void cFuncDrawImage::SetImageType(int id, const char *val) {
+ eImageType imgType = eImageType::image;
+ if (!strcmp(val, "channellogo"))
+ imgType = eImageType::channellogo;
+ else if (!strcmp(val, "seplogo"))
+ imgType = eImageType::seplogo;
+ else if (!strcmp(val, "skinpart"))
+ imgType = eImageType::skinpart;
+ else if (!strcmp(val, "menuicon"))
+ imgType = eImageType::menuicon;
+ else if (!strcmp(val, "icon"))
+ imgType = eImageType::icon;
+ attribs[id] = (int)imgType;
+}
+
+void cFuncDrawImage::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("align", (int)eDrawImageAttribs::align));
+ attribIDs.insert(pair<string, int>("valign", (int)eDrawImageAttribs::valign));
+ attribIDs.insert(pair<string, int>("imagetype", (int)eDrawImageAttribs::imagetype));
+ attribIDs.insert(pair<string, int>("name", (int)eDrawImageAttribs::name));
+ attribIDs.insert(pair<string, int>("cache", (int)eDrawImageAttribs::cache));
+ attribIDs.insert(pair<string, int>("path", (int)eDrawImageAttribs::path));
+ attribIDs.insert(pair<string, int>("animtype", (int)eDrawImageAttribs::animtype));
+ attribIDs.insert(pair<string, int>("animfreq", (int)eDrawImageAttribs::animfreq));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::align, "align"));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::valign, "valign"));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::imagetype, "imagetype"));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::cache, "cache"));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::path, "path"));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::animtype, "animtype"));
+ attribNames.insert(pair<int, string>((int)eDrawImageAttribs::animfreq, "animfreq"));
+}
+
+void cFuncDrawImage::Cache(void) {
+ cFunction::Cache();
+ if (path) {
+ int type = GetValue((int)eDrawImageAttribs::imagetype);
+ if (type == (int)eImageType::image) {
+ path->CorrectImagePath();
+ }
+ path->SetGlobals(globals);
+ path->SetTokenContainer(tokenContainer);
+ path->Cache();
+ }
+
+ if (config.cacheImagesInitial)
+ PreCacheImage();
+}
+
+void cFuncDrawImage::PreCacheImage(void) {
+ int imgWidth = Width();
+ int imgHeight = Height();
+ char *imgPath = path->DeterminateText();
+ if (!(imgWidth > 0 && imgHeight > 0))
+ return;
+
+ eImageType type = (eImageType)GetValue((int)eDrawImageAttribs::imagetype);
+ switch (type) {
+ case eImageType::channellogo:
+ imgCache->CacheLogo(imgWidth, imgHeight);
+ break;
+ case eImageType::skinpart:
+ if (imgPath)
+ imgCache->GetSkinpart(imgPath, imgWidth, imgHeight);
+ break;
+ case eImageType::icon:
+ case eImageType::menuicon:
+ if (imgPath)
+ imgCache->GetIcon(type, imgPath, imgWidth, imgHeight);
+ break;
+ default:
+ break;
+ }
+ free(imgPath);
+}
+
+void cFuncDrawImage::Render(cPixmap *p, int x0, int y0, int colWidth, int rowHeight) {
+ if (!path)
+ return;
+ eAlign align = (eAlign)GetValue((int)eDrawImageAttribs::align);
+ eAlign valign = (eAlign)GetValue((int)eDrawImageAttribs::valign);
+ int x = GetX(align, x0, colWidth);
+ int y = GetY(valign, y0, rowHeight);
+ cPoint pos(x, y);
+ eImageType type = (eImageType)GetValue((int)eDrawImageAttribs::imagetype);
+ char *imgPath = path->DeterminateText();
+ if (!imgPath)
+ return;
+
+ switch (type) {
+ case eImageType::channellogo: {
+ cImage *logo = imgCache->GetLogo(imgPath, Width(), Height());
+ if (logo) {
+ p->DrawImage(pos, *logo);
+ }
+ break; }
+ case eImageType::seplogo: {
+ cImage *sep = imgCache->GetSeparatorLogo(imgPath, Width(), Height());
+ if (sep) {
+ p->DrawImage(pos, *sep);
+ }
+ break; }
+ case eImageType::skinpart: {
+ cCachedImage *img = imgCache->GetSkinpart(imgPath, Width(), Height());
+ if (!img) break;
+ if (img->handle) {
+ p->DrawImage(pos, img->handle);
+ } else if (img->image) {
+ p->DrawImage(pos, *(img->image));
+ }
+ break; }
+ case eImageType::icon:
+ case eImageType::menuicon: {
+ cCachedImage *img = imgCache->GetIcon(type, imgPath, Width(), Height());
+ if (!img) break;
+ if (img->handle) {
+ p->DrawImage(pos, img->handle);
+ } else if (img->image) {
+ p->DrawImage(pos, *(img->image));
+ }
+ break; }
+ case eImageType::image: {
+ cImageLoader imgLoader;
+ if (imgLoader.LoadImage(imgPath)) {
+ cImage *img = imgLoader.CreateImage(Width(), Height());
+ if (!img) break;
+ p->DrawImage(pos, *img);
+ delete(img);
+ }
+ break; }
+ }
+ free(imgPath);
+}
+
+/***************************************************************************
+* cFuncLoop
+***************************************************************************/
+cFuncLoop::cFuncLoop(cArea *owner, int numAttributes) : cFunction(owner, numAttributes) {
+ funcType = "LoopFunc";
+ SetAttributesDefs();
+}
+
+cFuncLoop::~cFuncLoop(void) {
+}
+
+void cFuncLoop::Set(vector<stringpair> &attributes) {
+ for (vector<stringpair>::iterator att = attributes.begin(); att != attributes.end(); att++) {
+ const char *attName = (*att).first.c_str();
+ const char *attVal = (*att).second.c_str();
+ int id = AttributeId(attName);
+ if (id == ATTR_UNKNOWN) {
+ esyslog("skindesigner: unknown loopfunc attribute \"%s\" = \"%s\"", attName, attVal);
+ continue;
+ }
+
+ if (SetCommon(id, attVal))
+ continue;
+ if (IdEqual(id, (int)eLoopAttribs::name)) {
+ name = strdup(attVal);
+ } else if (IdEqual(id, (int)eLoopAttribs::orientation)) {
+ SetOrientation(id, attVal);
+ } else if (IdEqual(id, (int)eLoopAttribs::overflow)) {
+ SetOverflow(id, attVal);
+ } else {
+ attribCtors[id] = new cNumericExpr(attVal);
+ }
+ }
+}
+
+void cFuncLoop::Cache(void) {
+ cFunction::Cache();
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetGlobals(globals);
+ f->SetTokenContainer(tokenContainer);
+ f->Cache();
+ }
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetLoopInfo(&loopInfo);
+ f->CacheFuncReferences();
+ }
+}
+
+void cFuncLoop::SetContainer(int x, int y, int width, int height) {
+ cAttributes::SetContainer(x, y, width, height);
+ int funcX = X();
+ int funcY = Y();
+ int funcWidth = Width();
+ int funcHeight = Height();
+
+ int funcContainerX = (funcX > 0) ? x + funcX : x;
+ int funcContainerY = (funcY > 0) ? y + funcY : y;
+ int funcContainerWidth = (funcWidth > 0) ? funcWidth : width;
+ int funcContainerHeight = (funcHeight > 0) ? funcHeight : height;
+
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->SetContainer(funcContainerX, funcContainerY, funcContainerWidth, funcContainerHeight);
+ }
+}
+
+
+void cFuncLoop::AddFunction(cFunction *f) {
+ functions.Add(f);
+}
+
+cFunction *cFuncLoop::GetFunction(const char *name) {
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ const char *funcName = f->Name();
+ if (funcName && !strcmp(funcName, name)) {
+ return f;
+ }
+ }
+ return NULL;
+}
+
+void cFuncLoop::Render(cPixmap *p, int x0, int y0, int cw, int rh) {
+ int loopIndex = tokenContainer->LoopIndex(Name());
+ if (loopIndex < 0) {
+ esyslog("skindesigner: unknown loop function \"%s\"", Name());
+ return;
+ }
+ int numRows = tokenContainer->NumLoops(loopIndex);
+ int columnWidth = GetValue((int)eLoopAttribs::columnwidth);
+ int rowHeight = GetValue((int)eLoopAttribs::rowheight);
+ int maxItems = GetValue((int)eLoopAttribs::maxitems);
+ eOrientation orientation = (eOrientation)GetValue((int)eLoopAttribs::orientation);
+ eOverflowType overflow = (eOverflowType)GetValue((int)eLoopAttribs::overflow);
+ int loopWidth = Width();
+ if (loopWidth <= 0)
+ loopWidth = container.Width();
+ int loopHeight = Height();
+ if (loopHeight <= 0)
+ loopHeight = container.Height();
+
+ loopInfo.colWidth = columnWidth;
+ loopInfo.rowHeight = rowHeight;
+ loopInfo.index = loopIndex;
+
+ int loopX = X();
+ int loopY = Y();
+ int x = (loopX > 0) ? loopX : 0;
+ int y = (loopY > 0) ? loopY : 0;
+ for (int row = 0; row < numRows; ++row) {
+ if (maxItems > 0 && row >= maxItems) {
+ break;
+ }
+ loopInfo.row = row;
+ //check overflow cut
+ if (overflow == eOverflowType::cut) {
+ if (orientation == eOrientation::horizontal && (row * columnWidth > loopWidth)) {
+ return;
+ } else if (orientation == eOrientation::vertical && (row * rowHeight > loopHeight)) {
+ return;
+ }
+ }
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (f->DoDebug())
+ f->Debug();
+ if (!f->DoExecute())
+ continue;
+ f->Render(p, x, y, columnWidth, rowHeight);
+ }
+ if (orientation == eOrientation::horizontal) {
+ if (columnWidth > 0) {
+ x += columnWidth;
+ } else {
+ x += ColumnWidth();
+ }
+ //check overflow wrap
+ if (overflow == eOverflowType::wrap && orientation == eOrientation::horizontal) {
+ if (x + columnWidth - 10 > loopWidth) {
+ x = X();
+ if (x < 0) x = 0;
+ y += rowHeight;
+ }
+ }
+ } else if (orientation == eOrientation::vertical) {
+ if (rowHeight > 0) {
+ y += rowHeight;
+ } else {
+ y += RowHeight();
+ }
+ }
+ }
+}
+
+int cFuncLoop::FuncWidth(void) {
+ loopInfo.row = 0;
+ int loopIndex = tokenContainer->LoopIndex(Name());
+ if (loopIndex < 0) {
+ esyslog("skindesigner: unknown loop function \"%s\"", Name());
+ return 0;
+ }
+ int numLoops = tokenContainer->NumLoops(loopIndex);
+ int columnWidth = GetValue((int)eLoopAttribs::columnwidth);
+ if (columnWidth <=0)
+ columnWidth = ColumnWidth();
+ eOverflowType overflow = (eOverflowType)GetValue((int)eLoopAttribs::overflow);
+ if (overflow == eOverflowType::cut) {
+ int maxItems = GetValue((int)eLoopAttribs::maxitems);
+ numLoops = min(numLoops, maxItems);
+ }
+ if (numLoops > 0)
+ return numLoops * columnWidth;
+ return 0;
+}
+
+int cFuncLoop::FuncHeight(void) {
+ loopInfo.row = 0;
+ int loopIndex = tokenContainer->LoopIndex(Name());
+ if (loopIndex < 0) {
+ esyslog("skindesigner: unknown loop function \"%s\"", Name());
+ return 0;
+ }
+ int numLoops = tokenContainer->NumLoops(loopIndex);
+ int rowHeight = GetValue((int)eLoopAttribs::rowheight);
+ if (rowHeight <=0)
+ rowHeight = RowHeight();
+
+ eOverflowType overflow = (eOverflowType)GetValue((int)eLoopAttribs::overflow);
+ if (overflow == eOverflowType::cut) {
+ int maxItems = GetValue((int)eLoopAttribs::maxitems);
+ numLoops = min(numLoops, maxItems);
+ } else if (overflow == eOverflowType::wrap) {
+ int loopWidth = Width();
+ if (loopWidth <= 0)
+ loopWidth = container.Width();
+ loopWidth++;
+ int columnWidth = GetValue((int)eLoopAttribs::columnwidth);
+ if (columnWidth <=0)
+ columnWidth = ColumnWidth();
+ int itemsPerRow = loopWidth / columnWidth;
+ int rows = numLoops / itemsPerRow;
+ if (numLoops % itemsPerRow > 0)
+ rows++;
+ return rows * rowHeight;
+ }
+ if (numLoops > 0)
+ return numLoops * rowHeight;
+ return 0;
+}
+
+void cFuncLoop::Debug(void) {
+ loopInfo.row = 0;
+ cFunction::Debug();
+ dsyslog("skindesigner: loopfunc Functions:");
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ f->Debug();
+ }
+}
+
+void cFuncLoop::SetAttributesDefs(void) {
+ attribIDs.insert(pair<string, int>("columnwidth", (int)eLoopAttribs::columnwidth));
+ attribIDs.insert(pair<string, int>("rowheight", (int)eLoopAttribs::rowheight));
+ attribIDs.insert(pair<string, int>("name", (int)eLoopAttribs::name));
+ attribIDs.insert(pair<string, int>("orientation", (int)eLoopAttribs::orientation));
+ attribIDs.insert(pair<string, int>("overflow", (int)eLoopAttribs::overflow));
+ attribIDs.insert(pair<string, int>("maxitems", (int)eLoopAttribs::maxitems));
+ attribNames.insert(pair<int, string>((int)eLoopAttribs::columnwidth, "columnwidth"));
+ attribNames.insert(pair<int, string>((int)eLoopAttribs::rowheight, "rowheight"));
+ attribNames.insert(pair<int, string>((int)eLoopAttribs::name, "name"));
+ attribNames.insert(pair<int, string>((int)eLoopAttribs::orientation, "orientation"));
+ attribNames.insert(pair<int, string>((int)eLoopAttribs::overflow, "overflow"));
+ attribNames.insert(pair<int, string>((int)eLoopAttribs::maxitems, "maxitems"));
+}
+
+int cFuncLoop::ColumnWidth(void) {
+ int width = 0;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (!f->DoExecute())
+ continue;
+ int funcWidth = f->X() + f->FuncWidth();
+ if (funcWidth > width)
+ width = funcWidth;
+ }
+ return width;
+}
+
+int cFuncLoop::RowHeight(void) {
+ int height = 0;
+ for (cFunction *f = functions.First(); f; f = functions.Next(f)) {
+ if (!f->DoExecute())
+ continue;
+ int funcHeight = f->Y() + f->FuncHeight();
+ if (funcHeight > height)
+ height = funcHeight;
+ }
+ return height;
+}
+
+// --- cTextFloater ----------------------------------------------------------
+
+cTextFloater::cTextFloater(void) {
+ text = eol = NULL;
+ lines = 0;
+ lastLine = -1;
+}
+
+cTextFloater::cTextFloater(const char *fext, const cFont *font, int width, int height, int floatWidth, int floatHeight, int maxLines) {
+ text = NULL;
+ Set(text, font, width, height, floatWidth, floatHeight, maxLines);
+}
+
+cTextFloater::~cTextFloater() {
+ free(text);
+}
+
+void cTextFloater::Set(const char *Text, const cFont *font, int width, int height, int floatWidth, int floatHeight, int maxLines) {
+ free(text);
+ text = Text ? strdup(Text) : NULL;
+ eol = NULL;
+ lines = 0;
+ lastLine = -1;
+ if (!text)
+ return;
+ lines = 1;
+ if (width <= 0)
+ return;
+ int lineHeight = font->Height();
+ bool cut = false;
+ if (height > 0)
+ cut = true;
+ bool doFloat = false;
+ if (floatWidth > 0 && floatHeight > 0)
+ doFloat = true;
+ int textWidth = width;
+ if (doFloat) {
+ textWidth = width - floatWidth;
+ }
+
+ char *Blank = NULL;
+ char *Delim = NULL;
+ int w = 0;
+
+ stripspace(text); // strips trailing newlines
+
+ for (char *p = text; *p; ) {
+ int sl = Utf8CharLen(p);
+ uint sym = Utf8CharGet(p, sl);
+ if (sym == '\n') {
+ if ((maxLines > 0) && (lines == maxLines)) {
+ while (*p) {
+ *p = 0;
+ p++;
+ }
+ return;
+ }
+ lines++;
+ if (cut) {
+ if (lines * lineHeight >= height) {
+ //remove last line, find last linebreak
+ p--;
+ int max = 100;
+ int i = 0;
+ while (*p) {
+ int sl = Utf8CharLen(p);
+ uint sym = Utf8CharGet(p, sl);
+ if (sym == '\n')
+ break;
+ p -= sl;
+ i++;
+ if (i > max)
+ break;
+ }
+ p++;
+ if (*p) {
+ *p = '.'; p++;
+ if (*p) {
+ *p = '.'; p++;
+ if (*p) {
+ *p = '.'; p++;
+ *p = 0;
+ }
+ }
+ }
+ break;
+ }
+ }
+ if (doFloat) {
+ if ((lines-1) * lineHeight >= floatHeight) {
+ textWidth = width;
+ }
+ }
+ w = 0;
+ Blank = Delim = NULL;
+ p++;
+ continue;
+ } else if (sl == 1 && isspace(sym))
+ Blank = p;
+
+ int cw = font->Width(sym);
+ if (w + cw > textWidth) {
+ if (Blank) {
+ *Blank = '\n';
+ p = Blank;
+ continue;
+ } else if (w > 0) { // there has to be at least one character before the newline
+ // Here's the ugly part, where we don't have any whitespace to
+ // punch in a newline, so we need to make room for it:
+ if (Delim)
+ p = Delim + 1; // let's fall back to the most recent delimiter
+ char *s = MALLOC(char, strlen(text) + 2); // The additional '\n' plus the terminating '\0'
+ int l = p - text;
+ strncpy(s, text, l);
+ s[l] = '\n';
+ strcpy(s + l + 1, p);
+ free(text);
+ text = s;
+ p = text + l;
+ continue;
+ }
+ }
+ w += cw;
+ if (strchr("-.,:;!?_", *p)) {
+ Delim = p;
+ Blank = NULL;
+ }
+ p += sl;
+ }
+}
+
+const char *cTextFloater::Text(void) {
+ if (eol) {
+ *eol = '\n';
+ eol = NULL;
+ }
+ return text;
+}
+
+const char *cTextFloater::GetLine(int line) {
+ char *s = NULL;
+ if (line < lines) {
+ if (eol) {
+ *eol = '\n';
+ if (line == lastLine + 1)
+ s = eol + 1;
+ eol = NULL;
+ }
+ if (!s) {
+ s = text;
+ for (int i = 0; i < line; i++) {
+ s = strchr(s, '\n');
+ if (s)
+ s++;
+ else
+ break;
+ }
+ }
+ if (s) {
+ if ((eol = strchr(s, '\n')) != NULL)
+ *eol = 0;
+ }
+ lastLine = line;
+ }
+ return s;
+}
diff --git a/coreengine/functions.h b/coreengine/functions.h new file mode 100644 index 0000000..57cbe64 --- /dev/null +++ b/coreengine/functions.h @@ -0,0 +1,220 @@ +#ifndef __FUNCTIONS_H
+#define __FUNCTIONS_H
+
+#include "functions.h"
+
+class cFuncFill : public cFunction {
+private:
+ void SetAttributesDefs(void);
+public:
+ cFuncFill(cArea *owner, int numAttributes);
+ cFuncFill(const cFuncFill &other);
+ virtual ~cFuncFill(void);
+ void Set(vector<stringpair> &attributes);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+};
+
+class cFuncDrawRectangle : public cFunction {
+private:
+ void SetAttributesDefs(void);
+public:
+ cFuncDrawRectangle(cArea *owner, int numAttributes);
+ cFuncDrawRectangle(const cFuncDrawRectangle &other);
+ virtual ~cFuncDrawRectangle(void);
+ void Set(vector<stringpair> &attributes);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ bool Blinking(void) { return GetValue((int)eDrawRectangleAttribs::animtype) == (int)eAnimType::blink; };
+ int BlinkFreq(void) { return GetValue((int)eDrawRectangleAttribs::animfreq); };
+ int Align(void) { return GetValue((int)eDrawRectangleAttribs::align); };
+ int Valign(void) { return GetValue((int)eDrawRectangleAttribs::valign); };
+};
+
+class cFuncDrawEllipse : public cFunction {
+private:
+ void SetAttributesDefs(void);
+public:
+ cFuncDrawEllipse(cArea *owner, int numAttributes);
+ cFuncDrawEllipse(const cFuncDrawEllipse &other);
+ virtual ~cFuncDrawEllipse(void);
+ void Set(vector<stringpair> &attributes);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ bool Blinking(void) { return GetValue((int)eDrawEllipseAttribs::animtype) == (int)eAnimType::blink; };
+ int BlinkFreq(void) { return GetValue((int)eDrawEllipseAttribs::animfreq); };
+ int Align(void) { return GetValue((int)eDrawEllipseAttribs::align); };
+ int Valign(void) { return GetValue((int)eDrawEllipseAttribs::valign); };
+};
+
+class cFuncDrawSlope : public cFunction {
+private:
+ void SetAttributesDefs(void);
+public:
+ cFuncDrawSlope(cArea *owner, int numAttributes);
+ cFuncDrawSlope(const cFuncDrawSlope &other);
+ virtual ~cFuncDrawSlope(void);
+ void Set(vector<stringpair> &attributes);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ bool Blinking(void) { return GetValue((int)eDrawSlopeAttribs::animtype) == (int)eAnimType::blink; };
+ int BlinkFreq(void) { return GetValue((int)eDrawSlopeAttribs::animfreq); };
+ int Align(void) { return GetValue((int)eDrawSlopeAttribs::align); };
+ int Valign(void) { return GetValue((int)eDrawSlopeAttribs::valign); };
+};
+
+class cTextDrawer {
+private:
+ static cMutex fontLock;
+protected:
+ const cFont *font;
+ char *fontName;
+ int fontSize;
+ void CacheFont(cGlobals *globals, int size);
+ void LoadFont(int size);
+ int TextWidth(const char *text);
+ int FontHeight(void);
+public:
+ cTextDrawer(void);
+ virtual ~cTextDrawer(void);
+};
+
+class cFuncDrawText : public cFunction, public cTextDrawer {
+private:
+ cTextExpr *text;
+ void SetAttributesDefs(void);
+ char *Cut(char *expr, int width);
+public:
+ cFuncDrawText(cArea *owner, int numAttributes);
+ cFuncDrawText(const cFuncDrawText &other);
+ virtual ~cFuncDrawText(void);
+ void SetLoopInfo(cLoopInfo *loopInfo);
+ void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
+ void Set(vector<stringpair> &attributes);
+ void Cache(void);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ int FuncX(void);
+ int FuncY(void);
+ int FuncWidth(void);
+ int FuncHeight(void);
+ int AvrgFontWidth(void);
+ const cFont *GetFont(void);
+ bool Blinking(void) { return GetValue((int)eDrawTextAttribs::animtype) == (int)eAnimType::blink; };
+ int BlinkFreq(void) { return GetValue((int)eDrawTextAttribs::animfreq); };
+ int Align(void) { return GetValue((int)eDrawTextAttribs::align); };
+ int Valign(void) { return GetValue((int)eDrawTextAttribs::valign); };
+ void Debug(void);
+};
+
+class cFuncDrawTextVertical : public cFunction, public cTextDrawer {
+private:
+ cTextExpr *text;
+ void SetAttributesDefs(void);
+public:
+ cFuncDrawTextVertical(cArea *owner, int numAttributes);
+ cFuncDrawTextVertical(const cFuncDrawTextVertical &other);
+ virtual ~cFuncDrawTextVertical(void);
+ void SetLoopInfo(cLoopInfo *loopInfo);
+ void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
+ void Set(vector<stringpair> &attributes);
+ void Cache(void);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ int FuncWidth(void);
+ int FuncHeight(void);
+ bool Blinking(void) { return GetValue((int)eDrawTextAttribsVertical::animtype) == (int)eAnimType::blink; };
+ int BlinkFreq(void) { return GetValue((int)eDrawTextAttribsVertical::animfreq); };
+ int Align(void) { return GetValue((int)eDrawTextAttribsVertical::align); };
+ int Valign(void) { return GetValue((int)eDrawTextAttribsVertical::valign); };
+ void Debug(void);
+};
+
+class cTextFloater;
+
+class cFuncDrawTextBox : public cFunction, public cTextDrawer {
+private:
+ cTextExpr *text;
+ cTextFloater *floater;
+ void SetFloater(void);
+ void SetAttributesDefs(void);
+ void SetFloatMode(int id, const char *val);
+public:
+ cFuncDrawTextBox(cArea *owner, int numAttributes);
+ cFuncDrawTextBox(const cFuncDrawTextBox &other);
+ virtual ~cFuncDrawTextBox(void);
+ void SetLoopInfo(cLoopInfo *loopInfo);
+ void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
+ void Set(vector<stringpair> &attributes);
+ void Cache(void);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ int FuncWidth(void);
+ int FuncHeight(void);
+ void Debug(void);
+};
+
+class cFuncDrawImage : public cFunction {
+private:
+ cTextExpr *path;
+ void SetAttributesDefs(void);
+ void SetImageType(int id, const char *val);
+ void PreCacheImage(void);
+public:
+ cFuncDrawImage(cArea *owner, int numAttributes);
+ cFuncDrawImage(const cFuncDrawImage &other);
+ virtual ~cFuncDrawImage(void);
+ void SetLoopInfo(cLoopInfo *loopInfo);
+ void SetTokenContainerDeep(skindesignerapi::cTokenContainer *tokenContainer);
+ void Set(vector<stringpair> &attributes);
+ void Cache(void);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ bool Blinking(void) { return GetValue((int)eDrawImageAttribs::animtype) == (int)eAnimType::blink; };
+ int BlinkFreq(void) { return GetValue((int)eDrawImageAttribs::animfreq); };
+ int Align(void) { return GetValue((int)eDrawImageAttribs::align); };
+ int Valign(void) { return GetValue((int)eDrawImageAttribs::valign); };
+ void Debug(void);
+};
+
+class cFuncLoop : public cFunction {
+private:
+ cLoopInfo loopInfo;
+ cList<cFunction> functions;
+ void SetAttributesDefs(void);
+ int ColumnWidth(void);
+ int RowHeight(void);
+public:
+ cFuncLoop(cArea *owner, int numAttributes);
+ virtual ~cFuncLoop(void);
+ void Set(vector<stringpair> &attributes);
+ void SetContainer(int x, int y, int width, int height);
+ void Cache(void);
+ void AddFunction(cFunction *f);
+ cFunction *GetFunction(const char *name);
+ void Render(cPixmap *p, int x0 = 0, int y0 = 0, int colWidth = 0, int rowHeight = 0);
+ int FuncWidth(void);
+ int FuncHeight(void);
+ void Debug(void);
+};
+
+class cTextFloater {
+private:
+ char *text;
+ char *eol;
+ int lines;
+ int lastLine;
+public:
+ cTextFloater(void);
+ cTextFloater(const char *text, const cFont *font, int width, int height = 0, int floatWidth = 0, int floatHeight = 0, int maxLines = 0);
+ ~cTextFloater();
+ void Set(const char *Text, const cFont *font, int width, int height = 0, int floatWidth = 0, int floatHeight = 0, int maxLines = 0);
+ ///< Wraps the Text to make it fit into the area defined by the given Width
+ ///< when displayed with the given Font.
+ ///< Wrapping is done by inserting the necessary number of newline
+ ///< characters into the string.
+ ///< if height is set, new lines are only set till height is reached
+ ///< if floatwidth and floatheight are set, the first lines (depending on
+ ///< size of floatheight) are set to floatwidth
+ const char *Text(void);
+ ///< Returns the full wrapped text.
+ int Lines(void) { return lines; }
+ ///< Returns the actual number of lines needed to display the full wrapped text.
+ const char *GetLine(int line);
+ ///< Returns the given Line. The first line is numbered 0.
+};
+
+
+#endif //__FUNCTIONS_H
\ No newline at end of file diff --git a/libtemplate/globals.c b/coreengine/globals.c index 3fd0705..bb50a41 100644 --- a/libtemplate/globals.c +++ b/coreengine/globals.c @@ -89,6 +89,7 @@ void cGlobals::ReplaceIntVars(string &value) { } bool cGlobals::GetInt(string name, int &val) { + DeleteCurledBrackets(name); map < string, int >::iterator hit = intVars.find(name); if (hit != intVars.end()) { val = hit->second; @@ -146,10 +147,10 @@ void cGlobals::ReplaceStringVars(string &value) { value = value.replace(foundToken, token.size(), it->second); } } - } -bool cGlobals::GetString(string &name, string &value) { +bool cGlobals::GetString(string name, string &value) { + DeleteCurledBrackets(name); map<string,string>::iterator hit = stringVars.find(name); if (hit == stringVars.end()) return false; @@ -157,7 +158,6 @@ bool cGlobals::GetString(string &name, string &value) { return true; } - bool cGlobals::AddTranslation(string name, map < string, string > transl) { translations.erase(name); translations.insert(pair<string, map < string, string > >(name, transl)); @@ -207,20 +207,20 @@ string cGlobals::DoTranslate(string token) { return translation; } -void cGlobals::AddCustomInt(string &name, int value) { - customIntTokens.erase(name); - customIntTokens.insert(pair<string,int>(name, value)); +void cGlobals::AddCustomInt(int num, int value) { + customIntTokens.erase(num); + customIntTokens.insert(pair<int,int>(num, value)); customTokenChange = time(0); } -void cGlobals::AddCustomString(string &name, string &value) { - customStringTokens.erase(name); - customStringTokens.insert(pair<string,string>(name, value)); +void cGlobals::AddCustomString(int num, string &value) { + customStringTokens.erase(num); + customStringTokens.insert(pair<int,string>(num, value)); customTokenChange = time(0); } -bool cGlobals::GetCustomInt(string name, int &val) { - map < string, int >::iterator hit = customIntTokens.find(name); +bool cGlobals::GetCustomInt(int num, int &val) { + map < int, int >::iterator hit = customIntTokens.find(num); if (hit != customIntTokens.end()) { val = hit->second; return true; @@ -228,12 +228,21 @@ bool cGlobals::GetCustomInt(string name, int &val) { return false; } -map <string, string> cGlobals::GetCustomStringTokens(void) { +bool cGlobals::GetCustomString(int num, string &val) { + map < int, string >::iterator hit = customStringTokens.find(num); + if (hit != customStringTokens.end()) { + val = hit->second; + return true; + } + return false; +} + +map <int, string> cGlobals::GetCustomStringTokens(void) { lastCustomTokenQuery = time(0); return customStringTokens; } -map <string, int> cGlobals::GetCustomIntTokens(void) { +map <int, int> cGlobals::GetCustomIntTokens(void) { lastCustomTokenQuery = time(0); return customIntTokens; } @@ -246,12 +255,16 @@ bool cGlobals::CustomTokenChange(void) { return false; } +void cGlobals::ResetCustomTokenChange(void) { + lastCustomTokenQuery = 0; +} + void cGlobals::ListCustomTokens(void) { - for (map<string, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) { - dsyslog("skindesigner: custom string token \"%s\" = \"%s\"", (it->first).c_str(), (it->second).c_str()); + for (map<int, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) { + dsyslog("skindesigner: custom string token %d = \"%s\"", it->first, (it->second).c_str()); } - for (map<string, int>::iterator it = customIntTokens.begin(); it != customIntTokens.end(); it++) { - dsyslog("skindesigner: custom int token \"%s\" = \"%d\"", (it->first).c_str(), it->second); + for (map<int, int>::iterator it = customIntTokens.begin(); it != customIntTokens.end(); it++) { + dsyslog("skindesigner: custom int token %d = \"%d\"", it->first, it->second); } } @@ -281,3 +294,12 @@ void cGlobals::Debug(void) { } } } + +void cGlobals::DeleteCurledBrackets(string &token) { + if (token.find("{") != 0) + return; + if (token.find("}") != token.size() - 1) + return; + token = token.substr(1, token.size() - 2); +} + diff --git a/libtemplate/globals.h b/coreengine/globals.h index 12ee917..13c4515 100644 --- a/libtemplate/globals.h +++ b/coreengine/globals.h @@ -10,6 +10,7 @@ #include <map> #include <set> #include <sstream> +#include <algorithm> #include <vdr/plugin.h> using namespace std; @@ -24,14 +25,15 @@ private: time_t lastCustomTokenQuery; string language; string DoTranslate(string token); + void DeleteCurledBrackets(string &token); map <string, tColor> colors; map <string, string> fonts; map <string, int> intVars; map <string, double> doubleVars; map <string, string> stringVars; map <string, map< string, string > > translations; - map <string, string> customStringTokens; - map <string, int> customIntTokens; + map <int, string> customStringTokens; + map <int, int> customIntTokens; public: cGlobals(void); virtual ~cGlobals(void) {}; @@ -47,15 +49,17 @@ public: void ReplaceDoubleVars(string &value); void AddString(string &name, string &value); void ReplaceStringVars(string &value); - bool GetString(string &name, string &value); + bool GetString(string name, string &value); bool AddTranslation(string name, map < string, string > transl); bool Translate(string text, string &translation); - void AddCustomInt(string &name, int value); - void AddCustomString(string &name, string &value); - bool GetCustomInt(string name, int &val); - map <string, string> GetCustomStringTokens(void); - map <string, int> GetCustomIntTokens(void); + void AddCustomInt(int num, int value); + void AddCustomString(int num, string &value); + bool GetCustomInt(int num, int &val); + bool GetCustomString(int num, string &val); + map <int, string> GetCustomStringTokens(void); + map <int, int> GetCustomIntTokens(void); bool CustomTokenChange(void); + void ResetCustomTokenChange(void); void ListCustomTokens(void); void Debug(void); }; diff --git a/coreengine/gridelement.c b/coreengine/gridelement.c new file mode 100644 index 0000000..223546e --- /dev/null +++ b/coreengine/gridelement.c @@ -0,0 +1,57 @@ +#include "gridelement.h"
+#include "../config.h"
+
+cGridElement::cGridElement(void) {
+ current = false;
+ indexCurrent = -1;
+ viewId = -1;
+ plugId = -1;
+}
+
+cGridElement::cGridElement(const cGridElement &other) : cViewElement(other) {
+ current = false;
+ viewId = other.viewId;
+ plugId = other.plugId;
+ tokenContainer = new skindesignerapi::cTokenContainer(*other.tokenContainer);
+ indexCurrent = other.indexCurrent;
+ InheritTokenContainerDeep();
+}
+
+cGridElement::~cGridElement(void) {
+}
+
+void cGridElement::SetTokenContainer(void) {
+ skindesignerapi::cTokenContainer *tkGe = plgManager->GetTokenContainerGE(plugId, viewId, id);
+ if (!tkGe)
+ return;
+ tokenContainer = new skindesignerapi::cTokenContainer(*tkGe);
+ indexCurrent = tokenContainer->GetNumDefinedIntTokens();
+ tokenContainer->DefineIntToken("{current}", indexCurrent);
+ InheritTokenContainer();
+}
+
+void cGridElement::Set(skindesignerapi::cTokenContainer *tk) {
+ tokenContainer->Clear();
+ tokenContainer->SetTokens(tk);
+ SetDirty();
+}
+
+void cGridElement::SetCurrent(bool current) {
+ this->current = current;
+ SetDirty();
+}
+
+bool cGridElement::Parse(bool forced) {
+ if (!dirty)
+ return false;
+ tokenContainer->AddIntToken(indexCurrent, current);
+ return true;
+}
+
+int cGridElement::Width(void) {
+ return container.Width();
+}
+
+int cGridElement::Height(void) {
+ return container.Height();
+}
\ No newline at end of file diff --git a/coreengine/gridelement.h b/coreengine/gridelement.h new file mode 100644 index 0000000..6e94985 --- /dev/null +++ b/coreengine/gridelement.h @@ -0,0 +1,27 @@ +#ifndef __GRIDELEMENT_H
+#define __GRIDELEMENT_H
+
+#include "viewelement.h"
+
+class cGridElement : public cViewElement {
+private:
+ int viewId;
+ int plugId;
+ bool current;
+ int indexCurrent;
+public:
+ cGridElement(void);
+ cGridElement(const cGridElement &other);
+ virtual ~cGridElement(void);
+ void SetPluginId(int plugId) { this->plugId = plugId; };
+ void SetViewId(int viewId) { this->viewId = viewId; };
+ void SetTokenContainer(void);
+ skindesignerapi::cTokenContainer *GetTokenContainer(void) { return tokenContainer; };
+ void Set(skindesignerapi::cTokenContainer *tk);
+ void SetCurrent(bool current);
+ bool Parse(bool forced = true);
+ int Width(void);
+ int Height(void);
+};
+
+#endif //__GRIDELEMENT_H
\ No newline at end of file diff --git a/coreengine/listelements.c b/coreengine/listelements.c new file mode 100644 index 0000000..04e3cf4 --- /dev/null +++ b/coreengine/listelements.c @@ -0,0 +1,1830 @@ +#include "listelements.h"
+#include "../config.h"
+#include <sstream>
+#include <algorithm>
+
+/******************************************************************
+* cListElement
+******************************************************************/
+cListElement::cListElement(void) {
+ dirty = false;
+ num = -1;
+ current = false;
+ wasCurrent = false;
+ selectable = false;
+ currentElement = NULL;
+ menuCat = mcUnknown;
+};
+
+cListElement::cListElement(const cListElement &other) : cViewElement(other) {
+ num = -1;
+ current = false;
+ selectable = false;
+ currentElement = NULL;
+}
+
+void cListElement::SetCurrent(bool cur) {
+ if (!cur && current)
+ wasCurrent = true;
+ else
+ wasCurrent = false;
+ current = cur;
+}
+
+void cListElement::Close(void) {
+ if (current && currentElement) {
+ currentElement->Close();
+ }
+ cViewElement::Close();
+ dirty = false;
+}
+
+void cListElement::Clear(void) {
+ if (current && currentElement) {
+ currentElement->Close();
+ }
+ cViewElement::Clear();
+ dirty = false;
+}
+
+void cListElement::WakeCurrent(void) {
+ if (currentElement) {
+ currentElement->WakeUp();
+ }
+}
+
+
+char *cListElement::ParseSeparator(const char *text) {
+ const char *start = text;
+ while (*start && (*start == '-' || *start == ' ' || *start == 9)) {
+ start++;
+ }
+ const char *end = start;
+ while (*end && *end != '-') {
+ end++;
+ }
+ int len = end - start;
+ char *ret = (char*)malloc(len);
+ memset(ret, 0, len);
+ strncpy(ret, start, len-1);
+ return ret;
+}
+
+/******************************************************************
+* cCurrentElement
+******************************************************************/
+cCurrentElement::cCurrentElement(void) {
+ listX = 0;
+ listY = 0;
+ listWidth = 0;
+ listHeight = 0;
+}
+
+void cCurrentElement::SetListPosition(int x, int y, int width, int height) {
+ listX = x;
+ listY = y;
+ listWidth = width;
+ listHeight = height;
+}
+
+void cCurrentElement::SetListTokens(skindesignerapi::cTokenContainer *tokenContainer) {
+ tokenContainer->AddIntToken(0, listX);
+ tokenContainer->AddIntToken(1, listY);
+ tokenContainer->AddIntToken(2, listWidth);
+ tokenContainer->AddIntToken(3, listHeight);
+}
+
+/******************************************************************
+* cLeMenuDefault
+******************************************************************/
+cLeMenuDefault::cLeMenuDefault(void) {
+ text = NULL;
+ colX = NULL;
+ colWidths = NULL;
+ plugName = NULL;
+}
+
+cLeMenuDefault::cLeMenuDefault(const cLeMenuDefault &other) : cListElement(other) {
+ text = NULL;
+ colX = NULL;
+ colWidths = NULL;
+ plugName = NULL;
+}
+
+cLeMenuDefault::~cLeMenuDefault(void) {
+
+}
+
+void cLeMenuDefault::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{column1}", (int)eLeMenuDefaultST::column1);
+ tokenContainer->DefineStringToken("{column2}", (int)eLeMenuDefaultST::column2);
+ tokenContainer->DefineStringToken("{column3}", (int)eLeMenuDefaultST::column3);
+ tokenContainer->DefineStringToken("{column4}", (int)eLeMenuDefaultST::column4);
+ tokenContainer->DefineStringToken("{column5}", (int)eLeMenuDefaultST::column5);
+ tokenContainer->DefineStringToken("{column6}", (int)eLeMenuDefaultST::column6);
+ tokenContainer->DefineIntToken("{nummenuitem}", (int)eLeMenuDefaultIT::nummenuitem);
+ tokenContainer->DefineIntToken("{current}", (int)eLeMenuDefaultIT::current);
+ tokenContainer->DefineIntToken("{separator}", (int)eLeMenuDefaultIT::separator);
+ tokenContainer->DefineIntToken("{column2set}", (int)eLeMenuDefaultIT::column2set);
+ tokenContainer->DefineIntToken("{column3set}", (int)eLeMenuDefaultIT::column3set);
+ tokenContainer->DefineIntToken("{column4set}", (int)eLeMenuDefaultIT::column4set);
+ tokenContainer->DefineIntToken("{column5set}", (int)eLeMenuDefaultIT::column5set);
+ tokenContainer->DefineIntToken("{column6set}", (int)eLeMenuDefaultIT::column6set);
+ tokenContainer->DefineIntToken("{column1x}", (int)eLeMenuDefaultIT::column1x);
+ tokenContainer->DefineIntToken("{column2x}", (int)eLeMenuDefaultIT::column2x);
+ tokenContainer->DefineIntToken("{column3x}", (int)eLeMenuDefaultIT::column3x);
+ tokenContainer->DefineIntToken("{column4x}", (int)eLeMenuDefaultIT::column4x);
+ tokenContainer->DefineIntToken("{column5x}", (int)eLeMenuDefaultIT::column5x);
+ tokenContainer->DefineIntToken("{column6x}", (int)eLeMenuDefaultIT::column6x);
+ tokenContainer->DefineIntToken("{column1width}", (int)eLeMenuDefaultIT::column1width);
+ tokenContainer->DefineIntToken("{column2width}", (int)eLeMenuDefaultIT::column2width);
+ tokenContainer->DefineIntToken("{column3width}", (int)eLeMenuDefaultIT::column3width);
+ tokenContainer->DefineIntToken("{column4width}", (int)eLeMenuDefaultIT::column4width);
+ tokenContainer->DefineIntToken("{column5width}", (int)eLeMenuDefaultIT::column5width);
+ tokenContainer->DefineIntToken("{column6width}", (int)eLeMenuDefaultIT::column6width);
+ tokenContainer->DefineIntToken("{column1pb}", (int)eLeMenuDefaultIT::column1pb);
+ tokenContainer->DefineIntToken("{column2pb}", (int)eLeMenuDefaultIT::column2pb);
+ tokenContainer->DefineIntToken("{column3pb}", (int)eLeMenuDefaultIT::column3pb);
+ tokenContainer->DefineIntToken("{column4pb}", (int)eLeMenuDefaultIT::column4pb);
+ tokenContainer->DefineIntToken("{column5pb}", (int)eLeMenuDefaultIT::column5pb);
+ tokenContainer->DefineIntToken("{column6pb}", (int)eLeMenuDefaultIT::column6pb);
+ tokenContainer->DefineIntToken("{column1pbtotalsize}", (int)eLeMenuDefaultIT::column1pbtotalsize);
+ tokenContainer->DefineIntToken("{column2pbtotalsize}", (int)eLeMenuDefaultIT::column2pbtotalsize);
+ tokenContainer->DefineIntToken("{column3pbtotalsize}", (int)eLeMenuDefaultIT::column3pbtotalsize);
+ tokenContainer->DefineIntToken("{column4pbtotalsize}", (int)eLeMenuDefaultIT::column4pbtotalsize);
+ tokenContainer->DefineIntToken("{column5pbtotalsize}", (int)eLeMenuDefaultIT::column5pbtotalsize);
+ tokenContainer->DefineIntToken("{column6pbtotalsize}", (int)eLeMenuDefaultIT::column6pbtotalsize);
+ tokenContainer->DefineIntToken("{column1pbsize}", (int)eLeMenuDefaultIT::column1pbsize);
+ tokenContainer->DefineIntToken("{column2pbsize}", (int)eLeMenuDefaultIT::column2pbsize);
+ tokenContainer->DefineIntToken("{column3pbsize}", (int)eLeMenuDefaultIT::column3pbsize);
+ tokenContainer->DefineIntToken("{column4pbsize}", (int)eLeMenuDefaultIT::column4pbsize);
+ tokenContainer->DefineIntToken("{column5pbsize}", (int)eLeMenuDefaultIT::column5pbsize);
+ tokenContainer->DefineIntToken("{column6pbsize}", (int)eLeMenuDefaultIT::column6pbsize);
+ tokenContainer->DefineIntToken("{setup}", (int)eLeMenuDefaultIT::setup);
+ tokenContainer->DefineIntToken("{commands}", (int)eLeMenuDefaultIT::commands);
+ tokenContainer->DefineIntToken("{fritzbox}", (int)eLeMenuDefaultIT::fritzbox);
+ tokenContainer->DefineIntToken("{systeminfo}", (int)eLeMenuDefaultIT::systeminfo);
+ tokenContainer->DefineIntToken("{mailbox}", (int)eLeMenuDefaultIT::mailbox);
+ tokenContainer->DefineIntToken("{neutrinoepg}", (int)eLeMenuDefaultIT::neutrinoepg);
+ tokenContainer->DefineIntToken("{remotetimers}", (int)eLeMenuDefaultIT::remotetimers);
+ InheritTokenContainer();
+}
+
+void cLeMenuDefault::SetListInfo(int *colX, int *colWidths) {
+ this->colX = colX;
+ this->colWidths = colWidths;
+}
+
+void cLeMenuDefault::SetText(const char *text) {
+ dirty = true;
+ free(this->text);
+ this->text = strdup(text);
+}
+
+bool cLeMenuDefault::Parse(bool forced) {
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::nummenuitem, num);
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::current, current);
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::separator, !selectable);
+ for (int i = 0; i < MAX_TABS; i++) {
+ bool colUsed = false;
+ const char *s = GetTabbedText(text, i);
+ if (s) {
+ tokenContainer->AddStringToken(i, s);
+ colUsed = true;
+ CheckProgressBar(s, i);
+ }
+ else
+ tokenContainer->AddStringToken(i, "");
+ if (i > 0)
+ tokenContainer->AddIntToken(i + 2, colUsed);
+ tokenContainer->AddIntToken(i + 8, colX[i]);
+ tokenContainer->AddIntToken(i + 14, colWidths[i]);
+ }
+ SetMenuCategory();
+ return true;
+}
+
+const char *cLeMenuDefault::GetTabbedText(const char *s, int tab) {
+ if (!s)
+ return NULL;
+ static char buffer[1000];
+ const char *a = s;
+ const char *b = strchrnul(a, '\t');
+ while (*b && tab-- > 0) {
+ a = b + 1;
+ b = strchrnul(a, '\t');
+ }
+ if (!*b)
+ return (tab <= 0) ? a : NULL;
+ unsigned int n = b - a;
+ if (n >= sizeof(buffer))
+ n = sizeof(buffer) - 1;
+ strncpy(buffer, a, n);
+ buffer[n] = 0;
+ return buffer;
+}
+
+void cLeMenuDefault::SetMenuCategory(void) {
+ if (menuCat >= mcPluginSetup && menuCat <= mcSetupPlugins) {
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::setup, 1);
+ return;
+ } else if (menuCat == mcCommand) {
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::commands, 1);
+ return;
+ }
+
+ if (!plugName) {
+ return;
+ }
+ if (!strcmp(plugName, "fritzbox")) {
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::fritzbox, 1);
+ } else if (!strcmp(plugName, "systeminfo")) {
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::systeminfo, 1);
+ } else if (!strcmp(plugName, "mailbox")) {
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::mailbox, 1);
+ } else if (!strcmp(plugName, "neutrinoepg")) {
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::neutrinoepg, 1);
+ } else if (!strcmp(plugName, "remotetimers")) {
+ tokenContainer->AddIntToken((int)eLeMenuDefaultIT::remotetimers, 1);
+ }
+}
+
+void cLeMenuDefault::CheckProgressBar(const char *text, int tab) {
+ const char *start = strchr(text, '[');
+ if (!start)
+ return;
+ const char *stop = strchr(text, ']');
+ if (!stop)
+ return;
+ int total = stop - start - 1;
+ int len = 0;
+ char *s = (char*)start + 1;
+ while (*s && *s == '|') {
+ len++;
+ s++;
+ }
+ tokenContainer->AddIntToken(20 + tab, 1);
+ tokenContainer->AddIntToken(26 + tab, total);
+ tokenContainer->AddIntToken(32 + tab, len);
+}
+
+/******************************************************************
+* cVeMenuMain
+******************************************************************/
+cVeMenuMain::cVeMenuMain(void) {
+ text = NULL;
+ number = NULL;
+ label = NULL;
+}
+
+cVeMenuMain::~cVeMenuMain(void) {
+ free(text);
+ free(number);
+ free(label);
+}
+
+void cVeMenuMain::SplitText(void) {
+ char *start = skipspace(text);
+ bool found = false;
+ bool doBreak = false;
+ size_t i = 0;
+ char *c = start;
+ while (*c) {
+ if (i==0) {
+ //if text directly starts with nonnumeric, break
+ if (!(*c >= '0' && *c <= '9')) {
+ break;
+ }
+ }
+ if (found) {
+ //if current char is not a figure anymore, break
+ if (!(*c >= '0' && *c <= '9')) {
+ //there has to be a space after the menu item number
+ //plugins with figures in their name are eval :-)
+ if (*c != ' ')
+ found = false;
+ doBreak = true;
+ }
+ }
+ if (*c >= '0' && *c <= '9') {
+ found = true;
+ }
+ if (doBreak)
+ break;
+ if (i>4)
+ break;
+ c++;
+ i++;
+ }
+
+ free(number);
+ free(label);
+ if (found) {
+ number = (char*)malloc(i+1);
+ memset(number, 0, i+1);
+ strncpy(number, start, i);
+ } else {
+ number = (char*)malloc(2);
+ memset(number, 0, 2);
+ strncpy(number, "", 1);
+ }
+ label = strdup(skipspace(c));
+}
+
+/******************************************************************
+* cLeMenuMain
+******************************************************************/
+cLeMenuMain::cLeMenuMain(void) {
+ currentMain = NULL;
+}
+
+cLeMenuMain::cLeMenuMain(const cLeMenuMain &other) : cListElement(other) {
+ text = NULL;
+ number = NULL;
+ label = NULL;
+ currentMain = NULL;
+}
+
+cLeMenuMain::~cLeMenuMain(void) {
+}
+
+void cLeMenuMain::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{label}", (int)eLeMenuMainST::label);
+ tokenContainer->DefineStringToken("{number}", (int)eLeMenuMainST::number);
+ tokenContainer->DefineStringToken("{icon}", (int)eLeMenuMainST::icon);
+ tokenContainer->DefineIntToken("{nummenuitem}", (int)eLeMenuMainIT::nummenuitem);
+ tokenContainer->DefineIntToken("{current}", (int)eLeMenuMainIT::current);
+ tokenContainer->DefineIntToken("{separator}", (int)eLeMenuMainIT::separator);
+ InheritTokenContainer();
+}
+
+void cLeMenuMain::ClearCurrentElement(void) {
+ if (wasCurrent && currentMain) {
+ currentMain->Close();
+ }
+}
+
+void cLeMenuMain::SetText(const char *text) {
+ dirty = true;
+ free(this->text);
+ this->text = strdup(text);
+}
+
+bool cLeMenuMain::Parse(bool forced) {
+ if (!dirty)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eLeMenuMainIT::nummenuitem, num);
+ tokenContainer->AddIntToken((int)eLeMenuMainIT::current, current);
+ tokenContainer->AddIntToken((int)eLeMenuMainIT::separator, !selectable);
+ SplitText();
+ tokenContainer->AddStringToken((int)eLeMenuMainST::number, number);
+ tokenContainer->AddStringToken((int)eLeMenuMainST::label, label);
+ tokenContainer->AddStringToken((int)eLeMenuMainST::icon, imgCache->GetIconName(label).c_str());
+ return true;
+}
+
+void cLeMenuMain::RenderCurrent(void) {
+ if (!currentMain)
+ return;
+ currentMain->SetText(text);
+ currentMain->SetListPosition(container.X(), container.Y(), container.Width(), container.Height());
+ currentMain->Parse();
+}
+
+const char *cLeMenuMain::PluginName(void) {
+ if (!label)
+ return NULL;
+ for (int i = 0; ; i++) {
+ cPlugin *p = cPluginManager::GetPlugin(i);
+ if (p) {
+ const char *mainMenuEntry = p->MainMenuEntry();
+ if (!mainMenuEntry)
+ continue;
+ if (!strcmp(mainMenuEntry, label)) {
+ return p->Name();
+ }
+ } else
+ break;
+ }
+ return NULL;
+}
+
+/******************************************************************
+* cCeMenuMain
+******************************************************************/
+cCeMenuMain::cCeMenuMain(void) {
+
+}
+
+cCeMenuMain::~cCeMenuMain(void) {
+
+}
+
+void cCeMenuMain::SetText(const char *text) {
+ dirty = true;
+ free(this->text);
+ this->text = strdup(text);
+}
+
+void cCeMenuMain::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{menuitemx}", (int)eCeMenuMainIT::menuitemx);
+ tokenContainer->DefineIntToken("{menuitemy}", (int)eCeMenuMainIT::menuitemy);
+ tokenContainer->DefineIntToken("{menuitemwidth}", (int)eCeMenuMainIT::menuitemwidth);
+ tokenContainer->DefineIntToken("{menuitemheight}", (int)eCeMenuMainIT::menuitemheight);
+ tokenContainer->DefineStringToken("{label}", (int)eCeMenuMainST::label);
+ tokenContainer->DefineStringToken("{number}", (int)eCeMenuMainST::number);
+ tokenContainer->DefineStringToken("{icon}", (int)eCeMenuMainST::icon);
+ InheritTokenContainer();
+}
+
+bool cCeMenuMain::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!dirty)
+ return false;
+ tokenContainer->Clear();
+ SplitText();
+ SetListTokens(tokenContainer);
+ tokenContainer->AddStringToken((int)eLeMenuMainST::number, number);
+ tokenContainer->AddStringToken((int)eLeMenuMainST::label, label);
+ tokenContainer->AddStringToken((int)eLeMenuMainST::icon, imgCache->GetIconName(label).c_str());
+ return true;
+}
+
+/******************************************************************
+* cVeMenuSchedules
+******************************************************************/
+cVeMenuSchedules::cVeMenuSchedules(void) {
+ event = NULL;
+ channel = NULL;
+ withDate = false;
+ timerMatch = tmNone;
+ epgSearchFav = false;
+}
+
+/******************************************************************
+* cLeMenuSchedules
+******************************************************************/
+cLeMenuSchedules::cLeMenuSchedules(void) {
+ currentSchedules = NULL;
+ menuCat = mcUnknown;
+}
+
+cLeMenuSchedules::cLeMenuSchedules(const cLeMenuSchedules &other) : cListElement(other) {
+}
+
+cLeMenuSchedules::~cLeMenuSchedules(void) {
+}
+
+void cLeMenuSchedules::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eLeMenuSchedulesST::title);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eLeMenuSchedulesST::shorttext);
+ tokenContainer->DefineStringToken("{start}", (int)eLeMenuSchedulesST::start);
+ tokenContainer->DefineStringToken("{stop}", (int)eLeMenuSchedulesST::stop);
+ tokenContainer->DefineStringToken("{day}", (int)eLeMenuSchedulesST::day);
+ tokenContainer->DefineStringToken("{date}", (int)eLeMenuSchedulesST::date);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eLeMenuSchedulesST::durationminutes);
+ tokenContainer->DefineStringToken("{channelname}", (int)eLeMenuSchedulesST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eLeMenuSchedulesST::channelid);
+ tokenContainer->DefineIntToken("{nummenuitem}", (int)eLeMenuSchedulesIT::nummenuitem);
+ tokenContainer->DefineIntToken("{current}", (int)eLeMenuSchedulesIT::current);
+ tokenContainer->DefineIntToken("{separator}", (int)eLeMenuSchedulesIT::separator);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eLeMenuSchedulesIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eLeMenuSchedulesIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eLeMenuSchedulesIT::year);
+ tokenContainer->DefineIntToken("{running}", (int)eLeMenuSchedulesIT::running);
+ tokenContainer->DefineIntToken("{elapsed}", (int)eLeMenuSchedulesIT::elapsed);
+ tokenContainer->DefineIntToken("{startsin}", (int)eLeMenuSchedulesIT::startsin);
+ tokenContainer->DefineIntToken("{duration}", (int)eLeMenuSchedulesIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eLeMenuSchedulesIT::durationhours);
+ tokenContainer->DefineIntToken("{channelnumber}", (int)eLeMenuSchedulesIT::channelnumber);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eLeMenuSchedulesIT::channellogoexists);
+ tokenContainer->DefineIntToken("{whatson}", (int)eLeMenuSchedulesIT::whatson);
+ tokenContainer->DefineIntToken("{whatsonnow}", (int)eLeMenuSchedulesIT::whatsonnow);
+ tokenContainer->DefineIntToken("{whatsonnext}", (int)eLeMenuSchedulesIT::whatsonnext);
+ tokenContainer->DefineIntToken("{whatsonfavorites}", (int)eLeMenuSchedulesIT::whatsonfavorites);
+ tokenContainer->DefineIntToken("{timerpartitial}", (int)eLeMenuSchedulesIT::timerpartitial);
+ tokenContainer->DefineIntToken("{timerfull}", (int)eLeMenuSchedulesIT::timerfull);
+ tokenContainer->DefineIntToken("{hasVPS}", (int)eLeMenuSchedulesIT::hasVPS);
+ InheritTokenContainer();
+}
+
+void cLeMenuSchedules::ClearCurrentElement(void) {
+ if (wasCurrent && currentSchedules) {
+ currentSchedules->Close();
+ }
+}
+
+void cLeMenuSchedules::Set(const cEvent *event, const cChannel *channel, bool withDate, eTimerMatch timerMatch) {
+ dirty = true;
+ this->event = event;
+ this->channel = channel;
+ this->withDate = withDate;
+ this->timerMatch = timerMatch;
+}
+
+bool cLeMenuSchedules::Parse(bool forced) {
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::nummenuitem, num);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::current, current);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::separator, !selectable);
+
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::whatson, (menuCat == mcSchedule && !epgSearchFav) ? true : false);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::whatsonnow, menuCat == mcScheduleNow ? true : false);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::whatsonnext, menuCat == mcScheduleNext ? true : false);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::whatsonfavorites, epgSearchFav);
+
+ if (timerMatch == tmFull) {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerpartitial, false);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerfull, true);
+ } else if (timerMatch == tmPartial) {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerpartitial, true);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerfull, false);
+ } else {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerpartitial, false);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerfull, false);
+ }
+
+ if (event) {
+ if (selectable) {
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::title, event->Title());
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::shorttext, event->ShortText());
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::start, *(event->GetTimeString()));
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::stop, *(event->GetEndTimeString()));
+ time_t startTime = event->StartTime();
+ struct tm * sStartTime = localtime(&startTime);
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::day, *WeekDayName(startTime));
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::date, *ShortDateString(startTime));
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::month, sStartTime->tm_mon+1);
+
+ bool isRunning = false;
+ time_t now = time(NULL);
+ if ((now >= event->StartTime()) && (now <= event->EndTime()))
+ isRunning = true;
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::running, isRunning);
+ if (isRunning) {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::elapsed, (now - event->StartTime())/60);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::startsin, 0);
+ } else {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::elapsed, 0);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::startsin, (event->StartTime() - now)/60);
+ }
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::duration, event->Duration() / 60);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::durationhours, event->Duration() / 3600);
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::durationminutes, *cString::sprintf("%.2d", (event->Duration() / 60)%60));
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::hasVPS, (bool)event->Vps());
+ } else {
+ char *sep = ParseSeparator(event->Title());
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::title, sep);
+ free(sep);
+ }
+ } else if (!channel) {
+ //Hack für komischen patch von jinx
+ //stringTokens.insert(pair<string,string>("title", dayseparator));
+ }
+ if (channel) {
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::channelname, channel->Name());
+ cString channelID = channel->GetChannelID().ToString();
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::channelnumber, channel->Number());
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::channellogoexists, imgCache->LogoExists(*channelID));
+ if (!event && !selectable) {
+ tokenContainer->AddStringToken((int)eLeMenuSchedulesST::title, channel->Name());
+ }
+ }
+ return true;
+}
+
+void cLeMenuSchedules::RenderCurrent(void) {
+ if (!currentSchedules)
+ return;
+ currentSchedules->Set(event, channel, withDate, timerMatch, menuCat);
+ currentSchedules->SetEpgSearchFav(epgSearchFav);
+ currentSchedules->SetListPosition(container.X(), container.Y(), container.Width(), container.Height());
+ currentSchedules->Parse();
+}
+
+/******************************************************************
+* cCeMenuSchedules
+******************************************************************/
+cCeMenuSchedules::cCeMenuSchedules(void) {
+ schedulesIndex = -1;
+}
+
+cCeMenuSchedules::~cCeMenuSchedules(void) {
+}
+
+void cCeMenuSchedules::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eCeMenuSchedulesST::title);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eCeMenuSchedulesST::shorttext);
+ tokenContainer->DefineStringToken("{description}", (int)eCeMenuSchedulesST::description);
+ tokenContainer->DefineStringToken("{start}", (int)eCeMenuSchedulesST::start);
+ tokenContainer->DefineStringToken("{stop}", (int)eCeMenuSchedulesST::stop);
+ tokenContainer->DefineStringToken("{day}", (int)eCeMenuSchedulesST::day);
+ tokenContainer->DefineStringToken("{date}", (int)eCeMenuSchedulesST::date);
+ tokenContainer->DefineStringToken("{channelname}", (int)eCeMenuSchedulesST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eCeMenuSchedulesST::channelid);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eCeMenuSchedulesST::posterpath);
+ tokenContainer->DefineStringToken("{bannerpath}", (int)eCeMenuSchedulesST::bannerpath);
+ tokenContainer->DefineIntToken("{menuitemx}", (int)eCeMenuSchedulesIT::menuitemx);
+ tokenContainer->DefineIntToken("{menuitemy}", (int)eCeMenuSchedulesIT::menuitemy);
+ tokenContainer->DefineIntToken("{menuitemwidth}", (int)eCeMenuSchedulesIT::menuitemwidth);
+ tokenContainer->DefineIntToken("{menuitemheight}", (int)eCeMenuSchedulesIT::menuitemheight);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eCeMenuSchedulesIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eCeMenuSchedulesIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eCeMenuSchedulesIT::year);
+ tokenContainer->DefineIntToken("{running}", (int)eCeMenuSchedulesIT::running);
+ tokenContainer->DefineIntToken("{elapsed}", (int)eCeMenuSchedulesIT::elapsed);
+ tokenContainer->DefineIntToken("{duration}", (int)eCeMenuSchedulesIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eCeMenuSchedulesIT::durationhours);
+ tokenContainer->DefineIntToken("{durationminutes}", (int)eCeMenuSchedulesIT::durationminutes);
+ tokenContainer->DefineIntToken("{channelnumber}", (int)eCeMenuSchedulesIT::channelnumber);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eCeMenuSchedulesIT::channellogoexists);
+ tokenContainer->DefineIntToken("{hasposter}", (int)eCeMenuSchedulesIT::hasposter);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eCeMenuSchedulesIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eCeMenuSchedulesIT::posterheight);
+ tokenContainer->DefineIntToken("{hasbanner}", (int)eCeMenuSchedulesIT::hasbanner);
+ tokenContainer->DefineIntToken("{bannerwidth}", (int)eCeMenuSchedulesIT::bannerwidth);
+ tokenContainer->DefineIntToken("{bannerheight}", (int)eCeMenuSchedulesIT::bannerheight);
+ tokenContainer->DefineIntToken("{whatson}", (int)eCeMenuSchedulesIT::whatson);
+ tokenContainer->DefineIntToken("{whatsonnow}", (int)eCeMenuSchedulesIT::whatsonnow);
+ tokenContainer->DefineIntToken("{whatsonnext}", (int)eCeMenuSchedulesIT::whatsonnext);
+ tokenContainer->DefineIntToken("{whatsonfavorites}", (int)eCeMenuSchedulesIT::whatsonfavorites);
+ tokenContainer->DefineIntToken("{timerpartitial}", (int)eCeMenuSchedulesIT::timerpartitial);
+ tokenContainer->DefineIntToken("{timerfull}", (int)eCeMenuSchedulesIT::timerfull);
+ tokenContainer->DefineLoopToken("{schedule[title]}", (int)eCeMenuSchedulesLT::title);
+ tokenContainer->DefineLoopToken("{schedule[shorttext]}", (int)eCeMenuSchedulesLT::shorttext);
+ tokenContainer->DefineLoopToken("{schedule[start]}", (int)eCeMenuSchedulesLT::start);
+ tokenContainer->DefineLoopToken("{schedule[stop]}", (int)eCeMenuSchedulesLT::stop);
+ schedulesIndex = tokenContainer->LoopIndex("schedule");
+ InheritTokenContainer();
+}
+
+void cCeMenuSchedules::Set(const cEvent *event, const cChannel *channel, bool withDate, eTimerMatch timerMatch, eMenuCategory menuCat) {
+ dirty = true;
+ this->menuCat = menuCat;
+ this->event = event;
+ this->channel = channel;
+ this->withDate = withDate;
+ this->timerMatch = timerMatch;
+}
+
+bool cCeMenuSchedules::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!dirty)
+ return false;
+ tokenContainer->Clear();
+ SetListTokens(tokenContainer);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::whatson, (menuCat == mcSchedule && !epgSearchFav) ? true : false);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::whatsonnow, menuCat == mcScheduleNow ? true : false);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::whatsonnext, menuCat == mcScheduleNext ? true : false);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::whatsonfavorites, epgSearchFav);
+ if (timerMatch == tmFull) {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerpartitial, false);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerfull, true);
+ } else if (timerMatch == tmPartial) {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerpartitial, true);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerfull, false);
+ } else {
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerpartitial, false);
+ tokenContainer->AddIntToken((int)eLeMenuSchedulesIT::timerfull, false);
+ }
+
+ if (event) {
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::title, event->Title());
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::shorttext, event->ShortText());
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::description, event->Description());
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::start, *(event->GetTimeString()));
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::stop, *(event->GetEndTimeString()));
+ time_t startTime = event->StartTime();
+ struct tm * sStartTime = localtime(&startTime);
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::day, *WeekDayName(startTime));
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::date, *ShortDateString(startTime));
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::month, sStartTime->tm_mon+1);
+ bool isRunning = false;
+ time_t now = time(NULL);
+ if ((now >= event->StartTime()) && (now <= event->EndTime()))
+ isRunning = true;
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::running, isRunning);
+ if (isRunning) {
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::elapsed, (now - event->StartTime())/60);
+ } else {
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::elapsed, 0);
+ }
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::duration, event->Duration() / 60);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::durationhours, event->Duration() / 3600);
+ if (LoadFullScrapInfo(event, NULL))
+ SetScraperPosterBanner(tokenContainer);
+ }
+ if (channel) {
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::channelname, channel->Name());
+ cString channelID = channel->GetChannelID().ToString();
+ tokenContainer->AddStringToken((int)eCeMenuSchedulesST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::channelnumber, channel->Number());
+ tokenContainer->AddIntToken((int)eCeMenuSchedulesIT::channellogoexists, imgCache->LogoExists(*channelID));
+ }
+
+ if (menuCat == mcScheduleNow || menuCat == mcScheduleNext) {
+ int eventsAvailable = 0;
+ cSchedulesLock schedulesLock;
+ const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
+ const cSchedule *schedule = NULL;
+ schedule = schedules->GetSchedule(channel);
+ if (schedule) {
+ for (const cEvent *e = schedule->GetPresentEvent(); e; e = schedule->Events()->Next(e)) {
+ eventsAvailable++;
+ if (eventsAvailable == 10)
+ break;
+ }
+ }
+ vector<int> loopInfo;
+ loopInfo.push_back(eventsAvailable);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+
+ if (schedule) {
+ int num = 0;
+ for (const cEvent *e = schedule->GetPresentEvent(); e; e = schedule->Events()->Next(e)) {
+ if (num < 2) {
+ num++;
+ continue;
+ }
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::title, e->Title());
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::shorttext, e->ShortText());
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::start, *(e->GetTimeString()));
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::stop, *(e->GetEndTimeString()));
+ num++;
+ if (num > 11)
+ break;
+ }
+ }
+ }
+ return true;
+}
+
+/******************************************************************
+* cLeMenuChannels
+******************************************************************/
+cLeMenuChannels::cLeMenuChannels(void) {
+ currentChannel = NULL;
+ channel = NULL;
+ withProvider = false;
+}
+
+cLeMenuChannels::cLeMenuChannels(const cLeMenuChannels &other) : cListElement(other) {
+ channel = NULL;
+ withProvider = false;
+}
+
+cLeMenuChannels::~cLeMenuChannels(void) {
+}
+
+void cLeMenuChannels::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{name}", (int)eLeMenuChannelsST::name);
+ tokenContainer->DefineStringToken("{channelid}", (int)eLeMenuChannelsST::channelid);
+ tokenContainer->DefineStringToken("{source}", (int)eLeMenuChannelsST::source);
+ tokenContainer->DefineStringToken("{sourcedescription}", (int)eLeMenuChannelsST::sourcedescription);
+ tokenContainer->DefineStringToken("{position}", (int)eLeMenuChannelsST::position);
+ tokenContainer->DefineStringToken("{presenteventtitle}", (int)eLeMenuChannelsST::presenteventtitle);
+ tokenContainer->DefineStringToken("{presenteventstart}", (int)eLeMenuChannelsST::presenteventstart);
+ tokenContainer->DefineStringToken("{presenteventstop}", (int)eLeMenuChannelsST::presenteventstop);
+ tokenContainer->DefineIntToken("{nummenuitem}", (int)eLeMenuChannelsIT::nummenuitem);
+ tokenContainer->DefineIntToken("{current}", (int)eLeMenuChannelsIT::current);
+ tokenContainer->DefineIntToken("{separator}", (int)eLeMenuChannelsIT::separator);
+ tokenContainer->DefineIntToken("{number}", (int)eLeMenuChannelsIT::number);
+ tokenContainer->DefineIntToken("{transponder}", (int)eLeMenuChannelsIT::transponder);
+ tokenContainer->DefineIntToken("{frequency}", (int)eLeMenuChannelsIT::frequency);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eLeMenuChannelsIT::channellogoexists);
+ tokenContainer->DefineIntToken("{isAtsc}", (int)eLeMenuChannelsIT::isAtsc);
+ tokenContainer->DefineIntToken("{isCable}", (int)eLeMenuChannelsIT::isCable);
+ tokenContainer->DefineIntToken("{isSat}", (int)eLeMenuChannelsIT::isSat);
+ tokenContainer->DefineIntToken("{isTerr}", (int)eLeMenuChannelsIT::isTerr);
+ InheritTokenContainer();
+}
+
+void cLeMenuChannels::ClearCurrentElement(void) {
+ if (wasCurrent && currentChannel) {
+ currentChannel->Close();
+ }
+}
+
+void cLeMenuChannels::Set(const cChannel *channel, bool withProvider) {
+ dirty = true;
+ this->channel = channel;
+ this->withProvider = withProvider;
+}
+
+bool cLeMenuChannels::Parse(bool forced) {
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::nummenuitem, num);
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::current, current);
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::separator, !selectable);
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::number, channel->Number());
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::transponder, channel->Transponder());
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::frequency, channel->Frequency());
+
+ tokenContainer->AddStringToken((int)eLeMenuChannelsST::name, channel->Name());
+ cString channelID = channel->GetChannelID().ToString();
+ tokenContainer->AddStringToken((int)eLeMenuChannelsST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::channellogoexists, imgCache->LogoExists(*channelID));
+
+ //Channel Source Information
+ const cSource *source = Sources.Get(channel->Source());
+ if (source) {
+ tokenContainer->AddStringToken((int)eLeMenuChannelsST::source, *cSource::ToString(source->Code()));
+ tokenContainer->AddStringToken((int)eLeMenuChannelsST::sourcedescription, source->Description());
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::isAtsc, source->IsAtsc(source->Code()));
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::isCable, source->IsCable(source->Code()));
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::isSat, source->IsSat(source->Code()));
+ tokenContainer->AddIntToken((int)eLeMenuChannelsIT::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) {
+ tokenContainer->AddStringToken((int)eLeMenuChannelsST::presenteventtitle, presentEvent->Title());
+ tokenContainer->AddStringToken((int)eLeMenuChannelsST::presenteventstart, *presentEvent->GetTimeString());
+ tokenContainer->AddStringToken((int)eLeMenuChannelsST::presenteventstop, *presentEvent->GetEndTimeString());
+ }
+ }
+ return true;
+}
+
+void cLeMenuChannels::RenderCurrent(void) {
+ if (!currentChannel)
+ return;
+ currentChannel->Set(channel, withProvider);
+ currentChannel->SetListPosition(container.X(), container.Y(), container.Width(), container.Height());
+ currentChannel->Parse();
+}
+
+/******************************************************************
+* cCeMenuChannels
+******************************************************************/
+cCeMenuChannels::cCeMenuChannels(void) {
+ schedulesIndex = -1;
+ channel = NULL;
+ withProvider = false;
+}
+
+cCeMenuChannels::~cCeMenuChannels(void) {
+}
+
+void cCeMenuChannels::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{name}", (int)eCeMenuChannelsST::name);
+ tokenContainer->DefineStringToken("{channelid}", (int)eCeMenuChannelsST::channelid);
+ tokenContainer->DefineStringToken("{source}", (int)eCeMenuChannelsST::source);
+ tokenContainer->DefineStringToken("{sourcedescription}", (int)eCeMenuChannelsST::sourcedescription);
+ tokenContainer->DefineStringToken("{position}", (int)eCeMenuChannelsST::position);
+ tokenContainer->DefineStringToken("{presenteventtitle}", (int)eCeMenuChannelsST::presenteventtitle);
+ tokenContainer->DefineStringToken("{presenteventstart}", (int)eCeMenuChannelsST::presenteventstart);
+ tokenContainer->DefineStringToken("{presenteventstop}", (int)eCeMenuChannelsST::presenteventstop);
+ tokenContainer->DefineStringToken("{presenteventshorttext}", (int)eCeMenuChannelsST::presenteventshorttext);
+ tokenContainer->DefineStringToken("{presenteventdescription}", (int)eCeMenuChannelsST::presenteventdescription);
+ tokenContainer->DefineStringToken("{presenteventday}", (int)eCeMenuChannelsST::presenteventday);
+ tokenContainer->DefineStringToken("{presenteventdate}", (int)eCeMenuChannelsST::presenteventdate);
+ tokenContainer->DefineStringToken("{presenteventdurationminutes}", (int)eCeMenuChannelsST::presenteventdurationminutes);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eCeMenuChannelsST::posterpath);
+ tokenContainer->DefineStringToken("{nexteventtitle}", (int)eCeMenuChannelsST::nexteventtitle);
+ tokenContainer->DefineStringToken("{nexteventstart}", (int)eCeMenuChannelsST::nexteventstart);
+ tokenContainer->DefineStringToken("{nexteventstop}", (int)eCeMenuChannelsST::nexteventstop);
+ tokenContainer->DefineStringToken("{nexteventshorttext}", (int)eCeMenuChannelsST::nexteventshorttext);
+ tokenContainer->DefineStringToken("{nexteventdescription}", (int)eCeMenuChannelsST::nexteventdescription);
+ tokenContainer->DefineStringToken("{nexteventdurationminutes}", (int)eCeMenuChannelsST::nexteventdurationminutes);
+ tokenContainer->DefineStringToken("{nexteventday}", (int)eCeMenuChannelsST::nexteventday);
+ tokenContainer->DefineStringToken("{nexteventdate}", (int)eCeMenuChannelsST::nexteventdate);
+ tokenContainer->DefineIntToken("{menuitemx}", (int)eCeMenuChannelsIT::menuitemx);
+ tokenContainer->DefineIntToken("{menuitemy}", (int)eCeMenuChannelsIT::menuitemy);
+ tokenContainer->DefineIntToken("{menuitemwidth}", (int)eCeMenuChannelsIT::menuitemwidth);
+ tokenContainer->DefineIntToken("{menuitemheight}", (int)eCeMenuChannelsIT::menuitemheight);
+ tokenContainer->DefineIntToken("{number}", (int)eCeMenuChannelsIT::number);
+ tokenContainer->DefineIntToken("{transponder}", (int)eCeMenuChannelsIT::transponder);
+ tokenContainer->DefineIntToken("{frequency}", (int)eCeMenuChannelsIT::frequency);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eCeMenuChannelsIT::channellogoexists);
+ tokenContainer->DefineIntToken("{isAtsc}", (int)eCeMenuChannelsIT::isAtsc);
+ tokenContainer->DefineIntToken("{isCable}", (int)eCeMenuChannelsIT::isCable);
+ tokenContainer->DefineIntToken("{isSat}", (int)eCeMenuChannelsIT::isSat);
+ tokenContainer->DefineIntToken("{isTerr}", (int)eCeMenuChannelsIT::isTerr);
+ tokenContainer->DefineIntToken("{presenteventelapsed}", (int)eCeMenuChannelsIT::presenteventelapsed);
+ tokenContainer->DefineIntToken("{presenteventduration}", (int)eCeMenuChannelsIT::presenteventduration);
+ tokenContainer->DefineIntToken("{presenteventdurationhours}", (int)eCeMenuChannelsIT::presenteventdurationhours);
+ tokenContainer->DefineIntToken("{hasposter}", (int)eCeMenuChannelsIT::hasposter);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eCeMenuChannelsIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eCeMenuChannelsIT::posterheight);
+ tokenContainer->DefineIntToken("{nexteventduration}", (int)eCeMenuChannelsIT::nexteventduration);
+ tokenContainer->DefineIntToken("{nexteventdurationhours}", (int)eCeMenuChannelsIT::nexteventdurationhours);
+ tokenContainer->DefineLoopToken("{schedule[title]}", (int)eCeMenuChannelsLT::title);
+ tokenContainer->DefineLoopToken("{schedule[shorttext]}", (int)eCeMenuChannelsLT::shorttext);
+ tokenContainer->DefineLoopToken("{schedule[start]}", (int)eCeMenuChannelsLT::start);
+ tokenContainer->DefineLoopToken("{schedule[stop]}", (int)eCeMenuChannelsLT::stop);
+ schedulesIndex = tokenContainer->LoopIndex("schedule");
+ InheritTokenContainer();
+}
+
+void cCeMenuChannels::Set(const cChannel *channel, bool withProvider) {
+ dirty = true;
+ this->channel = channel;
+ this->withProvider = withProvider;
+}
+
+bool cCeMenuChannels::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+
+ SetListTokens(tokenContainer);
+
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::number, channel->Number());
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::transponder, channel->Transponder());
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::frequency, channel->Frequency());
+
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::name, channel->Name());
+ cString channelID = channel->GetChannelID().ToString();
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::channellogoexists, imgCache->LogoExists(*channelID));
+
+ //Channel Source Information
+ const cSource *source = Sources.Get(channel->Source());
+ if (source) {
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::source, *cSource::ToString(source->Code()));
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::sourcedescription, source->Description());
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::isAtsc, source->IsAtsc(source->Code()));
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::isCable, source->IsCable(source->Code()));
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::isSat, source->IsSat(source->Code()));
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::isTerr, source->IsTerr(source->Code()));
+ }
+
+ 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) {
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventtitle, presentEvent->Title());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventshorttext, presentEvent->ShortText());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventdescription, presentEvent->Description());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventstart, *presentEvent->GetTimeString());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventstop, *presentEvent->GetEndTimeString());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventday, *WeekDayName(presentEvent->StartTime()));
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventdate, *ShortDateString(presentEvent->StartTime()));
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::presenteventelapsed, (time(0) - presentEvent->StartTime())/60);
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::presenteventduration, presentEvent->Duration() / 60);
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::presenteventdurationhours, presentEvent->Duration() / 3600);
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::presenteventdurationminutes, *cString::sprintf("%.2d", (presentEvent->Duration() / 60)%60));
+ //SetScraperPoster(presentEvent);
+ }
+ const cList<cEvent> *events = schedule->Events();
+ if (events && presentEvent) {
+ const cEvent *nextEvent = events->Next(presentEvent);
+ if (nextEvent) {
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventtitle, nextEvent->Title());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventshorttext, nextEvent->ShortText());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventdescription, nextEvent->Description());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventstart, *nextEvent->GetTimeString());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventstop, *nextEvent->GetEndTimeString());
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventday, *WeekDayName(nextEvent->StartTime()));
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventdate, *ShortDateString(nextEvent->StartTime()));
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::nexteventduration, nextEvent->Duration() / 60);
+ tokenContainer->AddIntToken((int)eCeMenuChannelsIT::nexteventdurationhours, nextEvent->Duration() / 3600);
+ tokenContainer->AddStringToken((int)eCeMenuChannelsST::nexteventdurationminutes, *cString::sprintf("%.2d", (nextEvent->Duration() / 60)%60));
+ }
+ }
+ }
+
+ vector<int> loopInfo;
+ int eventsAvailable = 0;
+ if (schedule) {
+ for (const cEvent *e = schedule->GetPresentEvent(); e; e = schedule->Events()->Next(e)) {
+ eventsAvailable++;
+ if (eventsAvailable == 10)
+ break;
+ }
+ }
+ loopInfo.push_back(eventsAvailable);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+
+ if (schedule) {
+ int num = 0;
+ for (const cEvent *e = schedule->GetPresentEvent(); e; e = schedule->Events()->Next(e)) {
+ if (num < 2) {
+ num++;
+ continue;
+ }
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::title, e->Title());
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::shorttext, e->ShortText());
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::start, *(e->GetTimeString()));
+ tokenContainer->AddLoopToken(schedulesIndex, num-2, (int)eCeMenuChannelsLT::stop, *(e->GetEndTimeString()));
+ num++;
+ if (num > 11)
+ break;
+ }
+ }
+ return true;
+}
+
+/******************************************************************
+* cLeMenuTimers
+******************************************************************/
+cLeMenuTimers::cLeMenuTimers(void) {
+ currentTimer = NULL;
+ timer = NULL;
+}
+
+cLeMenuTimers::~cLeMenuTimers(void) {
+}
+
+void cLeMenuTimers::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eLeMenuTimersST::title);
+ tokenContainer->DefineStringToken("{timerstart}", (int)eLeMenuTimersST::timerstart);
+ tokenContainer->DefineStringToken("{timerstop}", (int)eLeMenuTimersST::timerstop);
+ tokenContainer->DefineStringToken("{day}", (int)eLeMenuTimersST::day);
+ tokenContainer->DefineStringToken("{dayname}", (int)eLeMenuTimersST::dayname);
+ tokenContainer->DefineStringToken("{monthname}", (int)eLeMenuTimersST::monthname);
+ tokenContainer->DefineStringToken("{channelname}", (int)eLeMenuTimersST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eLeMenuTimersST::channelid);
+ tokenContainer->DefineStringToken("{eventtitle}", (int)eLeMenuTimersST::eventtitle);
+ tokenContainer->DefineStringToken("{eventstart}", (int)eLeMenuTimersST::eventstart);
+ tokenContainer->DefineStringToken("{eventstop}", (int)eLeMenuTimersST::eventstop);
+ tokenContainer->DefineIntToken("{nummenuitem}", (int)eLeMenuTimersIT::nummenuitem);
+ tokenContainer->DefineIntToken("{current}", (int)eLeMenuTimersIT::current);
+ tokenContainer->DefineIntToken("{separator}", (int)eLeMenuTimersIT::separator);
+ tokenContainer->DefineIntToken("{month}", (int)eLeMenuTimersIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eLeMenuTimersIT::year);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eLeMenuTimersIT::channellogoexists);
+ tokenContainer->DefineIntToken("{channelnumber}", (int)eLeMenuTimersIT::channelnumber);
+ tokenContainer->DefineIntToken("{flagactive}", (int)eLeMenuTimersIT::flagactive);
+ tokenContainer->DefineIntToken("{flaginstant}", (int)eLeMenuTimersIT::flaginstant);
+ tokenContainer->DefineIntToken("{flagvps}", (int)eLeMenuTimersIT::flagvps);
+ tokenContainer->DefineIntToken("{flagrecording}", (int)eLeMenuTimersIT::flagrecording);
+ tokenContainer->DefineIntToken("{flagpending}", (int)eLeMenuTimersIT::flagpending);
+ InheritTokenContainer();
+}
+
+void cLeMenuTimers::ClearCurrentElement(void) {
+ if (wasCurrent && currentTimer) {
+ currentTimer->Close();
+ }
+}
+
+void cLeMenuTimers::Set(const cTimer *timer) {
+ this->timer = timer;
+ dirty = true;
+}
+
+bool cLeMenuTimers::Parse(bool forced) {
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::nummenuitem, num);
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::current, current);
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::separator, !selectable);
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::flagactive, timer->HasFlags(tfActive));
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::flaginstant, timer->HasFlags(tfInstant));
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::flagvps, timer->HasFlags(tfVps));
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::flagrecording, timer->Recording());
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::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();
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::title, file);
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::timerstart, *cString::sprintf("%02d:%02d", timer->Start() / 100, timer->Start() % 100));
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::timerstop, *cString::sprintf("%02d:%02d", timer->Stop() / 100, timer->Stop() % 100));
+
+ cString day("");
+ cString 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);
+ char buffer3[6];
+ strftime(buffer3, sizeof(buffer3), "%Y", &tm_r);
+ int year = atoi(buffer3);
+
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::day, *day);
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::dayname, *dayName);
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::month, month);
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::monthname, buffer2);
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::year, year);
+
+ const cChannel *channel = timer->Channel();
+ if (channel) {
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::channelname, channel->Name());
+ cString channelID = channel->GetChannelID().ToString();
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::channellogoexists, imgCache->LogoExists(*channelID));
+ tokenContainer->AddIntToken((int)eLeMenuTimersIT::channelnumber, channel->Number());
+ }
+
+ const cEvent *event = timer->Event();
+ if (event) {
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::eventtitle, event->Title());
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::eventstart, *event->GetTimeString());
+ tokenContainer->AddStringToken((int)eLeMenuTimersST::eventstop, *event->GetEndTimeString());
+ }
+ return true;
+}
+
+void cLeMenuTimers::RenderCurrent(void) {
+ if (!currentTimer)
+ return;
+ currentTimer->Set(timer);
+ currentTimer->SetListPosition(container.X(), container.Y(), container.Width(), container.Height());
+ currentTimer->Parse();
+}
+
+/******************************************************************
+* cCeMenuTimers
+******************************************************************/
+cCeMenuTimers::cCeMenuTimers(void) {
+ timer = NULL;
+}
+
+cCeMenuTimers::~cCeMenuTimers(void) {
+
+}
+
+void cCeMenuTimers::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eCeMenuTimersST::title);
+ tokenContainer->DefineStringToken("{timerstart}", (int)eCeMenuTimersST::timerstart);
+ tokenContainer->DefineStringToken("{timerstop}", (int)eCeMenuTimersST::timerstop);
+ tokenContainer->DefineStringToken("{day}", (int)eCeMenuTimersST::day);
+ tokenContainer->DefineStringToken("{dayname}", (int)eCeMenuTimersST::dayname);
+ tokenContainer->DefineStringToken("{monthname}", (int)eCeMenuTimersST::monthname);
+ tokenContainer->DefineStringToken("{channelname}", (int)eCeMenuTimersST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eCeMenuTimersST::channelid);
+ tokenContainer->DefineStringToken("{eventtitle}", (int)eCeMenuTimersST::eventtitle);
+ tokenContainer->DefineStringToken("{eventstart}", (int)eCeMenuTimersST::eventstart);
+ tokenContainer->DefineStringToken("{eventstop}", (int)eCeMenuTimersST::eventstop);
+ tokenContainer->DefineStringToken("{eventshorttext}", (int)eCeMenuTimersST::eventshorttext);
+ tokenContainer->DefineStringToken("{eventdescription}", (int)eCeMenuTimersST::eventdescription);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eCeMenuTimersST::posterpath);
+ tokenContainer->DefineIntToken("{menuitemx}", (int)eCeMenuTimersIT::menuitemx);
+ tokenContainer->DefineIntToken("{menuitemy}", (int)eCeMenuTimersIT::menuitemy);
+ tokenContainer->DefineIntToken("{menuitemwidth}", (int)eCeMenuTimersIT::menuitemwidth);
+ tokenContainer->DefineIntToken("{menuitemheight}", (int)eCeMenuTimersIT::menuitemheight);
+ tokenContainer->DefineIntToken("{month}", (int)eCeMenuTimersIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eCeMenuTimersIT::year);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eCeMenuTimersIT::channellogoexists);
+ tokenContainer->DefineIntToken("{channelnumber}", (int)eCeMenuTimersIT::channelnumber);
+ tokenContainer->DefineIntToken("{flagactive}", (int)eCeMenuTimersIT::flagactive);
+ tokenContainer->DefineIntToken("{flaginstant}", (int)eCeMenuTimersIT::flaginstant);
+ tokenContainer->DefineIntToken("{flagvps}", (int)eCeMenuTimersIT::flagvps);
+ tokenContainer->DefineIntToken("{flagrecording}", (int)eCeMenuTimersIT::flagrecording);
+ tokenContainer->DefineIntToken("{flagpending}", (int)eCeMenuTimersIT::flagpending);
+ tokenContainer->DefineIntToken("{hasposter}", (int)eCeMenuTimersIT::hasposter);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eCeMenuTimersIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eCeMenuTimersIT::posterheight);
+ InheritTokenContainer();
+}
+
+void cCeMenuTimers::Set(const cTimer *timer) {
+ dirty = true;
+ this->timer = timer;
+}
+
+bool cCeMenuTimers::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+
+ SetListTokens(tokenContainer);
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::flagactive, timer->HasFlags(tfActive));
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::flaginstant, timer->HasFlags(tfInstant));
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::flagvps, timer->HasFlags(tfVps));
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::flagrecording, timer->Recording());
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::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();
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::title, file);
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::timerstart, *cString::sprintf("%02d:%02d", timer->Start() / 100, timer->Start() % 100));
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::timerstop, *cString::sprintf("%02d:%02d", timer->Stop() / 100, timer->Stop() % 100));
+
+ cString day("");
+ cString 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);
+ char buffer3[6];
+ strftime(buffer3, sizeof(buffer3), "%Y", &tm_r);
+ int year = atoi(buffer3);
+
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::day, *day);
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::dayname, *dayName);
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::month, month);
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::monthname, buffer2);
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::year, year);
+
+ const cChannel *channel = timer->Channel();
+ if (channel) {
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::channelname, channel->Name());
+ cString channelID = channel->GetChannelID().ToString();
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::channellogoexists, imgCache->LogoExists(*channelID));
+ tokenContainer->AddIntToken((int)eCeMenuTimersIT::channelnumber, channel->Number());
+ }
+
+ const cEvent *event = timer->Event();
+ if (event) {
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::eventtitle, event->Title());
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::eventstart, *event->GetTimeString());
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::eventstop, *event->GetEndTimeString());
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::eventshorttext, event->ShortText());
+ tokenContainer->AddStringToken((int)eCeMenuTimersST::eventdescription, event->Description());
+ }
+ return true;
+}
+
+/******************************************************************
+* cLeMenuRecordings
+******************************************************************/
+cLeMenuRecordings::cLeMenuRecordings(void) {
+ currentRecording = NULL;
+ recording = NULL;
+ level = 0;
+ total = 0;
+ New = 0;
+}
+
+cLeMenuRecordings::~cLeMenuRecordings(void) {
+}
+
+void cLeMenuRecordings::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{name}", (int)eLeMenuRecordingsST::name);
+ tokenContainer->DefineStringToken("{epgname}", (int)eLeMenuRecordingsST::epgname);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eLeMenuRecordingsST::shorttext);
+ tokenContainer->DefineStringToken("{description}", (int)eLeMenuRecordingsST::description);
+ tokenContainer->DefineStringToken("{date}", (int)eLeMenuRecordingsST::date);
+ tokenContainer->DefineStringToken("{time}", (int)eLeMenuRecordingsST::time);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eLeMenuRecordingsST::durationminutes);
+ tokenContainer->DefineStringToken("{durationeventminutes}", (int)eLeMenuRecordingsST::durationeventminutes);
+ tokenContainer->DefineStringToken("{thumbnailpath}", (int)eLeMenuRecordingsST::thumbnailpath);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eLeMenuRecordingsST::posterpath);
+ tokenContainer->DefineIntToken("{nummenuitem}", (int)eLeMenuRecordingsIT::nummenuitem);
+ tokenContainer->DefineIntToken("{current}", (int)eLeMenuRecordingsIT::current);
+ tokenContainer->DefineIntToken("{new}", (int)eLeMenuRecordingsIT::isnew);
+ tokenContainer->DefineIntToken("{percentseen}", (int)eLeMenuRecordingsIT::percentseen);
+ tokenContainer->DefineIntToken("{watched}", (int)eLeMenuRecordingsIT::watched);
+ tokenContainer->DefineIntToken("{cutted}", (int)eLeMenuRecordingsIT::cutted);
+ tokenContainer->DefineIntToken("{folder}", (int)eLeMenuRecordingsIT::folder);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eLeMenuRecordingsIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eLeMenuRecordingsIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eLeMenuRecordingsIT::year);
+ tokenContainer->DefineIntToken("{duration}", (int)eLeMenuRecordingsIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eLeMenuRecordingsIT::durationhours);
+ tokenContainer->DefineIntToken("{durationevent}", (int)eLeMenuRecordingsIT::durationevent);
+ tokenContainer->DefineIntToken("{durationeventhours}", (int)eLeMenuRecordingsIT::durationeventhours);
+ tokenContainer->DefineIntToken("{numrecordingsfolder}", (int)eLeMenuRecordingsIT::numrecordingsfolder);
+ tokenContainer->DefineIntToken("{newrecordingsfolder}", (int)eLeMenuRecordingsIT::newrecordingsfolder);
+ tokenContainer->DefineIntToken("{hasposterthumbnail}", (int)eLeMenuRecordingsIT::hasposterthumbnail);
+ tokenContainer->DefineIntToken("{thumbnailwidth}", (int)eLeMenuRecordingsIT::thumbnailwidth);
+ tokenContainer->DefineIntToken("{thumbnailheight}", (int)eLeMenuRecordingsIT::thumbnailheight);
+ tokenContainer->DefineIntToken("{hasposter}", (int)eLeMenuRecordingsIT::hasposter);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eLeMenuRecordingsIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eLeMenuRecordingsIT::posterheight);
+ InheritTokenContainer();
+}
+
+void cLeMenuRecordings::ClearCurrentElement(void) {
+ if (wasCurrent && currentRecording) {
+ currentRecording->Close();
+ }
+}
+
+void cLeMenuRecordings::Set(const cRecording *recording, int level, int total, int New) {
+ this->recording = recording;
+ this->level = level;
+ this->total = total;
+ this->New = New;
+ dirty = true;
+}
+
+bool cLeMenuRecordings::Parse(bool forced) {
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::nummenuitem, num);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::current, current);
+ bool isFolder = (total > 0) ? true : false;
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::folder, isFolder);
+
+ char *recName = RecName(recording->Name(), level);
+ tokenContainer->AddStringToken((int)eLeMenuRecordingsST::name, recName);
+ delete[] recName;
+
+ const cRecording *usedRecording = recording;
+
+ if (isFolder) {
+ char *folderName = FolderName(recording->Name(), level);
+ cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName);
+ delete[] folderName;
+ if (folderInfo) {
+ cRecording *newestRec = Recordings.GetByName(*folderInfo->LatestFileName);
+ if (newestRec) {
+ usedRecording = newestRec;
+ }
+ delete folderInfo;
+ }
+ }
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::isnew, 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
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::percentseen, percSeen);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::newrecordingsfolder, New);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::numrecordingsfolder, total);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::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;
+ }
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::watched, watched);
+
+ const cEvent *event = NULL;
+ const cRecordingInfo *info = usedRecording->Info();
+ if (!info) return true;
+ event = info->GetEvent();
+ if (!event) return true;
+
+ cString recDate = event->GetDateString();
+ cString recTime = event->GetTimeString();
+ if (strstr(*recDate, "1970")) {
+ 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);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::month, sStartTime->tm_mon+1);
+
+ int duration = event->Duration() / 60;
+ recDuration = (recDuration>0)?(recDuration / 60):0;
+ tokenContainer->AddStringToken((int)eLeMenuRecordingsST::date, *recDate);
+ tokenContainer->AddStringToken((int)eLeMenuRecordingsST::time, *recTime);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::duration, recDuration);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::durationhours, recDuration / 60);
+ tokenContainer->AddStringToken((int)eLeMenuRecordingsST::durationminutes, *cString::sprintf("%.2d", recDuration%60));
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::durationevent, duration);
+ tokenContainer->AddIntToken((int)eLeMenuRecordingsIT::durationeventhours, duration / 60);
+ tokenContainer->AddStringToken((int)eLeMenuRecordingsST::durationeventminutes, *cString::sprintf("%.2d", duration%60));
+
+ tokenContainer->AddStringToken((int)eLeMenuRecordingsST::shorttext, info->ShortText());
+ tokenContainer->AddStringToken((int)eLeMenuRecordingsST::description, info->Description());
+
+ SetScraperRecordingPoster(tokenContainer, usedRecording, true);
+
+ return true;
+}
+
+void cLeMenuRecordings::RenderCurrent(void) {
+ if (!currentRecording)
+ return;
+ currentRecording->Set(recording, level, total, New);
+ currentRecording->SetListPosition(container.X(), container.Y(), container.Width(), container.Height());
+ currentRecording->Parse();
+}
+
+char *cLeMenuRecordings::RecName(const char *path, int level) {
+ char *recName;
+ const char *startName = path;
+ for (int i = 0; i < level; i++) {
+ startName = strchr(startName, FOLDERDELIMCHAR);
+ startName++;
+ }
+ const char *endName = startName;
+ if (endName = strchr(endName, FOLDERDELIMCHAR)) {
+ int len = endName - startName;
+ recName = new char[len+1];
+ strncpy(recName, startName, len);
+ recName[len] = 0;
+ } else {
+ recName = strdup(startName);
+ }
+ return recName;
+}
+
+char *cLeMenuRecordings::FolderName(const char *path, int level) {
+ char *folderName;
+ const char *endName = path;
+ bool foundEnd = false;
+ for (int i = 0; i <= level; i++) {
+ endName = strchr(endName, FOLDERDELIMCHAR);
+ if (!endName) {
+ foundEnd = false;
+ }
+ foundEnd = true;
+ endName++;
+ }
+ if (foundEnd) {
+ int len = endName - path - 1;
+ folderName = new char[len+1];
+ strncpy(folderName, path, len);
+ folderName[len] = 0;
+ } else {
+ folderName = strdup(path);
+ }
+ return folderName;
+}
+
+/******************************************************************
+* cCeMenuRecordings
+******************************************************************/
+cCeMenuRecordings::cCeMenuRecordings(void) {
+ recording = NULL;
+ level = 0;
+ total = 0;
+ New = 0;
+}
+
+cCeMenuRecordings::~cCeMenuRecordings(void) {
+}
+
+void cCeMenuRecordings::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{name}", (int)eCeMenuRecordingsST::name);
+ tokenContainer->DefineStringToken("{epgname}", (int)eCeMenuRecordingsST::epgname);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eCeMenuRecordingsST::shorttext);
+ tokenContainer->DefineStringToken("{description}", (int)eCeMenuRecordingsST::description);
+ tokenContainer->DefineStringToken("{date}", (int)eCeMenuRecordingsST::date);
+ tokenContainer->DefineStringToken("{time}", (int)eCeMenuRecordingsST::time);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eCeMenuRecordingsST::durationminutes);
+ tokenContainer->DefineStringToken("{durationeventminutes}", (int)eCeMenuRecordingsST::durationeventminutes);
+ tokenContainer->DefineStringToken("{thumbnailpath}", (int)eCeMenuRecordingsST::thumbnailpath);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eCeMenuRecordingsST::posterpath);
+ tokenContainer->DefineIntToken("{menuitemx}", (int)eCeMenuRecordingsIT::menuitemx);
+ tokenContainer->DefineIntToken("{menuitemy}", (int)eCeMenuRecordingsIT::menuitemy);
+ tokenContainer->DefineIntToken("{menuitemwidth}", (int)eCeMenuRecordingsIT::menuitemwidth);
+ tokenContainer->DefineIntToken("{menuitemheight}", (int)eCeMenuRecordingsIT::menuitemheight);
+ tokenContainer->DefineIntToken("{new}", (int)eCeMenuRecordingsIT::isnew);
+ tokenContainer->DefineIntToken("{percentseen}", (int)eCeMenuRecordingsIT::percentseen);
+ tokenContainer->DefineIntToken("{watched}", (int)eCeMenuRecordingsIT::watched);
+ tokenContainer->DefineIntToken("{cutted}", (int)eCeMenuRecordingsIT::cutted);
+ tokenContainer->DefineIntToken("{folder}", (int)eCeMenuRecordingsIT::folder);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eCeMenuRecordingsIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eCeMenuRecordingsIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eCeMenuRecordingsIT::year);
+ tokenContainer->DefineIntToken("{duration}", (int)eCeMenuRecordingsIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eCeMenuRecordingsIT::durationhours);
+ tokenContainer->DefineIntToken("{durationevent}", (int)eCeMenuRecordingsIT::durationevent);
+ tokenContainer->DefineIntToken("{durationeventhours}", (int)eCeMenuRecordingsIT::durationeventhours);
+ tokenContainer->DefineIntToken("{numrecordingsfolder}", (int)eCeMenuRecordingsIT::numrecordingsfolder);
+ tokenContainer->DefineIntToken("{newrecordingsfolder}", (int)eCeMenuRecordingsIT::newrecordingsfolder);
+ tokenContainer->DefineIntToken("{hasposterthumbnail}", (int)eCeMenuRecordingsIT::hasposterthumbnail);
+ tokenContainer->DefineIntToken("{thumbnailwidth}", (int)eCeMenuRecordingsIT::thumbnailwidth);
+ tokenContainer->DefineIntToken("{thumbnailheight}", (int)eCeMenuRecordingsIT::thumbnailheight);
+ tokenContainer->DefineIntToken("{hasposter}", (int)eCeMenuRecordingsIT::hasposter);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eCeMenuRecordingsIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eCeMenuRecordingsIT::posterheight);
+ InheritTokenContainer();
+}
+
+void cCeMenuRecordings::Set(const cRecording *recording, int level, int total, int New) {
+ this->recording = recording;
+ this->level = level;
+ this->total = total;
+ this->New = New;
+ dirty = true;
+}
+
+bool cCeMenuRecordings::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!dirty)
+ return false;
+
+ tokenContainer->Clear();
+ SetListTokens(tokenContainer);
+ bool isFolder = (total > 0) ? true : false;
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::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;
+ }
+ }
+
+ tokenContainer->AddStringToken((int)eCeMenuRecordingsST::name, buffer.c_str());
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::isnew, 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
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::percentseen, percSeen);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::newrecordingsfolder, New);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::numrecordingsfolder, total);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::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;
+ }
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::watched, watched);
+
+ const cEvent *event = NULL;
+ const cRecordingInfo *info = usedRecording->Info();
+ if (!info) return true;
+ event = info->GetEvent();
+ if (!event) return true;
+
+ cString recDate = event->GetDateString();
+ cString recTime = event->GetTimeString();
+ if (strstr(*recDate, "1970")) {
+ 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);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::month, sStartTime->tm_mon+1);
+
+ int duration = event->Duration() / 60;
+ recDuration = (recDuration>0)?(recDuration / 60):0;
+ tokenContainer->AddStringToken((int)eCeMenuRecordingsST::date, *recDate);
+ tokenContainer->AddStringToken((int)eCeMenuRecordingsST::time, *recTime);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::duration, recDuration);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::durationhours, recDuration / 60);
+ tokenContainer->AddStringToken((int)eCeMenuRecordingsST::durationminutes, *cString::sprintf("%.2d", recDuration%60));
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::durationevent, duration);
+ tokenContainer->AddIntToken((int)eCeMenuRecordingsIT::durationeventhours, duration / 60);
+ tokenContainer->AddStringToken((int)eCeMenuRecordingsST::durationeventminutes, *cString::sprintf("%.2d", duration%60));
+
+ tokenContainer->AddStringToken((int)eCeMenuRecordingsST::shorttext, info->ShortText());
+ tokenContainer->AddStringToken((int)eCeMenuRecordingsST::description, info->Description());
+
+ SetScraperRecordingPoster(tokenContainer, usedRecording, false);
+
+ return true;
+}
+
+/******************************************************************
+* cLeMenuPlugin
+******************************************************************/
+cLeMenuPlugin::cLeMenuPlugin(void) {
+ currentPlugin = NULL;
+ plugId = -1;
+ plugMenuId = -1;
+}
+
+cLeMenuPlugin::~cLeMenuPlugin(void) {
+}
+
+void cLeMenuPlugin::SetTokenContainer(void) {
+ if (plugId == -1 || plugMenuId == -1)
+ return;
+ skindesignerapi::cTokenContainer *tkPlugMenu = plgManager->GetTokenContainer(plugId, plugMenuId);
+ tokenContainer = new skindesignerapi::cTokenContainer(*tkPlugMenu);
+ InheritTokenContainer();
+}
+
+void cLeMenuPlugin::ClearCurrentElement(void) {
+ if (wasCurrent && currentPlugin) {
+ currentPlugin->Close();
+ }
+}
+
+void cLeMenuPlugin::Set(skindesignerapi::cTokenContainer *tk) {
+ tokenContainer->Clear();
+ tokenContainer->SetTokens(tk);
+ dirty = true;
+}
+
+bool cLeMenuPlugin::Parse(bool forced) {
+ if (!dirty)
+ return false;
+ tokenContainer->AddIntToken(0, current);
+ return true;
+}
+
+void cLeMenuPlugin::RenderCurrent(void) {
+ if (!currentPlugin)
+ return;
+ currentPlugin->Set(tokenContainer);
+ currentPlugin->SetListPosition(container.X(), container.Y(), container.Width(), container.Height());
+ currentPlugin->Parse();
+}
+
+/******************************************************************
+* cCeMenuPlugin
+******************************************************************/
+cCeMenuPlugin::cCeMenuPlugin(void) {
+ plugId = -1;
+ plugMenuId = -1;
+}
+
+cCeMenuPlugin::~cCeMenuPlugin(void) {
+}
+
+void cCeMenuPlugin::SetTokenContainer(void) {
+ if (plugId == -1 || plugMenuId == -1)
+ return;
+ skindesignerapi::cTokenContainer *tkPlugMenu = plgManager->GetTokenContainer(plugId, plugMenuId);
+ tokenContainer = new skindesignerapi::cTokenContainer(*tkPlugMenu);
+ InheritTokenContainer();
+}
+
+void cCeMenuPlugin::Set(skindesignerapi::cTokenContainer *tk) {
+ tokenContainer->Clear();
+ tokenContainer->SetTokens(tk);
+ dirty = true;
+}
+
+bool cCeMenuPlugin::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!dirty)
+ return false;
+ return true;
+}
+
+/******************************************************************
+* cLeAudioTracks
+******************************************************************/
+cLeAudioTracks::cLeAudioTracks(void) {
+ text = NULL;
+}
+
+cLeAudioTracks::~cLeAudioTracks(void) {
+ free(text);
+}
+
+void cLeAudioTracks::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eLeDisplayTracksST::title);
+ tokenContainer->DefineIntToken("{nummenuitem}", (int)eLeDisplayTracksIT::nummenuitem);
+ tokenContainer->DefineIntToken("{current}", (int)eLeDisplayTracksIT::current);
+ InheritTokenContainer();
+}
+
+void cLeAudioTracks::Set(const char *text) {
+ if (!text)
+ return;
+ free(this->text);
+ this->text = strdup(text);
+ dirty = true;
+}
+
+bool cLeAudioTracks::Parse(bool forced) {
+ if (!dirty)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eLeDisplayTracksIT::nummenuitem, num);
+ tokenContainer->AddIntToken((int)eLeDisplayTracksIT::current, current);
+ tokenContainer->AddStringToken((int)eLeDisplayTracksST::title, text);
+ return true;
+}
\ No newline at end of file diff --git a/coreengine/listelements.h b/coreengine/listelements.h new file mode 100644 index 0000000..9fc0b27 --- /dev/null +++ b/coreengine/listelements.h @@ -0,0 +1,337 @@ +#ifndef __LISTELEMENTS_H
+#define __LISTELEMENTS_H
+
+#include "viewelement.h"
+#include "../extensions/scrapmanager.h"
+
+#define MAX_TABS 6
+/******************************************************************
+* cListElement
+******************************************************************/
+class cListElement : public cViewElement {
+protected:
+ eMenuCategory menuCat;
+ int num;
+ bool current;
+ bool wasCurrent;
+ bool selectable;
+ cViewElement *currentElement;
+ char *ParseSeparator(const char *text);
+public:
+ cListElement(void);
+ cListElement(const cListElement &other);
+ virtual ~cListElement(void) {};
+ void SetMenuCategory(eMenuCategory menuCat) { this->menuCat = menuCat; };
+ void SetNumber(int number) { num = number; };
+ void SetCurrent(bool cur);
+ bool Current(void) { return current; };
+ void WakeCurrent(void);
+ void SetSelectable(bool sel) { selectable = sel; };
+ bool DoScroll(void) { return current; };
+ virtual void RenderCurrent(void) { };
+ void Close(void);
+ void Clear(void);
+};
+
+/******************************************************************
+* cCurrentElement
+******************************************************************/
+class cCurrentElement : public cViewElement {
+protected:
+ int listX;
+ int listY;
+ int listWidth;
+ int listHeight;
+public:
+ cCurrentElement(void);
+ virtual ~cCurrentElement(void) {};
+ void SetListPosition(int x, int y, int width, int height);
+ void SetListTokens(skindesignerapi::cTokenContainer *tokenContainer);
+};
+
+/******************************************************************
+* cLeMenuDefault
+******************************************************************/
+class cLeMenuDefault : public cListElement {
+private:
+ char *text;
+ int *colX;
+ int *colWidths;
+ const char *plugName;
+ const char *GetTabbedText(const char *s, int tab);
+ void SetMenuCategory(void);
+ void CheckProgressBar(const char *text, int tab);
+public:
+ cLeMenuDefault(void);
+ cLeMenuDefault(const cLeMenuDefault &other);
+ virtual ~cLeMenuDefault(void);
+ void SetListInfo(int *colX, int *colWidths);
+ void SetText(const char *text);
+ void SetPlugin(const char *plugName) { this->plugName = plugName; };
+ void SetTokenContainer(void);
+ bool Parse(bool forced = true);
+};
+
+/******************************************************************
+* cVeMenuMain
+******************************************************************/
+class cVeMenuMain {
+protected:
+ char *text;
+ char *number;
+ char *label;
+ void SplitText(void);
+public:
+ cVeMenuMain(void);
+ virtual ~cVeMenuMain(void);
+ void SetText(const char *text);
+};
+
+/******************************************************************
+* cLeMenuMain
+******************************************************************/
+class cCeMenuMain;
+class cLeMenuMain : public cListElement, public cVeMenuMain {
+private:
+ cCeMenuMain *currentMain;
+public:
+ cLeMenuMain(void);
+ cLeMenuMain(const cLeMenuMain &other);
+ virtual ~cLeMenuMain(void);
+ void SetTokenContainer(void);
+ void SetCurrentElement(cCeMenuMain *cur) { currentMain = cur; currentElement = (cViewElement*)cur; };
+ void ClearCurrentElement(void);
+ void SetText(const char *text);
+ bool Parse(bool forced = true);
+ void RenderCurrent(void);
+ const char *PluginName(void);
+};
+
+/******************************************************************
+* cCeMenuMain
+******************************************************************/
+class cCeMenuMain : public cCurrentElement, public cVeMenuMain {
+private:
+public:
+ cCeMenuMain(void);
+ virtual ~cCeMenuMain(void);
+ void SetTokenContainer(void);
+ void SetText(const char *text);
+ bool Parse(bool forced = true);
+};
+
+/******************************************************************
+* cVeMenuSchedules
+******************************************************************/
+class cVeMenuSchedules {
+protected:
+ const cEvent *event;
+ const cChannel *channel;
+ bool withDate;
+ eTimerMatch timerMatch;
+ bool epgSearchFav;
+public:
+ cVeMenuSchedules(void);
+ virtual ~cVeMenuSchedules(void){};
+ void SetEpgSearchFav(bool isFav) { epgSearchFav = isFav; };
+};
+
+/******************************************************************
+* cLeMenuSchedules
+******************************************************************/
+class cCeMenuSchedules;
+class cLeMenuSchedules : public cListElement, public cVeMenuSchedules {
+private:
+ cCeMenuSchedules *currentSchedules;
+public:
+ cLeMenuSchedules(void);
+ cLeMenuSchedules(const cLeMenuSchedules &other);
+ virtual ~cLeMenuSchedules(void);
+ void SetTokenContainer(void);
+ void SetCurrentElement(cCeMenuSchedules *cur) { currentSchedules = cur; currentElement = (cViewElement*)cur; };
+ void ClearCurrentElement(void);
+ void Set(const cEvent *event, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
+ bool Parse(bool forced = true);
+ void RenderCurrent(void);
+};
+
+/******************************************************************
+* cCeMenuSchedules
+******************************************************************/
+class cCeMenuSchedules : public cCurrentElement, public cVeMenuSchedules, public cScrapManager {
+private:
+ eMenuCategory menuCat;
+ int schedulesIndex;
+public:
+ cCeMenuSchedules(void);
+ virtual ~cCeMenuSchedules(void);
+ void SetTokenContainer(void);
+ void Set(const cEvent *event, const cChannel *channel, bool withDate, eTimerMatch timerMatch, eMenuCategory menuCat);
+ bool Parse(bool forced = true);
+};
+
+/******************************************************************
+* cLeMenuChannels
+******************************************************************/
+class cCeMenuChannels;
+class cLeMenuChannels : public cListElement {
+private:
+ cCeMenuChannels *currentChannel;
+ const cChannel *channel;
+ bool withProvider;
+public:
+ cLeMenuChannels(void);
+ cLeMenuChannels(const cLeMenuChannels &other);
+ virtual ~cLeMenuChannels(void);
+ void SetTokenContainer(void);
+ void SetCurrentElement(cCeMenuChannels *cur) { currentChannel = cur; currentElement = (cViewElement*)cur; };
+ void ClearCurrentElement(void);
+ void Set(const cChannel *channel, bool withProvider);
+ bool Parse(bool forced = true);
+ void RenderCurrent(void);
+};
+
+/******************************************************************
+* cCeMenuChannels
+******************************************************************/
+class cCeMenuChannels : public cCurrentElement {
+private:
+ const cChannel *channel;
+ bool withProvider;
+ int schedulesIndex;
+public:
+ cCeMenuChannels(void);
+ virtual ~cCeMenuChannels(void);
+ void SetTokenContainer(void);
+ void Set(const cChannel *channel, bool withProvider);
+ bool Parse(bool forced = true);
+};
+
+/******************************************************************
+* cLeMenuTimers
+******************************************************************/
+class cCeMenuTimers;
+class cLeMenuTimers : public cListElement {
+private:
+ cCeMenuTimers *currentTimer;
+ const cTimer *timer;
+public:
+ cLeMenuTimers(void);
+ virtual ~cLeMenuTimers(void);
+ void SetTokenContainer(void);
+ void SetCurrentElement(cCeMenuTimers *cur) { currentTimer = cur; currentElement = (cViewElement*)cur; };
+ void ClearCurrentElement(void);
+ void Set(const cTimer *timer);
+ bool Parse(bool forced = true);
+ void RenderCurrent(void);
+};
+
+/******************************************************************
+* cCeMenuTimers
+******************************************************************/
+class cCeMenuTimers : public cCurrentElement {
+private:
+ const cTimer *timer;
+public:
+ cCeMenuTimers(void);
+ virtual ~cCeMenuTimers(void);
+ void SetTokenContainer(void);
+ void Set(const cTimer *timer);
+ bool Parse(bool forced = true);
+};
+
+/******************************************************************
+* cLeMenuRecordings
+******************************************************************/
+class cCeMenuRecordings;
+class cLeMenuRecordings : public cListElement, public cScrapManager {
+private:
+ cCeMenuRecordings *currentRecording;
+ const cRecording *recording;
+ int level;
+ int total;
+ int New;
+ char *RecName(const char *path, int level);
+ char *FolderName(const char *path, int level);
+public:
+ cLeMenuRecordings(void);
+ virtual ~cLeMenuRecordings(void);
+ void SetTokenContainer(void);
+ void SetCurrentElement(cCeMenuRecordings *cur) { currentRecording = cur; currentElement = (cViewElement*)cur; };
+ void ClearCurrentElement(void);
+ void Set(const cRecording *recording, int level, int total, int New);
+ bool Parse(bool forced = true);
+ void RenderCurrent(void);
+};
+
+/******************************************************************
+* cCeMenuRecordings
+******************************************************************/
+class cCeMenuRecordings : public cCurrentElement, public cScrapManager {
+private:
+ const cRecording *recording;
+ int level;
+ int total;
+ int New;
+public:
+ cCeMenuRecordings(void);
+ virtual ~cCeMenuRecordings(void);
+ void SetTokenContainer(void);
+ void Set(const cRecording *recording, int level, int total, int New);
+ bool Parse(bool forced = true);
+};
+
+/******************************************************************
+* cLeMenuPlugin
+******************************************************************/
+class cCeMenuPlugin;
+class cLeMenuPlugin : public cListElement {
+private:
+ int plugId;
+ int plugMenuId;
+ cCeMenuPlugin *currentPlugin;
+public:
+ cLeMenuPlugin(void);
+ virtual ~cLeMenuPlugin(void);
+ void SetTokenContainer(void);
+ void SetPlugId(int id) { plugId = id; };
+ void SetPlugMenuId(int id) { plugMenuId = id; };
+ void SetCurrentElement(cCeMenuPlugin *cur) { currentPlugin = cur; currentElement = (cViewElement*)cur; };
+ void ClearCurrentElement(void);
+ void Set(skindesignerapi::cTokenContainer *tk);
+ bool Parse(bool forced = true);
+ void RenderCurrent(void);
+};
+
+/******************************************************************
+* cCeMenuPlugin
+******************************************************************/
+class cCeMenuPlugin : public cCurrentElement {
+private:
+ int plugId;
+ int plugMenuId;
+public:
+ cCeMenuPlugin(void);
+ virtual ~cCeMenuPlugin(void);
+ void SetTokenContainer(void);
+ void SetPlugId(int id) { plugId = id; };
+ void SetPlugMenuId(int id) { plugMenuId = id; };
+ void Set(skindesignerapi::cTokenContainer *tk);
+ bool Parse(bool forced = true);
+};
+
+/******************************************************************
+* cLeAudioTracks
+******************************************************************/
+class cLeAudioTracks : public cListElement {
+private:
+ char *text;
+public:
+ cLeAudioTracks(void);
+ virtual ~cLeAudioTracks(void);
+ void SetTokenContainer(void);
+ void Set(const char *text);
+ bool Parse(bool forced = true);
+};
+
+#endif //__LISTELEMENTS_H
\ No newline at end of file diff --git a/coreengine/osdwrapper.c b/coreengine/osdwrapper.c new file mode 100644 index 0000000..ec1119c --- /dev/null +++ b/coreengine/osdwrapper.c @@ -0,0 +1,71 @@ +#include "osdwrapper.h"
+
+cSdOsd::cSdOsd(void) {
+ osd = NULL;
+ flushLocked = false;
+}
+
+cSdOsd::~cSdOsd(void) {
+ DeleteOsd();
+}
+
+void cSdOsd::Lock(void) {
+ mutex.Lock();
+}
+
+void cSdOsd::Unlock(void) {
+ mutex.Unlock();
+}
+
+void cSdOsd::LockFlush(void) {
+ Lock();
+ flushLocked = true;
+ Unlock();
+}
+
+void cSdOsd::UnlockFlush(void) {
+ Lock();
+ flushLocked = false;
+ Unlock();
+}
+
+bool cSdOsd::CreateOsd(int x, int y, int width, int height) {
+ cOsd *newOsd = cOsdProvider::NewOsd(cOsd::OsdLeft() + x, cOsd::OsdTop() + y);
+ if (newOsd) {
+ tArea Area = { 0, 0, width - 1, height - 1, 32 };
+ if (newOsd->SetAreas(&Area, 1) == oeOk) {
+ Lock();
+ osd = newOsd;
+ Unlock();
+ return true;
+ }
+ }
+ return false;
+}
+
+void cSdOsd::DeleteOsd(void) {
+ Lock();
+ delete osd;
+ osd = NULL;
+ Unlock();
+}
+
+cPixmap *cSdOsd::CreatePixmap(int layer, cRect &viewPort, cRect &drawPort) {
+ if (osd) {
+ return osd->CreatePixmap(layer, viewPort, drawPort);
+ }
+ return NULL;
+}
+
+void cSdOsd::DestroyPixmap(cPixmap *pix) {
+ if (osd) {
+ osd->DestroyPixmap(pix);
+ }
+}
+
+void cSdOsd::Flush(void) {
+ Lock();
+ if (osd && !flushLocked)
+ osd->Flush();
+ Unlock();
+}
diff --git a/coreengine/osdwrapper.h b/coreengine/osdwrapper.h new file mode 100644 index 0000000..ad0394d --- /dev/null +++ b/coreengine/osdwrapper.h @@ -0,0 +1,26 @@ +#ifndef __OSDWRAPPER_H
+#define __OSDWRAPPER_H
+
+#include <vdr/osd.h>
+#include <vdr/thread.h>
+
+class cSdOsd {
+private:
+ cOsd *osd;
+ cMutex mutex;
+ bool flushLocked;
+public:
+ cSdOsd(void);
+ virtual ~cSdOsd(void);
+ void Lock(void);
+ void Unlock(void);
+ void LockFlush(void);
+ void UnlockFlush(void);
+ bool CreateOsd(int x, int y, int width, int height);
+ void DeleteOsd(void);
+ cPixmap *CreatePixmap(int layer, cRect &viewPort, cRect &drawPort);
+ void DestroyPixmap(cPixmap *pix);
+ void Flush(void);
+};
+
+#endif //__OSDWRAPPER_H
\ No newline at end of file diff --git a/coreengine/view.c b/coreengine/view.c new file mode 100644 index 0000000..8bfa22b --- /dev/null +++ b/coreengine/view.c @@ -0,0 +1,419 @@ +#include "../config.h" +#include "view.h" + +// --- cView ------------------------------------------------------------- + +cView::cView(void) { + globals = NULL; + viewName = NULL; + attribs = new cViewAttribs((int)eViewAttribs::count); + numViewElements = 0; + viewElements = NULL; + viewElementsHorizontal = NULL; + fader = NULL; + shifter = NULL; + currentTvFrame = NULL; + newTvFrame = NULL; + menuInit = false; +} + +cView::~cView() { + for (int i=0; i< numViewElements; i++) + delete viewElements[i]; + delete[] viewElements; + if (viewElementsHorizontal) { + for (int i=0; i< numViewElements; i++) + delete viewElementsHorizontal[i]; + delete[] viewElementsHorizontal; + } + delete attribs; + free(viewName); + delete fader; + delete shifter; + sdOsd.DeleteOsd(); +} + +/******************************************************************* +* Public Functions +*******************************************************************/ +bool cView::ReadFromXML(void) { + const char *xmlFile; + switch (viewId) { + case eViewType::DisplayChannel: + xmlFile = "displaychannel.xml"; + break; + case eViewType::DisplayMenu: + xmlFile = "displaymenu.xml"; + break; + case eViewType::DisplayMessage: + xmlFile = "displaymessage.xml"; + break; + case eViewType::DisplayReplay: + xmlFile = "displayreplay.xml"; + break; + case eViewType::DisplayVolume: + xmlFile = "displayvolume.xml"; + break; + case eViewType::DisplayTracks: + xmlFile = "displayaudiotracks.xml"; + break; + default: + return false; + } + cXmlParser parser; + parser.SetOsd(&sdOsd); + if (!parser.ReadView(this, xmlFile)) { + return false; + } + if (!parser.ParseView()) { + return false; + } + + //read additional plugin menu templates + bool ok = true; + if (viewId == eViewType::DisplayMenu) { + plgManager->InitPluginMenuIterator(); + map <int,skindesignerapi::sPlugMenu> *plugMenus = NULL; + string plugName = ""; + int plugId = -1; + while ( plugMenus = plgManager->GetPluginMenus(plugName, plugId) ) { + for (map <int,skindesignerapi::sPlugMenu>::iterator it = plugMenus->begin(); it != plugMenus->end(); it++) { + int templateNumber = it->first; + int menuType = it->second.type; + cString templateName = cString::sprintf("plug-%s-%s", plugName.c_str(), it->second.tplname.c_str()); + if (parser.ReadPluginView(*templateName)) { + ok = parser.ParsePluginView(plugName, plugId, templateNumber, menuType); + } else { + dsyslog("skindesigner: template %s for plugin %s not available", *templateName, plugName.c_str()); + } + } + } + } + return ok; +} + +void cView::SetGlobals(cGlobals *globals) { + this->globals = globals; + attribs->SetGlobals(globals); + for (int i=0; i < numViewElements; ++i) { + if (viewElements[i]) { + viewElements[i]->SetGlobals(globals); + } + if (viewElementsHorizontal && viewElementsHorizontal[i]) { + viewElementsHorizontal[i]->SetGlobals(globals); + } + } +} + +void cView::SetContainer(int x, int y, int width, int height) { + container.SetX(x); + container.SetY(y); + container.SetWidth(width); + container.SetHeight(height); +} + +void cView::SetAttributes(vector<stringpair> &attributes) { + attribs->Set(attributes); +} + +void cView::AddViewElement(const char *sViewElement, cViewElement *viewElement) { + int id = ViewElementId(sViewElement); + if (id == ATTR_UNKNOWN) + return; + viewElement->SetId(id); + viewElement->SetTokenContainer(); + eOrientation orientation = viewElement->Orientation(); + if (viewElementsHorizontal && orientation == eOrientation::horizontal) { + viewElementsHorizontal[id] = viewElement; + } else { + viewElements[id] = viewElement; + } +} + +bool cView::ValidViewElement(const char *viewElement) { + if (ViewElementId(viewElement) != ATTR_UNKNOWN) + return true; + return false; +} + +bool cView::ValidViewList(const char *viewList) { + if (!strcmp(viewList, "menuitems")) + return true; + return false; +} + +void cView::PreCache(void) { + if (container.Width() == 0) { + SetContainer(0, 0, cOsd::OsdWidth(), cOsd::OsdHeight()); + attribs->SetContainer(0, 0, cOsd::OsdWidth(), cOsd::OsdHeight()); + attribs->Cache(); + } + //set frame for scaling tv picture + tvFrame = attribs->TvFrame(); + //cache viewelements + for (int i=0; i < numViewElements; i++) { + if (!viewElements[i]) + continue; + viewElements[i]->SetContainer(0, 0, attribs->Width(), attribs->Height()); + viewElements[i]->Cache(); + } + if (viewElementsHorizontal) { + for (int i=0; i < numViewElements; i++) { + if (!viewElementsHorizontal[i]) + continue; + viewElementsHorizontal[i]->SetContainer(0, 0, attribs->Width(), attribs->Height()); + viewElementsHorizontal[i]->Cache(); + } + } + + //cleanup viewelements + for (int i=0; i < numViewElements; i++) { + if (!viewElements[i]) + continue; + if (!viewElements[i]->Execute()) { + delete viewElements[i]; + viewElements[i] = NULL; + } + } + if (viewElementsHorizontal) { + for (int i=0; i < numViewElements; i++) { + if (!viewElementsHorizontal[i]) + continue; + if (!viewElementsHorizontal[i]->Execute()) { + delete viewElementsHorizontal[i]; + viewElementsHorizontal[i] = NULL; + } + } + } + //set viewelement objects for each view + SetViewElementObjects(); +} + +bool cView::Init(void) { + int osdX = attribs->X(); + int osdY = attribs->Y(); + int osdWidth = attribs->Width(); + int osdHeight = attribs->Height(); + return sdOsd.CreateOsd(osdX, osdY, osdWidth, osdHeight); +} + +void cView::Clear(int ve) { + if (!viewElements[ve]) + return; + viewElements[ve]->Clear(); +} + +void cView::Render(int ve, bool force) { + if (!viewElements[ve]) + return; + if (viewElements[ve]->Parse(force)) + viewElements[ve]->Render(); +} + +void cView::Close(void) { + delete fader; + fader = NULL; + delete shifter; + shifter = NULL; + if (initFinished && ShiftTime() > 0) { + cRect shiftbox = CoveredArea(); + cPoint ref = cPoint(shiftbox.X(), shiftbox.Y()); + cPoint end = ShiftStart(shiftbox); + shifter = new cAnimation((cShiftable*)this, end, ref, false); + shifter->Shift(); + delete shifter; + shifter = NULL; + } else if (initFinished && FadeTime() > 0) { + fader = new cAnimation((cFadable*)this, false); + fader->Fade(); + delete fader; + fader = NULL; + } + if (initFinished) + UnScaleTv(); + ClearVariables(); + for (int i=0; i < numViewElements; i++) { + if (!viewElements[i]) + continue; + viewElements[i]->Close(); + } + sdOsd.DeleteOsd(); +} + +int cView::FadeTime(void) { + return attribs->FadeTime(); +} + +void cView::SetTransparency(int transparency, bool force) { + for (int i = 0; i < numViewElements; i++) { + if (viewElements[i] && (!viewElements[i]->Fading() || force)) { + viewElements[i]->SetTransparency(transparency); + } + } +} + +int cView::ShiftTime(void) { + return attribs->ShiftTime(); +} + +int cView::ShiftMode(void) { + return attribs->ShiftMode(); +} + +void cView::SetPosition(cPoint &position, cPoint &reference, bool force) { + for (int i = 0; i < numViewElements; i++) { + if (viewElements[i] && (!viewElements[i]->Shifting() || force)) { + viewElements[i]->SetPosition(position, reference); + } + } +} + +void cView::Flush(void) { + if (init) { + init = false; + StartAnimation(); + menuInit = true; + //LockFlush was set at startup of view to avoid display + //of not positioned pixmaps for shifting and fading + sdOsd.UnlockFlush(); + } + if (menuInit) { + ScaleTv(); + WakeViewElements(); + menuInit = false; + } + sdOsd.Flush(); +} + +void cView::Debug(void) { + esyslog("skindesigner: ---> view %s", viewName); + for (int i=0; i < numViewElements; i++) { + if (!viewElements[i]) + continue; + esyslog("skindesigner: debugging ve %d", i); + viewElements[i]->Debug(true); + } +} + +/******************************************************************* +* Protected Functions +*******************************************************************/ +void cView::ClearVariables(void) { + init = true; + initFinished = false; + newTvFrame = NULL; + currentTvFrame = NULL; + menuInit = false; +} + +int cView::ViewElementId(const char *name) { + map<string, int>::iterator hit = viewElementNames.find(name); + if (hit != viewElementNames.end()) + return (int)hit->second; + return ATTR_UNKNOWN; +} + +void cView::StartAnimation(void) { + if (ShiftTime() > 0) { + cRect shiftbox = CoveredArea(); + cPoint ref = cPoint(shiftbox.X(), shiftbox.Y()); + cPoint start = ShiftStart(shiftbox); + SetPosition(start, ref); + shifter = new cAnimation((cShiftable*)this, start, ref, true); + shifter->Start(); + } else if (FadeTime() > 0) { + if (fader) + return; + SetTransparency(100); + sdOsd.Flush(); + fader = new cAnimation((cFadable*)this, true); + fader->Start(); + } + initFinished = true; +} + +void cView::WakeViewElements(void) { + for (int i = 0; i < numViewElements; i++) { + if (viewElements[i]) { + viewElements[i]->WakeUp(); + } + } + if (!viewElementsHorizontal) + return; + for (int i = 0; i < numViewElements; i++) { + if (viewElementsHorizontal[i]) { + viewElementsHorizontal[i]->WakeUp(); + } + } +} + +cPoint cView::ShiftStart(cRect &shiftbox) { + eShiftType type = (eShiftType)attribs->ShiftType(); + cPoint start; + if (type == eShiftType::none) { + start = attribs->ShiftStartpoint(); + } else if (type == eShiftType::left) { + start.SetX(-shiftbox.Width()); + start.SetY(shiftbox.Y()); + } else if (type == eShiftType::right) { + start.SetX(attribs->Width()); + start.SetY(shiftbox.Y()); + } else if (type == eShiftType::top) { + start.SetX(shiftbox.X()); + start.SetY(-shiftbox.Height()); + } else if (type == eShiftType::bottom) { + start.SetX(shiftbox.X()); + start.SetY(attribs->Height()); + } + return start; +} + +cRect cView::CoveredArea(void) { + cRect unionArea; + for (int i = 0; i < numViewElements; i++) { + if (viewElements[i] && !viewElements[i]->Shifting()) { + unionArea.Combine(viewElements[i]->CoveredArea()); + } + } + return unionArea; +} + +void cView::ScaleTv(void) { + bool scale = false; + if (newTvFrame) { + if (currentTvFrame) { + if (*newTvFrame != *currentTvFrame) { + scale = true; + } + } else { + scale = true; + } + currentTvFrame = newTvFrame; + } else { + if (tvFrame != cRect::Null) { + scale = true; + currentTvFrame = &tvFrame; + } + } + if (currentTvFrame && scale) { + DoScaleTv(currentTvFrame); + } +} + +void cView::UnScaleTv(void) { + if (currentTvFrame) { + DoScaleTv(&cRect::Null); + currentTvFrame = NULL; + } +} + +void cView::DoScaleTv(const cRect *frame) { + if (*frame == cRect::Null) { + cDevice::PrimaryDevice()->ScaleVideo(cRect::Null); + } else { + cRect scalingWindow = cDevice::PrimaryDevice()->CanScaleVideo(*frame); + if (scalingWindow != cRect::Null) { + cDevice::PrimaryDevice()->ScaleVideo(scalingWindow); + } + } +} diff --git a/coreengine/view.h b/coreengine/view.h new file mode 100644 index 0000000..b6ee0e6 --- /dev/null +++ b/coreengine/view.h @@ -0,0 +1,93 @@ +#ifndef __VIEW_H +#define __VIEW_H + +#include <iostream> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string> + +#include "osdwrapper.h" +#include "globals.h" +#include "../libskindesignerapi/tokencontainer.h" +#include "viewelementplugin.h" +#include "viewelementscommon.h" +#include "viewelementsdisplaychannel.h" +#include "viewelementsdisplaymenu.h" +#include "viewelementsdisplayreplay.h" +#include "viewelementsdisplaytracks.h" +#include "viewlist.h" +class cView; +#include "xmlparser.h" +#include "animation.h" + +using namespace std; + +class cView : public cFadable, public cShiftable { +private: + void DoScaleTv(const cRect *frame); +protected: + cSdOsd sdOsd; + cViewAttribs *attribs; + cRect container; + bool init; + bool initFinished; + eViewType viewId; + cGlobals *globals; + char *viewName; + int numViewElements; + cViewElement **viewElements; + cViewElement **viewElementsHorizontal; + map<string,int> viewElementNames; + cAnimation *fader; + cAnimation *shifter; + cRect tvFrame; + cRect *currentTvFrame; + cRect *newTvFrame; + bool menuInit; + int ViewElementId(const char *name); + virtual void ClearVariables(void); + virtual void SetViewElementObjects(void) { }; + virtual void StartAnimation(void); + virtual void WakeViewElements(void); + cPoint ShiftStart(cRect &shiftbox); + virtual cRect CoveredArea(void); + void ScaleTv(void); + void UnScaleTv(void); +public: + cView(void); + virtual ~cView(void); + //Loading and Caching functionality + bool ReadFromXML(void); + virtual void SetGlobals(cGlobals *globals); + const char *GetViewName(void) { return viewName; }; + void SetContainer(int x, int y, int width, int height); + void SetAttributes(vector<stringpair> &attributes); + void AddViewElement(const char *sViewElement, cViewElement *viewElement); + bool ValidViewElement(const char *viewElement); + virtual void AddViewList(cViewList *viewList) { }; + bool ValidViewList(const char *viewList); + virtual void PreCache(void); + cRect *GetTvFrame(void) { return &tvFrame; }; + virtual const cFont *GetTextAreaFont(void) { return NULL; }; + virtual int GetTextAreaWidth(void) { return 0; }; + virtual int GetListWidth(void) { return 0; }; + //View API + virtual bool Init(void); + void Clear(int ve); + void Render(int ve, bool force = false); + virtual void Close(void); + virtual void Flush(void); + virtual void Debug(void); + bool Detached(void) { return false; }; + int Delay(void) { return 0; }; + //Fadable + int FadeTime(void); + virtual void SetTransparency(int transparency, bool force = false); + //Shiftable + int ShiftTime(void); + int ShiftMode(void); + virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false); +}; + +#endif //__VIEW_H diff --git a/coreengine/viewdetail.c b/coreengine/viewdetail.c new file mode 100644 index 0000000..334cf5d --- /dev/null +++ b/coreengine/viewdetail.c @@ -0,0 +1,978 @@ +#include "viewdetail.h"
+#include "../config.h"
+/******************************************************************
+* cViewDetail
+******************************************************************/
+cViewDetail::cViewDetail(void) {
+ activeTab = NULL;
+ activeTabIndex = -1;
+ numTabs = 0;
+ plugId = -1;
+ plugMenuId = -1;
+}
+
+cViewDetail::~cViewDetail(void) {
+}
+
+void cViewDetail::SetActiveTab(void) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ if (node->ActiveTab()) {
+ activeTab = dynamic_cast<cArea*>(node);
+ activeTabIndex = 0;
+ return;
+ }
+ }
+}
+
+int cViewDetail::GetWidth(void) {
+ cAreaNode *node = areaNodes.First();
+ if (!node)
+ return 0;
+ return node->GetWidth();
+}
+
+void cViewDetail::ResetTabs(void) {
+ activeTab = NULL;
+ activeTabIndex = -1;
+}
+
+void cViewDetail::Clear(void) {
+ cViewElement::Close();
+}
+
+void cViewDetail::Close(void) {
+ cViewElement::Close();
+ activeTab = NULL;
+ activeTabIndex = -1;
+ numTabs = 0;
+}
+
+void cViewDetail::Render(void) {
+ if (!dirty || blocked)
+ return;
+
+ if (attribs->DoDebug())
+ Debug();
+
+ if (!activeTab)
+ SetActiveTab();
+ if (!activeTab)
+ return;
+
+ activeTab->Clear();
+ if (activeTab->Execute()) {
+ activeTab->Render();
+ }
+
+ dirty = false;
+}
+
+void cViewDetail::Scrollbar(int &barheight, int &offset, bool &end) {
+ if (!activeTab)
+ return;
+ cRect tabViewPort = activeTab->ViewPort();
+ cRect tabDrawPort = activeTab->DrawPort();
+ int totalHeight = tabDrawPort.Height();
+ int screenHeight = tabViewPort.Height();
+ int y = (-1)*tabDrawPort.Y();
+ if (totalHeight == 0) {
+ return;
+ }
+ if (totalHeight <= screenHeight)
+ barheight = 1000;
+ else {
+ barheight = (double)screenHeight / (double) totalHeight * 1000;
+ }
+ offset = (double)y / (double) totalHeight * 1000;
+ end = true;
+}
+
+bool cViewDetail::ScrollUp(bool page) {
+ if (!activeTab)
+ return false;
+ cRect tabDrawPort = activeTab->DrawPort();
+ int scrollStep = activeTab->ScrollStep();
+ if (page) {
+ cRect tabViewPort = activeTab->ViewPort();
+ scrollStep = tabViewPort.Height();
+ }
+ int aktHeight = tabDrawPort.Y();
+ if (aktHeight >= 0) {
+ return false;
+ }
+ int newY = aktHeight + scrollStep;
+ if (newY > 0)
+ newY = 0;
+ cPoint dp(0, newY);
+ activeTab->SetDrawPort(dp);
+ return true;
+}
+
+bool cViewDetail::ScrollDown(bool page) {
+ if (!activeTab)
+ return false;
+ cRect tabViewPort = activeTab->ViewPort();
+ cRect tabDrawPort = activeTab->DrawPort();
+ int scrollStep = activeTab->ScrollStep();
+ if (page) {
+ scrollStep = tabViewPort.Height();
+ }
+ int aktHeight = tabDrawPort.Y();
+ int totalHeight = tabDrawPort.Height();
+ int screenHeight = tabViewPort.Height();
+
+ if (totalHeight - ((-1)*aktHeight) == screenHeight) {
+ return false;
+ }
+ int newY = aktHeight - scrollStep;
+ if ((-1)*newY > totalHeight - screenHeight)
+ newY = (-1)*(totalHeight - screenHeight);
+ cPoint dp(0, newY);
+ activeTab->SetDrawPort(dp);
+ return true;
+}
+
+int cViewDetail::GetTabs(vector<const char*> &tabs) {
+ int i=0;
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ if (!node->Execute())
+ continue;
+ tabs.push_back(node->Name());
+ if (node->ActiveTab()) {
+ activeTabIndex = i;
+ }
+ i++;
+ }
+ numTabs = i;
+ return activeTabIndex;
+}
+
+void cViewDetail::NextTab(void) {
+ cArea *nextActiveTab = NULL;
+ for (cAreaNode *node = areaNodes.Next(activeTab); node; node = areaNodes.Next(node)) {
+ if (node->Execute()) {
+ nextActiveTab = dynamic_cast<cArea*>(node);
+ activeTabIndex++;
+ break;
+ }
+ }
+ if (!nextActiveTab) {
+ nextActiveTab = dynamic_cast<cArea*>(areaNodes.First());
+ activeTabIndex = 0;
+ }
+ activeTab = nextActiveTab;
+}
+
+void cViewDetail::PrevTab(void) {
+ cArea *prevActiveTab = NULL;
+ for (cAreaNode *node = areaNodes.Prev(activeTab); node; node = areaNodes.Prev(node)) {
+ if (node->Execute()) {
+ prevActiveTab = dynamic_cast<cArea*>(node);
+ activeTabIndex--;
+ break;
+ }
+ }
+ if (!prevActiveTab) {
+ int numActiveTabs = 0;
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ if (node->Execute()) {
+ numActiveTabs++;
+ }
+ }
+ for (cAreaNode *node = areaNodes.Last(); node; node = areaNodes.Prev(node)) {
+ if (node->Execute()) {
+ prevActiveTab = dynamic_cast<cArea*>(node);
+ activeTabIndex = numActiveTabs-1;
+ break;
+ }
+ }
+ }
+ activeTab = prevActiveTab;
+}
+
+void cViewDetail::SetTransparency(int transparency, bool forceDetached) {
+ if (activeTab)
+ activeTab->SetTransparency(transparency);
+}
+
+/******************************************************************
+* cViewDetailEpg
+******************************************************************/
+cViewDetailEpg::cViewDetailEpg(void) {
+ event = NULL;
+ rerunsIndex = -1;
+ actorsIndex = -1;
+}
+
+cViewDetailEpg::~cViewDetailEpg(void) {
+}
+
+void cViewDetailEpg::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eDmDetailedEpgST::title);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eDmDetailedEpgST::shorttext);
+ tokenContainer->DefineStringToken("{description}", (int)eDmDetailedEpgST::description);
+ tokenContainer->DefineStringToken("{start}", (int)eDmDetailedEpgST::start);
+ tokenContainer->DefineStringToken("{stop}", (int)eDmDetailedEpgST::stop);
+ tokenContainer->DefineStringToken("{day}", (int)eDmDetailedEpgST::day);
+ tokenContainer->DefineStringToken("{date}", (int)eDmDetailedEpgST::date);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eDmDetailedEpgST::durationminutes);
+ tokenContainer->DefineStringToken("{vps}", (int)eDmDetailedEpgST::vps);
+ tokenContainer->DefineStringToken("{channelname}", (int)eDmDetailedEpgST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eDmDetailedEpgST::channelid);
+ tokenContainer->DefineStringToken("{epgpic1path}", (int)eDmDetailedEpgST::epgpic1path);
+ tokenContainer->DefineStringToken("{epgpic2path}", (int)eDmDetailedEpgST::epgpic2path);
+ tokenContainer->DefineStringToken("{epgpic3path}", (int)eDmDetailedEpgST::epgpic3path);
+ tokenContainer->DefineStringToken("{movietitle}", (int)eScraperST::movietitle);
+ tokenContainer->DefineStringToken("{movieoriginalTitle}", (int)eScraperST::movieoriginalTitle);
+ tokenContainer->DefineStringToken("{movietagline}", (int)eScraperST::movietagline);
+ tokenContainer->DefineStringToken("{movieoverview}", (int)eScraperST::movieoverview);
+ tokenContainer->DefineStringToken("{moviegenres}", (int)eScraperST::moviegenres);
+ tokenContainer->DefineStringToken("{moviehomepage}", (int)eScraperST::moviehomepage);
+ tokenContainer->DefineStringToken("{moviereleasedate}", (int)eScraperST::moviereleasedate);
+ tokenContainer->DefineStringToken("{moviepopularity}", (int)eScraperST::moviepopularity);
+ tokenContainer->DefineStringToken("{movievoteaverage}", (int)eScraperST::movievoteaverage);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperST::posterpath);
+ tokenContainer->DefineStringToken("{fanartpath}", (int)eScraperST::fanartpath);
+ tokenContainer->DefineStringToken("{moviecollectionName}", (int)eScraperST::moviecollectionName);
+ tokenContainer->DefineStringToken("{collectionposterpath}", (int)eScraperST::collectionposterpath);
+ tokenContainer->DefineStringToken("{collectionfanartpath}", (int)eScraperST::collectionfanartpath);
+ tokenContainer->DefineStringToken("{seriesname}", (int)eScraperST::seriesname);
+ tokenContainer->DefineStringToken("{seriesoverview}", (int)eScraperST::seriesoverview);
+ tokenContainer->DefineStringToken("{seriesfirstaired}", (int)eScraperST::seriesfirstaired);
+ tokenContainer->DefineStringToken("{seriesnetwork}", (int)eScraperST::seriesnetwork);
+ tokenContainer->DefineStringToken("{seriesgenre}", (int)eScraperST::seriesgenre);
+ tokenContainer->DefineStringToken("{seriesrating}", (int)eScraperST::seriesrating);
+ tokenContainer->DefineStringToken("{seriesstatus}", (int)eScraperST::seriesstatus);
+ tokenContainer->DefineStringToken("{episodetitle}", (int)eScraperST::episodetitle);
+ tokenContainer->DefineStringToken("{episodefirstaired}", (int)eScraperST::episodefirstaired);
+ tokenContainer->DefineStringToken("{episodegueststars}", (int)eScraperST::episodegueststars);
+ tokenContainer->DefineStringToken("{episodeoverview}", (int)eScraperST::episodeoverview);
+ tokenContainer->DefineStringToken("{episoderating}", (int)eScraperST::episoderating);
+ tokenContainer->DefineStringToken("{episodeimagepath}", (int)eScraperST::episodeimagepath);
+ tokenContainer->DefineStringToken("{seasonposterpath}", (int)eScraperST::seasonposterpath);
+ tokenContainer->DefineStringToken("{seriesposter1path}", (int)eScraperST::seriesposter1path);
+ tokenContainer->DefineStringToken("{seriesposter2path}", (int)eScraperST::seriesposter2path);
+ tokenContainer->DefineStringToken("{seriesposter3path}", (int)eScraperST::seriesposter3path);
+ tokenContainer->DefineStringToken("{seriesfanart1path}", (int)eScraperST::seriesfanart1path);
+ tokenContainer->DefineStringToken("{seriesfanart2path}", (int)eScraperST::seriesfanart2path);
+ tokenContainer->DefineStringToken("{seriesfanart3path}", (int)eScraperST::seriesfanart3path);
+ tokenContainer->DefineStringToken("{seriesbanner1path}", (int)eScraperST::seriesbanner1path);
+ tokenContainer->DefineStringToken("{seriesbanner2path}", (int)eScraperST::seriesbanner2path);
+ tokenContainer->DefineStringToken("{seriesbanner3path}", (int)eScraperST::seriesbanner3path);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eDmDetailedEpgIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eDmDetailedEpgIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eDmDetailedEpgIT::year);
+ tokenContainer->DefineIntToken("{running}", (int)eDmDetailedEpgIT::running);
+ tokenContainer->DefineIntToken("{elapsed}", (int)eDmDetailedEpgIT::elapsed);
+ tokenContainer->DefineIntToken("{duration}", (int)eDmDetailedEpgIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eDmDetailedEpgIT::durationhours);
+ tokenContainer->DefineIntToken("{channelnumber}", (int)eDmDetailedEpgIT::channelnumber);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eDmDetailedEpgIT::channellogoexists);
+ tokenContainer->DefineIntToken("{hasreruns}", (int)eDmDetailedEpgIT::hasreruns);
+ tokenContainer->DefineIntToken("{epgpic1avaialble}", (int)eDmDetailedEpgIT::epgpic1avaialble);
+ tokenContainer->DefineIntToken("{epgpic2avaialble}", (int)eDmDetailedEpgIT::epgpic2avaialble);
+ tokenContainer->DefineIntToken("{epgpic3avaialble}", (int)eDmDetailedEpgIT::epgpic3avaialble);
+ tokenContainer->DefineIntToken("{ismovie}", (int)eScraperIT::ismovie);
+ tokenContainer->DefineIntToken("{moviebudget}", (int)eScraperIT::moviebudget);
+ tokenContainer->DefineIntToken("{movierevenue}", (int)eScraperIT::movierevenue);
+ tokenContainer->DefineIntToken("{movieadult}", (int)eScraperIT::movieadult);
+ tokenContainer->DefineIntToken("{movieruntime}", (int)eScraperIT::movieruntime);
+ tokenContainer->DefineIntToken("{isseries}", (int)eScraperIT::isseries);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperIT::posterheight);
+ tokenContainer->DefineIntToken("{fanartwidth}", (int)eScraperIT::fanartwidth);
+ tokenContainer->DefineIntToken("{fanartheight}", (int)eScraperIT::fanartheight);
+ tokenContainer->DefineIntToken("{movieiscollection}", (int)eScraperIT::movieiscollection);
+ tokenContainer->DefineIntToken("{collectionposterwidth}", (int)eScraperIT::collectionposterwidth);
+ tokenContainer->DefineIntToken("{collectionposterheight}", (int)eScraperIT::collectionposterheight);
+ tokenContainer->DefineIntToken("{collectionfanartwidth}", (int)eScraperIT::collectionfanartwidth);
+ tokenContainer->DefineIntToken("{collectionfanartheight}", (int)eScraperIT::collectionfanartheight);
+ tokenContainer->DefineIntToken("{epgpicavailable}", (int)eScraperIT::epgpicavailable);
+ tokenContainer->DefineIntToken("{episodenumber}", (int)eScraperIT::episodenumber);
+ tokenContainer->DefineIntToken("{episodeseason}", (int)eScraperIT::episodeseason);
+ tokenContainer->DefineIntToken("{episodeimagewidth}", (int)eScraperIT::episodeimagewidth);
+ tokenContainer->DefineIntToken("{episodeimageheight}", (int)eScraperIT::episodeimageheight);
+ tokenContainer->DefineIntToken("{seasonposterwidth}", (int)eScraperIT::seasonposterwidth);
+ tokenContainer->DefineIntToken("{seasonposterheight}", (int)eScraperIT::seasonposterheight);
+ tokenContainer->DefineIntToken("{seriesposter1width}", (int)eScraperIT::seriesposter1width);
+ tokenContainer->DefineIntToken("{seriesposter1height}", (int)eScraperIT::seriesposter1height);
+ tokenContainer->DefineIntToken("{seriesposter2width}", (int)eScraperIT::seriesposter2width);
+ tokenContainer->DefineIntToken("{seriesposter2height}", (int)eScraperIT::seriesposter2height);
+ tokenContainer->DefineIntToken("{seriesposter3width}", (int)eScraperIT::seriesposter3width);
+ tokenContainer->DefineIntToken("{seriesposter3height}", (int)eScraperIT::seriesposter3height);
+ tokenContainer->DefineIntToken("{seriesfanart1width}", (int)eScraperIT::seriesfanart1width);
+ tokenContainer->DefineIntToken("{seriesfanart1height}", (int)eScraperIT::seriesfanart1height);
+ tokenContainer->DefineIntToken("{seriesfanart2width}", (int)eScraperIT::seriesfanart2width);
+ tokenContainer->DefineIntToken("{seriesfanart2height}", (int)eScraperIT::seriesfanart2height);
+ tokenContainer->DefineIntToken("{seriesfanart3width}", (int)eScraperIT::seriesfanart3width);
+ tokenContainer->DefineIntToken("{seriesfanart3height}", (int)eScraperIT::seriesfanart3height);
+ tokenContainer->DefineIntToken("{seriesbanner1width}", (int)eScraperIT::seriesbanner1width);
+ tokenContainer->DefineIntToken("{seriesbanner1height}", (int)eScraperIT::seriesbanner1height);
+ tokenContainer->DefineIntToken("{seriesbanner2width}", (int)eScraperIT::seriesbanner2width);
+ tokenContainer->DefineIntToken("{seriesbanner2height}", (int)eScraperIT::seriesbanner2height);
+ tokenContainer->DefineIntToken("{seriesbanner3width}", (int)eScraperIT::seriesbanner3width);
+ tokenContainer->DefineIntToken("{seriesbanner3height}", (int)eScraperIT::seriesbanner3height);
+ tokenContainer->DefineLoopToken("{reruns[title]}", (int)eRerunsLT::title);
+ tokenContainer->DefineLoopToken("{reruns[shorttext]}", (int)eRerunsLT::shorttext);
+ tokenContainer->DefineLoopToken("{reruns[date]}", (int)eRerunsLT::date);
+ tokenContainer->DefineLoopToken("{reruns[day]}", (int)eRerunsLT::day);
+ tokenContainer->DefineLoopToken("{reruns[start]}", (int)eRerunsLT::start);
+ tokenContainer->DefineLoopToken("{reruns[stop]}", (int)eRerunsLT::stop);
+ tokenContainer->DefineLoopToken("{reruns[channelname]}", (int)eRerunsLT::channelname);
+ tokenContainer->DefineLoopToken("{reruns[channelnumber]}", (int)eRerunsLT::channelnumber);
+ tokenContainer->DefineLoopToken("{reruns[channelid]}", (int)eRerunsLT::channelid);
+ tokenContainer->DefineLoopToken("{reruns[channellogoexists]}", (int)eRerunsLT::channellogoexists);
+ tokenContainer->DefineLoopToken("{actors[name]}", (int)eScraperLT::name);
+ tokenContainer->DefineLoopToken("{actors[role]}", (int)eScraperLT::role);
+ tokenContainer->DefineLoopToken("{actors[thumb]}", (int)eScraperLT::thumb);
+ tokenContainer->DefineLoopToken("{actors[thumbwidth]}", (int)eScraperLT::thumbwidth);
+ tokenContainer->DefineLoopToken("{actors[thumbheight]}", (int)eScraperLT::thumbheight);
+ rerunsIndex = tokenContainer->LoopIndex("reruns");
+ actorsIndex = tokenContainer->LoopIndex("actors");
+ InheritTokenContainer();
+}
+
+bool cViewDetailEpg::Parse(bool forced) {
+ if (!cViewElement::Parse())
+ return false;
+ if (!event)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::title, event->Title());
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::shorttext, event->ShortText());
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::description, event->Description());
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::start, *(event->GetTimeString()));
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::stop, *(event->GetEndTimeString()));
+ time_t startTime = event->StartTime();
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::day, *WeekDayName(startTime));
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::date, *ShortDateString(startTime));
+ struct tm * sStartTime = localtime(&startTime);
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::month, sStartTime->tm_mon+1);
+ const cChannel *channel = Channels.GetByChannelID(event->ChannelID());
+ if (channel) {
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::channelname, channel->Name());
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::channelnumber, channel->Number());
+ }
+ cString channelID = event->ChannelID().ToString();
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::channellogoexists, imgCache->LogoExists(*channelID));
+
+ bool isRunning = false;
+ time_t now = time(NULL);
+ if ((now >= event->StartTime()) && (now <= event->EndTime()))
+ isRunning = true;
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::running, isRunning);
+ if (isRunning) {
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::elapsed, (now - event->StartTime())/60);
+ } else {
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::elapsed, 0);
+ }
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::duration, event->Duration() / 60);
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::durationhours, event->Duration() / 3600);
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::durationminutes, *cString::sprintf("%.2d", (event->Duration() / 60)%60));
+ if (event->Vps())
+ tokenContainer->AddStringToken((int)eDmDetailedEpgST::vps, *event->GetVpsString());
+
+ cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns = LoadReruns();
+ int numReruns = NumReruns(reruns);
+ vector<int> loopInfo;
+ //num reruns
+ loopInfo.push_back(numReruns);
+ //num actors
+ bool scrapInfoAvailable = LoadFullScrapInfo(event, NULL);
+ int numActors = NumActors();
+ loopInfo.push_back(numActors);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+ if (numReruns > 0) {
+ tokenContainer->AddIntToken((int)eDmDetailedEpgIT::hasreruns, 1);
+ SetReruns(reruns);
+ }
+ if (scrapInfoAvailable) {
+ SetFullScrapInfo(tokenContainer, actorsIndex);
+ }
+ SetDirty();
+ return true;
+}
+
+cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *cViewDetailEpg::LoadReruns(void) {
+ cPlugin *epgSearchPlugin = cPluginManager::GetPlugin("epgsearch");
+ if (!epgSearchPlugin)
+ return NULL;
+
+ if (isempty(event->Title()))
+ return NULL;
+
+ Epgsearch_searchresults_v1_0 data;
+ data.query = (char*)event->Title();
+ data.mode = 0;
+ data.channelNr = 0;
+ data.useTitle = true;
+ data.useSubTitle = true;
+ data.useDescription = false;
+
+ cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *result = NULL;
+ if (epgSearchPlugin->Service("Epgsearch-searchresults-v1.0", &data))
+ result = data.pResultList;
+ return result;
+}
+
+int cViewDetailEpg::NumReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns) {
+ if (!reruns || reruns->Count() < 2)
+ return 0;
+
+ int maxNumReruns = config.rerunAmount;
+ int rerunDistance = config.rerunDistance * 3600;
+ int rerunMaxChannel = config.rerunMaxChannel;
+
+ int i = 0;
+ for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = reruns->First(); r && i < maxNumReruns; r = reruns->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 (rerunMaxChannel > 0)
+ if (channel && channel->Number() > rerunMaxChannel)
+ continue;
+ i++;
+ }
+ return i;
+}
+
+void cViewDetailEpg::SetReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns) {
+ if (!reruns || reruns->Count() < 2)
+ return;
+
+ int maxNumReruns = config.rerunAmount;
+ int rerunDistance = config.rerunDistance * 3600;
+ int rerunMaxChannel = config.rerunMaxChannel;
+
+ int i = 0;
+ for (Epgsearch_searchresults_v1_0::cServiceSearchResult *r = reruns->First(); r && i < maxNumReruns; r = reruns->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 (rerunMaxChannel > 0)
+ if (channel && channel->Number() > rerunMaxChannel)
+ continue;
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::title, r->event->Title());
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::shorttext, r->event->ShortText());
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::start, *(r->event->GetTimeString()));
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::stop, *(r->event->GetEndTimeString()));
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::date, *ShortDateString(r->event->StartTime()));
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::day, *WeekDayName(r->event->StartTime()));
+ cString channelID = r->event->ChannelID().ToString();
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelid, *channelID);
+ bool logoExists = imgCache->LogoExists(*channelID);
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channellogoexists, logoExists ? "1" : "0");
+ if (channel) {
+ cString channelNumber = cString::sprintf("%d", channel->Number());
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelname, channel->ShortName(true));
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelnumber, *channelNumber);
+ } else {
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelname, "");
+ tokenContainer->AddLoopToken(rerunsIndex, i, (int)eRerunsLT::channelnumber, "");
+ }
+ i++;
+ }
+}
+
+/******************************************************************
+* cViewDetailRec
+******************************************************************/
+cViewDetailRec::cViewDetailRec(void) {
+ recording = NULL;
+ actorsIndex = -1;
+}
+
+cViewDetailRec::~cViewDetailRec(void) {
+}
+
+void cViewDetailRec::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{name}", (int)eDmDetailedRecST::name);
+ tokenContainer->DefineStringToken("{epgname}", (int)eDmDetailedRecST::epgname);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eDmDetailedRecST::shorttext);
+ tokenContainer->DefineStringToken("{description}", (int)eDmDetailedRecST::description);
+ tokenContainer->DefineStringToken("{day}", (int)eDmDetailedRecST::day);
+ tokenContainer->DefineStringToken("{date}", (int)eDmDetailedRecST::date);
+ tokenContainer->DefineStringToken("{time}", (int)eDmDetailedRecST::time);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eDmDetailedRecST::durationminutes);
+ tokenContainer->DefineStringToken("{durationeventminutes}", (int)eDmDetailedRecST::durationeventminutes);
+ tokenContainer->DefineStringToken("{recchannelname}", (int)eDmDetailedRecST::recchannelname);
+ tokenContainer->DefineStringToken("{recchannelid}", (int)eDmDetailedRecST::recchannelid);
+ tokenContainer->DefineStringToken("{recordingsize}", (int)eDmDetailedRecST::recordingsize);
+ tokenContainer->DefineStringToken("{recordingsizecutted}", (int)eDmDetailedRecST::recordingsizecutted);
+ tokenContainer->DefineStringToken("{recordinglength}", (int)eDmDetailedRecST::recordinglength);
+ tokenContainer->DefineStringToken("{recordinglengthcutted}", (int)eDmDetailedRecST::recordinglengthcutted);
+ tokenContainer->DefineStringToken("{recordingbitrate}", (int)eDmDetailedRecST::recordingbitrate);
+ tokenContainer->DefineStringToken("{recordingformat}", (int)eDmDetailedRecST::recordingformat);
+ tokenContainer->DefineStringToken("{searchtimer}", (int)eDmDetailedRecST::searchtimer);
+ tokenContainer->DefineStringToken("{recimg1path}", (int)eDmDetailedRecST::recimg1path);
+ tokenContainer->DefineStringToken("{recimg2path}", (int)eDmDetailedRecST::recimg2path);
+ tokenContainer->DefineStringToken("{recimg3path}", (int)eDmDetailedRecST::recimg3path);
+ tokenContainer->DefineStringToken("{movietitle}", (int)eScraperST::movietitle);
+ tokenContainer->DefineStringToken("{movieoriginalTitle}", (int)eScraperST::movieoriginalTitle);
+ tokenContainer->DefineStringToken("{movietagline}", (int)eScraperST::movietagline);
+ tokenContainer->DefineStringToken("{movieoverview}", (int)eScraperST::movieoverview);
+ tokenContainer->DefineStringToken("{moviegenres}", (int)eScraperST::moviegenres);
+ tokenContainer->DefineStringToken("{moviehomepage}", (int)eScraperST::moviehomepage);
+ tokenContainer->DefineStringToken("{moviereleasedate}", (int)eScraperST::moviereleasedate);
+ tokenContainer->DefineStringToken("{moviepopularity}", (int)eScraperST::moviepopularity);
+ tokenContainer->DefineStringToken("{movievoteaverage}", (int)eScraperST::movievoteaverage);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperST::posterpath);
+ tokenContainer->DefineStringToken("{fanartpath}", (int)eScraperST::fanartpath);
+ tokenContainer->DefineStringToken("{moviecollectionName}", (int)eScraperST::moviecollectionName);
+ tokenContainer->DefineStringToken("{collectionposterpath}", (int)eScraperST::collectionposterpath);
+ tokenContainer->DefineStringToken("{collectionfanartpath}", (int)eScraperST::collectionfanartpath);
+ tokenContainer->DefineStringToken("{seriesname}", (int)eScraperST::seriesname);
+ tokenContainer->DefineStringToken("{seriesoverview}", (int)eScraperST::seriesoverview);
+ tokenContainer->DefineStringToken("{seriesfirstaired}", (int)eScraperST::seriesfirstaired);
+ tokenContainer->DefineStringToken("{seriesnetwork}", (int)eScraperST::seriesnetwork);
+ tokenContainer->DefineStringToken("{seriesgenre}", (int)eScraperST::seriesgenre);
+ tokenContainer->DefineStringToken("{seriesrating}", (int)eScraperST::seriesrating);
+ tokenContainer->DefineStringToken("{seriesstatus}", (int)eScraperST::seriesstatus);
+ tokenContainer->DefineStringToken("{episodetitle}", (int)eScraperST::episodetitle);
+ tokenContainer->DefineStringToken("{episodefirstaired}", (int)eScraperST::episodefirstaired);
+ tokenContainer->DefineStringToken("{episodegueststars}", (int)eScraperST::episodegueststars);
+ tokenContainer->DefineStringToken("{episodeoverview}", (int)eScraperST::episodeoverview);
+ tokenContainer->DefineStringToken("{episoderating}", (int)eScraperST::episoderating);
+ tokenContainer->DefineStringToken("{episodeimagepath}", (int)eScraperST::episodeimagepath);
+ tokenContainer->DefineStringToken("{seasonposterpath}", (int)eScraperST::seasonposterpath);
+ tokenContainer->DefineStringToken("{seriesposter1path}", (int)eScraperST::seriesposter1path);
+ tokenContainer->DefineStringToken("{seriesposter2path}", (int)eScraperST::seriesposter2path);
+ tokenContainer->DefineStringToken("{seriesposter3path}", (int)eScraperST::seriesposter3path);
+ tokenContainer->DefineStringToken("{seriesfanart1path}", (int)eScraperST::seriesfanart1path);
+ tokenContainer->DefineStringToken("{seriesfanart2path}", (int)eScraperST::seriesfanart2path);
+ tokenContainer->DefineStringToken("{seriesfanart3path}", (int)eScraperST::seriesfanart3path);
+ tokenContainer->DefineStringToken("{seriesbanner1path}", (int)eScraperST::seriesbanner1path);
+ tokenContainer->DefineStringToken("{seriesbanner2path}", (int)eScraperST::seriesbanner2path);
+ tokenContainer->DefineStringToken("{seriesbanner3path}", (int)eScraperST::seriesbanner3path);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eDmDetailedRecIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eDmDetailedRecIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eDmDetailedRecIT::year);
+ tokenContainer->DefineIntToken("{duration}", (int)eDmDetailedRecIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eDmDetailedRecIT::durationhours);
+ tokenContainer->DefineIntToken("{durationevent}", (int)eDmDetailedRecIT::durationevent);
+ tokenContainer->DefineIntToken("{durationeventhours}", (int)eDmDetailedRecIT::durationeventhours);
+ tokenContainer->DefineIntToken("{recchannelnumber}", (int)eDmDetailedRecIT::recchannelnumber);
+ tokenContainer->DefineIntToken("{cutted}", (int)eDmDetailedRecIT::cutted);
+ tokenContainer->DefineIntToken("{recimg1avaialble}", (int)eDmDetailedRecIT::recimg1avaialble);
+ tokenContainer->DefineIntToken("{recimg2avaialble}", (int)eDmDetailedRecIT::recimg2avaialble);
+ tokenContainer->DefineIntToken("{recimg3avaialble}", (int)eDmDetailedRecIT::recimg3avaialble);
+ tokenContainer->DefineIntToken("{ismovie}", (int)eScraperIT::ismovie);
+ tokenContainer->DefineIntToken("{moviebudget}", (int)eScraperIT::moviebudget);
+ tokenContainer->DefineIntToken("{movierevenue}", (int)eScraperIT::movierevenue);
+ tokenContainer->DefineIntToken("{movieadult}", (int)eScraperIT::movieadult);
+ tokenContainer->DefineIntToken("{movieruntime}", (int)eScraperIT::movieruntime);
+ tokenContainer->DefineIntToken("{isseries}", (int)eScraperIT::isseries);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperIT::posterheight);
+ tokenContainer->DefineIntToken("{fanartwidth}", (int)eScraperIT::fanartwidth);
+ tokenContainer->DefineIntToken("{fanartheight}", (int)eScraperIT::fanartheight);
+ tokenContainer->DefineIntToken("{movieiscollection}", (int)eScraperIT::movieiscollection);
+ tokenContainer->DefineIntToken("{collectionposterwidth}", (int)eScraperIT::collectionposterwidth);
+ tokenContainer->DefineIntToken("{collectionposterheight}", (int)eScraperIT::collectionposterheight);
+ tokenContainer->DefineIntToken("{collectionfanartwidth}", (int)eScraperIT::collectionfanartwidth);
+ tokenContainer->DefineIntToken("{collectionfanartheight}", (int)eScraperIT::collectionfanartheight);
+ tokenContainer->DefineIntToken("{epgpicavailable}", (int)eScraperIT::epgpicavailable);
+ tokenContainer->DefineIntToken("{episodenumber}", (int)eScraperIT::episodenumber);
+ tokenContainer->DefineIntToken("{episodeseason}", (int)eScraperIT::episodeseason);
+ tokenContainer->DefineIntToken("{episodeimagewidth}", (int)eScraperIT::episodeimagewidth);
+ tokenContainer->DefineIntToken("{episodeimageheight}", (int)eScraperIT::episodeimageheight);
+ tokenContainer->DefineIntToken("{seasonposterwidth}", (int)eScraperIT::seasonposterwidth);
+ tokenContainer->DefineIntToken("{seasonposterheight}", (int)eScraperIT::seasonposterheight);
+ tokenContainer->DefineIntToken("{seriesposter1width}", (int)eScraperIT::seriesposter1width);
+ tokenContainer->DefineIntToken("{seriesposter1height}", (int)eScraperIT::seriesposter1height);
+ tokenContainer->DefineIntToken("{seriesposter2width}", (int)eScraperIT::seriesposter2width);
+ tokenContainer->DefineIntToken("{seriesposter2height}", (int)eScraperIT::seriesposter2height);
+ tokenContainer->DefineIntToken("{seriesposter3width}", (int)eScraperIT::seriesposter3width);
+ tokenContainer->DefineIntToken("{seriesposter3height}", (int)eScraperIT::seriesposter3height);
+ tokenContainer->DefineIntToken("{seriesfanart1width}", (int)eScraperIT::seriesfanart1width);
+ tokenContainer->DefineIntToken("{seriesfanart1height}", (int)eScraperIT::seriesfanart1height);
+ tokenContainer->DefineIntToken("{seriesfanart2width}", (int)eScraperIT::seriesfanart2width);
+ tokenContainer->DefineIntToken("{seriesfanart2height}", (int)eScraperIT::seriesfanart2height);
+ tokenContainer->DefineIntToken("{seriesfanart3width}", (int)eScraperIT::seriesfanart3width);
+ tokenContainer->DefineIntToken("{seriesfanart3height}", (int)eScraperIT::seriesfanart3height);
+ tokenContainer->DefineIntToken("{seriesbanner1width}", (int)eScraperIT::seriesbanner1width);
+ tokenContainer->DefineIntToken("{seriesbanner1height}", (int)eScraperIT::seriesbanner1height);
+ tokenContainer->DefineIntToken("{seriesbanner2width}", (int)eScraperIT::seriesbanner2width);
+ tokenContainer->DefineIntToken("{seriesbanner2height}", (int)eScraperIT::seriesbanner2height);
+ tokenContainer->DefineIntToken("{seriesbanner3width}", (int)eScraperIT::seriesbanner3width);
+ tokenContainer->DefineIntToken("{seriesbanner3height}", (int)eScraperIT::seriesbanner3height);
+ tokenContainer->DefineLoopToken("{actors[name]}", (int)eScraperLT::name);
+ tokenContainer->DefineLoopToken("{actors[role]}", (int)eScraperLT::role);
+ tokenContainer->DefineLoopToken("{actors[thumb]}", (int)eScraperLT::thumb);
+ tokenContainer->DefineLoopToken("{actors[thumbwidth]}", (int)eScraperLT::thumbwidth);
+ tokenContainer->DefineLoopToken("{actors[thumbheight]}", (int)eScraperLT::thumbheight);
+ actorsIndex = tokenContainer->LoopIndex("actors");
+ InheritTokenContainer();
+}
+
+bool cViewDetailRec::Parse(bool forced) {
+ if (!cViewElement::Parse())
+ return false;
+ if (!recording)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::name, recording->Name());
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::cutted, recording->IsEdited());
+
+ const cRecordingInfo *info = recording->Info();
+ if (info) {
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::epgname, info->Title());
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::shorttext, info->ShortText());
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::description, info->Description());
+ const cEvent *event = info->GetEvent();
+ if (event) {
+ cString recDate = event->GetDateString();
+ cString recTime = event->GetTimeString();
+ if (strstr(*recDate, "1970")) {
+ 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;
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::date, *recDate);
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::time, *recTime);
+ time_t startTime = event->StartTime();
+ struct tm * sStartTime = localtime(&startTime);
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::month, sStartTime->tm_mon+1);
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::duration, recDuration);
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationhours, recDuration / 60);
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::durationminutes, *cString::sprintf("%.2d", recDuration%60));
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationevent, duration);
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::durationeventhours, duration / 60);
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::durationeventminutes, *cString::sprintf("%.2d", duration%60));
+ }
+ }
+ SetRecInfos();
+ SetRecordingImages(recording->FileName());
+
+ vector<int> loopInfo;
+ bool scrapInfoAvailable = LoadFullScrapInfo(NULL, recording);
+ int numActors = NumActors();
+ loopInfo.push_back(numActors);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+ if (scrapInfoAvailable) {
+ SetFullScrapInfo(tokenContainer, actorsIndex);
+ }
+
+ SetDirty();
+ return true;
+}
+
+void cViewDetailRec::SetRecInfos(void) {
+ 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;
+ }
+ }
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingsize, *strRecSize);
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingsizecutted, *strRecSizeCut);
+ }
+
+ const cRecordingInfo *info = recording->Info();
+ if (info) {
+ cChannel *channel = Channels.GetByChannelID(info->ChannelID());
+ if (channel) {
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recchannelname, channel->Name());
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recchannelid, *channel->GetChannelID().ToString());
+ tokenContainer->AddIntToken((int)eDmDetailedRecIT::recchannelnumber, channel->Number());
+ }
+ }
+
+
+ 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));
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recordinglength, strLength.c_str());
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recordinglengthcutted, strLengthCutted.c_str());
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingbitrate, strBitrate.c_str());
+ }
+ delete index;
+ }
+
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::recordingformat, recording->IsPesRecording() ? "PES" : "TS");
+
+ 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()) {
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::searchtimer, searchTimer.c_str());
+ searchTimerFound = true;
+ }
+ }
+ }
+ }
+ if (!searchTimerFound)
+ tokenContainer->AddStringToken((int)eDmDetailedRecST::searchtimer, "n.a.");
+}
+
+int cViewDetailRec::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;
+}
+
+string cViewDetailRec::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);
+}
+
+void cViewDetailRec::SetRecordingImages(const char *recPath) {
+ if (!recPath) {
+ return;
+ }
+ DIR *dirHandle;
+ struct dirent *dirEntry;
+ dirHandle = opendir(recPath);
+ if (!dirHandle) {
+ return;
+ }
+ int picsFound = 0;
+ int indexStr = (int)eDmDetailedRecST::recimg1path;
+ int indexInt = (int)eDmDetailedRecIT::recimg1avaialble;
+ while ( 0 != (dirEntry = readdir(dirHandle))) {
+ if (endswith(dirEntry->d_name, "jpg")) {
+ tokenContainer->AddStringToken(indexStr, *cString::sprintf("%s/%s", recPath, dirEntry->d_name));
+ tokenContainer->AddIntToken(indexInt, 1);
+ picsFound++;
+ }
+ if (picsFound == 3) {
+ break;
+ }
+ }
+ closedir(dirHandle);
+}
+
+/******************************************************************
+* cViewDetailText
+******************************************************************/
+cViewDetailText::cViewDetailText(void) {
+ text = NULL;
+}
+
+cViewDetailText::~cViewDetailText(void) {
+}
+
+void cViewDetailText::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{text}", (int)eDmDetailedTextST::text);
+ InheritTokenContainer();
+}
+
+bool cViewDetailText::Parse(bool forced) {
+ if (!cViewElement::Parse())
+ return false;
+ if (!text)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDmDetailedTextST::text, text);
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cViewDetailPlugin
+******************************************************************/
+cViewDetailPlugin::cViewDetailPlugin(void) {
+}
+
+cViewDetailPlugin::~cViewDetailPlugin(void) {
+}
+
+void cViewDetailPlugin::SetTokenContainer(void) {
+ if (plugId == -1 || plugMenuId == -1)
+ return;
+ skindesignerapi::cTokenContainer *tkPlugMenu = plgManager->GetTokenContainer(plugId, plugMenuId);
+ tokenContainer = new skindesignerapi::cTokenContainer(*tkPlugMenu);
+ InheritTokenContainer();
+}
+
+void cViewDetailPlugin::Set(skindesignerapi::cTokenContainer *tk) {
+ tokenContainer->Clear();
+ tokenContainer->SetTokens(tk);
+}
+
+bool cViewDetailPlugin::Parse(bool forced) {
+ if (!cViewElement::Parse())
+ return false;
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cViewDetailAdvancedPlugin
+******************************************************************/
+cViewDetailAdvancedPlugin::cViewDetailAdvancedPlugin(int viewId, int plugId) {
+ this->plugId = plugId;
+ plugViewId = viewId;
+}
+
+cViewDetailAdvancedPlugin::~cViewDetailAdvancedPlugin(void) {
+}
+
+void cViewDetailAdvancedPlugin::SetTokenContainer(void) {
+ if (plugId == -1 || plugViewId == -1)
+ return;
+ skindesignerapi::cTokenContainer *tkDetail = plgManager->GetTokenContainerTab(plugId, plugViewId);
+ tokenContainer = new skindesignerapi::cTokenContainer(*tkDetail);
+ InheritTokenContainer();
+}
+
+void cViewDetailAdvancedPlugin::Set(skindesignerapi::cTokenContainer *tk) {
+ tokenContainer->Clear();
+ tokenContainer->SetTokens(tk);
+}
+
+bool cViewDetailAdvancedPlugin::Parse(bool forced) {
+ if (!cViewElement::Parse())
+ return false;
+ SetDirty();
+ return true;
+}
diff --git a/coreengine/viewdetail.h b/coreengine/viewdetail.h new file mode 100644 index 0000000..9fb63e6 --- /dev/null +++ b/coreengine/viewdetail.h @@ -0,0 +1,114 @@ +#ifndef __VIEWDETAIL_H
+#define __VIEWDETAIL_H
+
+#include "../services/epgsearch.h"
+#include "../extensions/scrapmanager.h"
+#include "viewelement.h"
+/******************************************************************
+* cViewDetail
+******************************************************************/
+class cViewDetail : public cViewElement, public cScrapManager {
+protected:
+ int plugId;
+ int plugMenuId;
+ cArea *activeTab;
+ int activeTabIndex;
+ int numTabs;
+ void SetActiveTab(void);
+public:
+ cViewDetail(void);
+ virtual ~cViewDetail(void);
+ void SetPlugId(int id) { plugId = id; };
+ void SetPlugMenuId(int id) { plugMenuId = id; };
+ int GetWidth(void);
+ void ResetTabs(void);
+ void Clear(void);
+ void Close(void);
+ void Render(void);
+ void Scrollbar(int &barheight, int &offset, bool &end);
+ bool ScrollUp(bool page = false);
+ bool ScrollDown(bool page = false);
+ int GetTabs(vector<const char*> &tabs);
+ int NumTabs(void) { return numTabs; };
+ int ActiveTab(void) { return activeTabIndex; };
+ void NextTab(void);
+ void PrevTab(void);
+ void SetTransparency(int transparency, bool forceDetached = false);
+};
+/******************************************************************
+* cViewDetailEpg
+******************************************************************/
+class cViewDetailEpg : public cViewDetail {
+protected:
+ const cEvent *event;
+ int rerunsIndex;
+ int actorsIndex;
+ cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *LoadReruns(void);
+ int NumReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns);
+ void SetReruns(cList<Epgsearch_searchresults_v1_0::cServiceSearchResult> *reruns);
+public:
+ cViewDetailEpg(void);
+ virtual ~cViewDetailEpg(void);
+ void SetTokenContainer(void);
+ void SetEvent(const cEvent *event) { this->event = event; };
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cViewDetailRec
+******************************************************************/
+class cViewDetailRec : public cViewDetail {
+protected:
+ const cRecording *recording;
+ int actorsIndex;
+ void SetRecInfos(void);
+ int ReadSizeVdr(const char *strPath);
+ string StripXmlTag(string &Line, const char *Tag);
+ void SetRecordingImages(const char *recPath);
+public:
+ cViewDetailRec(void);
+ virtual ~cViewDetailRec(void);
+ void SetTokenContainer(void);
+ void SetRecording(const cRecording *recording) { this->recording = recording; };
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cViewDetailText
+******************************************************************/
+class cViewDetailText : public cViewDetail {
+protected:
+ const char *text;
+public:
+ cViewDetailText(void);
+ virtual ~cViewDetailText(void);
+ void SetTokenContainer(void);
+ void SetText(const char *text) { this->text = text; };
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cViewDetailPlugin
+******************************************************************/
+class cViewDetailPlugin : public cViewDetail {
+protected:
+public:
+ cViewDetailPlugin(void);
+ virtual ~cViewDetailPlugin(void);
+ void SetTokenContainer(void);
+ void Set(skindesignerapi::cTokenContainer *tk);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cViewDetailAdvancedPlugin
+******************************************************************/
+class cViewDetailAdvancedPlugin : public cViewDetail {
+protected:
+ int plugViewId;
+public:
+ cViewDetailAdvancedPlugin(int viewId, int plugId);
+ virtual ~cViewDetailAdvancedPlugin(void);
+ void SetTokenContainer(void);
+ void Set(skindesignerapi::cTokenContainer *tk);
+ bool Parse(bool forced = false);
+};
+#endif //__VIEWDETAIL_H
\ No newline at end of file diff --git a/coreengine/viewdisplaychannel.c b/coreengine/viewdisplaychannel.c new file mode 100644 index 0000000..9be9393 --- /dev/null +++ b/coreengine/viewdisplaychannel.c @@ -0,0 +1,199 @@ +#include "viewdisplaychannel.h"
+#include "../config.h"
+
+/************************************************************************************
+* cViewChannel
+************************************************************************************/
+
+cViewChannel::cViewChannel(void) {
+ veCustomTokens = NULL;
+ ClearVariables();
+ viewId = eViewType::DisplayChannel;
+ viewName = strdup("displaychannel");
+ numViewElements = (int)eVeDisplayChannel::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ SetViewElements();
+ veMessage = NULL;
+ veChannelInfo = NULL;
+ veChannelGroup = NULL;
+ veEpgInfo = NULL;
+ veProgressBar = NULL;
+ veStatusInfo = NULL;
+ veScraperContent = NULL;
+ veEcmInfo = NULL;
+}
+
+cViewChannel::~cViewChannel() {
+}
+
+void cViewChannel::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayChannel::background));
+ viewElementNames.insert(pair<string, int>("channelgroup", (int)eVeDisplayChannel::channelgroup));
+ viewElementNames.insert(pair<string, int>("channelinfo", (int)eVeDisplayChannel::channelinfo));
+ viewElementNames.insert(pair<string, int>("epginfo", (int)eVeDisplayChannel::epginfo));
+ viewElementNames.insert(pair<string, int>("progressbar", (int)eVeDisplayChannel::progressbar));
+ viewElementNames.insert(pair<string, int>("statusinfo", (int)eVeDisplayChannel::statusinfo));
+ viewElementNames.insert(pair<string, int>("audioinfo", (int)eVeDisplayChannel::audioinfo));
+ viewElementNames.insert(pair<string, int>("ecminfo", (int)eVeDisplayChannel::ecminfo));
+ viewElementNames.insert(pair<string, int>("screenresolution", (int)eVeDisplayChannel::screenresolution));
+ viewElementNames.insert(pair<string, int>("signalquality", (int)eVeDisplayChannel::signalquality));
+ viewElementNames.insert(pair<string, int>("devices", (int)eVeDisplayChannel::devices));
+ viewElementNames.insert(pair<string, int>("currentweather", (int)eVeDisplayChannel::currentweather));
+ viewElementNames.insert(pair<string, int>("scrapercontent", (int)eVeDisplayChannel::scrapercontent));
+ viewElementNames.insert(pair<string, int>("datetime", (int)eVeDisplayChannel::datetime));
+ viewElementNames.insert(pair<string, int>("time", (int)eVeDisplayChannel::time));
+ viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayChannel::message));
+ viewElementNames.insert(pair<string, int>("customtokens", (int)eVeDisplayChannel::customtokens));
+}
+
+void cViewChannel::SetViewElementObjects(void) {
+ for (int i = 0; i < numViewElements; i++) {
+ if (!viewElements[i])
+ continue;
+ if (dynamic_cast<cVeMessage*>(viewElements[i]))
+ {
+ veMessage = dynamic_cast<cVeMessage*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDcChannelInfo*>(viewElements[i])) {
+
+ veChannelInfo = dynamic_cast<cVeDcChannelInfo*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDcChannelGroup*>(viewElements[i]))
+ {
+ veChannelGroup = dynamic_cast<cVeDcChannelGroup*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDcEpgInfo*>(viewElements[i]))
+ {
+ veEpgInfo = dynamic_cast<cVeDcEpgInfo*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDcProgressBar*>(viewElements[i]))
+ {
+ veProgressBar = dynamic_cast<cVeDcProgressBar*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDcStatusInfo*>(viewElements[i]))
+ {
+ veStatusInfo = dynamic_cast<cVeDcStatusInfo*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDcScraperContent*>(viewElements[i]))
+ {
+ veScraperContent = dynamic_cast<cVeDcScraperContent*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDcEcmInfo*>(viewElements[i]))
+ {
+ veEcmInfo = dynamic_cast<cVeDcEcmInfo*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeCustomTokens*>(viewElements[i]))
+ {
+ veCustomTokens = dynamic_cast<cVeCustomTokens*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDevices*>(viewElements[i]))
+ {
+ viewElements[i]->SetDetached();
+ }
+ }
+}
+
+void cViewChannel::ClearVariables(void) {
+ cView::ClearVariables();
+ channelChange = false;
+ displayChannelGroups = false;
+ if (veCustomTokens)
+ veCustomTokens->Reset();
+}
+
+void cViewChannel::SetChannel(const cChannel *channel, int number) {
+ channelChange = true;
+ bool wasChannelGroups = displayChannelGroups;
+ displayChannelGroups = false;
+
+ if (veChannelInfo) {
+ veChannelInfo->Set(channel, number);
+ }
+
+ if (channel) {
+ if (!channel->GroupSep()) {
+ if (wasChannelGroups)
+ Clear((int)eVeDisplayChannel::channelgroup);
+ if (veStatusInfo)
+ veStatusInfo->Set(channel);
+ if (veEcmInfo)
+ veEcmInfo->Set(channel);
+ } else {
+ displayChannelGroups = true;
+ Clear((int)eVeDisplayChannel::channelinfo);
+ Clear((int)eVeDisplayChannel::epginfo);
+ Clear((int)eVeDisplayChannel::statusinfo);
+ Clear((int)eVeDisplayChannel::progressbar);
+ Clear((int)eVeDisplayChannel::screenresolution);
+ Clear((int)eVeDisplayChannel::signalquality);
+ Clear((int)eVeDisplayChannel::audioinfo);
+ Clear((int)eVeDisplayChannel::ecminfo);
+ Clear((int)eVeDisplayChannel::devices);
+ Clear((int)eVeDisplayChannel::customtokens);
+ if (veChannelGroup)
+ veChannelGroup->Set(channel);
+ }
+ }
+}
+
+void cViewChannel::SetEvents(const cEvent *present, const cEvent *following) {
+ Clear((int)eVeDisplayChannel::epginfo);
+ Clear((int)eVeDisplayChannel::progressbar);
+ Clear((int)eVeDisplayChannel::scrapercontent);
+ if (veProgressBar)
+ veProgressBar->Set(present);
+
+ if (!present && !following)
+ return;
+
+ if (veEpgInfo)
+ veEpgInfo->Set(present, following);
+
+ if (veScraperContent)
+ veScraperContent->Set(present);
+}
+
+void cViewChannel::SetMessage(eMessageType type, const char *text) {
+ if (veMessage) {
+ if (text)
+ veMessage->Set(type, text);
+ else
+ veMessage->Clear();
+ }
+}
+
+void cViewChannel::Flush(void) {
+ if (init) {
+ sdOsd.LockFlush();
+ Render((int)eVeDisplayChannel::background);
+ Render((int)eVeDisplayChannel::progressbar);
+ Render((int)eVeDisplayChannel::currentweather);
+ }
+
+ if (!displayChannelGroups) {
+ //normal display
+ Render((int)eVeDisplayChannel::channelinfo);
+ Render((int)eVeDisplayChannel::epginfo);
+ Render((int)eVeDisplayChannel::statusinfo);
+ Render((int)eVeDisplayChannel::scrapercontent);
+ Render((int)eVeDisplayChannel::progressbar, channelChange);
+ Render((int)eVeDisplayChannel::screenresolution);
+ Render((int)eVeDisplayChannel::signalquality);
+ Render((int)eVeDisplayChannel::audioinfo);
+ Render((int)eVeDisplayChannel::ecminfo);
+ Render((int)eVeDisplayChannel::devices);
+ Render((int)eVeDisplayChannel::customtokens);
+ Render((int)eVeDisplayChannel::message);
+ } else {
+ //channelgroup display
+ Render((int)eVeDisplayChannel::channelgroup);
+ }
+ Render((int)eVeDisplayChannel::datetime);
+ Render((int)eVeDisplayChannel::time);
+ channelChange = false;
+ cView::Flush();
+}
+
diff --git a/coreengine/viewdisplaychannel.h b/coreengine/viewdisplaychannel.h new file mode 100644 index 0000000..d42f8ce --- /dev/null +++ b/coreengine/viewdisplaychannel.h @@ -0,0 +1,31 @@ +#ifndef __VIEWDISPLAYCHANNEL_H
+#define __VIEWDISPLAYCHANNEL_H
+
+#include "view.h"
+
+class cViewChannel : public cView {
+private:
+ cVeMessage *veMessage;
+ cVeCustomTokens *veCustomTokens;
+ cVeDcChannelInfo *veChannelInfo;
+ cVeDcChannelGroup *veChannelGroup;
+ cVeDcEpgInfo *veEpgInfo;
+ cVeDcProgressBar *veProgressBar;
+ cVeDcStatusInfo *veStatusInfo;
+ cVeDcScraperContent *veScraperContent;
+ cVeDcEcmInfo *veEcmInfo;
+ bool channelChange;
+ bool displayChannelGroups;
+ void SetViewElements(void);
+ void ClearVariables(void);
+ void SetViewElementObjects(void);
+public:
+ cViewChannel(void);
+ virtual ~cViewChannel(void);
+ void SetChannel(const cChannel *channel, int number);
+ void SetEvents(const cEvent *present, const cEvent *following);
+ void SetMessage(eMessageType type, const char *text);
+ void Flush(void);
+};
+
+#endif //__VIEWDISPLAYCHANNEL_H
\ No newline at end of file diff --git a/coreengine/viewdisplaymenu.c b/coreengine/viewdisplaymenu.c new file mode 100644 index 0000000..d65b145 --- /dev/null +++ b/coreengine/viewdisplaymenu.c @@ -0,0 +1,1705 @@ +#include "viewdisplaymenu.h"
+#include "../config.h"
+
+/************************************************************************************
+* cViewMenu
+************************************************************************************/
+cViewMenu::cViewMenu(void) {
+ menuDefault = NULL;
+ menuMain = NULL;
+ menuSetup = NULL;
+ menuSchedules = NULL;
+ menuChannels = NULL;
+ menuTimers = NULL;
+ menuRecordings = NULL;
+ menuDetailedEpg = NULL;
+ menuDetailedRec = NULL;
+ menuDetailedText = NULL;
+ ClearVariables();
+ viewId = eViewType::DisplayMenu;
+ viewName = strdup("displaymenu");
+ numViewElements = (int)eVeDisplayMenu::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ viewElementsHorizontal = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElementsHorizontal[i] = NULL;
+ }
+ SetViewElements();
+ int numPluginMenus = plgManager->GetNumPluginMenus();
+ numSubviews = (int)eSvDisplayMenu::count + numPluginMenus;
+ subViews = new cSubView*[numSubviews];
+ for (int i=0; i < numSubviews; i++) {
+ subViews[i] = NULL;
+ }
+ SetSubViews();
+ menuCat = mcUnknown;
+ plugName = NULL;
+}
+
+cViewMenu::~cViewMenu() {
+ for (int i=0; i< numSubviews; i++)
+ delete subViews[i];
+ delete[] subViews;
+}
+
+void cViewMenu::SetGlobals(cGlobals *globals) {
+ cView::SetGlobals(globals);
+ for (int i=0; i < numSubviews; ++i) {
+ if (subViews[i]) {
+ subViews[i]->SetGlobals(globals);
+ }
+ }
+}
+
+void cViewMenu::PreCache(void) {
+ cView::PreCache();
+ for (int i=0; i < numSubviews; i++) {
+ if (subViews[i]) {
+ subViews[i]->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ subViews[i]->PreCache();
+ //setting default viewelements for subviews
+ for (int ve = (int)eVeDisplayMenu::background; ve < (int)eVeDisplayMenu::count; ve++) {
+ if (viewElements[ve] && !subViews[i]->ViewElementSet(ve)) {
+ subViews[i]->SetViewElement((eVeDisplayMenu)ve, viewElements[ve]);
+ }
+ }
+ for (int ve = (int)eVeDisplayMenu::background; ve < (int)eVeDisplayMenu::count; ve++) {
+ if (viewElementsHorizontal[ve] && !subViews[i]->ViewElementHorizontalSet(ve)) {
+ subViews[i]->SetViewElementHorizontal((eVeDisplayMenu)ve, viewElementsHorizontal[ve]);
+ }
+ }
+ }
+ }
+}
+
+void cViewMenu::SetViewElementObjects(void) {
+ //setting subviews
+ for (int i=0; i < numSubviews; i++) {
+ if (!subViews[i])
+ continue;
+ if (i == (int)eSvDisplayMenu::menudefault)
+ menuDefault = dynamic_cast<cViewMenuDefault*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::main)
+ menuMain = dynamic_cast<cViewMenuMain*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::setup)
+ menuSetup = dynamic_cast<cViewMenuSetup*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::schedules)
+ menuSchedules = dynamic_cast<cViewMenuSchedules*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::channels)
+ menuChannels = dynamic_cast<cViewMenuChannels*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::timers)
+ menuTimers = dynamic_cast<cViewMenuTimers*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::recordings)
+ menuRecordings = dynamic_cast<cViewMenuRecordings*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::detailepg)
+ menuDetailedEpg = dynamic_cast<cViewMenuDetail*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::detailrec)
+ menuDetailedRec = dynamic_cast<cViewMenuDetail*>(subViews[i]);
+ else if (i == (int)eSvDisplayMenu::detailtext)
+ menuDetailedText = dynamic_cast<cViewMenuDetail*>(subViews[i]);
+ }
+}
+
+void cViewMenu::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayMenu::background));
+ viewElementNames.insert(pair<string, int>("header", (int)eVeDisplayMenu::header));
+ viewElementNames.insert(pair<string, int>("datetime", (int)eVeDisplayMenu::datetime));
+ viewElementNames.insert(pair<string, int>("time", (int)eVeDisplayMenu::time));
+ viewElementNames.insert(pair<string, int>("colorbuttons", (int)eVeDisplayMenu::colorbuttons));
+ viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayMenu::message));
+ viewElementNames.insert(pair<string, int>("scrollbar", (int)eVeDisplayMenu::scrollbar));
+ viewElementNames.insert(pair<string, int>("sortmode", (int)eVeDisplayMenu::sortmode));
+}
+
+void cViewMenu::SetSubViews(void) {
+ //adding VDR submenus
+ subviewNames.insert(pair<string, int>("menudefault", (int)eSvDisplayMenu::menudefault));
+ subviewNames.insert(pair<string, int>("menumain", (int)eSvDisplayMenu::main));
+ subviewNames.insert(pair<string, int>("menusetup", (int)eSvDisplayMenu::setup));
+ subviewNames.insert(pair<string, int>("menuschedules", (int)eSvDisplayMenu::schedules));
+ subviewNames.insert(pair<string, int>("menuchannels", (int)eSvDisplayMenu::channels));
+ subviewNames.insert(pair<string, int>("menutimers", (int)eSvDisplayMenu::timers));
+ subviewNames.insert(pair<string, int>("menurecordings", (int)eSvDisplayMenu::recordings));
+ subviewNames.insert(pair<string, int>("menudetailedepg", (int)eSvDisplayMenu::detailepg));
+ subviewNames.insert(pair<string, int>("menudetailedrecording", (int)eSvDisplayMenu::detailrec));
+ subviewNames.insert(pair<string, int>("menudetailedtext", (int)eSvDisplayMenu::detailtext));
+ //adding additional plugin subviews
+ int subViewNumber = (int)eSvDisplayMenu::count;
+ map <int,skindesignerapi::sPlugMenu> *plugMenus = NULL;
+ string plugName = "";
+ int plugId = -1;
+ plgManager->InitPluginMenuIterator();
+ while ( plugMenus = plgManager->GetPluginMenus(plugName, plugId) ) {
+ for (map <int,skindesignerapi::sPlugMenu>::iterator it = plugMenus->begin(); it != plugMenus->end(); it++) {
+ int menuNumber = it->first;
+ cString menuName = cString::sprintf("menuplugin-%s-%d", plugName.c_str(), menuNumber);
+ subviewNames.insert(pair<string, int>(*menuName, subViewNumber));
+ plgManager->AddSubviewMapping(plugId, menuNumber, subViewNumber);
+ subViewNumber++;
+ }
+ }
+}
+
+void cViewMenu::ClearVariables(void) {
+ cView::ClearVariables();
+ menuChange = true;
+ listChange = true;
+ detailViewInit = false;
+ menuCat = mcUnknown;
+ pluginIdSet = false;
+ plugId = -1;
+ plugMenuId = -1;
+ activeSubview = NULL;
+ activeSubviewLast = NULL;
+}
+
+int cViewMenu::SubviewId(const char *name) {
+ map<string, int>::iterator hit = subviewNames.find(name);
+ if (hit != subviewNames.end())
+ return (int)hit->second;
+ return ATTR_UNKNOWN;
+}
+
+bool cViewMenu::ValidSubView(const char *subView) {
+ if (SubviewId(subView) != ATTR_UNKNOWN)
+ return true;
+ return false;
+}
+
+cSubView *cViewMenu::CreateSubview(const char *name) {
+ cSubView *sv = NULL;
+ if (!strcmp(name, "menudefault"))
+ sv = new cViewMenuDefault(name);
+ else if (!strcmp(name, "menumain"))
+ sv = new cViewMenuMain(name);
+ else if (!strcmp(name, "menusetup"))
+ sv = new cViewMenuSetup(name);
+ else if (!strcmp(name, "menuschedules"))
+ sv = new cViewMenuSchedules(name);
+ else if (!strcmp(name, "menuchannels"))
+ sv = new cViewMenuChannels(name);
+ else if (!strcmp(name, "menutimers"))
+ sv = new cViewMenuTimers(name);
+ else if (!strcmp(name, "menurecordings"))
+ sv = new cViewMenuRecordings(name);
+ else if (!strcmp(name, "menudetailedepg"))
+ sv = new cViewMenuDetail(name);
+ else if (!strcmp(name, "menudetailedrecording"))
+ sv = new cViewMenuDetail(name);
+ else if (!strcmp(name, "menudetailedtext"))
+ sv = new cViewMenuDetail(name);
+ return sv;
+}
+
+cSubView *cViewMenu::CreatePluginview(const char *plugname, int plugId, int menuNumber, int menuType) {
+ cString menuName = cString::sprintf("menuplugin-%s-%d", plugname, menuNumber);
+ cSubView *pv = NULL;
+ if (menuType == skindesignerapi::mtList)
+ pv = new cViewMenuPlugin(*menuName);
+ else if (menuType == skindesignerapi::mtText)
+ pv = new cViewMenuDetail(*menuName);
+ if (pv) {
+ pv->SetPlugId(plugId);
+ pv->SetPlugMenuId(menuNumber);
+ }
+ return pv;
+}
+
+
+void cViewMenu::AddPluginview(cSubView *plugView) {
+ int id = SubviewId(plugView->GetViewName());
+ if (id == ATTR_UNKNOWN)
+ return;
+ subViews[id] = plugView;
+}
+
+void cViewMenu::AddSubview(const char *sSubView, cSubView *subView) {
+ int id = SubviewId(sSubView);
+ if (id == ATTR_UNKNOWN)
+ return;
+ subViews[id] = subView;
+}
+
+/* eMenuCategory:
+ -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 cViewMenu::SetSubView(eMenuCategory MenuCat) {
+ //menuCat --> old menucat
+ //MenuCat --> new menucat
+ if (menuCat == mcMain) {
+ cViewMenuMain *menuMain = dynamic_cast<cViewMenuMain*>(activeSubview);
+ if (menuMain) {
+ plugName = menuMain->GetPlugin();
+ }
+ }
+ //first check plugin menu
+ if (MenuCat == mcPlugin) {
+ bool plugMenuFound = SetPluginSubView(MenuCat);
+ if (plugMenuFound) {
+ menuCat = MenuCat;
+ return;
+ }
+ }
+ //then check regular menus
+ bool catChange = false;
+ if (menuCat != MenuCat) {
+ catChange = true;
+ } else {
+ return;
+ }
+ cSubView *newSubview = NULL;
+ menuCat = MenuCat;
+ switch (MenuCat) {
+ case mcMain:
+ newSubview = subViews[(int)eSvDisplayMenu::main];
+ break;
+ case mcSchedule:
+ case mcScheduleNow:
+ case mcScheduleNext:
+ newSubview = subViews[(int)eSvDisplayMenu::schedules];
+ break;
+ case mcChannel:
+ newSubview = subViews[(int)eSvDisplayMenu::channels];
+ break;
+ case mcTimer:
+ newSubview = subViews[(int)eSvDisplayMenu::timers];
+ break;
+ case mcRecording:
+ newSubview = subViews[(int)eSvDisplayMenu::recordings];
+ break;
+ case mcSetup:
+ newSubview = subViews[(int)eSvDisplayMenu::setup];
+ break;
+ case mcEvent:
+ newSubview = subViews[(int)eSvDisplayMenu::detailepg];
+ break;
+ case mcRecordingInfo:
+ newSubview = subViews[(int)eSvDisplayMenu::detailrec];
+ break;
+ case mcText:
+ newSubview = subViews[(int)eSvDisplayMenu::detailtext];
+ break;
+ default:
+ newSubview = subViews[(int)eSvDisplayMenu::menudefault];
+ //setting plugin name for detecting plugins in default menus
+ cViewMenuDefault *menuDefault = dynamic_cast<cViewMenuDefault*>(newSubview);
+ if (menuDefault) {
+ menuDefault->SetPlugin(plugName);
+ }
+ break;
+ };
+ if (catChange) {
+ menuChange = true;
+ activeSubview->Clear();
+ activeSubviewLast = activeSubview;
+ activeSubview = newSubview;
+ if (!activeSubview)
+ activeSubview = subViews[(int)eSvDisplayMenu::menudefault];
+ activeSubview->SetMenuCategory(MenuCat);
+ }
+}
+
+bool cViewMenu::SetPluginSubView(eMenuCategory menuCat) {
+ if (!pluginIdSet)
+ return false;
+ cSubView *newSubview = NULL;
+ if (plugId >= 0 && plugMenuId >= 0) {
+ int subViewId = plgManager->GetSubviewId(plugId, plugMenuId);
+ if (subViewId >= 0 && subViews[subViewId]) {
+ newSubview = subViews[subViewId];
+ menuChange = true;
+ activeSubview->Clear();
+ activeSubviewLast = activeSubview;
+ activeSubview = newSubview;
+ activeSubview->SetMenuCategory(menuCat);
+ return true;
+ }
+ }
+ return false;
+}
+
+void cViewMenu::WakeViewElements(void) {
+ cView::WakeViewElements();
+ if (activeSubview)
+ activeSubview->WakeViewElements();
+}
+
+
+void cViewMenu::SetSortMode(eMenuSortMode sortMode) {
+ if (activeSubview)
+ activeSubview->SetSortMode(sortMode);
+}
+
+void cViewMenu::SetPluginMenu(int plugId, int plugMenuId) {
+ this->plugId = plugId;
+ this->plugMenuId = plugMenuId;
+ pluginIdSet = true;
+}
+
+int cViewMenu::NumListItems(void) {
+ return activeSubview->NumListItems();
+}
+
+eMenuOrientation cViewMenu::MenuOrientation(void) {
+ return activeSubview->MenuOrientation();
+}
+
+const cFont *cViewMenu::GetTextAreaFont(void) {
+ return activeSubview->GetTextAreaFont();
+}
+
+int cViewMenu::GetTextAreaWidth(void) {
+ if (!menuDetailedText)
+ return 0;
+ return menuDetailedText->GetWidth();
+}
+
+int cViewMenu::GetListWidth(void) {
+ return activeSubview->GetListWidth();
+}
+
+void cViewMenu::SetTitleHeader(const char *title) {
+ activeSubview->SetTitle(title);
+}
+
+void cViewMenu::SetMessage(eMessageType type, const char *text) {
+ activeSubview->SetMessage(type, text);
+}
+
+void cViewMenu::SetChannelHeader(const cEvent *event) {
+ if (menuChange && menuCat == mcSchedule) {
+ const cChannel *channel = Channels.GetByChannelID(event->ChannelID());
+ if (channel)
+ activeSubview->SetChannel(channel);
+ }
+}
+
+void cViewMenu::SetMenuButtons(const char *red, const char *green, const char *yellow, const char *blue) {
+ activeSubview->SetMenuButtons(red, green, yellow, blue);
+}
+
+void cViewMenu::SetScrollbar(int total, int offset) {
+ activeSubview->SetScrollbar(total, offset);
+}
+
+void cViewMenu::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
+ menuDefault->SetTabs(tab1, tab2, tab3, tab4, tab5);
+}
+
+void cViewMenu::SetItem(const char *text, int index, bool current, bool selectable) {
+ if (menuCat == mcMain && menuMain) {
+ menuMain->SetItem(text, index, current, selectable);
+ } else if (menuCat == mcSetup && menuSetup) {
+ menuSetup->SetItem(text, index, current, selectable);
+ } else {
+ menuDefault->SetItem(text, index, current, selectable);
+ }
+ listChange = true;
+}
+
+bool cViewMenu::SetItemEvent(const cEvent *event, int index, bool current, bool selectable,
+ const cChannel *channel, bool withDate, eTimerMatch timerMatch) {
+ if (!menuSchedules)
+ return false;
+ menuSchedules->SetItem(event, index, current, selectable, channel, withDate, timerMatch);
+ listChange = true;
+ return true;
+}
+
+bool cViewMenu::SetItemTimer(const cTimer *timer, int index, bool current, bool selectable) {
+ if (!menuTimers)
+ return false;
+ menuTimers->SetItem(timer, index, current, selectable);
+ listChange = true;
+ return true;
+}
+
+bool cViewMenu::SetItemChannel(const cChannel *channel, int index, bool current, bool selectable, bool withProvider) {
+ if (!menuChannels)
+ return false;
+ menuChannels->SetItem(channel, index, current, selectable, withProvider);
+ listChange = true;
+ return true;
+}
+
+bool cViewMenu::SetItemRecording(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New) {
+ if (!menuRecordings)
+ return false;
+ menuRecordings->SetItem(recording, index, current, selectable, level, total, New);
+ listChange = true;
+ return true;
+}
+
+bool cViewMenu::SetItemPlugin(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable) {
+ cViewMenuPlugin *menuPlugin = dynamic_cast<cViewMenuPlugin*>(activeSubview);
+ if (!menuPlugin) {
+ return false;
+ }
+ menuPlugin->SetItem(tk, index, current, selectable);
+ listChange = true;
+ return true;
+}
+
+void cViewMenu::SetEvent(const cEvent *event) {
+ menuDetailedEpg->SetEvent(event);
+ detailViewInit = true;
+}
+
+void cViewMenu::SetRecording(const cRecording *recording) {
+ menuDetailedRec->SetRecording(recording);
+ detailViewInit = true;
+}
+
+void cViewMenu::SetText(const char *text) {
+ menuDetailedText->SetText(text);
+ detailViewInit = true;
+}
+
+bool cViewMenu::SetPluginText(skindesignerapi::cTokenContainer *tk) {
+ cViewMenuDetail *menuPlugin = dynamic_cast<cViewMenuDetail*>(activeSubview);
+ if (!menuPlugin) {
+ return false;
+ }
+ menuPlugin->SetPluginText(tk);
+ detailViewInit = true;
+ return true;
+}
+
+void cViewMenu::SetCurrentRecording(const char *currentRec) {
+ if (menuMain) {
+ menuMain->SetCurrentRecording(currentRec); }
+}
+
+void cViewMenu::KeyDetailView(bool up, bool page) {
+ cViewMenuDetail *detailView = dynamic_cast<cViewMenuDetail*>(activeSubview);
+ 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();
+ }
+}
+
+bool cViewMenu::Init(void) {
+ activeSubview = subViews[(int)eSvDisplayMenu::main];
+ return cView::Init();
+}
+
+void cViewMenu::Close(void) {
+ delete fader;
+ fader = NULL;
+ if (FadeTime() > 0) {
+ fader = new cAnimation((cFadable*)this, false);
+ fader->Fade();
+ delete fader;
+ fader = NULL;
+ }
+ for (int i=0; i < numSubviews; i++) {
+ if (subViews[i]) {
+ subViews[i]->Close();
+ }
+ }
+ for (int i=0; i < numViewElements; i++) {
+ if (viewElements[i]) {
+ viewElements[i]->Close();
+ }
+ if (viewElementsHorizontal[i]) {
+ viewElementsHorizontal[i]->Close();
+ }
+ }
+ UnScaleTv();
+ ClearVariables();
+ sdOsd.DeleteOsd();
+}
+
+void cViewMenu::Clear(void) {
+ activeSubview->ClearViewList();
+}
+
+void cViewMenu::Flush(void) {
+ if (init) {
+ sdOsd.LockFlush();
+ }
+ bool staticInitiated = false;
+ if (menuChange) {
+ newTvFrame = activeSubview->GetTvFrame();
+ menuInit = true;
+ activeSubview->DrawStaticVEs();
+ pluginIdSet = false;
+ menuChange = false;
+ staticInitiated = true;
+ }
+ if (listChange) {
+ activeSubview->DrawList();
+ listChange = false;
+ }
+ if (detailViewInit) {
+ if (!staticInitiated)
+ activeSubview->DrawStaticVEs();
+ activeSubview->DrawDetailedView();
+ pluginIdSet = false;
+ detailViewInit = false;
+ }
+ activeSubview->DrawDynamicVEs();
+ cView::Flush();
+}
+
+void cViewMenu::SetTransparency(int transparency, bool forceDetached) {
+ activeSubview->SetTransparency(transparency, forceDetached);
+ if (menuDetailedEpg)
+ menuDetailedEpg->SetTransparency(transparency);
+ if (menuDetailedRec)
+ menuDetailedRec->SetTransparency(transparency);
+ if (menuDetailedText)
+ menuDetailedText->SetTransparency(transparency);
+}
+
+void cViewMenu::Debug(void) {
+ cView::Debug();
+ for (int i=0; i < numSubviews; i++) {
+ if (subViews[i]) {
+ subViews[i]->Debug();
+ }
+ }
+}
+
+/***********************************************************
+* cSubView
+***********************************************************/
+cSubView::cSubView(const char *name) {
+ menuCat = mcUnknown;
+ plugId = -1;
+ plugMenuId = -1;
+ this->viewName = strdup(name);
+ numViewElements = (int)eVeDisplayMenu::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ viewElementsHorizontal = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElementsHorizontal[i] = NULL;
+ }
+ background = NULL;
+ header = NULL;
+ datetime = NULL;
+ time = NULL;
+ message = NULL;
+ sortmode = NULL;
+ colorbuttons = NULL;
+ scrollbar = NULL;
+ viewList = NULL;
+ viewListVertical = NULL;
+ viewListHorizontal = NULL;
+ SetViewElements();
+}
+
+cSubView::~cSubView(void) {
+ delete viewListHorizontal;
+ delete viewListVertical;
+}
+
+void cSubView::SetGlobals(cGlobals *globals) {
+ cView::SetGlobals(globals);
+ if (viewListVertical)
+ viewListVertical->SetGlobals(globals);
+ if (viewListHorizontal)
+ viewListHorizontal->SetGlobals(globals);
+}
+
+void cSubView::PreCache(void) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Cache();
+ cView::PreCache();
+ if (viewListVertical) {
+ viewListVertical->SetPlugId(plugId);
+ viewListVertical->SetPlugMenuId(plugMenuId);
+ viewListVertical->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ viewListVertical->PreCache();
+ }
+ if (viewListHorizontal) {
+ viewListHorizontal->SetPlugId(plugId);
+ viewListHorizontal->SetPlugMenuId(plugMenuId);
+ viewListHorizontal->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ viewListHorizontal->PreCache();
+ }
+}
+
+bool cSubView::ViewElementSet(int ve) {
+ if (ve >= 0 && ve < (int)eVeDisplayMenu::count && viewElements[ve])
+ return true;
+ return false;
+}
+
+bool cSubView::ViewElementHorizontalSet(int ve) {
+ if (ve >= 0 && ve < (int)eVeDisplayMenu::count && viewElementsHorizontal[ve])
+ return true;
+ return false;
+}
+
+void cSubView::SetViewElement(eVeDisplayMenu ve, cViewElement *viewElement) {
+ switch (ve) {
+ case eVeDisplayMenu::background:
+ if (!background)
+ background = viewElement;
+ break;
+ case eVeDisplayMenu::header:
+ if (!header)
+ header = dynamic_cast<cVeDmHeader*>(viewElement);
+ break;
+ case eVeDisplayMenu::datetime:
+ if (!datetime)
+ datetime = dynamic_cast<cVeDateTime*>(viewElement);
+ break;
+ case eVeDisplayMenu::time:
+ if (!time)
+ time = dynamic_cast<cVeTime*>(viewElement);
+ break;
+ case eVeDisplayMenu::message:
+ if (!message)
+ message = dynamic_cast<cVeMessage*>(viewElement);
+ break;
+ case eVeDisplayMenu::sortmode:
+ if (!sortmode)
+ sortmode = dynamic_cast<cVeDmSortmode*>(viewElement);
+ break;
+ case eVeDisplayMenu::colorbuttons:
+ if (!colorbuttons)
+ colorbuttons = dynamic_cast<cVeDmColorbuttons*>(viewElement);
+ break;
+ case eVeDisplayMenu::scrollbar:
+ if (!scrollbar)
+ scrollbar = dynamic_cast<cVeDmScrollbar*>(viewElement);
+ break;
+ default:
+ break;
+ };
+}
+
+void cSubView::SetViewElementHorizontal(eVeDisplayMenu ve, cViewElement *viewElement) {
+ eOrientation orientation = attribs->Orientation();
+ if (orientation != eOrientation::horizontal)
+ return;
+ switch (ve) {
+ case eVeDisplayMenu::background:
+ if (!background)
+ background = viewElement;
+ break;
+ case eVeDisplayMenu::header:
+ if (!header)
+ header = dynamic_cast<cVeDmHeader*>(viewElement);
+ break;
+ case eVeDisplayMenu::datetime:
+ if (!datetime)
+ datetime = dynamic_cast<cVeDateTime*>(viewElement);
+ break;
+ case eVeDisplayMenu::time:
+ if (!time)
+ time = dynamic_cast<cVeTime*>(viewElement);
+ break;
+ case eVeDisplayMenu::message:
+ if (!message)
+ message = dynamic_cast<cVeMessage*>(viewElement);
+ break;
+ case eVeDisplayMenu::sortmode:
+ if (!sortmode)
+ sortmode = dynamic_cast<cVeDmSortmode*>(viewElement);
+ break;
+ case eVeDisplayMenu::colorbuttons:
+ if (!colorbuttons)
+ colorbuttons = dynamic_cast<cVeDmColorbuttons*>(viewElement);
+ break;
+ case eVeDisplayMenu::scrollbar:
+ if (!scrollbar)
+ scrollbar = dynamic_cast<cVeDmScrollbar*>(viewElement);
+ break;
+ default:
+ break;
+ };
+}
+
+void cSubView::AddViewList(cViewList *viewList) {
+ eOrientation orientation = viewList->Orientation();
+ if (orientation == eOrientation::vertical) {
+ viewListVertical = viewList;
+ } else if (orientation == eOrientation::horizontal) {
+ viewListHorizontal = viewList;
+ } else {
+ viewListVertical = viewList;
+ }
+}
+
+int cSubView::NumListItems(void) {
+ if (viewList)
+ return viewList->NumItems();
+ return 0;
+}
+
+eMenuOrientation cSubView::MenuOrientation(void) {
+ eOrientation orientation = attribs->Orientation();
+ if (orientation == eOrientation::horizontal)
+ return moHorizontal;
+ return moVertical;
+}
+
+void cSubView::SetTitle(const char *title) {
+ if (header) {
+ header->SetTitle(title);
+ }
+}
+
+void cSubView::SetChannel(const cChannel *channel) {
+ if (header) {
+ header->SetChannel(channel);
+ }
+}
+
+void cSubView::SetMessage(eMessageType type, const char *text) {
+ if (!message)
+ return;
+ if (!text) {
+ message->Clear();
+ message->Hide();
+ return;
+ }
+ message->Set(type, text);
+ message->Show();
+ if (message->Parse())
+ message->Render();
+}
+
+void cSubView::SetMenuButtons(const char *red, const char *green, const char *yellow, const char *blue) {
+ if (!colorbuttons)
+ return;
+ colorbuttons->SetButtons(red, green, yellow, blue);
+ if (colorbuttons->Parse()) {
+ colorbuttons->Show();
+ colorbuttons->Render();
+ }
+}
+
+void cSubView::SetScrollbar(int total, int offset) {
+ if (!scrollbar)
+ return;
+ scrollbar->SetList(total, offset, NumListItems());
+ if (scrollbar->Parse()) {
+ scrollbar->Show();
+ scrollbar->Render();
+ }
+}
+
+void cSubView::SetSortMode(eMenuSortMode sortMode) {
+ if (!sortmode)
+ return;
+ sortmode->Set(sortMode);
+ if (sortmode->Parse()) {
+ sortmode->Show();
+ sortmode->Render();
+ }
+}
+
+void cSubView::Close(void) {
+ ClearVariables();
+ for (int i=0; i < numViewElements; i++) {
+ if (!viewElements[i])
+ continue;
+ viewElements[i]->Close();
+ }
+ for (int i=0; i < numViewElements; i++) {
+ if (!viewElementsHorizontal[i])
+ continue;
+ viewElementsHorizontal[i]->Close();
+ }
+ if (viewList)
+ viewList->Close();
+}
+
+void cSubView::ClearViewList(void) {
+ if (viewList)
+ viewList->Clear();
+}
+
+void cSubView::WakeViewElements(void) {
+ for (int i = 0; i < numViewElements; i++) {
+ if (viewElements[i]) {
+ viewElements[i]->WakeUp();
+ }
+ if (viewElementsHorizontal[i]) {
+ viewElementsHorizontal[i]->WakeUp();
+ }
+ }
+}
+
+void cSubView::Clear(void) {
+ if (background) background->Hide();
+ if (datetime) datetime->Hide();
+ if (time) time->Hide();
+ if (header) header->Hide();
+ if (colorbuttons) colorbuttons->Hide();
+ if (scrollbar) scrollbar->Hide();
+ if (sortmode) {
+ sortmode->Reset();
+ sortmode->Hide();
+ }
+
+ if (viewList) viewList->Close();
+}
+
+void cSubView::DrawStaticVEs(void) {
+ if (background) {
+ background->Show();
+ background->Render();
+ }
+ if (header) {
+ header->Show();
+ header->Set(menuCat);
+ if (header->Parse())
+ header->Render();
+ }
+}
+
+void cSubView::DrawDynamicVEs(void) {
+ if (datetime) {
+ datetime->Show();
+ if (datetime->Parse())
+ datetime->Render();
+ }
+ if (time) {
+ time->Show();
+ if (time->Parse()) {
+ time->Render();
+ }
+ }
+}
+
+void cSubView::DrawList(void) {
+ if (viewList) {
+ viewList->Draw(menuCat);
+ }
+}
+
+void cSubView::SetTransparency(int transparency, bool forceDetached) {
+ for (int i = 0; i < numViewElements; i++) {
+ if (viewElements[i] && (!viewElements[i]->Detached() || forceDetached)) {
+ viewElements[i]->SetTransparency(transparency);
+ }
+ if (viewElementsHorizontal[i] && (!viewElementsHorizontal[i]->Detached() || forceDetached)) {
+ viewElementsHorizontal[i]->SetTransparency(transparency);
+ }
+ }
+ if (viewList)
+ viewList->SetTransparency(transparency);
+}
+/***********************************************************
+* Protected Functions
+***********************************************************/
+void cSubView::SetViewElementObjects(void) {
+ eOrientation orientation = attribs->Orientation();
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::background])
+ background = viewElementsHorizontal[(int)eVeDisplayMenu::background];
+ else if (viewElements[(int)eVeDisplayMenu::background])
+ background = viewElements[(int)eVeDisplayMenu::background];
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::header])
+ header = dynamic_cast<cVeDmHeader*>(viewElementsHorizontal[(int)eVeDisplayMenu::header]);
+ else if (viewElements[(int)eVeDisplayMenu::header])
+ header = dynamic_cast<cVeDmHeader*>(viewElements[(int)eVeDisplayMenu::header]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::datetime])
+ datetime = dynamic_cast<cVeDateTime*>(viewElementsHorizontal[(int)eVeDisplayMenu::datetime]);
+ else if (viewElements[(int)eVeDisplayMenu::datetime])
+ datetime = dynamic_cast<cVeDateTime*>(viewElements[(int)eVeDisplayMenu::datetime]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::time])
+ time = dynamic_cast<cVeTime*>(viewElementsHorizontal[(int)eVeDisplayMenu::time]);
+ else if (viewElements[(int)eVeDisplayMenu::time])
+ time = dynamic_cast<cVeTime*>(viewElements[(int)eVeDisplayMenu::time]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::message])
+ message = dynamic_cast<cVeMessage*>(viewElementsHorizontal[(int)eVeDisplayMenu::message]);
+ else if (viewElements[(int)eVeDisplayMenu::message])
+ message = dynamic_cast<cVeMessage*>(viewElements[(int)eVeDisplayMenu::message]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::sortmode])
+ sortmode = dynamic_cast<cVeDmSortmode*>(viewElementsHorizontal[(int)eVeDisplayMenu::sortmode]);
+ else if (viewElements[(int)eVeDisplayMenu::sortmode])
+ sortmode = dynamic_cast<cVeDmSortmode*>(viewElements[(int)eVeDisplayMenu::sortmode]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::colorbuttons])
+ colorbuttons = dynamic_cast<cVeDmColorbuttons*>(viewElementsHorizontal[(int)eVeDisplayMenu::colorbuttons]);
+ else if (viewElements[(int)eVeDisplayMenu::colorbuttons])
+ colorbuttons = dynamic_cast<cVeDmColorbuttons*>(viewElements[(int)eVeDisplayMenu::colorbuttons]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenu::scrollbar])
+ scrollbar = dynamic_cast<cVeDmScrollbar*>(viewElementsHorizontal[(int)eVeDisplayMenu::scrollbar]);
+ else if (viewElements[(int)eVeDisplayMenu::scrollbar])
+ scrollbar = dynamic_cast<cVeDmScrollbar*>(viewElements[(int)eVeDisplayMenu::scrollbar]);
+
+
+ if (attribs->Orientation() == eOrientation::horizontal)
+ viewList = viewListHorizontal;
+ else
+ viewList = viewListVertical;
+}
+
+void cSubView::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayMenu::background));
+ viewElementNames.insert(pair<string, int>("header", (int)eVeDisplayMenu::header));
+ viewElementNames.insert(pair<string, int>("datetime", (int)eVeDisplayMenu::datetime));
+ viewElementNames.insert(pair<string, int>("time", (int)eVeDisplayMenu::time));
+ viewElementNames.insert(pair<string, int>("colorbuttons", (int)eVeDisplayMenu::colorbuttons));
+ viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayMenu::message));
+ viewElementNames.insert(pair<string, int>("scrollbar", (int)eVeDisplayMenu::scrollbar));
+ viewElementNames.insert(pair<string, int>("sortmode", (int)eVeDisplayMenu::sortmode));
+}
+
+/***********************************************************
+* cViewMenuDefault
+***********************************************************/
+cViewMenuDefault::cViewMenuDefault(const char *name) : cSubView(name) {
+ listDefault = NULL;
+}
+
+cViewMenuDefault::~cViewMenuDefault(void) {
+}
+
+void cViewMenuDefault::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ listDefault = dynamic_cast<cViewListDefault*>(viewList);
+}
+
+void cViewMenuDefault::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
+ if (listDefault)
+ listDefault->SetTabs(tab1, tab2, tab3, tab4, tab5);
+}
+
+void cViewMenuDefault::SetPlugin(const char *plugName) {
+ listDefault->SetPlugin(plugName);
+}
+
+void cViewMenuDefault::SetItem(const char *text, int index, bool current, bool selectable) {
+ listDefault->Set(text, index, current, selectable);
+}
+
+const cFont *cViewMenuDefault::GetTextAreaFont(void) {
+ if (!listDefault)
+ return NULL;
+ return listDefault->GetListFont();
+}
+
+int cViewMenuDefault::GetListWidth(void) {
+ if (!listDefault)
+ return 0;
+ return listDefault->GetListWidth();
+}
+
+/************************************************************************************
+* cViewMenuMain
+************************************************************************************/
+cViewMenuMain::cViewMenuMain(const char *name) : cSubView(name) {
+ for (int i=0; i < numViewElements; i++) {
+ delete viewElements[i];
+ }
+ delete[] viewElements;
+ numViewElements = (int)eVeDisplayMenuMain::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ delete[] viewElementsHorizontal;
+ viewElementsHorizontal = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElementsHorizontal[i] = NULL;
+ }
+ listMain = NULL;
+ timers = NULL;
+ devices = NULL;
+ weather = NULL;
+ discusage = NULL;
+ load = NULL;
+ memory = NULL;
+ vdrstats = NULL;
+ temperatures = NULL;
+ currentSchedule = NULL;
+ lastRecordings = NULL;
+ customTokens = NULL;
+ lastDrawDynamic = 0;
+ SetViewElements();
+}
+
+cViewMenuMain::~cViewMenuMain() {
+}
+
+void cViewMenuMain::ClearVariables(void) {
+ init = true;
+}
+
+void cViewMenuMain::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("timers", (int)eVeDisplayMenuMain::timers));
+ viewElementNames.insert(pair<string, int>("devices", (int)eVeDisplayMenuMain::devices));
+ viewElementNames.insert(pair<string, int>("currentweather", (int)eVeDisplayMenuMain::currentweather));
+ viewElementNames.insert(pair<string, int>("currentschedule", (int)eVeDisplayMenuMain::currentschedule));
+ viewElementNames.insert(pair<string, int>("discusage", (int)eVeDisplayMenuMain::discusage));
+ viewElementNames.insert(pair<string, int>("systemload", (int)eVeDisplayMenuMain::systemload));
+ viewElementNames.insert(pair<string, int>("systemmemory", (int)eVeDisplayMenuMain::systemmemory));
+ viewElementNames.insert(pair<string, int>("vdrstatistics", (int)eVeDisplayMenuMain::vdrstatistics));
+ viewElementNames.insert(pair<string, int>("temperatures", (int)eVeDisplayMenuMain::temperatures));
+ viewElementNames.insert(pair<string, int>("lastrecordings", (int)eVeDisplayMenuMain::lastrecordings));
+ viewElementNames.insert(pair<string, int>("customtokens", (int)eVeDisplayMenuMain::customtokens));
+}
+
+void cViewMenuMain::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ eOrientation orientation = attribs->Orientation();
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::timers])
+ timers = dynamic_cast<cVeDmTimers*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::timers]);
+ else if (viewElements[(int)eVeDisplayMenuMain::timers])
+ timers = dynamic_cast<cVeDmTimers*>(viewElements[(int)eVeDisplayMenuMain::timers]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::devices])
+ devices = dynamic_cast<cVeDevices*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::devices]);
+ else if (viewElements[(int)eVeDisplayMenuMain::devices])
+ devices = dynamic_cast<cVeDevices*>(viewElements[(int)eVeDisplayMenuMain::devices]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::currentweather])
+ weather = dynamic_cast<cVeCurrentWeather*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::currentweather]);
+ else if (viewElements[(int)eVeDisplayMenuMain::currentweather])
+ weather = dynamic_cast<cVeCurrentWeather*>(viewElements[(int)eVeDisplayMenuMain::currentweather]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::currentschedule])
+ currentSchedule = dynamic_cast<cVeDmCurrentschedule*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::currentschedule]);
+ else if (viewElements[(int)eVeDisplayMenuMain::currentschedule])
+ currentSchedule = dynamic_cast<cVeDmCurrentschedule*>(viewElements[(int)eVeDisplayMenuMain::currentschedule]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::discusage])
+ discusage = dynamic_cast<cVeDmDiscusage*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::discusage]);
+ else if (viewElements[(int)eVeDisplayMenuMain::discusage])
+ discusage = dynamic_cast<cVeDmDiscusage*>(viewElements[(int)eVeDisplayMenuMain::discusage]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::systemload])
+ load = dynamic_cast<cVeDmSystemload*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::systemload]);
+ else if (viewElements[(int)eVeDisplayMenuMain::systemload])
+ load = dynamic_cast<cVeDmSystemload*>(viewElements[(int)eVeDisplayMenuMain::systemload]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::systemmemory])
+ memory = dynamic_cast<cVeDmSystemmemory*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::systemmemory]);
+ else if (viewElements[(int)eVeDisplayMenuMain::systemmemory])
+ memory = dynamic_cast<cVeDmSystemmemory*>(viewElements[(int)eVeDisplayMenuMain::systemmemory]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::vdrstatistics])
+ vdrstats = dynamic_cast<cVeDmVdrstatistics*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::vdrstatistics]);
+ else if (viewElements[(int)eVeDisplayMenuMain::vdrstatistics])
+ vdrstats = dynamic_cast<cVeDmVdrstatistics*>(viewElements[(int)eVeDisplayMenuMain::vdrstatistics]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::temperatures])
+ temperatures = dynamic_cast<cVeDmTemperatures*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::temperatures]);
+ else if (viewElements[(int)eVeDisplayMenuMain::temperatures])
+ temperatures = dynamic_cast<cVeDmTemperatures*>(viewElements[(int)eVeDisplayMenuMain::temperatures]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::lastrecordings])
+ lastRecordings = dynamic_cast<cVeDmLastrecordings*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::lastrecordings]);
+ else if (viewElements[(int)eVeDisplayMenuMain::lastrecordings])
+ lastRecordings = dynamic_cast<cVeDmLastrecordings*>(viewElements[(int)eVeDisplayMenuMain::lastrecordings]);
+
+ if (orientation == eOrientation::horizontal && viewElementsHorizontal[(int)eVeDisplayMenuMain::customtokens])
+ customTokens = dynamic_cast<cVeCustomTokens*>(viewElementsHorizontal[(int)eVeDisplayMenuMain::customtokens]);
+ else if (viewElements[(int)eVeDisplayMenuMain::customtokens])
+ customTokens = dynamic_cast<cVeCustomTokens*>(viewElements[(int)eVeDisplayMenuMain::customtokens]);
+
+ if (devices) devices->SetDetached();
+ if (weather) weather->SetDetached();
+ if (discusage) discusage->SetDetached();
+ if (load) load->SetDetached();
+ if (memory) memory->SetDetached();
+ if (vdrstats) vdrstats->SetDetached();
+ if (temperatures) temperatures->SetDetached();
+ if (timers) timers->SetDetached();
+ if (currentSchedule) currentSchedule->SetDetached();
+ if (lastRecordings) lastRecordings->SetDetached();
+ if (customTokens) customTokens->SetDetached();
+
+ listMain = dynamic_cast<cViewListMain*>(viewList);
+}
+
+void cViewMenuMain::Clear(void) {
+ cSubView::Clear();
+ lastDrawDynamic = 0;
+
+ if (devices)
+ devices->Hide();
+
+ if (weather)
+ weather->Hide();
+
+ if (discusage)
+ discusage->Hide();
+
+ if (load) {
+ load->Reset();
+ load->Hide();
+ }
+
+ if (memory) {
+ memory->Reset();
+ memory->Hide();
+ }
+
+ if (vdrstats) {
+ vdrstats->Reset();
+ vdrstats->Hide();
+ }
+
+ if (temperatures) {
+ temperatures->Reset();
+ temperatures->Hide();
+ }
+
+ if (timers) {
+ timers->Hide();
+ }
+
+ if (currentSchedule) {
+ currentSchedule->Hide();
+ }
+
+ if (lastRecordings) {
+ lastRecordings->Hide();
+ }
+
+ if (customTokens) {
+ customTokens->Reset();
+ customTokens->Hide();
+ }
+}
+
+void cViewMenuMain::SetItem(const char *text, int index, bool current, bool selectable) {
+ listMain->Set(text, index, current, selectable);
+}
+
+void cViewMenuMain::SetCurrentRecording(const char *currentRec) {
+ if (currentSchedule)
+ currentSchedule->SetRecording(currentRec);
+}
+
+void cViewMenuMain::DrawStaticVEs(void) {
+ cSubView::DrawStaticVEs();
+ if (weather) {
+ weather->Show();
+ if (weather->Parse())
+ weather->Render();
+ }
+ if (discusage) {
+ discusage->Show();
+ if (discusage->Parse())
+ discusage->Render();
+ }
+ if (timers) {
+ timers->Show();
+ if (timers->Parse())
+ timers->Render();
+ }
+ if (currentSchedule) {
+ currentSchedule->Show();
+ if (currentSchedule->Parse())
+ currentSchedule->Render();
+ }
+ if (lastRecordings) {
+ lastRecordings->Show();
+ if (lastRecordings->Parse())
+ lastRecordings->Render();
+ }
+}
+
+void cViewMenuMain::DrawDynamicVEs(void) {
+ cSubView::DrawDynamicVEs();
+ //draw main menu dynamic elements
+ //only every 3 seconds
+ uint64_t now = cTimeMs::Now();
+ if (now - lastDrawDynamic < 3000)
+ return;
+ else {
+ lastDrawDynamic = now;
+ }
+
+ if (devices) {
+ devices->Show();
+ if (devices->Parse())
+ devices->Render();
+ }
+ if (load) {
+ load->Show();
+ if (load->Parse())
+ load->Render();
+ }
+ if (memory) {
+ memory->Show();
+ if (memory->Parse())
+ memory->Render();
+ }
+ if (vdrstats) {
+ vdrstats->Show();
+ if (vdrstats->Parse())
+ vdrstats->Render();
+ }
+ if (temperatures) {
+ temperatures->Show();
+ if (temperatures->Parse())
+ temperatures->Render();
+ }
+ if (customTokens) {
+ customTokens->Show();
+ if (customTokens->Parse())
+ customTokens->Render();
+ }
+}
+
+const char *cViewMenuMain::GetPlugin(void) {
+ return listMain->GetPlugin();
+}
+
+/***********************************************************
+* cViewMenuSetup
+***********************************************************/
+cViewMenuSetup::cViewMenuSetup(const char *name) : cSubView(name) {
+ listSetup = NULL;
+}
+
+cViewMenuSetup::~cViewMenuSetup(void) {
+
+}
+
+void cViewMenuSetup::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ listSetup = dynamic_cast<cViewListMain*>(viewList);
+}
+
+void cViewMenuSetup::SetItem(const char *text, int index, bool current, bool selectable) {
+ listSetup->Set(text, index, current, selectable);
+}
+
+/***********************************************************
+* cViewMenuSchedules
+***********************************************************/
+cViewMenuSchedules::cViewMenuSchedules(const char *name) : cSubView(name) {
+ listSchedules = NULL;
+}
+
+cViewMenuSchedules::~cViewMenuSchedules(void) {
+}
+
+void cViewMenuSchedules::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ listSchedules = dynamic_cast<cViewListSchedules*>(viewList);
+}
+
+void cViewMenuSchedules::SetItem(const cEvent *event, int index, bool current, bool selectable,
+ const cChannel *channel, bool withDate, eTimerMatch timerMatch) {
+
+ bool epgSearchFavMenu = (menuCat == mcSchedule && channel) ? true : false;
+ listSchedules->IsEpgSearchFav(epgSearchFavMenu);
+ if (header) header->IsEpgSearchFav(epgSearchFavMenu);
+ listSchedules->Set(event, index, current, selectable, channel, withDate, timerMatch);
+}
+
+/***********************************************************
+* cViewMenuChannels
+***********************************************************/
+cViewMenuChannels::cViewMenuChannels(const char *name) : cSubView(name) {
+ listChannels = NULL;
+}
+
+cViewMenuChannels::~cViewMenuChannels(void) {
+}
+
+void cViewMenuChannels::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ listChannels = dynamic_cast<cViewListChannels*>(viewList);
+}
+
+void cViewMenuChannels::SetItem(const cChannel *channel, int index, bool current, bool selectable, bool withProvider) {
+ listChannels->Set(channel, index, current, selectable, withProvider);
+}
+
+/***********************************************************
+* cViewMenuTimers
+***********************************************************/
+cViewMenuTimers::cViewMenuTimers(const char *name) : cSubView(name) {
+ listTimers = NULL;
+}
+
+cViewMenuTimers::~cViewMenuTimers(void) {
+}
+
+void cViewMenuTimers::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ listTimers = dynamic_cast<cViewListTimers*>(viewList);
+}
+
+void cViewMenuTimers::SetItem(const cTimer *timer, int index, bool current, bool selectable) {
+ listTimers->Set(timer, index, current, selectable);
+}
+
+/***********************************************************
+* cViewMenuRecordings
+***********************************************************/
+cViewMenuRecordings::cViewMenuRecordings(const char *name) : cSubView(name) {
+ listRecordings = NULL;
+}
+
+cViewMenuRecordings::~cViewMenuRecordings(void) {
+}
+
+void cViewMenuRecordings::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ listRecordings = dynamic_cast<cViewListRecordings*>(viewList);
+}
+
+void cViewMenuRecordings::SetItem(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New) {
+ listRecordings->Set(recording, index, current, selectable, level, total, New);
+}
+
+/***********************************************************
+* cViewMenuPlugin
+***********************************************************/
+cViewMenuPlugin::cViewMenuPlugin(const char *name) : cSubView(name) {
+ listPlugin = NULL;
+}
+
+cViewMenuPlugin::~cViewMenuPlugin(void) {
+}
+
+void cViewMenuPlugin::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ listPlugin = dynamic_cast<cViewListPlugin*>(viewList);
+}
+
+void cViewMenuPlugin::SetItem(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable) {
+ listPlugin->Set(tk, index, current, selectable);
+}
+
+/***********************************************************
+* cViewMenuDetail
+***********************************************************/
+cViewMenuDetail::cViewMenuDetail(const char *name) : cSubView(name) {
+ firstTab = true;
+ for (int i=0; i < numViewElements; i++) {
+ delete viewElements[i];
+ }
+ delete[] viewElements;
+ numViewElements = (int)eVeDisplayDetailedMenu::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ delete[] viewElementsHorizontal;
+ viewElementsHorizontal = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElementsHorizontal[i] = NULL;
+ }
+ SetViewElements();
+ detailedheaderEpg = NULL;
+ detailedheaderRec = NULL;
+ detailedheaderPlug = NULL;
+ tablabels = NULL;
+ detailViewEpg = NULL;
+ detailViewRec = NULL;
+ detailViewText = NULL;
+ detailViewPlugin = NULL;
+ SetDetailedView();
+}
+
+cViewMenuDetail::~cViewMenuDetail(void) {
+}
+
+void cViewMenuDetail::SetDetailedView(void) {
+ if (!strcmp(viewName, "menudetailedepg")) {
+ detailViewEpg = new cViewDetailEpg();
+ detailView = detailViewEpg;
+ } else if (!strcmp(viewName, "menudetailedrecording")) {
+ detailViewRec = new cViewDetailRec();
+ detailView = detailViewRec;
+ } else if (!strcmp(viewName, "menudetailedtext")) {
+ detailViewText = new cViewDetailText();
+ detailView = detailViewText;
+ } else if (startswith(viewName, "menuplugin")) {
+ detailViewPlugin = new cViewDetailPlugin();
+ detailView = detailViewPlugin;
+ } else {
+ esyslog("skindesigner: invalid detailedview %s", viewName);
+ }
+ if (detailView) {
+ detailView->SetOsd(&sdOsd);
+ }
+}
+
+void cViewMenuDetail::AddTab(cArea *tab) {
+ if (firstTab) {
+ tab->SetActiveTab(true);
+ firstTab = false;
+ }
+ detailView->AddArea(tab);
+}
+
+void cViewMenuDetail::SetGlobals(cGlobals *globals) {
+ cView::SetGlobals(globals);
+ detailView->SetGlobals(globals);
+}
+
+void cViewMenuDetail::PreCache(void) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Cache();
+ if (plugId >= 0 && plugMenuId >= 0) {
+ cVeDmDetailheaderPlugin *dhPlug = dynamic_cast<cVeDmDetailheaderPlugin*>(viewElements[(int)eVeDisplayDetailedMenu::detailheader]);
+ dhPlug->SetPlugId(plugId);
+ dhPlug->SetPlugMenuId(plugMenuId);
+ dhPlug->SetTokenContainer();
+ }
+ cView::PreCache();
+ detailView->SetPlugId(plugId);
+ detailView->SetPlugMenuId(plugMenuId);
+ detailView->SetTokenContainer();
+ detailView->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ detailView->Cache();
+}
+
+int cViewMenuDetail::GetWidth(void) {
+ return detailView->GetWidth();
+}
+
+void cViewMenuDetail::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("detailheader", (int)eVeDisplayDetailedMenu::detailheader));
+ viewElementNames.insert(pair<string, int>("tablabels", (int)eVeDisplayDetailedMenu::tablabels));
+}
+
+void cViewMenuDetail::SetViewElementObjects(void) {
+ cSubView::SetViewElementObjects();
+ if (viewElements[(int)eVeDisplayDetailedMenu::detailheader]) {
+ if (!strcmp(viewName, "menudetailedepg"))
+ detailedheaderEpg = dynamic_cast<cVeDmDetailheaderEpg*>(viewElements[(int)eVeDisplayDetailedMenu::detailheader]);
+ else if (!strcmp(viewName, "menudetailedrecording"))
+ detailedheaderRec = dynamic_cast<cVeDmDetailheaderRec*>(viewElements[(int)eVeDisplayDetailedMenu::detailheader]);
+ else if (startswith(viewName, "menuplugin"))
+ detailedheaderPlug = dynamic_cast<cVeDmDetailheaderPlugin*>(viewElements[(int)eVeDisplayDetailedMenu::detailheader]);
+ }
+
+ if (viewElements[(int)eVeDisplayDetailedMenu::tablabels])
+ tablabels = dynamic_cast<cVeDmTablabels*>(viewElements[(int)eVeDisplayDetailedMenu::tablabels]);
+}
+
+void cViewMenuDetail::SetEvent(const cEvent *event) {
+ if (detailedheaderEpg)
+ detailedheaderEpg->SetEvent(event);
+ if (detailViewEpg)
+ detailViewEpg->SetEvent(event);
+}
+
+void cViewMenuDetail::SetRecording(const cRecording *recording) {
+ if (detailedheaderRec)
+ detailedheaderRec->SetRecording(recording);
+ if (detailViewRec)
+ detailViewRec->SetRecording(recording);
+}
+
+void cViewMenuDetail::SetText(const char *text) {
+ if (detailViewText)
+ detailViewText->SetText(text);
+}
+
+void cViewMenuDetail::SetPluginText(skindesignerapi::cTokenContainer *tk) {
+ if (detailedheaderPlug)
+ detailedheaderPlug->Set(tk);
+ if (detailViewPlugin)
+ detailViewPlugin->Set(tk);
+}
+
+void cViewMenuDetail::Clear(void) {
+ cSubView::Close();
+ if (detailedheaderEpg) {
+ detailedheaderEpg->Close();
+ } else if (detailedheaderRec) {
+ detailedheaderRec->Close();
+ } else if (detailedheaderPlug) {
+ detailedheaderPlug->Close();
+ }
+ if (header) {
+ header->Hide();
+ }
+ if (detailView) {
+ detailView->Close();
+ }
+}
+
+void cViewMenuDetail::Close(void) {
+ cSubView::Close();
+ if (detailView) {
+ detailView->Close();
+ }
+}
+
+void cViewMenuDetail::DrawStaticVEs(void) {
+ cSubView::DrawStaticVEs();
+ if (detailedheaderEpg && detailedheaderEpg->Parse()) {
+ detailedheaderEpg->Render();
+ } else if (detailedheaderRec && detailedheaderRec->Parse()) {
+ detailedheaderRec->Render();
+ } else if (detailedheaderPlug && detailedheaderPlug->Parse()) {
+ detailedheaderPlug->Render();
+ }
+}
+
+void cViewMenuDetail::DrawDynamicVEs(void) {
+ if (datetime) {
+ datetime->Show();
+ if (datetime->Parse())
+ datetime->Render();
+ }
+ if (time) {
+ time->Show();
+ if (time->Parse())
+ time->Render();
+ }
+}
+
+void cViewMenuDetail::DrawDetailedView(void) {
+ detailView->Clear();
+ detailView->ResetTabs();
+ if (detailView->Parse()) {
+ detailView->Render();
+ }
+ if (scrollbar) {
+ scrollbar->Show();
+ DrawScrollbar();
+ }
+ vector<const char*> tabs;
+ int activeTab = detailView->GetTabs(tabs);
+ if (tablabels) {
+ tablabels->SetTabs(tabs);
+ tablabels->SetActiveTab(activeTab);
+ if (tablabels->Parse())
+ tablabels->Render();
+ }
+}
+
+void cViewMenuDetail::KeyLeft(void) {
+ if (detailView->NumTabs() > 1) {
+ detailView->Clear();
+ detailView->PrevTab();
+ detailView->SetDirty();
+ if (tablabels) {
+ tablabels->Clear();
+ tablabels->SetActiveTab(detailView->ActiveTab());
+ if (tablabels->Parse())
+ tablabels->Render();
+ }
+ sdOsd.Flush();
+ detailView->Render();
+ if (scrollbar) {
+ DrawScrollbar();
+ }
+ } else {
+ //scroll page
+ if (detailView->ScrollUp(true)) {
+ if (scrollbar)
+ DrawScrollbar();
+ }
+ }
+}
+
+void cViewMenuDetail::KeyRight(void) {
+ if (detailView->NumTabs() > 1) {
+ detailView->Clear();
+ detailView->NextTab();
+ detailView->SetDirty();
+ if (tablabels) {
+ tablabels->Clear();
+ tablabels->SetActiveTab(detailView->ActiveTab());
+ if (tablabels->Parse())
+ tablabels->Render();
+ }
+ sdOsd.Flush();
+ detailView->Render();
+ if (scrollbar) {
+ DrawScrollbar();
+ }
+
+ } else {
+ //scroll page
+ if (detailView->ScrollDown(true)) {
+ if (scrollbar)
+ DrawScrollbar();
+ }
+ }
+}
+
+void cViewMenuDetail::KeyUp(void) {
+ if (detailView->ScrollUp()) {
+ if (scrollbar)
+ DrawScrollbar();
+ }
+}
+
+void cViewMenuDetail::KeyDown(void) {
+ if (scrollbar && detailView->ScrollDown()) {
+ if (scrollbar)
+ DrawScrollbar();
+ }
+}
+
+void cViewMenuDetail::SetTransparency(int transparency, bool forceDetached) {
+ if (detailedheaderEpg)
+ detailedheaderEpg->SetTransparency(transparency);
+ if (detailedheaderRec)
+ detailedheaderRec->SetTransparency(transparency);
+ if (tablabels)
+ tablabels->SetTransparency(transparency);
+ if (detailView)
+ detailView->SetTransparency(transparency);
+}
+
+void cViewMenuDetail::DrawScrollbar(void) {
+ int barheight = 0;
+ int offset = 0;
+ bool end = true;
+ detailView->Scrollbar(barheight, offset, end);
+ scrollbar->SetDetail(barheight, offset, end);
+ scrollbar->Render();
+}
diff --git a/coreengine/viewdisplaymenu.h b/coreengine/viewdisplaymenu.h new file mode 100644 index 0000000..1658f72 --- /dev/null +++ b/coreengine/viewdisplaymenu.h @@ -0,0 +1,316 @@ +#ifndef __VIEWDISPLAYMENU_H
+#define __VIEWDISPLAYMENU_H
+
+#include "view.h"
+#include "viewdetail.h"
+
+/***********************************************************
+* cViewMenu
+***********************************************************/
+class cSubView;
+class cViewMenuDefault;
+class cViewMenuMain;
+class cViewMenuSetup;
+class cViewMenuSchedules;
+class cViewMenuChannels;
+class cViewMenuTimers;
+class cViewMenuRecordings;
+class cViewMenuDetail;
+
+class cViewMenu : public cView {
+protected:
+ map<string,int> subviewNames;
+ cSubView **subViews;
+ int numSubviews;
+ cSubView *activeSubview;
+ cSubView *activeSubviewLast;
+ cViewMenuDefault *menuDefault;
+ cViewMenuMain *menuMain;
+ cViewMenuSetup *menuSetup;
+ cViewMenuSchedules *menuSchedules;
+ cViewMenuChannels *menuChannels;
+ cViewMenuTimers *menuTimers;
+ cViewMenuRecordings *menuRecordings;
+ cViewMenuDetail *menuDetailedEpg;
+ cViewMenuDetail *menuDetailedRec;
+ cViewMenuDetail *menuDetailedText;
+ eMenuCategory menuCat;
+ //name of current plugin for menu icon
+ const char *plugName;
+ //external plugin menus
+ bool pluginIdSet;
+ int plugId;
+ int plugMenuId;
+ //status variables
+ bool menuChange;
+ bool listChange;
+ bool detailViewInit;
+ void SetViewElements(void);
+ void SetViewElementObjects(void);
+ void SetSubViews(void);
+ void ClearVariables(void);
+ int SubviewId(const char *name);
+ bool SetPluginSubView(eMenuCategory menuCat);
+ void WakeViewElements(void);
+public:
+ cViewMenu(void);
+ virtual ~cViewMenu(void);
+ void SetGlobals(cGlobals *globals);
+ void PreCache(void);
+ bool ValidSubView(const char *subView);
+ static cSubView *CreateSubview(const char *name);
+ static cSubView *CreatePluginview(const char *plugname, int plugId, int menuNumber, int menuType);
+ void AddSubview(const char *sSubView, cSubView *subView);
+ void AddPluginview(cSubView *plugView);
+ void SetSubView(eMenuCategory MenuCat);
+ void SetSortMode(eMenuSortMode sortMode);
+ void SetPluginMenu(int plugId, int plugMenuId);
+ int NumListItems(void);
+ eMenuOrientation MenuOrientation(void);
+ const cFont *GetTextAreaFont(void);
+ int GetTextAreaWidth(void);
+ int GetListWidth(void);
+ void SetTitleHeader(const char *title);
+ void SetChannelHeader(const cEvent *event);
+ void SetMessage(eMessageType type, const char *text);
+ void SetMenuButtons(const char *red, const char *green, const char *yellow, const char *blue);
+ void SetScrollbar(int total, int offset);
+ void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
+ void SetItem(const char *text, int index, bool current, bool selectable);
+ bool SetItemEvent(const cEvent *event, int index, bool current, bool selectable, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
+ bool SetItemTimer(const cTimer *timer, int index, bool current, bool selectable);
+ bool SetItemChannel(const cChannel *channel, int index, bool current, bool selectable, bool withProvider);
+ bool SetItemRecording(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New);
+ bool SetItemPlugin(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable);
+ void SetEvent(const cEvent *event);
+ void SetRecording(const cRecording *recording);
+ void SetText(const char *text);
+ bool SetPluginText(skindesignerapi::cTokenContainer *tk);
+ void SetCurrentRecording(const char *currentRec);
+ void KeyDetailView(bool up, bool page);
+ bool Init(void);
+ void Close(void);
+ void Clear(void);
+ void Flush(void);
+ void SetTransparency(int transparency, bool forceDetached = false);
+ void Debug(void);
+};
+
+/***********************************************************
+* cSubView
+***********************************************************/
+class cSubView : public cView {
+protected:
+ eMenuCategory menuCat;
+ int plugId;
+ int plugMenuId;
+ cViewList *viewList;
+ cViewList *viewListVertical;
+ cViewList *viewListHorizontal;
+ cViewElement *background;
+ cVeDmHeader *header;
+ cVeDateTime *datetime;
+ cVeTime *time;
+ cVeMessage *message;
+ cVeDmSortmode *sortmode;
+ cVeDmColorbuttons *colorbuttons;
+ cVeDmScrollbar *scrollbar;
+ virtual void SetViewElementObjects(void);
+ virtual void SetViewElements(void);
+public:
+ cSubView(const char *name);
+ virtual ~cSubView(void);
+ virtual void SetGlobals(cGlobals *globals);
+ virtual void PreCache(void);
+ bool ViewElementSet(int ve);
+ bool ViewElementHorizontalSet(int ve);
+ void SetViewElement(eVeDisplayMenu ve, cViewElement *viewElement);
+ void SetViewElementHorizontal(eVeDisplayMenu ve, cViewElement *viewElement);
+ void AddViewList(cViewList *viewList);
+ virtual void AddTab(cArea *tab) {};
+ int NumListItems(void);
+ eMenuOrientation MenuOrientation(void);
+ void SetMenuCategory(eMenuCategory menuCat) { this->menuCat = menuCat; };
+ void SetPlugId(int id) { plugId = id; };
+ void SetPlugMenuId(int id) { plugMenuId = id; };
+ void SetTitle(const char *title);
+ void SetMessage(eMessageType type, const char *text);
+ void SetChannel(const cChannel *channel);
+ void SetMenuButtons(const char *red, const char *green, const char *yellow, const char *blue);
+ void SetScrollbar(int total, int offset);
+ void SetSortMode(eMenuSortMode sortMode);
+ virtual void Close(void);
+ virtual void Clear(void);
+ void ClearViewList(void);
+ void WakeViewElements(void);
+ virtual void DrawStaticVEs(void);
+ virtual void DrawDynamicVEs(void);
+ void DrawList(void);
+ virtual void DrawDetailedView(void) {};
+ virtual void UpdateDetailedView(void) {};
+ void SetTransparency(int transparency, bool forceDetached = false);
+};
+/***********************************************************
+* cViewMenuDefault
+***********************************************************/
+class cViewMenuDefault : public cSubView {
+private:
+ cViewListDefault *listDefault;
+ void SetViewElementObjects(void);
+public:
+ cViewMenuDefault(const char *name);
+ virtual ~cViewMenuDefault(void);
+ void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
+ void SetPlugin(const char *plugName);
+ void SetItem(const char *text, int index, bool current, bool selectable);
+ const cFont *GetTextAreaFont(void);
+ int GetListWidth(void);
+};
+/***********************************************************
+* cViewMenuMain
+***********************************************************/
+class cViewMenuMain : public cSubView {
+private:
+ cViewListMain *listMain;
+ cVeDmTimers *timers;
+ cVeDevices *devices;
+ cVeCurrentWeather *weather;
+ cVeDmDiscusage *discusage;
+ cVeDmSystemload *load;
+ cVeDmSystemmemory *memory;
+ cVeDmVdrstatistics *vdrstats;
+ cVeDmTemperatures *temperatures;
+ cVeDmCurrentschedule *currentSchedule;
+ cVeDmLastrecordings *lastRecordings;
+ cVeCustomTokens *customTokens;
+ uint64_t lastDrawDynamic;
+ void ClearVariables(void);
+ void SetViewElements(void);
+ void SetViewElementObjects(void);
+public:
+ cViewMenuMain(const char *name);
+ virtual ~cViewMenuMain(void);
+ void Clear(void);
+ void SetItem(const char *text, int index, bool current, bool selectable);
+ void SetCurrentRecording(const char *currentRec);
+ void DrawStaticVEs(void);
+ void DrawDynamicVEs(void);
+ const char *GetPlugin(void);
+};
+/***********************************************************
+* cViewMenuSetup
+***********************************************************/
+class cViewMenuSetup : public cSubView {
+private:
+ cViewListMain *listSetup;
+ void SetViewElementObjects(void);
+public:
+ cViewMenuSetup(const char *name);
+ virtual ~cViewMenuSetup(void);
+ void SetItem(const char *text, int index, bool current, bool selectable);
+};
+/***********************************************************
+* cViewMenuSchedules
+***********************************************************/
+class cViewMenuSchedules : public cSubView {
+private:
+ cViewListSchedules *listSchedules;
+ void SetViewElementObjects(void);
+public:
+ cViewMenuSchedules(const char *name);
+ virtual ~cViewMenuSchedules(void);
+ void SetItem(const cEvent *event, int index, bool current, bool selectable, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
+};
+/***********************************************************
+* cViewMenuChannels
+***********************************************************/
+class cViewMenuChannels : public cSubView {
+private:
+ cViewListChannels *listChannels;
+ void SetViewElementObjects(void);
+public:
+ cViewMenuChannels(const char *name);
+ virtual ~cViewMenuChannels(void);
+ void SetItem(const cChannel *channel, int index, bool current, bool selectable, bool withProvider);
+};
+/***********************************************************
+* cViewMenuTimers
+***********************************************************/
+class cViewMenuTimers : public cSubView {
+private:
+ cViewListTimers *listTimers;
+ void SetViewElementObjects(void);
+public:
+ cViewMenuTimers(const char *name);
+ virtual ~cViewMenuTimers(void);
+ void SetItem(const cTimer *timer, int index, bool current, bool selectable);
+};
+/***********************************************************
+* cViewMenuRecordings
+***********************************************************/
+class cViewMenuRecordings : public cSubView {
+private:
+ cViewListRecordings *listRecordings;
+ void SetViewElementObjects(void);
+public:
+ cViewMenuRecordings(const char *name);
+ virtual ~cViewMenuRecordings(void);
+ void SetItem(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New);
+};
+
+/***********************************************************
+* cViewMenuPlugins
+***********************************************************/
+class cViewMenuPlugin : public cSubView {
+private:
+ cViewListPlugin *listPlugin;
+ void SetViewElementObjects(void);
+public:
+ cViewMenuPlugin(const char *name);
+ virtual ~cViewMenuPlugin(void);
+ void SetItem(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable);
+};
+
+/***********************************************************
+* cViewMenuDetail
+***********************************************************/
+class cViewMenuDetail : public cSubView {
+private:
+ bool firstTab;
+ cVeDmDetailheaderEpg *detailedheaderEpg;
+ cVeDmDetailheaderRec *detailedheaderRec;
+ cVeDmDetailheaderPlugin *detailedheaderPlug;
+ cVeDmTablabels *tablabels;
+ cViewDetail *detailView;
+ cViewDetailEpg *detailViewEpg;
+ cViewDetailRec *detailViewRec;
+ cViewDetailText *detailViewText;
+ cViewDetailPlugin *detailViewPlugin;
+ void SetDetailedView(void);
+ void SetViewElements(void);
+ void SetViewElementObjects(void);
+ void DrawScrollbar(void);
+public:
+ cViewMenuDetail(const char *name);
+ virtual ~cViewMenuDetail(void);
+ void SetGlobals(cGlobals *globals);
+ void AddTab(cArea *tab);
+ void PreCache(void);
+ int GetWidth(void);
+ void SetEvent(const cEvent *event);
+ void SetRecording(const cRecording *recording);
+ void SetText(const char *text);
+ void SetPluginText(skindesignerapi::cTokenContainer *tk);
+ void Clear(void);
+ void Close(void);
+ void DrawStaticVEs(void);
+ void DrawDynamicVEs(void);
+ void DrawDetailedView(void);
+ void KeyLeft(void);
+ void KeyRight(void);
+ void KeyUp(void);
+ void KeyDown(void);
+ void SetTransparency(int transparency, bool forceDetached = false);
+};
+
+#endif //__VIEWDISPLAYMENU_H
\ No newline at end of file diff --git a/coreengine/viewdisplaymessage.c b/coreengine/viewdisplaymessage.c new file mode 100644 index 0000000..a9613fa --- /dev/null +++ b/coreengine/viewdisplaymessage.c @@ -0,0 +1,54 @@ +#include "viewdisplaymessage.h"
+#include "../config.h"
+
+/************************************************************************************
+* cViewMessage
+************************************************************************************/
+
+cViewMessage::cViewMessage(void) {
+ ClearVariables();
+ viewId = eViewType::DisplayMessage;
+ viewName = strdup("displaymessage");
+ numViewElements = (int)eVeDisplayMessage::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ SetViewElements();
+ veMessage = NULL;
+}
+
+cViewMessage::~cViewMessage() {
+}
+
+void cViewMessage::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayMessage::background));
+ viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayMessage::message));
+}
+
+void cViewMessage::SetViewElementObjects(void) {
+ if (!viewElements[(int)eVeDisplayMessage::message])
+ return;
+ veMessage = dynamic_cast<cVeMessage*>(viewElements[(int)eVeDisplayMessage::message]);
+}
+
+void cViewMessage::ClearVariables(void) {
+ init = true;
+}
+
+void cViewMessage::SetMessage(eMessageType type, const char *text) {
+ if (!text)
+ veMessage->Clear();
+ else
+ veMessage->Set(type, text);
+}
+
+void cViewMessage::Flush(void) {
+ if (init) {
+ sdOsd.LockFlush();
+ Render((int)eVeDisplayMessage::background);
+ }
+ Render((int)eVeDisplayMessage::message);
+ cView::Flush();
+}
+
diff --git a/coreengine/viewdisplaymessage.h b/coreengine/viewdisplaymessage.h new file mode 100644 index 0000000..44f4608 --- /dev/null +++ b/coreengine/viewdisplaymessage.h @@ -0,0 +1,19 @@ +#ifndef __VIEWDISPLAYMESSAGE_H
+#define __VIEWDISPLAYMESSAGE_H
+
+#include "view.h"
+
+class cViewMessage : public cView {
+private:
+ cVeMessage *veMessage;
+ void SetViewElements(void);
+ void SetViewElementObjects(void);
+ void ClearVariables(void);
+public:
+ cViewMessage(void);
+ virtual ~cViewMessage(void);
+ void SetMessage(eMessageType type, const char *text);
+ void Flush(void);
+};
+
+#endif //__VIEWDISPLAYMESSAGE_H
\ No newline at end of file diff --git a/coreengine/viewdisplayplugin.c b/coreengine/viewdisplayplugin.c new file mode 100644 index 0000000..1619944 --- /dev/null +++ b/coreengine/viewdisplayplugin.c @@ -0,0 +1,556 @@ +#include "viewdisplayplugin.h"
+#include "../config.h"
+/***********************************************************
+* cViewPlugin
+***********************************************************/
+cViewPlugin::cViewPlugin(int id, int plugId) {
+ this->id = id;
+ this->plugId = plugId;
+ viewId = eViewType::DisplayPlugin;
+ viewName = strdup("displayplugin");
+ if (id == 0)
+ numViews = plgManager->GetNumSubviews(plugId) + 1;
+ else
+ numViews = 1;
+ views = new cViewPlugin*[numViews];
+ views[0] = this;
+ for (int i=1; i < numViews; i++) {
+ views[i] = NULL;
+ }
+ numViewElements = plgManager->GetNumViewElements(plugId, id);
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ SetViewElements();
+ numViewGrids = plgManager->GetNumViewGrids(plugId, id);
+ viewGrids = new cViewGrid*[numViewGrids];
+ for (int i=0; i < numViewGrids; i++) {
+ viewGrids[i] = NULL;
+ }
+ SetViewGrids();
+ tabView = NULL;
+ viewChanged = true;
+ newViewId = 0;
+}
+
+cViewPlugin::~cViewPlugin(void) {
+ for (int i=0; i< numViewGrids; i++)
+ delete viewGrids[i];
+ delete[] viewGrids;
+ delete tabView;
+ for (int i=1; i < numViews; i++) {
+ delete views[i];
+ }
+ delete[] views;
+}
+
+/***********************************************************
+* Public Functions
+***********************************************************/
+bool cViewPlugin::ReadFromXML(const char *plugName, const char *tplName, cSdOsd *osd) {
+ cString xmlFile = cString::sprintf("plug-%s-%s", plugName, tplName);
+ cXmlParser parser;
+ if (osd)
+ parser.SetOsd(osd);
+ else
+ parser.SetOsd(&sdOsd);
+ if (!parser.ReadView(this, *xmlFile)) {
+ return false;
+ }
+ if (!parser.ParsePluginView()) {
+ return false;
+ }
+ return true;
+}
+
+bool cViewPlugin::ReadSubViews(const char *plugName) {
+ plgManager->InitPluginSubviewIterator(plugId);
+ int svId = -1;
+ string svTpl = "";
+ while (plgManager->GetNextSubView(svId, svTpl)) {
+ cViewPlugin *plugSubView = new cViewPlugin(svId, plugId);
+ if (!plugSubView->ReadFromXML(plugName, svTpl.c_str(), &sdOsd))
+ return false;
+ views[svId] = plugSubView;
+ }
+ return true;
+}
+
+
+void cViewPlugin::SetGlobals(cGlobals *globals) {
+ cView::SetGlobals(globals);
+ for (int i=0; i < numViewGrids; i++) {
+ if (viewGrids[i])
+ viewGrids[i]->SetGlobals(globals);
+ }
+ for (int i=1; i < numViews; i++) {
+ views[i]->SetGlobals(globals);
+ }
+ if (tabView) {
+ tabView->SetGlobals(globals);
+ }
+}
+
+void cViewPlugin::AddViewElement(cVePlugin *viewElement) {
+ int veId = ViewElementId(viewElement->Name());
+ if (veId == ATTR_UNKNOWN)
+ return;
+ viewElement->SetId(veId);
+ viewElement->SetPluginId(plugId);
+ viewElement->SetViewId(id);
+ viewElement->SetTokenContainer();
+ viewElements[veId] = viewElement;
+}
+
+void cViewPlugin::AddViewGrid(cViewGrid *viewGrid) {
+ int gId = GridId(viewGrid->Name());
+ if (gId == ATTR_UNKNOWN)
+ return;
+ viewGrid->SetId(gId);
+ viewGrid->SetPluginId(plugId);
+ viewGrid->SetViewId(id);
+ viewGrid->SetTokenContainer();
+ viewGrids[gId] = viewGrid;
+}
+
+void cViewPlugin::AddTab(cArea *tab) {
+ if (!tabView) {
+ tabView = new cPluginTabView(id, plugId);
+ tabView->SetOsd(&sdOsd);
+ }
+ tabView->AddTab(tab);
+}
+
+void cViewPlugin::AddScrollbar(cVeDmScrollbar *scrollbar) {
+ if (!tabView) {
+ tabView = new cPluginTabView(id, plugId);
+ tabView->SetOsd(&sdOsd);
+ }
+ int id = ViewElementId("scrollbar");
+ scrollbar->SetId(id);
+ scrollbar->SetTokenContainer();
+ tabView->AddScrollbar(scrollbar);
+}
+
+void cViewPlugin::AddTablabels(cVeDmTablabels *tablabels) {
+ if (!tabView) {
+ tabView = new cPluginTabView(id, plugId);
+ tabView->SetOsd(&sdOsd);
+ }
+ int id = ViewElementId("tablabels");
+ tablabels->SetId(id);
+ tablabels->SetTokenContainer();
+ tabView->AddTablabels(tablabels);
+}
+
+void cViewPlugin::PreCache(void) {
+ if (container.Width() > 0) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Cache();
+ }
+ cView::PreCache();
+ for (int i=0; i < numViewGrids; i++) {
+ if (viewGrids[i]) {
+ viewGrids[i]->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ viewGrids[i]->PreCache();
+ }
+ }
+ for (int i=1; i < numViews; i++) {
+ views[i]->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ views[i]->PreCache();
+ }
+ if (tabView) {
+ tabView->PreCache(0, 0, attribs->Width(), attribs->Height());
+ }
+}
+
+cVePlugin *cViewPlugin::GetViewElement(int veId) {
+ if (!viewElements[veId])
+ return NULL;
+ cVePlugin *ve = dynamic_cast<cVePlugin*>(viewElements[veId]);
+ return ve;
+}
+
+cViewGrid *cViewPlugin::GetViewGrid(int gId) {
+ return viewGrids[gId];
+}
+
+cPluginTabView *cViewPlugin::GetViewTab(void) {
+ return tabView;
+}
+
+void cViewPlugin::Hide(void) {
+ for (int i=0; i < numViewGrids; i++) {
+ if (viewGrids[i])
+ viewGrids[i]->Hide();
+ }
+ for (int i=0; i < numViewElements; i++) {
+ if (viewElements[i])
+ viewElements[i]->Hide();
+ }
+}
+
+void cViewPlugin::Show(void) {
+ for (int i=0; i < numViewGrids; i++) {
+ if (viewGrids[i])
+ viewGrids[i]->Show();
+ }
+ for (int i=0; i < numViewElements; i++) {
+ if (viewElements[i])
+ viewElements[i]->Show();
+ }
+}
+/***********************************************************
+* libskindesigner api interface
+***********************************************************/
+bool cViewPlugin::InitOsd(void) {
+ return Init();
+}
+
+void cViewPlugin::CloseOsd(void) {
+ viewChanged = true;
+ newViewId = 0;
+ Close();
+ for (int i=0 ; i < numViewGrids; i++) {
+ if (viewGrids[i])
+ viewGrids[i]->Close();
+ }
+ for (int i=1 ; i < numViews; i++) {
+ if (views[i])
+ views[i]->Close();
+ }
+}
+
+void cViewPlugin::Deactivate(int viewId, bool hide) {
+ for (int i=0; i < numViewElements; i++) {
+ if (viewElements[i])
+ viewElements[i]->StopScrolling(false);
+ }
+ if (hide)
+ views[viewId]->Hide();
+}
+
+void cViewPlugin::Activate(int viewId) {
+ viewChanged = true;
+ newViewId = viewId;
+ views[viewId]->Show();
+}
+
+void cViewPlugin::SetViewElementTokens(int veId, int viewId, skindesignerapi::cTokenContainer *tk) {
+ cVePlugin *ve = views[viewId]->GetViewElement(veId);
+ if (!ve)
+ return;
+ ve->Set(tk);
+}
+
+void cViewPlugin::ClearViewElement(int veId, int viewId) {
+ cVePlugin *ve = views[viewId]->GetViewElement(veId);
+ if (!ve)
+ return;
+ ve->StopScrolling();
+ ve->Clear();
+}
+
+void cViewPlugin::DisplayViewElement(int veId, int viewId) {
+ cVePlugin *ve = views[viewId]->GetViewElement(veId);
+ if (!ve)
+ return;
+ if (ve->Parse())
+ ve->Render();
+}
+
+void cViewPlugin::SetGrid(long gId, int viewId, int viewGridId, double x, double y, double width, double height, skindesignerapi::cTokenContainer *tk){
+ cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
+ if (!grid)
+ return;
+ grid->CheckSize(gId);
+ grid->PositionGrid(gId, x, y, width, height);
+ if (tk) {
+ //only set tokens new if necessary
+ grid->SetTokens(gId, tk);
+ }
+}
+
+void cViewPlugin::SetGridCurrent(long gId, int viewId, int viewGridId, bool current) {
+ if (gId < 0)
+ return;
+ cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
+ if (!grid)
+ return;
+ grid->SetCurrentGrid(gId, current);
+}
+
+void cViewPlugin::DeleteGrid(long gId, int viewId, int viewGridId) {
+ cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
+ if (!grid)
+ return;
+ grid->DeleteGrid(gId);
+}
+
+void cViewPlugin::DisplayGrids(int viewId, int viewGridId) {
+ cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
+ if (!grid)
+ return;
+ grid->Render();
+}
+
+void cViewPlugin::ClearGrids(int viewId, int viewGridId) {
+ cViewGrid *grid = views[viewId]->GetViewGrid(viewGridId);
+ if (!grid)
+ return;
+ grid->ClearGrids();
+}
+
+void cViewPlugin::SetTabTokens(int viewId, skindesignerapi::cTokenContainer *tk) {
+ cPluginTabView *tab = views[viewId]->GetViewTab();
+ if (!tab)
+ return;
+ tab->SetOsd(&sdOsd);
+ tab->Set(tk);
+}
+
+void cViewPlugin::TabLeft(int viewId) {
+ cPluginTabView *tab = views[viewId]->GetViewTab();
+ if (!tab)
+ return;
+ tab->KeyLeft();
+}
+
+void cViewPlugin::TabRight(int viewId) {
+ cPluginTabView *tab = views[viewId]->GetViewTab();
+ if (!tab)
+ return;
+ tab->KeyRight();
+}
+
+void cViewPlugin::TabUp(int viewId) {
+ cPluginTabView *tab = views[viewId]->GetViewTab();
+ if (!tab)
+ return;
+ tab->KeyUp();
+}
+
+void cViewPlugin::TabDown(int viewId) {
+ cPluginTabView *tab = views[viewId]->GetViewTab();
+ if (!tab)
+ return;
+ tab->KeyDown();
+}
+
+void cViewPlugin::DisplayTabs(int viewId) {
+ cPluginTabView *tab = views[viewId]->GetViewTab();
+ if (!tab)
+ return;
+ tab->Render();
+}
+
+void cViewPlugin::ClearTab(int viewId) {
+ cPluginTabView *tab = views[viewId]->GetViewTab();
+ if (!tab)
+ return;
+ tab->Clear();
+}
+
+void cViewPlugin::Flush(void) {
+ if (viewChanged) {
+ viewChanged = false;
+ newTvFrame = views[newViewId]->GetTvFrame();
+ menuInit = true;
+ }
+ cView::Flush();
+}
+
+bool cViewPlugin::ChannelLogoExists(string channelId) {
+ return imgCache->LogoExists(channelId);
+}
+
+string cViewPlugin::GetEpgImagePath(void) {
+ return *config.epgImagePath;
+}
+
+/***********************************************************
+* Private Functions
+***********************************************************/
+void cViewPlugin::SetViewElements(void) {
+ plgManager->InitViewElementIterator(plugId, id);
+ int veId = -1;
+ string veName = "";
+ while (plgManager->GetNextViewElement(veId, veName)) {
+ viewElementNames.insert(pair<string, int>(veName, veId));
+ }
+}
+
+void cViewPlugin::SetViewGrids(void) {
+ plgManager->InitViewGridIterator(plugId, id);
+ int gId = -1;
+ string gName = "";
+ while (plgManager->GetNextViewGrid(gId, gName)) {
+ gridNames.insert(pair<string, int>(gName, gId));
+ }
+}
+
+int cViewPlugin::GridId(const char *name) {
+ map<string, int>::iterator hit = gridNames.find(name);
+ if (hit != gridNames.end())
+ return (int)hit->second;
+ return ATTR_UNKNOWN;
+}
+
+/***********************************************************
+* cPluginTabView
+***********************************************************/
+cPluginTabView::cPluginTabView(int viewId, int plugId) {
+ sdOsd = NULL;
+ init = true;
+ drawScrollbar = true;
+ scrollbar = NULL;
+ tablabels = NULL;
+ detailView = new cViewDetailAdvancedPlugin(viewId, plugId);
+ firstTab = true;
+}
+
+cPluginTabView::~cPluginTabView(void) {
+ delete scrollbar;
+ delete tablabels;
+ delete detailView;
+}
+
+void cPluginTabView::SetGlobals(cGlobals *globals) {
+ detailView->SetGlobals(globals);
+ if (scrollbar)
+ scrollbar->SetGlobals(globals);
+ if (tablabels)
+ tablabels->SetGlobals(globals);
+}
+
+void cPluginTabView::AddTab(cArea *tab) {
+ if (firstTab) {
+ tab->SetActiveTab(true);
+ firstTab = false;
+ }
+ detailView->AddArea(tab);
+}
+
+void cPluginTabView::AddScrollbar(cVeDmScrollbar *scrollbar) {
+ this->scrollbar = scrollbar;
+}
+
+void cPluginTabView::AddTablabels(cVeDmTablabels *tablabels) {
+ this->tablabels = tablabels;
+}
+
+void cPluginTabView::PreCache(int containerX, int containerY, int containerWidth, int containerHeight) {
+ detailView->SetOsd(sdOsd);
+ detailView->SetTokenContainer();
+ detailView->SetContainer(containerX, containerY, containerWidth, containerHeight);
+ detailView->Cache();
+ if (scrollbar) {
+ scrollbar->SetContainer(containerX, containerY, containerWidth, containerHeight);
+ scrollbar->Cache();
+ }
+ if (tablabels) {
+ tablabels->SetContainer(containerX, containerY, containerWidth, containerHeight);
+ tablabels->Cache();
+ }
+}
+
+void cPluginTabView::Set(skindesignerapi::cTokenContainer *tk) {
+ detailView->Set(tk);
+}
+
+void cPluginTabView::Render(void) {
+ detailView->Render();
+ if (drawScrollbar) {
+ drawScrollbar = false;
+ DrawScrollbar();
+ }
+ if (!init)
+ return;
+ init = false;
+ vector<const char*> tabs;
+ int activeTab = detailView->GetTabs(tabs);
+ if (tablabels) {
+ tablabels->SetTabs(tabs);
+ tablabels->SetActiveTab(activeTab);
+ if (tablabels->Parse())
+ tablabels->Render();
+ }
+}
+
+void cPluginTabView::Clear(void) {
+ init = true;
+ drawScrollbar = true;
+ detailView->ResetTabs();
+ detailView->Close();
+ if (tablabels)
+ tablabels->Close();
+ if (scrollbar)
+ scrollbar->Close();
+}
+
+void cPluginTabView::KeyLeft(void) {
+ if (detailView->NumTabs() > 1) {
+ detailView->Clear();
+ detailView->PrevTab();
+ detailView->SetDirty();
+ if (tablabels) {
+ tablabels->Clear();
+ tablabels->SetActiveTab(detailView->ActiveTab());
+ if (tablabels->Parse())
+ tablabels->Render();
+ }
+ sdOsd->Flush();
+ drawScrollbar = true;
+ } else {
+ //scroll page
+ if (detailView->ScrollUp(true)) {
+ drawScrollbar = true;
+ }
+ }
+}
+
+void cPluginTabView::KeyRight(void) {
+ if (detailView->NumTabs() > 1) {
+ detailView->Clear();
+ detailView->NextTab();
+ detailView->SetDirty();
+ if (tablabels) {
+ tablabels->Clear();
+ tablabels->SetActiveTab(detailView->ActiveTab());
+ if (tablabels->Parse())
+ tablabels->Render();
+ }
+ sdOsd->Flush();
+ drawScrollbar = true;
+ } else {
+ //scroll page
+ if (detailView->ScrollDown(true)) {
+ drawScrollbar = true;
+ }
+ }
+}
+
+void cPluginTabView::KeyUp(void) {
+ if (detailView->ScrollUp()) {
+ drawScrollbar = true;
+ }
+}
+
+void cPluginTabView::KeyDown(void) {
+ if (detailView->ScrollDown()) {
+ drawScrollbar = true;
+ }
+}
+
+void cPluginTabView::DrawScrollbar(void) {
+ if (!scrollbar)
+ return;
+ int barheight = 0;
+ int offset = 0;
+ bool end = true;
+ detailView->Scrollbar(barheight, offset, end);
+ scrollbar->SetDetail(barheight, offset, end);
+ scrollbar->Render();
+}
+
diff --git a/coreengine/viewdisplayplugin.h b/coreengine/viewdisplayplugin.h new file mode 100644 index 0000000..4d9cd59 --- /dev/null +++ b/coreengine/viewdisplayplugin.h @@ -0,0 +1,101 @@ +#ifndef __VIEWDISPLAYPLUGIN_H
+#define __VIEWDISPLAYPLUGIN_H
+
+#include "view.h"
+#include "viewdetail.h"
+#include "viewelementsdisplaymenu.h"
+#include "viewgrid.h"
+#include "../libskindesignerapi/skindesignerapi.h"
+
+class cPluginTabView;
+/***********************************************************
+* cViewPlugin
+***********************************************************/
+class cViewPlugin : public cView, public skindesignerapi::ISkinDisplayPlugin {
+private:
+ int id;
+ int plugId;
+ int numViews;
+ cViewPlugin **views;
+ int numViewGrids;
+ cViewGrid **viewGrids;
+ map<string,int> gridNames;
+ cPluginTabView *tabView;
+ bool viewChanged;
+ int newViewId;
+ void SetViewElements(void);
+ void SetViewGrids(void);
+ int GridId(const char *name);
+public:
+ cViewPlugin(int id, int plugId);
+ ~cViewPlugin(void);
+ //Internal Interface
+ bool ReadFromXML(const char *plugName, const char *tplName, cSdOsd *osd = NULL);
+ bool ReadSubViews(const char *plugName);
+ void AddViewElement(cVePlugin *viewElement);
+ void AddViewGrid(cViewGrid *viewGrid);
+ void AddTab(cArea *tab);
+ void AddScrollbar(cVeDmScrollbar *scrollbar);
+ void AddTablabels(cVeDmTablabels *tablabels);
+ void SetGlobals(cGlobals *globals);
+ void PreCache(void);
+ cVePlugin *GetViewElement(int veId);
+ cViewGrid *GetViewGrid(int gId);
+ cPluginTabView *GetViewTab(void);
+ void Hide(void);
+ void Show(void);
+ //libskindesigner api interface
+ bool InitOsd(void);
+ void CloseOsd(void);
+ void Deactivate(int viewId, bool hide);
+ void Activate(int viewId);
+ void SetViewElementTokens(int veId, int viewId, skindesignerapi::cTokenContainer *tk);
+ void ClearViewElement(int veId, int viewId);
+ void DisplayViewElement(int veId, int viewId);
+ void SetGrid(long gId, int viewId, int viewGridId, double x, double y, double width, double height, skindesignerapi::cTokenContainer *tk);
+ void SetGridCurrent(long gId, int viewId, int viewGridId, bool current);
+ void DeleteGrid(long gId, int viewId, int viewGridId);
+ void DisplayGrids(int viewId, int viewGridId);
+ void ClearGrids(int viewId, int viewGridId);
+ void SetTabTokens(int viewId, skindesignerapi::cTokenContainer *tk);
+ void TabLeft(int viewId);
+ void TabRight(int viewId);
+ void TabUp(int viewId);
+ void TabDown(int viewId);
+ void DisplayTabs(int viewId);
+ void ClearTab(int viewId);
+ void Flush(void);
+ bool ChannelLogoExists(string channelId);
+ string GetEpgImagePath(void);
+};
+/***********************************************************
+* cPluginTabView
+***********************************************************/
+class cPluginTabView {
+private:
+ cSdOsd *sdOsd;
+ bool init;
+ bool drawScrollbar;
+ bool firstTab;
+ cVeDmScrollbar *scrollbar;
+ cVeDmTablabels *tablabels;
+ cViewDetailAdvancedPlugin *detailView;
+ void DrawScrollbar(void);
+public:
+ cPluginTabView(int viewId, int plugId);
+ ~cPluginTabView(void);
+ void SetGlobals(cGlobals *globals);
+ void SetOsd(cSdOsd *osd) { sdOsd = osd; };
+ void AddTab(cArea *tab);
+ void AddScrollbar(cVeDmScrollbar *scrollbar);
+ void AddTablabels(cVeDmTablabels *tablabels);
+ void PreCache(int containerX, int containerY, int containerWidth, int containerHeight);
+ void Set(skindesignerapi::cTokenContainer *tk);
+ void Render(void);
+ void Clear(void);
+ void KeyLeft(void);
+ void KeyRight(void);
+ void KeyUp(void);
+ void KeyDown(void);
+};
+#endif //__VIEWDISPLAYPLUGIN_H
\ No newline at end of file diff --git a/coreengine/viewdisplayreplay.c b/coreengine/viewdisplayreplay.c new file mode 100644 index 0000000..503b72f --- /dev/null +++ b/coreengine/viewdisplayreplay.c @@ -0,0 +1,314 @@ +#include "viewdisplayreplay.h"
+
+/************************************************************************************
+* cViewReplay
+************************************************************************************/
+
+cViewReplay::cViewReplay(void) {
+ veCustomTokens = NULL;
+ veEndTime = NULL;
+ veMessage = NULL;
+ veScraperContent = NULL;
+ veRecTitle = NULL;
+ veRecInfo = NULL;
+ veCurrentTime = NULL;
+ veTotalTime = NULL;
+ veProgressbar = NULL;
+ veCutMarks = NULL;
+ veProgressModeOnly = NULL;
+ veControlIcons = NULL;
+ veControlIconsModeOnly = NULL;
+ veJump = NULL;
+ veOnPause = NULL;
+ veOnPauseModeOnly = NULL;
+ ClearVariables();
+ viewId = eViewType::DisplayReplay;
+ viewName = strdup("displayreplay");
+ numViewElements = (int)eVeDisplayReplay::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ SetViewElements();
+}
+
+cViewReplay::~cViewReplay() {
+}
+
+void cViewReplay::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayReplay::background));
+ viewElementNames.insert(pair<string, int>("backgroundmodeonly", (int)eVeDisplayReplay::backgroundmodeonly));
+ viewElementNames.insert(pair<string, int>("datetime", (int)eVeDisplayReplay::datetime));
+ viewElementNames.insert(pair<string, int>("time", (int)eVeDisplayReplay::time));
+ viewElementNames.insert(pair<string, int>("scrapercontent", (int)eVeDisplayReplay::scrapercontent));
+ viewElementNames.insert(pair<string, int>("rectitle", (int)eVeDisplayReplay::rectitle));
+ viewElementNames.insert(pair<string, int>("recinfo", (int)eVeDisplayReplay::recinfo));
+ viewElementNames.insert(pair<string, int>("currenttime", (int)eVeDisplayReplay::currenttime));
+ viewElementNames.insert(pair<string, int>("endtime", (int)eVeDisplayReplay::endtime));
+ viewElementNames.insert(pair<string, int>("totaltime", (int)eVeDisplayReplay::totaltime));
+ viewElementNames.insert(pair<string, int>("progressbar", (int)eVeDisplayReplay::progressbar));
+ viewElementNames.insert(pair<string, int>("cutmarks", (int)eVeDisplayReplay::cutmarks));
+ viewElementNames.insert(pair<string, int>("cutmarks", (int)eVeDisplayReplay::cutmarks));
+ viewElementNames.insert(pair<string, int>("controlicons", (int)eVeDisplayReplay::controlicons));
+ viewElementNames.insert(pair<string, int>("controliconsmodeonly", (int)eVeDisplayReplay::controliconsmodeonly));
+ viewElementNames.insert(pair<string, int>("progressmodeonly", (int)eVeDisplayReplay::progressmodeonly));
+ viewElementNames.insert(pair<string, int>("jump", (int)eVeDisplayReplay::jump));
+ viewElementNames.insert(pair<string, int>("message", (int)eVeDisplayReplay::message));
+ viewElementNames.insert(pair<string, int>("onpause", (int)eVeDisplayReplay::onpause));
+ viewElementNames.insert(pair<string, int>("onpausemodeonly", (int)eVeDisplayReplay::onpausemodeonly));
+ viewElementNames.insert(pair<string, int>("customtokens", (int)eVeDisplayReplay::customtokens));
+}
+
+void cViewReplay::SetViewElementObjects(void) {
+ for (int i = 0; i < numViewElements; i++) {
+ if (!viewElements[i])
+ continue;
+ if (dynamic_cast<cVeMessage*>(viewElements[i]))
+ {
+ veMessage = dynamic_cast<cVeMessage*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrScraperContent*>(viewElements[i]))
+ {
+ veScraperContent = dynamic_cast<cVeDrScraperContent*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeCustomTokens*>(viewElements[i]))
+ {
+ veCustomTokens = dynamic_cast<cVeCustomTokens*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrRecTitle*>(viewElements[i]))
+ {
+ veRecTitle = dynamic_cast<cVeDrRecTitle*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrRecInfo*>(viewElements[i]))
+ {
+ veRecInfo = dynamic_cast<cVeDrRecInfo*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrCurrentTime*>(viewElements[i]))
+ {
+ veCurrentTime = dynamic_cast<cVeDrCurrentTime*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrTotalTime*>(viewElements[i]))
+ {
+ veTotalTime = dynamic_cast<cVeDrTotalTime*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrEndTime*>(viewElements[i]))
+ {
+ veEndTime = dynamic_cast<cVeDrEndTime*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrProgressBar*>(viewElements[i]))
+ {
+ veProgressbar = dynamic_cast<cVeDrProgressBar*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrCutMarks*>(viewElements[i]))
+ {
+ veCutMarks = dynamic_cast<cVeDrCutMarks*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrProgressModeonly*>(viewElements[i]))
+ {
+ veProgressModeOnly = dynamic_cast<cVeDrProgressModeonly*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrControlIcons*>(viewElements[i]) && (i == (int)eVeDisplayReplay::controlicons))
+ {
+ veControlIcons = dynamic_cast<cVeDrControlIcons*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrControlIcons*>(viewElements[i]) && i == (int)eVeDisplayReplay::controliconsmodeonly)
+ {
+ veControlIconsModeOnly = dynamic_cast<cVeDrControlIcons*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrJump*>(viewElements[i]))
+ {
+ veJump = dynamic_cast<cVeDrJump*>(viewElements[i]);
+ }
+ else if (dynamic_cast<cVeDrOnPause*>(viewElements[i]) && i == (int)eVeDisplayReplay::onpause)
+ {
+ veOnPause = dynamic_cast<cVeDrOnPause*>(viewElements[i]);
+ veOnPause->SetDetached();
+ veOnPause->UnsetWaitOnWakeup();
+ }
+ else if (dynamic_cast<cVeDrOnPause*>(viewElements[i]) && i == (int)eVeDisplayReplay::onpausemodeonly)
+ {
+ veOnPauseModeOnly = dynamic_cast<cVeDrOnPause*>(viewElements[i]);
+ veOnPauseModeOnly->SetDetached();
+ veOnPauseModeOnly->UnsetWaitOnWakeup();
+ }
+ }
+}
+
+void cViewReplay::ClearVariables(void) {
+ cView::ClearVariables();
+ modeOnly = false;
+ lastFlush = 0;
+ message = false;
+ reclength = -1;
+ timeShiftActive = false;
+ timeShiftFramesTotal = -1;
+ timeShiftLength = -1;
+ timeShiftDuration = "";
+ if (veCustomTokens)
+ veCustomTokens->Reset();
+ if (veEndTime)
+ veEndTime->Set(cString(""));
+ if (veCutMarks)
+ veCutMarks->Reset();
+}
+
+void cViewReplay::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 cViewReplay::SetRecording(const cRecording *recording) {
+ if (veRecTitle) {
+ veRecTitle->Set(recording);
+ }
+ if (veRecInfo) {
+ veRecInfo->Set(recording);
+ }
+ if (veScraperContent) {
+ veScraperContent->Set(recording);
+ }
+}
+
+void cViewReplay::SetTitle(const char *title) {
+ if (veRecTitle) {
+ veRecTitle->Set(title);
+ }
+}
+
+void cViewReplay::SetCurrent(const char *current) {
+ if (veCurrentTime)
+ veCurrentTime->Set(current);
+ Render((int)eVeDisplayReplay::currenttime);
+ //good place to refresh these viewelements
+ //since SetCurrent is called every second
+ Render((int)eVeDisplayReplay::datetime);
+ Render((int)eVeDisplayReplay::time);
+ Render((int)eVeDisplayChannel::customtokens);
+}
+
+void cViewReplay::SetTotal(const char *total) {
+ if (veTotalTime)
+ veTotalTime->Set(total, timeShiftActive, *timeShiftDuration);
+ Render((int)eVeDisplayReplay::totaltime);
+}
+
+void cViewReplay::SetEndTime(int current, int total) {
+ if (!veEndTime)
+ return;
+ int totalLength = total;
+ int recordingLength = reclength;
+ if (timeShiftActive && timeShiftFramesTotal > 0) {
+ totalLength = timeShiftFramesTotal;
+ recordingLength = timeShiftLength;
+ }
+ double rest = (double)(totalLength - current) / (double)totalLength;
+ time_t end = time(0) + rest*recordingLength;
+ veEndTime->Set(TimeString(end));
+ Render((int)eVeDisplayReplay::endtime);
+}
+
+void cViewReplay::SetProgressbar(int current, int total) {
+ if (veProgressbar)
+ veProgressbar->Set(current, total, timeShiftActive, timeShiftFramesTotal);
+ Render((int)eVeDisplayReplay::progressbar);
+}
+
+void cViewReplay::SetMarks(const cMarks *marks, int current, int total) {
+ if (veCutMarks)
+ veCutMarks->Set(marks, current, total, timeShiftActive, timeShiftFramesTotal);
+ Render((int)eVeDisplayReplay::cutmarks);
+}
+
+void cViewReplay::SetControlIcons(bool play, bool forward, int speed) {
+ if (!modeOnly) {
+ if (veControlIcons)
+ veControlIcons->Set(play, forward, speed);
+ Render((int)eVeDisplayReplay::controlicons);
+ } else {
+ if (veControlIconsModeOnly)
+ veControlIconsModeOnly->Set(play, forward, speed);
+ Render((int)eVeDisplayReplay::controliconsmodeonly);
+ }
+
+}
+
+void cViewReplay::SetJump(const char *jump) {
+ if (veJump) {
+ if (!jump)
+ veJump->Clear();
+ else
+ veJump->Set(jump);
+ }
+ Render((int)eVeDisplayReplay::jump);
+}
+
+void cViewReplay::SetMessage(eMessageType type, const char *text) {
+ if (veMessage) {
+ if (text)
+ veMessage->Set(type, text);
+ else
+ veMessage->Clear();
+ }
+ Render((int)eVeDisplayReplay::message);
+}
+
+void cViewReplay::StartOnPause(const char *recfilename) {
+ cVeDrOnPause *onPause = (!modeOnly) ? veOnPause : veOnPauseModeOnly;
+ if (!onPause)
+ return;
+ onPause->Set(recfilename);
+ onPause->Parse(true);
+}
+
+void cViewReplay::ClearOnPause(void) {
+ cVeDrOnPause *onPause = (!modeOnly) ? veOnPause : veOnPauseModeOnly;
+ if (!onPause)
+ return;
+ onPause->Close();
+}
+
+void cViewReplay::Flush(void) {
+ if (init) {
+ sdOsd.LockFlush();
+ if (!modeOnly) {
+ Render((int)eVeDisplayReplay::background);
+ Render((int)eVeDisplayReplay::rectitle);
+ Render((int)eVeDisplayReplay::recinfo);
+ Render((int)eVeDisplayReplay::scrapercontent);
+ } else {
+ Render((int)eVeDisplayReplay::backgroundmodeonly);
+ }
+ }
+
+ if (modeOnly) {
+ SetProgressModeOnly();
+ }
+
+ cView::Flush();
+}
+
+void cViewReplay::SetProgressModeOnly(void) {
+ if (!veProgressModeOnly)
+ return;
+ time_t now = time(0);
+ if (now == lastFlush) {
+ return;
+ }
+ lastFlush = now;
+
+ cControl *control = cControl::Control();
+ if (!control)
+ return;
+ double fps = control->FramesPerSecond();
+ int current = 0;
+ int total = 0;
+ if (!control->GetIndex(current, total))
+ return;
+ veProgressModeOnly->Set(fps, current, total);
+ if (veProgressModeOnly->Parse())
+ veProgressModeOnly->Render();
+}
\ No newline at end of file diff --git a/coreengine/viewdisplayreplay.h b/coreengine/viewdisplayreplay.h new file mode 100644 index 0000000..74ed10b --- /dev/null +++ b/coreengine/viewdisplayreplay.h @@ -0,0 +1,57 @@ +#ifndef __VIEWDISPLAYREPLAY_H
+#define __VIEWDISPLAYREPLAY_H
+
+#include "view.h"
+
+class cViewReplay : public cView {
+private:
+ cVeMessage *veMessage;
+ cVeCustomTokens *veCustomTokens;
+ cVeDrRecTitle *veRecTitle;
+ cVeDrRecInfo *veRecInfo;
+ cVeDrScraperContent *veScraperContent;
+ cVeDrCurrentTime *veCurrentTime;
+ cVeDrTotalTime *veTotalTime;
+ cVeDrEndTime *veEndTime;
+ cVeDrProgressBar *veProgressbar;
+ cVeDrCutMarks *veCutMarks;
+ cVeDrProgressModeonly *veProgressModeOnly;
+ cVeDrControlIcons *veControlIcons;
+ cVeDrControlIcons *veControlIconsModeOnly;
+ cVeDrJump *veJump;
+ cVeDrOnPause *veOnPause;
+ cVeDrOnPause *veOnPauseModeOnly;
+ bool modeOnly;
+ time_t lastFlush;
+ bool message;
+ int reclength;
+ bool timeShiftActive;
+ int timeShiftFramesTotal;
+ int timeShiftLength;
+ cString timeShiftDuration;
+ void SetViewElements(void);
+ void ClearVariables(void);
+ void SetViewElementObjects(void);
+ void SetProgressModeOnly(void);
+public:
+ cViewReplay(void);
+ virtual ~cViewReplay(void);
+ void SetModeOnly(bool modeOnly) { this->modeOnly = modeOnly; };
+ void SetRecordingLength(int length) { reclength = length; };
+ void SetTimeShift(int framesTotal, int timeShiftLength);
+ void SetRecording(const cRecording *recording);
+ void SetTitle(const char *title);
+ void SetCurrent(const char *current);
+ void SetTotal(const char *total);
+ void SetEndTime(int current, int total);
+ void SetProgressbar(int current, int total);
+ void SetMarks(const cMarks *marks, int current, int total);
+ void SetControlIcons(bool play, bool forward, int speed);
+ void SetJump(const char *jump);
+ void SetMessage(eMessageType type, const char *text);
+ void StartOnPause(const char *recfilename);
+ void ClearOnPause(void);
+ void Flush(void);
+};
+
+#endif //__VIEWDISPLAYREPLAY_H1
\ No newline at end of file diff --git a/coreengine/viewdisplaytracks.c b/coreengine/viewdisplaytracks.c new file mode 100644 index 0000000..15ff584 --- /dev/null +++ b/coreengine/viewdisplaytracks.c @@ -0,0 +1,122 @@ +#include "viewdisplaytracks.h"
+#include "../config.h"
+
+/************************************************************************************
+* cViewTracks
+************************************************************************************/
+
+cViewTracks::cViewTracks(void) {
+ ClearVariables();
+ viewId = eViewType::DisplayTracks;
+ viewName = strdup("displayaudiotracks");
+ numViewElements = (int)eVeDisplayTracks::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ viewList = NULL;
+ veBackground = NULL;
+ veHeader = NULL;
+ SetViewElements();
+}
+
+cViewTracks::~cViewTracks() {
+}
+
+void cViewTracks::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayTracks::background));
+ viewElementNames.insert(pair<string, int>("header", (int)eVeDisplayTracks::header));
+}
+
+void cViewTracks::SetViewElementObjects(void) {
+ if (viewElements[(int)eVeDisplayTracks::background])
+ veBackground = dynamic_cast<cVeDtBackground*>(viewElements[(int)eVeDisplayTracks::background]);
+ if (viewElements[(int)eVeDisplayTracks::header])
+ veHeader = dynamic_cast<cVeDtHeader*>(viewElements[(int)eVeDisplayTracks::header]);
+}
+
+void cViewTracks::ClearVariables(void) {
+ init = true;
+ change = true;
+}
+
+void cViewTracks::Close(void) {
+ delete fader;
+ fader = NULL;
+ if (FadeTime() > 0) {
+ fader = new cAnimation((cFadable*)this, false);
+ fader->Fade();
+ delete fader;
+ fader = NULL;
+ }
+ for (int i=0; i < numViewElements; i++) {
+ if (viewElements[i]) {
+ viewElements[i]->Close();
+ }
+ }
+ if (viewList) {
+ viewList->Close();
+ }
+ ClearVariables();
+ sdOsd.DeleteOsd();
+}
+
+void cViewTracks::AddViewList(cViewList *viewList) {
+ this->viewList = dynamic_cast<cViewListAudioTracks*>(viewList);
+}
+
+void cViewTracks::PreCache(void) {
+ cView::PreCache();
+ if (viewList) {
+ viewList->SetContainer(0, 0, attribs->Width(), attribs->Height());
+ viewList->SetGlobals(globals);
+ viewList->PreCache();
+ }
+}
+
+void cViewTracks::SetTitle(const char *title) {
+ if (veHeader)
+ veHeader->SetTitle(title);
+ change = true;
+}
+
+void cViewTracks::SetNumtracks(int numTracks) {
+ if (veBackground)
+ veBackground->Set(numTracks);
+ if (veHeader)
+ veHeader->SetNumtracks(numTracks);
+ if (viewList)
+ viewList->SetNumtracks(numTracks);
+}
+
+void cViewTracks::SetAudiochannel(int audioChannel) {
+ if (veHeader)
+ veHeader->SetAudiochannel(audioChannel);
+ change = true;
+}
+
+void cViewTracks::SetTracks(const char * const *tracks) {
+ if (viewList)
+ viewList->SetTracks(tracks);
+ change = true;
+}
+
+void cViewTracks::SetCurrentTrack(int index) {
+ if (viewList)
+ viewList->SetCurrentTrack(index);
+ change = true;
+}
+
+void cViewTracks::Flush(void) {
+ if (init) {
+ sdOsd.LockFlush();
+ Render((int)eVeDisplayTracks::background);
+ }
+ if (change) {
+ Render((int)eVeDisplayTracks::header);
+ if (viewList)
+ viewList->Draw();
+ change = false;
+ }
+ cView::Flush();
+}
diff --git a/coreengine/viewdisplaytracks.h b/coreengine/viewdisplaytracks.h new file mode 100644 index 0000000..c3aea1f --- /dev/null +++ b/coreengine/viewdisplaytracks.h @@ -0,0 +1,29 @@ +#ifndef __VIEWDISPLAYTRACKS_H
+#define __VIEWDISPLAYTRACKS_H
+
+#include "view.h"
+
+class cViewTracks : public cView {
+private:
+ cViewListAudioTracks *viewList;
+ cVeDtBackground *veBackground;
+ cVeDtHeader *veHeader;
+ bool change;
+ void SetViewElements(void);
+ void SetViewElementObjects(void);
+ void ClearVariables(void);
+public:
+ cViewTracks(void);
+ virtual ~cViewTracks(void);
+ void Close(void);
+ void AddViewList(cViewList *viewList);
+ void PreCache(void);
+ void SetTitle(const char *title);
+ void SetNumtracks(int numTracks);
+ void SetTracks(const char * const *tracks);
+ void SetAudiochannel(int audioChannel);
+ void SetCurrentTrack(int index);
+ void Flush(void);
+};
+
+#endif //__VIEWDISPLAYTRACKS_H
\ No newline at end of file diff --git a/coreengine/viewdisplayvolume.c b/coreengine/viewdisplayvolume.c new file mode 100644 index 0000000..2764a67 --- /dev/null +++ b/coreengine/viewdisplayvolume.c @@ -0,0 +1,52 @@ +#include "viewdisplayvolume.h"
+
+/************************************************************************************
+* cViewVolume
+************************************************************************************/
+
+cViewVolume::cViewVolume(void) {
+ viewId = eViewType::DisplayVolume;
+ viewName = strdup("displayvolume");
+ numViewElements = (int)eVeDisplayVolume::count;
+ viewElements = new cViewElement*[numViewElements];
+ for (int i=0; i < numViewElements; i++) {
+ viewElements[i] = NULL;
+ }
+ SetViewElements();
+ ClearVariables();
+ veVolume = NULL;
+}
+
+cViewVolume::~cViewVolume() {
+}
+
+void cViewVolume::SetViewElements(void) {
+ viewElementNames.insert(pair<string, int>("background", (int)eVeDisplayVolume::background));
+ viewElementNames.insert(pair<string, int>("volume", (int)eVeDisplayVolume::volume));
+}
+
+void cViewVolume::SetViewElementObjects(void) {
+ if (!viewElements[(int)eVeDisplayVolume::volume])
+ return;
+ veVolume = dynamic_cast<cVeVolume*>(viewElements[(int)eVeDisplayVolume::volume]);
+}
+
+void cViewVolume::ClearVariables(void) {
+ init = true;
+}
+
+void cViewVolume::SetVolume(int current, int total, bool mute) {
+ if (veVolume)
+ veVolume->Set(current, total, mute);
+}
+
+void cViewVolume::Flush(void) {
+ if (init) {
+ sdOsd.LockFlush();
+ Render((int)eVeDisplayVolume::background);
+ }
+ Render((int)eVeDisplayVolume::volume);
+ cView::Flush();
+}
+
+
diff --git a/coreengine/viewdisplayvolume.h b/coreengine/viewdisplayvolume.h new file mode 100644 index 0000000..b65b3fd --- /dev/null +++ b/coreengine/viewdisplayvolume.h @@ -0,0 +1,19 @@ +#ifndef __VIEWDISPLAYVOLUME_H
+#define __VIEWDISPLAYVOLUME_H
+
+#include "view.h"
+
+class cViewVolume : public cView {
+private:
+ cVeVolume *veVolume;
+ void SetViewElements(void);
+ void SetViewElementObjects(void);
+ void ClearVariables(void);
+public:
+ cViewVolume(void);
+ virtual ~cViewVolume(void);
+ void SetVolume(int current, int total, bool mute);
+ void Flush(void);
+};
+
+#endif //__VIEWDISPLAYVOLUME_H
\ No newline at end of file diff --git a/coreengine/viewelement.c b/coreengine/viewelement.c new file mode 100644 index 0000000..5f6f04b --- /dev/null +++ b/coreengine/viewelement.c @@ -0,0 +1,532 @@ +#include "viewelement.h"
+#include "../config.h"
+
+/******************************************************************
+* cViewElement
+******************************************************************/
+cViewElement::cViewElement(void) {
+ sdOsd = NULL;
+ id = -1;
+ dirty = true;
+ init = true;
+ drawn = false;
+ scrollingStarted = false;
+ blocked = false;
+ detached = false;
+ waitOnWakeup = true;
+ startAnimation = true;
+ globals = NULL;
+ tokenContainer = NULL;
+ attribs = new cViewElementAttribs((int)eViewElementAttribs::count);
+ detacher = NULL;
+ fader = NULL;
+ shifter = NULL;
+}
+
+cViewElement::cViewElement(const cViewElement &other) {
+ sdOsd = other.sdOsd;
+ id = other.id;
+ dirty = other.dirty;
+ init = other.init;
+ drawn = false;
+ scrollingStarted = false;
+ blocked = false;
+ detached = false;
+ waitOnWakeup = true;
+ startAnimation = true;
+ globals = other.globals;
+ container.Set(other.container.X(), other.container.Y(), other.container.Width(), other.container.Height());
+ tokenContainer = NULL;
+ attribs = new cViewElementAttribs(*other.attribs);
+
+ for (cAreaNode *node = other.areaNodes.First(); node; node = other.areaNodes.Next(node)) {
+ if (cArea *a = dynamic_cast<cArea*>(node)) {
+ areaNodes.Add(new cArea(*a));
+ } else if (cAreaContainer *ac = dynamic_cast<cAreaContainer*>(node)) {
+ areaNodes.Add(new cAreaContainer(*ac));
+ }
+ }
+
+ detacher = NULL;
+ fader = NULL;
+ shifter = NULL;
+}
+
+cViewElement::~cViewElement(void) {
+ delete attribs;
+ delete detacher;
+ delete fader;
+ delete shifter;
+ delete tokenContainer;
+}
+
+/******************************************************************
+* Public Functions
+******************************************************************/
+cViewElement *cViewElement::CreateViewElement(const char *name, const char *viewname) {
+ cViewElement *e = NULL;
+
+ //common view elements
+ if (!strcmp(name, "background") && strcmp(viewname, "displayaudiotracks"))
+ e = new cViewElement();
+ else if (!strcmp(name, "datetime"))
+ e = new cVeDateTime();
+ else if (!strcmp(name, "time"))
+ e = new cVeTime();
+ else if (!strcmp(name, "message"))
+ e = new cVeMessage();
+ else if (!strcmp(name, "devices"))
+ e = new cVeDevices();
+ else if (!strcmp(name, "currentweather"))
+ e = new cVeCurrentWeather();
+ else if (!strcmp(name, "customtokens"))
+ e = new cVeCustomTokens();
+
+ //displaychannel viewelements
+ else if (!strcmp(name, "channelinfo"))
+ e = new cVeDcChannelInfo();
+ else if (!strcmp(name, "channelgroup"))
+ e = new cVeDcChannelGroup();
+ else if (!strcmp(name, "epginfo"))
+ e = new cVeDcEpgInfo();
+ else if (!strcmp(name, "progressbar") && !strcmp(viewname, "displaychannel"))
+ e = new cVeDcProgressBar();
+ else if (!strcmp(name, "statusinfo"))
+ e = new cVeDcStatusInfo();
+ else if (!strcmp(name, "audioinfo"))
+ e = new cVeDcAudioInfo();
+ else if (!strcmp(name, "screenresolution"))
+ e = new cVeDcScreenResolution();
+ else if (!strcmp(name, "signalquality"))
+ e = new cVeDcSignalQuality();
+ else if (!strcmp(name, "scrapercontent") && !strcmp(viewname, "displaychannel"))
+ e = new cVeDcScraperContent();
+ else if (!strcmp(name, "ecminfo"))
+ e = new cVeDcEcmInfo();
+
+ //displaymenu viewelements
+ else if (!strcmp(name, "header") && strcmp(viewname, "displayaudiotracks"))
+ e = new cVeDmHeader();
+ else if (!strcmp(name, "sortmode"))
+ e = new cVeDmSortmode();
+ else if (!strcmp(name, "colorbuttons"))
+ e = new cVeDmColorbuttons();
+ else if (!strcmp(name, "scrollbar"))
+ e = new cVeDmScrollbar();
+ else if (!strcmp(name, "timers"))
+ e = new cVeDmTimers();
+ else if (!strcmp(name, "currentschedule"))
+ e = new cVeDmCurrentschedule();
+ else if (!strcmp(name, "discusage"))
+ e = new cVeDmDiscusage();
+ else if (!strcmp(name, "systemload"))
+ e = new cVeDmSystemload();
+ else if (!strcmp(name, "systemmemory"))
+ e = new cVeDmSystemmemory();
+ else if (!strcmp(name, "temperatures"))
+ e = new cVeDmTemperatures();
+ else if (!strcmp(name, "vdrstatistics"))
+ e = new cVeDmVdrstatistics();
+ else if (!strcmp(name, "lastrecordings"))
+ e = new cVeDmLastrecordings();
+ else if (!strcmp(name, "detailheaderepg"))
+ e = new cVeDmDetailheaderEpg();
+ else if (!strcmp(name, "detailheaderrec"))
+ e = new cVeDmDetailheaderRec();
+ else if (!strcmp(name, "detailheaderplugin"))
+ e = new cVeDmDetailheaderPlugin();
+ else if (!strcmp(name, "tablabels"))
+ e = new cVeDmTablabels();
+
+ //displayreplay viewelements
+ else if (!strcmp(name, "backgroundmodeonly"))
+ e = new cViewElement();
+ else if (!strcmp(name, "rectitle"))
+ e = new cVeDrRecTitle();
+ else if (!strcmp(name, "recinfo"))
+ e = new cVeDrRecInfo();
+ else if (!strcmp(name, "currenttime"))
+ e = new cVeDrCurrentTime();
+ else if (!strcmp(name, "totaltime"))
+ e = new cVeDrTotalTime();
+ else if (!strcmp(name, "endtime"))
+ e = new cVeDrEndTime();
+ else if (!strcmp(name, "progressbar") && !strcmp(viewname, "displayreplay"))
+ e = new cVeDrProgressBar();
+ else if (!strcmp(name, "cutmarks"))
+ e = new cVeDrCutMarks();
+ else if (!strcmp(name, "controlicons"))
+ e = new cVeDrControlIcons();
+ else if (!strcmp(name, "controliconsmodeonly"))
+ e = new cVeDrControlIcons();
+ else if (!strcmp(name, "progressmodeonly"))
+ e = new cVeDrProgressModeonly();
+ else if (!strcmp(name, "jump"))
+ e = new cVeDrJump();
+ else if (!strcmp(name, "onpause"))
+ e = new cVeDrOnPause();
+ else if (!strcmp(name, "onpausemodeonly"))
+ e = new cVeDrOnPause();
+ else if (!strcmp(name, "scrapercontent") && !strcmp(viewname, "displayreplay"))
+ e = new cVeDrScraperContent();
+
+ //displayvolume viewelements
+ else if (!strcmp(name, "volume"))
+ e = new cVeVolume();
+
+ //displayvolume viewelements
+ else if (!strcmp(name, "background") && !strcmp(viewname, "displayaudiotracks"))
+ e = new cVeDtBackground();
+ else if (!strcmp(name, "header") && !strcmp(viewname, "displayaudiotracks"))
+ e = new cVeDtHeader();
+
+ //default
+ else {
+ dsyslog("skindesigner: unknown view element %s", name);
+ e = new cViewElement();
+ }
+
+ return e;
+}
+
+void cViewElement::SetGlobals(cGlobals *globals) {
+ this->globals = globals;
+ attribs->SetGlobals(globals);
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetGlobals(globals);
+ }
+}
+
+void cViewElement::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ InheritTokenContainer();
+}
+
+bool cViewElement::Detached(void) {
+ return detached;
+}
+
+void cViewElement::SetContainer(int x, int y, int width, int height) {
+ container.SetX(x);
+ container.SetY(y);
+ container.SetWidth(width);
+ container.SetHeight(height);
+}
+
+void cViewElement::SetAttributes(vector<stringpair> &attributes) {
+ attribs->Set(attributes);
+}
+
+void cViewElement::AddArea(cAreaNode *area) {
+ areaNodes.Add(area);
+}
+
+void cViewElement::SetAreaX(int x) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetX(x);
+ }
+}
+
+void cViewElement::SetAreaY(int y) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetY(y);
+ }
+}
+
+void cViewElement::SetAreaWidth(int width) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetWidth(width);
+ }
+}
+
+void cViewElement::SetAreaHeight(int height) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetHeight(height);
+ }
+}
+
+void cViewElement::SetPosition(int newX, int newY, int newWidth, int newHeight) {
+ cRect newPos(newX, newY, newWidth, newHeight);
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetViewPort(newPos);
+ }
+}
+
+void cViewElement::Cache(void) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Cache();
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ node->Cache();
+ }
+}
+
+bool cViewElement::Execute(void) {
+ return attribs->DoExecute();
+}
+
+void cViewElement::Clear(void) {
+ tokenContainer->Clear();
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ sdOsd->Lock();
+ node->Clear();
+ sdOsd->Unlock();
+ }
+ dirty = false;
+ drawn = false;
+ scrollingStarted = false;
+}
+
+void cViewElement::Hide(void) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ sdOsd->Lock();
+ node->Hide();
+ sdOsd->Unlock();
+ }
+ init = true;
+ StopScrolling();
+}
+
+void cViewElement::Show(void) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ sdOsd->Lock();
+ node->Show();
+ sdOsd->Unlock();
+ }
+}
+
+void cViewElement::WakeUp(void) {
+ if (!detacher || !waitOnWakeup) {
+ return;
+ }
+ detacher->WakeUp();
+}
+
+void cViewElement::Close(void) {
+ delete detacher;
+ detacher = NULL;
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ sdOsd->Lock();
+ node->Close();
+ sdOsd->Unlock();
+ }
+ StopScrolling();
+ dirty = true;
+ init = true;
+ startAnimation = true;
+ drawn = false;
+ scrollingStarted = false;
+ blocked = false;
+}
+
+void cViewElement::Render(void) {
+ if (!dirty || blocked)
+ return;
+
+ if (attribs->DoDebug())
+ Debug();
+
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ //Check redraw of already scrolling list element
+ if (drawn && scrollingStarted && node->Scrolling()) {
+ if (DoScroll()) {
+ //current list element
+ continue;
+ } else {
+ //not current list element anymore
+ scrollingStarted = false;
+ }
+ }
+ sdOsd->Lock();
+ node->Clear();
+ sdOsd->Unlock();
+ if (!node->Execute())
+ continue;
+ if (node->BackgroundArea() && drawn)
+ continue;
+ sdOsd->Lock();
+ node->Render();
+ sdOsd->Unlock();
+
+ if (DoScroll() && node->Scrolling()) {
+ cArea *scrollArea = node->ScrollingArea();
+ if (scrollArea) {
+ scrollingStarted = true;
+ cAnimation *scroller = new cAnimation(scrollArea);
+ scrollers.Add(scroller);
+ scroller->Start();
+ }
+ }
+ }
+ dirty = false;
+ drawn = true;
+ if (startAnimation) {
+ startAnimation = false;
+ StartAnimation();
+ }
+}
+
+void cViewElement::StopScrolling(bool deletePixmaps) {
+ for (cAnimation *scroller = scrollers.First(); scroller; scroller = scrollers.Next(scroller)) {
+ scroller->Stop(deletePixmaps);
+ }
+ scrollers.Clear();
+}
+
+void cViewElement::ParseDetached(void) {
+ Parse(true);
+}
+
+void cViewElement::RenderDetached(void) {
+ blocked = false;
+ Render();
+}
+
+bool cViewElement::Shifting(void) {
+ if (attribs->ShiftTime() >= 0) {
+ return true;
+ }
+ return false;
+}
+
+bool cViewElement::Fading(void) {
+ if (attribs->FadeTime() >= 0) {
+ return true;
+ }
+ return false;
+}
+
+int cViewElement::FadeTime(void) {
+ return attribs->FadeTime();
+}
+
+int cViewElement::ShiftTime(void) {
+ return attribs->ShiftTime();
+}
+
+int cViewElement::ShiftMode(void) {
+ return attribs->ShiftMode();
+}
+
+void cViewElement::StartAnimation(void) {
+ if (ShiftTime() > 0) {
+ cRect shiftbox = CoveredArea();
+ cPoint ref = cPoint(shiftbox.X(), shiftbox.Y());
+ cPoint start = ShiftStart(shiftbox);
+ SetPosition(start, ref);
+ sdOsd->Flush();
+ delete shifter;
+ shifter = new cAnimation((cShiftable*)this, start, ref, true);
+ shifter->Start();
+ } else if (FadeTime() > 0) {
+ SetTransparency(100);
+ sdOsd->Flush();
+ delete fader;
+ fader = new cAnimation((cFadable*)this, true);
+ fader->Start();
+ }
+}
+
+void cViewElement::SetTransparency(int transparency, bool force) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ sdOsd->Lock();
+ node->SetTransparency(transparency);
+ sdOsd->Unlock();
+ }
+}
+
+void cViewElement::SetPosition(cPoint &position, cPoint &reference, bool force) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ sdOsd->Lock();
+ node->SetPosition(position, reference);
+ sdOsd->Unlock();
+ }
+}
+
+cRect cViewElement::CoveredArea(void) {
+ cRect unionArea;
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ unionArea.Combine(node->CoveringArea());
+ }
+ return unionArea;
+}
+
+void cViewElement::Flush(void) {
+ sdOsd->Flush();
+}
+
+bool cViewElement::Parse(bool forced) {
+ if (blocked && !forced) {
+ return false;
+ }
+ if (!Detached() || !init) {
+ return true;
+ }
+ delete detacher;
+ detacher = new cAnimation((cDetachable*)this, waitOnWakeup, startAnimation);
+ detacher->Start();
+ startAnimation = false;
+ init = false;
+ blocked = true;
+ return false;
+}
+
+cFunction *cViewElement::GetFunction(const char *name) {
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ if (cFunction *f = node->GetFunction(name))
+ return f;
+ }
+ return NULL;
+}
+
+void cViewElement::Debug(bool full) {
+ esyslog("skindesigner: ---> viewElement %d", id);
+ tokenContainer->Debug();
+ esyslog("skindesigner: container %d %d %dx%d", container.X(), container.Y(), container.Width(), container.Height());
+ attribs->Debug();
+ if (!full)
+ return;
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->Debug(full);
+ }
+}
+
+/******************************************************************
+* protected Functions
+******************************************************************/
+void cViewElement::InheritTokenContainer(void) {
+ tokenContainer->CreateContainers();
+ attribs->SetTokenContainer(tokenContainer);
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetTokenContainer(tokenContainer);
+ }
+}
+
+void cViewElement::InheritTokenContainerDeep(void) {
+ tokenContainer->CreateContainers();
+ attribs->SetTokenContainerDeep(tokenContainer);
+ for (cAreaNode *node = areaNodes.First(); node; node = areaNodes.Next(node)) {
+ node->SetTokenContainerDeep(tokenContainer);
+ }
+}
+
+cPoint cViewElement::ShiftStart(cRect &shiftbox) {
+ eShiftType type = (eShiftType)attribs->ShiftType();
+ cPoint start;
+ if (type == eShiftType::none) {
+ start = attribs->ShiftStartpoint();
+ } else if (type == eShiftType::left) {
+ start.SetX(-shiftbox.Width());
+ start.SetY(shiftbox.Y());
+ } else if (type == eShiftType::right) {
+ start.SetX(cOsd::OsdWidth());
+ start.SetY(shiftbox.Y());
+ } else if (type == eShiftType::top) {
+ start.SetX(shiftbox.X());
+ start.SetY(-shiftbox.Height());
+ } else if (type == eShiftType::bottom) {
+ start.SetX(shiftbox.X());
+ start.SetY(cOsd::OsdHeight());
+ }
+ return start;
+}
\ No newline at end of file diff --git a/coreengine/viewelement.h b/coreengine/viewelement.h new file mode 100644 index 0000000..af12a6c --- /dev/null +++ b/coreengine/viewelement.h @@ -0,0 +1,93 @@ +#ifndef __VIEWELEMENT_H
+#define __VIEWELEMENT_H
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <vdr/tools.h>
+#include "osdwrapper.h"
+#include "globals.h"
+#include "../libskindesignerapi/tokencontainer.h"
+#include "area.h"
+#include "animation.h"
+
+/******************************************************************
+* cViewElement
+******************************************************************/
+class cViewElement : public cDetachable, public cFadable, public cShiftable {
+protected:
+ cSdOsd *sdOsd;
+ int id;
+ bool init;
+ bool drawn;
+ bool dirty;
+ bool blocked;
+ bool detached;
+ bool waitOnWakeup;
+ bool scrollingStarted;
+ bool startAnimation;
+ cGlobals *globals;
+ cRect container;
+ cViewElementAttribs *attribs;
+ cList<cAreaNode> areaNodes;
+ skindesignerapi::cTokenContainer *tokenContainer;
+ cList<cAnimation> scrollers;
+ cAnimation *detacher;
+ cAnimation *fader;
+ cAnimation *shifter;
+ void InheritTokenContainer(void);
+ void InheritTokenContainerDeep(void);
+ virtual bool DoScroll(void) { return true; };
+ cPoint ShiftStart(cRect &shiftbox);
+public:
+ cViewElement(void);
+ cViewElement(const cViewElement &other);
+ virtual ~cViewElement(void);
+ void SetOsd(cSdOsd *osd) { sdOsd = osd; };
+ static cViewElement *CreateViewElement(const char *name, const char *viewname);
+ void SetId(int id) { this->id = id; };
+ void SetGlobals(cGlobals *globals);
+ virtual void SetTokenContainer(void);
+ void SetDetached(void) { detached = true; };
+ void UnsetWaitOnWakeup(void) { waitOnWakeup = false; };
+ bool Detached(void);
+ void SetContainer(int x, int y, int width, int height);
+ void SetAttributes(vector<stringpair> &attributes);
+ void AddArea(cAreaNode *area);
+ void SetAreaX(int x);
+ void SetAreaY(int y);
+ void SetAreaWidth(int width);
+ void SetAreaHeight(int height);
+ void Cache(void);
+ virtual void Close(void);
+ virtual void Clear(void);
+ void Hide(void);
+ void Show(void);
+ void WakeUp(void);
+ bool Execute(void);
+ void SetDirty(void) { dirty = true; };
+ bool Dirty(void) { return dirty; };
+ void SetPosition(int newX, int newY, int newWidth, int newHeight);
+ virtual void Render(void);
+ void StopScrolling(bool deletePixmaps = true);
+ eOrientation Orientation(void) { return attribs->Orientation(); };
+ virtual int Delay(void) { return attribs->Delay(); };
+ void ParseDetached(void);
+ void RenderDetached(void);
+ bool Shifting(void);
+ bool Fading(void);
+ int FadeTime(void);
+ int ShiftTime(void);
+ int ShiftMode(void);
+ void StartAnimation(void);
+ virtual void SetTransparency(int transparency, bool force = false);
+ virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false);
+ cRect CoveredArea(void);
+ void Flush(void);
+ virtual bool Parse(bool forced = false);
+ cFunction *GetFunction(const char *name);
+ virtual void Debug(bool full = false);
+};
+
+#endif //__VIEWELEMENT_H
\ No newline at end of file diff --git a/coreengine/viewelementplugin.c b/coreengine/viewelementplugin.c new file mode 100644 index 0000000..7d50a82 --- /dev/null +++ b/coreengine/viewelementplugin.c @@ -0,0 +1,36 @@ +#include "viewelementplugin.h"
+#include "../config.h"
+
+cVePlugin::cVePlugin(void) {
+ plugId = -1;
+ viewId = -1;
+}
+
+cVePlugin::~cVePlugin(void) {
+}
+
+void cVePlugin::Close(void) {
+ cViewElement::Close();
+}
+
+void cVePlugin::SetTokenContainer(void) {
+ skindesignerapi::cTokenContainer *tkVe = plgManager->GetTokenContainerVE(plugId, viewId, id);
+ if (!tkVe)
+ return;
+ tokenContainer = new skindesignerapi::cTokenContainer(*tkVe);
+ InheritTokenContainer();
+}
+
+void cVePlugin::Set(skindesignerapi::cTokenContainer *tk) {
+ tokenContainer->Clear();
+ tokenContainer->SetTokens(tk);
+ SetDirty();
+}
+
+bool cVePlugin::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!dirty)
+ return false;
+ return true;
+}
diff --git a/coreengine/viewelementplugin.h b/coreengine/viewelementplugin.h new file mode 100644 index 0000000..8e2d5f1 --- /dev/null +++ b/coreengine/viewelementplugin.h @@ -0,0 +1,22 @@ +#ifndef __VIEWELEMENTPLUGIN_H
+#define __VIEWELEMENTPLUGIN_H
+
+#include "viewelement.h"
+
+class cVePlugin : public cViewElement {
+private:
+ int plugId;
+ int viewId;
+public:
+ cVePlugin(void);
+ virtual ~cVePlugin(void);
+ void SetPluginId(int plugId) { this->plugId = plugId; };
+ void SetViewId(int viewId) { this->viewId = viewId; };
+ void Close(void);
+ void SetTokenContainer(void);
+ void Set(skindesignerapi::cTokenContainer *tk);
+ bool Parse(bool forced = false);
+ const char *Name(void) { return attribs->Name(); };
+};
+
+#endif //__VIEWELEMENTPLUGIN_H
diff --git a/coreengine/viewelementscommon.c b/coreengine/viewelementscommon.c new file mode 100644 index 0000000..92538e5 --- /dev/null +++ b/coreengine/viewelementscommon.c @@ -0,0 +1,531 @@ +#include "viewelementscommon.h"
+#include "../config.h"
+#include "../services/weatherforecast.h"
+
+/******************************************************************
+* cVeDateTime
+******************************************************************/
+cVeDateTime::cVeDateTime(void) {
+ lastMinute = -1;
+}
+
+cVeDateTime::~cVeDateTime(void) {
+}
+
+void cVeDateTime::Close(void) {
+ lastMinute = -1;
+ cViewElement::Close();
+}
+
+void cVeDateTime::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{time}", (int)eDateTimeST::time);
+ tokenContainer->DefineStringToken("{dayleadingzero}", (int)eDateTimeST::dayleadingzero);
+ tokenContainer->DefineStringToken("{dayname}", (int)eDateTimeST::dayname);
+ tokenContainer->DefineStringToken("{daynameshort}", (int)eDateTimeST::daynameshort);
+ tokenContainer->DefineStringToken("{month}", (int)eDateTimeST::month);
+ tokenContainer->DefineStringToken("{monthname}", (int)eDateTimeST::monthname);
+ tokenContainer->DefineStringToken("{monthnameshort}", (int)eDateTimeST::monthnameshort);
+ tokenContainer->DefineIntToken("{day}", (int)eDateTimeIT::day);
+ tokenContainer->DefineIntToken("{year}", (int)eDateTimeIT::year);
+ InheritTokenContainer();
+}
+
+bool cVeDateTime::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ 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;
+ SetDirty();
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDateTimeIT::year, now->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eDateTimeIT::day, now->tm_mday);
+
+ char monthname[20];
+ char monthshort[10];
+ strftime(monthshort, sizeof(monthshort), "%b", now);
+ strftime(monthname, sizeof(monthname), "%B", now);
+
+ tokenContainer->AddStringToken((int)eDateTimeST::monthname, monthname);
+ tokenContainer->AddStringToken((int)eDateTimeST::monthnameshort, monthshort);
+ tokenContainer->AddStringToken((int)eDateTimeST::month, *cString::sprintf("%02d", now->tm_mon + 1));
+ tokenContainer->AddStringToken((int)eDateTimeST::dayleadingzero, *cString::sprintf("%02d", now->tm_mday));
+ tokenContainer->AddStringToken((int)eDateTimeST::dayname, *WeekDayNameFull(now->tm_wday));
+ tokenContainer->AddStringToken((int)eDateTimeST::daynameshort, *WeekDayName(now->tm_wday));
+ tokenContainer->AddStringToken((int)eDateTimeST::time, *TimeString(t));
+ return true;
+}
+
+/******************************************************************
+* cVeTime
+******************************************************************/
+cVeTime::cVeTime(void) {
+ lastSecond = -1;
+}
+
+cVeTime::~cVeTime(void) {
+}
+
+void cVeTime::Close(void) {
+ lastSecond = -1;
+ cViewElement::Close();
+}
+
+void cVeTime::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{sec}", (int)eTimeIT::sec);
+ tokenContainer->DefineIntToken("{min}", (int)eTimeIT::min);
+ tokenContainer->DefineIntToken("{hour}", (int)eTimeIT::hour);
+ tokenContainer->DefineIntToken("{hmins}", (int)eTimeIT::hmins);
+ InheritTokenContainer();
+}
+
+bool cVeTime::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ time_t t = time(0); // get time now
+ struct tm * now = localtime(&t);
+ int sec = now->tm_sec;
+ if (!forced && sec == lastSecond) {
+ return false;
+ }
+ lastSecond = sec;
+ SetDirty();
+
+ int min = now->tm_min;
+ int hour = now->tm_hour;
+ int hourMinutes = hour%12 * 5 + min / 12;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eTimeIT::sec, sec);
+ tokenContainer->AddIntToken((int)eTimeIT::min, min);
+ tokenContainer->AddIntToken((int)eTimeIT::hour, hour);
+ tokenContainer->AddIntToken((int)eTimeIT::hmins, hourMinutes);
+ return true;
+}
+/******************************************************************
+* cVeMessage
+******************************************************************/
+cVeMessage::cVeMessage(void) {
+ changed = false;
+ text = NULL;
+ type = mtStatus;
+}
+
+cVeMessage::~cVeMessage(void) {
+ free(text);
+}
+
+void cVeMessage::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{text}", (int)eMessageST::text);
+ tokenContainer->DefineIntToken("{status}", (int)eMessageIT::status);
+ tokenContainer->DefineIntToken("{info}", (int)eMessageIT::info);
+ tokenContainer->DefineIntToken("{warning}", (int)eMessageIT::warning);
+ tokenContainer->DefineIntToken("{error}", (int)eMessageIT::error);
+ InheritTokenContainer();
+}
+
+void cVeMessage::Set(eMessageType type, const char *text) {
+ if (!text)
+ return;
+ free(this->text);
+ this->text = strdup(text);
+ this->type = type;
+ changed = true;
+}
+
+bool cVeMessage::Parse(bool forced) {
+ if (!cViewElement::Parse(forced) || !changed)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eMessageIT::status, (type == mtStatus) ? true : false);
+ tokenContainer->AddIntToken((int)eMessageIT::info, (type == mtInfo) ? true : false);
+ tokenContainer->AddIntToken((int)eMessageIT::warning, (type == mtWarning) ? true : false);
+ tokenContainer->AddIntToken((int)eMessageIT::error, (type == mtError) ? true : false);
+ tokenContainer->AddStringToken((int)eMessageST::text, text);
+ SetDirty();
+ changed = false;
+ return true;
+}
+
+/******************************************************************
+* cVeDevices
+******************************************************************/
+cVeDevices::cVeDevices(void) {
+ lastRefresh = 0;
+ initial = true;
+ devicesIndex = -1;
+ lastSignalStrength = NULL;
+ lastSignalQuality = NULL;
+ recDevices = NULL;
+}
+
+cVeDevices::~cVeDevices(void) {
+ mutexDevices.Lock();
+ delete[] lastSignalStrength;
+ lastSignalStrength = NULL;
+ delete[] lastSignalQuality;
+ lastSignalQuality = NULL;
+ delete[] recDevices;
+ recDevices = NULL;
+ mutexDevices.Unlock();
+}
+
+void cVeDevices::Init(void) {
+ light = (attribs->Mode() == (int)eViewElementMode::light) ? true : false;
+ int totalDevices = cDevice::NumDevices();
+ for (int i = 0; i < totalDevices; i++) {
+ const cDevice *device = cDevice::GetDevice(i);
+ if (!device || !device->NumProvidedSystems()) {
+ continue;
+ }
+ devices.push_back(i);
+ }
+ numDevices = devices.size();
+ 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();
+}
+
+void cVeDevices::Close(void) {
+ devices.clear();
+ initial = true;
+ numDevices = 0;
+ mutexDevices.Lock();
+ delete[] lastSignalStrength;
+ lastSignalStrength = NULL;
+ delete[] lastSignalQuality;
+ lastSignalQuality = NULL;
+ delete[] recDevices;
+ recDevices = NULL;
+ mutexDevices.Unlock();
+ cViewElement::Close();
+}
+
+void cVeDevices::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{numdevices}", (int)eDevicesIT::numdevices);
+ tokenContainer->DefineLoopToken("{devices[num]}", (int)eDevicesLT::num);
+ tokenContainer->DefineLoopToken("{devices[type]}", (int)eDevicesLT::type);
+ tokenContainer->DefineLoopToken("{devices[istuned]}", (int)eDevicesLT::istuned);
+ tokenContainer->DefineLoopToken("{devices[livetv]}", (int)eDevicesLT::livetv);
+ tokenContainer->DefineLoopToken("{devices[recording]}", (int)eDevicesLT::recording);
+ tokenContainer->DefineLoopToken("{devices[hascam]}", (int)eDevicesLT::hascam);
+ tokenContainer->DefineLoopToken("{devices[cam]}", (int)eDevicesLT::cam);
+ tokenContainer->DefineLoopToken("{devices[signalstrength]}", (int)eDevicesLT::signalstrength);
+ tokenContainer->DefineLoopToken("{devices[signalquality]}", (int)eDevicesLT::signalquality);
+ tokenContainer->DefineLoopToken("{devices[channelnumber]}", (int)eDevicesLT::channelnumber);
+ tokenContainer->DefineLoopToken("{devices[channelname]}", (int)eDevicesLT::channelname);
+ tokenContainer->DefineLoopToken("{devices[channellogoexists]}", (int)eDevicesLT::channellogoexists);
+ tokenContainer->DefineLoopToken("{devices[channelid]}", (int)eDevicesLT::channelid);
+ tokenContainer->DefineLoopToken("{devices[source]}", (int)eDevicesLT::source);
+
+ devicesIndex = tokenContainer->LoopIndex("devices");
+ InheritTokenContainer();
+}
+
+bool cVeDevices::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (initial) {
+ Init();
+ initial = false;
+ } else {
+ //in light modus content is static
+ if (light)
+ return false;
+ //check if drawing is necessary
+ if (lastRefresh - cTimeMs::Now() < 500)
+ return false;
+ bool changed = false;
+ for (int i = 0; i < numDevices; i++) {
+ const cDevice *device = cDevice::GetDevice(devices[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();
+ }
+ }
+ }
+
+ //create loop container
+ tokenContainer->Clear();
+
+ vector<int> loopInfo;
+ loopInfo.push_back(numDevices);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+ tokenContainer->AddIntToken((int)eDevicesIT::numdevices, numDevices);
+
+ for (int i = 0; i < numDevices; i++) {
+ const cDevice *device = cDevice::GetDevice(devices[i]);
+ if (!device || !device->NumProvidedSystems()) {
+ continue;
+ }
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::num, *cString::sprintf("%d", i));
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::type, *(device->DeviceType()));
+
+ cCamSlot *camSlot = device->CamSlot();
+ int camNumber = -1;
+ if (camSlot) {
+ camNumber = camSlot->SlotNumber();
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::hascam, "1");
+ } else {
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::hascam, "0");
+ }
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::cam, *cString::sprintf("%d", camNumber));
+
+ int signalStrength = 0;
+ int signalQuality = 0;
+ if (!light) {
+ signalStrength = device->SignalStrength();
+ signalQuality = device->SignalQuality();
+ }
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::signalstrength, *cString::sprintf("%d", signalStrength));
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::signalstrength, *cString::sprintf("%d", signalQuality));
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::livetv, i == deviceLiveTV ? "1" : "0");
+
+ bool isRecording = false;
+ mutexDevices.Lock();
+ if (recDevices && recDevices[i])
+ isRecording = true;
+ mutexDevices.Unlock();
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::recording, isRecording ? "1" : "0");
+
+ const cChannel *channel = device->GetCurrentlyTunedTransponder();
+ const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
+ if (channel && channel->Number() > 0) {
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channelnumber, *cString::sprintf("%d", channel->Number()));
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channelname, channel->Name());
+ string channelID = *(channel->GetChannelID().ToString());
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channelid, channelID.c_str());
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::channellogoexists, imgCache->LogoExists(channelID) ? "1" : "0");
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::istuned, "1");
+ } else {
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::istuned, "0");
+ }
+
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::source, source ? source->Description() : "");
+
+ mutexDevices.Lock();
+ if (lastSignalStrength)
+ lastSignalStrength[i] = signalStrength;
+ if (lastSignalQuality)
+ lastSignalQuality[i] = signalQuality;
+ mutexDevices.Unlock();
+ }
+
+ SetDirty();
+ lastRefresh = cTimeMs::Now();
+ return true;
+}
+/******************************************************************
+* cVeCurrentWeather
+******************************************************************/
+cVeCurrentWeather::cVeCurrentWeather(void) {
+}
+
+cVeCurrentWeather::~cVeCurrentWeather(void) {
+}
+
+void cVeCurrentWeather::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{timestamp}", (int)eCurrentWeatherST::timestamp);
+ tokenContainer->DefineStringToken("{summary}", (int)eCurrentWeatherST::summary);
+ tokenContainer->DefineStringToken("{icon}", (int)eCurrentWeatherST::icon);
+ tokenContainer->DefineStringToken("{precipitationtype}", (int)eCurrentWeatherST::precipitationtype);
+ tokenContainer->DefineStringToken("{windbearingstring}", (int)eCurrentWeatherST::windbearingstring);
+ tokenContainer->DefineStringToken("{temperature}", (int)eCurrentWeatherST::temperature);
+ tokenContainer->DefineStringToken("{apparenttemperature}", (int)eCurrentWeatherST::apparenttemperature);
+ tokenContainer->DefineStringToken("{mintemperature}", (int)eCurrentWeatherST::mintemperature);
+ tokenContainer->DefineStringToken("{maxtemperature}", (int)eCurrentWeatherST::maxtemperature);
+ tokenContainer->DefineStringToken("{precipitationintensity}", (int)eCurrentWeatherST::precipitationintensity);
+ tokenContainer->DefineStringToken("{windspeed}", (int)eCurrentWeatherST::windspeed);
+ tokenContainer->DefineStringToken("{visibility}", (int)eCurrentWeatherST::visibility);
+ tokenContainer->DefineStringToken("{pressure}", (int)eCurrentWeatherST::pressure);
+ tokenContainer->DefineStringToken("{ozone}", (int)eCurrentWeatherST::ozone);
+ tokenContainer->DefineIntToken("{precipitationprobability}", (int)eCurrentWeatherIT::precipitationprobability);
+ tokenContainer->DefineIntToken("{humidity}", (int)eCurrentWeatherIT::humidity);
+ tokenContainer->DefineIntToken("{windbearing}", (int)eCurrentWeatherIT::windbearing);
+ tokenContainer->DefineIntToken("{cloudcover}", (int)eCurrentWeatherIT::cloudcover);
+ InheritTokenContainer();
+}
+
+bool cVeCurrentWeather::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ static cPlugin *pWeatherForecast = cPluginManager::GetPlugin("weatherforecast");
+ if (!pWeatherForecast)
+ return false;
+ cServiceCurrentWeather currentWeather;
+ if (!pWeatherForecast->Service("GetCurrentWeather", ¤tWeather)) {
+ return false;
+ }
+ SetDirty();
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::timestamp, currentWeather.timeStamp.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::temperature, currentWeather.temperature.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::apparenttemperature, currentWeather.apparentTemperature.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::mintemperature, currentWeather.minTemperature.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::maxtemperature, currentWeather.maxTemperature.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::summary, currentWeather.summary.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::icon, currentWeather.icon.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::precipitationintensity, currentWeather.precipitationIntensity.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::precipitationtype, currentWeather.precipitationType.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::windspeed, currentWeather.windSpeed.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::windbearingstring, currentWeather.windBearingString.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::visibility, currentWeather.visibility.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::pressure, currentWeather.pressure.c_str());
+ tokenContainer->AddStringToken((int)eCurrentWeatherST::ozone, currentWeather.ozone.c_str());
+ tokenContainer->AddIntToken((int)eCurrentWeatherIT::precipitationprobability, currentWeather.precipitationProbability);
+ tokenContainer->AddIntToken((int)eCurrentWeatherIT::humidity, currentWeather.humidity);
+ tokenContainer->AddIntToken((int)eCurrentWeatherIT::windbearing, currentWeather.windBearing);
+ tokenContainer->AddIntToken((int)eCurrentWeatherIT::cloudcover, currentWeather.cloudCover);
+ return true;
+}
+/******************************************************************
+* cVeCustomTokens
+******************************************************************/
+cVeCustomTokens::cVeCustomTokens(void) {
+}
+
+cVeCustomTokens::~cVeCustomTokens(void) {
+}
+
+void cVeCustomTokens::Reset(void) {
+ globals->ResetCustomTokenChange();
+}
+
+void cVeCustomTokens::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ int numTokens = config.numCustomTokens;
+ for (int i=0; i < numTokens; i++) {
+ cString nameIntToken = cString::sprintf("{customint%d}", i+1);
+ cString nameStringToken = cString::sprintf("{customstring%d}", i+1);
+ tokenContainer->DefineStringToken(*nameStringToken, i);
+ tokenContainer->DefineIntToken(*nameIntToken, i);
+ }
+ InheritTokenContainer();
+}
+
+bool cVeCustomTokens::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ if (!globals->CustomTokenChange())
+ return false;
+
+ tokenContainer->Clear();
+ map <int, string> customStringTokens = globals->GetCustomStringTokens();
+ for (map<int, string>::iterator it = customStringTokens.begin(); it != customStringTokens.end(); it++) {
+ int index = it->first;
+ if (index > 0 && index <= config.numCustomTokens) {
+ tokenContainer->AddStringToken(index-1, it->second.c_str());
+ }
+ }
+ map <int, int> customIntTokkens = globals-> GetCustomIntTokens();
+ for (map<int, int>::iterator it = customIntTokkens.begin(); it != customIntTokkens.end(); it++) {
+ int index = it->first;
+ if (index > 0 && index <= config.numCustomTokens) {
+ tokenContainer->AddIntToken(index-1, it->second);
+ }
+ }
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeVolume
+******************************************************************/
+cVeVolume::cVeVolume(void) {
+ current = 0;
+ total = 0;
+ mute = false;
+ changed = true;
+}
+
+cVeVolume::~cVeVolume(void) {
+}
+
+void cVeVolume::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{volume}", (int)eDVVolumeIT::volume);
+ tokenContainer->DefineIntToken("{volpercent}", (int)eDVVolumeIT::volpercent);
+ tokenContainer->DefineIntToken("{maxvolume}", (int)eDVVolumeIT::maxvolume);
+ tokenContainer->DefineIntToken("{mute}", (int)eDVVolumeIT::mute);
+ InheritTokenContainer();
+}
+
+void cVeVolume::Set(int current, int total, bool mute) {
+ this->current = current;
+ this->total = total;
+ this->mute = mute;
+ changed = true;
+}
+
+bool cVeVolume::Parse(bool forced) {
+ if (!cViewElement::Parse(forced) || !changed)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDVVolumeIT::volume, current);
+ tokenContainer->AddIntToken((int)eDVVolumeIT::maxvolume, total);
+ tokenContainer->AddIntToken((int)eDVVolumeIT::volpercent, (double)current *100 / (double)total);
+ tokenContainer->AddIntToken((int)eDVVolumeIT::mute, mute);
+ changed = false;
+ SetDirty();
+ return true;
+}
\ No newline at end of file diff --git a/coreengine/viewelementscommon.h b/coreengine/viewelementscommon.h new file mode 100644 index 0000000..b373bc9 --- /dev/null +++ b/coreengine/viewelementscommon.h @@ -0,0 +1,110 @@ +#ifndef __VIEWELEMENTSCOMMON_H
+#define __VIEWELEMENTSCOMMON_H
+
+#include <vdr/menu.h>
+#include "viewelement.h"
+
+/******************************************************************
+* cVeDateTime
+******************************************************************/
+class cVeDateTime : public cViewElement {
+private:
+ int lastMinute;
+public:
+ cVeDateTime(void);
+ virtual ~cVeDateTime(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeTime
+******************************************************************/
+class cVeTime : public cViewElement {
+private:
+ int lastSecond;
+public:
+ cVeTime(void);
+ virtual ~cVeTime(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeMessage
+******************************************************************/
+class cVeMessage : public cViewElement {
+private:
+ bool changed;
+ eMessageType type;
+ char *text;
+public:
+ cVeMessage(void);
+ virtual ~cVeMessage(void);
+ void SetTokenContainer(void);
+ void Set(eMessageType type, const char *text);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeDevices
+******************************************************************/
+class cVeDevices : public cViewElement {
+private:
+ bool light;
+ time_t lastRefresh;
+ vector<int> devices;
+ bool initial;
+ int devicesIndex;
+ cMutex mutexDevices;
+ int numDevices;
+ int* lastSignalStrength;
+ int* lastSignalQuality;
+ bool* recDevices;
+ void Init(void);
+public:
+ cVeDevices(void);
+ virtual ~cVeDevices(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeCurrentWeather
+******************************************************************/
+class cVeCurrentWeather : public cViewElement {
+private:
+public:
+ cVeCurrentWeather(void);
+ virtual ~cVeCurrentWeather(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeCustomTokens
+******************************************************************/
+class cVeCustomTokens : public cViewElement {
+private:
+public:
+ cVeCustomTokens(void);
+ virtual ~cVeCustomTokens(void);
+ void Reset(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeVolume
+******************************************************************/
+class cVeVolume : public cViewElement {
+private:
+ int current;
+ int total;
+ bool mute;
+ bool changed;
+public:
+ cVeVolume(void);
+ virtual ~cVeVolume(void);
+ void SetTokenContainer(void);
+ void Set(int current, int total, bool mute);
+ bool Parse(bool forced = false);
+};
+#endif //__VIEWELEMENTSCOMMON_H
\ No newline at end of file diff --git a/coreengine/viewelementsdisplaychannel.c b/coreengine/viewelementsdisplaychannel.c new file mode 100644 index 0000000..b523435 --- /dev/null +++ b/coreengine/viewelementsdisplaychannel.c @@ -0,0 +1,650 @@ +#include "viewelementsdisplaychannel.h"
+#include "../config.h"
+#include "../extensions/helpers.h"
+#include "../extensions/timers.h"
+#include "../services/scraper2vdr.h"
+
+/******************************************************************
+* cVeDcChannelInfo
+******************************************************************/
+cVeDcChannelInfo::cVeDcChannelInfo(void) {
+}
+
+cVeDcChannelInfo::~cVeDcChannelInfo(void) {
+}
+
+void cVeDcChannelInfo::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{channelnumber}", (int)eDCChannelInfoST::channelnumber);
+ tokenContainer->DefineStringToken("{channelname}", (int)eDCChannelInfoST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eDCChannelInfoST::channelid);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eDCChannelInfoIT::channellogoexists);
+ tokenContainer->DefineIntToken("{switching}", (int)eDCChannelInfoIT::switching);
+ InheritTokenContainer();
+}
+
+void cVeDcChannelInfo::Set(const cChannel *c, int number) {
+ cString channelNumber("");
+ cString channelName("");
+ cString channelId("");
+ if (c) {
+ channelName = c->Name() ? c->Name() : "";
+ channelId = c->GetChannelID().ToString();
+ if (!c->GroupSep()) {
+ channelNumber = cString::sprintf("%d%s", c->Number(), number ? "-" : "");
+ }
+ } else if (number) {
+ channelNumber = cString::sprintf("%d-", number);
+ } else {
+ channelName = ChannelString(NULL, 0);
+ }
+
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDCChannelInfoST::channelnumber, *channelNumber);
+ tokenContainer->AddStringToken((int)eDCChannelInfoST::channelname, *channelName);
+ tokenContainer->AddStringToken((int)eDCChannelInfoST::channelid, *channelId);
+ bool logoExists = imgCache->LogoExists(*channelId);
+ tokenContainer->AddIntToken((int)eDCChannelInfoIT::channellogoexists, logoExists);
+ tokenContainer->AddIntToken((int)eDCChannelInfoIT::switching, (number > 0)?true:false);
+
+ SetDirty();
+}
+
+/******************************************************************
+* cVeDcChannelGroup
+******************************************************************/
+cVeDcChannelGroup::cVeDcChannelGroup(void) {
+}
+
+cVeDcChannelGroup::~cVeDcChannelGroup(void) {
+}
+
+void cVeDcChannelGroup::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{group}", (int)eDCChannelGroupST::group);
+ tokenContainer->DefineStringToken("{nextgroup}", (int)eDCChannelGroupST::nextgroup);
+ tokenContainer->DefineStringToken("{prevgroup}", (int)eDCChannelGroupST::prevgroup);
+ tokenContainer->DefineStringToken("{seppath}", (int)eDCChannelGroupST::seppath);
+ tokenContainer->DefineIntToken("{prevAvailable}", (int)eDCChannelGroupIT::prevAvailable);
+ tokenContainer->DefineIntToken("{nextAvailable}", (int)eDCChannelGroupIT::nextAvailable);
+ tokenContainer->DefineIntToken("{sepexists}", (int)eDCChannelGroupIT::sepexists);
+ InheritTokenContainer();
+}
+
+void cVeDcChannelGroup::Set(const cChannel *c) {
+ const char *sep = c->Name();
+ bool sepExists = imgCache->SeparatorLogoExists(sep);
+
+ const char *prevChannelSep = GetChannelSep(c, true);
+ const char *nextChannelSep = GetChannelSep(c, false);
+
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDCChannelGroupST::group, sep);
+ tokenContainer->AddStringToken((int)eDCChannelGroupST::nextgroup, nextChannelSep ? nextChannelSep : "");
+ tokenContainer->AddStringToken((int)eDCChannelGroupST::prevgroup, prevChannelSep ? prevChannelSep : "");
+ tokenContainer->AddStringToken((int)eDCChannelGroupST::seppath, sepExists ? sep : "");
+ tokenContainer->AddIntToken((int)eDCChannelGroupIT::prevAvailable, (prevChannelSep)?true:false);
+ tokenContainer->AddIntToken((int)eDCChannelGroupIT::nextAvailable, (nextChannelSep)?true:false);
+ tokenContainer->AddIntToken((int)eDCChannelGroupIT::sepexists, sepExists);
+
+ SetDirty();
+}
+
+const char *cVeDcChannelGroup::GetChannelSep(const cChannel *c, bool prev) {
+ const cChannel *sep = prev ? Channels.Prev(c) :
+ Channels.Next(c);
+ for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) {
+ if (sep->GroupSep()) {
+ return sep->Name();
+ }
+ }
+ return NULL;
+}
+/******************************************************************
+* cVeDcEpgInfo
+******************************************************************/
+cVeDcEpgInfo::cVeDcEpgInfo(void) {
+}
+
+cVeDcEpgInfo::~cVeDcEpgInfo(void) {
+}
+
+void cVeDcEpgInfo::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{currenttitle}", (int)eDCEpgInfoST::currenttitle);
+ tokenContainer->DefineStringToken("{currentsubtitle}", (int)eDCEpgInfoST::currentsubtitle);
+ tokenContainer->DefineStringToken("{currentstart}", (int)eDCEpgInfoST::currentstart);
+ tokenContainer->DefineStringToken("{currentstop}", (int)eDCEpgInfoST::currentstop);
+ tokenContainer->DefineStringToken("{nexttitle}", (int)eDCEpgInfoST::nexttitle);
+ tokenContainer->DefineStringToken("{nextsubtitle}", (int)eDCEpgInfoST::nextsubtitle);
+ tokenContainer->DefineStringToken("{nextstart}", (int)eDCEpgInfoST::nextstart);
+ tokenContainer->DefineStringToken("{nextstop}", (int)eDCEpgInfoST::nextstop);
+ tokenContainer->DefineIntToken("{currentduration}", (int)eDCEpgInfoIT::currentduration);
+ tokenContainer->DefineIntToken("{currentdurationhours}", (int)eDCEpgInfoIT::currentdurationhours);
+ tokenContainer->DefineIntToken("{currentdurationminutes}", (int)eDCEpgInfoIT::currentdurationminutes);
+ tokenContainer->DefineIntToken("{currentelapsed}", (int)eDCEpgInfoIT::currentelapsed);
+ tokenContainer->DefineIntToken("{currentremaining}", (int)eDCEpgInfoIT::currentremaining);
+ tokenContainer->DefineIntToken("{nextduration}", (int)eDCEpgInfoIT::nextduration);
+ tokenContainer->DefineIntToken("{nextdurationhours}", (int)eDCEpgInfoIT::nextdurationhours);
+ tokenContainer->DefineIntToken("{nextdurationminutes}", (int)eDCEpgInfoIT::nextdurationminutes);
+ tokenContainer->DefineIntToken("{nextrecording}", (int)eDCEpgInfoIT::nextrecording);
+ tokenContainer->DefineIntToken("{currentrecording}", (int)eDCEpgInfoIT::currentrecording);
+ tokenContainer->DefineIntToken("{hasVPS}", (int)eDCEpgInfoIT::hasVPS);
+ InheritTokenContainer();
+}
+
+void cVeDcEpgInfo::Set(const cEvent *p, const cEvent *f) {
+ tokenContainer->Clear();
+ if (p) {
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::currenttitle, p->Title());
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::currentsubtitle, p->ShortText());
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::currentstart, *p->GetTimeString());
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::currentstop, *p->GetEndTimeString());
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentduration, p->Duration() / 60);
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentdurationhours, p->Duration() / 3600);
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentdurationminutes, (p->Duration() / 60) % 60);
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentelapsed, (int)round((time(NULL) - p->StartTime())/60));
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentremaining, (int)round((p->EndTime() - time(NULL))/60));
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::currentrecording, EventHasTimer(p));
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::hasVPS, (bool)p->Vps());
+ }
+ if (f) {
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::nexttitle, f->Title());
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::nextsubtitle, f->ShortText());
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::nextstart, *f->GetTimeString());
+ tokenContainer->AddStringToken((int)eDCEpgInfoST::nextstop, *f->GetEndTimeString());
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::nextduration, f->Duration() / 60);
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::nextdurationhours, f->Duration() / 3600);
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::nextdurationminutes, (f->Duration() / 60) % 60);
+ tokenContainer->AddIntToken((int)eDCEpgInfoIT::hasVPS, (bool)f->Vps());
+ }
+ SetDirty();
+}
+
+bool cVeDcEpgInfo::EventHasTimer(const cEvent *e) {
+ if (!e) return false;
+ cGlobalSortedTimers SortedTimers;// local and remote timers
+ bool hasTimer = e->HasTimer();
+ for (int i = 0; i < SortedTimers.Size() && !hasTimer; i++)
+ if (const cTimer *Timer = SortedTimers[i])
+ if (Timer->Channel()->GetChannelID() == e->ChannelID())
+ if (const cEvent *timerEvent = Timer->Event())
+ if (e->EventID() == timerEvent->EventID())
+ hasTimer = true;
+ return hasTimer;
+}
+
+/******************************************************************
+* cVeDcProgressBar
+******************************************************************/
+cVeDcProgressBar::cVeDcProgressBar(void) {
+ currentLast = -1;
+ startTime = -1;
+ duration = -1;
+}
+
+cVeDcProgressBar::~cVeDcProgressBar(void) {
+}
+
+void cVeDcProgressBar::Close(void) {
+ currentLast = -1;
+ startTime = -1;
+ duration = -1;
+ cViewElement::Close();
+}
+
+void cVeDcProgressBar::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{start}", (int)eDCProgressBarST::start);
+ tokenContainer->DefineStringToken("{stop}", (int)eDCProgressBarST::stop);
+ tokenContainer->DefineIntToken("{duration}", (int)eDCProgressBarIT::duration);
+ tokenContainer->DefineIntToken("{elapsed}", (int)eDCProgressBarIT::elapsed);
+ tokenContainer->DefineIntToken("{remaining}", (int)eDCProgressBarIT::remaining);
+ tokenContainer->DefineIntToken("{permashift}", (int)eDCProgressBarIT::permashift);
+ tokenContainer->DefineIntToken("{livebuffer}", (int)eDCProgressBarIT::livebuffer);
+ InheritTokenContainer();
+}
+
+void cVeDcProgressBar::Set(const cEvent *p) {
+ if (!p) {
+ startTime = -1;
+ duration = -1;
+ return;
+ }
+ startTime = p->StartTime();
+ duration = p->Duration();
+
+ int current = 0;
+ time_t t = time(NULL);
+ if (t > startTime)
+ current = t - startTime;
+
+ currentLast = current;
+ SetDirty();
+
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDCProgressBarST::start, *p->GetTimeString());
+ tokenContainer->AddStringToken((int)eDCProgressBarST::stop, *p->GetEndTimeString());
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::duration, duration);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::elapsed, current);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::remaining, duration - current);
+ int liveBuffer = GetLiveBuffer();
+ if (liveBuffer >= 0) {
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 1);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::livebuffer, liveBuffer);
+ } else {
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 0);
+ }
+}
+
+bool cVeDcProgressBar::Parse(bool force) {
+ if (!cViewElement::Parse(force))
+ return false;
+ int current = 0;
+ time_t t = time(NULL);
+ if (t > startTime)
+ current = t - startTime;
+ if (!(current > currentLast + 3) && !force && !Dirty())
+ return false;
+ SetDirty();
+ if (duration <= 0) {
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::duration, 0);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::elapsed, 0);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::remaining, 0);
+ } else {
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::duration, duration);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::elapsed, current);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::remaining, duration - current);
+ int liveBuffer = GetLiveBuffer();
+ if (liveBuffer >= 0) {
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 1);
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::livebuffer, liveBuffer);
+ } else {
+ tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 0);
+ }
+ }
+ return true;
+}
+
+int cVeDcProgressBar::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;
+}
+/******************************************************************
+* cVeDcStatusInfo
+******************************************************************/
+cVeDcStatusInfo::cVeDcStatusInfo(void) {
+}
+
+cVeDcStatusInfo::~cVeDcStatusInfo(void) {
+}
+
+void cVeDcStatusInfo::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{isRadio}", (int)eDCStatusInfoIT::isRadio);
+ tokenContainer->DefineIntToken("{hasVT}", (int)eDCStatusInfoIT::hasVT);
+ tokenContainer->DefineIntToken("{isStereo}", (int)eDCStatusInfoIT::isStereo);
+ tokenContainer->DefineIntToken("{isDolby}", (int)eDCStatusInfoIT::isDolby);
+ tokenContainer->DefineIntToken("{isEncrypted}", (int)eDCStatusInfoIT::isEncrypted);
+ tokenContainer->DefineIntToken("{isRecording}", (int)eDCStatusInfoIT::isRecording);
+ tokenContainer->DefineIntToken("{newmails}", (int)eDCStatusInfoIT::newmails);
+ InheritTokenContainer();
+}
+
+void cVeDcStatusInfo::Set(const cChannel *c) {
+ bool isRadio = !c->Vpid() && c->Apid(0);
+ bool hasVT = c->Vpid() && c->Tpid();
+ bool isStereo = c->Apid(0);
+ bool isDolby = c->Dpid(0);
+ bool isEncrypted = c->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;
+
+ tokenContainer->AddIntToken((int)eDCStatusInfoIT::isRadio, isRadio);
+ tokenContainer->AddIntToken((int)eDCStatusInfoIT::hasVT, hasVT);
+ tokenContainer->AddIntToken((int)eDCStatusInfoIT::isStereo, isStereo);
+ tokenContainer->AddIntToken((int)eDCStatusInfoIT::isDolby, isDolby);
+ tokenContainer->AddIntToken((int)eDCStatusInfoIT::isEncrypted, isEncrypted);
+ tokenContainer->AddIntToken((int)eDCStatusInfoIT::isRecording, isRecording);
+ tokenContainer->AddIntToken((int)eDCStatusInfoIT::newmails, CheckMails());
+ SetDirty();
+}
+
+bool cVeDcStatusInfo::CheckMails(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;
+}
+
+/******************************************************************
+* cVeDcAudioInfo
+******************************************************************/
+cVeDcAudioInfo::cVeDcAudioInfo(void) {
+ lastNumAudioTracks = -1;
+ lastAudioChannel = -1;
+ lastTracDesc = NULL;
+ lastTrackLang = NULL;
+}
+
+cVeDcAudioInfo::~cVeDcAudioInfo(void) {
+}
+
+void cVeDcAudioInfo::Close(void) {
+ lastNumAudioTracks = -1;
+ lastAudioChannel = -1;
+ free(lastTracDesc);
+ lastTracDesc = NULL;
+ free(lastTrackLang);
+ lastTrackLang = NULL;
+ cViewElement::Close();
+}
+
+void cVeDcAudioInfo::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{trackdesc}", (int)eDCAudioInfoST::trackdesc);
+ tokenContainer->DefineStringToken("{tracklang}", (int)eDCAudioInfoST::tracklang);
+ tokenContainer->DefineIntToken("{numaudiotracks}", (int)eDCAudioInfoIT::numaudiotracks);
+ tokenContainer->DefineIntToken("{audiochannel}", (int)eDCAudioInfoIT::audiochannel);
+ InheritTokenContainer();
+}
+
+bool cVeDcAudioInfo::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ int numAudioTracks = 0;
+ int audioChannel = -1;
+ const char *trackDescription = "";
+ const char *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 ( !Dirty() && !forced && lastNumAudioTracks == numAudioTracks
+ && lastAudioChannel == audioChannel
+ && lastTracDesc && !strcmp(trackDescription, lastTracDesc)
+ && lastTrackLang && !strcmp(trackLanguage, lastTrackLang)) {
+ return false;
+ }
+
+ lastNumAudioTracks = numAudioTracks;
+ lastAudioChannel = audioChannel;
+ free(lastTracDesc);
+ lastTracDesc = strdup(trackDescription);
+ free(lastTrackLang);
+ lastTrackLang = strdup(trackLanguage);
+ SetDirty();
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDCAudioInfoIT::numaudiotracks, numAudioTracks);
+ tokenContainer->AddIntToken((int)eDCAudioInfoIT::audiochannel, audioChannel);
+ tokenContainer->AddStringToken((int)eDCAudioInfoST::trackdesc, trackDescription);
+ tokenContainer->AddStringToken((int)eDCAudioInfoST::tracklang, trackLanguage);
+ return true;
+}
+/******************************************************************
+* cVeDcScreenResolution
+******************************************************************/
+cVeDcScreenResolution::cVeDcScreenResolution(void) {
+ lastScreenWidth = -1;
+ lastScreenHeight = -1;
+}
+
+cVeDcScreenResolution::~cVeDcScreenResolution(void) {
+}
+
+void cVeDcScreenResolution::Close(void) {
+ lastScreenWidth = -1;
+ lastScreenHeight = -1;
+ cViewElement::Close();
+}
+
+void cVeDcScreenResolution::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{resolution}", (int)eDCScreenResolutionST::resolution);
+ tokenContainer->DefineStringToken("{aspect}", (int)eDCScreenResolutionST::aspect);
+ tokenContainer->DefineIntToken("{screenwidth}", (int)eDCScreenResolutionIT::screenwidth);
+ tokenContainer->DefineIntToken("{screenheight}", (int)eDCScreenResolutionIT::screenheight);
+ tokenContainer->DefineIntToken("{isHD}", (int)eDCScreenResolutionIT::isHD);
+ tokenContainer->DefineIntToken("{isWideScreen}", (int)eDCScreenResolutionIT::isWideScreen);
+ InheritTokenContainer();
+}
+
+bool cVeDcScreenResolution::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ int screenWidth = 0;
+ int screenHeight = 0;
+ double aspect = 0;
+
+ cDevice::PrimaryDevice()->GetVideoSize(screenWidth, screenHeight, aspect);
+
+ if ((lastScreenWidth == screenWidth) && (lastScreenHeight == screenHeight))
+ return false;
+
+ if ((screenWidth == 0) && (screenHeight == 0))
+ return false;
+
+ lastScreenWidth = screenWidth;
+ lastScreenHeight = screenHeight;
+ SetDirty();
+
+ bool isHD = false;
+ string resName = GetScreenResolutionString(screenWidth, screenHeight, &isHD);
+
+ bool isWideScreen = false;
+ string aspectName = GetScreenAspectString(aspect, &isWideScreen);
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDCScreenResolutionIT::screenwidth, screenWidth);
+ tokenContainer->AddIntToken((int)eDCScreenResolutionIT::screenheight, screenHeight);
+ tokenContainer->AddIntToken((int)eDCScreenResolutionIT::isHD, isHD);
+ tokenContainer->AddIntToken((int)eDCScreenResolutionIT::isWideScreen, isWideScreen);
+ tokenContainer->AddStringToken((int)eDCScreenResolutionST::resolution, resName.c_str());
+ tokenContainer->AddStringToken((int)eDCScreenResolutionST::aspect, aspectName.c_str());
+ return true;
+}
+/******************************************************************
+* cVeDcSignalQuality
+******************************************************************/
+cVeDcSignalQuality::cVeDcSignalQuality(void) {
+ lastSignalDisplay = -1;
+ lastSignalStrength = -1;
+ lastSignalQuality = -1;
+}
+
+cVeDcSignalQuality::~cVeDcSignalQuality(void) {
+}
+
+void cVeDcSignalQuality::Close(void) {
+ lastSignalDisplay = -1;
+ lastSignalStrength = -1;
+ lastSignalQuality = -1;
+ cViewElement::Close();
+}
+
+void cVeDcSignalQuality::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{signalstrength}", (int)eDCSignalQualityIT::signalstrength);
+ tokenContainer->DefineIntToken("{signalquality}", (int)eDCSignalQualityIT::signalquality);
+ InheritTokenContainer();
+}
+
+bool cVeDcSignalQuality::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ time_t now = time(NULL);
+ if (now == lastSignalDisplay)
+ return false;
+ lastSignalDisplay = now;
+
+ 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 false;
+
+ if ((lastSignalStrength == signalStrength) && (lastSignalQuality == signalQuality))
+ return false;
+ SetDirty();
+ lastSignalStrength = signalStrength;
+ lastSignalQuality = signalQuality;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDCSignalQualityIT::signalstrength, signalStrength);
+ tokenContainer->AddIntToken((int)eDCSignalQualityIT::signalquality, signalQuality);
+ return true;
+}
+
+/******************************************************************
+* cVeDcScraperContent
+******************************************************************/
+cVeDcScraperContent::cVeDcScraperContent(void) {
+}
+
+cVeDcScraperContent::~cVeDcScraperContent(void) {
+}
+
+void cVeDcScraperContent::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperPosterBannerST::posterpath);
+ tokenContainer->DefineStringToken("{bannerpath}", (int)eScraperPosterBannerST::bannerpath);
+ tokenContainer->DefineStringToken("{mediapath}", (int)eScraperPosterBannerST::mediapath);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperPosterBannerIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperPosterBannerIT::posterheight);
+ tokenContainer->DefineIntToken("{hasPoster}", (int)eScraperPosterBannerIT::hasposter);
+ tokenContainer->DefineIntToken("{bannerwidth}", (int)eScraperPosterBannerIT::bannerwidth);
+ tokenContainer->DefineIntToken("{bannerheight}", (int)eScraperPosterBannerIT::bannerheight);
+ tokenContainer->DefineIntToken("{hasBanner}", (int)eScraperPosterBannerIT::hasbanner);
+ tokenContainer->DefineIntToken("{mediawidth}", (int)eScraperPosterBannerIT::mediawidth);
+ tokenContainer->DefineIntToken("{mediaheight}", (int)eScraperPosterBannerIT::mediaheight);
+ tokenContainer->DefineIntToken("{isbanner}", (int)eScraperPosterBannerIT::isbanner);
+ InheritTokenContainer();
+}
+
+void cVeDcScraperContent::Set(const cEvent *e) {
+ tokenContainer->Clear();
+ SetPosterBanner(tokenContainer, e, NULL);
+ SetDirty();
+}
+
+/******************************************************************
+* cVeDcScreenResolution
+******************************************************************/
+cVeDcEcmInfo::cVeDcEcmInfo(void) {
+ channelSid = -1;
+ lastEcmInfo.hops = -1;
+ lastEcmInfo.ecmtime = -1;
+ lastEcmInfo.caid = -1;
+ lastEcmInfo.pid = -1;
+ lastEcmInfo.prid = -1;
+}
+
+cVeDcEcmInfo::~cVeDcEcmInfo(void) {
+}
+
+void cVeDcEcmInfo::Close(void) {
+ channelSid = -1;
+ lastEcmInfo.hops = -1;
+ lastEcmInfo.ecmtime = -1;
+ lastEcmInfo.caid = -1;
+ lastEcmInfo.pid = -1;
+ lastEcmInfo.prid = -1;
+ cViewElement::Close();
+}
+
+void cVeDcEcmInfo::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{cardsystem}", (int)eDCEcmInfoST::cardsystem);
+ tokenContainer->DefineStringToken("{reader}", (int)eDCEcmInfoST::reader);
+ tokenContainer->DefineStringToken("{from}", (int)eDCEcmInfoST::from);
+ tokenContainer->DefineStringToken("{protocol}", (int)eDCEcmInfoST::protocol);
+ tokenContainer->DefineIntToken("{caid}", (int)eDCEcmInfoIT::caid);
+ tokenContainer->DefineIntToken("{pid}", (int)eDCEcmInfoIT::pid);
+ tokenContainer->DefineIntToken("{prid}", (int)eDCEcmInfoIT::prid);
+ tokenContainer->DefineIntToken("{ecmtime}", (int)eDCEcmInfoIT::ecmtime);
+ tokenContainer->DefineIntToken("{hops}", (int)eDCEcmInfoIT::hops);
+ InheritTokenContainer();
+}
+
+void cVeDcEcmInfo::Set(const cChannel *c) {
+ channelSid = c->Sid();
+}
+
+bool cVeDcEcmInfo::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ static cPlugin *pDVBApi = cPluginManager::GetPlugin("dvbapi");
+ if (!pDVBApi)
+ return false;
+ if (channelSid < 0)
+ 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;
+ SetDirty();
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDCEcmInfoIT::caid, ecmInfo.caid);
+ tokenContainer->AddIntToken((int)eDCEcmInfoIT::pid, ecmInfo.pid);
+ tokenContainer->AddIntToken((int)eDCEcmInfoIT::prid, ecmInfo.prid);
+ tokenContainer->AddIntToken((int)eDCEcmInfoIT::ecmtime, ecmInfo.ecmtime);
+ tokenContainer->AddIntToken((int)eDCEcmInfoIT::hops, ecmInfo.hops);
+ tokenContainer->AddStringToken((int)eDCEcmInfoST::cardsystem, *ecmInfo.cardsystem);
+ tokenContainer->AddStringToken((int)eDCEcmInfoST::reader, *ecmInfo.reader);
+ tokenContainer->AddStringToken((int)eDCEcmInfoST::from, *ecmInfo.from);
+ tokenContainer->AddStringToken((int)eDCEcmInfoST::protocol, *ecmInfo.protocol);
+ return true;
+}
+
+bool cVeDcEcmInfo::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;
+}
diff --git a/coreengine/viewelementsdisplaychannel.h b/coreengine/viewelementsdisplaychannel.h new file mode 100644 index 0000000..b4a2fbd --- /dev/null +++ b/coreengine/viewelementsdisplaychannel.h @@ -0,0 +1,145 @@ +#ifndef __VIEWELEMENTSDC_H
+#define __VIEWELEMENTSDC_H
+
+#include "viewelement.h"
+#include "../extensions/scrapmanager.h"
+#include "../services/dvbapi.h"
+
+/******************************************************************
+* cVeDcChannelInfo
+******************************************************************/
+class cVeDcChannelInfo : public cViewElement {
+private:
+public:
+ cVeDcChannelInfo(void);
+ virtual ~cVeDcChannelInfo(void);
+ void SetTokenContainer(void);
+ void Set(const cChannel *c, int number);
+};
+/******************************************************************
+* cVeDcChannelGroup
+******************************************************************/
+class cVeDcChannelGroup : public cViewElement {
+private:
+ const char *GetChannelSep(const cChannel *c, bool prev);
+public:
+ cVeDcChannelGroup(void);
+ virtual ~cVeDcChannelGroup(void);
+ void SetTokenContainer(void);
+ void Set(const cChannel *c);
+};
+/******************************************************************
+* cVeDcEpgInfo
+******************************************************************/
+class cVeDcEpgInfo : public cViewElement {
+private:
+ bool EventHasTimer(const cEvent *e);
+public:
+ cVeDcEpgInfo(void);
+ virtual ~cVeDcEpgInfo(void);
+ void SetTokenContainer(void);
+ void Set(const cEvent *p, const cEvent *f);
+};
+/******************************************************************
+* cVeDcProgressBar
+******************************************************************/
+class cVeDcProgressBar : public cViewElement {
+private:
+ int currentLast;
+ int startTime;
+ int duration;
+ int GetLiveBuffer(void);
+public:
+ cVeDcProgressBar(void);
+ virtual ~cVeDcProgressBar(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ void Set(const cEvent *p);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeDcStatusInfo
+******************************************************************/
+class cVeDcStatusInfo : public cViewElement {
+private:
+ bool CheckMails(void);
+public:
+ cVeDcStatusInfo(void);
+ virtual ~cVeDcStatusInfo(void);
+ void SetTokenContainer(void);
+ void Set(const cChannel *c);
+};
+/******************************************************************
+* cVeDcAudioInfo
+******************************************************************/
+class cVeDcAudioInfo : public cViewElement {
+private:
+ int lastNumAudioTracks;
+ int lastAudioChannel;
+ char *lastTracDesc;
+ char *lastTrackLang;
+public:
+ cVeDcAudioInfo(void);
+ virtual ~cVeDcAudioInfo(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeDcScreenResolution
+******************************************************************/
+class cVeDcScreenResolution : public cViewElement {
+private:
+ int lastScreenWidth;
+ int lastScreenHeight;
+public:
+ cVeDcScreenResolution(void);
+ virtual ~cVeDcScreenResolution(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeDcSignalQuality
+******************************************************************/
+class cVeDcSignalQuality : public cViewElement {
+private:
+ int lastSignalDisplay;
+ int lastSignalStrength;
+ int lastSignalQuality;
+public:
+ cVeDcSignalQuality(void);
+ virtual ~cVeDcSignalQuality(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+/******************************************************************
+* cVeDcScraperContent
+******************************************************************/
+class cVeDcScraperContent : public cViewElement, public cScrapManager {
+private:
+public:
+ cVeDcScraperContent(void);
+ virtual ~cVeDcScraperContent(void);
+ void SetTokenContainer(void);
+ void Set(const cEvent *e);
+};
+/******************************************************************
+* cVeDcEcmInfo
+******************************************************************/
+class cVeDcEcmInfo : public cViewElement {
+private:
+ int channelSid;
+ sDVBAPIEcmInfo lastEcmInfo;
+ bool CompareECMInfos(sDVBAPIEcmInfo *ecmInfo);
+public:
+ cVeDcEcmInfo(void);
+ virtual ~cVeDcEcmInfo(void);
+ void Close(void);
+ void SetTokenContainer(void);
+ void Set(const cChannel *c);
+ bool Parse(bool forced = false);
+};
+
+#endif //__VIEWELEMENTSDC_H
\ No newline at end of file diff --git a/coreengine/viewelementsdisplaymenu.c b/coreengine/viewelementsdisplaymenu.c new file mode 100644 index 0000000..52e2996 --- /dev/null +++ b/coreengine/viewelementsdisplaymenu.c @@ -0,0 +1,1232 @@ +#define __STL_CONFIG_H
+#include "viewelementsdisplaymenu.h"
+#include "../config.h"
+#include <vdr/videodir.h>
+#include "../extensions/timers.h"
+#include "../extensions/helpers.h"
+#include <sys/sysinfo.h>
+#include <fstream>
+#include <iostream>
+
+/******************************************************************
+* cVeDmHeader
+******************************************************************/
+cVeDmHeader::cVeDmHeader(void) {
+ title = NULL;
+ channelName = NULL;
+ channelNumber = 0;
+ channelId = NULL;
+ epgSearchFav = false;
+}
+
+cVeDmHeader::~cVeDmHeader(void) {
+ free(title);
+ free(channelName);
+ free(channelId);
+}
+
+void cVeDmHeader::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eDMHeaderST::title);
+ tokenContainer->DefineStringToken("{vdrversion}", (int)eDMHeaderST::vdrversion);
+ tokenContainer->DefineStringToken("{icon}", (int)eDMHeaderST::icon);
+ tokenContainer->DefineStringToken("{freetime}", (int)eDMHeaderST::freetime);
+ tokenContainer->DefineStringToken("{vdrusagestring}", (int)eDMHeaderST::vdrusagestring);
+ tokenContainer->DefineStringToken("{channelname}", (int)eDMHeaderST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eDMHeaderST::channelid);
+ tokenContainer->DefineIntToken("{hasicon}", (int)eDMHeaderIT::hasicon);
+ tokenContainer->DefineIntToken("{freepercent}", (int)eDMHeaderIT::freepercent);
+ tokenContainer->DefineIntToken("{usedpercent}", (int)eDMHeaderIT::usedpercent);
+ tokenContainer->DefineIntToken("{freegb}", (int)eDMHeaderIT::freegb);
+ tokenContainer->DefineIntToken("{discalert}", (int)eDMHeaderIT::discalert);
+ tokenContainer->DefineIntToken("{channelnumber}", (int)eDMHeaderIT::channelnumber);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eDMHeaderIT::channellogoexists);
+ tokenContainer->DefineIntToken("{whatson}", (int)eDMHeaderIT::whatson);
+ tokenContainer->DefineIntToken("{whatsonnow}", (int)eDMHeaderIT::whatsonnow);
+ tokenContainer->DefineIntToken("{whatsonnext}", (int)eDMHeaderIT::whatsonnext);
+ tokenContainer->DefineIntToken("{whatsonfavorites}", (int)eDMHeaderIT::whatsonfavorites);
+ InheritTokenContainer();
+}
+
+void cVeDmHeader::SetTitle(const char *title) {
+ this->title = strdup(title);
+ free(channelName);
+ channelName = NULL;
+ channelNumber = 0;
+ free(channelId);
+ channelId = NULL;
+}
+
+void cVeDmHeader::SetChannel(const cChannel *channel) {
+ channelNumber = channel->Number();
+ free(channelName);
+ free(channelId);
+ channelName = strdup(channel->Name());
+ channelId = strdup(*(channel->GetChannelID().ToString()));
+}
+
+void cVeDmHeader::Set(eMenuCategory menuCat) {
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDMHeaderST::title, title);
+ tokenContainer->AddStringToken((int)eDMHeaderST::vdrversion, VDRVERSION);
+
+ tokenContainer->AddIntToken((int)eDMHeaderIT::whatson, (menuCat == mcSchedule && !epgSearchFav) ? true : false);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::whatsonnow, menuCat == mcScheduleNow ? true : false);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::whatsonnext, menuCat == mcScheduleNext ? true : false);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::whatsonfavorites, epgSearchFav);
+
+ //check for standard menu entries
+ bool hasIcon = false;
+
+ string icon = imgCache->GetIconName(title, menuCat);
+ if (imgCache->MenuIconExists(icon))
+ hasIcon = true;
+
+ tokenContainer->AddStringToken((int)eDMHeaderST::icon, icon.c_str());
+ tokenContainer->AddIntToken((int)eDMHeaderIT::hasicon, hasIcon);
+
+ //Disc Usage
+ tokenContainer->AddStringToken((int)eDMHeaderST::vdrusagestring, *cVideoDiskUsage::String());
+ tokenContainer->AddStringToken((int)eDMHeaderST::freetime, *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60));
+ int discUsage = cVideoDiskUsage::UsedPercent();
+ bool discAlert = (discUsage > 95) ? true : false;
+ int freeGB = cVideoDiskUsage::FreeMB() / 1024;
+ tokenContainer->AddIntToken((int)eDMHeaderIT::usedpercent, discUsage);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::freepercent, 100-discUsage);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::discalert, discAlert);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::freegb, freeGB);
+
+ if (channelName && channelId) {
+ tokenContainer->AddStringToken((int)eDMHeaderST::channelname, channelName);
+ tokenContainer->AddStringToken((int)eDMHeaderST::channelid, channelId);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::channelnumber, channelNumber);
+ tokenContainer->AddIntToken((int)eDMHeaderIT::channellogoexists, imgCache->LogoExists(channelId));
+ }
+ SetDirty();
+}
+
+/******************************************************************
+* cVeDmSortmode
+******************************************************************/
+cVeDmSortmode::cVeDmSortmode(void) {
+ sortMode = msmUnknown;
+ lastSortMode = msmUnknown;
+}
+
+cVeDmSortmode::~cVeDmSortmode(void) {
+}
+
+void cVeDmSortmode::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{sortnumber}", (int)eDMSortmodeIT::sortnumber);
+ tokenContainer->DefineIntToken("{sortname}", (int)eDMSortmodeIT::sortname);
+ tokenContainer->DefineIntToken("{sorttime}", (int)eDMSortmodeIT::sorttime);
+ tokenContainer->DefineIntToken("{sortprovider}", (int)eDMSortmodeIT::sortprovider);
+ InheritTokenContainer();
+}
+
+void cVeDmSortmode::Set(eMenuSortMode sortMode) {
+ this->sortMode = sortMode;
+}
+
+bool cVeDmSortmode::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ if (sortMode == lastSortMode) {
+ return false;
+ }
+ lastSortMode = sortMode;
+
+ bool sortNumber = (sortMode == msmNumber) ? true : false;
+ bool sortName = (sortMode == msmName) ? true : false;
+ bool sortTime = (sortMode == msmTime) ? true : false;
+ bool sortProvider = (sortMode == msmProvider) ? true : false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDMSortmodeIT::sortnumber, sortNumber);
+ tokenContainer->AddIntToken((int)eDMSortmodeIT::sortname, sortName);
+ tokenContainer->AddIntToken((int)eDMSortmodeIT::sorttime, sortTime);
+ tokenContainer->AddIntToken((int)eDMSortmodeIT::sortprovider, sortProvider);
+ SetDirty();
+ return true;
+}
+/******************************************************************
+* cVeDmColorbuttons
+******************************************************************/
+cVeDmColorbuttons::cVeDmColorbuttons(void) {
+ changed = false;
+ red = NULL;
+ green = NULL;
+ yellow = NULL;
+ blue = NULL;
+}
+
+cVeDmColorbuttons::~cVeDmColorbuttons(void) {
+ free(red);
+ free(yellow);
+ free(green);
+ free(blue);
+}
+
+void cVeDmColorbuttons::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{red}", (int)eDMColorbuttonsST::red);
+ tokenContainer->DefineStringToken("{green}", (int)eDMColorbuttonsST::green);
+ tokenContainer->DefineStringToken("{yellow}", (int)eDMColorbuttonsST::yellow);
+ tokenContainer->DefineStringToken("{blue}", (int)eDMColorbuttonsST::blue);
+ tokenContainer->DefineIntToken("{red1}", (int)eDMColorbuttonsIT::red1);
+ tokenContainer->DefineIntToken("{red2}", (int)eDMColorbuttonsIT::red2);
+ tokenContainer->DefineIntToken("{red3}", (int)eDMColorbuttonsIT::red3);
+ tokenContainer->DefineIntToken("{red4}", (int)eDMColorbuttonsIT::red4);
+ tokenContainer->DefineIntToken("{green1}", (int)eDMColorbuttonsIT::green1);
+ tokenContainer->DefineIntToken("{green2}", (int)eDMColorbuttonsIT::green2);
+ tokenContainer->DefineIntToken("{green3}", (int)eDMColorbuttonsIT::green3);
+ tokenContainer->DefineIntToken("{green4}", (int)eDMColorbuttonsIT::green4);
+ tokenContainer->DefineIntToken("{yellow1}", (int)eDMColorbuttonsIT::yellow1);
+ tokenContainer->DefineIntToken("{yellow2}", (int)eDMColorbuttonsIT::yellow2);
+ tokenContainer->DefineIntToken("{yellow3}", (int)eDMColorbuttonsIT::yellow3);
+ tokenContainer->DefineIntToken("{yellow4}", (int)eDMColorbuttonsIT::yellow4);
+ tokenContainer->DefineIntToken("{blue1}", (int)eDMColorbuttonsIT::blue1);
+ tokenContainer->DefineIntToken("{blue2}", (int)eDMColorbuttonsIT::blue2);
+ tokenContainer->DefineIntToken("{blue3}", (int)eDMColorbuttonsIT::blue3);
+ tokenContainer->DefineIntToken("{blue4}", (int)eDMColorbuttonsIT::blue4);
+ InheritTokenContainer();
+}
+
+void cVeDmColorbuttons::SetButtons(const char *red, const char *green, const char *yellow, const char *blue) {
+ free(this->red);
+ free(this->yellow);
+ free(this->green);
+ free(this->blue);
+ this->red = NULL;
+ this->green = NULL;
+ this->yellow = NULL;
+ this->blue = NULL;
+ if (red) this->red = strdup(red);
+ if (green) this->green = strdup(green);
+ if (yellow) this->yellow = strdup(yellow);
+ if (blue) this->blue = strdup(blue);
+ changed = true;
+}
+
+bool cVeDmColorbuttons::Parse(bool forced) {
+ if (!cViewElement::Parse(forced) || !changed)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDMColorbuttonsST::red, red);
+ tokenContainer->AddStringToken((int)eDMColorbuttonsST::green, green);
+ tokenContainer->AddStringToken((int)eDMColorbuttonsST::yellow, yellow);
+ tokenContainer->AddStringToken((int)eDMColorbuttonsST::blue, blue);
+
+ int colorKeys[4] = { Setup.ColorKey0, Setup.ColorKey1, Setup.ColorKey2, Setup.ColorKey3 };
+
+ for (int button = 1; button < 5; 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;
+ }
+ int tokRed = button - 1;
+ int tokGreen = 3 + button;
+ int tokYellow = 7 + button;
+ int tokBlue = 11 + button;
+ tokenContainer->AddIntToken(tokRed, isRed);
+ tokenContainer->AddIntToken(tokGreen, isGreen);
+ tokenContainer->AddIntToken(tokYellow, isYellow);
+ tokenContainer->AddIntToken(tokBlue, isBlue);
+ }
+ SetDirty();
+ changed = false;
+ return true;
+}
+
+/******************************************************************
+* cVeDmScrollbar
+******************************************************************/
+cVeDmScrollbar::cVeDmScrollbar(void) {
+}
+
+cVeDmScrollbar::~cVeDmScrollbar(void) {
+}
+
+void cVeDmScrollbar::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{height}", (int)eDMScrollbarIT::height);
+ tokenContainer->DefineIntToken("{offset}", (int)eDMScrollbarIT::offset);
+ tokenContainer->DefineIntToken("{hasprev}", (int)eDMScrollbarIT::hasprev);
+ tokenContainer->DefineIntToken("{hasnext}", (int)eDMScrollbarIT::hasnext);
+ InheritTokenContainer();
+}
+
+void cVeDmScrollbar::SetList(int numDisplayed, int offset, int numMax) {
+ 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;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::height, barHeight);
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::offset, barOffset);
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::hasprev, (offset == 0) ? 0 : 1);
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::hasnext, (offset + numMax == numDisplayed) ? 0 : 1);
+ SetDirty();
+}
+
+void cVeDmScrollbar::SetDetail(int height, int offset, bool end) {
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::height, height);
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::offset, offset);
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::hasprev, (offset == 0) ? 0 : 1);
+ tokenContainer->AddIntToken((int)eDMScrollbarIT::hasnext, (end) ? 0 : 1);
+ SetDirty();
+}
+
+/******************************************************************
+* cVeDmTimers
+******************************************************************/
+cVeDmTimers::cVeDmTimers(void) {
+ timerIndex = -1;
+}
+
+cVeDmTimers::~cVeDmTimers(void) {
+}
+
+void cVeDmTimers::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineLoopToken("{timers[title]}", (int)eDMTimersLT::title);
+ tokenContainer->DefineLoopToken("{timers[datetime]}", (int)eDMTimersLT::datetime);
+ tokenContainer->DefineLoopToken("{timers[recording]}", (int)eDMTimersLT::recording);
+ tokenContainer->DefineLoopToken("{timers[channelname]}", (int)eDMTimersLT::channelname);
+ tokenContainer->DefineLoopToken("{timers[channelnumber]}", (int)eDMTimersLT::channelnumber);
+ tokenContainer->DefineLoopToken("{timers[channelid]}", (int)eDMTimersLT::channelid);
+ tokenContainer->DefineLoopToken("{timers[channellogoexists]}", (int)eDMTimersLT::channellogoexists);
+ tokenContainer->DefineLoopToken("{timers[isremotetimer]}", (int)eDMTimersLT::isremotetimer);
+ tokenContainer->DefineIntToken("{numtimers}", (int)eDMTimersIT::numtimers);
+ tokenContainer->DefineIntToken("{numtimerconflicts}", (int)eDMTimersIT::numtimerconflicts);
+ tokenContainer->DefineIntToken("{timer1exists}", (int)eDMTimersIT::timer1exists);
+ tokenContainer->DefineIntToken("{timer2exists}", (int)eDMTimersIT::timer2exists);
+ tokenContainer->DefineIntToken("{timer3exists}", (int)eDMTimersIT::timer3exists);
+ tokenContainer->DefineIntToken("{timer4exists}", (int)eDMTimersIT::timer4exists);
+ tokenContainer->DefineIntToken("{timer5exists}", (int)eDMTimersIT::timer5exists);
+ tokenContainer->DefineIntToken("{timer6exists}", (int)eDMTimersIT::timer6exists);
+ tokenContainer->DefineIntToken("{timer7exists}", (int)eDMTimersIT::timer7exists);
+ tokenContainer->DefineIntToken("{timer8exists}", (int)eDMTimersIT::timer8exists);
+ tokenContainer->DefineIntToken("{timer9exists}", (int)eDMTimersIT::timer9exists);
+ tokenContainer->DefineIntToken("{timer10exists}", (int)eDMTimersIT::timer10exists);
+ tokenContainer->DefineIntToken("{timer11exists}", (int)eDMTimersIT::timer11exists);
+ tokenContainer->DefineIntToken("{timer12exists}", (int)eDMTimersIT::timer12exists);
+ tokenContainer->DefineIntToken("{timer13exists}", (int)eDMTimersIT::timer13exists);
+ tokenContainer->DefineIntToken("{timer14exists}", (int)eDMTimersIT::timer14exists);
+ tokenContainer->DefineIntToken("{timer15exists}", (int)eDMTimersIT::timer15exists);
+ timerIndex = tokenContainer->LoopIndex("timers");
+ InheritTokenContainer();
+}
+
+bool cVeDmTimers::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ tokenContainer->Clear();
+ cGlobalSortedTimers SortedTimers;// local and remote timers
+ int numTimers = SortedTimers.Size();
+ tokenContainer->AddIntToken((int)eDMTimersIT::numtimers, numTimers);
+ tokenContainer->AddIntToken((int)eDMTimersIT::numtimerconflicts, SortedTimers.NumTimerConfilicts());
+ for (int i=0; i<15; i++) {
+ if (i < numTimers) {
+ tokenContainer->AddIntToken(i+2, true);
+ } else {
+ tokenContainer->AddIntToken(i+2, false);
+ }
+ }
+
+ vector<int> timerInfo;
+ timerInfo.push_back(numTimers);
+ tokenContainer->CreateLoopTokenContainer(&timerInfo);
+
+ for (int i = 0; i < numTimers; i++) {
+ if (i >=15)
+ break;
+ const cTimer *Timer = SortedTimers[i];
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::isremotetimer, SortedTimers.IsRemoteTimer(i) ? "1" : "0");
+ const cEvent *event = Timer->Event();
+ if (event) {
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::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();
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::title, File);
+ }
+ const cChannel *channel = Timer->Channel();
+ if (channel) {
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::channelname, channel->Name());
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::channelnumber, *cString::sprintf("%d", channel->Number()));
+ cString channelID = channel->GetChannelID().ToString();
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::channelid, *channelID);
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::channellogoexists, imgCache->LogoExists(*channelID) ? "1" : "0");
+ }
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::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);
+ }
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::datetime, *timerDate);
+ tokenContainer->AddLoopToken(timerIndex, i, (int)eDMTimersLT::isremotetimer, SortedTimers.IsRemoteTimer(i) ? "1" : "0");
+ }
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDmCurrentschedule
+******************************************************************/
+cVeDmCurrentschedule::cVeDmCurrentschedule(void) {
+ rec = NULL;
+}
+
+cVeDmCurrentschedule::~cVeDmCurrentschedule(void) {
+}
+
+void cVeDmCurrentschedule::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{title}", (int)eDMCurrentscheduleST::title);
+ tokenContainer->DefineStringToken("{subtitle}", (int)eDMCurrentscheduleST::subtitle);
+ tokenContainer->DefineStringToken("{start}", (int)eDMCurrentscheduleST::start);
+ tokenContainer->DefineStringToken("{stop}", (int)eDMCurrentscheduleST::stop);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eDMCurrentscheduleST::durationminutes);
+ tokenContainer->DefineStringToken("{mediapath}", (int)eScraperPosterBannerST::mediapath);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperPosterBannerST::posterpath);
+ tokenContainer->DefineStringToken("{bannerpath}", (int)eScraperPosterBannerST::bannerpath);
+ tokenContainer->DefineIntToken("{islivetv}", (int)eDMCurrentscheduleIT::islivetv);
+ tokenContainer->DefineIntToken("{duration}", (int)eDMCurrentscheduleIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eDMCurrentscheduleIT::durationhours);
+ tokenContainer->DefineIntToken("{minutes}", (int)eDMCurrentscheduleIT::minutes);
+ tokenContainer->DefineIntToken("{elapsed}", (int)eDMCurrentscheduleIT::elapsed);
+ tokenContainer->DefineIntToken("{remaining}", (int)eDMCurrentscheduleIT::remaining);
+ tokenContainer->DefineIntToken("{mediawidth}", (int)eScraperPosterBannerIT::mediawidth);
+ tokenContainer->DefineIntToken("{mediaheight}", (int)eScraperPosterBannerIT::mediaheight);
+ tokenContainer->DefineIntToken("{isbanner}", (int)eScraperPosterBannerIT::isbanner);
+ tokenContainer->DefineIntToken("{hasposter}", (int)eScraperPosterBannerIT::hasposter);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperPosterBannerIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperPosterBannerIT::posterheight);
+ tokenContainer->DefineIntToken("{hasBanner}", (int)eScraperPosterBannerIT::hasbanner);
+ tokenContainer->DefineIntToken("{bannerwidth}", (int)eScraperPosterBannerIT::bannerwidth);
+ tokenContainer->DefineIntToken("{bannerheight}", (int)eScraperPosterBannerIT::bannerheight);
+ InheritTokenContainer();
+}
+
+void cVeDmCurrentschedule::SetRecording(const char *currentRec) {
+ rec = currentRec;
+}
+
+bool cVeDmCurrentschedule::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ cDevice *device = cDevice::PrimaryDevice();
+ const cChannel *channel = NULL;
+ if (!device->Replaying() || device->Transferring()) {
+ channel = Channels.GetByNumber(device->CurrentChannel());
+ }
+ if (channel) {
+ ParseFromChannel(channel);
+ } else {
+ if (!rec)
+ return true;
+ const cRecording *recording = new cRecording(rec);
+ if (recording) {
+ ParseFromRecording(recording);
+ delete recording;
+ }
+ }
+ SetDirty();
+ return true;
+}
+
+void cVeDmCurrentschedule::ParseFromChannel(const cChannel *channel) {
+ 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;
+
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::islivetv, 1);
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::title, event->Title());
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::subtitle, event->ShortText());
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::start, *event->GetTimeString());
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::stop, *event->GetEndTimeString());
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::duration, event->Duration() / 60);
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::durationhours, event->Duration() / 3600);
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::durationminutes, *cString::sprintf("%.2d", (event->Duration() / 60)%60));
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::elapsed, (int)round((time(NULL) - event->StartTime())/60));
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::remaining, (int)round((event->EndTime() - time(NULL))/60));
+ SetPosterBanner(tokenContainer, event, NULL);
+}
+
+void cVeDmCurrentschedule::ParseFromRecording(const cRecording *recording) {
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::islivetv, 0);
+ string recFullName = recording->Name() ? recording->Name() : "";
+ string recName = "";
+ string recFolder = "";
+ RecName(recFullName, recName, recFolder);
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::title, recName.c_str());
+ const cRecordingInfo *info = recording->Info();
+ if (info)
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::subtitle, info->ShortText());
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::duration, recording->LengthInSeconds() / 60);
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::durationhours, recording->LengthInSeconds() / 3600);
+ tokenContainer->AddStringToken((int)eDMCurrentscheduleST::durationminutes, *cString::sprintf("%.2d", (recording->LengthInSeconds() / 60)%60));
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::elapsed, 0);
+ tokenContainer->AddIntToken((int)eDMCurrentscheduleIT::remaining, 0);
+ SetPosterBanner(tokenContainer, NULL, recording);
+}
+
+void cVeDmCurrentschedule::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);
+}
+/******************************************************************
+* cVeDmDiscusage
+******************************************************************/
+cVeDmDiscusage::cVeDmDiscusage(void) {
+}
+
+cVeDmDiscusage::~cVeDmDiscusage(void) {
+}
+
+void cVeDmDiscusage::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{freetime}", (int)eDMDiscusageST::freetime);
+ tokenContainer->DefineStringToken("{vdrusagestring}", (int)eDMDiscusageST::vdrusagestring);
+ tokenContainer->DefineIntToken("{freepercent}", (int)eDMDiscusageIT::freepercent);
+ tokenContainer->DefineIntToken("{usedpercent}", (int)eDMDiscusageIT::usedpercent);
+ tokenContainer->DefineIntToken("{freegb}", (int)eDMDiscusageIT::freegb);
+ tokenContainer->DefineIntToken("{discalert}", (int)eDMDiscusageIT::discalert);
+ InheritTokenContainer();
+}
+
+bool cVeDmDiscusage::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDMDiscusageST::vdrusagestring, *cVideoDiskUsage::String());
+ tokenContainer->AddStringToken((int)eDMDiscusageST::freetime, *cString::sprintf("%02d:%02d", cVideoDiskUsage::FreeMinutes() / 60, cVideoDiskUsage::FreeMinutes() % 60));
+ int discUsage = cVideoDiskUsage::UsedPercent();
+ bool discAlert = (discUsage > 95) ? true : false;
+ int freeGB = cVideoDiskUsage::FreeMB() / 1024;
+ tokenContainer->AddIntToken((int)eDMDiscusageIT::usedpercent, discUsage);
+ tokenContainer->AddIntToken((int)eDMDiscusageIT::freepercent, 100-discUsage);
+ tokenContainer->AddIntToken((int)eDMDiscusageIT::discalert, discAlert);
+ tokenContainer->AddIntToken((int)eDMDiscusageIT::freegb, freeGB);
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDmSystemload
+******************************************************************/
+cVeDmSystemload::cVeDmSystemload(void) {
+ lastSystemLoad = -1.0f;
+}
+
+cVeDmSystemload::~cVeDmSystemload(void) {
+}
+
+void cVeDmSystemload::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{load}", (int)eDMSystemloadST::load);
+ tokenContainer->DefineIntToken("{loadhand}", (int)eDMSystemloadIT::loadhand);
+ InheritTokenContainer();
+}
+
+bool cVeDmSystemload::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ double systemLoad;
+ if (getloadavg(&systemLoad, 1) <= 0)
+ return false;
+ if (lastSystemLoad == systemLoad && !forced)
+ return false;
+
+ lastSystemLoad = systemLoad;
+
+ 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;
+ }
+ tokenContainer->AddStringToken((int)eDMSystemloadST::load, *cString::sprintf("%.2f", systemLoad));
+ tokenContainer->AddIntToken((int)eDMSystemloadIT::loadhand, loadHandValue);
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDmSystemmemory
+******************************************************************/
+cVeDmSystemmemory::cVeDmSystemmemory(void) {
+ lastMemUsage = -1;
+}
+
+cVeDmSystemmemory::~cVeDmSystemmemory(void) {
+}
+
+void cVeDmSystemmemory::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{totalmem}", (int)eDMSystemmemoryIT::totalmem);
+ tokenContainer->DefineIntToken("{usedmem}", (int)eDMSystemmemoryIT::usedmem);
+ tokenContainer->DefineIntToken("{usedmempercent}", (int)eDMSystemmemoryIT::usedmempercent);
+ InheritTokenContainer();
+}
+
+bool cVeDmSystemmemory::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ struct sysinfo memInfo;
+ sysinfo (&memInfo);
+ long long totalMem = memInfo.totalram;
+ totalMem += memInfo.totalswap;
+ totalMem *= memInfo.mem_unit;
+ int totalMemMB = totalMem / 1024 / 1024;
+ long long usedMem = memInfo.totalram - memInfo.freeram;
+ usedMem += memInfo.totalswap - memInfo.freeswap;
+ usedMem *= memInfo.mem_unit;
+ int usedMemMB = usedMem / 1024 / 1024;
+
+ if (lastMemUsage == usedMemMB) {
+ return false;
+ }
+ lastMemUsage = usedMemMB;
+ tokenContainer->AddIntToken((int)eDMSystemmemoryIT::totalmem, totalMemMB);
+ tokenContainer->AddIntToken((int)eDMSystemmemoryIT::usedmem, usedMemMB);
+ if (totalMemMB > 0)
+ tokenContainer->AddIntToken((int)eDMSystemmemoryIT::usedmempercent, usedMemMB * 100 / totalMemMB);
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDmTemperatures
+******************************************************************/
+cVeDmTemperatures::cVeDmTemperatures(void) {
+ Reset();
+}
+
+cVeDmTemperatures::~cVeDmTemperatures(void) {
+}
+
+void cVeDmTemperatures::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{cputemp}", (int)eDMTemperaturesIT::cputemp);
+ tokenContainer->DefineIntToken("{gputemp}", (int)eDMTemperaturesIT::gputemp);
+ InheritTokenContainer();
+}
+
+bool cVeDmTemperatures::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ 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 {
+ 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 {
+ gpu = 0;
+ }
+
+ if ((lastCpuTemp == cpu) && (lastGpuTemp == gpu))
+ return false;
+ lastCpuTemp = cpu;
+ lastGpuTemp = gpu;
+
+ tokenContainer->AddIntToken((int)eDMTemperaturesIT::cputemp, cpu);
+ tokenContainer->AddIntToken((int)eDMTemperaturesIT::gputemp, gpu);
+ SetDirty();
+ return true;
+}
+/******************************************************************
+* cVeDmVdrstatistics
+******************************************************************/
+cVeDmVdrstatistics::cVeDmVdrstatistics(void) {
+ Reset();
+}
+
+cVeDmVdrstatistics::~cVeDmVdrstatistics(void) {
+}
+
+void cVeDmVdrstatistics::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{vdrcpu}", (int)eDMVdrstatisticsST::vdrcpu);
+ tokenContainer->DefineStringToken("{vdrmem}", (int)eDMVdrstatisticsST::vdrmem);
+ InheritTokenContainer();
+}
+
+bool cVeDmVdrstatistics::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ 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;
+
+ tokenContainer->AddStringToken((int)eDMVdrstatisticsST::vdrcpu, vdrCPU.c_str());
+ tokenContainer->AddStringToken((int)eDMVdrstatisticsST::vdrmem, vdrMEM.c_str());
+ SetDirty();
+ return true;
+}
+/******************************************************************
+* cVeDmLastrecordings
+******************************************************************/
+cVeDmLastrecordings::cVeDmLastrecordings(void) {
+ recIndex = -1;
+}
+
+cVeDmLastrecordings::~cVeDmLastrecordings(void) {
+}
+
+void cVeDmLastrecordings::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{numtimers}", (int)eDMLastrecordingsIT::numtimers);
+ tokenContainer->DefineLoopToken("{recordings[name]}", (int)eDMLastrecordingsLT::name);
+ tokenContainer->DefineLoopToken("{recordings[seriesname]}", (int)eDMLastrecordingsLT::seriesname);
+ tokenContainer->DefineLoopToken("{recordings[date]}", (int)eDMLastrecordingsLT::date);
+ tokenContainer->DefineLoopToken("{recordings[time]}", (int)eDMLastrecordingsLT::time);
+ tokenContainer->DefineLoopToken("{recordings[duration]}", (int)eDMLastrecordingsLT::duration);
+ tokenContainer->DefineLoopToken("{recordings[hasposter]}", (int)eDMLastrecordingsLT::hasposter);
+ tokenContainer->DefineLoopToken("{recordings[posterpath]}", (int)eDMLastrecordingsLT::posterpath);
+ tokenContainer->DefineLoopToken("{recordings[posterwidth]}", (int)eDMLastrecordingsLT::posterwidth);
+ tokenContainer->DefineLoopToken("{recordings[posterheight]}", (int)eDMLastrecordingsLT::posterheight);
+ recIndex = tokenContainer->LoopIndex("recordings");
+ InheritTokenContainer();
+}
+
+bool cVeDmLastrecordings::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+
+ cGlobalSortedTimers SortedTimers;// local and remote timers
+ int numTimers = SortedTimers.Size();
+ //set number of timers so that it is possible to adapt this viewelement accordingly
+ tokenContainer->AddIntToken((int)eDMLastrecordingsIT::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 MAX_RECORDINGS = 10;
+ int availableRecordings = orderedRecs.size();
+ int numRecordings = min(MAX_RECORDINGS, availableRecordings);
+ if (!numRecordings)
+ return true;
+
+ vector<int> loopInfo;
+ loopInfo.push_back(numRecordings);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+
+ int i = 0;
+ for (list<cRecording*>::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) {
+ const cRecording *recording = *it;
+#if APIVERSNUM >= 20101
+ if (recording->IsInUse()) {
+ continue;
+ }
+#endif
+ string recFullPath = recording->Name() ? recording->Name() : "";
+ string recName = "";
+ string recPath = "";
+ RecName(recFullPath, recName, recPath);
+ cString recDuration = cString::sprintf("%d", recording->LengthInSeconds()/60);
+
+ string posterPath = "";
+ int posterWidth = 0;
+ int posterHeight = 0;
+ bool hasPoster = false;
+ RecPoster(recording, posterWidth, posterHeight, posterPath, hasPoster);
+
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::name, recName.c_str());
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::seriesname, recPath.c_str());
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::date, *ShortDateString(recording->Start()));
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::time, *TimeString(recording->Start()));
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::duration, *recDuration);
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::hasposter, hasPoster ? "1" : "0");
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::posterpath, posterPath.c_str());
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::posterwidth, *cString::sprintf("%d", posterWidth));
+ tokenContainer->AddLoopToken(recIndex, i, (int)eDMLastrecordingsLT::posterheight, *cString::sprintf("%d", posterHeight));
+
+ i++;
+ if (i == MAX_RECORDINGS)
+ break;
+ }
+ SetDirty();
+ return true;
+}
+
+void cVeDmLastrecordings::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);
+}
+/******************************************************************
+* cVeDmDetailheaderEpg
+******************************************************************/
+cVeDmDetailheaderEpg::cVeDmDetailheaderEpg(void) {
+ event = NULL;
+}
+
+cVeDmDetailheaderEpg::~cVeDmDetailheaderEpg(void) {
+}
+
+void cVeDmDetailheaderEpg::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperHeaderST::posterpath);
+ tokenContainer->DefineStringToken("{bannerpath}", (int)eScraperHeaderST::bannerpath);
+ tokenContainer->DefineStringToken("{title}", (int)eDmDetailedHeaderEpgST::title);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eDmDetailedHeaderEpgST::shorttext);
+ tokenContainer->DefineStringToken("{start}", (int)eDmDetailedHeaderEpgST::start);
+ tokenContainer->DefineStringToken("{stop}", (int)eDmDetailedHeaderEpgST::stop);
+ tokenContainer->DefineStringToken("{day}", (int)eDmDetailedHeaderEpgST::day);
+ tokenContainer->DefineStringToken("{date}", (int)eDmDetailedHeaderEpgST::date);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eDmDetailedHeaderEpgST::durationminutes);
+ tokenContainer->DefineStringToken("{vps}", (int)eDmDetailedHeaderEpgST::vps);
+ tokenContainer->DefineStringToken("{channelname}", (int)eDmDetailedHeaderEpgST::channelname);
+ tokenContainer->DefineStringToken("{channelid}", (int)eDmDetailedHeaderEpgST::channelid);
+ tokenContainer->DefineStringToken("{epgpicpath}", (int)eDmDetailedHeaderEpgST::epgpicpath);
+ tokenContainer->DefineIntToken("{ismovie}", (int)eScraperHeaderIT::ismovie);
+ tokenContainer->DefineIntToken("{isseries}", (int)eScraperHeaderIT::isseries);
+ tokenContainer->DefineIntToken("{posteravailable}", (int)eScraperHeaderIT::posteravailable);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperHeaderIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperHeaderIT::posterheight);
+ tokenContainer->DefineIntToken("{banneravailable}", (int)eScraperHeaderIT::banneravailable);
+ tokenContainer->DefineIntToken("{bannerwidth}", (int)eScraperHeaderIT::bannerwidth);
+ tokenContainer->DefineIntToken("{bannerheight}", (int)eScraperHeaderIT::bannerheight);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eDmDetailedHeaderEpgIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eDmDetailedHeaderEpgIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eDmDetailedHeaderEpgIT::year);
+ tokenContainer->DefineIntToken("{running}", (int)eDmDetailedHeaderEpgIT::running);
+ tokenContainer->DefineIntToken("{elapsed}", (int)eDmDetailedHeaderEpgIT::elapsed);
+ tokenContainer->DefineIntToken("{duration}", (int)eDmDetailedHeaderEpgIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eDmDetailedHeaderEpgIT::durationhours);
+ tokenContainer->DefineIntToken("{channelnumber}", (int)eDmDetailedHeaderEpgIT::channelnumber);
+ tokenContainer->DefineIntToken("{channellogoexists}", (int)eDmDetailedHeaderEpgIT::channellogoexists);
+ tokenContainer->DefineIntToken("{epgpicavailable}", (int)eDmDetailedHeaderEpgIT::epgpicavailable);
+ InheritTokenContainer();
+}
+
+void cVeDmDetailheaderEpg::SetEvent(const cEvent *event) {
+ this->event = event;
+}
+
+bool cVeDmDetailheaderEpg::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!event)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::title, event->Title());
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::shorttext, event->ShortText());
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::start, *(event->GetTimeString()));
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::stop, *(event->GetEndTimeString()));
+ time_t startTime = event->StartTime();
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::day, *WeekDayName(startTime));
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::date, *ShortDateString(startTime));
+ struct tm * sStartTime = localtime(&startTime);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::month, sStartTime->tm_mon+1);
+ const cChannel *channel = Channels.GetByChannelID(event->ChannelID());
+ if (channel) {
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::channelname, channel->Name());
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::channelnumber, channel->Number());
+ }
+ cString channelID = event->ChannelID().ToString();
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::channelid, *channelID);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::channellogoexists, imgCache->LogoExists(*channelID));
+
+ bool isRunning = false;
+ time_t now = time(NULL);
+ if ((now >= event->StartTime()) && (now <= event->EndTime()))
+ isRunning = true;
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::running, isRunning);
+ if (isRunning) {
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::elapsed, (now - event->StartTime())/60);
+ } else {
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::elapsed, 0);
+ }
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::duration, event->Duration() / 60);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::durationhours, event->Duration() / 3600);
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::durationminutes, *cString::sprintf("%.2d", (event->Duration() / 60)%60));
+ if (event->Vps())
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::vps, *event->GetVpsString());
+
+ cString epgImageName = cString::sprintf("%d", event->EventID());
+ bool epgPicAvailable = FileExists(*config.epgImagePath, *epgImageName, "jpg");
+ if (epgPicAvailable) {
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::epgpicavailable, true);
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::epgpicpath, *cString::sprintf("%s%s.jpg", *config.epgImagePath, *epgImageName));
+ } else {
+ epgImageName = cString::sprintf("%d_0", event->EventID());
+ epgPicAvailable = FileExists(*config.epgImagePath, *epgImageName, "jpg");
+ if (epgPicAvailable) {
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::epgpicavailable, true);
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::epgpicpath, *cString::sprintf("%s%s.jpg", *config.epgImagePath, *epgImageName));
+ }
+ }
+ bool scrapInfoAvailable = LoadFullScrapInfo(event, NULL);
+ if (scrapInfoAvailable) {
+ SetHeaderScrapInfo(tokenContainer);
+ }
+
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDmDetailheaderRec
+******************************************************************/
+cVeDmDetailheaderRec::cVeDmDetailheaderRec(void) {
+}
+
+cVeDmDetailheaderRec::~cVeDmDetailheaderRec(void) {
+}
+
+void cVeDmDetailheaderRec::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperHeaderST::posterpath);
+ tokenContainer->DefineStringToken("{bannerpath}", (int)eScraperHeaderST::bannerpath);
+ tokenContainer->DefineStringToken("{name}", (int)eDmDetailedHeaderRecST::name);
+ tokenContainer->DefineStringToken("{epgname}", (int)eDmDetailedHeaderRecST::epgname);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eDmDetailedHeaderRecST::shorttext);
+ tokenContainer->DefineStringToken("{date}", (int)eDmDetailedHeaderRecST::date);
+ tokenContainer->DefineStringToken("{time}", (int)eDmDetailedHeaderRecST::time);
+ tokenContainer->DefineStringToken("{recimgpath}", (int)eDmDetailedHeaderRecST::recimgpath);
+ tokenContainer->DefineStringToken("{recchannelname}", (int)eDmDetailedHeaderRecST::recchannelname);
+ tokenContainer->DefineStringToken("{recchannelid}", (int)eDmDetailedHeaderRecST::recchannelid);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eDmDetailedHeaderRecST::durationminutes);
+ tokenContainer->DefineStringToken("{durationeventminutes}", (int)eDmDetailedHeaderRecST::durationeventminutes);
+ tokenContainer->DefineIntToken("{ismovie}", (int)eScraperHeaderIT::ismovie);
+ tokenContainer->DefineIntToken("{isseries}", (int)eScraperHeaderIT::isseries);
+ tokenContainer->DefineIntToken("{posteravailable}", (int)eScraperHeaderIT::posteravailable);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperHeaderIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperHeaderIT::posterheight);
+ tokenContainer->DefineIntToken("{banneravailable}", (int)eScraperHeaderIT::banneravailable);
+ tokenContainer->DefineIntToken("{bannerwidth}", (int)eScraperHeaderIT::bannerwidth);
+ tokenContainer->DefineIntToken("{bannerheight}", (int)eScraperHeaderIT::bannerheight);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eDmDetailedHeaderRecIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eDmDetailedHeaderRecIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eDmDetailedHeaderRecIT::year);
+ tokenContainer->DefineIntToken("{duration}", (int)eDmDetailedHeaderRecIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eDmDetailedHeaderRecIT::durationhours);
+ tokenContainer->DefineIntToken("{durationevent}", (int)eDmDetailedHeaderRecIT::durationevent);
+ tokenContainer->DefineIntToken("{durationeventhours}", (int)eDmDetailedHeaderRecIT::durationeventhours);
+ tokenContainer->DefineIntToken("{recimgavailable}", (int)eDmDetailedHeaderRecIT::recimgavailable);
+ tokenContainer->DefineIntToken("{recchannelnumber}", (int)eDmDetailedHeaderRecIT::recchannelnumber);
+ InheritTokenContainer();
+}
+
+void cVeDmDetailheaderRec::SetRecording(const cRecording *recording) {
+ this->recording = recording;
+}
+
+bool cVeDmDetailheaderRec::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ if (!recording)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::name, recording->Name());
+
+ const cRecordingInfo *info = recording->Info();
+ if (info) {
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::epgname, info->Title());
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::shorttext, info->ShortText());
+ const cEvent *event = info->GetEvent();
+ if (event) {
+ cString recDate = event->GetDateString();
+ cString recTime = event->GetTimeString();
+ if (strstr(*recDate, "1970")) {
+ 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;
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::date, *recDate);
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::time, *recTime);
+ time_t startTime = event->StartTime();
+ struct tm * sStartTime = localtime(&startTime);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::month, sStartTime->tm_mon+1);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::duration, recDuration);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::durationhours, recDuration / 60);
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::durationminutes, *cString::sprintf("%.2d", recDuration%60));
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::durationevent, duration);
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::durationeventhours, duration / 60);
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::durationeventminutes, *cString::sprintf("%.2d", duration%60));
+ }
+ cChannel *channel = Channels.GetByChannelID(info->ChannelID());
+ if (channel) {
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelname, channel->Name());
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelid, *channel->GetChannelID().ToString());
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::recchannelnumber, channel->Number());
+ }
+ }
+ string recImage = "";
+ string path = recording->FileName() ? recording->FileName() : "";
+ string extension = ".jpg";
+ if (FirstFileInFolder(path, extension, recImage)) {
+ tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::recimgavailable, 1);
+ tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recimgpath, *cString::sprintf("%s/%s", path.c_str(), recImage.c_str()));
+ }
+ bool scrapInfoAvailable = LoadFullScrapInfo(NULL, recording);
+ if (scrapInfoAvailable) {
+ SetHeaderScrapInfo(tokenContainer);
+ }
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDmDetailheaderPlugin
+******************************************************************/
+cVeDmDetailheaderPlugin::cVeDmDetailheaderPlugin(void) {
+ plugId = -1;
+ plugMenuId = -1;
+}
+
+cVeDmDetailheaderPlugin::~cVeDmDetailheaderPlugin(void) {
+}
+
+void cVeDmDetailheaderPlugin::SetTokenContainer(void) {
+ if (plugId == -1 || plugMenuId == -1)
+ return;
+ skindesignerapi::cTokenContainer *tkPlugMenu = plgManager->GetTokenContainer(plugId, plugMenuId);
+ tokenContainer = new skindesignerapi::cTokenContainer(*tkPlugMenu);
+ InheritTokenContainer();
+}
+
+void cVeDmDetailheaderPlugin::Set(skindesignerapi::cTokenContainer *tk) {
+ tokenContainer->Clear();
+ tokenContainer->SetTokens(tk);
+}
+
+bool cVeDmDetailheaderPlugin::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ SetDirty();
+ return true;
+}
+/******************************************************************
+* cVeDmTablabels
+******************************************************************/
+cVeDmTablabels::cVeDmTablabels(void) {
+ tabIndex = -1;
+ activeTab = -1;
+}
+
+cVeDmTablabels::~cVeDmTablabels(void) {
+}
+
+void cVeDmTablabels::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineLoopToken("{tabs[title]}", (int)eDmTabsLT::title);
+ tokenContainer->DefineLoopToken("{tabs[current]}", (int)eDmTabsLT::current);
+ tokenContainer->DefineStringToken("{currenttab}", (int)eDmTabsST::currenttab);
+ tokenContainer->DefineStringToken("{prevtab}", (int)eDmTabsST::prevtab);
+ tokenContainer->DefineStringToken("{nexttab}", (int)eDmTabsST::nexttab);
+ tabIndex = tokenContainer->LoopIndex("tabs");
+ InheritTokenContainer();
+}
+
+void cVeDmTablabels::SetTabs(vector<const char*> &newTabs) {
+ tabs.clear();
+ for (vector<const char*>::iterator it = newTabs.begin(); it != newTabs.end(); it++) {
+ tabs.push_back(*it);
+ }
+ SetDirty();
+}
+
+bool cVeDmTablabels::Parse(bool forced) {
+ tokenContainer->Clear();
+ int numTabs = tabs.size();
+ vector<int> loopInfo;
+ loopInfo.push_back(numTabs);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+ for (int i = 0; i < numTabs; i++) {
+ if (i == activeTab) {
+ tokenContainer->AddLoopToken(tabIndex, i, (int)eDmTabsLT::current, "1");
+
+ } else {
+ tokenContainer->AddLoopToken(tabIndex, i, (int)eDmTabsLT::current, "0");
+ }
+ tokenContainer->AddLoopToken(tabIndex, i, (int)eDmTabsLT::title, tabs[i]);
+ }
+
+ if (activeTab >= 0 && activeTab < numTabs) {
+ tokenContainer->AddStringToken((int)eDmTabsST::currenttab, tabs[activeTab]);
+ tokenContainer->AddStringToken((int)eDmTabsST::prevtab, (activeTab == 0) ? tabs[numTabs-1] : tabs[activeTab-1]);
+ tokenContainer->AddStringToken((int)eDmTabsST::nexttab, (activeTab == numTabs-1) ? tabs[0] : tabs[activeTab+1]);
+ }
+ return true;
+}
+
+
+
diff --git a/coreengine/viewelementsdisplaymenu.h b/coreengine/viewelementsdisplaymenu.h new file mode 100644 index 0000000..20b1bed --- /dev/null +++ b/coreengine/viewelementsdisplaymenu.h @@ -0,0 +1,250 @@ +#ifndef __VIEWELEMENTSDM_H
+#define __VIEWELEMENTSDM_H
+
+#include "viewelement.h"
+#include "../extensions/scrapmanager.h"
+
+/******************************************************************
+* cVeDmHeader
+******************************************************************/
+class cVeDmHeader : public cViewElement {
+private:
+ char *title;
+ char *channelName;
+ int channelNumber;
+ char *channelId;
+ bool epgSearchFav;
+public:
+ cVeDmHeader(void);
+ virtual ~cVeDmHeader(void);
+ void SetTokenContainer(void);
+ void SetTitle(const char *title);
+ void SetChannel(const cChannel *channel);
+ void Set(eMenuCategory menuCat);
+ void IsEpgSearchFav(bool isFav) { epgSearchFav = isFav;} ;
+};
+
+/******************************************************************
+* cVeDmSortmode
+******************************************************************/
+class cVeDmSortmode : public cViewElement {
+private:
+ eMenuSortMode sortMode;
+ eMenuSortMode lastSortMode;
+public:
+ cVeDmSortmode(void);
+ virtual ~cVeDmSortmode(void);
+ void Reset(void) { lastSortMode = msmUnknown; }
+ void SetTokenContainer(void);
+ void Set(eMenuSortMode sortMode);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmColorbuttons
+******************************************************************/
+class cVeDmColorbuttons : public cViewElement {
+private:
+ bool changed;
+ char *red;
+ char *green;
+ char *yellow;
+ char *blue;
+public:
+ cVeDmColorbuttons(void);
+ virtual ~cVeDmColorbuttons(void);
+ void SetTokenContainer(void);
+ void SetButtons(const char *red, const char *green, const char *yellow, const char *blue);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmScrollbar
+******************************************************************/
+class cVeDmScrollbar : public cViewElement {
+private:
+public:
+ cVeDmScrollbar(void);
+ virtual ~cVeDmScrollbar(void);
+ void SetTokenContainer(void);
+ void SetList(int numDisplayed, int offset, int numMax);
+ void SetDetail(int height, int offset, bool end);
+};
+
+
+/******************************************************************
+* cVeDmTimers
+******************************************************************/
+class cVeDmTimers : public cViewElement {
+private:
+ int timerIndex;
+public:
+ cVeDmTimers(void);
+ virtual ~cVeDmTimers(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmCurrentschedule
+******************************************************************/
+class cVeDmCurrentschedule : public cViewElement, public cScrapManager {
+private:
+ const char *rec;
+ void ParseFromChannel(const cChannel *channel);
+ void ParseFromRecording(const cRecording *recording);
+ void RecName(string &path, string &name, string &folder);
+public:
+ cVeDmCurrentschedule(void);
+ virtual ~cVeDmCurrentschedule(void);
+ void SetTokenContainer(void);
+ void SetRecording(const char *currentRec);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmDiscusage
+******************************************************************/
+class cVeDmDiscusage : public cViewElement {
+private:
+public:
+ cVeDmDiscusage(void);
+ virtual ~cVeDmDiscusage(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmSystemload
+******************************************************************/
+class cVeDmSystemload : public cViewElement {
+private:
+ double lastSystemLoad;
+public:
+ cVeDmSystemload(void);
+ virtual ~cVeDmSystemload(void);
+ void Reset(void) { lastSystemLoad = -1.0f; }
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmSystemmemory
+******************************************************************/
+class cVeDmSystemmemory : public cViewElement {
+private:
+ int lastMemUsage;
+public:
+ cVeDmSystemmemory(void);
+ virtual ~cVeDmSystemmemory(void);
+ void Reset(void) { lastMemUsage = -1; }
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmTemperatures
+******************************************************************/
+class cVeDmTemperatures : public cViewElement {
+private:
+ int lastCpuTemp;
+ int lastGpuTemp;
+public:
+ cVeDmTemperatures(void);
+ virtual ~cVeDmTemperatures(void);
+ void Reset(void) { lastCpuTemp = -1; lastGpuTemp = -1; }
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmVdrstatistics
+******************************************************************/
+class cVeDmVdrstatistics : public cViewElement {
+private:
+ string lastVdrCPU;
+ string lastVdrMEM;
+public:
+ cVeDmVdrstatistics(void);
+ virtual ~cVeDmVdrstatistics(void);
+ void Reset(void) { lastVdrCPU = "undefined"; lastVdrMEM = "undefined"; }
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmLastrecordings
+******************************************************************/
+class cVeDmLastrecordings : public cViewElement, public cScrapManager {
+private:
+ int recIndex;
+ void RecName(string &path, string &name, string &folder);
+public:
+ cVeDmLastrecordings(void);
+ virtual ~cVeDmLastrecordings(void);
+ void SetTokenContainer(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmDetailheaderEpg
+******************************************************************/
+class cVeDmDetailheaderEpg : public cViewElement, public cScrapManager {
+private:
+ const cEvent *event;
+public:
+ cVeDmDetailheaderEpg(void);
+ virtual ~cVeDmDetailheaderEpg(void);
+ void SetTokenContainer(void);
+ void SetEvent(const cEvent *event);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmDetailheaderRec
+******************************************************************/
+class cVeDmDetailheaderRec : public cViewElement, public cScrapManager {
+private:
+ const cRecording *recording;
+public:
+ cVeDmDetailheaderRec(void);
+ virtual ~cVeDmDetailheaderRec(void);
+ void SetTokenContainer(void);
+ void SetRecording(const cRecording *rec);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmDetailheaderPlugin
+******************************************************************/
+class cVeDmDetailheaderPlugin : public cViewElement {
+private:
+ int plugId;
+ int plugMenuId;
+public:
+ cVeDmDetailheaderPlugin(void);
+ virtual ~cVeDmDetailheaderPlugin(void);
+ void SetPlugId(int id) { plugId = id; };
+ void SetPlugMenuId(int id) { plugMenuId = id; };
+ void SetTokenContainer(void);
+ void Set(skindesignerapi::cTokenContainer *tk);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDmTablabels
+******************************************************************/
+class cVeDmTablabels : public cViewElement {
+private:
+ int tabIndex;
+ int activeTab;
+ vector<const char*> tabs;
+public:
+ cVeDmTablabels(void);
+ virtual ~cVeDmTablabels(void);
+ void SetTokenContainer(void);
+ void SetTabs(vector<const char*> &newTabs);
+ void SetActiveTab(int activeTab) { SetDirty(); this->activeTab = activeTab; };
+ bool Parse(bool forced = false);
+};
+#endif //__VIEWELEMENTSDM_H
\ No newline at end of file diff --git a/coreengine/viewelementsdisplayreplay.c b/coreengine/viewelementsdisplayreplay.c new file mode 100644 index 0000000..06ec8f8 --- /dev/null +++ b/coreengine/viewelementsdisplayreplay.c @@ -0,0 +1,816 @@ +#include "viewelementsdisplayreplay.h"
+#include "../config.h"
+#include "../extensions/helpers.h"
+#include "../services/scraper2vdr.h"
+
+/******************************************************************
+* cVeDrRecTitle
+******************************************************************/
+cVeDrRecTitle::cVeDrRecTitle(void) {
+ recording = NULL;
+ title = NULL;
+}
+
+cVeDrRecTitle::~cVeDrRecTitle(void) {
+ free(title);
+}
+
+void cVeDrRecTitle::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{rectitle}", (int)eDRRecTitleST::rectitle);
+ tokenContainer->DefineStringToken("{recsubtitle}", (int)eDRRecTitleST::recsubtitle);
+ tokenContainer->DefineStringToken("{recdate}", (int)eDRRecTitleST::recdate);
+ tokenContainer->DefineStringToken("{rectime}", (int)eDRRecTitleST::rectime);
+ InheritTokenContainer();
+}
+
+void cVeDrRecTitle::Set(const cRecording *recording) {
+ this->recording = recording;
+}
+
+void cVeDrRecTitle::Set(const char *title) {
+ if (!title)
+ return;
+ free(this->title);
+ this->title = strdup(title);
+}
+
+bool cVeDrRecTitle::Parse(bool force) {
+ if (!cViewElement::Parse(force))
+ return false;
+ if (!recording && !title)
+ return false;
+
+ tokenContainer->Clear();
+ if (recording) {
+ const char *recName = NULL;
+ const cRecordingInfo *recInfo = recording->Info();
+ if (recInfo)
+ recName = recInfo->Title();
+ if (!recName)
+ recName = recording->Name();
+ tokenContainer->AddStringToken((int)eDRRecTitleST::rectitle, recName);
+ tokenContainer->AddStringToken((int)eDRRecTitleST::recsubtitle, recInfo ? recInfo->ShortText() : "");
+ tokenContainer->AddStringToken((int)eDRRecTitleST::recdate, *ShortDateString(recording->Start()));
+ tokenContainer->AddStringToken((int)eDRRecTitleST::rectime, *TimeString(recording->Start()));
+ } else if (title) {
+ tokenContainer->AddStringToken((int)eDRRecTitleST::rectitle, title);
+ }
+
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDrRecInfo
+******************************************************************/
+cVeDrRecInfo::cVeDrRecInfo(void) {
+ recording = NULL;
+}
+
+cVeDrRecInfo::~cVeDrRecInfo(void) {
+}
+
+void cVeDrRecInfo::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{resolution}", (int)eDRRecInfoST::resolution);
+ tokenContainer->DefineStringToken("{aspect}", (int)eDRRecInfoST::aspect);
+ tokenContainer->DefineIntToken("{screenwidth}", (int)eDRRecInfoIT::screenwidth);
+ tokenContainer->DefineIntToken("{screenheight}", (int)eDRRecInfoIT::screenheight);
+ tokenContainer->DefineIntToken("{isHD}", (int)eDRRecInfoIT::isHD);
+ tokenContainer->DefineIntToken("{isWideScreen}", (int)eDRRecInfoIT::isWideScreen);
+ InheritTokenContainer();
+}
+
+void cVeDrRecInfo::Set(const cRecording *recording) {
+ this->recording = recording;
+}
+
+bool cVeDrRecInfo::Parse(bool force) {
+ if (!cViewElement::Parse(force))
+ return false;
+ if (!recording)
+ return false;
+
+ 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);
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDRRecInfoIT::screenwidth, screenWidth);
+ tokenContainer->AddIntToken((int)eDRRecInfoIT::screenheight, screenHeight);
+ tokenContainer->AddIntToken((int)eDRRecInfoIT::isHD, isHD);
+ tokenContainer->AddIntToken((int)eDRRecInfoIT::isWideScreen, isWideScreen);
+ tokenContainer->AddStringToken((int)eDRRecInfoST::resolution, resName.c_str());
+ tokenContainer->AddStringToken((int)eDRRecInfoST::aspect, aspectName.c_str());
+
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDrCurrentTime
+******************************************************************/
+cVeDrCurrentTime::cVeDrCurrentTime(void) {
+ changed = true;
+ current = NULL;
+}
+
+cVeDrCurrentTime::~cVeDrCurrentTime(void) {
+ free(current);
+}
+
+void cVeDrCurrentTime::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{reccurrent}", (int)eDRCurrentTimeST::reccurrent);
+ InheritTokenContainer();
+}
+
+void cVeDrCurrentTime::Set(const char *current) {
+ if (!current)
+ return;
+ free(this->current);
+ this->current = strdup(current);
+ changed = true;
+}
+
+bool cVeDrCurrentTime::Parse(bool force) {
+ if (!cViewElement::Parse(force) || !changed)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDRCurrentTimeST::reccurrent, current);
+ SetDirty();
+ changed = false;
+ return true;
+}
+
+/******************************************************************
+* cVeDrTotalTime
+******************************************************************/
+cVeDrTotalTime::cVeDrTotalTime(void) {
+ changed = true;
+ total = NULL;
+ timeshiftActive = false;
+ timeshiftDuration = NULL;
+}
+
+cVeDrTotalTime::~cVeDrTotalTime(void) {
+ free(total);
+ free(timeshiftDuration);
+}
+
+void cVeDrTotalTime::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{rectotal}", (int)eDRTotalTimeST::rectotal);
+ tokenContainer->DefineStringToken("{timeshifttotal}", (int)eDRTotalTimeST::timeshifttotal);
+ tokenContainer->DefineIntToken("{timeshift}", (int)eDRTotalTimeIT::timeshift);
+ InheritTokenContainer();
+}
+
+void cVeDrTotalTime::Set(const char *total, bool timeshiftActive, const char *timeshiftDuration) {
+ if (!total)
+ return;
+ free(this->total);
+ this->total = strdup(total);
+ this->timeshiftActive = timeshiftActive;
+ free(this->timeshiftDuration);
+ this->timeshiftDuration = NULL;
+ if (timeshiftDuration)
+ this->timeshiftDuration = strdup(timeshiftDuration);
+ changed = true;
+}
+
+bool cVeDrTotalTime::Parse(bool force) {
+ if (!cViewElement::Parse(force) || !changed)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDRTotalTimeST::rectotal, total);
+ tokenContainer->AddStringToken((int)eDRTotalTimeST::timeshifttotal, timeshiftDuration);
+ tokenContainer->AddIntToken((int)eDRTotalTimeIT::timeshift, timeshiftActive);
+ SetDirty();
+ changed = false;
+ return true;
+}
+
+/******************************************************************
+* cVeDrEndTime
+******************************************************************/
+cVeDrEndTime::cVeDrEndTime(void) {
+ end = "";
+}
+
+cVeDrEndTime::~cVeDrEndTime(void) {
+}
+
+void cVeDrEndTime::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{recend}", (int)eDREndTimeST::recend);
+ InheritTokenContainer();
+}
+
+void cVeDrEndTime::Set(cString end) {
+ if (strcmp(*this->end, *end)) {
+ this->end = end;
+ changed = true;
+ }
+}
+
+bool cVeDrEndTime::Parse(bool force) {
+ if (!cViewElement::Parse(force) || !changed)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDREndTimeST::recend, *end);
+ SetDirty();
+ changed = false;
+ return true;
+}
+
+/******************************************************************
+* cVeDrProgressBar
+******************************************************************/
+cVeDrProgressBar::cVeDrProgressBar(void) {
+ current = -1;
+ total = -1;
+ timeshiftActive = false;
+ timeshiftTotal = -1;
+ changed = true;
+}
+
+cVeDrProgressBar::~cVeDrProgressBar(void) {
+}
+
+void cVeDrProgressBar::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{current}", (int)eDRProgressbarIT::current);
+ tokenContainer->DefineIntToken("{total}", (int)eDRProgressbarIT::total);
+ tokenContainer->DefineIntToken("{timeshift}", (int)eDRProgressbarIT::timeshift);
+ tokenContainer->DefineIntToken("{timeshifttotal}", (int)eDRProgressbarIT::timeshifttotal);
+ InheritTokenContainer();
+}
+
+void cVeDrProgressBar::Set(int current, int total, bool timeshiftActive, int timeshiftTotal) {
+ if (this->current == current)
+ return;
+ this->current = current;
+ this->total = total;
+ this->timeshiftActive = timeshiftActive;
+ this->timeshiftTotal = timeshiftTotal;
+ changed = true;
+}
+
+bool cVeDrProgressBar::Parse(bool force) {
+ if (!cViewElement::Parse(force) || !changed)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDRProgressbarIT::current, current);
+ tokenContainer->AddIntToken((int)eDRProgressbarIT::total, total);
+ tokenContainer->AddIntToken((int)eDRProgressbarIT::timeshift, timeshiftActive);
+ tokenContainer->AddIntToken((int)eDRProgressbarIT::timeshifttotal, timeshiftTotal);
+
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDrCutMarks
+******************************************************************/
+cVeDrCutMarks::cVeDrCutMarks(void) {
+ cutmarksIndex = -1;
+ lastMarks = NULL;
+ Reset();
+}
+
+cVeDrCutMarks::~cVeDrCutMarks(void) {
+ delete[] lastMarks;
+}
+
+void cVeDrCutMarks::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{timeshift}", (int)eDRCutmarksIT::timeshift);
+ tokenContainer->DefineLoopToken("{marks[position]}", (int)eDRCutmarksLT::position);
+ tokenContainer->DefineLoopToken("{marks[endposition]}", (int)eDRCutmarksLT::endposition);
+ tokenContainer->DefineLoopToken("{marks[total]}", (int)eDRCutmarksLT::total);
+ tokenContainer->DefineLoopToken("{marks[timeshifttotal]}", (int)eDRCutmarksLT::timeshifttotal);
+ tokenContainer->DefineLoopToken("{marks[active]}", (int)eDRCutmarksLT::active);
+ tokenContainer->DefineLoopToken("{marks[startmark]}", (int)eDRCutmarksLT::startmark);
+ cutmarksIndex = tokenContainer->LoopIndex("marks");
+ InheritTokenContainer();
+}
+
+void cVeDrCutMarks::Set(const cMarks *marks, int current, int total, bool timeshiftActive, int timeshiftTotal) {
+ this->marks = marks;
+ this->current = current;
+ this->total = total;
+ this->timeshiftActive = timeshiftActive;
+ this->timeshiftTotal = timeshiftTotal;
+}
+
+void cVeDrCutMarks::Reset(void) {
+ marks = NULL;
+ current = -1;
+ total = -1;
+ numMarksLast = 0;
+ delete[] lastMarks;
+ lastMarks = NULL;
+ markActive = -1;
+ timeshiftActive = false;
+ timeshiftTotal = -1;
+}
+
+bool cVeDrCutMarks::Parse(bool force) {
+ if (!cViewElement::Parse(force))
+ return false;
+ if (!marks || !MarksChanged()) {
+ return false;
+ }
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDRCutmarksIT::timeshift, timeshiftActive);
+ int numMarks = marks->Count();
+ vector<int> cutmarksInfo;
+ cutmarksInfo.push_back(numMarks);
+ tokenContainer->CreateLoopTokenContainer(&cutmarksInfo);
+ cString tot = cString::sprintf("%d", total);
+ cString timeshifttot = cString::sprintf("%d",timeshiftTotal);
+ int i = 0;
+ bool isStartMark = true;
+ for (const cMark *m = marks->First(); m; m = marks->Next(m)) {
+ tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::position, *cString::sprintf("%d", m->Position()));
+ tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::total, *tot);
+ if (timeshiftActive) {
+ tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::timeshifttotal, *timeshifttot);
+ }
+ tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::startmark, isStartMark ? "1" : "0");
+ tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::active, (m->Position() == current) ? "1" : "0");
+ const cMark *m2 = marks->Next(m);
+ if (m2) {
+ tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::endposition, *cString::sprintf("%d", m2->Position()));
+ } else {
+ tokenContainer->AddLoopToken(cutmarksIndex, i, (int)eDRCutmarksLT::endposition, *tot);
+ }
+ i++;
+ isStartMark = !isStartMark;
+ }
+ SetDirty();
+ return true;
+}
+
+bool cVeDrCutMarks::MarksChanged(void) {
+ 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();
+ 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();
+ return true;
+ }
+ i++;
+ }
+ return false;
+}
+
+void cVeDrCutMarks::RememberMarks(void) {
+ if (!marks)
+ return;
+ numMarksLast = marks->Count();
+ if (numMarksLast < 1)
+ return;
+ 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++;
+ }
+}
+
+/******************************************************************
+* cVeDrControlIcons
+******************************************************************/
+cVeDrControlIcons::cVeDrControlIcons(void) {
+ play = false;
+ forward = false;
+ speed = 0;
+ changed = true;
+}
+
+cVeDrControlIcons::~cVeDrControlIcons(void) {
+}
+
+void cVeDrControlIcons::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{play}", (int)eDRControlIconsIT::play);
+ tokenContainer->DefineIntToken("{pause}", (int)eDRControlIconsIT::pause);
+ tokenContainer->DefineIntToken("{forward}", (int)eDRControlIconsIT::forward);
+ tokenContainer->DefineIntToken("{forward1x}", (int)eDRControlIconsIT::forward1x);
+ tokenContainer->DefineIntToken("{forward2x}", (int)eDRControlIconsIT::forward2x);
+ tokenContainer->DefineIntToken("{forward3x}", (int)eDRControlIconsIT::forward3x);
+ tokenContainer->DefineIntToken("{rewind}", (int)eDRControlIconsIT::rewind);
+ tokenContainer->DefineIntToken("{rewind1x}", (int)eDRControlIconsIT::rewind1x);
+ tokenContainer->DefineIntToken("{rewind2x}", (int)eDRControlIconsIT::rewind2x);
+ tokenContainer->DefineIntToken("{rewind3x}", (int)eDRControlIconsIT::rewind3x);
+ InheritTokenContainer();
+}
+
+void cVeDrControlIcons::Set(bool play, bool forward, int speed) {
+ this->play = play;
+ this->forward = forward;
+ this->speed = speed;
+ changed = true;
+}
+
+bool cVeDrControlIcons::Parse(bool force) {
+ if (!cViewElement::Parse(force) || !changed)
+ return false;
+
+ 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;
+ }
+ }
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::play, isPlay);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::pause, isPause);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::forward, isFF);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::forward1x, isFF1x);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::forward2x, isFF2x);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::forward3x, isFF3x);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind, isRew);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind1x, isRew1x);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind2x, isRew2x);
+ tokenContainer->AddIntToken((int)eDRControlIconsIT::rewind3x, isRew3x);
+ SetDirty();
+ changed = false;
+ return true;
+}
+
+/******************************************************************
+* cVeDrProgressModeonly
+******************************************************************/
+cVeDrProgressModeonly::cVeDrProgressModeonly(void) {
+ fps = 0.0f;
+ current = 0;
+ total = 0;
+ changed = true;
+}
+
+cVeDrProgressModeonly::~cVeDrProgressModeonly(void) {
+}
+
+void cVeDrProgressModeonly::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{current}", (int)eDRProgressModeonlyIT::current);
+ tokenContainer->DefineIntToken("{total}", (int)eDRProgressModeonlyIT::total);
+ tokenContainer->DefineStringToken("{timecurrent}", (int)eDRProgressModeonlyST::timecurrent);
+ tokenContainer->DefineStringToken("{timetotal}", (int)eDRProgressModeonlyST::timetotal);
+ InheritTokenContainer();
+}
+
+void cVeDrProgressModeonly::Set(double fps, int current, int total) {
+ if (this->current == current)
+ return;
+ this->fps = fps;
+ this->current = current;
+ this->total = total;
+ changed = true;
+}
+
+bool cVeDrProgressModeonly::Parse(bool force) {
+ if (!cViewElement::Parse(force) || !changed)
+ return false;
+
+ string cur = GetTimeString((double)current / fps);
+ string tot = GetTimeString((double)total / fps);
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDRProgressModeonlyIT::current, current);
+ tokenContainer->AddIntToken((int)eDRProgressModeonlyIT::total, total);
+ tokenContainer->AddStringToken((int)eDRProgressModeonlyST::timecurrent, cur.c_str());
+ tokenContainer->AddStringToken((int)eDRProgressModeonlyST::timetotal, tot.c_str());
+
+ SetDirty();
+ changed = false;
+ return true;
+}
+
+/******************************************************************
+* cVeDrJump
+******************************************************************/
+cVeDrJump::cVeDrJump(void) {
+ jump = NULL;
+ changed = false;
+}
+
+cVeDrJump::~cVeDrJump(void) {
+ free(jump);
+}
+
+void cVeDrJump::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{jump}", (int)eDRJumpST::jump);
+ InheritTokenContainer();
+}
+
+void cVeDrJump::Set(const char *jump) {
+ if (!jump)
+ return;
+ free(this->jump);
+ this->jump = strdup(jump);
+ changed = true;
+}
+
+bool cVeDrJump::Parse(bool force) {
+ if (!cViewElement::Parse(force) || !changed)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDRJumpST::jump, jump);
+ changed = false;
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDrOnPause
+******************************************************************/
+cVeDrOnPause::cVeDrOnPause(void) {
+ actorsIndex = -1;
+ recfilename = NULL;
+}
+
+cVeDrOnPause::~cVeDrOnPause(void) {
+ free(recfilename);
+}
+
+void cVeDrOnPause::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{name}", (int)eDROnpauseST::name);
+ tokenContainer->DefineStringToken("{shorttext}", (int)eDROnpauseST::shorttext);
+ tokenContainer->DefineStringToken("{description}", (int)eDROnpauseST::description);
+ tokenContainer->DefineStringToken("{date}", (int)eDROnpauseST::date);
+ tokenContainer->DefineStringToken("{time}", (int)eDROnpauseST::time);
+ tokenContainer->DefineStringToken("{durationminutes}", (int)eDROnpauseST::durationminutes);
+ tokenContainer->DefineStringToken("{durationeventminutes}", (int)eDROnpauseST::durationeventminutes);
+ tokenContainer->DefineIntToken("{daynumeric}", (int)eDROnpauseIT::daynumeric);
+ tokenContainer->DefineIntToken("{month}", (int)eDROnpauseIT::month);
+ tokenContainer->DefineIntToken("{year}", (int)eDROnpauseIT::year);
+ tokenContainer->DefineIntToken("{duration}", (int)eDROnpauseIT::duration);
+ tokenContainer->DefineIntToken("{durationhours}", (int)eDROnpauseIT::durationhours);
+ tokenContainer->DefineIntToken("{durationevent}", (int)eDROnpauseIT::durationevent);
+ tokenContainer->DefineIntToken("{durationeventhours}", (int)eDROnpauseIT::durationeventhours);
+ tokenContainer->DefineStringToken("{movietitle}", (int)eScraperST::movietitle);
+ tokenContainer->DefineStringToken("{movieoriginalTitle}", (int)eScraperST::movieoriginalTitle);
+ tokenContainer->DefineStringToken("{movietagline}", (int)eScraperST::movietagline);
+ tokenContainer->DefineStringToken("{movieoverview}", (int)eScraperST::movieoverview);
+ tokenContainer->DefineStringToken("{moviegenres}", (int)eScraperST::moviegenres);
+ tokenContainer->DefineStringToken("{moviehomepage}", (int)eScraperST::moviehomepage);
+ tokenContainer->DefineStringToken("{moviereleasedate}", (int)eScraperST::moviereleasedate);
+ tokenContainer->DefineStringToken("{moviepopularity}", (int)eScraperST::moviepopularity);
+ tokenContainer->DefineStringToken("{movievoteaverage}", (int)eScraperST::movievoteaverage);
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperST::posterpath);
+ tokenContainer->DefineStringToken("{fanartpath}", (int)eScraperST::fanartpath);
+ tokenContainer->DefineStringToken("{moviecollectionName}", (int)eScraperST::moviecollectionName);
+ tokenContainer->DefineStringToken("{collectionposterpath}", (int)eScraperST::collectionposterpath);
+ tokenContainer->DefineStringToken("{collectionfanartpath}", (int)eScraperST::collectionfanartpath);
+ tokenContainer->DefineStringToken("{seriesname}", (int)eScraperST::seriesname);
+ tokenContainer->DefineStringToken("{seriesoverview}", (int)eScraperST::seriesoverview);
+ tokenContainer->DefineStringToken("{seriesfirstaired}", (int)eScraperST::seriesfirstaired);
+ tokenContainer->DefineStringToken("{seriesnetwork}", (int)eScraperST::seriesnetwork);
+ tokenContainer->DefineStringToken("{seriesgenre}", (int)eScraperST::seriesgenre);
+ tokenContainer->DefineStringToken("{seriesrating}", (int)eScraperST::seriesrating);
+ tokenContainer->DefineStringToken("{seriesstatus}", (int)eScraperST::seriesstatus);
+ tokenContainer->DefineStringToken("{episodetitle}", (int)eScraperST::episodetitle);
+ tokenContainer->DefineStringToken("{episodefirstaired}", (int)eScraperST::episodefirstaired);
+ tokenContainer->DefineStringToken("{episodegueststars}", (int)eScraperST::episodegueststars);
+ tokenContainer->DefineStringToken("{episodeoverview}", (int)eScraperST::episodeoverview);
+ tokenContainer->DefineStringToken("{episoderating}", (int)eScraperST::episoderating);
+ tokenContainer->DefineStringToken("{episodeimagepath}", (int)eScraperST::episodeimagepath);
+ tokenContainer->DefineStringToken("{seasonposterpath}", (int)eScraperST::seasonposterpath);
+ tokenContainer->DefineStringToken("{seriesposter1path}", (int)eScraperST::seriesposter1path);
+ tokenContainer->DefineStringToken("{seriesposter2path}", (int)eScraperST::seriesposter2path);
+ tokenContainer->DefineStringToken("{seriesposter3path}", (int)eScraperST::seriesposter3path);
+ tokenContainer->DefineStringToken("{seriesfanart1path}", (int)eScraperST::seriesfanart1path);
+ tokenContainer->DefineStringToken("{seriesfanart2path}", (int)eScraperST::seriesfanart2path);
+ tokenContainer->DefineStringToken("{seriesfanart3path}", (int)eScraperST::seriesfanart3path);
+ tokenContainer->DefineStringToken("{seriesbanner1path}", (int)eScraperST::seriesbanner1path);
+ tokenContainer->DefineStringToken("{seriesbanner2path}", (int)eScraperST::seriesbanner2path);
+ tokenContainer->DefineStringToken("{seriesbanner3path}", (int)eScraperST::seriesbanner3path);
+ tokenContainer->DefineIntToken("{ismovie}", (int)eScraperIT::ismovie);
+ tokenContainer->DefineIntToken("{moviebudget}", (int)eScraperIT::moviebudget);
+ tokenContainer->DefineIntToken("{movierevenue}", (int)eScraperIT::movierevenue);
+ tokenContainer->DefineIntToken("{movieadult}", (int)eScraperIT::movieadult);
+ tokenContainer->DefineIntToken("{movieruntime}", (int)eScraperIT::movieruntime);
+ tokenContainer->DefineIntToken("{isseries}", (int)eScraperIT::isseries);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperIT::posterheight);
+ tokenContainer->DefineIntToken("{fanartwidth}", (int)eScraperIT::fanartwidth);
+ tokenContainer->DefineIntToken("{fanartheight}", (int)eScraperIT::fanartheight);
+ tokenContainer->DefineIntToken("{movieiscollection}", (int)eScraperIT::movieiscollection);
+ tokenContainer->DefineIntToken("{collectionposterwidth}", (int)eScraperIT::collectionposterwidth);
+ tokenContainer->DefineIntToken("{collectionposterheight}", (int)eScraperIT::collectionposterheight);
+ tokenContainer->DefineIntToken("{collectionfanartwidth}", (int)eScraperIT::collectionfanartwidth);
+ tokenContainer->DefineIntToken("{collectionfanartheight}", (int)eScraperIT::collectionfanartheight);
+ tokenContainer->DefineIntToken("{epgpicavailable}", (int)eScraperIT::epgpicavailable);
+ tokenContainer->DefineIntToken("{episodenumber}", (int)eScraperIT::episodenumber);
+ tokenContainer->DefineIntToken("{episodeseason}", (int)eScraperIT::episodeseason);
+ tokenContainer->DefineIntToken("{episodeimagewidth}", (int)eScraperIT::episodeimagewidth);
+ tokenContainer->DefineIntToken("{episodeimageheight}", (int)eScraperIT::episodeimageheight);
+ tokenContainer->DefineIntToken("{seasonposterwidth}", (int)eScraperIT::seasonposterwidth);
+ tokenContainer->DefineIntToken("{seasonposterheight}", (int)eScraperIT::seasonposterheight);
+ tokenContainer->DefineIntToken("{seriesposter1width}", (int)eScraperIT::seriesposter1width);
+ tokenContainer->DefineIntToken("{seriesposter1height}", (int)eScraperIT::seriesposter1height);
+ tokenContainer->DefineIntToken("{seriesposter2width}", (int)eScraperIT::seriesposter2width);
+ tokenContainer->DefineIntToken("{seriesposter2height}", (int)eScraperIT::seriesposter2height);
+ tokenContainer->DefineIntToken("{seriesposter3width}", (int)eScraperIT::seriesposter3width);
+ tokenContainer->DefineIntToken("{seriesposter3height}", (int)eScraperIT::seriesposter3height);
+ tokenContainer->DefineIntToken("{seriesfanart1width}", (int)eScraperIT::seriesfanart1width);
+ tokenContainer->DefineIntToken("{seriesfanart1height}", (int)eScraperIT::seriesfanart1height);
+ tokenContainer->DefineIntToken("{seriesfanart2width}", (int)eScraperIT::seriesfanart2width);
+ tokenContainer->DefineIntToken("{seriesfanart2height}", (int)eScraperIT::seriesfanart2height);
+ tokenContainer->DefineIntToken("{seriesfanart3width}", (int)eScraperIT::seriesfanart3width);
+ tokenContainer->DefineIntToken("{seriesfanart3height}", (int)eScraperIT::seriesfanart3height);
+ tokenContainer->DefineIntToken("{seriesbanner1width}", (int)eScraperIT::seriesbanner1width);
+ tokenContainer->DefineIntToken("{seriesbanner1height}", (int)eScraperIT::seriesbanner1height);
+ tokenContainer->DefineIntToken("{seriesbanner2width}", (int)eScraperIT::seriesbanner2width);
+ tokenContainer->DefineIntToken("{seriesbanner2height}", (int)eScraperIT::seriesbanner2height);
+ tokenContainer->DefineIntToken("{seriesbanner3width}", (int)eScraperIT::seriesbanner3width);
+ tokenContainer->DefineIntToken("{seriesbanner3height}", (int)eScraperIT::seriesbanner3height);
+ tokenContainer->DefineLoopToken("{actors[name]}", (int)eScraperLT::name);
+ tokenContainer->DefineLoopToken("{actors[role]}", (int)eScraperLT::role);
+ tokenContainer->DefineLoopToken("{actors[thumb]}", (int)eScraperLT::thumb);
+ tokenContainer->DefineLoopToken("{actors[thumbwidth]}", (int)eScraperLT::thumbwidth);
+ tokenContainer->DefineLoopToken("{actors[thumbheight]}", (int)eScraperLT::thumbheight);
+ actorsIndex = tokenContainer->LoopIndex("actors");
+ InheritTokenContainer();
+}
+
+void cVeDrOnPause::Set(const char *recfilename) {
+ if (!recfilename)
+ return;
+ free(this->recfilename);
+ this->recfilename = strdup(recfilename);
+}
+
+bool cVeDrOnPause::Parse(bool force) {
+ if (!cViewElement::Parse(force))
+ return false;
+ if (!recfilename)
+ return false;
+ const cRecording *recording = new cRecording(recfilename);
+ if (!recording)
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddStringToken((int)eDROnpauseST::name, recording->Name());
+ const cRecordingInfo *info = recording->Info();
+ if (info) {
+ tokenContainer->AddStringToken((int)eDROnpauseST::shorttext, info->ShortText());
+ tokenContainer->AddStringToken((int)eDROnpauseST::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);
+ }
+ tokenContainer->AddStringToken((int)eDROnpauseST::date, recDate.c_str());
+ tokenContainer->AddStringToken((int)eDROnpauseST::time, recTime.c_str());
+ time_t startTime = event->StartTime();
+ struct tm * sStartTime = localtime(&startTime);
+ tokenContainer->AddIntToken((int)eDROnpauseIT::year, sStartTime->tm_year + 1900);
+ tokenContainer->AddIntToken((int)eDROnpauseIT::daynumeric, sStartTime->tm_mday);
+ tokenContainer->AddIntToken((int)eDROnpauseIT::month, sStartTime->tm_mon+1);
+ int duration = event->Duration() / 60;
+ int recDuration = recording->LengthInSeconds();
+ recDuration = (recDuration>0)?(recDuration / 60):0;
+ tokenContainer->AddIntToken((int)eDROnpauseIT::duration, recDuration);
+ tokenContainer->AddIntToken((int)eDROnpauseIT::durationhours, recDuration / 60);
+ tokenContainer->AddStringToken((int)eDROnpauseST::durationminutes, *cString::sprintf("%.2d", recDuration%60));
+ tokenContainer->AddIntToken((int)eDROnpauseIT::durationevent, duration);
+ tokenContainer->AddIntToken((int)eDROnpauseIT::durationeventhours, duration / 60);
+ tokenContainer->AddStringToken((int)eDROnpauseST::durationeventminutes, *cString::sprintf("%.2d", duration%60));
+ }
+ }
+
+ vector<int> loopInfo;
+ bool scrapInfoAvailable = LoadFullScrapInfo(NULL, recording);
+ int numActors = NumActors();
+ loopInfo.push_back(numActors);
+ tokenContainer->CreateLoopTokenContainer(&loopInfo);
+ if (scrapInfoAvailable) {
+ SetFullScrapInfo(tokenContainer, actorsIndex);
+ }
+
+ SetDirty();
+ delete recording;
+ return true;
+}
+
+/******************************************************************
+* cVeDrScraperContent
+******************************************************************/
+cVeDrScraperContent::cVeDrScraperContent(void) {
+ recording = NULL;
+}
+
+cVeDrScraperContent::~cVeDrScraperContent(void) {
+}
+
+void cVeDrScraperContent::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineStringToken("{posterpath}", (int)eScraperPosterBannerST::posterpath);
+ tokenContainer->DefineStringToken("{bannerpath}", (int)eScraperPosterBannerST::bannerpath);
+ tokenContainer->DefineStringToken("{mediapath}", (int)eScraperPosterBannerST::mediapath);
+ tokenContainer->DefineIntToken("{posterwidth}", (int)eScraperPosterBannerIT::posterwidth);
+ tokenContainer->DefineIntToken("{posterheight}", (int)eScraperPosterBannerIT::posterheight);
+ tokenContainer->DefineIntToken("{hasPoster}", (int)eScraperPosterBannerIT::hasposter);
+ tokenContainer->DefineIntToken("{bannerwidth}", (int)eScraperPosterBannerIT::bannerwidth);
+ tokenContainer->DefineIntToken("{bannerheight}", (int)eScraperPosterBannerIT::bannerheight);
+ tokenContainer->DefineIntToken("{hasBanner}", (int)eScraperPosterBannerIT::hasbanner);
+ tokenContainer->DefineIntToken("{mediawidth}", (int)eScraperPosterBannerIT::mediawidth);
+ tokenContainer->DefineIntToken("{mediaheight}", (int)eScraperPosterBannerIT::mediaheight);
+ tokenContainer->DefineIntToken("{isbanner}", (int)eScraperPosterBannerIT::isbanner);
+ InheritTokenContainer();
+}
+
+void cVeDrScraperContent::Set(const cRecording *recording) {
+ this->recording = recording;
+}
+
+bool cVeDrScraperContent::Parse(bool force) {
+ if (!cViewElement::Parse(force))
+ return false;
+ if (!recording)
+ return false;
+ SetPosterBanner(tokenContainer, NULL, recording);
+ SetDirty();
+ return true;
+}
diff --git a/coreengine/viewelementsdisplayreplay.h b/coreengine/viewelementsdisplayreplay.h new file mode 100644 index 0000000..fc25655 --- /dev/null +++ b/coreengine/viewelementsdisplayreplay.h @@ -0,0 +1,206 @@ +#ifndef __VIEWELEMENTSDR_H
+#define __VIEWELEMENTSDR_H
+
+#include "viewelement.h"
+#include "../extensions/scrapmanager.h"
+
+/******************************************************************
+* cVeDrRecTitle
+******************************************************************/
+class cVeDrRecTitle : public cViewElement {
+private:
+ const cRecording *recording;
+ char *title;
+public:
+ cVeDrRecTitle(void);
+ virtual ~cVeDrRecTitle(void);
+ void SetTokenContainer(void);
+ void Set(const cRecording *recording);
+ void Set(const char *title);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrRecInfo
+******************************************************************/
+class cVeDrRecInfo : public cViewElement {
+private:
+ const cRecording *recording;
+public:
+ cVeDrRecInfo(void);
+ virtual ~cVeDrRecInfo(void);
+ void SetTokenContainer(void);
+ void Set(const cRecording *recording);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrCurrentTime
+******************************************************************/
+class cVeDrCurrentTime : public cViewElement {
+private:
+ bool changed;
+ char *current;
+public:
+ cVeDrCurrentTime(void);
+ virtual ~cVeDrCurrentTime(void);
+ void SetTokenContainer(void);
+ void Set(const char *current);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrTotalTime
+******************************************************************/
+class cVeDrTotalTime : public cViewElement {
+private:
+ bool changed;
+ char *total;
+ bool timeshiftActive;
+ char *timeshiftDuration;
+public:
+ cVeDrTotalTime(void);
+ virtual ~cVeDrTotalTime(void);
+ void SetTokenContainer(void);
+ void Set(const char *total, bool timeshiftActive, const char *timeshiftDuration);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrEndTime
+******************************************************************/
+class cVeDrEndTime : public cViewElement {
+private:
+ cString end;
+ bool changed;
+public:
+ cVeDrEndTime(void);
+ virtual ~cVeDrEndTime(void);
+ void SetTokenContainer(void);
+ void Set(cString end);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrProgressBar
+******************************************************************/
+class cVeDrProgressBar : public cViewElement {
+private:
+ int current;
+ int total;
+ bool timeshiftActive;
+ int timeshiftTotal;
+ bool changed;
+public:
+ cVeDrProgressBar(void);
+ virtual ~cVeDrProgressBar(void);
+ void SetTokenContainer(void);
+ void Set(int current, int total, bool timeshiftActive, int timeshiftTotal);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrCutMarks
+******************************************************************/
+class cVeDrCutMarks : public cViewElement {
+private:
+ int cutmarksIndex;
+ const cMarks *marks;
+ int current;
+ int total;
+ bool timeshiftActive;
+ int timeshiftTotal;
+ int numMarksLast;
+ int *lastMarks;
+ int markActive;
+ bool MarksChanged(void);
+ void RememberMarks(void);
+public:
+ cVeDrCutMarks(void);
+ virtual ~cVeDrCutMarks(void);
+ void SetTokenContainer(void);
+ void Set(const cMarks *marks, int current, int total, bool timeshiftActive, int timeshiftTotal);
+ void Reset(void);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrControlIcons
+******************************************************************/
+class cVeDrControlIcons : public cViewElement {
+private:
+ bool play;
+ bool forward;
+ int speed;
+ bool changed;
+public:
+ cVeDrControlIcons(void);
+ virtual ~cVeDrControlIcons(void);
+ void SetTokenContainer(void);
+ void Set(bool play, bool forward, int speed);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrProgressModeonly
+******************************************************************/
+class cVeDrProgressModeonly : public cViewElement {
+private:
+ double fps;
+ int current;
+ int total;
+ bool changed;
+public:
+ cVeDrProgressModeonly(void);
+ virtual ~cVeDrProgressModeonly(void);
+ void SetTokenContainer(void);
+ void Set(double fps, int current, int total);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrJump
+******************************************************************/
+class cVeDrJump : public cViewElement {
+private:
+ char *jump;
+ bool changed;
+public:
+ cVeDrJump(void);
+ virtual ~cVeDrJump(void);
+ void SetTokenContainer(void);
+ void Set(const char *jump);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrOnPause
+******************************************************************/
+class cVeDrOnPause : public cViewElement, public cScrapManager {
+private:
+ int actorsIndex;
+ char *recfilename;
+public:
+ cVeDrOnPause(void);
+ virtual ~cVeDrOnPause(void);
+ int Delay(void) { return attribs->Delay() * 1000; };
+ void SetTokenContainer(void);
+ void Set(const char *recfilename);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDrScraperContent
+******************************************************************/
+class cVeDrScraperContent : public cViewElement, public cScrapManager {
+private:
+ const cRecording *recording;
+public:
+ cVeDrScraperContent(void);
+ virtual ~cVeDrScraperContent(void);
+ void SetTokenContainer(void);
+ void Set(const cRecording *recording);
+ bool Parse(bool forced = false);
+};
+
+#endif //__VIEWELEMENTSDR_H
\ No newline at end of file diff --git a/coreengine/viewelementsdisplaytracks.c b/coreengine/viewelementsdisplaytracks.c new file mode 100644 index 0000000..d5ef124 --- /dev/null +++ b/coreengine/viewelementsdisplaytracks.c @@ -0,0 +1,84 @@ +#include "viewelementsdisplaytracks.h"
+
+/******************************************************************
+* cVeDtBackground
+******************************************************************/
+cVeDtBackground::cVeDtBackground(void) {
+ numTracks = 0;
+}
+
+cVeDtBackground::~cVeDtBackground(void) {
+}
+
+void cVeDtBackground::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{numtracks}", (int)eDTBackgroundIT::numtracks);
+ InheritTokenContainer();
+}
+
+void cVeDtBackground::Set(int numTracks) {
+ this->numTracks = numTracks;
+}
+
+bool cVeDtBackground::Parse(bool forced) {
+ if (!cViewElement::Parse(forced))
+ return false;
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDTBackgroundIT::numtracks, numTracks);
+ SetDirty();
+ return true;
+}
+
+/******************************************************************
+* cVeDtHeader
+******************************************************************/
+cVeDtHeader::cVeDtHeader(void) {
+ title = NULL;
+ audioChannel = 0;
+ numTracks = 0;
+ changed = true;
+}
+
+cVeDtHeader::~cVeDtHeader(void) {
+ free(title);
+}
+
+void cVeDtHeader::SetTokenContainer(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{numtracks}", (int)eDTHeaderIT::numtracks);
+ tokenContainer->DefineIntToken("{isstereo}", (int)eDTHeaderIT::isstereo);
+ tokenContainer->DefineIntToken("{isac3}", (int)eDTHeaderIT::isac3);
+ tokenContainer->DefineStringToken("{title}", (int)eDTHeaderST::title);
+ InheritTokenContainer();
+}
+
+void cVeDtHeader::SetTitle(const char *title) {
+ if (!title)
+ return;
+ free(this->title);
+ this->title = strdup(title);
+ changed = true;
+}
+
+void cVeDtHeader::SetNumtracks(int numTracks) {
+ this->numTracks = numTracks;
+ changed = true;
+}
+
+void cVeDtHeader::SetAudiochannel(int audioChannel) {
+ this->audioChannel = audioChannel;
+ changed = true;
+}
+
+bool cVeDtHeader::Parse(bool forced) {
+ if (!cViewElement::Parse(forced) || !changed)
+ return false;
+
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken((int)eDTHeaderIT::numtracks, numTracks);
+ tokenContainer->AddIntToken((int)eDTHeaderIT::isstereo, (audioChannel < 0) ? false : true);
+ tokenContainer->AddIntToken((int)eDTHeaderIT::isac3, (audioChannel < 0) ? true : false);
+ tokenContainer->AddStringToken((int)eDTHeaderST::title, title);
+ SetDirty();
+ return true;
+}
\ No newline at end of file diff --git a/coreengine/viewelementsdisplaytracks.h b/coreengine/viewelementsdisplaytracks.h new file mode 100644 index 0000000..7529855 --- /dev/null +++ b/coreengine/viewelementsdisplaytracks.h @@ -0,0 +1,40 @@ +#ifndef __VIEWELEMENTSDT_H
+#define __VIEWELEMENTSDT_H
+
+#include <vdr/menu.h>
+#include "viewelement.h"
+
+/******************************************************************
+* cVeDtBackground
+******************************************************************/
+class cVeDtBackground : public cViewElement {
+private:
+ int numTracks;
+public:
+ cVeDtBackground(void);
+ virtual ~cVeDtBackground(void);
+ void SetTokenContainer(void);
+ void Set(int numTracks);
+ bool Parse(bool forced = false);
+};
+
+/******************************************************************
+* cVeDtHeader
+******************************************************************/
+class cVeDtHeader : public cViewElement {
+private:
+ char *title;
+ int audioChannel;
+ int numTracks;
+ bool changed;
+public:
+ cVeDtHeader(void);
+ virtual ~cVeDtHeader(void);
+ void SetTokenContainer(void);
+ void SetTitle(const char *title);
+ void SetNumtracks(int numTracks);
+ void SetAudiochannel(int audioChannel);
+ bool Parse(bool forced = false);
+};
+
+#endif //__VIEWELEMENTSDT_H
\ No newline at end of file diff --git a/coreengine/viewgrid.c b/coreengine/viewgrid.c new file mode 100644 index 0000000..6f28ef4 --- /dev/null +++ b/coreengine/viewgrid.c @@ -0,0 +1,188 @@ +#include "viewgrid.h"
+#include "../extensions/helpers.h"
+
+cViewGrid::cViewGrid(void) {
+ id = -1;
+ plugId = -1;
+ viewId = -1;
+ globals = NULL;
+ attribs = new cViewElementAttribs((int)eViewElementAttribs::count);
+ gridTpl = NULL;
+ gridsize = GRIDSIZE;
+ grid = new cGridElement*[gridsize];
+ for (int i=0; i < gridsize; i++) {
+ grid[i] = NULL;
+ }
+ gridMin = 0;
+ gridMax = -1;
+}
+
+cViewGrid::~cViewGrid(void) {
+ delete attribs;
+ delete gridTpl;
+}
+
+void cViewGrid::SetGlobals(cGlobals *globals) {
+ this->globals = globals;
+}
+
+void cViewGrid::SetContainer(int x, int y, int width, int height) {
+ container.SetX(x);
+ container.SetY(y);
+ container.SetWidth(width);
+ container.SetHeight(height);
+}
+
+void cViewGrid::SetAttributes(vector<stringpair> &attributes) {
+ attribs->Set(attributes);
+}
+
+void cViewGrid::AddGridElement(cGridElement *gridElement) {
+ gridTpl = gridElement;
+}
+
+const char *cViewGrid::Name(void) {
+ return attribs->Name();
+}
+
+void cViewGrid::SetTokenContainer(void) {
+ if (!gridTpl)
+ return;
+ gridTpl->SetId(id);
+ gridTpl->SetPluginId(plugId);
+ gridTpl->SetViewId(viewId);
+ gridTpl->SetTokenContainer();
+}
+
+void cViewGrid::PreCache(void) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->SetGlobals(globals);
+ attribs->Cache();
+ gridTpl->SetGlobals(globals);
+ gridTpl->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ gridTpl->Cache();
+
+}
+
+void cViewGrid::CheckSize(int id) {
+ if (id < gridsize)
+ return;
+ int newgridsize = gridsize + GRIDSIZE;
+ while (newgridsize < id)
+ newgridsize += gridsize;
+ cGridElement **gridNew = new cGridElement*[newgridsize];
+ int i=0;
+ bool foundFirst = false;
+ for (; i < gridsize; i++) {
+ if (!foundFirst && grid[i]) {
+ foundFirst = true;
+ gridMin = i;
+ }
+ gridNew[i] = grid[i];
+ }
+ gridsize = newgridsize;
+ for (; i < gridsize; i++) {
+ gridNew[i] = NULL;
+ }
+ delete[] grid;
+ grid = gridNew;
+}
+
+void cViewGrid::SetTokens(int gId, skindesignerapi::cTokenContainer *tk) {
+ if (!grid[gId]) {
+ return;
+ }
+ grid[gId]->Set(tk);
+}
+
+void cViewGrid::PositionGrid(int gId, double x, double y, double width, double height) {
+ int gridX = attribs->X() + x * attribs->Width();
+ int gridY = attribs->Y() + y * attribs->Height();
+ int gridWidth = width * attribs->Width();
+ int gridHeight = height * attribs->Height();
+ if (!grid[gId]) {
+ if (gId >= gridMax)
+ gridMax = gId+1;
+ grid[gId] = CreateGrid(gridX, gridY, gridWidth, gridHeight);
+ } else {
+ if (grid[gId]->Width() == gridWidth && grid[gId]->Height() == gridHeight) {
+ grid[gId]->SetPosition(gridX, gridY, gridWidth, gridHeight);
+ } else {
+ cGridElement *ge = CreateGrid(gridX, gridY, gridWidth, gridHeight);
+ ge->Set(grid[gId]->GetTokenContainer());
+ grid[gId]->Close();
+ delete grid[gId];
+ grid[gId] = ge;
+ }
+ grid[gId]->SetDirty();
+ }
+}
+
+void cViewGrid::SetCurrentGrid(int gId, bool current) {
+ if (gId >= 0 && grid[gId]) {
+ grid[gId]->SetCurrent(current);
+ }
+}
+
+void cViewGrid::DeleteGrid(int gId) {
+ if (!grid[gId])
+ return;
+ grid[gId]->Close();
+ delete grid[gId];
+ grid[gId] = NULL;
+}
+
+void cViewGrid::ClearGrids(void) {
+ for (int i = 0; i < gridsize; i++) {
+ if (!grid[i])
+ continue;
+ grid[i]->Close();
+ delete grid[i];
+ grid[i] = NULL;
+ }
+}
+
+void cViewGrid::Render(void) {
+ for (int i = gridMin; i < gridMax; i++) {
+ if (grid[i] && grid[i]->Parse()) {
+ grid[i]->Render();
+ }
+ }
+}
+
+cGridElement *cViewGrid::CreateGrid(int x, int y, int width, int height) {
+ cGridElement *ge = new cGridElement(*gridTpl);
+ ge->SetAreaX(x);
+ ge->SetAreaY(y);
+ ge->SetAreaWidth(width);
+ ge->SetAreaHeight(height);
+ return ge;
+}
+
+void cViewGrid::Close(void) {
+ ClearGrids();
+ gridsize = GRIDSIZE;
+ delete[] grid;
+ grid = new cGridElement*[gridsize];
+ for (int i=0; i < gridsize; i++) {
+ grid[i] = NULL;
+ }
+ gridMin = 0;
+ gridMax = -1;
+}
+
+void cViewGrid::Hide(void) {
+ for (int i = 0; i < gridsize; i++) {
+ if (grid[i]) {
+ grid[i]->Hide();
+ }
+ }
+}
+
+void cViewGrid::Show(void) {
+ for (int i = 0; i < gridsize; i++) {
+ if (grid[i]) {
+ grid[i]->Show();
+ }
+ }
+}
diff --git a/coreengine/viewgrid.h b/coreengine/viewgrid.h new file mode 100644 index 0000000..1bcbd74 --- /dev/null +++ b/coreengine/viewgrid.h @@ -0,0 +1,47 @@ +#ifndef __VIEWGRID_H
+#define __VIEWGRID_H
+
+#define GRIDSIZE 500
+
+#include "gridelement.h"
+
+class cViewGrid {
+protected:
+ cRect container;
+ cGlobals *globals;
+ cViewElementAttribs *attribs;
+ cGridElement *gridTpl;
+ int gridsize;
+ cGridElement **grid;
+ int gridMin;
+ int gridMax;
+ int id;
+ int viewId;
+ int plugId;
+ cGridElement *CreateGrid(int x, int y, int width, int height);
+public:
+ cViewGrid(void);
+ virtual ~cViewGrid(void);
+ void SetGlobals(cGlobals *globals);
+ void SetContainer(int x, int y, int width, int height);
+ void SetAttributes(vector<stringpair> &attributes);
+ void SetId(int id) { this->id = id; };
+ void SetPluginId(int plugId) { this->plugId = plugId; };
+ void SetViewId(int viewId) { this->viewId = viewId; };
+ void AddGridElement(cGridElement *gridElement);
+ const char *Name(void);
+ void SetTokenContainer(void);
+ void PreCache(void);
+ void CheckSize(int id);
+ void SetTokens(int gId, skindesignerapi::cTokenContainer *tk);
+ void PositionGrid(int gId, double x, double y, double width, double height);
+ void SetCurrentGrid(int gId, bool current);
+ void DeleteGrid(int gId);
+ void ClearGrids(void);
+ void Render(void);
+ void Close(void);
+ void Hide(void);
+ void Show(void);
+};
+
+#endif //__VIEWGRID_H
\ No newline at end of file diff --git a/coreengine/viewlist.c b/coreengine/viewlist.c new file mode 100644 index 0000000..1d20eea --- /dev/null +++ b/coreengine/viewlist.c @@ -0,0 +1,899 @@ +#include "viewlist.h"
+
+cViewList::cViewList(void) {
+ globals = NULL;
+ attribs = new cViewListAttribs((int)eViewListAttribs::count);
+ numElements = 0;
+ listElement = NULL;
+ currentElement = NULL;
+ listElements = NULL;
+ plugId = -1;
+ plugMenuId = -1;
+}
+
+cViewList::~cViewList(void) {
+ delete attribs;
+ delete listElement;
+ delete currentElement;
+ if (listElements) {
+ for (int i=0; i < numElements; ++i) {
+ if (listElements[i]) {
+ delete listElements[i];
+ listElements[i] = NULL;
+ }
+ }
+ }
+ delete[] listElements;
+}
+
+void cViewList::SetGlobals(cGlobals *globals) {
+ this->globals = globals;
+ if (listElement)
+ listElement->SetGlobals(globals);
+ if (currentElement)
+ currentElement->SetGlobals(globals);
+}
+
+void cViewList::SetContainer(int x, int y, int width, int height) {
+ container.SetX(x);
+ container.SetY(y);
+ container.SetWidth(width);
+ container.SetHeight(height);
+}
+
+void cViewList::SetAttributes(vector<stringpair> &attributes) {
+ attribs->Set(attributes);
+}
+
+cViewList *cViewList::CreateViewList(const char *name) {
+ cViewList *l = NULL;
+ if (!strcmp(name, "menudefault"))
+ l = new cViewListDefault();
+ else if (!strcmp(name, "menumain"))
+ l = new cViewListMain();
+ else if (!strcmp(name, "menusetup"))
+ l = new cViewListMain();
+ else if (!strcmp(name, "menuschedules"))
+ l = new cViewListSchedules();
+ else if (!strcmp(name, "menutimers"))
+ l = new cViewListTimers();
+ else if (!strcmp(name, "menuchannels"))
+ l = new cViewListChannels();
+ else if (!strcmp(name, "menurecordings"))
+ l = new cViewListRecordings();
+ else if (!strcmp(name, "displayaudiotracks"))
+ l = new cViewListAudioTracks();
+ else if (startswith(name, "menuplugin"))
+ l = new cViewListPlugin();
+ else
+ esyslog("skindesigner: unknown viewlist %s", name);
+ return l;
+}
+
+cViewElement *cViewList::CreateListElement(const char *name) {
+ cViewElement *le = NULL;
+ if (!strcmp(name, "menudefault"))
+ le = new cLeMenuDefault();
+ else if (!strcmp(name, "menumain"))
+ le = new cLeMenuMain();
+ else if (!strcmp(name, "menusetup"))
+ le = new cLeMenuMain();
+ else if (!strcmp(name, "menuschedules"))
+ le = new cLeMenuSchedules();
+ else if (!strcmp(name, "menutimers"))
+ le = new cLeMenuTimers();
+ else if (!strcmp(name, "menuchannels"))
+ le = new cLeMenuChannels();
+ else if (!strcmp(name, "menurecordings"))
+ le = new cLeMenuRecordings();
+ else if (!strcmp(name, "displayaudiotracks"))
+ le = new cLeAudioTracks();
+ else if (startswith(name, "menuplugin"))
+ le = new cLeMenuPlugin();
+ else
+ esyslog("skindesigner: unknown viewlist %s", name);
+ return le;
+}
+
+cViewElement *cViewList::CreateCurrentElement(const char *name) {
+ cViewElement *ce = NULL;
+ if (!strcmp(name, "menumain"))
+ ce = new cCeMenuMain();
+ else if (!strcmp(name, "menusetup"))
+ ce = new cCeMenuMain();
+ else if (!strcmp(name, "menuschedules"))
+ ce = new cCeMenuSchedules();
+ else if (!strcmp(name, "menutimers"))
+ ce = new cCeMenuTimers();
+ else if (!strcmp(name, "menuchannels"))
+ ce = new cCeMenuChannels();
+ else if (!strcmp(name, "menurecordings"))
+ ce = new cCeMenuRecordings();
+ else if (startswith(name, "menuplugin"))
+ ce = new cCeMenuPlugin();
+ else
+ esyslog("skindesigner: unknown viewlist %s", name);
+ return ce;
+}
+
+void cViewList::AddListElement(cViewElement *listElement) {
+ this->listElement = listElement;
+ listElement->SetTokenContainer();
+}
+
+void cViewList::AddCurrentElement(cViewElement *currentElement) {
+ this->currentElement = currentElement;
+ currentElement->SetTokenContainer();
+}
+
+void cViewList::PreCache(void) {
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->SetGlobals(globals);
+ attribs->Cache();
+ numElements = attribs->NumListElements();
+ orientation = attribs->Orientation();
+ eAlign align = attribs->Align();
+ int x = attribs->X();
+ int y = attribs->Y();
+ int width = attribs->Width();
+ int height = attribs->Height();
+
+ int step = 0;
+ if (orientation == eOrientation::vertical) {
+ step = height / numElements;
+ } else {
+ step = width / numElements;
+ }
+
+ int start = 0;
+ if (align == eAlign::center) {
+ if (orientation == eOrientation::vertical) {
+ start = y + (height - numElements * step) / 2;
+ } else {
+ start = x + (width - numElements * step) / 2;
+ }
+ } else if (align == eAlign::bottom) {
+ start = y + height - numElements * step;
+ } else if (align == eAlign::right) {
+ start = x + width - numElements * step;
+ }
+ Prepare(start, step);
+}
+
+int cViewList::NumItems(void) {
+ return numElements;
+}
+
+eOrientation cViewList::Orientation(void) {
+ return attribs->Orientation();
+}
+
+void cViewList::Draw(eMenuCategory menuCat) {
+ int current = -1;
+ for (int i = 0; i < numElements; i++) {
+ listElements[i]->SetMenuCategory(menuCat);
+ if (listElements[i]->Parse()) {
+ listElements[i]->Render();
+ if (listElements[i]->Current()) {
+ listElements[i]->RenderCurrent();
+ current = i;
+ }
+ }
+ }
+ if (current >= 0 && listElements[current]) {
+ listElements[current]->WakeCurrent();
+ }
+
+}
+
+void cViewList::Clear(void) {
+ if (!listElements)
+ return;
+ for (int i = 0; i < numElements; i++) {
+ listElements[i]->StopScrolling();
+ listElements[i]->Clear();
+ }
+}
+
+void cViewList::Close(void) {
+ if (!listElements)
+ return;
+ for (int i = 0; i < numElements; i++) {
+ listElements[i]->StopScrolling();
+ listElements[i]->Close();
+ }
+}
+
+void cViewList::SetTransparency(int transparency) {
+ for (int i = 0; i < numElements; i++) {
+ if (listElements[i]) {
+ listElements[i]->SetTransparency(transparency);
+ }
+ }
+}
+
+void cViewList::Debug(void) {
+}
+
+/******************************************************************
+* cViewListDefault
+******************************************************************/
+cViewListDefault::cViewListDefault(void) {
+ listDefault = NULL;
+ colX = NULL;
+ colWidths = NULL;
+ avrgFontWidth = 0;
+ listFont = NULL;
+ plugName = NULL;
+}
+
+cViewListDefault::~cViewListDefault(void) {
+ delete[] listDefault;
+ delete[] colX;
+ delete[] colWidths;
+}
+
+void cViewListDefault::Prepare(int start, int step) {
+ if (!listElement)
+ return;
+
+ cLeMenuDefault *tpl = dynamic_cast<cLeMenuDefault*>(listElement);
+ if (!tpl) return;
+ listDefault = new cLeMenuDefault*[numElements];
+ listElements = new cListElement*[numElements];
+ int pos = start;
+
+ for (int i = 0; i < numElements; i++) {
+ listDefault[i] = new cLeMenuDefault(*tpl);
+ listElements[i] = listDefault[i];
+ listDefault[i]->SetNumber(i);
+ listDefault[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listDefault[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listDefault[i]->SetAreaWidth(width);
+ }
+ listDefault[i]->SetContainer(x, y, width, height);
+ listDefault[i]->Cache();
+ pos += step;
+ }
+
+ //Setting average font width
+ avrgFontWidth = 20;
+ const char *determinateFont = attribs->DeterminateFont();
+ if (!determinateFont) {
+ return;
+ }
+ cFunction *f = listDefault[0]->GetFunction(determinateFont);
+ if (!f)
+ return;
+ cFuncDrawText *fdt = dynamic_cast<cFuncDrawText*>(f);
+ if (!fdt) {
+ return;
+ }
+ avrgFontWidth = fdt->AvrgFontWidth();
+ listFont = fdt->GetFont();
+ colX = new int[MAX_TABS];
+ colWidths = new int[MAX_TABS];
+ for (int i=0; i < MAX_TABS; i++) {
+ colX[i] = 0;
+ colWidths[i] = 0;
+ }
+ for (int i = 0; i < numElements; i++) {
+ listDefault[i]->SetListInfo(colX, colWidths);
+ }
+}
+
+void cViewListDefault::SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5) {
+ int itemWidth = attribs->MenuItemWidth();
+ if (!tab1) {
+ colX[0] = 0;
+ colWidths[0] = itemWidth;
+ for (int i = 1; i < MAX_TABS; i++) {
+ colX[i] = 0;
+ colWidths[i] = 0;
+ }
+ } else {
+ colX[0] = 0;
+ colX[1] = tab1 ? colX[0] + tab1 : 0;
+ colX[2] = tab2 ? colX[1] + tab2 : 0;
+ colX[3] = tab3 ? colX[2] + tab3 : 0;
+ colX[4] = tab4 ? colX[3] + tab4 : 0;
+ colX[5] = tab5 ? colX[4] + tab5 : 0;
+ for (int i = 1; i < MAX_TABS; i++)
+ colX[i] *= avrgFontWidth;
+
+ bool end = false;
+ for (int i = 0; i < MAX_TABS; i++) {
+ if ( i < MAX_TABS -1 && colX[i+1] > 0) {
+ colWidths[i] = colX[i+1] - colX[i];
+ } else if (!end) {
+ end = true;
+ colWidths[i] = itemWidth - colX[i];
+ } else {
+ colWidths[i] = 0;
+ }
+ }
+ }
+}
+
+void cViewListDefault::Set(const char *text, int index, bool current, bool selectable) {
+ if (!current)
+ listDefault[index]->StopScrolling();
+ listDefault[index]->SetCurrent(current);
+ listDefault[index]->SetSelectable(selectable);
+ listDefault[index]->SetPlugin(plugName);
+ listDefault[index]->SetText(text);
+}
+
+const cFont *cViewListDefault::GetListFont(void) {
+ return listFont;
+};
+
+int cViewListDefault::GetListWidth(void) {
+ return attribs->MenuItemWidth();
+}
+
+/******************************************************************
+* cViewListMain
+******************************************************************/
+cViewListMain::cViewListMain(void) {
+ listMain = NULL;
+ currentMain = NULL;
+}
+
+cViewListMain::~cViewListMain(void) {
+ delete[] listMain;
+}
+
+void cViewListMain::Prepare(int start, int step) {
+ if (!listElement)
+ return;
+
+ cLeMenuMain *tpl = dynamic_cast<cLeMenuMain*>(listElement);
+ if (!tpl) return;
+
+ listMain = new cLeMenuMain*[numElements];
+ listElements = new cListElement*[numElements];
+ int pos = start;
+
+ for (int i = 0; i < numElements; i++) {
+ listMain[i] = new cLeMenuMain(*tpl);
+ listElements[i] = listMain[i];
+ listMain[i]->SetNumber(i);
+ listMain[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listMain[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listMain[i]->SetAreaWidth(width);
+ }
+ listMain[i]->SetContainer(x, y, width, height);
+ listMain[i]->Cache();
+ pos += step;
+ }
+
+ if (!currentElement) return;
+ currentMain = dynamic_cast<cCeMenuMain*>(currentElement);
+ if (!currentMain) return;
+
+ currentMain->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ currentMain->SetDetached();
+ currentMain->Cache();
+ for (int i = 0; i < numElements; i++) {
+ listMain[i]->SetCurrentElement(currentMain);
+ }
+}
+
+void cViewListMain::Set(const char *text, int index, bool current, bool selectable) {
+ if (!current)
+ listMain[index]->StopScrolling();
+ listMain[index]->SetCurrent(current);
+ listMain[index]->ClearCurrentElement();
+ listMain[index]->SetSelectable(selectable);
+ listMain[index]->SetText(text);
+}
+
+const char *cViewListMain::GetPlugin(void) {
+ for (int i = 0; i < numElements; i++) {
+ if (listMain[i] && listMain[i]->Current()) {
+ return listMain[i]->PluginName();
+ }
+ }
+ return NULL;
+}
+/******************************************************************
+* cViewListSchedules
+******************************************************************/
+cViewListSchedules::cViewListSchedules(void) {
+ listSchedules = NULL;
+ currentSchedules = NULL;
+ epgSearchFav = false;
+}
+
+cViewListSchedules::~cViewListSchedules(void) {
+ delete[] listSchedules;
+}
+
+void cViewListSchedules::Prepare(int start, int step) {
+ if (!listElement)
+ return;
+
+ cLeMenuSchedules *tpl = dynamic_cast<cLeMenuSchedules*>(listElement);
+ if (!tpl) return;
+
+ listSchedules = new cLeMenuSchedules*[numElements];
+ listElements = new cListElement*[numElements];
+ int pos = start;
+
+ for (int i = 0; i < numElements; i++) {
+ listSchedules[i] = new cLeMenuSchedules(*tpl);
+ listElements[i] = listSchedules[i];
+ listSchedules[i]->SetNumber(i);
+ listSchedules[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listSchedules[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listSchedules[i]->SetAreaWidth(width);
+ }
+ listSchedules[i]->SetContainer(x, y, width, height);
+ listSchedules[i]->Cache();
+ pos += step;
+ }
+
+ if (!currentElement) return;
+ currentSchedules = dynamic_cast<cCeMenuSchedules*>(currentElement);
+ if (!currentSchedules) return;
+
+ currentSchedules->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ currentSchedules->SetDetached();
+ currentSchedules->Cache();
+ for (int i = 0; i < numElements; i++) {
+ listSchedules[i]->SetCurrentElement(currentSchedules);
+ }
+}
+
+void cViewListSchedules::Set(const cEvent *event, int index, bool current, bool selectable,
+ const cChannel *channel, bool withDate, eTimerMatch timerMatch) {
+ if (!current)
+ listSchedules[index]->StopScrolling();
+ listSchedules[index]->SetCurrent(current);
+ listSchedules[index]->ClearCurrentElement();
+ listSchedules[index]->SetSelectable(selectable);
+ listSchedules[index]->SetEpgSearchFav(epgSearchFav);
+ listSchedules[index]->Set(event, channel, withDate, timerMatch);
+}
+
+/******************************************************************
+* cViewListTimers
+******************************************************************/
+cViewListTimers::cViewListTimers(void) {
+ listTimers = NULL;
+ currentTimer = NULL;
+}
+
+cViewListTimers::~cViewListTimers(void) {
+ delete[] listTimers;
+}
+
+void cViewListTimers::Prepare(int start, int step) {
+ if (!listElement)
+ return;
+
+ cLeMenuTimers *tpl = dynamic_cast<cLeMenuTimers*>(listElement);
+ if (!tpl) return;
+
+ listTimers = new cLeMenuTimers*[numElements];
+ listElements = new cListElement*[numElements];
+ int pos = start;
+
+ for (int i = 0; i < numElements; i++) {
+ listTimers[i] = new cLeMenuTimers(*tpl);
+ listElements[i] = listTimers[i];
+ listTimers[i]->SetNumber(i);
+ listTimers[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listTimers[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listTimers[i]->SetAreaWidth(width);
+ }
+ listTimers[i]->SetContainer(x, y, width, height);
+ listTimers[i]->Cache();
+ pos += step;
+ }
+
+ if (!currentElement) return;
+ currentTimer = dynamic_cast<cCeMenuTimers*>(currentElement);
+ if (!currentTimer) return;
+
+ currentTimer->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ currentTimer->SetDetached();
+ currentTimer->Cache();
+ for (int i = 0; i < numElements; i++) {
+ listTimers[i]->SetCurrentElement(currentTimer);
+ }
+}
+
+void cViewListTimers::Set(const cTimer *timer, int index, bool current, bool selectable) {
+ if (!current)
+ listTimers[index]->StopScrolling();
+ listTimers[index]->SetCurrent(current);
+ listTimers[index]->ClearCurrentElement();
+ listTimers[index]->SetSelectable(selectable);
+ listTimers[index]->Set(timer);
+}
+
+/******************************************************************
+* cViewListChannels
+******************************************************************/
+cViewListChannels::cViewListChannels(void) {
+ listChannels = NULL;
+ currentChannel = NULL;
+}
+
+cViewListChannels::~cViewListChannels(void) {
+ delete[] listChannels;
+}
+
+void cViewListChannels::Prepare(int start, int step) {
+ if (!listElement)
+ return;
+
+ cLeMenuChannels *tpl = dynamic_cast<cLeMenuChannels*>(listElement);
+ if (!tpl) return;
+
+ listChannels = new cLeMenuChannels*[numElements];
+ listElements = new cListElement*[numElements];
+ int pos = start;
+
+ for (int i = 0; i < numElements; i++) {
+ listChannels[i] = new cLeMenuChannels(*tpl);
+ listElements[i] = listChannels[i];
+ listChannels[i]->SetNumber(i);
+ listChannels[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listChannels[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listChannels[i]->SetAreaWidth(width);
+ }
+ listChannels[i]->SetContainer(x, y, width, height);
+ listChannels[i]->Cache();
+ pos += step;
+ }
+
+ if (!currentElement) return;
+ currentChannel = dynamic_cast<cCeMenuChannels*>(currentElement);
+ if (!currentChannel) return;
+
+ currentChannel->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ currentChannel->SetDetached();
+ currentChannel->Cache();
+ for (int i = 0; i < numElements; i++) {
+ listChannels[i]->SetCurrentElement(currentChannel);
+ }
+}
+
+void cViewListChannels::Set(const cChannel *channel, int index, bool current, bool selectable, bool withProvider) {
+ if (!current)
+ listChannels[index]->StopScrolling();
+ listChannels[index]->SetCurrent(current);
+ listChannels[index]->ClearCurrentElement();
+ listChannels[index]->SetSelectable(selectable);
+ listChannels[index]->Set(channel, withProvider);
+}
+
+/******************************************************************
+* cViewListRecordings
+******************************************************************/
+cViewListRecordings::cViewListRecordings(void) {
+ listRecordings = NULL;
+ currentRecording = NULL;
+}
+
+cViewListRecordings::~cViewListRecordings(void) {
+ delete[] listRecordings;
+}
+
+void cViewListRecordings::Prepare(int start, int step) {
+ if (!listElement)
+ return;
+
+ cLeMenuRecordings *tpl = dynamic_cast<cLeMenuRecordings*>(listElement);
+ if (!tpl) return;
+
+ listRecordings = new cLeMenuRecordings*[numElements];
+ listElements = new cListElement*[numElements];
+ int pos = start;
+
+ for (int i = 0; i < numElements; i++) {
+ listRecordings[i] = new cLeMenuRecordings(*tpl);
+ listElements[i] = listRecordings[i];
+ listRecordings[i]->SetNumber(i);
+ listRecordings[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listRecordings[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listRecordings[i]->SetAreaWidth(width);
+ }
+ listRecordings[i]->SetContainer(x, y, width, height);
+ listRecordings[i]->Cache();
+ pos += step;
+ }
+
+ if (!currentElement) return;
+ currentRecording = dynamic_cast<cCeMenuRecordings*>(currentElement);
+ if (!currentRecording) return;
+
+ currentRecording->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ currentRecording->SetDetached();
+ currentRecording->Cache();
+ for (int i = 0; i < numElements; i++) {
+ listRecordings[i]->SetCurrentElement(currentRecording);
+ }
+}
+
+void cViewListRecordings::Set(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New) {
+ if (!current)
+ listRecordings[index]->StopScrolling();
+ listRecordings[index]->SetCurrent(current);
+ listRecordings[index]->ClearCurrentElement();
+ listRecordings[index]->SetSelectable(selectable);
+ listRecordings[index]->Set(recording, level, total, New);
+}
+
+/******************************************************************
+* cViewListPlugin
+******************************************************************/
+cViewListPlugin::cViewListPlugin(void) {
+ listPlugin = NULL;
+ currentPlugin = NULL;
+}
+
+cViewListPlugin::~cViewListPlugin(void) {
+ delete[] listPlugin;
+}
+
+void cViewListPlugin::Prepare(int start, int step) {
+ if (!listElement)
+ return;
+
+ if (!listElement)
+ return;
+
+ cLeMenuPlugin *tpl = dynamic_cast<cLeMenuPlugin*>(listElement);
+ if (!tpl) return;
+
+ listPlugin = new cLeMenuPlugin*[numElements];
+ listElements = new cListElement*[numElements];
+ int pos = start;
+
+ for (int i = 0; i < numElements; i++) {
+ listPlugin[i] = new cLeMenuPlugin(*tpl);
+ listElements[i] = listPlugin[i];
+ listPlugin[i]->SetNumber(i);
+ listPlugin[i]->SetPlugId(plugId);
+ listPlugin[i]->SetPlugMenuId(plugMenuId);
+ listPlugin[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listPlugin[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listPlugin[i]->SetAreaWidth(width);
+ }
+ listPlugin[i]->SetContainer(x, y, width, height);
+ listPlugin[i]->Cache();
+ pos += step;
+ }
+
+ if (!currentElement) return;
+ currentPlugin = dynamic_cast<cCeMenuPlugin*>(currentElement);
+ if (!currentPlugin) return;
+
+ currentPlugin->SetContainer(attribs->X(), attribs->Y(), attribs->Width(), attribs->Height());
+ currentPlugin->SetPlugId(plugId);
+ currentPlugin->SetPlugMenuId(plugMenuId);
+ currentPlugin->SetTokenContainer();
+ currentPlugin->SetDetached();
+ currentPlugin->Cache();
+ for (int i = 0; i < numElements; i++) {
+ listPlugin[i]->SetCurrentElement(currentPlugin);
+ }
+}
+
+void cViewListPlugin::Set(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable) {
+ if (!current)
+ listPlugin[index]->StopScrolling();
+ listPlugin[index]->SetCurrent(current);
+ listPlugin[index]->ClearCurrentElement();
+ listPlugin[index]->SetSelectable(selectable);
+ listPlugin[index]->Set(tk);
+}
+
+/******************************************************************
+* cViewListAudioTracks
+******************************************************************/
+cViewListAudioTracks::cViewListAudioTracks(void) {
+ listAudioTracks = NULL;
+ numTracks = 0;
+ tokenContainer = NULL;
+}
+
+cViewListAudioTracks::~cViewListAudioTracks(void) {
+ delete[] listAudioTracks;
+ delete tokenContainer;
+}
+
+void cViewListAudioTracks::Close(void) {
+ if (!listElements)
+ return;
+ for (int i = 0; i < numElements; i++) {
+ delete listAudioTracks[i];
+ }
+ delete[] listAudioTracks;
+ listAudioTracks = NULL;
+ }
+
+void cViewListAudioTracks::PreCache(void) {
+ tokenContainer = new skindesignerapi::cTokenContainer();
+ tokenContainer->DefineIntToken("{numelements}", 0);
+ tokenContainer->CreateContainers();
+ attribs->SetTokenContainer(tokenContainer);
+ attribs->SetContainer(container.X(), container.Y(), container.Width(), container.Height());
+ attribs->SetGlobals(globals);
+ attribs->Cache();
+}
+
+void cViewListAudioTracks::SetNumtracks(int numTracks) {
+ this->numTracks = numTracks;
+ tokenContainer->Clear();
+ tokenContainer->AddIntToken(0, numTracks);
+}
+
+void cViewListAudioTracks::SetTracks(const char * const *tracks) {
+ if (numTracks <= 0)
+ return;
+ orientation = attribs->Orientation();
+ eAlign align = attribs->Align();
+ int x = attribs->X();
+ int y = attribs->Y();
+ int width = attribs->Width();
+ int height = attribs->Height();
+
+ int step = 0;
+ if (orientation == eOrientation::vertical) {
+ step = height / numTracks;
+ } else {
+ step = width / numTracks;
+ }
+
+ int start = 0;
+ if (align == eAlign::center) {
+ if (orientation == eOrientation::vertical) {
+ start = y + (height - numTracks * step) / 2;
+ } else {
+ start = x + (width - numTracks * step) / 2;
+ }
+ } else if (align == eAlign::bottom) {
+ start = y + height - numTracks * step;
+ } else if (align == eAlign::right) {
+ start = x + width - numTracks * step;
+ } else if (align == eAlign::top) {
+ start = y;
+ }
+
+ cLeAudioTracks *tpl = dynamic_cast<cLeAudioTracks*>(listElement);
+ if (!tpl) return;
+
+ listAudioTracks = new cLeAudioTracks*[numTracks];
+ listElements = new cListElement*[numTracks];
+ int pos = start;
+
+ for (int i = 0; i < numTracks; i++) {
+ listAudioTracks[i] = new cLeAudioTracks(*tpl);
+ listElements[i] = listAudioTracks[i];
+ listAudioTracks[i]->SetNumber(i);
+ listAudioTracks[i]->SetTokenContainer();
+ int x, y, width, height;
+ if (orientation == eOrientation::vertical) {
+ x = attribs->X();
+ y = pos;
+ width = attribs->Width();
+ height = step;
+ listAudioTracks[i]->SetAreaHeight(height);
+ } else {
+ x = pos;
+ y = attribs->Y();
+ width = step;
+ height = attribs->Height();
+ listAudioTracks[i]->SetAreaWidth(width);
+ }
+ listAudioTracks[i]->SetContainer(x, y, width, height);
+ listAudioTracks[i]->Cache();
+ pos += step;
+ }
+ for (int i=0; i < numTracks; i++) {
+ listAudioTracks[i]->Set(tracks[i]);
+ listAudioTracks[i]->SetSelectable(true);
+ }
+}
+
+void cViewListAudioTracks::SetCurrentTrack(int index) {
+ for (int i = 0; i < numTracks; i++) {
+ if (i != index) {
+ listAudioTracks[i]->SetCurrent(false);
+ listAudioTracks[i]->SetDirty();
+ listAudioTracks[i]->StopScrolling();
+ }
+ }
+ listAudioTracks[index]->SetCurrent(true);
+ listAudioTracks[index]->SetDirty();
+}
+
+void cViewListAudioTracks::Draw(void) {
+ for (int i = 0; i < numTracks; i++) {
+ if (listAudioTracks[i]->Parse()) {
+ listAudioTracks[i]->Render();
+ }
+ }
+}
\ No newline at end of file diff --git a/coreengine/viewlist.h b/coreengine/viewlist.h new file mode 100644 index 0000000..aadb5ed --- /dev/null +++ b/coreengine/viewlist.h @@ -0,0 +1,155 @@ +#ifndef __VIEWLIST_H
+#define __VIEWLIST_H
+
+#include "globals.h"
+#include "../libskindesignerapi/tokencontainer.h"
+#include "listelements.h"
+#include "area.h"
+
+class cViewList {
+protected:
+ int plugId;
+ int plugMenuId;
+ cViewListAttribs *attribs;
+ cRect container;
+ cGlobals *globals;
+ int numElements;
+ eOrientation orientation;
+ cViewElement *listElement;
+ cViewElement *currentElement;
+ cListElement **listElements;
+ virtual void Prepare(int start, int step) {};
+public:
+ cViewList(void);
+ virtual ~cViewList(void);
+ void SetGlobals(cGlobals *globals);
+ void SetContainer(int x, int y, int width, int height);
+ void SetAttributes(vector<stringpair> &attributes);
+ void SetPlugId(int id) { plugId = id; };
+ void SetPlugMenuId(int id) { plugMenuId = id; };
+ static cViewList *CreateViewList(const char *name);
+ static cViewElement *CreateListElement(const char *name);
+ static cViewElement *CreateCurrentElement(const char *name);
+ void AddListElement(cViewElement *listElement);
+ void AddCurrentElement(cViewElement *currentElement);
+ virtual void PreCache(void);
+ int NumItems(void);
+ eOrientation Orientation(void);
+ void Draw(eMenuCategory menuCat);
+ void Clear(void);
+ virtual void Close(void);
+ void SetTransparency(int transparency);
+ void Debug(void);
+};
+
+class cViewListDefault : public cViewList {
+private:
+ cLeMenuDefault **listDefault;
+ int avrgFontWidth;
+ const cFont *listFont;
+ int *colX;
+ int *colWidths;
+ const char *plugName;
+protected:
+ void Prepare(int start, int step);
+public:
+ cViewListDefault(void);
+ virtual ~cViewListDefault(void);
+ void SetTabs(int tab1, int tab2, int tab3, int tab4, int tab5);
+ void SetPlugin(const char *plugName) { this->plugName = plugName; };
+ void Set(const char *text, int index, bool current, bool selectable);
+ const cFont *GetListFont(void);
+ int GetListWidth(void);
+};
+
+class cViewListMain : public cViewList {
+private:
+ cLeMenuMain **listMain;
+ cCeMenuMain *currentMain;
+protected:
+ void Prepare(int start, int step);
+public:
+ cViewListMain(void);
+ virtual ~cViewListMain(void);
+ void Set(const char *text, int index, bool current, bool selectable);
+ const char *GetPlugin(void);
+};
+
+class cViewListSchedules : public cViewList {
+private:
+ cLeMenuSchedules **listSchedules;
+ cCeMenuSchedules *currentSchedules;
+ bool epgSearchFav;
+protected:
+ void Prepare(int start, int step);
+public:
+ cViewListSchedules(void);
+ virtual ~cViewListSchedules(void);
+ void IsEpgSearchFav(bool isFav) { epgSearchFav = isFav; };
+ void Set(const cEvent *event, int index, bool current, bool selectable, const cChannel *channel, bool withDate, eTimerMatch timerMatch);
+};
+
+class cViewListTimers : public cViewList {
+private:
+ cLeMenuTimers **listTimers;
+ cCeMenuTimers *currentTimer;
+protected:
+ void Prepare(int start, int step);
+public:
+ cViewListTimers(void);
+ virtual ~cViewListTimers(void);
+ void Set(const cTimer *timer, int index, bool current, bool selectable);
+};
+
+class cViewListChannels : public cViewList {
+private:
+ cLeMenuChannels **listChannels;
+ cCeMenuChannels *currentChannel;
+protected:
+ void Prepare(int start, int step);
+public:
+ cViewListChannels(void);
+ virtual ~cViewListChannels(void);
+ void Set(const cChannel *channel, int index, bool current, bool selectable, bool withProvider);
+};
+
+class cViewListRecordings : public cViewList {
+private:
+ cLeMenuRecordings **listRecordings;
+ cCeMenuRecordings *currentRecording;
+protected:
+ void Prepare(int start, int step);
+public:
+ cViewListRecordings(void);
+ virtual ~cViewListRecordings(void);
+ void Set(const cRecording *recording, int index, bool current, bool selectable, int level, int total, int New);
+};
+
+class cViewListPlugin : public cViewList {
+private:
+ cLeMenuPlugin **listPlugin;
+ cCeMenuPlugin *currentPlugin;
+protected:
+ void Prepare(int start, int step);
+public:
+ cViewListPlugin(void);
+ virtual ~cViewListPlugin(void);
+ void Set(skindesignerapi::cTokenContainer *tk, int index, bool current, bool selectable);
+};
+
+class cViewListAudioTracks : public cViewList {
+private:
+ skindesignerapi::cTokenContainer *tokenContainer;
+ int numTracks;
+ cLeAudioTracks **listAudioTracks;
+public:
+ cViewListAudioTracks(void);
+ virtual ~cViewListAudioTracks(void);
+ void Close(void);
+ void PreCache(void);
+ void SetNumtracks(int numTracks);
+ void SetTracks(const char * const *tracks);
+ void SetCurrentTrack(int index);
+ void Draw(void);
+};
+#endif //__VIEWLIST_H
\ No newline at end of file diff --git a/libtemplate/xmlparser.c b/coreengine/xmlparser.c index 8db3d3d..617313a 100644 --- a/libtemplate/xmlparser.c +++ b/coreengine/xmlparser.c @@ -1,10 +1,11 @@ #include "xmlparser.h" #include "../config.h" -#include "../libcore/helpers.h" +#include "../extensions/helpers.h" using namespace std; cXmlParser::cXmlParser(void) { + sdOsd = NULL; view = NULL; globals = NULL; skinSetup = NULL; @@ -16,7 +17,7 @@ cXmlParser::~cXmlParser() { /********************************************************************* * PUBLIC Functions *********************************************************************/ -bool cXmlParser::ReadView(cTemplateView *view, string xmlFile) { +bool cXmlParser::ReadView(cView *view, string xmlFile) { if (!view) return false; this->view = view; @@ -27,7 +28,7 @@ bool cXmlParser::ReadView(cTemplateView *view, string xmlFile) { return false; if (! SetDocument() ) return false; - if (! CheckNodeName(view->GetViewName()) ) + if (! CheckNodeName( view->GetViewName() )) return false; return true; } @@ -35,37 +36,72 @@ bool cXmlParser::ReadView(cTemplateView *view, string xmlFile) { bool cXmlParser::ParseView(void) { if (!view) return false; - vector<stringpair> rootAttribs = ParseAttributes(); - ValidateAttributes(NodeName(), rootAttribs); - view->SetParameters(rootAttribs); + view->SetAttributes(rootAttribs); + + cViewMenu *menuView = dynamic_cast<cViewMenu*>(view); + cViewTracks *tracksView = dynamic_cast<cViewTracks*>(view); if (!LevelDown()) return false; do { + if (view->ValidViewElement(NodeName())) { + ParseViewElement(NodeName()); + } else if (menuView) { + if (menuView->ValidSubView(NodeName())) { + ParseSubView(NodeName()); + } else if (view->ValidViewList(NodeName())) { + ParseViewList(); + } else { + esyslog("skindesigner: unknown node %s", NodeName()); + return false; + } + } else if (tracksView) { + if (view->ValidViewList(NodeName())) { + ParseViewList(); + } else { + esyslog("skindesigner: unknown node %s", NodeName()); + return false; + } + } else { + esyslog("skindesigner: unknown view %s", NodeName()); + return false; + } + } while (NextNode()); + + return true; +} + +bool cXmlParser::ParsePluginView(void) { + if (!view) + return false; + vector<stringpair> rootAttribs = ParseAttributes(); + view->SetAttributes(rootAttribs); + + if (!LevelDown()) + return false; - if (view->ValidSubView(NodeName())) { - ParseSubView(); - } else if (view->ValidViewElement(NodeName())) { - ParseViewElement(); - } else if (view->ValidViewList(NodeName())) { - ParseViewList(); - } else if (view->ValidViewGrid(NodeName())) { + do { + if (CheckNodeName("viewelement")) { + ParsePluginViewElement(); + } else if (CheckNodeName("grid")) { ParseGrid(); } else if (CheckNodeName("tab")) { - ParseViewTab(view); + ParseViewTabPlugin(); + } else if (CheckNodeName("scrollbar")) { + ParsePluginViewElement(true, false); + } else if (CheckNodeName("tablabels")) { + ParsePluginViewElement(false, true); } else { - return false; + esyslog("skindesigner: unknown node %s in plugin view", NodeName()); } - } while (NextNode()); return true; - } -bool cXmlParser::ReadPluginView(string plugName, int templateNumber, string templateName) { +bool cXmlParser::ReadPluginView(string templateName) { string xmlPath = GetPath(templateName); DeleteDocument(); if (! ReadXMLFile(xmlPath.c_str()) ) @@ -77,30 +113,34 @@ bool cXmlParser::ReadPluginView(string plugName, int templateNumber, string temp return true; } -bool cXmlParser::ParsePluginView(string plugName, int templateNumber) { - cTemplateView *plugView = new cTemplateViewMenu(); - view->AddPluginView(plugName, templateNumber, plugView); - - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - plugView->SetParameters(attribs); +bool cXmlParser::ParsePluginView(string plugName, int plugId, int menuNumber, int menuType) { + if (!view) + return false; + cViewMenu *menuView = dynamic_cast<cViewMenu*>(view); + if (!menuView) { + return false; + } + vector<pair<string, string> > attribs = ParseAttributes(); if (!LevelDown()) return false; + + cSubView *plugView = cViewMenu::CreatePluginview(plugName.c_str(), plugId, menuNumber, menuType); + plugView->SetAttributes(attribs); + menuView->AddPluginview(plugView); do { - if (plugView->ValidViewElement(NodeName())) { - ParseViewElement(plugView); + ParseViewElement(NodeName(), plugView); } else if (plugView->ValidViewList(NodeName())) { ParseViewList(plugView); } else if (CheckNodeName("tab")) { - ParseViewTab(plugView); + ParseViewTab(plugView); } else { + esyslog("skindesigner: error - unknown %s", NodeName()); return false; } - } while (NextNode()); - + LevelUp(); return true; } @@ -164,24 +204,25 @@ bool cXmlParser::ParseSkinSetup(string skin) { /********************************************************************* * PRIVATE Functions *********************************************************************/ - -bool cXmlParser::ParseSubView(void) { +bool cXmlParser::ParseSubView(string name) { if (!view) return false; - - cTemplateView *subView = new cTemplateViewMenu(); - view->AddSubView(NodeName(), subView); - - vector<pair<string, string> > subViewAttribs = ParseAttributes(); - ValidateAttributes(NodeName(), subViewAttribs); - subView->SetParameters(subViewAttribs); + cViewMenu *menuView = dynamic_cast<cViewMenu*>(view); + if (!menuView) { + return false; + } + vector<pair<string, string> > attribs = ParseAttributes(); if (!LevelDown()) return false; - do { + cSubView *subView = cViewMenu::CreateSubview(name.c_str()); + subView->SetAttributes(attribs); + menuView->AddSubview(name.c_str(), subView); + + do { if (subView->ValidViewElement(NodeName())) { - ParseViewElement(subView); + ParseViewElement(NodeName(), subView); } else if (subView->ValidViewList(NodeName())) { ParseViewList(subView); } else if (CheckNodeName("tab")) { @@ -189,70 +230,133 @@ bool cXmlParser::ParseSubView(void) { } else { return false; } - } while (NextNode()); LevelUp(); return true; - } -void cXmlParser::ParseViewElement(cTemplateView *subView) { + +void cXmlParser::ParseViewElement(string name, cView *subView) { if (!view) return; - const char *viewElementName = NodeName(); vector<stringpair> attributes = ParseAttributes(); - ValidateAttributes("viewelement", attributes); if (!LevelDown()) return; - cTemplateViewElement *viewElement = new cTemplateViewElement(); - viewElement->SetParameters(attributes); + //correct detailheader name + if (subView) { + if (!strcmp(subView->GetViewName(), "menudetailedepg") && !name.compare("detailheader")) { + name = "detailheaderepg"; + } else if (!strcmp(subView->GetViewName(), "menudetailedrecording") && !name.compare("detailheader")) { + name = "detailheaderrec"; + } else if (startswith(subView->GetViewName(), "menuplugin") && !name.compare("detailheader")) { + name = "detailheaderplugin"; + } + } + cViewElement *viewElement = cViewElement::CreateViewElement(name.c_str(), view->GetViewName()); + if (!viewElement) { + LevelUp(); + return; + } + + viewElement->SetOsd(sdOsd); + viewElement->SetAttributes(attributes); do { if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) { esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName()); continue; } - cTemplatePixmapNode *pix = NULL; + cAreaNode *area = NULL; if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); + area = ParseArea(); } else { - pix = ParseAreaContainer(); + area = ParseAreaContainer(); } - pix->SetGlobals(globals); - viewElement->AddPixmap(pix); + viewElement->AddArea(area); } while (NextNode()); + LevelUp(); if (subView) subView->AddViewElement(viewElementName, viewElement); else view->AddViewElement(viewElementName, viewElement); + } -void cXmlParser::ParseViewList(cTemplateView *subView) { +void cXmlParser::ParsePluginViewElement(bool isScrollbar, bool isTabLabels) { if (!view) return; + cViewPlugin *pluginView = dynamic_cast<cViewPlugin*>(view); + if (!pluginView) + return; + + vector<stringpair> attributes = ParseAttributes(); + + if (!LevelDown()) + return; + + cViewElement *viewElement = NULL; + if (isScrollbar) { + viewElement = new cVeDmScrollbar(); + } else if (isTabLabels) { + viewElement = new cVeDmTablabels(); + } else { + viewElement = new cVePlugin(); + } + + viewElement->SetOsd(sdOsd); + viewElement->SetAttributes(attributes); + do { + if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) { + esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName()); + continue; + } + cAreaNode *area = NULL; + if (CheckNodeName("area") || CheckNodeName("areascroll")) { + area = ParseArea(); + } else { + area = ParseAreaContainer(); + } + viewElement->AddArea(area); + } while (NextNode()); + + LevelUp(); - vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); + if (isScrollbar) { + pluginView->AddScrollbar(dynamic_cast<cVeDmScrollbar*>(viewElement)); + } else if (isTabLabels) { + pluginView->AddTablabels(dynamic_cast<cVeDmTablabels*>(viewElement)); + } else { + pluginView->AddViewElement(dynamic_cast<cVePlugin*>(viewElement)); + } +} + +void cXmlParser::ParseViewList(cView *subView) { + if (!view) + return; + + const char *name = NULL; + if (subView) + name = subView->GetViewName(); + else + name = view->GetViewName(); - cTemplateViewList *viewList = new cTemplateViewList(); - viewList->SetGlobals(globals); - viewList->SetParameters(attribs); + vector<stringpair> attribs = ParseAttributes(); + cViewList *viewList = cViewList::CreateViewList(name); + viewList->SetAttributes(attribs); if (!LevelDown()) return; do { if (CheckNodeName("currentelement")) { - - cTemplateViewElement *currentElement = new cTemplateViewElement(); - vector<stringpair> attribsCur = ParseAttributes(); - ValidateAttributes(NodeName(), attribsCur); - currentElement->SetGlobals(globals); - currentElement->SetParameters(attribsCur); + cViewElement *currentElement = cViewList::CreateCurrentElement(name); + currentElement->SetOsd(sdOsd); + vector<stringpair> attribsList = ParseAttributes(); + currentElement->SetAttributes(attribsList); if (!LevelDown()) continue; do { @@ -260,24 +364,21 @@ void cXmlParser::ParseViewList(cTemplateView *subView) { esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName()); continue; } - cTemplatePixmapNode *pix = NULL; + cAreaNode *area = NULL; if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); + area = ParseArea(); } else { - pix = ParseAreaContainer(); + area = ParseAreaContainer(); } - currentElement->AddPixmap(pix); + currentElement->AddArea(area); } while (NextNode()); LevelUp(); viewList->AddCurrentElement(currentElement); - } else if (CheckNodeName("listelement")) { - - cTemplateViewElement *listElement = new cTemplateViewElement(); + cViewElement *listElement = cViewList::CreateListElement(name); + listElement->SetOsd(sdOsd); vector<stringpair> attribsList = ParseAttributes(); - ValidateAttributes(NodeName(), attribsList); - listElement->SetGlobals(globals); - listElement->SetParameters(attribsList); + listElement->SetAttributes(attribsList); if (!LevelDown()) return; do { @@ -285,110 +386,128 @@ void cXmlParser::ParseViewList(cTemplateView *subView) { esyslog("skindesigner: invalid tag \"%s\" in viewelement", NodeName()); continue; } - cTemplatePixmapNode *pix = NULL; + cAreaNode *area = NULL; if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); + area = ParseArea(); } else { - pix = ParseAreaContainer(); + area = ParseAreaContainer(); } - listElement->AddPixmap(pix); + listElement->AddArea(area); } while (NextNode()); LevelUp(); viewList->AddListElement(listElement); } - } while (NextNode()); LevelUp(); - + if (subView) - subView->AddViewList(NodeName(), viewList); + subView->AddViewList(viewList); else - view->AddViewList(NodeName(), viewList); + view->AddViewList(viewList); + } -void cXmlParser::ParseViewTab(cTemplateView *subView) { +void cXmlParser::ParseViewTab(cView *subView) { if (!view || !subView) return; + cSubView *menuSubView = dynamic_cast<cSubView*>(subView); + if (!menuSubView) { + return; + } + vector<stringpair> attribs = ParseAttributes(); + cArea *tab = new cArea(); + tab->SetOsd(sdOsd); + tab->SetTab(); + tab->SetAttributes(attribs); + ParseFunctionCalls(tab); + menuSubView->AddTab(tab); +} +void cXmlParser::ParseViewTabPlugin(void) { + if (!view) + return; + cViewPlugin *plugView = dynamic_cast<cViewPlugin*>(view); + if (!plugView) { + return; + } vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - - cTemplateViewTab *viewTab = new cTemplateViewTab(); - viewTab->SetGlobals(globals); - viewTab->SetParameters(attribs); - viewTab->SetScrolling(); - ParseFunctionCalls(viewTab); - subView->AddViewTab(viewTab); + cArea *tab = new cArea(); + tab->SetOsd(sdOsd); + tab->SetTab(); + tab->SetAttributes(attribs); + ParseFunctionCalls(tab); + plugView->AddTab(tab); } void cXmlParser::ParseGrid(void) { if (!view) return; + cViewPlugin *pluginView = dynamic_cast<cViewPlugin*>(view); + if (!pluginView) + return; vector<stringpair> attributes = ParseAttributes(); - ValidateAttributes(NodeName(), attributes); if (!LevelDown()) return; - cTemplateViewGrid *viewGrid = new cTemplateViewGrid(); - viewGrid->SetParameters(attributes); + cViewGrid *viewGrid = new cViewGrid(); + viewGrid->SetAttributes(attributes); + cGridElement *gridElement = new cGridElement(); + gridElement->SetOsd(sdOsd); do { - if (!CheckNodeName("areacontainer") && !CheckNodeName("area") && !CheckNodeName("areascroll")) { esyslog("skindesigner: invalid tag \"%s\" in grid", NodeName()); continue; } - cTemplatePixmapNode *pix = NULL; + cAreaNode *area = NULL; if (CheckNodeName("area") || CheckNodeName("areascroll")) { - pix = ParseArea(); + area = ParseArea(); } else { - pix = ParseAreaContainer(); + area = ParseAreaContainer(); } - pix->SetGlobals(globals); - viewGrid->AddPixmap(pix); + gridElement->AddArea(area); } while (NextNode()); LevelUp(); - view->AddGrid(viewGrid); + viewGrid->AddGridElement(gridElement); + pluginView->AddViewGrid(viewGrid); } -cTemplatePixmap *cXmlParser::ParseArea(void) { +cArea *cXmlParser::ParseArea(void) { vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - - cTemplatePixmap *pix = new cTemplatePixmap(); + cArea *area = new cArea(); + area->SetOsd(sdOsd); if (CheckNodeName("areascroll")) { - pix->SetScrolling(); + area->SetScrolling(); } - pix->SetParameters(attribs); - ParseFunctionCalls(pix); - return pix; + area->SetAttributes(attribs); + ParseFunctionCalls(area); + return area; } -cTemplatePixmapContainer *cXmlParser::ParseAreaContainer(void) { +cAreaContainer *cXmlParser::ParseAreaContainer(void) { vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - cTemplatePixmapContainer *pixContainer = new cTemplatePixmapContainer(); - pixContainer->SetParameters(attribs); + cAreaContainer *areaContainer = new cAreaContainer(); + areaContainer->SetAttributes(attribs); if (!LevelDown()) - return pixContainer; + return areaContainer; do { if (!CheckNodeName("area") && !CheckNodeName("areascroll")) { esyslog("skindesigner: invalid tag \"%s\" in areacontainer", NodeName()); continue; } - cTemplatePixmap *pix = ParseArea(); - pixContainer->AddPixmap(pix); + cArea *area = ParseArea(); + areaContainer->AddArea(area); } while (NextNode()); LevelUp(); - return pixContainer; + return areaContainer; } -void cXmlParser::ParseFunctionCalls(cTemplatePixmap *pix) { +void cXmlParser::ParseFunctionCalls(cArea *area) { if (!view) return; if (!LevelDown()) @@ -396,31 +515,28 @@ void cXmlParser::ParseFunctionCalls(cTemplatePixmap *pix) { do { if (CheckNodeName("loop")) { vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - cTemplateLoopFunction *loopFunc = new cTemplateLoopFunction(); - loopFunc->SetParameters(attribs); - ParseLoopFunctionCalls(loopFunc); - pix->AddLoopFunction(loopFunc); - } else if (view->ValidFunction(NodeName())) { + cFunction *f = area->AddFunction(NodeName(), attribs); + cFuncLoop *loopFunc = dynamic_cast<cFuncLoop*>(f); + if (!loopFunc) + continue; + ParseLoopFunctionCalls(area, loopFunc); + } else if (area->ValidFunction(NodeName())) { vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - pix->AddFunction(NodeName(), attribs); + area->AddFunction(NodeName(), attribs); } - } while (NextNode()); LevelUp(); } -void cXmlParser::ParseLoopFunctionCalls(cTemplateLoopFunction *loopFunc) { +void cXmlParser::ParseLoopFunctionCalls(cArea *area, cFuncLoop *loopFunc) { if (!view) return; if (!LevelDown()) return; do { - if (view->ValidFunction(NodeName())) { + if (area->ValidFunction(NodeName())) { vector<stringpair> attribs = ParseAttributes(); - ValidateAttributes(NodeName(), attribs); - loopFunc->AddFunction(NodeName(), attribs); + area->AddFunction(NodeName(), attribs, loopFunc); } } while (NextNode()); LevelUp(); @@ -610,21 +726,6 @@ void cXmlParser::ParseSetupParameter(void) { skinSetup->SetParameter(paramType, paramName, paramDisplayText, paramHelpText, paramMin, paramMax, paramValue, paramOptions); } -void cXmlParser::ValidateAttributes(const char *nodeName, vector<stringpair> &attributes) { - bool repeat = true; - while (repeat) { - repeat = false; - for (vector<stringpair>::iterator it = attributes.begin(); it != attributes.end(); it++) { - string attributeName = (*it).first; - if (!view->ValidAttribute(nodeName, attributeName.c_str())) { - attributes.erase(it); - repeat = true; - break; - } - } - } -} - string cXmlParser::GetPath(string xmlFile) { string activeSkin = Setup.OSDSkin; string activeTheme = Setup.OSDTheme; diff --git a/libtemplate/xmlparser.h b/coreengine/xmlparser.h index 3dd0705..398700e 100644 --- a/libtemplate/xmlparser.h +++ b/coreengine/xmlparser.h @@ -9,12 +9,11 @@ #include <map> #include <set> #include <vdr/plugin.h> -#include "../libcore/libxmlwrapper.h" -#include "templateview.h" -#include "templateviewlist.h" -#include "templateviewgrid.h" -#include "templateviewtab.h" -#include "../libcore/skinsetup.h" +#include "../extensions/libxmlwrapper.h" +#include "osdwrapper.h" +#include "view.h" +#include "viewlist.h" +#include "../extensions/skinsetup.h" using namespace std; @@ -22,19 +21,22 @@ using namespace std; class cXmlParser : public cLibXMLWrapper { private: - cTemplateView *view; + cSdOsd *sdOsd; + cView *view; cGlobals *globals; cSkinSetup *skinSetup; //parsing views - bool ParseSubView(void); - void ParseViewElement(cTemplateView *subView = NULL); - void ParseViewList(cTemplateView *subView = NULL); - void ParseViewTab(cTemplateView *subView); + bool ParseSubView(string name); + void ParseViewElement(string name, cView *subView = NULL); + void ParsePluginViewElement(bool isScrollbar = false, bool isTabLabels = false); + void ParseViewList(cView *subView = NULL); + void ParseViewTab(cView *subView); + void ParseViewTabPlugin(void); void ParseGrid(void); - cTemplatePixmap *ParseArea(void); - cTemplatePixmapContainer *ParseAreaContainer(void); - void ParseFunctionCalls(cTemplatePixmap *pix); - void ParseLoopFunctionCalls(cTemplateLoopFunction *loopFunc); + cArea *ParseArea(void); + cAreaContainer *ParseAreaContainer(void); + void ParseFunctionCalls(cArea *area); + void ParseLoopFunctionCalls(cArea *area, cFuncLoop *loopFunc); //parsing globals void ParseGlobalColors(void); void InsertColor(string name, string value); @@ -46,17 +48,19 @@ private: void ParseSetupMenu(void); void ParseSetupParameter(void); //helpers - void ValidateAttributes(const char *nodeName, vector<stringpair> &attributes); string GetPath(string xmlFile); public: cXmlParser(void); virtual ~cXmlParser(void); + void SetOsd(cSdOsd *osd) { sdOsd = osd; }; //reading views - bool ReadView(cTemplateView *view, string xmlFile); + bool ReadView(cView *view, string xmlFile); bool ParseView(void); - //reading plugin views - bool ReadPluginView(string plugName, int templateNumber, string templateName); - bool ParsePluginView(string plugName, int templateNumber); + //Parse advanced plugin view + bool ParsePluginView(void); + //reading basic plugin menu views + bool ReadPluginView(string templateName); + bool ParsePluginView(string plugName, int plugId, int menuNumber, int menuType); //reading globals bool ReadGlobals(cGlobals *globals, string xmlFile); bool ParseGlobals(void); @@ -1,5 +1,5 @@ #include "designer.h" -#include "libcore/helpers.h" +#include "extensions/helpers.h" cSkinDesigner::cSkinDesigner(string skin) : cSkin(skin.c_str(), &::Theme) { init = true; @@ -9,13 +9,12 @@ cSkinDesigner::cSkinDesigner(string skin) : cSkin(skin.c_str(), &::Theme) { useBackupSkin = false; globals = NULL; - channelTemplate = NULL; - menuTemplate = NULL; - messageTemplate = NULL; - replayTemplate = NULL; - volumeTemplate = NULL; - audiotracksTemplate = NULL; - + channelView = NULL; + menuView = NULL; + messageView = NULL; + replayView = NULL; + volumeView = NULL; + tracksView = NULL; currentMenu = NULL; dsyslog("skindesigner: skin %s started", skin.c_str()); @@ -24,7 +23,7 @@ cSkinDesigner::cSkinDesigner(string skin) : cSkin(skin.c_str(), &::Theme) { cSkinDesigner::~cSkinDesigner(void) { if (globals) delete globals; - DeleteTemplates(); + DeleteViews(); if (backupSkin) delete backupSkin; } @@ -36,9 +35,9 @@ const char *cSkinDesigner::Description(void) { cSkinDisplayChannel *cSkinDesigner::DisplayChannel(bool WithInfo) { currentMenu = NULL; cSkinDisplayChannel *displayChannel = NULL; + Init(); if (!useBackupSkin) { - Init(); - displayChannel = new cSDDisplayChannel(channelTemplate, WithInfo); + displayChannel = new cSDDisplayChannel(channelView, WithInfo); } else { displayChannel = backupSkin->DisplayChannel(WithInfo); } @@ -49,7 +48,7 @@ cSkinDisplayMenu *cSkinDesigner::DisplayMenu(void) { if (!useBackupSkin) { cSDDisplayMenu *displayMenu = NULL; Init(); - displayMenu = new cSDDisplayMenu(menuTemplate); + displayMenu = new cSDDisplayMenu(menuView); currentMenu = displayMenu; return displayMenu; } else { @@ -64,7 +63,7 @@ cSkinDisplayReplay *cSkinDesigner::DisplayReplay(bool ModeOnly) { cSkinDisplayReplay *displayReplay = NULL; if (!useBackupSkin) { Init(); - displayReplay = new cSDDisplayReplay(replayTemplate, ModeOnly); + displayReplay = new cSDDisplayReplay(replayView, ModeOnly); } else { displayReplay = backupSkin->DisplayReplay(ModeOnly); } @@ -76,7 +75,7 @@ cSkinDisplayVolume *cSkinDesigner::DisplayVolume(void) { cSkinDisplayVolume *displayVolume = NULL; if (!useBackupSkin) { Init(); - displayVolume = new cSDDisplayVolume(volumeTemplate); + displayVolume = new cSDDisplayVolume(volumeView); } else { displayVolume = backupSkin->DisplayVolume(); } @@ -88,7 +87,7 @@ cSkinDisplayTracks *cSkinDesigner::DisplayTracks(const char *Title, int NumTrack cSkinDisplayTracks *displayTracks = NULL; if (!useBackupSkin) { Init(); - displayTracks = new cSDDisplayTracks(audiotracksTemplate, Title, NumTracks, Tracks); + displayTracks = new cSDDisplayTracks(tracksView, Title, NumTracks, Tracks); } else { displayTracks = backupSkin->DisplayTracks(Title, NumTracks, Tracks); } @@ -100,28 +99,13 @@ cSkinDisplayMessage *cSkinDesigner::DisplayMessage(void) { cSkinDisplayMessage *displayMessage = NULL; if (!useBackupSkin) { Init(); - displayMessage = new cSDDisplayMessage(messageTemplate); + displayMessage = new cSDDisplayMessage(messageView); } else { displayMessage = backupSkin->DisplayMessage(); } return displayMessage; } -cSkinDisplayPlugin *cSkinDesigner::DisplayPlugin(string pluginName, int viewID, int subViewID) { - currentMenu = NULL; - if (useBackupSkin) - return NULL; - Init(); - map< string, map <int, cTemplate*> >::iterator hit = pluginTemplates.find(pluginName); - if (hit == pluginTemplates.end()) - return NULL; - map <int, cTemplate*>::iterator hit2 = (hit->second).find(viewID); - if (hit2 == (hit->second).end()) - return NULL; - return new cSkinDisplayPlugin(hit2->second, subViewID); -} - - void cSkinDesigner::Reload(void) { dsyslog("skindesigner: forcing full reload of templates"); if (cOsd::IsOpen()) { @@ -130,14 +114,14 @@ void cSkinDesigner::Reload(void) { } cStopWatch watch; - bool ok = LoadTemplates(); + bool ok = LoadViews(); if (!ok) { esyslog("skindesigner: error during loading of templates - using LCARS as backup"); if (!backupSkin) backupSkin = new cSkinLCARS(); useBackupSkin = true; } else { - CacheTemplates(); + CacheViews(); useBackupSkin = false; watch.Stop("templates reloaded and cache created"); } @@ -147,38 +131,62 @@ void cSkinDesigner::ListAvailableFonts(void) { fontManager->ListAvailableFonts(); } -bool cSkinDesigner::SetCustomToken(string option) { +bool cSkinDesigner::SetCustomIntToken(string option) { splitstring s(option.c_str()); vector<string> flds = s.split('=', 0); - if (flds.size() != 2) return false; - - string key = trim(flds[0]); + int key = atoi(trim(flds[0]).c_str()); string val = trim(flds[1]); - if (!globals) return true; - - if (isNumber(val)) { + if (key > 0 && isNumber(val)) { globals->AddCustomInt(key, atoi(val.c_str())); } else { - globals->AddCustomString(key, val); + return false; } return true; } +bool cSkinDesigner::SetCustomStringToken(string option) { + splitstring s(option.c_str()); + vector<string> flds = s.split('=', 0); + if (flds.size() != 2) + return false; + int key = atoi(trim(flds[0]).c_str()); + string val = trim(flds[1]); + if (!globals) + return true; + if (key > 0) + globals->AddCustomString(key, val); + else + return false; + return true; +} + void cSkinDesigner::ListCustomTokens(void) { if (!globals) return; globals->ListCustomTokens(); } +skindesignerapi::ISkinDisplayPlugin *cSkinDesigner::GetDisplayPlugin(int plugId) { + map<int, cViewPlugin*>::iterator hit = pluginViews.find(plugId); + if (hit == pluginViews.end()) + return NULL; + return hit->second; +} + /********************************************************************************* * PRIVATE FUNCTIONS *********************************************************************************/ void cSkinDesigner::Init(void) { - if (init || config.OsdSizeChanged() || config.SkinChanged() || config.OsdLanguageChanged() || config.setupCloseDoReload) { + if ( init + || config.OsdSizeChanged() + || config.SkinChanged() + || config.OsdLanguageChanged() || + config.setupCloseDoReload ) + { config.setupCloseDoReload = false; if (init) { config.SetSkin(); @@ -188,7 +196,8 @@ void cSkinDesigner::Init(void) { dsyslog("skindesigner: initializing skin %s", skin.c_str()); config.CheckDecimalPoint(); - + plgManager->Reset(); + if (fontManager) delete fontManager; fontManager = new cFontManager(); @@ -198,69 +207,63 @@ void cSkinDesigner::Init(void) { imgCache->SetPathes(); cStopWatch watch; - bool ok = LoadTemplates(); + bool ok = LoadViews(); if (!ok) { esyslog("skindesigner: error during loading of templates - using LCARS as backup"); backupSkin = new cSkinLCARS(); useBackupSkin = true; } else { - CacheTemplates(); - watch.Stop("templates loaded and cache created"); + CacheViews(); + watch.Stop("templates loaded and caches created"); } init = false; - } else if (config.OsdFontsChanged()) { + } + else if (config.OsdFontsChanged()) + { dsyslog("skindesigner: reloading fonts"); if (fontManager) delete fontManager; fontManager = new cFontManager(); cStopWatch watch; - bool ok = LoadTemplates(); + bool ok = LoadViews(); if (!ok) { esyslog("skindesigner: error during loading of templates - using LCARS as backup"); backupSkin = new cSkinLCARS(); useBackupSkin = true; } else { - CacheTemplates(); - watch.Stop("templates loaded and cache created"); + CacheViews(); + watch.Stop("templates loaded and caches created"); } } } -void cSkinDesigner::DeleteTemplates(void) { - if (channelTemplate) { - delete channelTemplate; - channelTemplate = NULL; - } - if (menuTemplate) { - delete menuTemplate; - menuTemplate = NULL; - } - if (messageTemplate) { - delete messageTemplate; - messageTemplate = NULL; - } - if (replayTemplate) { - delete replayTemplate; - replayTemplate = NULL; - } - if (volumeTemplate) { - delete volumeTemplate; - volumeTemplate = NULL; - } - if (audiotracksTemplate) { - delete audiotracksTemplate; - audiotracksTemplate = NULL; - } - for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs !=pluginTemplates.end(); plugs++) { - map <int, cTemplate*> plugTpls = plugs->second; - for (map <int, cTemplate*>::iterator tpl = plugTpls.begin(); tpl != plugTpls.end(); tpl++) { - delete tpl->second; - } +void cSkinDesigner::DeleteViews(void) { + delete channelView; + channelView = NULL; + + delete menuView; + menuView = NULL; + + delete messageView; + messageView = NULL; + + delete replayView; + replayView = NULL; + + delete volumeView; + volumeView = NULL; + + delete tracksView; + tracksView = NULL; + + for (map<int,cViewPlugin*>::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { + cViewPlugin *plugView = it->second; + delete plugView; } - pluginTemplates.clear(); + pluginViews.clear(); } -bool cSkinDesigner::LoadTemplates(void) { +bool cSkinDesigner::LoadViews(void) { if (globals) delete globals; globals = new cGlobals(); @@ -276,142 +279,102 @@ bool cSkinDesigner::LoadTemplates(void) { skinSetup->AddToGlobals(globals); } - DeleteTemplates(); + DeleteViews(); - channelTemplate = new cTemplate(vtDisplayChannel); - channelTemplate->SetGlobals(globals); - ok = channelTemplate->ReadFromXML(); + channelView = new cViewChannel(); + ok = channelView->ReadFromXML(); if (!ok) { esyslog("skindesigner: error reading displaychannel template, aborting"); - DeleteTemplates(); + DeleteViews(); return false; } - channelTemplate->Translate(); + channelView->SetGlobals(globals); - menuTemplate = new cTemplate(vtDisplayMenu); - menuTemplate->SetGlobals(globals); - ok = menuTemplate->ReadFromXML(); + menuView = new cViewMenu(); + ok = menuView->ReadFromXML(); if (!ok) { esyslog("skindesigner: error reading displaymenu template, aborting"); - DeleteTemplates(); + DeleteViews(); return false; } - menuTemplate->Translate(); + menuView->SetGlobals(globals); - messageTemplate = new cTemplate(vtDisplayMessage); - messageTemplate->SetGlobals(globals); - ok = messageTemplate->ReadFromXML(); + messageView = new cViewMessage(); + ok = messageView->ReadFromXML(); if (!ok) { esyslog("skindesigner: error reading displaymessage template, aborting"); - DeleteTemplates(); + DeleteViews(); return false; } - messageTemplate->Translate(); + messageView->SetGlobals(globals); - replayTemplate = new cTemplate(vtDisplayReplay); - replayTemplate->SetGlobals(globals); - ok = replayTemplate->ReadFromXML(); + replayView = new cViewReplay(); + ok = replayView->ReadFromXML(); if (!ok) { esyslog("skindesigner: error reading displayreplay template, aborting"); - DeleteTemplates(); + DeleteViews(); return false; } - replayTemplate->Translate(); + replayView->SetGlobals(globals); - volumeTemplate = new cTemplate(vtDisplayVolume); - volumeTemplate->SetGlobals(globals); - ok = volumeTemplate->ReadFromXML(); + volumeView = new cViewVolume(); + ok = volumeView->ReadFromXML(); if (!ok) { esyslog("skindesigner: error reading displayvolume template, aborting"); - DeleteTemplates(); + DeleteViews(); return false; } - volumeTemplate->Translate(); + volumeView->SetGlobals(globals); - audiotracksTemplate = new cTemplate(vtDisplayAudioTracks); - audiotracksTemplate->SetGlobals(globals); - ok = audiotracksTemplate->ReadFromXML(); + tracksView = new cViewTracks(); + ok = tracksView->ReadFromXML(); if (!ok) { esyslog("skindesigner: error reading displayaudiotracks template, aborting"); - DeleteTemplates(); + DeleteViews(); return false; } - audiotracksTemplate->Translate(); - - config.InitPluginViewIterator(); - map <int,string> *plugViews = NULL; - string plugName; - while ( plugViews = config.GetPluginViews(plugName) ) { - for (map <int,string>::iterator v = plugViews->begin(); v != plugViews->end(); v++) { - int viewID = v->first; - stringstream templateName; - templateName << "plug-" << plugName << "-" << v->second.c_str(); - cTemplate *plgTemplate = new cTemplate(vtDisplayPlugin, plugName, viewID); - plgTemplate->SetGlobals(globals); - ok = plgTemplate->ReadFromXML(templateName.str()); - if (!ok) { - esyslog("skindesigner: error reading plugin %s template", plugName.c_str()); - delete plgTemplate; - pluginTemplates.erase(plugName); - break; - } - ok = plgTemplate->SetSubViews(plugName, viewID); - if (!ok) { - delete plgTemplate; - pluginTemplates.erase(plugName); - break; - } - plgTemplate->Translate(); - map< string, map <int, cTemplate*> >::iterator hit = pluginTemplates.find(plugName); - if (hit == pluginTemplates.end()) { - map <int, cTemplate*> plugTemplates; - plugTemplates.insert(pair<int, cTemplate*>(v->first, plgTemplate)); - pluginTemplates.insert(pair<string, map <int, cTemplate*> >(plugName, plugTemplates)); - } else { - (hit->second).insert(pair<int, cTemplate*>(v->first, plgTemplate)); - } - } - } + tracksView->SetGlobals(globals); + + LoadPluginViews(); dsyslog("skindesigner: templates successfully validated and parsed"); return true; } -void cSkinDesigner::CacheTemplates(void) { - channelTemplate->PreCache(); - menuTemplate->PreCache(); - messageTemplate->PreCache(); - replayTemplate->PreCache(); - volumeTemplate->PreCache(); - audiotracksTemplate->PreCache(); - for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs != pluginTemplates.end(); plugs++) { - for (map <int, cTemplate*>::iterator plugTplts = plugs->second.begin(); plugTplts != plugs->second.end(); plugTplts++) { - (plugTplts->second)->PreCache(); +void cSkinDesigner::LoadPluginViews(void) { + plgManager->InitPluginViewIterator(); + string plugName = ""; + string viewTpl = ""; + int plugId = -1; + while ( plgManager->GetNextPluginView(plugName, plugId, viewTpl) ) { + cViewPlugin *plugView = new cViewPlugin(0, plugId); + bool ok = plugView->ReadFromXML(plugName.c_str(), viewTpl.c_str()); + if (!ok) { + esyslog("skindesigner: error during loading templates for plugin %s", plugName.c_str()); + continue; } - } - dsyslog("skindesigner: templates cached"); - fontManager->DeleteFonts(); - fontManager->CacheFonts(channelTemplate); - fontManager->CacheFonts(menuTemplate); - fontManager->CacheFonts(messageTemplate); - fontManager->CacheFonts(replayTemplate); - fontManager->CacheFonts(volumeTemplate); - fontManager->CacheFonts(audiotracksTemplate); - dsyslog("skindesigner: fonts cached"); - dsyslog("skindesigner: caching images..."); - imgCache->Clear(); - imgCache->SetPathes(); - channelTemplate->CacheImages(); - menuTemplate->CacheImages(); - messageTemplate->CacheImages(); - replayTemplate->CacheImages(); - volumeTemplate->CacheImages(); - audiotracksTemplate->CacheImages(); - for (map< string, map <int, cTemplate*> >::iterator plugs = pluginTemplates.begin(); plugs != pluginTemplates.end(); plugs++) { - for (map <int, cTemplate*>::iterator plugTplts = plugs->second.begin(); plugTplts != plugs->second.end(); plugTplts++) { - (plugTplts->second)->CacheImages(); + ok = plugView->ReadSubViews(plugName.c_str()); + if (!ok) { + esyslog("skindesigner: error during loading templates for plugin %s", plugName.c_str()); + continue; } + plugView->SetGlobals(globals); + pluginViews.insert(pair<int, cViewPlugin*>(plugId, plugView)); + } +} + +void cSkinDesigner::CacheViews(void) { + channelView->PreCache(); + menuView->PreCache(); + messageView->PreCache(); + replayView->PreCache(); + volumeView->PreCache(); + tracksView->PreCache(); + for (map<int,cViewPlugin*>::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { + cViewPlugin *plugView = it->second; + plugView->PreCache(); } + dsyslog("skindesigner: templates and images cached"); imgCache->Debug(false); } @@ -4,15 +4,19 @@ class cSkinDesigner; #include "config.h" -#include "libtemplate/template.h" -#include "libtemplate/xmlparser.h" +#include "coreengine/viewdisplaychannel.h" +#include "coreengine/viewdisplaymenu.h" +#include "coreengine/viewdisplayreplay.h" +#include "coreengine/viewdisplayvolume.h" +#include "coreengine/viewdisplaytracks.h" +#include "coreengine/viewdisplaymessage.h" +#include "coreengine/viewdisplayplugin.h" #include "displaychannel.h" #include "displaymenu.h" #include "displayreplay.h" #include "displayvolume.h" #include "displaytracks.h" #include "displaymessage.h" -#include "displayplugin.h" #include <vdr/skinlcars.h> class cSkinDesigner : public cSkin { @@ -22,19 +26,20 @@ private: cSkinLCARS *backupSkin; bool useBackupSkin; cGlobals *globals; - cTemplate *channelTemplate; - cTemplate *menuTemplate; - cTemplate *messageTemplate; - cTemplate *replayTemplate; - cTemplate *volumeTemplate; - cTemplate *audiotracksTemplate; - map< string, map <int, cTemplate*> > pluginTemplates; + cViewChannel *channelView; + cViewMenu *menuView; + cViewMessage *messageView; + cViewReplay *replayView; + cViewVolume *volumeView; + cViewTracks *tracksView; cSDDisplayMenu *currentMenu; + map<int, cViewPlugin* > pluginViews; void Init(void); void ReloadCaches(void); - void DeleteTemplates(void); - bool LoadTemplates(void); - void CacheTemplates(void); + void DeleteViews(void); + bool LoadViews(void); + void LoadPluginViews(void); + void CacheViews(void); public: cSkinDesigner(string skin); virtual ~cSkinDesigner(void); @@ -45,13 +50,14 @@ public: virtual cSkinDisplayVolume *DisplayVolume(void); virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks); virtual cSkinDisplayMessage *DisplayMessage(void); - virtual cSkinDisplayPlugin *DisplayPlugin(string pluginName, int viewID, int subViewID); void ActivateBackupSkin(void) { useBackupSkin = true; }; void Reload(void); void ListAvailableFonts(void); - bool SetCustomToken(string option); + bool SetCustomIntToken(string option); + bool SetCustomStringToken(string option); void ListCustomTokens(void); cSDDisplayMenu *GetDisplayMenu(void) { return currentMenu; }; + skindesignerapi::ISkinDisplayPlugin *GetDisplayPlugin(int plugId); }; #endif //__SKINDESIGNER_H diff --git a/displaychannel.c b/displaychannel.c index ff18da7..0b2fbdc 100644 --- a/displaychannel.c +++ b/displaychannel.c @@ -1,220 +1,36 @@ #include "displaychannel.h" -#include "libcore/timers.h" -cSDDisplayChannel::cSDDisplayChannel(cTemplate *channelTemplate, bool WithInfo) { - channelView = NULL; - - if (!channelTemplate) { - doOutput = false; - return; - } else { - doOutput = true; - } - groupSep = false; - present = NULL; - currentLast = 0; - channelChange = false; - initial = true; - devicesLast = cTimeMs::Now(); - currentChannelSid = -1; - isEncrypted = false; - - channelView = new cDisplayChannelView(channelTemplate->GetRootView()); - if (!channelView->createOsd()) { - doOutput = false; - return; - } - channelView->DrawDebugGrid(); +cSDDisplayChannel::cSDDisplayChannel(cViewChannel *channelView, bool WithInfo) { + view = channelView; + ok = view->Init(); + if (!ok) + esyslog("skindesigner: Error initiating displaychannel view - aborting"); } cSDDisplayChannel::~cSDDisplayChannel() { - if (channelView) - delete channelView; + view->Close(); } void cSDDisplayChannel::SetChannel(const cChannel *Channel, int Number) { - if (!doOutput) + if (!ok) return; - channelChange = true; - groupSep = false; - - cString ChannelNumber(""); - cString ChannelName(""); - cString ChannelID(""); - currentChannelSid = -1; - isEncrypted = false; - - if (Channel) { - ChannelName = Channel->Name() ? Channel->Name() : ""; - ChannelID = Channel->GetChannelID().ToString(); - currentChannelSid = Channel->Sid(); - isEncrypted = Channel->Ca(); - if (!Channel->GroupSep()) { - ChannelNumber = cString::sprintf("%d%s", Channel->Number(), Number ? "-" : ""); - } else { - groupSep = true; - } - } else if (Number) { - ChannelNumber = cString::sprintf("%d-", Number); - } else { - ChannelName = ChannelString(NULL, 0); - } - - channelView->ClearChannel(); - channelView->ClearEPGInfo(); - channelView->ClearStatusIcons(); - channelView->ClearChannelGroups(); - channelView->ClearScraperContent(); - channelView->ClearAudioInfo(); - channelView->ClearEncryptionInfo(); - if (!groupSep) { - channelView->DrawChannel(ChannelNumber, ChannelName, ChannelID, (Number > 0)?true:false); - channelView->DrawProgressBarBack(); - channelView->DrawSignalBackground(); - if (Channel) { - channelView->DrawStatusIcons(Channel); - channelView->DrawAudioInfo(); - } - } else { - channelView->ClearSignal(); - channelView->ClearSignalBackground(); - channelView->ClearProgressBar(); - channelView->ClearProgressBarBack(); - if (Channel) - channelView->DrawChannelGroups(Channel, ChannelName); - } - + view->SetChannel(Channel, Number); } void cSDDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following) { - if (!doOutput) + if (!ok) return; - - present = Present; - channelView->ClearProgressBar(); - if (!groupSep) { - channelView->ClearEPGInfo(); - } - - cGlobalSortedTimers SortedTimers;// local and remote timers - - bool recPresent = false; - if (Present) { - if (!groupSep) { - SetProgressBar(Present); - } - eTimerMatch TimerMatch = tmNone; - const cTimer *Timer = Timers.GetMatch(Present, &TimerMatch); - if (Timer && Timer->Recording()) { - recPresent = true; - } - for (int i = 0; i < SortedTimers.Size() && !recPresent; i++) - if (const cTimer *Timer = SortedTimers[i]) - if (Timer->Channel()->GetChannelID() == Present->ChannelID()) - if (const cEvent *timerEvent = Timer->Event()) - if (Present->EventID() == timerEvent->EventID()) - recPresent = Timer->Recording(); - - } - bool recFollowing = false; - if (Following) { - recFollowing = Following->HasTimer(); - for (int i = 0; i < SortedTimers.Size() && !recFollowing; i++) - if (const cTimer *Timer = SortedTimers[i]) - if (Timer->Channel()->GetChannelID() == Following->ChannelID()) - if (const cEvent *timerEvent = Timer->Event()) - if (Following->EventID() == timerEvent->EventID()) - recFollowing = true; - } - - if (Present || Following) { - channelView->DrawEPGInfo(Present, Following, recPresent, recFollowing); - channelView->DrawScraperContent(Present); - } -} - -void cSDDisplayChannel::SetProgressBar(const cEvent *present) { - int Current = 0; - int Total = 0; - time_t t = time(NULL); - if (t > present->StartTime()) - Current = t - present->StartTime(); - Total = present->Duration(); - if ((Current > currentLast + 3) || initial || channelChange) { - currentLast = Current; - cString start = present->GetTimeString(); - cString stop = present->GetEndTimeString(); - channelView->DrawProgressBar(start, stop, Current, Total); - } + view->SetEvents(Present, Following); } - void cSDDisplayChannel::SetMessage(eMessageType Type, const char *Text) { - if (!doOutput) + if (!ok) return; - channelView->ClearChannel(); - channelView->ClearEPGInfo(); - channelView->ClearStatusIcons(); - channelView->ClearScreenResolution(); - channelView->ClearProgressBar(); - channelView->ClearProgressBarBack(); - channelView->ClearSignal(); - channelView->ClearSignalBackground(); - channelView->ClearScraperContent(); - channelView->ClearAudioInfo(); - channelView->DisplayMessage(Type, Text); - groupSep = true; + view->SetMessage(Type, Text); } void cSDDisplayChannel::Flush(void) { - if (!doOutput) + if (!ok) return; - - if (initial) { - channelView->DrawBackground(); - channelView->DrawSignalBackground(); - channelView->DrawCurrentWeather(); - } - - if (initial || channelView->CustomTokenChange()) { - channelView->DrawCustomTokens(); - } - - if (initial || channelChange) { - channelView->DrawDate(); - } - channelView->DrawTime(); - - if (present) { - SetProgressBar(present); - } else { - channelView->ClearProgressBar(); - } - - if (!groupSep) { - channelView->DrawScreenResolution(); - channelView->DrawSignal(); - channelView->DrawAudioInfo(); - if (initial || cTimeMs::Now() - devicesLast > 500) { - channelView->DrawDevices(initial); - devicesLast = cTimeMs::Now(); - } - if (isEncrypted) { - channelView->DrawEncryptionInfo(currentChannelSid); - } - } else { - channelView->ClearStatusIcons(); - channelView->ClearScreenResolution(); - channelView->ClearSignal(); - channelView->ClearSignalBackground(); - channelView->ClearDevices(); - } - - if (initial) { - channelView->DoStart(); - } - - initial = false; - channelChange = false; - channelView->Flush(); + view->Flush(); } diff --git a/displaychannel.h b/displaychannel.h index b8d8973..f116f2c 100644 --- a/displaychannel.h +++ b/displaychannel.h @@ -1,34 +1,21 @@ #ifndef __DISPLAYCHANNEL_H #define __DISPLAYCHANNEL_H -#include <vdr/thread.h> +#include <vdr/skins.h> #include "config.h" -#include "libtemplate/template.h" -#include "views/displaychannelview.h" +#include "coreengine/definitions.h" +#include "coreengine/viewdisplaychannel.h" class cSDDisplayChannel : public cSkinDisplayChannel { private: - cDisplayChannelView *channelView; - bool doOutput; - bool initial; - bool groupSep; - bool channelChange; - time_t lastSignalDisplay; - int lastSignalStrength; - int lastSignalQuality; - int lastScreenWidth; - int currentLast; - uint64_t devicesLast; - const cEvent *present; - int currentChannelSid; - int isEncrypted; - void SetProgressBar(const cEvent *present); + cViewChannel *view; + bool ok; public: - cSDDisplayChannel(cTemplate *channelTemplate, bool WithInfo); + cSDDisplayChannel(cViewChannel *channelView, bool WithInfo); virtual ~cSDDisplayChannel(); virtual void SetChannel(const cChannel *Channel, int Number); virtual void SetEvents(const cEvent *Present, const cEvent *Following); virtual void SetMessage(eMessageType Type, const char *Text); virtual void Flush(void); }; -#endif //__DISPLAYCHANNEL_H
\ No newline at end of file +#endif //__DISPLAYCHANNEL_H diff --git a/displaymenu.c b/displaymenu.c index 2e78793..c2cd486 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -1,345 +1,174 @@ -#include <vdr/player.h> #include "displaymenu.h" -#include "libcore/helpers.h" -cSDDisplayMenu::cSDDisplayMenu(cTemplate *menuTemplate) { - textAreaFont = NULL; - rootView = NULL; - doOutput = true; - state = vsInit; - pluginMenu = -1; - pluginName = ""; - pluginMenuType = mtUnknown; - if (!menuTemplate) { - doOutput = false; - dsyslog("skindesigner: displayMenu no valid template - aborting"); - return; - } - rootView = new cDisplayMenuRootView(menuTemplate->GetRootView()); - if (!rootView->createOsd()) { - doOutput = false; - return; +cSDDisplayMenu::cSDDisplayMenu(cViewMenu *menuView) { + view = menuView; + bool ok = false; + if (view) + ok = view->Init(); + if (ok) { + SetCurrentRecording(); + } else { + esyslog("skindesigner: Error initiating displaymenu view - aborting"); } - SetCurrentRecording(); - rootView->DrawDebugGrid(); } cSDDisplayMenu::~cSDDisplayMenu() { - if (rootView) - delete rootView; - if (textAreaFont) - delete textAreaFont; + if (view) + view->Close(); } void cSDDisplayMenu::Scroll(bool Up, bool Page) { - if (!doOutput) - return; - rootView->KeyInput(Up, Page); + if (view) + view->KeyDetailView(Up, Page); } int cSDDisplayMenu::MaxItems(void) { - if (!doOutput) - return 0; - int maxItems = rootView->GetMaxItems(); - return maxItems; + if (view) + return view->NumListItems(); + return 0; } void cSDDisplayMenu::Clear(void) { - if (!doOutput) - return; - rootView->Clear(); + if (view) + view->Clear(); } void cSDDisplayMenu::SetMenuCategory(eMenuCategory MenuCat) { - if (!doOutput) - return; - rootView->SetMenu(MenuCat, (state == vsInit) ? true : false); - cSkinDisplayMenu::SetMenuCategory(MenuCat); - if (state != vsInit) - state = vsMenuInit; + if (view) + view->SetSubView(MenuCat); } void cSDDisplayMenu::SetMenuSortMode(eMenuSortMode MenuSortMode) { - if (!doOutput) - return; - rootView->SetSortMode(MenuSortMode); + if (view) + view->SetSortMode(MenuSortMode); } eMenuOrientation cSDDisplayMenu::MenuOrientation(void) { - if (!doOutput) - return moVertical; - return rootView->MenuOrientation(); + if (view) + return view->MenuOrientation(); + return moVertical; } -void cSDDisplayMenu::SetPluginMenu(string name, int menu, int type, bool init) { - pluginName = name; - pluginMenu = menu; - pluginMenuType = (ePluginMenuType)type; - rootView->SetPluginMenu(pluginName, pluginMenu, pluginMenuType); - if (!init) { - rootView->SetMenu(mcPlugin, false); - } +void cSDDisplayMenu::SetPluginMenu(int plugId, int menuId, int type, bool init) { + if (view) + view->SetPluginMenu(plugId, menuId); } void cSDDisplayMenu::SetTitle(const char *Title) { - if (!doOutput) - return; - rootView->SetTitle(Title); + if (view) + view->SetTitleHeader(Title); } void cSDDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue) { - if (!doOutput) - return; - rootView->SetButtonTexts(Red, Green, Yellow, Blue); - if (state != vsInit && MenuCategory() != mcMain) - state = vsMenuInit; + if (view) + view->SetMenuButtons(Red, Green, Yellow, Blue); } void cSDDisplayMenu::SetMessage(eMessageType Type, const char *Text) { - if (!doOutput) - return; - rootView->SetMessage(Type, Text); - rootView->DoFlush(); + if (view) + view->SetMessage(Type, Text); } bool cSDDisplayMenu::SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch) { - if (!doOutput) - return true; - if (!rootView->SubViewAvailable()) + if (!view) return false; - if (config.blockFlush) - rootView->LockFlush(); - bool isFav = false; - if (MenuCategory() == mcSchedule && Channel) { - isFav = true; - rootView->SetEpgSearchFavorite(); - } - const cChannel *channel = Channel; - if (MenuCategory() == mcSchedule) { - if (!channel) { - channel = rootView->GetChannel(); - } - if (!channel && Event) { - channel = Channels.GetByChannelID(Event->ChannelID()); - } - rootView->SetChannel(channel); + if (Index == 0) { + view->SetChannelHeader(Event); } - - cDisplayMenuListView *list = rootView->GetListView(); - if (!list) - return false; - list->AddSchedulesMenuItem(Index, Event, channel, TimerMatch, MenuCategory(), isFav, Current, Selectable, ""); - if (state == vsIdle) - state = vsMenuUpdate; - return true; + return view->SetItemEvent(Event, Index, Current, Selectable, Channel, WithDate, TimerMatch); } bool cSDDisplayMenu::SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable) { - if (!doOutput) - return true; - if (!rootView->SubViewAvailable()) - return false; - if (config.blockFlush) - rootView->LockFlush(); - cDisplayMenuListView *list = rootView->GetListView(); - if (!list) + if (!view) return false; - list->AddTimersMenuItem(Index, Timer, Current, Selectable); - if (state == vsIdle) - state = vsMenuUpdate; - return true; + return view->SetItemTimer(Timer, Index, Current, Selectable); } bool cSDDisplayMenu::SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider) { - if (!doOutput) - return true; - if (!rootView->SubViewAvailable()) - return false; - if (config.blockFlush) - rootView->LockFlush(); - cDisplayMenuListView *list = rootView->GetListView(); - if (!list) + if (!view) return false; - list->AddChannelsMenuItem(Index, Channel, WithProvider, Current, Selectable); - if (state == vsIdle) - state = vsMenuUpdate; - return true; + return view->SetItemChannel(Channel, Index, Current, Selectable, WithProvider); } bool cSDDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New) { - if (!doOutput) - return true; - if (!rootView->SubViewAvailable()) + if (!view) return false; - if (config.blockFlush) - rootView->LockFlush(); - cDisplayMenuListView *list = rootView->GetListView(); - if (!list) - return false; - - list->AddRecordingMenuItem(Index, Recording, Level, Total, New, Current, Selectable); - if (state == vsIdle) - state = vsMenuUpdate; - return true; -} - -bool cSDDisplayMenu::SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable) { - if (!doOutput) - return true; - if (!rootView->SubViewAvailable()) - return false; - if (config.blockFlush) - rootView->LockFlush(); - cDisplayMenuListView *list = rootView->GetListView(); - if (!list) - return false; - list->AddPluginMenuItem(stringTokens, intTokens, loopTokens, Index, Current, Selectable); - if (state == vsIdle) - state = vsMenuUpdate; - return true; + return view->SetItemRecording(Recording, Index, Current, Selectable, Level, Total, New); } void cSDDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable) { - if (!doOutput) - return; - //esyslog("skindesigner: %s %d - %s", Current ? "----->" : "", Index, Text); - cDisplayMenuListView *list = rootView->GetListView(); - if (!list) { + if (!view) return; - } - if (config.blockFlush) - rootView->LockFlush(); - eMenuCategory cat = MenuCategory(); - if (cat == mcMain && rootView->SubViewAvailable()) { - string plugName = list->AddMainMenuItem(Index, Text, Current, Selectable); - if (Current) { - rootView->SetSelectedPluginMainMenu(plugName); - } - } else if (cat == mcSetup && rootView->SubViewAvailable()) { - list->AddSetupMenuItem(Index, Text, Current, Selectable); - } else if ((cat == mcSchedule || cat == mcScheduleNow || cat == mcScheduleNext) && rootView->SubViewAvailable()) { - list->AddSchedulesMenuItem(Index, NULL, NULL, tmNone, MenuCategory(), false, Current, Selectable, Text ? Text : ""); - } else { - rootView->CorrectDefaultMenu(); - string *tabTexts = new string[MaxTabs]; - for (int i=0; i<MaxTabs; i++) { - const char *s = GetTabbedText(Text, i); - if (s) { - if (strlen(s) == 0) - tabTexts[i] = " "; - else - tabTexts[i] = s; - } else { - tabTexts[i] = ""; - } - } - list->AddDefaultMenuItem(Index, tabTexts, Current, Selectable); - SetEditableWidth( rootView->GetListViewWidth() / 2); - } - if (state == vsIdle) - state = vsMenuUpdate; + view->SetItem(Text, Index, Current, Selectable); + SetEditableWidth(view->GetListWidth() / 2); +} + +bool cSDDisplayMenu::SetItemPlugin(skindesignerapi::cTokenContainer *tk, int Index, bool Current, bool Selectable) { + if (!view) + return false; + bool ok = view->SetItemPlugin(tk, Index, Current, Selectable); + return ok; } void cSDDisplayMenu::SetTabs(int Tab1, int Tab2, int Tab3, int Tab4, int Tab5) { - if (!doOutput) - return; - rootView->SetTabs(Tab1, Tab2, Tab3, Tab4, Tab5); + if (view) + view->SetTabs(Tab1, Tab2, Tab3, Tab4, Tab5); } int cSDDisplayMenu::GetTextAreaWidth(void) const { - int areaWidth = rootView->GetTextAreaWidth(); - return areaWidth; + if (view) + return view->GetTextAreaWidth(); + return 0; } const cFont *cSDDisplayMenu::GetTextAreaFont(bool FixedFont) const { - if (textAreaFont) - return textAreaFont; - textAreaFont = rootView->GetTextAreaFont(); - return textAreaFont; + if (view) + return view->GetTextAreaFont(); + return NULL; } void cSDDisplayMenu::SetScrollbar(int Total, int Offset) { - if (!doOutput) - return; - rootView->RenderMenuScrollBar(Total, Offset); + if (view) + view->SetScrollbar(Total, Offset); } void cSDDisplayMenu::SetEvent(const cEvent *Event) { - if (!doOutput) - return; - rootView->SetDetailedViewEvent(Event); - state = vsMenuDetail; + if (view) + view->SetEvent(Event); } void cSDDisplayMenu::SetRecording(const cRecording *Recording) { - if (!doOutput) - return; - rootView->SetDetailedViewRecording(Recording); - state = vsMenuDetail; + if (view) + view->SetRecording(Recording); } void cSDDisplayMenu::SetText(const char *Text, bool FixedFont) { - if (!doOutput) - return; - rootView->SetDetailedViewText(Text); - state = vsMenuDetail; + if (view) + view->SetText(Text); } -bool cSDDisplayMenu::SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens) { - if (!doOutput) - return true; - bool tmplOk = rootView->SetDetailedViewPlugin(stringTokens, intTokens, loopTokens); - state = vsMenuDetail; - return tmplOk; +bool cSDDisplayMenu::SetPluginText(skindesignerapi::cTokenContainer *tk) { + bool ok = false; + if (view) + ok = view->SetPluginText(tk); + return ok; } void cSDDisplayMenu::Flush(void) { - if (!doOutput) - return; - bool doFlush = false; - if (state == vsInit) { - rootView->Start(); - rootView->RenderMenuItems(); - doFlush = true; - } else if (state == vsMenuInit) { - rootView->Render(); - rootView->RenderMenuItems(); - doFlush = true; - } else if (state == vsMenuUpdate) { - rootView->RenderMenuItems(); - doFlush = true; - } else if (state == vsMenuDetail) { - rootView->OpenFlush(); - rootView->Render(); - rootView->DoFlush(); - rootView->RenderDetailView(); - rootView->DoFlush(); - } - - if (rootView->RenderDynamicElements()) { - doFlush = true; - } - - if (doFlush) { - if (config.blockFlush) - rootView->OpenFlush(); - rootView->DoFlush(); - } - state = vsIdle; + if (view) + view->Flush(); } void cSDDisplayMenu::SetCurrentRecording(void) { cControl *control = cControl::Control(); if (!control) { + view->SetCurrentRecording(NULL); return; } const cRecording *recording = control->GetRecording(); if (!recording) { + view->SetCurrentRecording(NULL); return; } - string recFileName = ""; - if (recording->FileName()) { - recFileName = recording->FileName(); - } - rootView->SetCurrentRecording(recFileName); -} + view->SetCurrentRecording(recording->FileName()); +}
\ No newline at end of file diff --git a/displaymenu.h b/displaymenu.h index 6600a9a..4f49d8c 100644 --- a/displaymenu.h +++ b/displaymenu.h @@ -11,31 +11,16 @@ enum eMenuOrientation { #endif #include "libskindesignerapi/skindesignerapi.h" -#include "libtemplate/template.h" -#include "views/displaymenurootview.h" - -enum eViewState { - vsInit, - vsMenuInit, - vsMenuUpdate, - vsMenuDetail, - vsIdle -}; +#include <vdr/skins.h> +#include "coreengine/viewdisplaymenu.h" class cSDDisplayMenu : public skindesignerapi::ISDDisplayMenu { private: - cDisplayMenuRootView *rootView; - eViewState state; - bool doOutput; - string pluginName; - int pluginMenu; - ePluginMenuType pluginMenuType; - mutable cFont *textAreaFont; + cViewMenu *view; + bool ok; void SetCurrentRecording(void); -protected: - int Tab(int n); public: - cSDDisplayMenu(cTemplate *menuTemplate); + cSDDisplayMenu(cViewMenu *menuView); virtual ~cSDDisplayMenu(); virtual void Scroll(bool Up, bool Page); virtual int MaxItems(void); @@ -43,21 +28,21 @@ public: virtual void SetMenuCategory(eMenuCategory MenuCat); virtual void SetMenuSortMode(eMenuSortMode MenuSortMode); virtual eMenuOrientation MenuOrientation(void); - virtual void SetPluginMenu(string name, int menu, int type, bool init); + virtual void SetPluginMenu(int plugId, int menuId, int type, bool init); virtual void SetTitle(const char *Title); virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL); virtual void SetMessage(eMessageType Type, const char *Text); - virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable); virtual bool SetItemEvent(const cEvent *Event, int Index, bool Current, bool Selectable, const cChannel *Channel, bool WithDate, eTimerMatch TimerMatch); virtual bool SetItemTimer(const cTimer *Timer, int Index, bool Current, bool Selectable); virtual bool SetItemChannel(const cChannel *Channel, int Index, bool Current, bool Selectable, bool WithProvider); virtual bool SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New); - virtual bool SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable); + virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable); + virtual bool SetItemPlugin(skindesignerapi::cTokenContainer *tk, int Index, bool Current, bool Selectable); virtual void SetScrollbar(int Total, int Offset); virtual void SetEvent(const cEvent *Event); virtual void SetRecording(const cRecording *Recording); virtual void SetText(const char *Text, bool FixedFont); - virtual bool SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens); + virtual bool SetPluginText(skindesignerapi::cTokenContainer *tk); virtual void Flush(void); virtual void SetTabs(int Tab1, int Tab2 = 0, int Tab3 = 0, int Tab4 = 0, int Tab5 = 0); virtual int GetTextAreaWidth(void) const; diff --git a/displaymessage.c b/displaymessage.c index c125fd3..535f6d5 100644 --- a/displaymessage.c +++ b/displaymessage.c @@ -1,46 +1,25 @@ #include "displaymessage.h" -cSDDisplayMessage::cSDDisplayMessage(cTemplate *messageTemplate) { - messageView = NULL; - doOutput = true; - initial = true; - if (!messageTemplate) { - doOutput = false; - esyslog("skindesigner: displayMessage no valid template - aborting"); - return; - } - messageView = new cDisplayMessageView(messageTemplate->GetRootView()); - if (!messageView->createOsd()) { - doOutput = false; - return; - } - messageView->DrawDebugGrid(); - messageView->DrawBackground(); +cSDDisplayMessage::cSDDisplayMessage(cViewMessage *messageView) { + view = messageView; + ok = view->Init(); + if (!ok) + esyslog("skindesigner: Error initiating displaymessage view - aborting"); } cSDDisplayMessage::~cSDDisplayMessage() { - if (messageView) - delete messageView; + view->Close(); } void cSDDisplayMessage::SetMessage(eMessageType Type, const char *Text) { - if (!doOutput) - return; - messageView->ClearMessage(); - if (!Text) { + if (!ok) return; - } - messageView->DrawMessage(Type, Text); + view->SetMessage(Type, Text); } void cSDDisplayMessage::Flush(void) { - if (!doOutput) + if (!ok) return; - if (initial) { - messageView->DoFadeIn(); - initial = false; - } else { - messageView->Flush(); - } + view->Flush(); } diff --git a/displaymessage.h b/displaymessage.h index f1fd01b..e6e46c6 100644 --- a/displaymessage.h +++ b/displaymessage.h @@ -1,22 +1,18 @@ #ifndef __DISPLAYMESSAGE_H #define __DISPLAYMESSAGE_H -#include <vdr/thread.h> -#include <vdr/skins.h> #include "config.h" -#include "libtemplate/template.h" -#include "views/displaymessageview.h" +#include "coreengine/viewdisplaymessage.h" class cSDDisplayMessage : public cSkinDisplayMessage { private: - cDisplayMessageView *messageView; - bool doOutput; - bool initial; + cViewMessage *view; + bool ok; public: - cSDDisplayMessage(cTemplate *messageTemplate); + cSDDisplayMessage(cViewMessage *messageView); virtual ~cSDDisplayMessage(); virtual void SetMessage(eMessageType Type, const char *Text); virtual void Flush(void); }; -#endif //__DISPLAYMESSAGE_H
\ No newline at end of file +#endif //__DISPLAYMESSAGE_H diff --git a/displayplugin.c b/displayplugin.c deleted file mode 100644 index 35e92e7..0000000 --- a/displayplugin.c +++ /dev/null @@ -1,201 +0,0 @@ -#include "config.h" -#include "displayplugin.h" - -cSkinDisplayPlugin::cSkinDisplayPlugin(cTemplate *pluginTemplate, int subViewID) { - if (!pluginTemplate) { - doOutput = false; - return; - } else { - doOutput = true; - } - initial = true; - if (subViewID > -1) { - cTemplateView *subView = pluginTemplate->GetRootView()->GetSubView((eSubView)subViewID); - if (!subView) { - doOutput = false; - return; - } - pluginView = new cDisplayPluginView(subView, false); - } else { - pluginView = new cDisplayPluginView(pluginTemplate->GetRootView(), true); - } - if (!pluginView->createOsd() && subViewID < 0) { - doOutput = false; - return; - } - pluginView->DrawDebugGrid(); -} - -cSkinDisplayPlugin::~cSkinDisplayPlugin(void) { - if (pluginView) { - delete pluginView; - pluginView = NULL; - } -} - -void cSkinDisplayPlugin::Deactivate(bool hide) { - if (!doOutput) { - return; - } - pluginView->Deactivate(hide); -} - -void cSkinDisplayPlugin::Activate(void) { - if (!doOutput) { - return; - } - pluginView->Activate(); -} - - -void cSkinDisplayPlugin::ClearViewElement(int id) { - if (!doOutput) { - return; - } - pluginView->CleanViewElement(id); -} - -void cSkinDisplayPlugin::DisplayViewElement(int id) { - if (!doOutput) { - return; - } - pluginView->DisplayViewElement(id); -} - -void cSkinDisplayPlugin::SetViewElementIntTokens(map<string,int> *intTokens) { - if (pluginView) - pluginView->SetIntTokens(intTokens); -} - -void cSkinDisplayPlugin::SetViewElementStringTokens(map<string,string> *stringTokens) { - if (pluginView) - pluginView->SetStringTokens(stringTokens); -} - -void cSkinDisplayPlugin::SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens) { - if (pluginView) - pluginView->SetLoopTokens(loopTokens); -} - -void cSkinDisplayPlugin::InitGrids(int viewGridID) { - if (!doOutput) { - return; - } - pluginView->InitGrids(viewGridID); -} - -void cSkinDisplayPlugin::SetGrid(int viewGridID, long gridID, - double x, double y, double width, double height, - map<string,int> *intTokens, map<string,string> *stringTokens) { - if (!doOutput) { - return; - } - pluginView->SetGrid(viewGridID, gridID, x, y, width, height, intTokens, stringTokens); -} - -void cSkinDisplayPlugin::SetGridCurrent(int viewGridID, long gridID, bool current) { - if (!doOutput) { - return; - } - pluginView->SetGridCurrent(viewGridID, gridID, current); -} - -void cSkinDisplayPlugin::DeleteGrid(int viewGridID, long gridID) { - if (!doOutput) { - return; - } - pluginView->DeleteGrid(viewGridID, gridID); -} - -void cSkinDisplayPlugin::DisplayGrids(int viewGridID) { - if (!doOutput) { - return; - } - pluginView->DisplayGrids(viewGridID); -} - -void cSkinDisplayPlugin::ClearGrids(int viewGridID) { - if (!doOutput) { - return; - } - pluginView->ClearGrids(viewGridID); -} - -void cSkinDisplayPlugin::SetTabIntTokens(map<string,int> *intTokens) { - if (!doOutput) { - return; - } - pluginView->SetTabIntTokens(intTokens); -} - -void cSkinDisplayPlugin::SetTabStringTokens(map<string,string> *stringTokens) { - if (!doOutput) { - return; - } - pluginView->SetTabStringTokens(stringTokens); -} - -void cSkinDisplayPlugin::SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens) { - if (!doOutput) { - return; - } - pluginView->SetTabLoopTokens(loopTokens); -} - -void cSkinDisplayPlugin::SetTabs(void) { - if (!doOutput) { - return; - } - pluginView->SetTabs(); -} - -void cSkinDisplayPlugin::TabLeft(void) { - if (!doOutput) { - return; - } - pluginView->TabLeft(); -} - -void cSkinDisplayPlugin::TabRight(void) { - if (!doOutput) { - return; - } - pluginView->TabRight(); -} - -void cSkinDisplayPlugin::TabUp(void) { - if (!doOutput) { - return; - } - pluginView->TabUp(); -} - -void cSkinDisplayPlugin::TabDown(void) { - if (!doOutput) { - return; - } - pluginView->TabDown(); -} - -void cSkinDisplayPlugin::DisplayTabs(void) { - if (!doOutput) { - return; - } - pluginView->DisplayTab(); -} - -void cSkinDisplayPlugin::Flush(void) { - if (initial) { - pluginView->DoStart(); - initial = false; - } - pluginView->Flush(); -} - -bool cSkinDisplayPlugin::ChannelLogoExists(string channelId) { - return imgCache->LogoExists(channelId); -} - -string cSkinDisplayPlugin::GetEpgImagePath(void) { - return *config.epgImagePath; -}
\ No newline at end of file diff --git a/displayplugin.h b/displayplugin.h deleted file mode 100644 index 092c0a9..0000000 --- a/displayplugin.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __DISPLAYPLUGIN_H -#define __DISPLAYPLUGIN_H - -#include "libskindesignerapi/skindesignerapi.h" -#include "libtemplate/template.h" -#include "views/displaypluginview.h" - -class cSkinDisplayPlugin : public skindesignerapi::ISkinDisplayPlugin { -private: - bool doOutput; - bool initial; - cDisplayPluginView *pluginView; -public: - cSkinDisplayPlugin(void) {}; - cSkinDisplayPlugin(cTemplate *pluginTemplate, int subViewID); - virtual ~cSkinDisplayPlugin(void); - virtual void Deactivate(bool hide); - virtual void Activate(void); - virtual void ClearViewElement(int id); - virtual void DisplayViewElement(int id); - virtual void SetViewElementIntTokens(map<string,int> *intTokens); - virtual void SetViewElementStringTokens(map<string,string> *stringTokens); - virtual void SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens); - virtual void InitGrids(int viewGridID); - virtual void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens); - virtual void SetGridCurrent(int viewGridID, long gridID, bool current); - virtual void DeleteGrid(int viewGridID, long gridID); - virtual void DisplayGrids(int viewGridID); - virtual void ClearGrids(int viewGridID); - virtual void SetTabIntTokens(map<string,int> *intTokens); - virtual void SetTabStringTokens(map<string,string> *stringTokens); - virtual void SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens); - virtual void SetTabs(void); - virtual void TabLeft(void); - virtual void TabRight(void); - virtual void TabUp(void); - virtual void TabDown(void); - virtual void DisplayTabs(void); - virtual void Flush(void); - virtual bool ChannelLogoExists(string channelId); - virtual string GetEpgImagePath(void); -}; - -#endif //__DISPLAYPLUGIN_H diff --git a/displayreplay.c b/displayreplay.c index b57a696..02df55a 100644 --- a/displayreplay.c +++ b/displayreplay.c @@ -1,129 +1,84 @@ #define __STL_CONFIG_H -#include <vdr/player.h> #include "displayreplay.h" -cSDDisplayReplay::cSDDisplayReplay(cTemplate *replayTemplate, bool ModeOnly) { - doOutput = true; - initial = true; - initialModeSet = false; - modeOnly = ModeOnly; - replayView = NULL; - if (!replayTemplate) { - doOutput = false; - esyslog("skindesigner: displayReplay no valid template - aborting"); - return; - } - replayView = new cDisplayReplayView(replayTemplate->GetRootView()); - if (!replayView->createOsd()) { - doOutput = false; - return; - } - replayView->DrawDebugGrid(); +cSDDisplayReplay::cSDDisplayReplay(cViewReplay *replayView, bool ModeOnly) { + init = true; + view = replayView; + ok = view->Init(); + if (!ok) + esyslog("skindesigner: Error initiating displayreplay view - aborting"); + view->SetModeOnly(ModeOnly); } cSDDisplayReplay::~cSDDisplayReplay() { - if (replayView) - delete replayView; + view->Close(); } void cSDDisplayReplay::SetRecording(const cRecording *Recording) { - if (!doOutput || !Recording) - return; - if (initial) { - replayView->SetRecordingLength(Recording->LengthInSeconds()); - SetTimeShiftValues(Recording); + if (ok) { + view->SetRecording(Recording); + if (init) { + view->SetRecordingLength(Recording->LengthInSeconds()); + SetTimeShiftValues(Recording); + init = false; + } } - replayView->DrawTitle(Recording); - replayView->DrawRecordingInformation(Recording); - replayView->DrawScraperContent(Recording); } void cSDDisplayReplay::SetTitle(const char *Title) { - if (!doOutput || !Title) - return; - replayView->DrawTitle(Title); + view->SetTitle(Title); } void cSDDisplayReplay::SetMode(bool Play, bool Forward, int Speed) { - if (!doOutput) + if (!ok) return; if (!Play && Speed < 0) { - string recFileName = ""; cControl *control = cControl::Control(); if (control) { const cRecording *recording = control->GetRecording(); - if (recording && recording->FileName()) - recFileName = recording->FileName(); + if (recording && recording->FileName()) { + view->StartOnPause(recording->FileName()); + } } - replayView->DrawOnPause(recFileName, modeOnly); } else { - replayView->ClearOnPause(); + view->ClearOnPause(); } - replayView->DrawControlIcons(Play, Forward, Speed, modeOnly); - initialModeSet = true; + view->SetControlIcons(Play, Forward, Speed); } void cSDDisplayReplay::SetProgress(int Current, int Total) { - if (!doOutput) - return; - replayView->DelayOnPause(); - replayView->DrawProgressBar(Current, Total); - replayView->DrawMarks(marks, Current, Total); - replayView->DrawEndTime(Current, Total); + if (ok) { + view->SetProgressbar(Current, Total); + view->SetMarks(marks, Current, Total); + view->SetEndTime(Current, Total); + } } void cSDDisplayReplay::SetCurrent(const char *Current) { - if (!doOutput) - return; - replayView->DrawCurrent(Current); + if (ok) + view->SetCurrent(Current); } void cSDDisplayReplay::SetTotal(const char *Total) { - if (!doOutput) - return; - replayView->DrawTotal(Total); + if (ok) + view->SetTotal(Total); } void cSDDisplayReplay::SetJump(const char *Jump) { - if (!doOutput) - return; - replayView->DrawJump(Jump); + if (ok) + view->SetJump(Jump); } void cSDDisplayReplay::SetMessage(eMessageType Type, const char *Text) { - if (!doOutput) - return; - replayView->DrawMessage(Type, Text); + if (ok) + view->SetMessage(Type, Text); } void cSDDisplayReplay::Flush(void) { - if (!doOutput) + if (!ok) return; - if (!modeOnly) { - replayView->DrawDate(); - replayView->DrawTime(); - } - if (modeOnly) { - cControl *control = cControl::Control(); - if (control) { - double fps = control->FramesPerSecond(); - int current = 0; - int total = 0; - if (control->GetIndex(current, total)) - replayView->DrawProgressModeOnly(fps, current, total); - } - } - if (initial && initialModeSet) { - replayView->DrawBackground(modeOnly); - replayView->DrawCustomTokens(); - replayView->DoFadeIn(); - initial = false; - } else { - if (replayView->CustomTokenChange()) - replayView->DrawCustomTokens(); - replayView->Flush(); - } + view->Flush(); } void cSDDisplayReplay::SetTimeShiftValues(const cRecording *recording) { @@ -146,5 +101,5 @@ void cSDDisplayReplay::SetTimeShiftValues(const cRecording *recording) { time_t recordingStart = time(0) - recording->LengthInSeconds(); int framesTotal = (liveEventStop - recordingStart)*fps; int recLength = liveEventStop - recordingStart; - replayView->SetTimeShift(framesTotal, recLength); + view->SetTimeShift(framesTotal, recLength); } diff --git a/displayreplay.h b/displayreplay.h index 04840c5..2c4fa77 100644 --- a/displayreplay.h +++ b/displayreplay.h @@ -2,21 +2,17 @@ #define __DISPLAYREPLAY_H #include <vdr/skins.h> -#include <vdr/thread.h> #include "config.h" -#include "libtemplate/template.h" -#include "views/displayreplayview.h" +#include "coreengine/viewdisplayreplay.h" class cSDDisplayReplay : public cSkinDisplayReplay { private: - cDisplayReplayView *replayView; - bool initial; - bool initialModeSet; - bool doOutput; - bool modeOnly; + bool ok; + bool init; + cViewReplay *view; void SetTimeShiftValues(const cRecording *recording); public: - cSDDisplayReplay(cTemplate *replayTemplate, bool ModeOnly); + cSDDisplayReplay(cViewReplay *replayView, bool ModeOnly); virtual ~cSDDisplayReplay(); virtual void SetRecording(const cRecording *Recording); virtual void SetTitle(const char *Title); @@ -29,4 +25,4 @@ public: virtual void Flush(void); }; -#endif //__DISPLAYREPLAY_H
\ No newline at end of file +#endif //__DISPLAYREPLAY_H diff --git a/displaytracks.c b/displaytracks.c index 184163d..a7420f6 100644 --- a/displaytracks.c +++ b/displaytracks.c @@ -1,59 +1,31 @@ #include "displaytracks.h" - -cSDDisplayTracks::cSDDisplayTracks(cTemplate *audiotracksTemplate, const char *Title, int NumTracks, const char * const *Tracks) { - initial = true; - numTracks = NumTracks; - tracksView = NULL; - doOutput = true; - currentTrack = 0; - menuTitle = Title; - if (!audiotracksTemplate) { - esyslog("skindesigner: displayTracks no valid template - aborting"); - doOutput = false; - return; - } - tracksView = new cDisplayAudiotracksView(NumTracks, audiotracksTemplate->GetRootView()); - if (!tracksView->createOsd()) { - doOutput = false; - return; - } - tracksView->DrawDebugGrid(); - tracksView->DrawBackground(); - - cDisplayMenuListView *list = tracksView->GetListView(); - if (list) { - for (int i = 0; i < NumTracks; i++) { - list->AddTracksMenuItem(i, Tracks[i], (i==currentTrack)?true:false, true); - } - } +cSDDisplayTracks::cSDDisplayTracks(cViewTracks *tracksView, const char *Title, int NumTracks, const char * const *Tracks) { + view = tracksView; + ok = view->Init(); + if (!ok) + esyslog("skindesigner: Error initiating displaytracks view - aborting"); + view->SetTitle(Title); + view->SetNumtracks(NumTracks); + view->SetTracks(Tracks); } cSDDisplayTracks::~cSDDisplayTracks() { - if (tracksView) - delete tracksView; + view->Close(); } void cSDDisplayTracks::SetTrack(int Index, const char * const *Tracks) { - cDisplayMenuListView *list = tracksView->GetListView(); - if (list) { - list->AddTracksMenuItem(currentTrack, Tracks[currentTrack], false, true); - list->AddTracksMenuItem(Index, Tracks[Index], true, true); - currentTrack = Index; - } + if (ok) + view->SetCurrentTrack(Index); } void cSDDisplayTracks::SetAudioChannel(int AudioChannel) { - tracksView->DrawHeader(menuTitle, AudioChannel); + if (ok) + view->SetAudiochannel(AudioChannel); } void cSDDisplayTracks::Flush(void) { - if (!doOutput) + if (!ok) return; - if (initial) { - tracksView->DoFadeIn(); - } - initial = false; - tracksView->RenderMenuItems(); - tracksView->Flush(); + view->Flush(); } diff --git a/displaytracks.h b/displaytracks.h index 4dd978c..b4555c5 100644 --- a/displaytracks.h +++ b/displaytracks.h @@ -2,21 +2,15 @@ #define __DISPLAYTRACKS_H #include <vdr/skins.h> -#include <vdr/thread.h> #include "config.h" -#include "libtemplate/template.h" -#include "views/displayaudiotracksview.h" +#include "coreengine/viewdisplaytracks.h" class cSDDisplayTracks : public cSkinDisplayTracks { private: - cDisplayAudiotracksView *tracksView; - bool initial; - int numTracks; - bool doOutput; - int currentTrack; - const char *menuTitle; + cViewTracks *view; + bool ok; public: - cSDDisplayTracks(cTemplate *audiotracksTemplate, const char *Title, int NumTracks, const char * const *Tracks); + cSDDisplayTracks(cViewTracks *tracksView, const char *Title, int NumTracks, const char * const *Tracks); virtual ~cSDDisplayTracks(); virtual void SetTrack(int Index, const char * const *Tracks); virtual void SetAudioChannel(int AudioChannel); @@ -24,4 +18,4 @@ public: }; -#endif //__DISPLAYTRACKS_H
\ No newline at end of file +#endif //__DISPLAYTRACKS_H diff --git a/displayvolume.c b/displayvolume.c index d50e470..02e61d5 100644 --- a/displayvolume.c +++ b/displayvolume.c @@ -1,44 +1,26 @@ #include "displayvolume.h" #include "config.h" -#include "libcore/helpers.h" -cSDDisplayVolume::cSDDisplayVolume(cTemplate *volumeTemplate) { - volumeView = NULL; - doOutput = true; - initial = true; - if (!volumeTemplate) { - doOutput = false; - esyslog("skindesigner: displayVolume no valid template - aborting"); - return; - } - volumeView = new cDisplayVolumeView(volumeTemplate->GetRootView()); - if (!volumeView->createOsd()) { - doOutput = false; - } else { - volumeView->DrawDebugGrid(); - volumeView->DrawBackground(); - } +cSDDisplayVolume::cSDDisplayVolume(cViewVolume *volumeView) { + view = volumeView; + ok = view->Init(); + if (!ok) + esyslog("skindesigner: Error initiating displayvolume view - aborting"); } cSDDisplayVolume::~cSDDisplayVolume() { - if (volumeView) - delete volumeView; + view->Close(); } void cSDDisplayVolume::SetVolume(int Current, int Total, bool Mute) { - if (!doOutput) + if (!ok) return; - volumeView->DrawVolume(Current, Total, Mute); + view->SetVolume(Current, Total, Mute); } void cSDDisplayVolume::Flush(void) { - if (!doOutput) + if (!ok) return; - if (initial) { - volumeView->DoFadeIn(); - initial = false; - } else { - volumeView->Flush(); - } + view->Flush(); } diff --git a/displayvolume.h b/displayvolume.h index 1bfc877..4dde35a 100644 --- a/displayvolume.h +++ b/displayvolume.h @@ -1,21 +1,18 @@ #ifndef __DISPLAYVOLUME_H #define __DISPLAYVOLUME_H -#include <vdr/skins.h> #include "config.h" -#include "libtemplate/template.h" -#include "views/displayvolumeview.h" +#include "coreengine/viewdisplayvolume.h" class cSDDisplayVolume : public cSkinDisplayVolume { private: - cDisplayVolumeView *volumeView; - bool doOutput; - bool initial; + cViewVolume *view; + bool ok; public: - cSDDisplayVolume(cTemplate *volumeTemplate); + cSDDisplayVolume(cViewVolume *volumeView); virtual ~cSDDisplayVolume(); virtual void SetVolume(int Current, int Total, bool Mute); virtual void Flush(void); }; -#endif //__DISPLAYVOLUME_H
\ No newline at end of file +#endif //__DISPLAYVOLUME_H diff --git a/dtd/displaychannel.dtd b/dtd/displaychannel.dtd index 589f372..9fb6ada 100644 --- a/dtd/displaychannel.dtd +++ b/dtd/displaychannel.dtd @@ -26,79 +26,162 @@ <!ELEMENT background (areacontainer|area|areascroll)*>
<!ATTLIST background
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT channelinfo (areacontainer|area|areascroll)*>
<!ATTLIST channelinfo
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT epginfo (areacontainer|area|areascroll)*>
<!ATTLIST epginfo
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT progressbar (areacontainer|area|areascroll)*>
<!ATTLIST progressbar
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT progressbarback (areacontainer|area|areascroll)*>
<!ATTLIST progressbarback
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT statusinfo (areacontainer|area|areascroll)*>
<!ATTLIST statusinfo
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT audioinfo (areacontainer|area|areascroll)*>
<!ATTLIST audioinfo
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT ecminfo (areacontainer|area|areascroll)*>
<!ATTLIST ecminfo
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT screenresolution (areacontainer|area|areascroll)*>
<!ATTLIST screenresolution
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT channelgroup (areacontainer|area|areascroll)*>
<!ATTLIST channelgroup
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT signalquality (areacontainer|area|areascroll)*>
<!ATTLIST signalquality
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT signalqualityback (areacontainer|area|areascroll)*>
<!ATTLIST signalqualityback
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT devices (areacontainer|area|areascroll)*>
<!ATTLIST devices
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -113,7 +196,6 @@ <!ELEMENT currentweather (areacontainer|area|areascroll)*>
<!ATTLIST currentweather
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -127,7 +209,6 @@ <!ELEMENT scrapercontent (areacontainer|area|areascroll)*>
<!ATTLIST scrapercontent
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -141,7 +222,6 @@ <!ELEMENT datetime (areacontainer|area|areascroll)*>
<!ATTLIST datetime
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -155,7 +235,6 @@ <!ELEMENT time (areacontainer|area|areascroll)*>
<!ATTLIST time
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -175,8 +254,6 @@ <!ELEMENT customtokens (areacontainer|area|areascroll)*>
<!ATTLIST customtokens
- detached CDATA #IMPLIED
- delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shiftmode CDATA #IMPLIED
diff --git a/dtd/displaymenu.dtd b/dtd/displaymenu.dtd index ecbc374..d2afb04 100644 --- a/dtd/displaymenu.dtd +++ b/dtd/displaymenu.dtd @@ -2,7 +2,7 @@ <!ENTITY % functions SYSTEM "functions.dtd">
-<!ELEMENT displaymenu (background,header,datetime,time*,message,sortmode*,colorbuttons,
+<!ELEMENT displaymenu (background,header,datetime,time*,message,sortmode*,colorbuttons,scrollbar*,
menudefault,menumain*,menusetup*,menuschedules*,
menutimers*,menuchannels*,menurecordings*,
menudetailedepg,menudetailedrecording,
@@ -13,18 +13,31 @@ width CDATA #REQUIRED
height CDATA #REQUIRED
fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debuggrid CDATA #IMPLIED
>
<!ELEMENT background (areacontainer|area|areascroll)*>
<!ATTLIST background
+ orientation CDATA #IMPLIED
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT header (areacontainer|area|areascroll)*>
<!ATTLIST header
- detached CDATA #IMPLIED
+ orientation CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -38,7 +51,7 @@ <!ELEMENT datetime (areacontainer|area|areascroll)*>
<!ATTLIST datetime
- detached CDATA #IMPLIED
+ orientation CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -52,7 +65,7 @@ <!ELEMENT time (areacontainer|area|areascroll)*>
<!ATTLIST time
- detached CDATA #IMPLIED
+ orientation CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -66,7 +79,7 @@ <!ELEMENT message (areacontainer|area|areascroll)*>
<!ATTLIST message
- detached CDATA #IMPLIED
+ orientation CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -80,20 +93,36 @@ <!ELEMENT sortmode (areacontainer|area|areascroll)*>
<!ATTLIST sortmode
+ orientation CDATA #IMPLIED
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT colorbuttons (areacontainer|area|areascroll)*>
<!ATTLIST colorbuttons
+ orientation CDATA #IMPLIED
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT timers (areacontainer|area|areascroll)*>
<!ATTLIST timers
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -106,8 +135,8 @@ <!ELEMENT discusage (areacontainer|area|areascroll)*>
<!ATTLIST discusage
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -120,8 +149,8 @@ <!ELEMENT devices (areacontainer|area|areascroll)*>
<!ATTLIST devices
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -135,8 +164,8 @@ <!ELEMENT systemload (areacontainer|area|areascroll)*>
<!ATTLIST systemload
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -149,8 +178,8 @@ <!ELEMENT systemmemory (areacontainer|area|areascroll)*>
<!ATTLIST systemmemory
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -163,8 +192,8 @@ <!ELEMENT temperatures (areacontainer|area|areascroll)*>
<!ATTLIST temperatures
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -177,8 +206,8 @@ <!ELEMENT vdrstatistics (areacontainer|area|areascroll)*>
<!ATTLIST vdrstatistics
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -191,8 +220,8 @@ <!ELEMENT currentschedule (areacontainer|area|areascroll)*>
<!ATTLIST currentschedule
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -205,8 +234,8 @@ <!ELEMENT currentweather (areacontainer|area|areascroll)*>
<!ATTLIST currentweather
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -219,8 +248,8 @@ <!ELEMENT lastrecordings (areacontainer|area|areascroll)*>
<!ATTLIST lastrecordings
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -233,8 +262,8 @@ <!ELEMENT customtokens (areacontainer|area|areascroll)*>
<!ATTLIST customtokens
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
shifttype CDATA #IMPLIED
@@ -247,6 +276,14 @@ <!ELEMENT scrollbar (areacontainer|area|areascroll)*>
<!ATTLIST scrollbar
+ delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
@@ -269,6 +306,7 @@ y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
scaletvx CDATA #IMPLIED
scaletvy CDATA #IMPLIED
@@ -285,6 +323,7 @@ y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
scaletvx CDATA #IMPLIED
scaletvy CDATA #IMPLIED
@@ -299,6 +338,7 @@ y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
scaletvx CDATA #IMPLIED
scaletvy CDATA #IMPLIED
@@ -313,6 +353,7 @@ y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
scaletvx CDATA #IMPLIED
scaletvy CDATA #IMPLIED
@@ -327,6 +368,7 @@ y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
scaletvx CDATA #IMPLIED
scaletvy CDATA #IMPLIED
@@ -341,6 +383,7 @@ y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
scaletvx CDATA #IMPLIED
scaletvy CDATA #IMPLIED
@@ -355,6 +398,7 @@ y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
scaletvx CDATA #IMPLIED
scaletvy CDATA #IMPLIED
@@ -429,10 +473,16 @@ <!ELEMENT currentelement (areacontainer|area|areascroll)*>
<!ATTLIST currentelement
- delay CDATA #REQUIRED
+ delay CDATA #IMPLIED
+ orientation CDATA #IMPLIED
fadetime CDATA #IMPLIED
- condition CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT tab (loop|fill|drawtext|drawtextbox|drawimage|drawrectangle|drawellipse)*>
diff --git a/dtd/displaymenuplugin.dtd b/dtd/displaymenuplugin.dtd index 168d047..845f90d 100644 --- a/dtd/displaymenuplugin.dtd +++ b/dtd/displaymenuplugin.dtd @@ -13,49 +13,87 @@ scaletvy CDATA #IMPLIED
scaletvwidth CDATA #IMPLIED
scaletvheight CDATA #IMPLIED
+ orientation CDATA #IMPLIED
debuggrid CDATA #IMPLIED
>
<!ELEMENT background (areacontainer|area|areascroll)*>
<!ATTLIST background
- condition CDATA #IMPLIED
+ orientation CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT header (areacontainer|area|areascroll)*>
<!ATTLIST header
- condition CDATA #IMPLIED
+ orientation CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT datetime (areacontainer|area|areascroll)*>
<!ATTLIST datetime
- condition CDATA #IMPLIED
+ orientation CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT message (areacontainer|area|areascroll)*>
<!ATTLIST message
- condition CDATA #IMPLIED
+ orientation CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT colorbuttons (areacontainer|area|areascroll)*>
<!ATTLIST colorbuttons
- condition CDATA #IMPLIED
+ orientation CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT scrollbar (areacontainer|area|areascroll)*>
<!ATTLIST scrollbar
- condition CDATA #IMPLIED
+ orientation CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT detailheader (areacontainer|area|areascroll)*>
<!ATTLIST detailheader
- condition CDATA #IMPLIED
+ orientation CDATA #IMPLIED
debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
>
<!ELEMENT tablabels (areacontainer|area|areascroll)*>
@@ -85,7 +123,7 @@ <!ELEMENT currentelement (areacontainer|area|areascroll)*>
<!ATTLIST currentelement
condition CDATA #IMPLIED
- delay CDATA #REQUIRED
+ delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
debug CDATA #IMPLIED
>
diff --git a/dtd/displayreplay.dtd b/dtd/displayreplay.dtd index f15fb74..91c23cc 100644 --- a/dtd/displayreplay.dtd +++ b/dtd/displayreplay.dtd @@ -27,29 +27,56 @@ <!ELEMENT background (areacontainer|area|areascroll)*>
<!ATTLIST background
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
>
<!ELEMENT backgroundmodeonly (areacontainer|area|areascroll)*>
<!ATTLIST backgroundmodeonly
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
>
<!ELEMENT datetime (areacontainer|area|areascroll)*>
<!ATTLIST datetime
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT time (areacontainer|area|areascroll)*>
<!ATTLIST time
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT scrapercontent (areacontainer|area|areascroll)*>
<!ATTLIST scrapercontent
- detached CDATA #IMPLIED
delay CDATA #IMPLIED
fadetime CDATA #IMPLIED
shifttime CDATA #IMPLIED
@@ -63,66 +90,143 @@ <!ELEMENT rectitle (areacontainer|area|areascroll)*>
<!ATTLIST rectitle
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT recinfo (areacontainer|area|areascroll)*>
<!ATTLIST recinfo
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT currenttime (areacontainer|area|areascroll)*>
<!ATTLIST currenttime
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT totaltime (areacontainer|area|areascroll)*>
<!ATTLIST totaltime
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT endtime (areacontainer|area|areascroll)*>
<!ATTLIST endtime
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT progressbar (areacontainer|area|areascroll)*>
<!ATTLIST progressbar
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT cutmarks (areacontainer|area|areascroll)*>
<!ATTLIST cutmarks
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT controlicons (areacontainer|area|areascroll)*>
<!ATTLIST controlicons
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT controliconsmodeonly (areacontainer|area|areascroll)*>
<!ATTLIST controliconsmodeonly
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT progressmodeonly (areacontainer|area|areascroll)*>
<!ATTLIST progressmodeonly
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT jump (areacontainer|area|areascroll)*>
<!ATTLIST jump
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
@@ -138,6 +242,11 @@ debug CDATA #IMPLIED
delay CDATA #REQUIRED
fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
condition CDATA #IMPLIED
>
@@ -146,11 +255,23 @@ debug CDATA #IMPLIED
delay CDATA #REQUIRED
fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
condition CDATA #IMPLIED
>
<!ELEMENT customtokens (areacontainer|area|areascroll)*>
<!ATTLIST customtokens
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
debug CDATA #IMPLIED
condition CDATA #IMPLIED
>
diff --git a/dtd/functions.dtd b/dtd/functions.dtd index 7b08437..b7b4e0a 100644 --- a/dtd/functions.dtd +++ b/dtd/functions.dtd @@ -90,8 +90,8 @@ <!ELEMENT drawtextbox EMPTY> <!ATTLIST drawtextbox - x CDATA #REQUIRED - y CDATA #REQUIRED + x CDATA #IMPLIED + y CDATA #IMPLIED width CDATA #REQUIRED height CDATA #IMPLIED align (left|center|right) #IMPLIED @@ -130,8 +130,8 @@ <!ELEMENT drawrectangle EMPTY> <!ATTLIST drawrectangle - x CDATA #REQUIRED - y CDATA #REQUIRED + x CDATA #IMPLIED + y CDATA #IMPLIED width CDATA #IMPLIED height CDATA #IMPLIED align (left|center|right) #IMPLIED diff --git a/libcore/cairoimage.c b/extensions/cairoimage.c index 4b2bcab..0fc6879 100644 --- a/libcore/cairoimage.c +++ b/extensions/cairoimage.c @@ -1,5 +1,4 @@ #include "cairoimage.h" -#include "../libtemplate/templatefunction.h" cCairoImage::cCairoImage(void) { surface = NULL; @@ -35,7 +34,7 @@ void cCairoImage::DrawTextVertical(string text, tColor color, string font, int s int x = size; int y = imgHeight; double rotate = 3*M_PI/2; - if (direction == diTopDown) { + if (direction == (int)eDirection::topdown) { rotate = M_PI/2; x = size*0.3; y = 0; diff --git a/libcore/cairoimage.h b/extensions/cairoimage.h index 27fb6f3..4d4788d 100644 --- a/libcore/cairoimage.h +++ b/extensions/cairoimage.h @@ -5,6 +5,7 @@ #include <vdr/osd.h> #include <string> #include <sstream> +#include "../coreengine/definitions.h" using namespace std; diff --git a/libcore/curlfuncs.c b/extensions/curlfuncs.c index c6dfee5..c6dfee5 100644 --- a/libcore/curlfuncs.c +++ b/extensions/curlfuncs.c diff --git a/libcore/curlfuncs.h b/extensions/curlfuncs.h index e0f76cf..e0f76cf 100644 --- a/libcore/curlfuncs.h +++ b/extensions/curlfuncs.h diff --git a/libcore/extrecinfo.c b/extensions/extrecinfo.c index 435d43b..435d43b 100644 --- a/libcore/extrecinfo.c +++ b/extensions/extrecinfo.c diff --git a/libcore/extrecinfo.h b/extensions/extrecinfo.h index 9fb5bab..9fb5bab 100644 --- a/libcore/extrecinfo.h +++ b/extensions/extrecinfo.h diff --git a/libcore/fontmanager.c b/extensions/fontmanager.c index 2f1e79c..47e2885 100644 --- a/libcore/fontmanager.c +++ b/extensions/fontmanager.c @@ -7,38 +7,13 @@ using namespace std; cMutex cFontManager::mutex; -cFontManager::cFontManager() { +cFontManager::cFontManager(void) { } -cFontManager::~cFontManager() { +cFontManager::~cFontManager(void) { DeleteFonts(); } -void cFontManager::CacheFonts(cTemplate *tpl) { - cMutexLock MutexLock(&mutex); - - vector< pair<string, int> > usedFonts = tpl->GetUsedFonts(); - - cStringList availableFonts; - cFont::GetAvailableFontNames(&availableFonts); - - for (vector< pair<string, int> >::iterator ft = usedFonts.begin(); ft != usedFonts.end(); ft++) { - string fontName = ft->first; - int fontSize = ft->second; - if (fontSize < 1) { - continue; - } - - int fontAvailable = availableFonts.Find(fontName.c_str()); - if (fontAvailable == -1) { - esyslog("skindesigner: font %s not available, skipping", fontName.c_str()); - continue; - } - - InsertFont(fontName, fontSize); - } -} - void cFontManager::Debug(void) { dsyslog("skindesigner: fontmanager fonts available:"); for (map < string, map< int, cFont* > >::iterator fts = fonts.begin(); fts != fonts.end(); fts++) { diff --git a/libcore/fontmanager.h b/extensions/fontmanager.h index 1dbdcde..c71d465 100644 --- a/libcore/fontmanager.h +++ b/extensions/fontmanager.h @@ -6,8 +6,6 @@ #include <vector> #include <vdr/skins.h> -#include "../libtemplate/template.h" - using namespace std; class cFontManager { @@ -20,11 +18,10 @@ private: cFont *GetFont(string name, int size); int GetFontHeight(const char *name, int height, int charWidth = 0); public: - cFontManager(); - ~cFontManager(); + cFontManager(void); + ~cFontManager(void); void Lock(void) { mutex.Lock(); }; void Unlock(void) { mutex.Unlock(); }; - void CacheFonts(cTemplate *tpl); void DeleteFonts(void); int Width(string fontName, int fontSize, const char *text); int Height(string fontName, int fontSize); diff --git a/libcore/helpers.c b/extensions/helpers.c index e195c37..00c13d2 100644 --- a/libcore/helpers.c +++ b/extensions/helpers.c @@ -51,35 +51,6 @@ int Minimum(int a, int b, int c, int d, int e, int f) { return min; } -string CutText(string &text, int width, string fontName, int fontSize) { - if (width <= fontManager->Font(fontName, fontSize)->Size()) - return text.c_str(); - fontManager->Lock(); - cTextWrapper twText; - twText.Set(text.c_str(), fontManager->Font(fontName, fontSize), width); - fontManager->Unlock(); - string cuttedTextNative = twText.GetLine(0); - stringstream sstrText; - sstrText << cuttedTextNative << "..."; - string cuttedText = sstrText.str(); - int actWidth = fontManager->Width(fontName, fontSize, cuttedText.c_str()); - if (actWidth > width) { - int overlap = actWidth - width; - int charWidth = fontManager->Width(fontName, fontSize, "."); - if (charWidth == 0) - charWidth = 1; - int cutChars = overlap / charWidth; - if (cutChars > 0) { - cuttedTextNative = cuttedTextNative.substr(0, cuttedTextNative.length() - cutChars); - stringstream sstrText2; - sstrText2 << cuttedTextNative << "..."; - cuttedText = sstrText2.str(); - } - } - return cuttedText; -} - - string StrToLowerCase(string str) { string lowerCase = str; const int length = lowerCase.length(); @@ -107,7 +78,7 @@ bool FileExists(const string &fullpath) { return true; } if (config.debugImageLoading) { - dsyslog("skindesigner: did not found %s", fullpath.c_str()); + dsyslog("skindesigner: did not find %s", fullpath.c_str()); } return false; } @@ -120,7 +91,7 @@ bool FileExists(const string &path, const string &name, const string &ext) { return true; } if (config.debugImageLoading) { - dsyslog("skindesigner: did not found %s", fileName.str().c_str()); + dsyslog("skindesigner: did not find %s", fileName.str().c_str()); } return false; } diff --git a/libcore/helpers.h b/extensions/helpers.h index 74ed7d3..b059a16 100644 --- a/libcore/helpers.h +++ b/extensions/helpers.h @@ -1,6 +1,8 @@ #ifndef __HELPERS_H #define __HELPERS_H +#include <string> +#include <algorithm> #include <vdr/osd.h> #include <vdr/plugin.h> #include "../config.h" @@ -9,7 +11,6 @@ cPlugin *GetScraperPlugin(void); cSize ScaleToFit(int widthMax, int heightMax, int widthOriginal, int heightOriginal); int Minimum(int a, int b, int c, int d, int e, int f); -std::string CutText(string &text, int width, string fontName, int fontSize); std::string StrToLowerCase(string str); bool isNumber(const string& s); bool IsToken(const string& token); diff --git a/libcore/imagecache.c b/extensions/imagecache.c index fe07e98..d8c89c8 100644 --- a/libcore/imagecache.c +++ b/extensions/imagecache.c @@ -58,7 +58,10 @@ void cImageCache::CacheLogo(int width, int height) { return; int logosCached = 0; - + + if (config.numLogosMax && config.numLogosMax < (int)channelLogoCache.size()) + return; + for (const cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { if (logosCached >= config.numLogosPerSizeInitial) break; @@ -77,6 +80,8 @@ void cImageCache::CacheLogo(int width, int height) { cImage *image = CreateImage(width, height); channelLogoCache.insert(pair<string, cImage*>(logoName.str(), image)); } + if (config.numLogosMax && config.numLogosMax < (int)channelLogoCache.size()) + return; } } @@ -172,24 +177,34 @@ void cImageCache::CacheIcon(eImageType type, string name, int width, int height) GetIcon(type, name, width, height); } -cImage *cImageCache::GetIcon(eImageType type, string name, int width, int height) { +cCachedImage *cImageCache::GetIcon(eImageType type, string name, int width, int height) { if (width < 1 || width > 1920 || height < 1 || height > 1080) return NULL; cMutexLock MutexLock(&mutex); stringstream iconName; iconName << name << "_" << width << "x" << height; - map<string, cImage*>::iterator hit = iconCache.find(iconName.str()); + map<string, cCachedImage*>::iterator hit = iconCache.find(iconName.str()); if (hit != iconCache.end()) { - return (cImage*)hit->second; + return (cCachedImage*)hit->second; } else { bool success = LoadIcon(type, name); if (!success) return NULL; cImage *image = CreateImage(width, height, true); - iconCache.insert(pair<string, cImage*>(iconName.str(), image)); + cCachedImage *cachedImg = new cCachedImage(); + cachedImg->size = image->Width() * image->Height() * sizeof(tColor); + int handle = cOsdProvider::StoreImage(*image); + if (handle) { + cachedImg->handle = handle; + delete image; + } else { + cachedImg->image = image; + } + + iconCache.insert(pair<string, cCachedImage*>(iconName.str(), cachedImg)); hit = iconCache.find(iconName.str()); if (hit != iconCache.end()) { - return (cImage*)hit->second; + return (cCachedImage*)hit->second; } } return NULL; @@ -321,24 +336,33 @@ void cImageCache::CacheSkinpart(string name, int width, int height) { GetSkinpart(name, width, height); } -cImage *cImageCache::GetSkinpart(string name, int width, int height) { +cCachedImage *cImageCache::GetSkinpart(string name, int width, int height) { if (width < 1 || width > 1920 || height < 1 || height > 1080) return NULL; cMutexLock MutexLock(&mutex); stringstream iconName; iconName << name << "_" << width << "x" << height; - map<string, cImage*>::iterator hit = skinPartsCache.find(iconName.str()); + map<string, cCachedImage*>::iterator hit = skinPartsCache.find(iconName.str()); if (hit != skinPartsCache.end()) { - return (cImage*)hit->second; + return (cCachedImage*)hit->second; } else { bool success = LoadSkinpart(name); if (!success) return NULL; cImage *image = CreateImage(width, height, false); - skinPartsCache.insert(pair<string, cImage*>(iconName.str(), image)); + cCachedImage *cachedImg = new cCachedImage(); + cachedImg->size = image->Width() * image->Height() * sizeof(tColor); + int handle = cOsdProvider::StoreImage(*image); + if (handle) { + cachedImg->handle = handle; + delete image; + } else { + cachedImg->image = image; + } + skinPartsCache.insert(pair<string, cCachedImage*>(iconName.str(), cachedImg)); hit = skinPartsCache.find(iconName.str()); if (hit != skinPartsCache.end()) { - return (cImage*)hit->second; + return (cCachedImage*)hit->second; } } return NULL; @@ -368,9 +392,9 @@ cImage *cImageCache::GetVerticalText(string text, tColor color, string font, int bool cImageCache::LoadIcon(eImageType type, string name) { cString subdir(""); - if (type == itMenuIcon) + if (type == eImageType::menuicon) subdir = "menuicons"; - else if (type == itIcon) + else if (type == eImageType::icon) subdir = "icons"; //first check in theme specific icon path @@ -452,8 +476,8 @@ bool cImageCache::LoadSkinpart(string name) { } void cImageCache::Clear(void) { - for(map<string, cImage*>::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) { - cImage *img = (cImage*)it->second; + for(map<string, cCachedImage*>::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) { + cCachedImage *img = (cCachedImage*)it->second; delete img; } iconCache.clear(); @@ -464,8 +488,8 @@ void cImageCache::Clear(void) { } channelLogoCache.clear(); - for(map<string, cImage*>::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) { - cImage *img = (cImage*)it->second; + for(map<string, cCachedImage*>::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) { + cCachedImage *img = (cCachedImage*)it->second; delete img; } skinPartsCache.clear(); @@ -478,60 +502,78 @@ void cImageCache::Clear(void) { } void cImageCache::Debug(bool full) { - int sizeIconCache = 0; + float sizeIconCacheInternal = 0; + float sizeIconCacheExternal = 0; int numIcons = 0; - GetIconCacheSize(numIcons, sizeIconCache); - dsyslog("skindesigner: cached %d icons - size %d byte", numIcons, sizeIconCache); + GetIconCacheSize(numIcons, sizeIconCacheInternal, sizeIconCacheExternal); + dsyslog("skindesigner: cached %d icons - size internal mem %.2fMB, high level mem %.2fMB", numIcons, sizeIconCacheInternal, sizeIconCacheExternal); if (full) { - for(std::map<std::string, cImage*>::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) { + for(std::map<std::string, cCachedImage*>::const_iterator it = iconCache.begin(); it != iconCache.end(); it++) { string name = it->first; - dsyslog("skindesigner: cached icon %s", name.c_str()); + cCachedImage *img = (cCachedImage*)it->second; + dsyslog("skindesigner: cached icon %s, handle %d", name.c_str(), img->handle); } } - int sizeLogoCache = 0; + float sizeLogoCache = 0; int numLogos = 0; GetLogoCacheSize(numLogos, sizeLogoCache); - dsyslog("skindesigner: cached %d logos - size %d byte", numLogos, sizeLogoCache); + dsyslog("skindesigner: cached %d logos - size %.2fMB internal mem", numLogos, sizeLogoCache); if (full) { for(std::map<std::string, cImage*>::const_iterator it = channelLogoCache.begin(); it != channelLogoCache.end(); it++) { string name = it->first; dsyslog("skindesigner: cached logo %s", name.c_str()); } } - - int sizeSkinpartCache = 0; + float sizeSkinpartCacheInternal = 0; + float sizeSkinpartCacheExternal = 0; int numSkinparts = 0; - GetSkinpartsCacheSize(numSkinparts, sizeSkinpartCache); - dsyslog("skindesigner: cached %d skinparts - size %d byte", numSkinparts, sizeSkinpartCache); + GetSkinpartsCacheSize(numSkinparts, sizeSkinpartCacheInternal, sizeSkinpartCacheExternal); + dsyslog("skindesigner: cached %d skinparts - size internal mem %.2fMB, high level mem %.2fMB", numSkinparts, sizeSkinpartCacheInternal, sizeSkinpartCacheExternal); if (full) { - for(std::map<std::string, cImage*>::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) { + for(std::map<std::string, cCachedImage*>::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) { string name = it->first; dsyslog("skindesigner: cached skinpart %s", name.c_str()); } } } -void cImageCache::GetIconCacheSize(int &num, int &size) { +void cImageCache::GetIconCacheSize(int &num, float &sizeInternal, float &sizeExternal) { num = iconCache.size(); - for (map<string, cImage*>::iterator icon = iconCache.begin(); icon != iconCache.end(); icon++) { - cImage* img = icon->second; - size += img->Width() * img->Height() * sizeof(tColor); + int sizeByteInternal = 0; + int sizeByteExternal = 0; + for (map<string, cCachedImage*>::iterator icon = iconCache.begin(); icon != iconCache.end(); icon++) { + cCachedImage* img = icon->second; + if (img->image) + sizeByteInternal += img->size; + else + sizeByteExternal += img->size; } + sizeInternal = sizeByteInternal / 1024.0f / 1024.0f; + sizeExternal = sizeByteExternal / 1024.0f / 1024.0f; } -void cImageCache::GetLogoCacheSize(int &num, int &size) { +void cImageCache::GetLogoCacheSize(int &num, float &size) { num = channelLogoCache.size(); + int sizeByte = 0; for (map<string, cImage*>::iterator logo = channelLogoCache.begin(); logo != channelLogoCache.end(); logo++) { cImage* img = logo->second; - size += img->Width() * img->Height() * sizeof(tColor); + sizeByte += img->Width() * img->Height() * sizeof(tColor); } + size = sizeByte / 1024.0f; } -void cImageCache::GetSkinpartsCacheSize(int &num, int &size) { +void cImageCache::GetSkinpartsCacheSize(int &num, float &sizeInternal, float &sizeExternal) { num = skinPartsCache.size(); - for (map<string, cImage*>::iterator skinpart = skinPartsCache.begin(); skinpart != skinPartsCache.end(); skinpart++) { - cImage* img = skinpart->second; - size += img->Width() * img->Height() * sizeof(tColor); - } + int sizeByteInternal = 0; + int sizeByteExternal = 0; + for (map<string, cCachedImage*>::iterator skinpart = skinPartsCache.begin(); skinpart != skinPartsCache.end(); skinpart++) { + cCachedImage* img = skinpart->second; + if (img->image) + sizeByteInternal += img->size; + else + sizeByteExternal += img->size; + } + sizeInternal = sizeByteInternal / 1024.0f / 1024.0f; + sizeExternal = sizeByteExternal / 1024.0f / 1024.0f; } diff --git a/libcore/imagecache.h b/extensions/imagecache.h index e11f295..13f882b 100644 --- a/libcore/imagecache.h +++ b/extensions/imagecache.h @@ -7,7 +7,25 @@ #include <vdr/skins.h> #include <vector> #include "imageloader.h" -#include "../libtemplate/templatefunction.h" +#include "../coreengine/definitions.h" + +class cCachedImage { +public: + int handle; + cImage *image; + int size; + cCachedImage(void) { + handle = 0; + image = NULL; + size = 0; + }; + ~cCachedImage(void) { + if (handle) + cOsdProvider::DropImage(handle); + if (image) + delete image; + }; +}; class cImageCache : public cImageLoader { public: @@ -24,20 +42,20 @@ public: bool SeparatorLogoExists(string name); //icons void CacheIcon(eImageType type, string path, int width, int height); - cImage *GetIcon(eImageType type, string name, int width, int height); + cCachedImage *GetIcon(eImageType type, string name, int width, int height); string GetIconName(string label, eMenuCategory cat = mcUndefined, string plugName = ""); bool MenuIconExists(string name); //skinparts void CacheSkinpart(string path, int width, int height); - cImage *GetSkinpart(string name, int width, int height); + cCachedImage *GetSkinpart(string name, int width, int height); //cairo special images cImage *GetVerticalText(string text, tColor color, string font, int size, int direction); //helpers void Clear(void); void Debug(bool full); - void GetIconCacheSize(int &num, int &size); - void GetLogoCacheSize(int &num, int &size); - void GetSkinpartsCacheSize(int &num, int &size); + void GetIconCacheSize(int &num, float &sizeInternal, float &sizeExternal); + void GetLogoCacheSize(int &num, float &size); + void GetSkinpartsCacheSize(int &num, float &sizeInternal, float &sizeExternal); private: static cMutex mutex; static string items[16]; @@ -48,9 +66,9 @@ private: string iconPathTheme; string skinPartsPathTheme; string svgTemplatePath; - map<string, cImage*> iconCache; + map<string, cCachedImage*> iconCache; map<string, cImage*> channelLogoCache; - map<string, cImage*> skinPartsCache; + map<string, cCachedImage*> skinPartsCache; map<string, cImage*> cairoImageCache; bool LoadIcon(eImageType type, string name); bool LoadLogo(const cChannel *channel); diff --git a/libcore/imageloader.c b/extensions/imageloader.c index 62d284f..62d284f 100644 --- a/libcore/imageloader.c +++ b/extensions/imageloader.c diff --git a/libcore/imageloader.h b/extensions/imageloader.h index 12bd8d2..12bd8d2 100644 --- a/libcore/imageloader.h +++ b/extensions/imageloader.h diff --git a/libcore/libxmlwrapper.c b/extensions/libxmlwrapper.c index 0a93dfd..117815e 100644 --- a/libcore/libxmlwrapper.c +++ b/extensions/libxmlwrapper.c @@ -1,4 +1,4 @@ -#include "../libcore/helpers.h"
+#include "helpers.h"
#include "libxmlwrapper.h"
void SkinDesignerXMLErrorHandler (void * userData, xmlErrorPtr error) {
diff --git a/libcore/libxmlwrapper.h b/extensions/libxmlwrapper.h index 0ace267..3971bb9 100644 --- a/libcore/libxmlwrapper.h +++ b/extensions/libxmlwrapper.h @@ -5,6 +5,7 @@ #include <vector>
#include <map>
#include <set>
+#include <utility>
#include <stack>
#include <libxml/parser.h>
#include <libxml/tree.h>
@@ -12,8 +13,8 @@ #include <vdr/plugin.h>
using namespace std;
-
-#include "../views/viewhelpers.h"
+typedef pair<string,string> stringpair;
+typedef map<string,string> stringmap;
class cLibXMLWrapper {
private:
diff --git a/extensions/pluginmanager.c b/extensions/pluginmanager.c new file mode 100644 index 0000000..2f839f8 --- /dev/null +++ b/extensions/pluginmanager.c @@ -0,0 +1,301 @@ +#include "pluginmanager.h"
+
+cSDPluginManager::cSDPluginManager(void) {
+ lastId = 0;
+ subviewsfound = false;
+}
+
+cSDPluginManager::~cSDPluginManager(void) {
+}
+
+void cSDPluginManager::Reset(void) {
+ subViewMapping.clear();
+}
+
+void cSDPluginManager::RegisterBasicPlugin(skindesignerapi::cPluginStructure *plugStructure) {
+ dsyslog("skindesigner: plugin %s uses libskindesigner API Version %s",
+ plugStructure->name.c_str(),
+ plugStructure->libskindesignerAPIVersion.c_str());
+ plugStructure->id = lastId;
+ registeredPlugins.insert(pair<int,string>(lastId, plugStructure->name));
+ lastId++;
+ map< int, skindesignerapi::sPlugMenu > menusNew;
+ for (map< int, skindesignerapi::sPlugMenu >::iterator it = plugStructure->menus.begin(); it != plugStructure->menus.end(); it++) {
+ int key = it->first;
+ skindesignerapi::sPlugMenu menu = it->second;
+ skindesignerapi::sPlugMenu menuNew;
+ menuNew.type = menu.type;
+ menuNew.tplname = menu.tplname;
+ menuNew.tokenContainer = new skindesignerapi::cTokenContainer(*menu.tokenContainer);
+ menusNew.insert(pair<int, skindesignerapi::sPlugMenu>(key, menuNew));
+ }
+ pluginMenus.insert(pair< int, map < int, skindesignerapi::sPlugMenu > >(plugStructure->id, menusNew));
+
+ if (plugStructure->menus.size() > 0)
+ dsyslog("skindesigner: plugin %s has registered %ld menus", plugStructure->name.c_str(), plugStructure->menus.size());
+
+}
+
+int cSDPluginManager::GetNumPluginMenus(void) {
+ int numMenusTotal = 0;
+ for (map < int, map < int, skindesignerapi::sPlugMenu > >::iterator it = pluginMenus.begin(); it != pluginMenus.end(); it++) {
+ numMenusTotal += (it->second).size();
+ }
+ return numMenusTotal;
+}
+
+void cSDPluginManager::InitPluginMenuIterator(void) {
+ plugMenuIt = pluginMenus.begin();
+}
+
+map <int,skindesignerapi::sPlugMenu> *cSDPluginManager::GetPluginMenus(string &name, int &id) {
+ if (plugMenuIt == pluginMenus.end())
+ return NULL;
+ id = plugMenuIt->first;
+ map<int,string>::iterator hit = registeredPlugins.find(id);
+ if (hit != registeredPlugins.end())
+ name = hit->second;
+ map <int,skindesignerapi::sPlugMenu> *templates = &plugMenuIt->second;
+ plugMenuIt++;
+ return templates;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainer(int plugId, int plugMenuId) {
+ map <int, map<int, skindesignerapi::sPlugMenu> >::iterator hit = pluginMenus.find(plugId);
+ if (hit == pluginMenus.end())
+ return NULL;
+ map<int, skindesignerapi::sPlugMenu>::iterator hit2 = (hit->second).find(plugMenuId);
+ if (hit2 == (hit->second).end())
+ return NULL;
+ skindesignerapi::cTokenContainer *tk = hit2->second.tokenContainer;
+ return tk;
+}
+
+void cSDPluginManager::AddSubviewMapping(int plugId, int plugMenuId, int subViewId) {
+ map <int, map<int,int> >::iterator hit = subViewMapping.find(plugId);
+ if (hit == subViewMapping.end()) {
+ map<int,int> menus;
+ menus.insert(pair<int,int>(plugMenuId, subViewId));
+ subViewMapping.insert(pair<int, map<int,int> >(plugId, menus));
+ } else {
+ (hit->second).insert(pair<int,int>(plugMenuId, subViewId));
+ }
+}
+
+int cSDPluginManager::GetSubviewId(int plugId, int plugMenuId) {
+ map <int, map<int,int> >::iterator hit = subViewMapping.find(plugId);
+ if (hit == subViewMapping.end())
+ return -1;
+ map<int,int>::iterator hit2 = (hit->second).find(plugMenuId);
+ if (hit2 == (hit->second).end())
+ return -1;
+ return hit2->second;
+}
+
+void cSDPluginManager::RegisterAdvancedPlugin(skindesignerapi::cPluginStructure *plugStructure) {
+ dsyslog("skindesigner: plugin %s uses libskindesigner API Version %s",
+ plugStructure->name.c_str(),
+ plugStructure->libskindesignerAPIVersion.c_str());
+ plugStructure->id = lastId;
+ registeredPlugins.insert(pair<int,string>(lastId, plugStructure->name));
+ lastId++;
+
+ rootviews.insert(pair<int,string>(plugStructure->id, plugStructure->rootview));
+ subviews.insert(pair<int,map<int,string> >(plugStructure->id, plugStructure->subviews));
+
+ multimap< int, skindesignerapi::sPlugViewElement > viewelementsNew;
+ for (map< int, skindesignerapi::sPlugViewElement >::iterator it = plugStructure->viewelements.begin(); it != plugStructure->viewelements.end(); it++) {
+ int key = it->first;
+ skindesignerapi::sPlugViewElement ve = it->second;
+ skindesignerapi::sPlugViewElement veNew;
+ veNew.id = ve.id;
+ veNew.viewId = ve.viewId;
+ veNew.name = ve.name;
+ veNew.tokenContainer = new skindesignerapi::cTokenContainer(*ve.tokenContainer);
+ viewelementsNew.insert(pair<int, skindesignerapi::sPlugViewElement>(key, veNew));
+ }
+ viewelements.insert(pair< int, multimap < int, skindesignerapi::sPlugViewElement > >(plugStructure->id, viewelementsNew));
+
+ multimap< int, skindesignerapi::sPlugViewGrid > viewgridsNew;
+ for (map< int, skindesignerapi::sPlugViewGrid >::iterator it = plugStructure->viewgrids.begin(); it != plugStructure->viewgrids.end(); it++) {
+ int key = it->first;
+ skindesignerapi::sPlugViewGrid vg = it->second;
+ skindesignerapi::sPlugViewGrid vgNew;
+ vgNew.id = vg.id;
+ vgNew.viewId = vg.viewId;
+ vgNew.name = vg.name;
+ vgNew.tokenContainer = new skindesignerapi::cTokenContainer(*vg.tokenContainer);
+ viewgridsNew.insert(pair<int, skindesignerapi::sPlugViewGrid>(key, vgNew));
+ }
+ viewgrids.insert(pair< int, multimap < int, skindesignerapi::sPlugViewGrid > >(plugStructure->id, viewgridsNew));
+
+ map< int, skindesignerapi::cTokenContainer* > viewtabsNew;
+ for (map<int,skindesignerapi::cTokenContainer*>::iterator it = plugStructure->viewtabs.begin(); it != plugStructure->viewtabs.end(); it++) {
+ int id = it->first;
+ skindesignerapi::cTokenContainer *tk = it->second;
+ viewtabsNew.insert(pair<int,skindesignerapi::cTokenContainer*>(id, new skindesignerapi::cTokenContainer(*tk)));
+ }
+ viewtabs.insert(pair< int, map<int,skindesignerapi::cTokenContainer*> >(plugStructure->id, viewtabsNew));
+
+ if (plugStructure->rootview.size() > 0)
+ dsyslog("skindesigner: plugin %s has registered %ld views with %ld viewelements and %ld viewgrids",
+ plugStructure->name.c_str(),
+ 1 + plugStructure->subviews.size(),
+ plugStructure->viewelements.size(),
+ plugStructure->viewgrids.size());
+}
+
+void cSDPluginManager::InitPluginViewIterator(void) {
+ rootViewsIt = rootviews.begin();
+}
+
+bool cSDPluginManager::GetNextPluginView(string &plugName, int &plugId, string &tplName) {
+ if (rootViewsIt == rootviews.end())
+ return false;
+ plugId = rootViewsIt->first;
+ tplName = rootViewsIt->second;
+ map<int,string>::iterator hit = registeredPlugins.find(plugId);
+ if (hit != registeredPlugins.end())
+ plugName = hit->second;
+ rootViewsIt++;
+ return true;
+}
+
+int cSDPluginManager::GetNumSubviews(int plugId) {
+ map< int, map< int, string > >::iterator hit = subviews.find(plugId);
+ if (hit == subviews.end())
+ return 0;
+ return (hit->second).size();
+}
+
+void cSDPluginManager::InitPluginSubviewIterator(int plugId) {
+ map< int, map< int, string > >::iterator hit = subviews.find(plugId);
+ if (hit == subviews.end()) {
+ subviewsfound = false;
+ return;
+ }
+ subviewsCurrent = hit->second;
+ subviewsfound = true;
+ svIt = subviewsCurrent.begin();
+}
+
+bool cSDPluginManager::GetNextSubView(int &id, string &tplname) {
+ if (!subviewsfound)
+ return false;
+ if( svIt == subviewsCurrent.end() ) {
+ return false;
+ }
+ id = svIt->first;
+ tplname = svIt->second;
+ svIt++;
+ return true;
+}
+
+int cSDPluginManager::GetNumViewElements(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
+ if (hit == viewelements.end())
+ return 0;
+ multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
+ pair<multimap<int, skindesignerapi::sPlugViewElement>::iterator, multimap<int, skindesignerapi::sPlugViewElement>::iterator> range;
+ range = plugVEs->equal_range(viewId);
+ int numVEs = 0;
+ for (multimap<int, skindesignerapi::sPlugViewElement>::iterator it=range.first; it!=range.second; ++it) {
+ numVEs++;
+ }
+ return numVEs;
+}
+
+void cSDPluginManager::InitViewElementIterator(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
+ if (hit == viewelements.end())
+ return;
+ multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
+ veRange = plugVEs->equal_range(viewId);
+ veIt = veRange.first;
+}
+
+bool cSDPluginManager::GetNextViewElement(int &veId, string &veName) {
+ if (veIt == veRange.second)
+ return false;
+ skindesignerapi::sPlugViewElement *ve = &veIt->second;
+ veId = ve->id;
+ veName = ve->name;
+ veIt++;
+ return true;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerVE(int plugId, int viewId, int veId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > >::iterator hit = viewelements.find(plugId);
+ if (hit == viewelements.end())
+ return NULL;
+ multimap<int, skindesignerapi::sPlugViewElement> *plugVEs = &hit->second;
+ for (multimap<int, skindesignerapi::sPlugViewElement>::iterator it = plugVEs->begin(); it != plugVEs->end(); it++) {
+ int view = it->first;
+ if (view != viewId)
+ continue;
+ skindesignerapi::sPlugViewElement *ve = &it->second;
+ if (ve->id == veId)
+ return ve->tokenContainer;
+ }
+ return NULL;
+}
+
+int cSDPluginManager::GetNumViewGrids(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
+ if (hit == viewgrids.end())
+ return 0;
+ multimap<int, skindesignerapi::sPlugViewGrid> *plugVGs = &hit->second;
+ pair<multimap<int, skindesignerapi::sPlugViewGrid>::iterator, multimap<int, skindesignerapi::sPlugViewGrid>::iterator> range;
+ range = plugVGs->equal_range(viewId);
+ int numVGs = 0;
+ for (multimap<int, skindesignerapi::sPlugViewGrid>::iterator it=range.first; it!=range.second; ++it) {
+ numVGs++;
+ }
+ return numVGs;
+}
+
+void cSDPluginManager::InitViewGridIterator(int plugId, int viewId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
+ if (hit == viewgrids.end())
+ return;
+ multimap<int, skindesignerapi::sPlugViewGrid> *plugGEs = &hit->second;
+ gRange = plugGEs->equal_range(viewId);
+ gIt = gRange.first;
+}
+
+bool cSDPluginManager::GetNextViewGrid(int &gId, string &gName) {
+ if (gIt == gRange.second)
+ return false;
+ skindesignerapi::sPlugViewGrid *ge = &gIt->second;
+ gId = ge->id;
+ gName = ge->name;
+ gIt++;
+ return true;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerGE(int plugId, int viewId, int gId) {
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > >::iterator hit = viewgrids.find(plugId);
+ if (hit == viewgrids.end())
+ return NULL;
+ multimap<int, skindesignerapi::sPlugViewGrid> *plugGEs = &hit->second;
+ for (multimap<int, skindesignerapi::sPlugViewGrid>::iterator it = plugGEs->begin(); it != plugGEs->end(); it++) {
+ int view = it->first;
+ if (view != viewId)
+ continue;
+ skindesignerapi::sPlugViewGrid *g = &it->second;
+ if (g->id == gId)
+ return g->tokenContainer;
+ }
+ return NULL;
+}
+
+skindesignerapi::cTokenContainer *cSDPluginManager::GetTokenContainerTab(int plugId, int viewId) {
+ map< int, map< int, skindesignerapi::cTokenContainer* > >::iterator hit = viewtabs.find(plugId);
+ if (hit == viewtabs.end())
+ return NULL;
+ map< int, skindesignerapi::cTokenContainer* > *tabs = &hit->second;
+ map< int, skindesignerapi::cTokenContainer* >::iterator hit2 = tabs->find(viewId);
+ if (hit2 == tabs->end())
+ return NULL;
+ return (hit2->second);
+}
diff --git a/extensions/pluginmanager.h b/extensions/pluginmanager.h new file mode 100644 index 0000000..399c1d8 --- /dev/null +++ b/extensions/pluginmanager.h @@ -0,0 +1,71 @@ +#ifndef __PLUGINMANAGER_H
+#define __PLUGINMANAGER_H
+
+#include <string>
+#include <map>
+#include "libskindesignerapi/skindesignerapi.h"
+
+using namespace std;
+
+class cSDPluginManager {
+private:
+ int lastId;
+ //plugin id --> plugin name
+ map < int, string > registeredPlugins;
+ //Basic Plugin Interface
+ //plugin id --> plugin definition
+ map < int, map < int, skindesignerapi::sPlugMenu > > pluginMenus;
+ map < int, map < int, skindesignerapi::sPlugMenu > >::iterator plugMenuIt;
+ //plugin id - menuId --> subviewid
+ map < int, map<int, int> > subViewMapping;
+
+ //Advanced Plugin Interface
+ //plugin id --> rootview templatename definition
+ map< int, string > rootviews;
+ map< int, string >::iterator rootViewsIt;
+ //plugin id --> subviewid /templatename definition
+ map< int, map< int, string > > subviews;
+ map< int, string> subviewsCurrent;
+ map< int, string>::iterator svIt;
+ bool subviewsfound;
+ //plugin id --> view id --> viewelement definition
+ map< int, multimap< int, skindesignerapi::sPlugViewElement > > viewelements;
+ pair<multimap<int, skindesignerapi::sPlugViewElement>::iterator, multimap<int, skindesignerapi::sPlugViewElement>::iterator> veRange;
+ multimap<int, skindesignerapi::sPlugViewElement>::iterator veIt;
+ //plugin id --> view id --> viewgrid definition
+ map< int, multimap< int, skindesignerapi::sPlugViewGrid > > viewgrids;
+ pair<multimap<int, skindesignerapi::sPlugViewGrid>::iterator, multimap<int, skindesignerapi::sPlugViewGrid>::iterator> gRange;
+ multimap<int, skindesignerapi::sPlugViewGrid>::iterator gIt;
+ //plugin id --> view id --> tokencontainer of detailedview definition
+ map< int, map< int, skindesignerapi::cTokenContainer* > > viewtabs;
+public:
+ cSDPluginManager(void);
+ ~cSDPluginManager(void);
+ void Reset(void);
+ //Basic Plugin Interface
+ void RegisterBasicPlugin(skindesignerapi::cPluginStructure *plugStructure);
+ int GetNumPluginMenus(void);
+ void InitPluginMenuIterator(void);
+ map <int,skindesignerapi::sPlugMenu> *GetPluginMenus(string &name, int &id);
+ skindesignerapi::cTokenContainer *GetTokenContainer(int plugId, int plugMenuId);
+ void AddSubviewMapping(int plugId, int plugMenuId, int subViewId);
+ int GetSubviewId(int plugId, int plugMenuId);
+ //Advanced Plugin Interface
+ void RegisterAdvancedPlugin(skindesignerapi::cPluginStructure *plugStructure);
+ void InitPluginViewIterator(void);
+ bool GetNextPluginView(string &plugName, int &plugId, string &tplName);
+ int GetNumSubviews(int plugId);
+ void InitPluginSubviewIterator(int plugId);
+ bool GetNextSubView(int &id, string &tplname);
+ int GetNumViewElements(int plugId, int viewId);
+ void InitViewElementIterator(int plugId, int viewId);
+ bool GetNextViewElement(int &veId, string &veName);
+ skindesignerapi::cTokenContainer *GetTokenContainerVE(int plugId, int viewId, int veId);
+ int GetNumViewGrids(int plugId, int viewId);
+ void InitViewGridIterator(int plugId, int viewId);
+ bool GetNextViewGrid(int &gId, string &gName);
+ skindesignerapi::cTokenContainer *GetTokenContainerGE(int plugId, int viewId, int gId);
+ skindesignerapi::cTokenContainer *GetTokenContainerTab(int plugId, int viewId);
+};
+
+#endif //__PLUGINMANAGER_H
\ No newline at end of file diff --git a/libcore/recfolderinfo.c b/extensions/recfolderinfo.c index d03ed6c..d03ed6c 100644 --- a/libcore/recfolderinfo.c +++ b/extensions/recfolderinfo.c diff --git a/libcore/recfolderinfo.h b/extensions/recfolderinfo.h index 8148ea7..8148ea7 100644 --- a/libcore/recfolderinfo.h +++ b/extensions/recfolderinfo.h diff --git a/extensions/scrapmanager.c b/extensions/scrapmanager.c new file mode 100644 index 0000000..8452d75 --- /dev/null +++ b/extensions/scrapmanager.c @@ -0,0 +1,359 @@ +#include "scrapmanager.h"
+#include "../coreengine/definitions.h"
+#include "helpers.h"
+
+cPlugin *cScrapManager::pScraper = NULL;
+
+cScrapManager::cScrapManager(void) {
+ if (!pScraper) {
+ pScraper = GetScraperPlugin();
+ }
+ movie = NULL;
+ series = NULL;
+}
+
+cScrapManager::~cScrapManager(void) {
+ delete movie;
+ delete series;
+}
+
+bool cScrapManager::LoadFullScrapInfo(const cEvent *event, const cRecording *recording) {
+ if (!pScraper) {
+ return false;
+ }
+ delete movie;
+ movie = NULL;
+ delete series;
+ series = NULL;
+
+ ScraperGetEventType getType;
+ getType.event = event;
+ getType.recording = recording;
+ if (!pScraper->Service("GetEventType", &getType)) {
+ return false;
+ }
+ if (getType.type == tMovie) {
+ movie = new cMovie();
+ movie->movieId = getType.movieId;
+ pScraper->Service("GetMovie", movie);
+ return true;
+ } else if (getType.type == tSeries) {
+ series = new cSeries();
+ series->seriesId = getType.seriesId;
+ series->episodeId = getType.episodeId;
+ pScraper->Service("GetSeries", series);
+ return true;
+ }
+ return false;
+}
+
+void cScrapManager::SetFullScrapInfo(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
+ if (series) {
+ tk->AddIntToken((int)eScraperIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperIT::isseries, 1);
+ SetSeries(tk, actorsIndex);
+ } else if (movie) {
+ tk->AddIntToken((int)eScraperIT::ismovie, 1);
+ tk->AddIntToken((int)eScraperIT::isseries, 0);
+ SetMovie(tk, actorsIndex);
+ } else {
+ tk->AddIntToken((int)eScraperIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperIT::isseries, 0);
+ }
+}
+
+
+int cScrapManager::NumActors(void) {
+ if (series) {
+ return series->actors.size();
+ } else if (movie) {
+ return movie->actors.size();
+ }
+ return 0;
+}
+
+void cScrapManager::SetHeaderScrapInfo(skindesignerapi::cTokenContainer *tk) {
+ if (series) {
+ tk->AddIntToken((int)eScraperHeaderIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperHeaderIT::isseries, 1);
+ vector<cTvMedia>::iterator poster = series->posters.begin();
+ if (poster != series->posters.end()) {
+ tk->AddIntToken((int)eScraperHeaderIT::posteravailable, true);
+ tk->AddIntToken((int)eScraperHeaderIT::posterwidth, (*poster).width);
+ tk->AddIntToken((int)eScraperHeaderIT::posterheight, (*poster).height);
+ tk->AddStringToken((int)eScraperHeaderST::posterpath, (*poster).path.c_str());
+ }
+ vector<cTvMedia>::iterator banner = series->banners.begin();
+ if (banner != series->banners.end()) {
+ tk->AddIntToken((int)eScraperHeaderIT::banneravailable, true);
+ tk->AddIntToken((int)eScraperHeaderIT::bannerwidth, (*banner).width);
+ tk->AddIntToken((int)eScraperHeaderIT::bannerheight, (*banner).height);
+ tk->AddStringToken((int)eScraperHeaderST::bannerpath, (*banner).path.c_str());
+ }
+ } else if (movie) {
+ tk->AddIntToken((int)eScraperHeaderIT::ismovie, 1);
+ tk->AddIntToken((int)eScraperHeaderIT::isseries, 0);
+ tk->AddIntToken((int)eScraperHeaderIT::posteravailable, true);
+ tk->AddIntToken((int)eScraperHeaderIT::banneravailable, false);
+ tk->AddIntToken((int)eScraperHeaderIT::posterwidth, movie->poster.width);
+ tk->AddIntToken((int)eScraperHeaderIT::posterheight, movie->poster.height);
+ tk->AddStringToken((int)eScraperHeaderST::posterpath, movie->poster.path.c_str());
+ } else {
+ tk->AddIntToken((int)eScraperHeaderIT::ismovie, 0);
+ tk->AddIntToken((int)eScraperHeaderIT::isseries, 0);
+ }
+}
+
+void cScrapManager::SetScraperPosterBanner(skindesignerapi::cTokenContainer *tk) {
+ if (movie) {
+ tk->AddIntToken((int)eCeMenuSchedulesIT::hasposter, 1);
+ tk->AddStringToken((int)eCeMenuSchedulesST::posterpath, movie->poster.path.c_str());
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterwidth, movie->poster.width);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterheight, movie->poster.height);
+ } else if (series) {
+ vector<cTvMedia>::iterator poster = series->posters.begin();
+ if (poster != series->posters.end()) {
+ tk->AddIntToken((int)eCeMenuSchedulesIT::hasposter, 1);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterwidth, (*poster).width);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::posterheight, (*poster).height);
+ tk->AddStringToken((int)eCeMenuSchedulesST::posterpath, (*poster).path.c_str());
+ }
+ vector<cTvMedia>::iterator banner = series->banners.begin();
+ if (banner != series->banners.end()) {
+ tk->AddIntToken((int)eCeMenuSchedulesIT::hasbanner, 1);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::bannerwidth, (*banner).width);
+ tk->AddIntToken((int)eCeMenuSchedulesIT::bannerheight, (*banner).height);
+ tk->AddStringToken((int)eCeMenuSchedulesST::bannerpath, (*banner).path.c_str());
+ }
+ }
+}
+
+void cScrapManager::SetScraperRecordingPoster(skindesignerapi::cTokenContainer *tk, const cRecording *recording, bool isListElement) {
+ if (!pScraper) {
+ return;
+ }
+ ScraperGetPosterThumb call;
+ call.event = NULL;
+ call.recording = recording;
+ if (pScraper->Service("GetPosterThumb", &call)) {
+ if (isListElement) {
+ tk->AddIntToken((int)eLeMenuRecordingsIT::hasposterthumbnail, FileExists(call.poster.path));
+ tk->AddIntToken((int)eLeMenuRecordingsIT::thumbnailwidth, call.poster.width);
+ tk->AddIntToken((int)eLeMenuRecordingsIT::thumbnailheight, call.poster.height);
+ tk->AddStringToken((int)eLeMenuRecordingsST::thumbnailpath, call.poster.path.c_str());
+ } else {
+ tk->AddIntToken((int)eCeMenuRecordingsIT::hasposterthumbnail, FileExists(call.poster.path));
+ tk->AddIntToken((int)eCeMenuRecordingsIT::thumbnailwidth, call.poster.width);
+ tk->AddIntToken((int)eCeMenuRecordingsIT::thumbnailheight, call.poster.height);
+ tk->AddStringToken((int)eCeMenuRecordingsST::thumbnailpath, call.poster.path.c_str());
+ }
+ }
+
+ ScraperGetPoster call2;
+ call2.event = NULL;
+ call2.recording = recording;
+ if (pScraper->Service("GetPoster", &call2)) {
+ if (isListElement) {
+ tk->AddIntToken((int)eLeMenuRecordingsIT::hasposter, FileExists(call2.poster.path));
+ tk->AddIntToken((int)eLeMenuRecordingsIT::posterwidth, call2.poster.width);
+ tk->AddIntToken((int)eLeMenuRecordingsIT::posterheight, call2.poster.height);
+ tk->AddStringToken((int)eLeMenuRecordingsST::posterpath, call2.poster.path.c_str());
+ } else {
+ tk->AddIntToken((int)eCeMenuRecordingsIT::hasposter, FileExists(call2.poster.path));
+ tk->AddIntToken((int)eCeMenuRecordingsIT::posterwidth, call2.poster.width);
+ tk->AddIntToken((int)eCeMenuRecordingsIT::posterheight, call2.poster.height);
+ tk->AddStringToken((int)eCeMenuRecordingsST::posterpath, call2.poster.path.c_str());
+ }
+ }
+}
+
+cPlugin *cScrapManager::GetScraperPlugin(void) {
+ static cPlugin *pScraper = cPluginManager::GetPlugin("scraper2vdr");
+ if( !pScraper ) // if it doesn't exit, try tvscraper
+ pScraper = cPluginManager::GetPlugin("tvscraper");
+ return pScraper;
+}
+
+void cScrapManager::SetMovie(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
+ tk->AddStringToken((int)eScraperST::movietitle, movie->title.c_str());
+ tk->AddStringToken((int)eScraperST::movieoriginalTitle, movie->originalTitle.c_str());
+ tk->AddStringToken((int)eScraperST::movietagline, movie->tagline.c_str());
+ tk->AddStringToken((int)eScraperST::movieoverview, movie->overview.c_str());
+ tk->AddStringToken((int)eScraperST::moviegenres, movie->genres.c_str());
+ tk->AddStringToken((int)eScraperST::moviehomepage, movie->homepage.c_str());
+ tk->AddStringToken((int)eScraperST::moviereleasedate, movie->releaseDate.c_str());
+ tk->AddStringToken((int)eScraperST::moviepopularity, *cString::sprintf("%f", movie->popularity));
+ tk->AddStringToken((int)eScraperST::movievoteaverage, *cString::sprintf("%f", movie->voteAverage));
+ tk->AddStringToken((int)eScraperST::posterpath, movie->poster.path.c_str());
+ tk->AddStringToken((int)eScraperST::fanartpath, movie->fanart.path.c_str());
+ tk->AddStringToken((int)eScraperST::collectionposterpath, movie->collectionPoster.path.c_str());
+ tk->AddStringToken((int)eScraperST::collectionfanartpath, movie->collectionFanart.path.c_str());
+ tk->AddIntToken((int)eScraperIT::movieadult, movie->adult);
+ tk->AddIntToken((int)eScraperIT::moviebudget, movie->budget);
+ tk->AddIntToken((int)eScraperIT::movierevenue, movie->revenue);
+ tk->AddIntToken((int)eScraperIT::movieruntime, movie->runtime);
+ tk->AddIntToken((int)eScraperIT::posterwidth, movie->poster.width);
+ tk->AddIntToken((int)eScraperIT::posterheight, movie->poster.height);
+ tk->AddIntToken((int)eScraperIT::fanartwidth, movie->fanart.width);
+ tk->AddIntToken((int)eScraperIT::fanartheight, movie->fanart.height);
+ tk->AddIntToken((int)eScraperIT::collectionposterwidth, movie->collectionPoster.width);
+ tk->AddIntToken((int)eScraperIT::collectionposterheight, movie->collectionPoster.height);
+ tk->AddIntToken((int)eScraperIT::collectionfanartwidth, movie->collectionFanart.width);
+ tk->AddIntToken((int)eScraperIT::collectionfanartheight, movie->collectionFanart.height);
+ if (movie->collectionPoster.path.size() > 0)
+ tk->AddIntToken((int)eScraperIT::movieiscollection, 1);
+ int i=0;
+ for (vector<cActor>::iterator act = movie->actors.begin(); act != movie->actors.end(); act++) {
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::name, (*act).name.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::role, (*act).role.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumb, (*act).actorThumb.path.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbwidth, *cString::sprintf("%d", (*act).actorThumb.width));
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbheight, *cString::sprintf("%d", (*act).actorThumb.height));
+ i++;
+ }
+}
+
+void cScrapManager::SetSeries(skindesignerapi::cTokenContainer *tk, int actorsIndex) {
+ //Series Basics
+ tk->AddStringToken((int)eScraperST::seriesname, series->name.c_str());
+ tk->AddStringToken((int)eScraperST::seriesoverview, series->overview.c_str());
+ tk->AddStringToken((int)eScraperST::seriesfirstaired, series->firstAired.c_str());
+ tk->AddStringToken((int)eScraperST::seriesnetwork, series->network.c_str());
+ tk->AddStringToken((int)eScraperST::seriesgenre, series->genre.c_str());
+ tk->AddStringToken((int)eScraperST::seriesrating, *cString::sprintf("%f", series->rating));
+ tk->AddStringToken((int)eScraperST::seriesstatus, series->status.c_str());
+ //Episode Information
+ tk->AddIntToken((int)eScraperIT::episodenumber, series->episode.number);
+ tk->AddIntToken((int)eScraperIT::episodeseason, series->episode.season);
+ tk->AddStringToken((int)eScraperST::episodetitle, series->episode.name.c_str());
+ tk->AddStringToken((int)eScraperST::episodefirstaired, series->episode.firstAired.c_str());
+ tk->AddStringToken((int)eScraperST::episodegueststars, series->episode.guestStars.c_str());
+ tk->AddStringToken((int)eScraperST::episodeoverview, series->episode.overview.c_str());
+ tk->AddStringToken((int)eScraperST::episoderating, *cString::sprintf("%f", series->episode.rating));
+ tk->AddIntToken((int)eScraperIT::episodeimagewidth, series->episode.episodeImage.width);
+ tk->AddIntToken((int)eScraperIT::episodeimageheight, series->episode.episodeImage.height);
+ tk->AddStringToken((int)eScraperST::episodeimagepath, series->episode.episodeImage.path.c_str());
+ //Seasonposter
+ tk->AddIntToken((int)eScraperIT::seasonposterwidth, series->seasonPoster.width);
+ tk->AddIntToken((int)eScraperIT::seasonposterheight, series->seasonPoster.height);
+ tk->AddStringToken((int)eScraperST::seasonposterpath, series->seasonPoster.path.c_str());
+ //Posters
+ int indexInt = (int)eScraperIT::seriesposter1width;
+ int indexStr = (int)eScraperST::seriesposter1path;
+ for(vector<cTvMedia>::iterator poster = series->posters.begin(); poster != series->posters.end(); poster++) {
+ tk->AddIntToken(indexInt, (*poster).width);
+ tk->AddIntToken(indexInt+1, (*poster).height);
+ tk->AddStringToken(indexStr, (*poster).path.c_str());
+ indexInt += 2;
+ indexStr++;
+ }
+ //Banners
+ indexInt = (int)eScraperIT::seriesbanner1width;
+ indexStr = (int)eScraperST::seriesbanner1path;
+ for(vector<cTvMedia>::iterator banner = series->banners.begin(); banner != series->banners.end(); banner++) {
+ tk->AddIntToken(indexInt, (*banner).width);
+ tk->AddIntToken(indexInt+1, (*banner).height);
+ tk->AddStringToken(indexStr, (*banner).path.c_str());
+ indexInt += 2;
+ indexStr++;
+ }
+ //Fanarts
+ indexInt = (int)eScraperIT::seriesfanart1width;
+ indexStr = (int)eScraperST::seriesfanart1path;
+ for(vector<cTvMedia>::iterator fanart = series->fanarts.begin(); fanart != series->fanarts.end(); fanart++) {
+ tk->AddIntToken(indexInt, (*fanart).width);
+ tk->AddIntToken(indexInt+1, (*fanart).height);
+ tk->AddStringToken(indexStr, (*fanart).path.c_str());
+ indexInt += 2;
+ indexStr++;
+ }
+ //Actors
+ int i=0;
+ for (vector<cActor>::iterator act = series->actors.begin(); act != series->actors.end(); act++) {
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::name, (*act).name.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::role, (*act).role.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumb, (*act).actorThumb.path.c_str());
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbwidth, *cString::sprintf("%d", (*act).actorThumb.width));
+ tk->AddLoopToken(actorsIndex, i, (int)eScraperLT::thumbheight, *cString::sprintf("%d", (*act).actorThumb.height));
+ i++;
+ }
+}
+
+void cScrapManager::RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster) {
+ 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;
+ if (path.size() > 0)
+ hasPoster = true;
+ }
+}
+
+void cScrapManager::SetPosterBanner(skindesignerapi::cTokenContainer *tk, const cEvent *event, const cRecording *recording) {
+ 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 = event;
+ 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 = event;
+ 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;
+ }
+ }
+ tk->AddIntToken((int)eScraperPosterBannerIT::mediawidth, mediaWidth);
+ tk->AddIntToken((int)eScraperPosterBannerIT::mediaheight, mediaHeight);
+ tk->AddIntToken((int)eScraperPosterBannerIT::isbanner, isBanner);
+ tk->AddStringToken((int)eScraperPosterBannerST::mediapath, mediaPath.c_str());
+ tk->AddIntToken((int)eScraperPosterBannerIT::posterwidth, posterWidth);
+ tk->AddIntToken((int)eScraperPosterBannerIT::posterheight, posterHeight);
+ tk->AddStringToken((int)eScraperPosterBannerST::posterpath, posterPath.c_str());
+ tk->AddIntToken((int)eScraperPosterBannerIT::hasposter, hasPoster);
+ tk->AddIntToken((int)eScraperPosterBannerIT::bannerwidth, bannerWidth);
+ tk->AddIntToken((int)eScraperPosterBannerIT::bannerheight, bannerHeight);
+ tk->AddStringToken((int)eScraperPosterBannerST::bannerpath, bannerPath.c_str());
+ tk->AddIntToken((int)eScraperPosterBannerIT::hasbanner, hasBanner);
+}
\ No newline at end of file diff --git a/extensions/scrapmanager.h b/extensions/scrapmanager.h new file mode 100644 index 0000000..0e026fc --- /dev/null +++ b/extensions/scrapmanager.h @@ -0,0 +1,28 @@ +#ifndef __SCRAPMANAGER_H
+#define __SCRAPMANAGER_H
+
+#include "../services/scraper2vdr.h"
+#include "../libskindesignerapi/tokencontainer.h"
+
+class cScrapManager {
+private:
+ static cPlugin *pScraper;
+ cMovie *movie;
+ cSeries *series;
+ cPlugin *GetScraperPlugin(void);
+ void SetMovie(skindesignerapi::cTokenContainer *tk, int actorsIndex);
+ void SetSeries(skindesignerapi::cTokenContainer *tk, int actorsIndex);
+protected:
+ bool LoadFullScrapInfo(const cEvent *event, const cRecording *recording);
+ void SetFullScrapInfo(skindesignerapi::cTokenContainer *tk, int actorsIndex);
+ int NumActors(void);
+ void SetHeaderScrapInfo(skindesignerapi::cTokenContainer *tk);
+ void SetScraperPosterBanner(skindesignerapi::cTokenContainer *tk);
+ void SetScraperRecordingPoster(skindesignerapi::cTokenContainer *tk, const cRecording *recording, bool isListElement);
+ void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster);
+ void SetPosterBanner(skindesignerapi::cTokenContainer *tk, const cEvent *event, const cRecording *recording);
+public:
+ cScrapManager(void);
+ virtual ~cScrapManager(void);
+};
+#endif //__SCRAPMANAGER_H
\ No newline at end of file diff --git a/libcore/skinrepo.c b/extensions/skinrepo.c index e815421..16919e8 100644 --- a/libcore/skinrepo.c +++ b/extensions/skinrepo.c @@ -1,7 +1,7 @@ #include <iostream> #include <fstream> #include "skinrepo.h" -#include "../libcore/helpers.h" +#include "helpers.h" using namespace std; diff --git a/libcore/skinrepo.h b/extensions/skinrepo.h index 7452ad4..2f10929 100644 --- a/libcore/skinrepo.h +++ b/extensions/skinrepo.h @@ -5,7 +5,7 @@ #include <vector> #include <map> #include <set> -#include "../libcore/libxmlwrapper.h" +#include "libxmlwrapper.h" #include <vdr/plugin.h> using namespace std; @@ -61,9 +61,9 @@ public: string Author(void) { return author; }; string MinSDVersion(void) { return minSDVersion; }; string Url(void) { return url; }; - vector<string> SpecialFonts(void) { return specialFonts; }; - vector<string> SupportedPlugins(void) { return supportedPlugins; }; - vector< pair < string, string > > Screenshots(void) { return screenshots; }; + vector<string> *SpecialFonts(void) { return &specialFonts; }; + vector<string> *SupportedPlugins(void) { return &supportedPlugins; }; + vector< pair < string, string > > *Screenshots(void) { return &screenshots; }; void Install(string path, string themesPath); void Update(string path); bool InstallationFinished(void) { return !(Running()); }; diff --git a/libcore/skinsetup.c b/extensions/skinsetup.c index 3a6b7cf..f622336 100644 --- a/libcore/skinsetup.c +++ b/extensions/skinsetup.c @@ -1,7 +1,7 @@ #include "skinsetup.h" #include "../config.h" -#include "../libtemplate/xmlparser.h" -#include "../libcore/helpers.h" +#include "../coreengine/xmlparser.h" +#include "helpers.h" // --- cSkinSetupParameter ----------------------------------------------------------- diff --git a/libcore/skinsetup.h b/extensions/skinsetup.h index 0ae49cc..e3b9cc3 100644 --- a/libcore/skinsetup.h +++ b/extensions/skinsetup.h @@ -8,7 +8,7 @@ #include <sstream> #include <vdr/plugin.h> #include <libxml/xmlstring.h> -#include "../libtemplate/globals.h" +#include "../coreengine/globals.h" using namespace std; @@ -99,4 +99,4 @@ public: void Debug(void); }; -#endif //__SKINSETUP_H
\ No newline at end of file +#endif //__SKINSETUP_H diff --git a/libcore/timers.c b/extensions/timers.c index b93aada..b93aada 100644 --- a/libcore/timers.c +++ b/extensions/timers.c diff --git a/libcore/timers.h b/extensions/timers.h index aba873c..aba873c 100644 --- a/libcore/timers.h +++ b/extensions/timers.h diff --git a/libcore/pixmapcontainer.c b/libcore/pixmapcontainer.c deleted file mode 100644 index 5cbcf9e..0000000 --- a/libcore/pixmapcontainer.c +++ /dev/null @@ -1,835 +0,0 @@ -#define __STL_CONFIG_H -#include <math.h> -#include "pixmapcontainer.h" -#include "../config.h" - -cMutex cPixmapContainer::mutex; -cOsd *cPixmapContainer::osd = NULL; -eFlushState cPixmapContainer::flushState = fsOpen; - -cPixmapContainer::cPixmapContainer(int numPixmaps) { - this->numPixmaps = numPixmaps; - pixContainerInit = true; - mutex.Lock(); - pixmaps = new cPixmap*[numPixmaps]; - pixmapsTransparency = new int[numPixmaps]; - for(int i=0; i < numPixmaps; i++) { - pixmaps[i] = NULL; - pixmapsTransparency[i] = 0; - } - pixmapsLayer = NULL; - mutex.Unlock(); - checkRunning = false; - fadeTime = 0; - shiftTime = 0; - shiftType = stNone; - shiftMode = smLinear; - deleteOsdOnExit = false; -} - -cPixmapContainer::~cPixmapContainer(void) { - for (int i=0; i < numPixmaps; i++) { - mutex.Lock(); - if (pixmaps[i] && osd) { - osd->DestroyPixmap(pixmaps[i]); - pixmaps[i] = NULL; - } - mutex.Unlock(); - } - delete[] pixmaps; - delete[] pixmapsTransparency; - if (pixmapsLayer) - delete[] pixmapsLayer; - - if (deleteOsdOnExit && osd) { - mutex.Lock(); - delete osd; - osd = NULL; - mutex.Unlock(); - } - flushState = fsOpen; -} - -bool cPixmapContainer::CreateOsd(int Left, int Top, int Width, int Height) { - if (osd) { - return false; - } - cOsd *newOsd = cOsdProvider::NewOsd(Left, Top); - if (newOsd) { - tArea Area = { 0, 0, Width - 1, Height - 1, 32 }; - if (newOsd->SetAreas(&Area, 1) == oeOk) { - osd = newOsd; - return true; - } - } - return false; -} - -void cPixmapContainer::LockFlush(void) { - flushState = fsLock; -} - -void cPixmapContainer::OpenFlush(void) { - flushState = fsOpen; -} - - -void cPixmapContainer::DoFlush(void) { - cMutexLock MutexLock(&mutex); - if (!osd || (checkRunning && !Running())) - return; - if (flushState == fsOpen) { - osd->Flush(); - } -} - -void cPixmapContainer::HidePixmaps(void) { - cMutexLock MutexLock(&mutex); - pixmapsLayer = new int[numPixmaps]; - for(int i=0; i < numPixmaps; i++) { - if (!pixmaps[i]) { - pixmapsLayer[i] = 0; - continue; - } - pixmapsLayer[i] = pixmaps[i]->Layer(); - pixmaps[i]->SetLayer(-1); - } -} - -void cPixmapContainer::ShowPixmaps(void) { - cMutexLock MutexLock(&mutex); - if (!pixmapsLayer) - return; - for(int i=0; i < numPixmaps; i++) { - if (!pixmaps[i]) - continue; - pixmaps[i]->SetLayer(pixmapsLayer[i]); - } -} - -/****************************************************************************************************** -* Protected Functions -******************************************************************************************************/ - -bool cPixmapContainer::PixmapExists(int num) { - cMutexLock MutexLock(&mutex); - if (pixmaps[num]) - return true; - return false; -} - -void cPixmapContainer::CreatePixmap(int num, int Layer, const cRect &ViewPort, const cRect &DrawPort) { - cMutexLock MutexLock(&mutex); - if (!osd || (checkRunning && !Running())) - return; - pixmaps[num] = osd->CreatePixmap(Layer, ViewPort, DrawPort); - if (!pixmaps[num]) - return; - pixmaps[num]->Fill(clrTransparent); - if (pixContainerInit && (fadeTime || shiftTime)) { - pixmaps[num]->SetAlpha(0); - } else if (pixmapsTransparency[num]) { - pixmaps[num]->SetAlpha(pixmapsTransparency[num]); - } -} - -bool cPixmapContainer::DestroyPixmap(int num) { - cMutexLock MutexLock(&mutex); - if (pixmaps[num] && osd) { - osd->DestroyPixmap(pixmaps[num]); - pixmaps[num] = NULL; - return true; - } - return false; -} - -void cPixmapContainer::DrawText(int num, const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, std::string fontName, int fontSize) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - fontManager->Lock(); - cFont *font = fontManager->Font(fontName, fontSize); - if (font) - pixmaps[num]->DrawText(Point, s, ColorFg, ColorBg, font); - fontManager->Unlock(); -} - - -void cPixmapContainer::DrawRectangle(int num, const cRect &Rect, tColor Color) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->DrawRectangle(Rect, Color); -} - -void cPixmapContainer::DrawEllipse(int num, const cRect &Rect, tColor Color, int Quadrants) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->DrawEllipse(Rect, Color, Quadrants); -} - -void cPixmapContainer::DrawSlope(int num, const cRect &Rect, tColor Color, int Type) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->DrawSlope(Rect, Color, Type); -} - -void cPixmapContainer::DrawImage(int num, const cPoint &Point, const cImage &Image) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->DrawImage(Point, Image); -} - -void cPixmapContainer::DrawBitmap(int num, const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg, tColor ColorBg, bool Overlay) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->DrawBitmap(Point, Bitmap, ColorFg, ColorBg, Overlay); -} - -void cPixmapContainer::Fill(int num, tColor Color) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->Fill(Color); -} - -void cPixmapContainer::SetAlpha(int num, int Alpha) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->SetAlpha(Alpha); -} - -void cPixmapContainer::SetTransparency(int num, int Transparency) { - if (Transparency < 0 && Transparency > 100) - return; - pixmapsTransparency[num] = (100 - Transparency)*255/100; -} - -void cPixmapContainer::SetLayer(int num, int Layer) { - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->SetLayer(Layer); -} - -void cPixmapContainer::SetViewPort(int num, const cRect &rect) { - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->SetViewPort(rect); -} - -int cPixmapContainer::Layer(int num) { - if (checkRunning && !Running()) - return 0; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return 0; - return pixmaps[num]->Layer(); -} - -void cPixmapContainer::Pos(int num, cPoint &pos) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pos.SetX(pixmaps[num]->ViewPort().X()); - pos.SetY(pixmaps[num]->ViewPort().Y()); -} - -cRect cPixmapContainer::ViewPort(int num) { - cRect vp; - if (checkRunning && !Running()) - return vp; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return vp; - return pixmaps[num]->ViewPort(); -} - -int cPixmapContainer::Width(int num) { - if (checkRunning && !Running()) - return 0; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return 0; - int width = pixmaps[num]->ViewPort().Width(); - return width; -} - -int cPixmapContainer::Height(int num) { - if (checkRunning && !Running()) - return 0; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return 0; - int height = pixmaps[num]->ViewPort().Height(); - return height; -} - -int cPixmapContainer::DrawportWidth(int num) { - if (checkRunning && !Running()) - return 0; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return 0; - int width = pixmaps[num]->DrawPort().Width(); - return width; -} - -int cPixmapContainer::DrawportHeight(int num) { - if (checkRunning && !Running()) - return 0; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return 0; - int height = pixmaps[num]->DrawPort().Height(); - return height; -} - -int cPixmapContainer::DrawportX(int num) { - if (checkRunning && !Running()) - return 0; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return 0; - int x = pixmaps[num]->DrawPort().X(); - return x; -} - -int cPixmapContainer::DrawportY(int num) { - if (checkRunning && !Running()) - return 0; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return 0; - int y = pixmaps[num]->DrawPort().Y(); - return y; -} - -void cPixmapContainer::SetDrawPortPoint(int num, const cPoint &Point) { - if (checkRunning && !Running()) - return; - cMutexLock MutexLock(&mutex); - if (!pixmaps[num]) - return; - pixmaps[num]->SetDrawPortPoint(Point); -} - -/*************************************************************************** -* HELPERS -- do not access the pixmaps array directly, use wrapper functions -* to ensure that a proper lock is set before accessing pixmaps -****************************************************************************/ - -int cPixmapContainer::AnimationDelay(void) { - int animTime = max(shiftTime, fadeTime); - return animTime + 100; -} - -void cPixmapContainer::FadeIn(void) { - if (!fadeTime) { - for (int i = 0; i < numPixmaps; i++) { - if (PixmapExists(i)) { - SetAlpha(i, pixmapsTransparency[i] ? pixmapsTransparency[i] : ALPHA_OPAQUE); - } - } - return; - } - int frames = fadeTime * config.framesPerSecond / 1000; - if (frames <= 0) frames = 1; - int frameTime = fadeTime / frames; - uint64_t Start = cTimeMs::Now(); - while (Running()) { - uint64_t Now = cTimeMs::Now(); - double t = min(double(Now - Start) / fadeTime, 1.0); - int Alpha = t * ALPHA_OPAQUE; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - int alpha = (double)pixmapsTransparency[i] / 255.0 * Alpha; - SetAlpha(i, alpha); - } - DoFlush(); - int Delta = cTimeMs::Now() - Now; - if (Running() && (Delta < frameTime)) - cCondWait::SleepMs(frameTime - Delta); - if ((int)(Now - Start) > fadeTime) - break; - } -} - -void cPixmapContainer::FadeOut(void) { - if (!fadeTime || IsAnimated()) - return; - int frames = fadeTime * config.framesPerSecond / 1000; - if (frames <= 0) frames = 1; - int frameTime = fadeTime / frames; - uint64_t Start = cTimeMs::Now(); - while (true) { - uint64_t Now = cTimeMs::Now(); - double t = min(double(Now - Start) / fadeTime, 1.0); - int Alpha = (1 - t) * ALPHA_OPAQUE; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - int alpha = (double)pixmapsTransparency[i] / 255.0 * Alpha; - SetAlpha(i, alpha); - } - DoFlush(); - int Delta = cTimeMs::Now() - Now; - if (Delta < frameTime) - cCondWait::SleepMs(frameTime - Delta); - if ((int)(Now - Start) > fadeTime) - break; - } -} - -void cPixmapContainer::ShiftIn(void) { - if (shiftTime < 1) - return; - - int frames = shiftTime * config.framesPerSecond / 1000; - if (frames <= 0) frames = 1; - int frameTime = shiftTime / frames; - - if (shiftType > stNone) { - ShiftInFromBorder(frames, frameTime); - } else { - ShiftInFromPoint(frames, frameTime); - } -} - -void cPixmapContainer::ShiftOut(void) { - if (shiftTime < 1) - return; - - int frames = shiftTime * config.framesPerSecond / 1000; - if (frames <= 0) frames = 1; - int frameTime = shiftTime / frames; - - if (shiftType > stNone) { - ShiftOutToBorder(frames, frameTime); - } else { - ShiftOutToPoint(frames, frameTime); - } -} - -void cPixmapContainer::ShiftInFromBorder(int frames, int frameTime) { - cRect unionArea = UnionPixmaps(); - //shifthing all pixmaps to dedicated start positions - cPoint startPositions[numPixmaps]; - int osdWidth = osd->Width(); - int osdHeight = osd->Height(); - int xStart = 0; - int yStart = 0; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - cPoint pos; - Pos(i, pos); - switch (shiftType) { - case stLeft: - xStart = pos.X() - (unionArea.X() + unionArea.Width()); - pos.SetX(xStart); - break; - case stRight: - xStart = osdWidth + (pos.X() - unionArea.X()); - pos.SetX(xStart); - break; - case stTop: - yStart = pos.Y() - (unionArea.Y() + unionArea.Height()); - pos.SetY(yStart); - break; - case stBottom: - yStart = osdHeight + (pos.Y() - unionArea.Y()); - pos.SetY(yStart); - break; - default: - break; - } - startPositions[i] = pos; - cRect r = ViewPort(i); - r.SetPoint(pos.X(), pos.Y()); - SetViewPort(i, r); - SetAlpha(i, pixmapsTransparency[i] ? pixmapsTransparency[i] : ALPHA_OPAQUE); - } - DoFlush(); - //Calculating total shifting distance - int shiftTotal = 0; - switch (shiftType) { - case stLeft: - shiftTotal = unionArea.X() + unionArea.Width(); - break; - case stRight: - shiftTotal = unionArea.Width() + (osdWidth - (unionArea.X() + unionArea.Width())); - break; - case stTop: - shiftTotal = unionArea.Y() + unionArea.Height(); - break; - case stBottom: - shiftTotal = unionArea.Height() + (osdHeight - (unionArea.Y() + unionArea.Height())); - break; - default: - break; - } - //Moving In - uint64_t Start = cTimeMs::Now(); - while (Running()) { - uint64_t Now = cTimeMs::Now(); - double t = min(double(Now - Start) / shiftTime, 1.0); - if (shiftMode == smSlowedDown) { - //using f(x) = -(x-1)^2 + 1 as mapping function - t = (-1)*pow(t - 1, 2) + 1; - } - int xNew = 0; - int yNew = 0; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - cRect r = ViewPort(i); - switch (shiftType) { - case stLeft: - xNew = startPositions[i].X() + t * shiftTotal; - r.SetPoint(xNew, r.Y()); - break; - case stRight: - xNew = startPositions[i].X() - t * shiftTotal; - r.SetPoint(xNew, r.Y()); - break; - case stTop: - yNew = startPositions[i].Y() + t * shiftTotal; - r.SetPoint(r.X(), yNew); - break; - case stBottom: - yNew = startPositions[i].Y() - t * shiftTotal; - r.SetPoint(r.X(), yNew); - break; - default: - break; - } - SetViewPort(i, r); - } - DoFlush(); - int Delta = cTimeMs::Now() - Now; - if (Running() && (Delta < frameTime)) { - cCondWait::SleepMs(frameTime - Delta); - } - if ((int)(Now - Start) > shiftTime) - break; - } -} - -void cPixmapContainer::ShiftOutToBorder(int frames, int frameTime) { - cRect unionArea = UnionPixmaps(); - //calculating end positions - cPoint startPositions[numPixmaps]; - int osdWidth = osd->Width(); - int osdHeight = osd->Height(); - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - cPoint pos; - Pos(i, pos); - startPositions[i] = pos; - } - //Calculating total shifting distance - int shiftTotal = 0; - switch (shiftType) { - case stLeft: - shiftTotal = unionArea.X() + unionArea.Width(); - break; - case stRight: - shiftTotal = unionArea.Width() + (osdWidth - (unionArea.X() + unionArea.Width())); - break; - case stTop: - shiftTotal = unionArea.Y() + unionArea.Height(); - break; - case stBottom: - shiftTotal = unionArea.Height() + (osdHeight - (unionArea.Y() + unionArea.Height())); - break; - default: - break; - } - //Moving Out - uint64_t Start = cTimeMs::Now(); - while (true) { - uint64_t Now = cTimeMs::Now(); - double t = min(double(Now - Start) / shiftTime, 1.0); - int xNew = 0; - int yNew = 0; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - cRect r = ViewPort(i); - switch (shiftType) { - case stLeft: - xNew = startPositions[i].X() - t * shiftTotal; - r.SetPoint(xNew, r.Y()); - break; - case stRight: - xNew = startPositions[i].X() + t * shiftTotal; - r.SetPoint(xNew, r.Y()); - break; - case stTop: - yNew = startPositions[i].Y() - t * shiftTotal; - r.SetPoint(r.X(), yNew); - break; - case stBottom: - yNew = startPositions[i].Y() + t * shiftTotal; - r.SetPoint(r.X(), yNew); - break; - default: - break; - } - SetViewPort(i, r); - } - DoFlush(); - int Delta = cTimeMs::Now() - Now; - if ((Delta < frameTime)) { - cCondWait::SleepMs(frameTime - Delta); - } - if ((int)(Now - Start) > shiftTime) - break; - } -} - -void cPixmapContainer::ShiftInFromPoint(int frames, int frameTime) { - //store original positions of pixmaps and move to StartPosition - cPoint destPos[numPixmaps]; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - cPoint pos; - Pos(i, pos); - destPos[i] = pos; - cRect r = ViewPort(i); - r.SetPoint(startPos); - SetViewPort(i, r); - SetAlpha(i, pixmapsTransparency[i] ? pixmapsTransparency[i] : ALPHA_OPAQUE); - } - DoFlush(); - //Move In - uint64_t Start = cTimeMs::Now(); - while (Running()) { - uint64_t Now = cTimeMs::Now(); - double t = min(double(Now - Start) / shiftTime, 1.0); - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - int x = startPos.X() + t * (destPos[i].X() - startPos.X()); - int y = startPos.Y() + t * (destPos[i].Y() - startPos.Y()); - cRect r = ViewPort(i); - r.SetPoint(x, y); - SetViewPort(i, r); - } - DoFlush(); - int Delta = cTimeMs::Now() - Now; - if (Running() && (Delta < frameTime)) - cCondWait::SleepMs(frameTime - Delta); - if ((int)(Now - Start) > shiftTime) - break; - } -} - -void cPixmapContainer::ShiftOutToPoint(int frames, int frameTime) { - //TODO -} - -cRect cPixmapContainer::UnionPixmaps(void) { - cRect unionArea; - bool isNew = true; - for (int i = 0; i < numPixmaps; i++) { - if (!PixmapExists(i)) - continue; - if (isNew) { - unionArea = ViewPort(i); - isNew = false; - } else { - unionArea.Combine(ViewPort(i)); - } - } - return unionArea; -} - -/***************************************** -* scrollSpeed: 1 slow -* 2 medium -* 3 fast -******************************************/ -void cPixmapContainer::ScrollHorizontal(int num, int scrollDelay, int scrollSpeed, int scrollMode) { - bool carriageReturn = (scrollMode == 1) ? true : false; - - int scrollDelta = 1; - int drawPortX; - - int FrameTime = 0; - if (scrollSpeed == 1) - FrameTime = 50; - else if (scrollSpeed == 2) - FrameTime = 30; - else - FrameTime = 15; - if (!Running()) - return; - int maxX = DrawportWidth(num) - Width(num); - bool doSleep = false; - while (Running()) { - if (doSleep) { - DoSleep(scrollDelay); - doSleep = false; - } - if (!Running()) - return; - uint64_t Now = cTimeMs::Now(); - drawPortX = DrawportX(num); - drawPortX -= scrollDelta; - - if (abs(drawPortX) > maxX) { - DoSleep(scrollDelay); - if (carriageReturn) - drawPortX = 0; - else { - scrollDelta *= -1; - drawPortX -= scrollDelta; - } - doSleep = true; - } - if (!carriageReturn && (drawPortX == 0)) { - scrollDelta *= -1; - doSleep = true; - } - SetDrawPortPoint(num, cPoint(drawPortX, 0)); - int Delta = cTimeMs::Now() - Now; - DoFlush(); - if (Running() && (Delta < FrameTime)) - cCondWait::SleepMs(FrameTime - Delta); - } -} - -/***************************************** -* scrollSpeed: 1 slow -* 2 medium -* 3 fast -******************************************/ -void cPixmapContainer::ScrollVertical(int num, int scrollDelay, int scrollSpeed) { - if (!scrollSpeed) - return; - DoSleep(scrollDelay); - int drawPortY; - int FrameTime = 0; - if (scrollSpeed == 1) - FrameTime = 50; - else if (scrollSpeed == 2) - FrameTime = 30; - else - FrameTime = 15; - int maxY = DrawportHeight(num) - Height(num); - bool doSleep = false; - while (Running()) { - if (doSleep) { - doSleep = false; - DoSleep(scrollDelay); - } - uint64_t Now = cTimeMs::Now(); - drawPortY = DrawportY(num); - drawPortY -= 1; - if (abs(drawPortY) > maxY) { - doSleep = true; - DoSleep(scrollDelay); - drawPortY = 0; - } - SetDrawPortPoint(num, cPoint(0, drawPortY)); - if (doSleep) { - DoSleep(scrollDelay); - } - int Delta = cTimeMs::Now() - Now; - DoFlush(); - if (Running() && (Delta < FrameTime)) - cCondWait::SleepMs(FrameTime - Delta); - } -} - -void cPixmapContainer::CancelSave(void) { - Cancel(-1); - while (Active()) - cCondWait::SleepMs(10); -} - -void cPixmapContainer::DoSleep(int duration) { - int sleepSlice = 10; - for (int i = 0; Running() && (i*sleepSlice < duration); i++) - cCondWait::SleepMs(sleepSlice); -} - -void cPixmapContainer::DrawBlendedBackground(int num, int xStart, int width, tColor color, tColor colorBlending, bool fromTop) { - int height = Height(num); - int numSteps = 16; - int alphaStep = 0x0F; - int alpha = 0x00; - int step, begin, end; - if (fromTop) { - step = 1; - begin = 0; - end = numSteps; - } else { - step = -1; - begin = height; - end = height - numSteps; - } - tColor clr; - bool cont = true; - for (int i = begin; cont; i = i + step) { - clr = AlphaBlend(color, colorBlending, alpha); - DrawRectangle(num, cRect(xStart,i,width,1), clr); - alpha += alphaStep; - if (i == end) - cont = false; - } -} - -void cPixmapContainer::DrawRoundedCorners(int num, int radius, int x, int y, int width, int height) { - if (radius > 2) { - DrawEllipse(num, cRect(x, y, radius, radius), clrTransparent, -2); - DrawEllipse(num, cRect(x + width - radius, y , radius, radius), clrTransparent, -1); - DrawEllipse(num, cRect(x, y + height - radius, radius, radius), clrTransparent, -3); - DrawEllipse(num, cRect(x + width - radius, y + height - radius, radius, radius), clrTransparent, -4); - } -} - -void cPixmapContainer::DrawRoundedCornersWithBorder(int num, tColor borderColor, int radius, int width, int height) { - if (radius < 3) - return; - DrawEllipse(num, cRect(0,0,radius,radius), borderColor, -2); - DrawEllipse(num, cRect(-1,-1,radius,radius), clrTransparent, -2); - - DrawEllipse(num, cRect(width-radius,0,radius,radius), borderColor, -1); - DrawEllipse(num, cRect(width-radius+1,-1,radius,radius), clrTransparent, -1); - - DrawEllipse(num, cRect(0,height-radius,radius,radius), borderColor, -3); - DrawEllipse(num, cRect(-1,height-radius+1,radius,radius), clrTransparent, -3); - - DrawEllipse(num, cRect(width-radius,height-radius,radius,radius), borderColor, -4); - DrawEllipse(num, cRect(width-radius+1,height-radius+1,radius,radius), clrTransparent, -4); -} diff --git a/libcore/pixmapcontainer.h b/libcore/pixmapcontainer.h deleted file mode 100644 index a116da0..0000000 --- a/libcore/pixmapcontainer.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __PIXMAP_CONTAINER_H -#define __PIXMAP_CONTAINER_H - -#include <string> -#include <vdr/plugin.h> -#include "fontmanager.h" - -enum eFlushState { - fsOpen, - fsLock, - fsCount, -}; - -class cPixmapContainer : public cThread { -private: - static cMutex mutex; - static cOsd *osd; - static eFlushState flushState; - bool pixContainerInit; - int numPixmaps; - cPixmap **pixmaps; - int *pixmapsTransparency; - int *pixmapsLayer; - bool checkRunning; - int fadeTime; - int shiftTime; - int shiftType; - int shiftMode; - cPoint startPos; - bool deleteOsdOnExit; - void ShiftInFromBorder(int frames, int frameTime); - void ShiftOutToBorder(int frames, int frameTime); - void ShiftInFromPoint(int frames, int frameTime); - void ShiftOutToPoint(int frames, int frameTime); - cRect UnionPixmaps(void); -protected: - void SetInitFinished(void) { pixContainerInit = false; }; - bool CreateOsd(int Left, int Top, int Width, int Height); - void DeleteOsdOnExit(bool doDelete = true) { deleteOsdOnExit = doDelete; }; - //Wrappers for access to pixmaps - bool PixmapExists(int num); - int NumPixmaps(void) { return numPixmaps; }; - void CreatePixmap(int num, int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); - bool DestroyPixmap(int num); - void DrawText(int num, const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, std::string fontName, int fontSize); - void DrawRectangle(int num, const cRect &Rect, tColor Color); - void DrawEllipse(int num, const cRect &Rect, tColor Color, int Quadrants = 0); - void DrawSlope(int num, const cRect &Rect, tColor Color, int Type); - void DrawImage(int num, const cPoint &Point, const cImage &Image); - void DrawBitmap(int num, const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false); - void Fill(int num, tColor Color); - void SetAlpha(int num, int Alpha); - void SetTransparency(int num, int Transparency); - void SetLayer(int num, int Layer); - void SetViewPort(int num, const cRect &rect); - int Layer(int num); - void Pos(int num, cPoint &pos); - cRect ViewPort(int num); - int Width(int num); - int Height(int num); - int DrawportWidth(int num); - int DrawportHeight(int num); - int DrawportX(int num); - int DrawportY(int num); - void SetDrawPortPoint(int num, const cPoint &Point); - void SetCheckRunning(void) { checkRunning = true; }; - void UnsetCheckRunning(void) { checkRunning = false; }; - //HELPERS -- do not access the pixmaps array directly, use wrapper functions - void SetFadeTime(int fade) { fadeTime = fade; }; - void SetShiftTime(int shift) { shiftTime = shift; }; - void SetShiftType(int type) { shiftType = type; }; - void SetShiftMode(int mode) { shiftMode = mode; }; - void SetStartPos(int posX, int posY) { startPos.SetX(posX); startPos.SetY(posY); }; - bool IsAnimated(void) { return (shiftTime > 0); }; - int AnimationDelay(void); - void FadeIn(void); - void FadeOut(void); - void ShiftIn(void); - void ShiftOut(void); - void ScrollVertical(int num, int scrollDelay, int scrollSpeed); - void ScrollHorizontal(int num, int scrollDelay, int scrollSpeed, int scrollMode); - void CancelSave(void); - void DoSleep(int duration); - void DrawBlendedBackground(int num, int xStart, int width, tColor color, tColor colorBlending, bool fromTop); - void DrawRoundedCorners(int num, int radius, int x, int y, int width, int height); - void DrawRoundedCornersWithBorder(int num, tColor borderColor, int radius, int width, int height); -public: - cPixmapContainer(int numPixmaps); - virtual ~cPixmapContainer(void); - void LockFlush(void); - void OpenFlush(void); - void DoFlush(void); - void HidePixmaps(void); - void ShowPixmaps(void); - virtual void Action(void) {}; -}; - -#endif //__PIXMAP_CONTAINER_H
\ No newline at end of file diff --git a/libskindesignerapi/Makefile b/libskindesignerapi/Makefile index 7948799..edff97c 100644 --- a/libskindesignerapi/Makefile +++ b/libskindesignerapi/Makefile @@ -3,7 +3,7 @@ NAME = skindesignerapi LIBNAME = lib$(NAME) MAJOR = 0 -MINOR = 0.2 +MINOR = 1.0 VERSION = $(MAJOR).$(MINOR) SONAME = $(LIBNAME).so.$(MAJOR) diff --git a/libskindesignerapi/osdelements.c b/libskindesignerapi/osdelements.c index 105a409..ae688ea 100644 --- a/libskindesignerapi/osdelements.c +++ b/libskindesignerapi/osdelements.c @@ -3,37 +3,37 @@ /********************************************************************** * cOsdElement **********************************************************************/ -skindesignerapi::cOsdElement::cOsdElement(skindesignerapi::ISkinDisplayPlugin *view) { +skindesignerapi::cOsdElement::cOsdElement(skindesignerapi::ISkinDisplayPlugin *view, int viewId) { this->view = view; + this->viewId = viewId; + tk = NULL; } skindesignerapi::cOsdElement::~cOsdElement() { } void skindesignerapi::cOsdElement::ClearTokens(void) { - stringTokens.clear(); - intTokens.clear(); - loopTokens.clear(); + tk->Clear(); } -void skindesignerapi::cOsdElement::AddStringToken(string key, string value) { - stringTokens.insert(pair<string,string>(key, value)); +int skindesignerapi::cOsdElement::GetLoopIndex(const char *loop) { + return tk->LoopIndex(loop); } -void skindesignerapi::cOsdElement::AddIntToken(string key, int value) { - intTokens.insert(pair<string,int>(key, value)); +void skindesignerapi::cOsdElement::SetLoop(vector<int> loopInfo) { + tk->CreateLoopTokenContainer(&loopInfo); } -void skindesignerapi::cOsdElement::AddLoopToken(string loopName, map<string, string> &tokens) { - map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName); - if (hitLoop == loopTokens.end()) { - vector<map<string, string> > tokenVector; - tokenVector.push_back(tokens); - loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector)); - } else { - vector<map<string, string> > *tokenVector = &hitLoop->second; - tokenVector->push_back(tokens); - } +void skindesignerapi::cOsdElement::AddStringToken(int index, const char *value) { + tk->AddStringToken(index, value); +} + +void skindesignerapi::cOsdElement::AddIntToken(int index, int value) { + tk->AddIntToken(index, value); +} + +void skindesignerapi::cOsdElement::AddLoopToken(int loopIndex, int row, int index, const char *value) { + tk->AddLoopToken(loopIndex, row, index, value); } bool skindesignerapi::cOsdElement::ChannelLogoExists(string channelId) { @@ -41,166 +41,162 @@ bool skindesignerapi::cOsdElement::ChannelLogoExists(string channelId) { } string skindesignerapi::cOsdElement::GetEpgImagePath(void) { - return view->GetEpgImagePath(); + return view->GetEpgImagePath(); } +void skindesignerapi::cOsdElement::DebugTokenContainer(void) { + tk->Debug(); +} /********************************************************************** * cViewElement **********************************************************************/ -skindesignerapi::cViewElement::cViewElement(skindesignerapi::ISkinDisplayPlugin *view, int viewElementID) : cOsdElement(view) { - this->viewElementID = viewElementID; +skindesignerapi::cViewElement::cViewElement(skindesignerapi::ISkinDisplayPlugin *view, int viewId, int viewElementId) : cOsdElement(view, viewId) { + this->viewElementId = viewElementId; } skindesignerapi::cViewElement::~cViewElement() { + view->ClearViewElement(viewElementId, viewId); } void skindesignerapi::cViewElement::Clear(void) { - if (!view) - return; - view->ClearViewElement(viewElementID); + view->ClearViewElement(viewElementId, viewId); } void skindesignerapi::cViewElement::Display(void) { - if (!view) - return; - view->SetViewElementIntTokens(&intTokens); - view->SetViewElementStringTokens(&stringTokens); - view->SetViewElementLoopTokens(&loopTokens); - view->DisplayViewElement(viewElementID); + view->SetViewElementTokens(viewElementId, viewId, tk); + view->DisplayViewElement(viewElementId, viewId); } /********************************************************************** * cViewGrid **********************************************************************/ -skindesignerapi::cViewGrid::cViewGrid(skindesignerapi::ISkinDisplayPlugin *view, int viewGridID) : cOsdElement(view) { - this->viewGridID = viewGridID; +skindesignerapi::cViewGrid::cViewGrid(skindesignerapi::ISkinDisplayPlugin *view, int viewId, int viewGridId) : cOsdElement(view, viewId) { + this->viewGridId = viewGridId; } skindesignerapi::cViewGrid::~cViewGrid() { - if (!view) - return; - view->ClearGrids(viewGridID); + view->ClearGrids(viewId, viewGridId); } -void skindesignerapi::cViewGrid::SetGrid(long gridID, double x, double y, double width, double height) { - if (!view) - return; - view->SetGrid(viewGridID, gridID, x, y, width, height, &intTokens, &stringTokens); +void skindesignerapi::cViewGrid::SetGrid(long gridId, double x, double y, double width, double height) { + view->SetGrid(gridId, viewId, viewGridId, x, y, width, height, tk); } -void skindesignerapi::cViewGrid::SetCurrent(long gridID, bool current) { - if (!view) - return; - view->SetGridCurrent(viewGridID, gridID, current); +void skindesignerapi::cViewGrid::SetCurrent(long gridId, bool current) { + view->SetGridCurrent(gridId, viewId, viewGridId, current); } -void skindesignerapi::cViewGrid::MoveGrid(long gridID, double x, double y, double width, double height) { - if (!view) - return; - view->SetGrid(viewGridID, gridID, x, y, width, height, NULL, NULL); +void skindesignerapi::cViewGrid::MoveGrid(long gridId, double x, double y, double width, double height) { + view->SetGrid(gridId, viewId, viewGridId, x, y, width, height, NULL); } -void skindesignerapi::cViewGrid::Delete(long gridID) { - if (!view) - return; - view->DeleteGrid(viewGridID, gridID); +void skindesignerapi::cViewGrid::Delete(long gridId) { + view->DeleteGrid(gridId, viewId, viewGridId); } void skindesignerapi::cViewGrid::Clear(void) { - if (!view) - return; - view->ClearGrids(viewGridID); + view->ClearGrids(viewId, viewGridId); } void skindesignerapi::cViewGrid::Display(void) { - if (!view) - return; - view->DisplayGrids(viewGridID); + view->DisplayGrids(viewId, viewGridId); } /********************************************************************** * cViewTab **********************************************************************/ -skindesignerapi::cViewTab::cViewTab(skindesignerapi::ISkinDisplayPlugin *view) : cOsdElement(view) { +skindesignerapi::cViewTab::cViewTab(skindesignerapi::ISkinDisplayPlugin *view, int viewId) : cOsdElement(view, viewId) { } skindesignerapi::cViewTab::~cViewTab() { + view->ClearTab(viewId); } void skindesignerapi::cViewTab::Init(void) { - view->SetTabIntTokens(&intTokens); - view->SetTabStringTokens(&stringTokens); - view->SetTabLoopTokens(&loopTokens); - view->SetTabs(); + view->SetTabTokens(viewId, tk); } void skindesignerapi::cViewTab::Left(void) { - view->TabLeft(); + view->TabLeft(viewId); } void skindesignerapi::cViewTab::Right(void) { - view->TabRight(); + view->TabRight(viewId); } void skindesignerapi::cViewTab::Up(void) { - view->TabUp(); + view->TabUp(viewId); } void skindesignerapi::cViewTab::Down(void) { - view->TabDown(); + view->TabDown(viewId); } void skindesignerapi::cViewTab::Display(void) { - if (!view) - return; - view->DisplayTabs(); + view->DisplayTabs(viewId); } /********************************************************************** * cOsdView **********************************************************************/ -skindesignerapi::cOsdView::cOsdView(skindesignerapi::ISkinDisplayPlugin *displayPlugin) { +skindesignerapi::cOsdView::cOsdView(skindesignerapi::cPluginStructure *plugStruct, skindesignerapi::ISkinDisplayPlugin *displayPlugin, int viewId) { + this->plugStruct = plugStruct; this->displayPlugin = displayPlugin; + this->viewId = viewId; } skindesignerapi::cOsdView::~cOsdView() { - delete displayPlugin; + if (displayPlugin && (viewId == 0)) + displayPlugin->CloseOsd(); } void skindesignerapi::cOsdView::Deactivate(bool hide) { if (!displayPlugin) return; - displayPlugin->Deactivate(hide); + displayPlugin->Deactivate(viewId, hide); } void skindesignerapi::cOsdView::Activate(void) { if (!displayPlugin) return; - displayPlugin->Activate(); + displayPlugin->Activate(viewId); } -skindesignerapi::cViewElement *skindesignerapi::cOsdView::GetViewElement(int viewElementID) { +skindesignerapi::cViewElement *skindesignerapi::cOsdView::GetViewElement(int viewElementId) { if (!displayPlugin) return NULL; - return new cViewElement(displayPlugin, viewElementID); + cTokenContainer *tk = plugStruct->GetTokenContainerVE(viewId, viewElementId); + if (!tk) + return NULL; + skindesignerapi::cViewElement *ve = new cViewElement(displayPlugin, viewId, viewElementId); + ve->SetTokenContainer(tk); + return ve; } -skindesignerapi::cViewGrid *skindesignerapi::cOsdView::GetViewGrid(int viewGridID) { +skindesignerapi::cViewGrid *skindesignerapi::cOsdView::GetViewGrid(int viewGridId) { if (!displayPlugin) return NULL; - displayPlugin->InitGrids(viewGridID); - return new cViewGrid(displayPlugin, viewGridID); + cTokenContainer *tk = plugStruct->GetTokenContainerGE(viewId, viewGridId); + if (!tk) + return NULL; + skindesignerapi::cViewGrid *ge = new cViewGrid(displayPlugin, viewId, viewGridId); + ge->SetTokenContainer(tk); + return ge; } skindesignerapi::cViewTab *skindesignerapi::cOsdView::GetViewTabs(void) { if (!displayPlugin) return NULL; - return new cViewTab(displayPlugin); + cTokenContainer *tk = plugStruct->GetTokenContainerTab(viewId); + if (!tk) + return NULL; + skindesignerapi::cViewTab *tab = new cViewTab(displayPlugin, viewId); + tab->SetTokenContainer(tk); + return tab; } void skindesignerapi::cOsdView::Display(void) { - if (!displayPlugin) - return; - displayPlugin->Flush(); + if (displayPlugin) + displayPlugin->Flush(); } diff --git a/libskindesignerapi/osdelements.h b/libskindesignerapi/osdelements.h index df6193f..816a219 100644 --- a/libskindesignerapi/osdelements.h +++ b/libskindesignerapi/osdelements.h @@ -12,19 +12,22 @@ namespace skindesignerapi { class cOsdElement { protected: + int viewId; ISkinDisplayPlugin *view; - map < string, string > stringTokens; - map < string, int > intTokens; - map < string, vector< map< string, string > > > loopTokens; + cTokenContainer *tk; public: - cOsdElement(ISkinDisplayPlugin *view); + cOsdElement(ISkinDisplayPlugin *view, int viewId); virtual ~cOsdElement(); - void AddLoopToken(string loopName, map<string, string> &tokens); - void AddStringToken(string key, string value); - void AddIntToken(string key, int value); + void SetTokenContainer(cTokenContainer *tk) { this->tk = tk; }; + int GetLoopIndex(const char *loop); + void SetLoop(vector<int> loopInfo); + void AddLoopToken(int loopIndex, int row, int index, const char *value); + void AddStringToken(int index, const char *value); + void AddIntToken(int index, int value); void ClearTokens(void); bool ChannelLogoExists(string channelId); string GetEpgImagePath(void); + void DebugTokenContainer(void); }; /********************************************************************** @@ -32,9 +35,9 @@ public: **********************************************************************/ class cViewElement : public cOsdElement { private: - int viewElementID; + int viewElementId; public: - cViewElement(ISkinDisplayPlugin *view, int viewElementID); + cViewElement(ISkinDisplayPlugin *view, int viewId, int viewElementId); virtual ~cViewElement(); void Clear(void); void Display(void); @@ -45,14 +48,14 @@ public: **********************************************************************/ class cViewGrid : public cOsdElement { private: - int viewGridID; + int viewGridId; public: - cViewGrid(ISkinDisplayPlugin *view, int viewGridID); + cViewGrid(ISkinDisplayPlugin *view, int viewId, int viewGridId); virtual ~cViewGrid(); - void SetGrid(long gridID, double x, double y, double width, double height); - void SetCurrent(long gridID, bool current); - void MoveGrid(long gridID, double x, double y, double width, double height); - void Delete(long gridID); + void SetGrid(long gridId, double x, double y, double width, double height); + void SetCurrent(long gridId, bool current); + void MoveGrid(long gridId, double x, double y, double width, double height); + void Delete(long gridId); void Clear(void); void Display(void); }; @@ -63,7 +66,7 @@ public: class cViewTab : public cOsdElement { private: public: - cViewTab(ISkinDisplayPlugin *view); + cViewTab(ISkinDisplayPlugin *view, int viewId); virtual ~cViewTab(); void Init(void); void Left(void); @@ -79,8 +82,10 @@ public: class cOsdView { private: ISkinDisplayPlugin *displayPlugin; + cPluginStructure *plugStruct; + int viewId; public: - cOsdView(ISkinDisplayPlugin *displayPlugin); + cOsdView(cPluginStructure *plugStruct, ISkinDisplayPlugin *displayPlugin, int viewId); virtual ~cOsdView(); void Deactivate(bool hide); void Activate(void); diff --git a/libskindesignerapi/pluginstructure.c b/libskindesignerapi/pluginstructure.c new file mode 100644 index 0000000..2d5d4f3 --- /dev/null +++ b/libskindesignerapi/pluginstructure.c @@ -0,0 +1,92 @@ +#include "pluginstructure.h"
+
+skindesignerapi::cPluginStructure::cPluginStructure(void) {
+ name = "";
+ libskindesignerAPIVersion = "undefined";
+ id = -1;
+ rootview = "";
+};
+
+skindesignerapi::cPluginStructure::~cPluginStructure(void) {
+ for (map<int,sPlugMenu>::iterator it = menus.begin(); it != menus.end(); it++) {
+ delete (it->second).tokenContainer;
+ }
+};
+
+void skindesignerapi::cPluginStructure::RegisterMenu(int key, int type, string tpl, skindesignerapi::cTokenContainer *tk) {
+ tk->CreateContainers();
+ sPlugMenu s;
+ s.type = type;
+ s.tplname = tpl;
+ s.tokenContainer = tk;
+ menus.insert(pair<int, sPlugMenu>(key, s));
+}
+
+skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetMenuTokenContainer(int key) {
+ map<int, sPlugMenu>::iterator hit = menus.find(key);
+ if (hit == menus.end())
+ return NULL;
+ return hit->second.tokenContainer;
+}
+
+void skindesignerapi::cPluginStructure::RegisterRootView(string templateName) {
+ rootview = templateName;
+}
+
+void skindesignerapi::cPluginStructure::RegisterSubView(int subView, string templateName) {
+ subviews.insert(pair<int, string>(subView, templateName));
+}
+
+void skindesignerapi::cPluginStructure::RegisterViewElement(int view, int viewElement, string name, skindesignerapi::cTokenContainer *tk) {
+ tk->CreateContainers();
+ sPlugViewElement ve;
+ ve.id = viewElement;
+ ve.viewId = view;
+ ve.name = name;
+ ve.tokenContainer = tk;
+ viewelements.insert(pair<int, sPlugViewElement>(view, ve));
+}
+
+void skindesignerapi::cPluginStructure::RegisterViewGrid(int view, int viewGrid, string name, skindesignerapi::cTokenContainer *tk) {
+ tk->CreateContainers();
+ sPlugViewGrid vg;
+ vg.id = viewGrid;
+ vg.viewId = view;
+ vg.name = name;
+ vg.tokenContainer = tk;
+ viewgrids.insert(pair<int, sPlugViewGrid>(view, vg));
+}
+
+void skindesignerapi::cPluginStructure::RegisterViewTab(int view, skindesignerapi::cTokenContainer *tk) {
+ tk->CreateContainers();
+ viewtabs.insert(pair<int, skindesignerapi::cTokenContainer*>(view, tk));
+}
+
+skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetTokenContainerVE(int viewId, int veId) {
+ pair<multimap<int, sPlugViewElement>::iterator, multimap<int, sPlugViewElement>::iterator> range;
+ range = viewelements.equal_range(viewId);
+ for (multimap<int, sPlugViewElement>::iterator it=range.first; it!=range.second; ++it) {
+ sPlugViewElement *ve = &it->second;
+ if (ve->id == veId)
+ return ve->tokenContainer;
+ }
+ return NULL;
+}
+
+skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetTokenContainerGE(int viewId, int geId) {
+ pair<multimap<int, sPlugViewGrid>::iterator, multimap<int, sPlugViewGrid>::iterator> range;
+ range = viewgrids.equal_range(viewId);
+ for (multimap<int, sPlugViewGrid>::iterator it=range.first; it!=range.second; ++it) {
+ sPlugViewGrid *ge = &it->second;
+ if (ge->id == geId)
+ return ge->tokenContainer;
+ }
+ return NULL;
+}
+
+skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetTokenContainerTab(int viewId) {
+ map<int,skindesignerapi::cTokenContainer*>::iterator hit = viewtabs.find(viewId);
+ if (hit == viewtabs.end())
+ return NULL;
+ return hit->second;
+}
diff --git a/libskindesignerapi/pluginstructure.h b/libskindesignerapi/pluginstructure.h new file mode 100644 index 0000000..f4ba281 --- /dev/null +++ b/libskindesignerapi/pluginstructure.h @@ -0,0 +1,57 @@ +#ifndef __PLUGINSTRUCTURE_H
+#define __PLUGINSTRUCTURE_H
+
+#include "tokencontainer.h"
+
+namespace skindesignerapi {
+
+struct sPlugMenu {
+ int type;
+ string tplname;
+ cTokenContainer *tokenContainer;
+};
+
+struct sPlugViewElement {
+ int id;
+ int viewId;
+ string name;
+ cTokenContainer *tokenContainer;
+};
+
+struct sPlugViewGrid {
+ int id;
+ int viewId;
+ string name;
+ cTokenContainer *tokenContainer;
+};
+
+class cPluginStructure {
+public:
+ cPluginStructure(void);
+ ~cPluginStructure(void);
+ void RegisterMenu(int key, int type, string tpl, cTokenContainer *tk);
+ cTokenContainer *GetMenuTokenContainer(int key);
+ void RegisterRootView(string templateName);
+ void RegisterSubView(int subView, string templateName);
+ void RegisterViewElement(int view, int viewElement, string name, cTokenContainer *tk);
+ void RegisterViewGrid(int view, int viewGrid, string name, cTokenContainer *tk);
+ void RegisterViewTab(int view, cTokenContainer *tk);
+ cTokenContainer *GetTokenContainerVE(int viewId, int veId);
+ cTokenContainer *GetTokenContainerGE(int viewId, int geId);
+ cTokenContainer *GetTokenContainerTab(int viewId);
+ string name; //name of plugin
+ string libskindesignerAPIVersion; //skindesigner API Version plugin is using
+ int id; //id of plugin in skindesigner
+ //basic plugin interface
+ map< int, sPlugMenu > menus; //menus as key -> sPlugMenu struct hashmap
+ //advanced plugin interface
+ string rootview; //template name of root view
+ map< int, string > subviews; //subviews as subviewid -> template name map
+ multimap< int, sPlugViewElement > viewelements; //viewelements as viewid -> sPlugViewElement struct multimap
+ multimap< int, sPlugViewGrid > viewgrids; //viewgrids as viewid -> sPlugViewGrid struct hashmap
+ map< int, cTokenContainer* > viewtabs; //viewtabs as viewid -> tokencontainer hashmap
+};
+
+
+}
+#endif //__PLUGINSTRUCTURE_H
\ No newline at end of file diff --git a/libskindesignerapi/skindesignerapi.c b/libskindesignerapi/skindesignerapi.c index 0cd024e..6308b3e 100644 --- a/libskindesignerapi/skindesignerapi.c +++ b/libskindesignerapi/skindesignerapi.c @@ -3,31 +3,37 @@ skindesignerapi::SkindesignerAPI *skindesignerapi::SkindesignerAPI::skindesigner = NULL; skindesignerapi::SkindesignerAPI::SkindesignerAPI(void) { - if (skindesigner != NULL) - esyslog("skindesigner should only be loaded once"); - else - skindesigner = this; + if (skindesigner != NULL) + esyslog("skindesigner should only be loaded once"); + else + skindesigner = this; } skindesignerapi::SkindesignerAPI::~SkindesignerAPI(void) { - if (skindesigner == this) - skindesigner = NULL; + if (skindesigner == this) + skindesigner = NULL; +} + +bool skindesignerapi::SkindesignerAPI::ServiceAvailable(void) { + if (skindesigner) + return true; + return false; } bool skindesignerapi::SkindesignerAPI::RegisterPlugin(cPluginStructure *plugStructure) { - if (skindesigner) - return skindesigner->ServiceRegisterPlugin(plugStructure); - return false; + if (skindesigner) + return skindesigner->ServiceRegisterPlugin(plugStructure); + return false; } skindesignerapi::ISDDisplayMenu *skindesignerapi::SkindesignerAPI::GetDisplayMenu() { - if (skindesigner) - return skindesigner->ServiceGetDisplayMenu(); - return NULL; + if (skindesigner) + return skindesigner->ServiceGetDisplayMenu(); + return NULL; } -skindesignerapi::ISkinDisplayPlugin *skindesignerapi::SkindesignerAPI::GetDisplayPlugin(string pluginName, int viewID, int subViewID) { - if (skindesigner) - return skindesigner->ServiceGetDisplayPlugin(pluginName, viewID, subViewID); - return NULL; -}
\ No newline at end of file +skindesignerapi::ISkinDisplayPlugin *skindesignerapi::SkindesignerAPI::GetDisplayPlugin(int plugId) { + if (skindesigner) + return skindesigner->ServiceGetDisplayPlugin(plugId); + return NULL; +} diff --git a/libskindesignerapi/skindesignerapi.h b/libskindesignerapi/skindesignerapi.h index f38e191..64155ae 100644 --- a/libskindesignerapi/skindesignerapi.h +++ b/libskindesignerapi/skindesignerapi.h @@ -7,92 +7,51 @@ using namespace std; #include <map> #include <vector> #include <vdr/osdbase.h> +#include "pluginstructure.h" +#include "tokencontainer.h" namespace skindesignerapi { +enum eMenuType { + mtList, + mtText +}; + class ISDDisplayMenu : public cSkinDisplayMenu { public: virtual void SetTitle(const char *Title) = 0; - virtual void SetPluginMenu(string name, int menu, int type, bool init) = 0; - virtual bool SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable) = 0; - virtual bool SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens) = 0; + virtual void SetPluginMenu(int plugId, int menuId, int type, bool init) = 0; + virtual bool SetItemPlugin(cTokenContainer *tk, int Index, bool Current, bool Selectable) = 0; + virtual bool SetPluginText(cTokenContainer *tk) = 0; }; class ISkinDisplayPlugin { public: virtual ~ISkinDisplayPlugin(void) {}; - virtual void Deactivate(bool hide) = 0; - virtual void Activate(void) = 0; - virtual void ClearViewElement(int id) = 0; - virtual void DisplayViewElement(int id) = 0; - virtual void SetViewElementIntTokens(map<string,int> *intTokens) = 0; - virtual void SetViewElementStringTokens(map<string,string> *stringTokens) = 0; - virtual void SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens) = 0; - virtual void InitGrids(int viewGridID) = 0; - virtual void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens) = 0; - virtual void SetGridCurrent(int viewGridID, long gridID, bool current) = 0; - virtual void DeleteGrid(int viewGridID, long gridID) = 0; - virtual void DisplayGrids(int viewGridID) = 0; - virtual void ClearGrids(int viewGridID) = 0; - virtual void SetTabIntTokens(map<string,int> *intTokens) = 0; - virtual void SetTabStringTokens(map<string,string> *stringTokens) = 0; - virtual void SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens) = 0; - virtual void SetTabs(void) = 0; - virtual void TabLeft(void) = 0; - virtual void TabRight(void) = 0; - virtual void TabUp(void) = 0; - virtual void TabDown(void) = 0; - virtual void DisplayTabs(void) = 0; + virtual bool InitOsd(void) = 0; + virtual void CloseOsd(void) = 0; + virtual void Deactivate(int viewId, bool hide) = 0; + virtual void Activate(int viewId) = 0; + virtual void SetViewElementTokens(int id, int viewId, skindesignerapi::cTokenContainer *tk) = 0; + virtual void ClearViewElement(int id, int viewId) = 0; + virtual void DisplayViewElement(int id, int viewId) = 0; + virtual void SetGrid(long id, int viewId, int viewGridId, double x, double y, double width, double height, skindesignerapi::cTokenContainer *tk) = 0; + virtual void SetGridCurrent(long id, int viewId, int viewGridId, bool current) = 0; + virtual void DeleteGrid(long id, int viewId, int viewGridId) = 0; + virtual void DisplayGrids(int viewId, int viewGridId) = 0; + virtual void ClearGrids(int viewId, int viewGridId) = 0; + virtual void SetTabTokens(int viewId, skindesignerapi::cTokenContainer *tk) = 0; + virtual void TabLeft(int viewId) = 0; + virtual void TabRight(int viewId) = 0; + virtual void TabUp(int viewId) = 0; + virtual void TabDown(int viewId) = 0; + virtual void DisplayTabs(int viewId) = 0; + virtual void ClearTab(int viewId) = 0; virtual void Flush(void) = 0; virtual bool ChannelLogoExists(string channelId) = 0; virtual string GetEpgImagePath(void) = 0; }; -class cPluginStructure { -public: - cPluginStructure(void) { - name = ""; - libskindesignerAPIVersion = "undefined"; - }; - void SetMenu(int key, string templateName) { - menus.insert(pair<int, string>(key, templateName)); - } - void SetView(int key, string templateName) { - views.insert(pair<int, string>(key, templateName)); - } - void SetSubView(int view, int subView, string templateName) { - pair<int, string> sub = make_pair(subView, templateName); - subViews.insert(pair<int, pair<int, string> >(view, sub)); - } - void SetViewElement(int view, int viewElement, string name) { - map< int, map<int, string> >::iterator hit = viewElements.find(view); - if (hit == viewElements.end()) { - map<int, string> vE; - vE.insert(pair<int, string >(viewElement, name)); - viewElements.insert(pair<int, map < int, string > >(view, vE)); - } else { - (hit->second).insert(pair<int, string >(viewElement, name)); - } - } - void SetViewGrid(int view, int viewGrid, string name) { - map< int, map<int, string> >::iterator hit = viewGrids.find(view); - if (hit == viewGrids.end()) { - map<int, string> vG; - vG.insert(pair<int, string >(viewGrid, name)); - viewGrids.insert(pair<int, map < int, string > >(view, vG)); - } else { - (hit->second).insert(pair<int, string >(viewGrid, name)); - } - } - string name; //name of plugin - string libskindesignerAPIVersion; //skindesigner API Version plugin is using - map< int, string > menus; //menus as key -> templatename hashmap - map< int, string> views; //standalone views as key -> templatename hashmap - multimap< int, pair <int, string> > subViews; //subviews of standalone views as view -> (subview, templatename) multimap - map< int, map <int, string> > viewElements; //viewelements as key -> (viewelement, viewelementname) hashmap - map< int, map <int, string> > viewGrids; //viewgrids as key -> (viewgrid, viewgridname) hashmap -}; - class SkindesignerAPI { private: static SkindesignerAPI* skindesigner; @@ -101,11 +60,12 @@ protected: virtual ~SkindesignerAPI(void); virtual bool ServiceRegisterPlugin(cPluginStructure *plugStructure) = 0; virtual ISDDisplayMenu *ServiceGetDisplayMenu(void) = 0; - virtual ISkinDisplayPlugin *ServiceGetDisplayPlugin(string pluginName, int viewID, int subViewID) = 0; + virtual ISkinDisplayPlugin *ServiceGetDisplayPlugin(int plugId) = 0; public: + static bool ServiceAvailable(void); static bool RegisterPlugin(cPluginStructure *plugStructure); static ISDDisplayMenu *GetDisplayMenu(void); - static ISkinDisplayPlugin *GetDisplayPlugin(string pluginName, int viewID, int subViewID); + static ISkinDisplayPlugin *GetDisplayPlugin(int plugId); }; } diff --git a/libskindesignerapi/skindesignerosdbase.c b/libskindesignerapi/skindesignerosdbase.c index f552664..ed3ee73 100644 --- a/libskindesignerapi/skindesignerosdbase.c +++ b/libskindesignerapi/skindesignerosdbase.c @@ -4,44 +4,61 @@ * cSkindesignerOsdObject **********************************************************************/ -skindesignerapi::cSkindesignerOsdObject::cSkindesignerOsdObject(void) { - pluginName = ""; +skindesignerapi::cSkindesignerOsdObject::cSkindesignerOsdObject(cPluginStructure *plugStruct) { + this->plugStruct = plugStruct; + init = true; } skindesignerapi::cSkindesignerOsdObject::~cSkindesignerOsdObject() { } -bool skindesignerapi::cSkindesignerOsdObject::InitSkindesignerInterface(string pluginName) { - this->pluginName = pluginName; - return true; -} - -skindesignerapi::cOsdView *skindesignerapi::cSkindesignerOsdObject::GetOsdView(int viewID, int subViewID) { - ISkinDisplayPlugin *displayPlugin = SkindesignerAPI::GetDisplayPlugin(pluginName, viewID, subViewID); +skindesignerapi::cOsdView *skindesignerapi::cSkindesignerOsdObject::GetOsdView(int subViewId) { + ISkinDisplayPlugin *displayPlugin = SkindesignerAPI::GetDisplayPlugin(plugStruct->id); if (!displayPlugin) return NULL; - cOsdView *view = new cOsdView(displayPlugin); + if (init) { + init = false; + if (!displayPlugin->InitOsd()) { + esyslog("skindesignerapi: error opening osd"); + return NULL; + } + } + cOsdView *view = NULL; + if (subViewId > -1) + view = new cOsdView(plugStruct, displayPlugin, subViewId); + else { + view = new cOsdView(plugStruct, displayPlugin, 0); + } return view; } +bool skindesignerapi::cSkindesignerOsdObject::SkindesignerAvailable(void) { + return SkindesignerAPI::ServiceAvailable(); +} + + /********************************************************************** * cSkindesignerOsdItem **********************************************************************/ -skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) { +skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(cTokenContainer *tk, eOSState State) : cOsdItem(State) { sdDisplayMenu = NULL; + tokenContainer = new skindesignerapi::cTokenContainer(*tk); + tokenContainer->CreateContainers(); } -skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) { +skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(cTokenContainer *tk, const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) { sdDisplayMenu = NULL; + tokenContainer = new skindesignerapi::cTokenContainer(*tk); + tokenContainer->CreateContainers(); } skindesignerapi::cSkindesignerOsdItem::~cSkindesignerOsdItem() { - + delete tokenContainer; } void skindesignerapi::cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) { if (sdDisplayMenu) { - if (!sdDisplayMenu->SetItemPlugin(&stringTokens, &intTokens, &loopTokens, Index, Current, Selectable)) { + if (!sdDisplayMenu->SetItemPlugin(tokenContainer, Index, Current, Selectable)) { DisplayMenu->SetItem(Text(), Index, Current, Selectable); } } else { @@ -49,59 +66,61 @@ void skindesignerapi::cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *Displa } } -void skindesignerapi::cSkindesignerOsdItem::AddStringToken(string key, string value) { - stringTokens.insert(pair<string,string>(key, value)); +int skindesignerapi::cSkindesignerOsdItem::GetLoopIndex(const char *loop) { + return tokenContainer->LoopIndex(loop); } -void skindesignerapi::cSkindesignerOsdItem::AddIntToken(string key, int value) { - intTokens.insert(pair<string,int>(key, value)); +void skindesignerapi::cSkindesignerOsdItem::SetLoop(vector<int> loopInfo) { + tokenContainer->CreateLoopTokenContainer(&loopInfo); } -void skindesignerapi::cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &tokens) { - map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName); - if (hitLoop == loopTokens.end()) { - vector<map<string, string> > tokenVector; - tokenVector.push_back(tokens); - loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector)); - } else { - vector<map<string, string> > *tokenVector = &hitLoop->second; - tokenVector->push_back(tokens); - } +void skindesignerapi::cSkindesignerOsdItem::AddStringToken(int index, const char *value) { + tokenContainer->AddStringToken(index, value); +} + +void skindesignerapi::cSkindesignerOsdItem::AddIntToken(int index, int value) { + tokenContainer->AddIntToken(index, value); +} + +void skindesignerapi::cSkindesignerOsdItem::AddLoopToken(int loopIndex, int row, int index, const char *value) { + tokenContainer->AddLoopToken(loopIndex, row, index, value); } /********************************************************************** * cSkindesignerOsdMenu **********************************************************************/ -skindesignerapi::cSkindesignerOsdMenu::cSkindesignerOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) { +skindesignerapi::cSkindesignerOsdMenu::cSkindesignerOsdMenu(skindesignerapi::cPluginStructure *plugStruct, const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) { + this->plugStruct = plugStruct; + tokenContainer = NULL; init = true; + activeMenu = 0; firstCallCleared = false; secondCall = false; firstMenu = -1; firstType = mtList; displayText = false; sdDisplayMenu = NULL; - pluginName = ""; SetMenuCategory(mcPlugin); SetSkinDesignerDisplayMenu(); } skindesignerapi::cSkindesignerOsdMenu::~cSkindesignerOsdMenu() { - } -void skindesignerapi::cSkindesignerOsdMenu::SetPluginMenu(int menu, eMenuType type) { +void skindesignerapi::cSkindesignerOsdMenu::SetPluginMenu(int menuId, eMenuType type) { + activeMenu = menuId; if (firstCallCleared) { - firstMenu = menu; + firstMenu = menuId; firstType = type; } if (type == mtList) displayText = false; else if (type == mtText) displayText = true; - if (sdDisplayMenu) { - sdDisplayMenu->SetPluginMenu(pluginName, menu, type, init); + int plugId = plugStruct->id; + sdDisplayMenu->SetPluginMenu(plugId, menuId, type, init); } init = false; } @@ -113,29 +132,32 @@ bool skindesignerapi::cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) { void skindesignerapi::cSkindesignerOsdMenu::ClearTokens(void) { text = ""; - stringTokens.clear(); - intTokens.clear(); - loopTokens.clear(); + if (tokenContainer) + tokenContainer->Clear(); } -void skindesignerapi::cSkindesignerOsdMenu::AddStringToken(string key, string value) { - stringTokens.insert(pair<string,string>(key, value)); +int skindesignerapi::cSkindesignerOsdMenu::GetLoopIndex(const char *loop) { + return tokenContainer->LoopIndex(loop); } -void skindesignerapi::cSkindesignerOsdMenu::AddIntToken(string key, int value) { - intTokens.insert(pair<string,int>(key, value)); +void skindesignerapi::cSkindesignerOsdMenu::SetLoop(vector<int> loopInfo) { + tokenContainer->CreateLoopTokenContainer(&loopInfo); } -void skindesignerapi::cSkindesignerOsdMenu::AddLoopToken(string loopName, map<string, string> &tokens) { - map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName); - if (hitLoop == loopTokens.end()) { - vector<map<string, string> > tokenVector; - tokenVector.push_back(tokens); - loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector)); - } else { - vector<map<string, string> > *tokenVector = &hitLoop->second; - tokenVector->push_back(tokens); - } +void skindesignerapi::cSkindesignerOsdMenu::SetTokenContainer(cTokenContainer *tk) { + tokenContainer = tk; +} + +void skindesignerapi::cSkindesignerOsdMenu::AddStringToken(int index, const char *value) { + tokenContainer->AddStringToken(index, value); +} + +void skindesignerapi::cSkindesignerOsdMenu::AddIntToken(int index, int value) { + tokenContainer->AddIntToken(index, value); +} + +void skindesignerapi::cSkindesignerOsdMenu::AddLoopToken(int loopIndex, int row, int index, const char *value) { + tokenContainer->AddLoopToken(loopIndex, row, index, value); } void skindesignerapi::cSkindesignerOsdMenu::TextKeyLeft(void) { @@ -162,6 +184,12 @@ void skindesignerapi::cSkindesignerOsdMenu::TextKeyDown(void) { DisplayMenu()->Scroll(false, false); } +skindesignerapi::cTokenContainer *skindesignerapi::cSkindesignerOsdMenu::GetTokenContainer(int menuId) { + if (!plugStruct) + return NULL; + return plugStruct->GetMenuTokenContainer(menuId); +} + void skindesignerapi::cSkindesignerOsdMenu::Display(void) { if (firstCallCleared) { firstCallCleared = false; @@ -174,11 +202,13 @@ void skindesignerapi::cSkindesignerOsdMenu::Display(void) { } if (displayText) { if (sdDisplayMenu) { + sdDisplayMenu->SetMenuCategory(mcPlugin); sdDisplayMenu->SetTitle(Title()); - if (sdDisplayMenu->SetPluginText(&stringTokens, &intTokens, &loopTokens)) { + if (tokenContainer && sdDisplayMenu->SetPluginText(tokenContainer)) { sdDisplayMenu->Flush(); } else { DisplayMenu()->Clear(); + DisplayMenu()->SetMenuCategory(mcText); DisplayMenu()->SetTitle(Title()); DisplayMenu()->SetText(text.c_str(), false); DisplayMenu()->Flush(); @@ -192,6 +222,7 @@ void skindesignerapi::cSkindesignerOsdMenu::Display(void) { return; } if (sdDisplayMenu) { + //sdDisplayMenu->SetMenuCategory(mcPlugin); sdDisplayMenu->SetTitle(Title()); for (cOsdItem *item = First(); item; item = Next(item)) { cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item); diff --git a/libskindesignerapi/skindesignerosdbase.h b/libskindesignerapi/skindesignerosdbase.h index 1b41092..baa7999 100644 --- a/libskindesignerapi/skindesignerosdbase.h +++ b/libskindesignerapi/skindesignerosdbase.h @@ -13,11 +13,6 @@ namespace skindesignerapi { -enum eMenuType { - mtList, - mtText -}; - class cOsdView; /********************************************************************** @@ -25,11 +20,12 @@ class cOsdView; **********************************************************************/ class cSkindesignerOsdObject : public cOsdObject { protected: - string pluginName; - bool InitSkindesignerInterface(string pluginName); - cOsdView *GetOsdView(int viewID, int subViewID = -1); + bool init; + cPluginStructure *plugStruct; + cOsdView *GetOsdView(int subViewId = -1); + bool SkindesignerAvailable(void); public: - cSkindesignerOsdObject(void); + cSkindesignerOsdObject(cPluginStructure *plugStruct); virtual ~cSkindesignerOsdObject(); virtual void Show(void) {}; }; @@ -40,19 +36,19 @@ public: class cSkindesignerOsdItem : public cOsdItem { private: ISDDisplayMenu *sdDisplayMenu; - map < string, string > stringTokens; - map < string, int > intTokens; - map < string, vector< map< string, string > > > loopTokens; + cTokenContainer *tokenContainer; protected: public: - cSkindesignerOsdItem(eOSState State = osUnknown); - cSkindesignerOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true); + cSkindesignerOsdItem(cTokenContainer *tk, eOSState State = osUnknown); + cSkindesignerOsdItem(cTokenContainer *tk, const char *Text, eOSState State = osUnknown, bool Selectable = true); virtual ~cSkindesignerOsdItem(); virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable); void SetDisplayMenu(ISDDisplayMenu *sdDisplayMenu) { this->sdDisplayMenu = sdDisplayMenu; }; - void AddStringToken(string key, string value); - void AddIntToken(string key, int value); - void AddLoopToken(string loopName, map<string, string> &tokens); + int GetLoopIndex(const char *loop); + void SetLoop(vector<int> loopInfo); + void AddStringToken(int index, const char *value); + void AddIntToken(int index, int value); + void AddLoopToken(int loopIndex, int row, int index, const char *value); }; /********************************************************************** @@ -60,34 +56,37 @@ public: **********************************************************************/ class cSkindesignerOsdMenu : public cOsdMenu { private: + cPluginStructure *plugStruct; + cTokenContainer *tokenContainer; + int activeMenu; bool init; bool firstCallCleared; bool secondCall; int firstMenu; eMenuType firstType; bool displayText; - string pluginName; ISDDisplayMenu *sdDisplayMenu; string text; - map < string, string > stringTokens; - map < string, int > intTokens; - map < string, vector< map< string, string > > > loopTokens; bool SetSkinDesignerDisplayMenu(void); protected: + void SetPluginName(const char *name); void FirstCallCleared(void) { firstCallCleared = true; }; void ClearTokens(void); - void SetPluginName(string name) {pluginName = name; }; - void SetPluginMenu(int menu, eMenuType type); + void SetTokenContainer(cTokenContainer *tk); + void SetPluginMenu(int menuId, eMenuType type); void SetText(string text) { this->text = text; }; - void AddStringToken(string key, string value); - void AddIntToken(string key, int value); - void AddLoopToken(string loopName, map<string, string> &tokens); + int GetLoopIndex(const char *loop); + void SetLoop(vector<int> loopInfo); + void AddStringToken(int index, const char *value); + void AddIntToken(int index, int value); + void AddLoopToken(int loopIndex, int row, int index, const char *value); void TextKeyLeft(void); void TextKeyRight(void); void TextKeyUp(void); void TextKeyDown(void); + cTokenContainer *GetTokenContainer(int menuId); public: - cSkindesignerOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); + cSkindesignerOsdMenu(skindesignerapi::cPluginStructure *plugStruct, const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); virtual ~cSkindesignerOsdMenu(); virtual void Display(void); }; diff --git a/libskindesignerapi/tokencontainer.c b/libskindesignerapi/tokencontainer.c new file mode 100644 index 0000000..00df1f2 --- /dev/null +++ b/libskindesignerapi/tokencontainer.c @@ -0,0 +1,305 @@ +#include "tokencontainer.h"
+
+skindesignerapi::cTokenContainer::cTokenContainer(void) {
+ numIntTokens = 0;
+ numStringTokens = 0;
+ stringTokens = NULL;
+ intTokens = NULL;
+ stNames = NULL;
+ itNames = NULL;
+}
+
+skindesignerapi::cTokenContainer::cTokenContainer(const cTokenContainer &other) {
+ numIntTokens = 0;
+ numStringTokens = 0;
+ stringTokens = NULL;
+ intTokens = NULL;
+ stNames = NULL;
+ itNames = NULL;
+ stringTokenNames = other.stringTokenNames;
+ intTokenNames = other.intTokenNames;
+ loopTokenNames = other.loopTokenNames;
+ loopNameMapping = other.loopNameMapping;
+}
+
+skindesignerapi::cTokenContainer::~cTokenContainer(void) {
+ Clear();
+ delete[] intTokens;
+ delete[] stringTokens;
+ delete[] stNames;
+ delete[] itNames;
+}
+
+void skindesignerapi::cTokenContainer::CreateContainers(void) {
+ numIntTokens = intTokenNames.size();
+ if (numIntTokens) {
+ intTokens = new int[numIntTokens];
+ itNames = new string[numIntTokens];
+ for (int i=0; i < numIntTokens; i++) {
+ intTokens[i] = -1;
+ itNames[i] = GetIntTokenName(i);
+ }
+ }
+ numStringTokens = stringTokenNames.size();
+ if (numStringTokens) {
+ stringTokens = new char*[numStringTokens];
+ stNames = new string[numStringTokens];
+ for (int i=0; i < numStringTokens; i++) {
+ stringTokens[i] = NULL;
+ stNames[i] = GetStringTokenName(i);
+ }
+ }
+
+ int numLoops = loopTokenNames.size();
+ for (int i = 0; i < numLoops; ++i) {
+ vector<string> loopToken;
+ int numLoopTokens = loopTokenNames[i].size();
+ for (int j = 0; j < numLoopTokens; ++j) {
+ string tokenName = GetLoopTokenName(i, j);
+ loopToken.push_back(tokenName);
+ }
+ ltNames.push_back(loopToken);
+ }
+}
+
+void skindesignerapi::cTokenContainer::CreateLoopTokenContainer(vector<int> *loopInfo) {
+ int numLoops = loopInfo->size();
+ for (int i = 0; i < numLoops; ++i) {
+ numLoopTokens.push_back(loopInfo->at(i));
+ int rows = loopInfo->at(i);
+ char*** loopToks = new char**[rows];
+ for (int j = 0; j < rows ; ++j) {
+ int numLoopTokens = loopTokenNames[i].size();
+ loopToks[j] = new char*[numLoopTokens];
+ for (int k = 0; k < numLoopTokens; ++k) {
+ loopToks[j][k] = NULL;
+ }
+ }
+ loopTokens.push_back(loopToks);
+ }
+}
+
+void skindesignerapi::cTokenContainer::DeleteLoopTokenContainer(void) {
+ int i = 0;
+ for (vector<char***>::iterator it = loopTokens.begin(); it != loopTokens.end(); it++) {
+ char*** loopToks = *it;
+ for (int j = 0; j < numLoopTokens[i] ; j++) {
+ int numToks = loopTokenNames[i].size();
+ for (int k = 0; k < numToks; ++k) {
+ free(loopToks[j][k]);
+ }
+ delete[] loopToks[j];
+ }
+ delete[] loopToks;
+ ++i;
+ }
+ loopTokens.clear();
+ numLoopTokens.clear();
+}
+
+void skindesignerapi::cTokenContainer::DefineStringToken(string name, int index) {
+ stringTokenNames.insert(pair<string, int>(name, index));
+}
+
+void skindesignerapi::cTokenContainer::DefineIntToken(string name, int index) {
+ intTokenNames.insert(pair<string, int>(name, index));
+}
+
+void skindesignerapi::cTokenContainer::DefineLoopToken(string name, int index) {
+ string loopName = LoopName(name);
+ int loopIndex = LoopIndex(loopName, true);
+ if ((int)loopTokenNames.size() < loopIndex+1) {
+ map<string, int> newloop;
+ newloop.insert(pair<string, int>(name, index));
+ loopTokenNames.push_back(newloop);
+ return;
+ }
+ loopTokenNames[loopIndex].insert(pair<string, int>(name, index));
+}
+
+int skindesignerapi::cTokenContainer::GetNumDefinedIntTokens(void) {
+ return intTokenNames.size();
+}
+
+int skindesignerapi::cTokenContainer::LoopIndex(string name, bool createNew) {
+ map<string, int>::iterator hit = loopNameMapping.find(name);
+ if (hit != loopNameMapping.end())
+ return hit->second;
+ if (!createNew)
+ return -1;
+ int index = loopNameMapping.size();
+ loopNameMapping.insert(pair<string, int>(name, index));
+ return index;
+}
+
+int skindesignerapi::cTokenContainer::StringTokenIndex(string name) {
+ map<string, int>::iterator hit = stringTokenNames.find(name);
+ if (hit == stringTokenNames.end())
+ return -1;
+ return hit->second;
+}
+
+int skindesignerapi::cTokenContainer::IntTokenIndex(string name) {
+ map<string, int>::iterator hit = intTokenNames.find(name);
+ if (hit == intTokenNames.end())
+ return -1;
+ return hit->second;
+}
+
+int skindesignerapi::cTokenContainer::LoopTokenIndex(string name) {
+ string loopName = LoopName(name);
+ int loopIndex = LoopIndex(loopName);
+ if (loopIndex > -1 && loopIndex < (int)loopTokenNames.size()) {
+ map<string, int>::iterator hit = loopTokenNames[loopIndex].find(name);
+ if (hit == loopTokenNames[loopIndex].end())
+ return -1;
+ return hit->second;
+ }
+ return -1;
+}
+
+void skindesignerapi::cTokenContainer::AddIntToken(int index, int value) {
+ intTokens[index] = value;
+}
+
+void skindesignerapi::cTokenContainer::AddStringToken(int index, const char *value) {
+ if (value)
+ stringTokens[index] = strdup(value);
+}
+
+void skindesignerapi::cTokenContainer::AddLoopToken(int loopIndex, int row, int index, const char *value) {
+ if (value) {
+ loopTokens[loopIndex][row][index] = strdup(value);
+ }
+}
+
+int skindesignerapi::cTokenContainer::NumLoops(int loopIndex) {
+ int numLT = numLoopTokens.size();
+ if (loopIndex >= 0 && loopIndex < numLT)
+ return numLoopTokens[loopIndex];
+ return 0;
+}
+
+void skindesignerapi::cTokenContainer::SetTokens(cTokenContainer *other) {
+ //Set Int and String Tokens
+ if (numIntTokens) {
+ for (int i=0; i < numIntTokens; i++) {
+ AddIntToken(i, other->IntToken(i));
+ }
+ }
+ if (numStringTokens) {
+ for (int i=0; i < numStringTokens; i++) {
+ AddStringToken(i, other->StringToken(i));
+ }
+ }
+ //Set Looptoken Container
+ set<int> loopIndices;
+ for (map<string, int>::iterator it = loopNameMapping.begin(); it != loopNameMapping.end(); it++) {
+ loopIndices.insert(it->second);
+ }
+ vector<int> loopInfo;
+ for (set<int>::iterator it = loopIndices.begin(); it != loopIndices.end(); it++) {
+ loopInfo.push_back(other->NumLoops(*it));
+ }
+ CreateLoopTokenContainer(&loopInfo);
+ //Set Loop Tokens
+ int i = 0;
+ for (vector<int>::iterator it = loopInfo.begin(); it != loopInfo.end(); it++) {
+ int numRows = *it;
+ int numCols = loopTokenNames[i].size();
+ for (int j = 0; j < numRows; j++) {
+ for (int k = 0; k < numCols; k++) {
+ AddLoopToken(i, j, k, other->LoopToken(i, j, k));
+ }
+ }
+ i++;
+ }
+}
+
+void skindesignerapi::cTokenContainer::Clear(void) {
+ if (numIntTokens) {
+ for (int i=0; i < numIntTokens; i++) {
+ intTokens[i] = -1;
+ }
+ }
+ if (numStringTokens) {
+ for (int i=0; i < numStringTokens; i++) {
+ free(stringTokens[i]);
+ stringTokens[i] = NULL;
+ }
+ }
+ DeleteLoopTokenContainer();
+}
+
+void skindesignerapi::cTokenContainer::Debug(void) {
+ /*
+ esyslog("skindesigner: TokenContainer defined string tokens");
+ for (map<string, int>::iterator it = stringTokenNames.begin(); it != stringTokenNames.end(); it++) {
+ esyslog("skindesigner: name %s id %d", (it->first).c_str(), it->second);
+ }
+ esyslog("skindesigner: TokenContainer defined int tokens");
+ for (map<string, int>::iterator it = intTokenNames.begin(); it != intTokenNames.end(); it++) {
+ esyslog("skindesigner: name %s id %d", (it->first).c_str(), it->second);
+ }
+ */
+ esyslog("skindesigner: TokenContainer content");
+ for (int i=0; i < numStringTokens; i++) {
+ if (stringTokens[i])
+ esyslog("skindesigner: stringtoken %d. %s: \"%s\"", i, stNames[i].c_str(), stringTokens[i]);
+ else
+ esyslog("skindesigner: stringtoken %d. %s: empty", i, stNames[i].c_str());
+ }
+ for (int i=0; i < numIntTokens; i++) {
+ if (intTokens[i] >= 0)
+ esyslog("skindesigner: inttoken %d. %s: %d", i, itNames[i].c_str(), intTokens[i]);
+ else
+ esyslog("skindesigner: inttoken %d. %s: empty", i, itNames[i].c_str());
+ }
+
+ for (size_t i=0; i < loopTokens.size(); i++) {
+ for (int j = 0; j < numLoopTokens[i]; j++) {
+ esyslog("skindesigner: row %d", j);
+ for (size_t k = 0; k < loopTokenNames[i].size(); k++) {
+ if (loopTokens[i][j][k])
+ esyslog("skindesigner: looptoken %d. %s: \"%s\"", (int)k, ltNames[i][k].c_str(), loopTokens[i][j][k]);
+ else
+ esyslog("skindesigner: looptoken %d. %s: empty", (int)k, ltNames[i][k].c_str());
+ }
+ }
+ }
+}
+
+
+string skindesignerapi::cTokenContainer::GetStringTokenName(int id) {
+ for (map<string, int>::iterator it = stringTokenNames.begin(); it != stringTokenNames.end(); it++) {
+ if (it->second == id)
+ return it->first;
+ }
+ return "";
+}
+string skindesignerapi::cTokenContainer::GetIntTokenName(int id) {
+ for (map<string, int>::iterator it = intTokenNames.begin(); it != intTokenNames.end(); it++) {
+ if (it->second == id)
+ return it->first;
+ }
+ return "";
+}
+
+string skindesignerapi::cTokenContainer::GetLoopTokenName(int loop, int id) {
+ for (map<string, int>::iterator it = loopTokenNames[loop].begin(); it != loopTokenNames[loop].end(); it++) {
+ if (it->second == id)
+ return it->first;
+ }
+ return "";
+}
+
+//Get name of loop from a loop token name
+string skindesignerapi::cTokenContainer::LoopName(string &loopToken) {
+ size_t hit = loopToken.find('{');
+ if (hit != 0)
+ return "";
+ hit = loopToken.find('[');
+ if (hit == string::npos)
+ return "";
+ return loopToken.substr(1, hit-1);
+}
diff --git a/libskindesignerapi/tokencontainer.h b/libskindesignerapi/tokencontainer.h new file mode 100644 index 0000000..86d8652 --- /dev/null +++ b/libskindesignerapi/tokencontainer.h @@ -0,0 +1,69 @@ +#ifndef __TOKENCONTAINER_H
+#define __TOKENCONTAINER_H
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <set>
+#include <vdr/plugin.h>
+
+using namespace std;
+
+namespace skindesignerapi {
+
+class cTokenContainer {
+private:
+ int numIntTokens;
+ int numStringTokens;
+ vector<int> numLoopTokens;
+ //token containers
+ char **stringTokens;
+ int *intTokens;
+ vector<char***>loopTokens;
+ //mapping id --> name
+ string *stNames;
+ string *itNames;
+ vector< vector<string> > ltNames;
+ //mapping name --> id
+ map<string, int> stringTokenNames;
+ map<string, int> intTokenNames;
+ vector< map<string, int> > loopTokenNames;
+ //get token name from id
+ string GetStringTokenName(int id);
+ string GetIntTokenName(int id);
+ string GetLoopTokenName(int loop, int id);
+ //looptoken management
+ string LoopName(string &loopToken);
+ map<string, int> loopNameMapping;
+ void DeleteLoopTokenContainer(void);
+public:
+ cTokenContainer(void);
+ cTokenContainer(const cTokenContainer &other);
+ ~cTokenContainer(void);
+ void CreateContainers(void);
+ void CreateLoopTokenContainer(vector<int> *loopInfo);
+ void DefineStringToken (string name, int index);
+ void DefineIntToken (string name, int index);
+ void DefineLoopToken (string name, int index);
+ int GetNumDefinedIntTokens(void);
+ int LoopIndex (string name, bool createNew = false);
+ int StringTokenIndex (string name);
+ int IntTokenIndex (string name);
+ int LoopTokenIndex (string name);
+ void AddIntToken (int index, int value);
+ void AddStringToken (int index, const char *value);
+ void AddLoopToken (int loopIndex, int row, int index, const char *value);
+ char *StringToken (int index) { return stringTokens[index]; };
+ int IntToken (int index) { return intTokens[index]; };
+ char *LoopToken (int i, int j, int k) { return loopTokens[i][j][k]; };
+ int NumLoops (int loopIndex);
+ void SetTokens (cTokenContainer *other);
+ void Clear(void);
+ void Debug(void);
+};
+
+}
+#endif //__TOKENCONTAINER_H
\ No newline at end of file diff --git a/libtemplate/parameter.c b/libtemplate/parameter.c deleted file mode 100644 index d76cb35..0000000 --- a/libtemplate/parameter.c +++ /dev/null @@ -1,493 +0,0 @@ -#include "../config.h" -#include "parameter.h" - -using namespace std; - -// --- cNumericParameter ------------------------------------------------------------- - -cNumericParameter::cNumericParameter(string value) { - this->value = value; - globals = NULL; - isValid = false; - width = 0; - height = 0; - columnWidth = -1; - rowHeight = -1; - hor = true; - defaultValue = 0; -} - -cNumericParameter::~cNumericParameter(void) { -} - -void cNumericParameter::SetAreaSize(int w, int h) { - width = w; - height = h; -} - -int cNumericParameter::Parse(string &parsedValue) { - int retVal = defaultValue; - - if (IsNumber(value)) { - isValid = true; - retVal = atoi(value.c_str()); - return retVal; - } - - //checking for percent value - bool isPercentValue = CheckPercentValue(retVal); - if (isPercentValue) { - isValid = true; - return retVal; - } - - //checking for expression - bool isValidExpression = CheckExpression(retVal, parsedValue); - if (isValidExpression) { - isValid = true; - return retVal; - } - - return retVal; -} - -bool cNumericParameter::IsNumber(const string& s) { - string::const_iterator it = s.begin(); - while (it != s.end() && isdigit(*it)) ++it; - return !s.empty() && it == s.end(); -} - -bool cNumericParameter::CheckPercentValue(int &val) { - bool ok = false; - size_t posPercent = value.find('%'); - if (posPercent != string::npos) { - string strPerc = value.substr(0, posPercent); - if (!IsNumber(strPerc)) { - return ok; - } - int perc = atoi(strPerc.c_str()); - if (hor) { - val = width * perc / 100; - } else { - val = height * perc / 100; - } - ok = true; - } - return ok; -} - -bool cNumericParameter::CheckExpression(int &val, string &parsedVal) { - bool ok = false; - string parsedValue = value; - //remove white spaces - parsedValue.erase( std::remove_if( parsedValue.begin(), parsedValue.end(), ::isspace ), parsedValue.end() ); - - //check and replace {areawidth} and {areaheight} tokens - string tokenWidth = "{areawidth}"; - string tokenHeight = "{areaheight}"; - - stringstream sw; - sw << width; - string strWidth = sw.str(); - stringstream sh; - sh << height; - string strHeight = sh.str(); - - bool foundToken = true; - while(foundToken) { - size_t foundTokenWidth = parsedValue.find(tokenWidth); - if (foundTokenWidth != string::npos) { - parsedValue = parsedValue.replace(foundTokenWidth, tokenWidth.size(), strWidth); - } else { - foundToken = false; - } - } - - foundToken = true; - while(foundToken) { - size_t foundTokenHeight = parsedValue.find(tokenHeight); - if (foundTokenHeight != string::npos) { - parsedValue = parsedValue.replace(foundTokenHeight, tokenHeight.size(), strHeight); - } else { - foundToken = false; - } - } - - //check and replace {columnwidth} and {rowheight} tokens for loop functions - if (columnWidth > 0 || rowHeight > 0) { - tokenWidth = "{columnwidth}"; - tokenHeight = "{rowheight}"; - stringstream cw; - cw << columnWidth; - strWidth = cw.str(); - stringstream rh; - rh << rowHeight; - strHeight = rh.str(); - - foundToken = true; - while(foundToken) { - size_t foundTokenWidth = parsedValue.find(tokenWidth); - if (foundTokenWidth != string::npos) { - parsedValue = parsedValue.replace(foundTokenWidth, tokenWidth.size(), strWidth); - } else { - foundToken = false; - } - } - - foundToken = true; - while(foundToken) { - size_t foundTokenHeight = parsedValue.find(tokenHeight); - if (foundTokenHeight != string::npos) { - parsedValue = parsedValue.replace(foundTokenHeight, tokenHeight.size(), strHeight); - } else { - foundToken = false; - } - } - } - - if (globals) { - globals->ReplaceIntVars(parsedValue); - globals->ReplaceDoubleVars(parsedValue); - } - - if (IsNumber(parsedValue)) { - ok = true; - val = atoi(parsedValue.c_str()); - return ok; - } - - if (!ValidNumericExpression(parsedValue)) { - parsedVal = parsedValue; - return ok; - } - ok = true; - char * expression = new char[parsedValue.size() + 1]; - std::copy(parsedValue.begin(), parsedValue.end(), expression); - expression[parsedValue.size()] = '\0'; - int expRes = EvaluateTheExpression(expression); - val = expRes; - delete[] expression; - return ok; -} - -bool cNumericParameter::ValidNumericExpression(string &parsedValue) { - string::const_iterator it = parsedValue.begin(); - while (it != parsedValue.end() && (isdigit(*it) || *it == '.' || *it == ',' || *it == '+' || *it == '-' || *it == '*' || *it == '/')) ++it; - return !parsedValue.empty() && it == parsedValue.end(); -} - -int cNumericParameter::EvaluateTheExpression(char* expr) { - return round(ParseSummands(expr)); -} - -double cNumericParameter::ParseAtom(char*& expr) { - // Read the number from string - char* end_ptr; - double res = strtod(expr, &end_ptr); - // Advance the pointer and return the result - expr = end_ptr; - return res; -} - -// Parse multiplication and division -double cNumericParameter::ParseFactors(char*& expr) { - double num1 = ParseAtom(expr); - for(;;) { - // Save the operation - char op = *expr; - if(op != '/' && op != '*') - return num1; - expr++; - double num2 = ParseAtom(expr); - // Perform the saved operation - if(op == '/') { - if (num2 != 0) { - num1 /= num2; - } - } else - num1 *= num2; - } -} - -// Parse addition and subtraction -double cNumericParameter::ParseSummands(char*& expr) { - double num1 = ParseFactors(expr); - for(;;) { - char op = *expr; - if(op != '-' && op != '+') - return num1; - expr++; - double num2 = ParseFactors(expr); - if(op == '-') - num1 -= num2; - else - num1 += num2; - } -} - -// --- cConditionalParameter ------------------------------------------------------------- - -cConditionalParameter::cConditionalParameter(cGlobals *globals, string value) { - this->globals = globals; - isTrue = false; - this->value = value; - type = cpNone; -} - -cConditionalParameter::~cConditionalParameter(void) { -} - -void cConditionalParameter::Tokenize(void) { - size_t posAnd = value.find("++"); - if (posAnd != string::npos) { - type = cpAnd; - TokenizeValue("++"); - } else { - size_t posOr = value.find("||"); - if (posOr != string::npos) { - type = cpOr; - TokenizeValue("||"); - } - } - if (type == cpNone) { - InsertCondition(value); - } -} - -void cConditionalParameter::Evaluate(map < string, int > *intTokens, map < string, string > *stringTokens) { - isTrue = false; - bool first = true; - for (vector<sCondition>::iterator cond = conditions.begin(); cond != conditions.end(); cond++) { - bool tokenTrue = false; - - if (cond->type == ctStringSet) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.size() > 0) - tokenTrue = true; - } - } - } else if (cond->type == ctStringEmpty) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.size() == 0) - tokenTrue = true; - } else { - tokenTrue = true; - } - } else { - tokenTrue = true; - } - } else if (cond->type == ctStringEquals) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (!value.compare(cond->strCompareValue)) - tokenTrue = true; - } - } - if (!tokenTrue) { - string value = ""; - if (globals->GetString(cond->tokenName, value)) { - if (!value.compare(cond->strCompareValue)) { - tokenTrue = true; - } - } - } - } else if (cond->type == ctStringNotEquals) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.compare(cond->strCompareValue)) - tokenTrue = true; - } else { - tokenTrue = true; - } - } else { - tokenTrue = true; - } - } else if (cond->type == ctStringContains) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.find(cond->strCompareValue) != string::npos) - tokenTrue = true; - } - } - if (!tokenTrue) { - string value = ""; - if (globals->GetString(cond->tokenName, value)) { - if (value.find(cond->strCompareValue) != string::npos) { - tokenTrue = true; - } - } - } - } else if (cond->type == ctStringNotContains) { - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(cond->tokenName); - if (hit != stringTokens->end()) { - string value = hit->second; - if (value.find(cond->strCompareValue) == string::npos) - tokenTrue = true; - } else { - tokenTrue = true; - } - } else { - tokenTrue = true; - } - } else { - int tokenValue = EvaluateParameter(cond->tokenName, intTokens, stringTokens); - if (cond->type == ctBool) { - tokenTrue = tokenValue; - } else if (cond->type == ctGreater) { - tokenTrue = (tokenValue > cond->compareValue) ? true : false; - } else if (cond->type == ctLower) { - tokenTrue = (tokenValue < cond->compareValue) ? true : false; - } else if (cond->type == ctEquals) { - tokenTrue = (tokenValue == cond->compareValue) ? true : false; - } - } - - if (cond->isNegated) - tokenTrue = !tokenTrue; - if (type == cpAnd) { - if (first) - isTrue = tokenTrue; - else - isTrue = isTrue && tokenTrue; - } else if (type == cpOr) { - isTrue = isTrue || tokenTrue; - } else { - isTrue = tokenTrue; - } - first = false; - } -} - -int cConditionalParameter::EvaluateParameter(string token, map < string, int > *intTokens, map < string, string > *stringTokens) { - //first check globals - int result = 0; - if (globals->GetInt(token, result)) - return result; - //then check custom tokens - if (globals->GetCustomInt(token, result)) - return result; - //then check tokens - if (intTokens) { - map < string, int >::iterator hit = intTokens->find(token); - if (hit != intTokens->end()) { - return hit->second; - } - } - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(token); - if (hit != stringTokens->end()) { - string value = hit->second; - return atoi(value.c_str()); - } - } - return 0; -} - -void cConditionalParameter::TokenizeValue(string sep) { - string buffer = value; - bool sepFound = true; - while (sepFound) { - size_t posSep = buffer.find(sep); - if (posSep == string::npos) { - InsertCondition(buffer); - sepFound = false; - } - string token = buffer.substr(0, posSep); - buffer = buffer.replace(0, posSep + sep.size(), ""); - InsertCondition(token); - } -} - -void cConditionalParameter::InsertCondition(string cond) { - cond = StripWhitespaces(cond); - if (cond.size() < 1) - return; - - size_t tokenStart = cond.find('{'); - size_t tokenEnd = cond.find('}'); - - if (tokenStart == string::npos || tokenEnd == string::npos || tokenStart > tokenEnd) - return; - - string tokenName = cond.substr(tokenStart + 1, tokenEnd - tokenStart - 1); - string rest = cond.replace(tokenStart, tokenEnd - tokenStart + 1, ""); - - sCondition sCond; - sCond.tokenName = tokenName; - sCond.type = ctBool; - sCond.compareValue = 0; - sCond.strCompareValue = ""; - sCond.isNegated = false; - if (!rest.compare("not")) { - sCond.isNegated = true; - } else if (!rest.compare("isset")) { - sCond.type = ctStringSet; - } else if (!rest.compare("empty")) { - sCond.type = ctStringEmpty; - } else if (startswith(rest.c_str(), "strequal(")) { - sCond.strCompareValue = rest.substr(10, rest.size() - 11); - sCond.type = ctStringEquals; - } else if (startswith(rest.c_str(), "strnotequal(")) { - sCond.strCompareValue = rest.substr(13, rest.size() - 14); - sCond.type = ctStringNotEquals; - } else if (startswith(rest.c_str(), "strcontains(")) { - sCond.strCompareValue = rest.substr(13, rest.size() - 14); - sCond.type = ctStringContains; - } else if (startswith(rest.c_str(), "strnotcontains(")) { - sCond.strCompareValue = rest.substr(16, rest.size() - 17); - sCond.type = ctStringNotContains; - } else if (startswith(rest.c_str(), "gt(")) { - string compVal = rest.substr(4, rest.size() - 5); - sCond.compareValue = atoi(compVal.c_str()); - sCond.type = ctGreater; - } else if (startswith(rest.c_str(), "lt(")) { - string compVal = rest.substr(4, rest.size() - 5); - sCond.compareValue = atoi(compVal.c_str()); - sCond.type = ctLower; - } else if (startswith(rest.c_str(), "eq(")) { - string compVal = rest.substr(4, rest.size() - 5); - sCond.compareValue = atoi(compVal.c_str()); - sCond.type = ctEquals; - } - - conditions.push_back(sCond); -} - -string cConditionalParameter::StripWhitespaces(string value) { - size_t startEqual = value.find("strequal("); - size_t startNotEqual = value.find("strnotequal("); - size_t startContains = value.find("strcontains("); - size_t startNotContains = value.find("strnotcontains("); - if (startEqual != string::npos || startContains != string::npos || startNotEqual != string::npos || startNotContains != string::npos) { - size_t startString = value.find_first_of('\''); - size_t stopString = value.find_last_of('\''); - string text = value.substr(startString + 1, stopString - startString - 1); - value.replace(startString, stopString - startString + 1, "xxxxxx"); - value.erase( std::remove_if( value.begin(), value.end(), ::isspace ), value.end() ); - size_t startPlaceholder = value.find("xxxxxx"); - value.replace(startPlaceholder, 6, text); - } else { - value.erase( std::remove_if( value.begin(), value.end(), ::isspace ), value.end() ); - } - return value; -} - -void cConditionalParameter::Debug(void) { - dsyslog("skindesigner: Condition %s, Type: %s, cond is %s", value.c_str(), (type == cpAnd)?"and combination":((type == cpOr)?"or combination":"single param") , isTrue?"true":"false"); - for (vector<sCondition>::iterator it = conditions.begin(); it != conditions.end(); it++) { - dsyslog("skindesigner: cond token %s, type: %d, compareValue %d, negated: %d, strCompareValue %s", it->tokenName.c_str(), it->type, it->compareValue, it->isNegated, it->strCompareValue.c_str()); - } -}
\ No newline at end of file diff --git a/libtemplate/parameter.h b/libtemplate/parameter.h deleted file mode 100644 index 0a4ca23..0000000 --- a/libtemplate/parameter.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef __TEMPLATEPARAMETER_H -#define __TEMPLATEPARAMETER_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <algorithm> -#include <math.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" - -using namespace std; - -enum eAlign { - alLeft, - alCenter, - alRight, - alTop, - alBottom -}; - -enum eScrollMode { - smNone, - smCarriageReturn, - smForthAndBack -}; - -enum eScrollSpeed { - ssNone, - ssSlow, - ssMedium, - ssFast -}; - -enum eOrientation { - orNone, - orHorizontal, - orVertical, - orAbsolute -}; - -// --- cNumericParameter ------------------------------------------------------------- - -class cNumericParameter { -private: - cGlobals *globals; - string value; - bool isValid; - int width; - int height; - int columnWidth; - int rowHeight; - bool hor; - int defaultValue; - bool IsNumber(const string& s); - bool CheckPercentValue(int &val); - bool CheckExpression(int &val, string &parsedVal); - bool ValidNumericExpression(string &parsedValue); - int EvaluateTheExpression(char* expr); - double ParseAtom(char*& expr); - double ParseFactors(char*& expr); - double ParseSummands(char*& expr); -public: - cNumericParameter(string value); - virtual ~cNumericParameter(void); - void SetGlobals(cGlobals *globals) { this->globals = globals; }; - void SetAreaSize(int w, int h); - void SetLoopContainer(int columnWidth, int rowHeight) { this->columnWidth = columnWidth; this->rowHeight = rowHeight; }; - void SetDefault(int def) { defaultValue = def; }; - void SetHorizontal(void) { hor = true; }; - void SetVertical(void) { hor = false; }; - int Parse(string &parsedValue); - bool Valid(void) { return isValid; }; -}; - -// --- cTextToken ------------------------------------------------------------- - -enum eTextTokenType { - ttConstString, - ttToken, - ttConditionalToken, - ttPrintfToken -}; - -class cTextToken { -public: - eTextTokenType type; - string value; - vector<string> parameters; - vector<cTextToken> subTokens; -}; - -// --- cConditionalParameter ------------------------------------------------------------- - -enum eCondParameterType { - cpAnd, - cpOr, - cpNone -}; - -enum eCondType { - ctLower, - ctGreater, - ctEquals, - ctBool, - ctStringSet, - ctStringEmpty, - ctStringEquals, - ctStringNotEquals, - ctStringContains, - ctStringNotContains, - ctNone -}; - -struct sCondition { - string tokenName; - bool isNegated; - eCondType type; - int compareValue; - string strCompareValue; -}; - -class cConditionalParameter { -private: - cGlobals *globals; - bool isTrue; - string value; - eCondParameterType type; - vector<sCondition> conditions; - void TokenizeValue(string sep); - void InsertCondition(string cond); - string StripWhitespaces(string value); - int EvaluateParameter(string token, map < string, int > *intTokens, map < string, string > *stringTokens); -public: - cConditionalParameter(cGlobals *globals, string value); - virtual ~cConditionalParameter(void); - void Tokenize(void); - void Evaluate(map < string, int > *intTokens, map < string, string > *stringTokens); - bool IsTrue(void) { return isTrue; }; - void Debug(void); -}; -#endif //__TEMPLATEPARAMETER_H
\ No newline at end of file diff --git a/libtemplate/template.c b/libtemplate/template.c deleted file mode 100644 index 43fd3da..0000000 --- a/libtemplate/template.c +++ /dev/null @@ -1,322 +0,0 @@ - #include "template.h" -#include "xmlparser.h" -#include "../config.h" - -// --- cTemplate ------------------------------------------------------------- - -cTemplate::cTemplate(eViewType viewType, string pluginName, int viewID) { - globals = NULL; - rootView = NULL; - this->viewType = viewType; - CreateView(pluginName, viewID); -} - -cTemplate::~cTemplate() { - if (rootView) - delete rootView; - -} - -/******************************************************************* -* Public Functions -*******************************************************************/ -bool cTemplate::ReadFromXML(string xmlfile) { - string xmlFile; - switch (viewType) { - case vtDisplayChannel: - xmlFile = "displaychannel.xml"; - break; - case vtDisplayMenu: - xmlFile = "displaymenu.xml"; - break; - case vtDisplayMessage: - xmlFile = "displaymessage.xml"; - break; - case vtDisplayReplay: - xmlFile = "displayreplay.xml"; - break; - case vtDisplayVolume: - xmlFile = "displayvolume.xml"; - break; - case vtDisplayAudioTracks: - xmlFile = "displayaudiotracks.xml"; - break; - case vtDisplayPlugin: - xmlFile = xmlfile; - break; - default: - return false; - } - - cXmlParser parser; - if (!parser.ReadView(rootView, xmlFile)) { - return false; - } - if (!parser.ParseView()) { - return false; - } - - //read additional plugin menu templates - bool ok = true; - if (viewType == vtDisplayMenu) { - config.InitPluginMenuIterator(); - map <int,string> *plugTemplates = NULL; - string plugName; - while ( plugTemplates = config.GetPluginTemplates(plugName) ) { - for (map <int,string>::iterator it = plugTemplates->begin(); it != plugTemplates->end(); it++) { - int templateNumber = it->first; - stringstream templateName; - templateName << "plug-" << plugName << "-" << it->second.c_str(); - if (parser.ReadPluginView(plugName, templateNumber, templateName.str())) { - ok = parser.ParsePluginView(plugName, templateNumber); - } else { - dsyslog("skindesigner: template %s for plugin %s not available", templateName.str().c_str(), plugName.c_str()); - } - } - } - } - return ok; -} - -void cTemplate::SetGlobals(cGlobals *globals) { - this->globals = globals; - rootView->SetGlobals(globals); -} - -void cTemplate::Translate(void) { - rootView->Translate(); -} - - -void cTemplate::PreCache(void) { - rootView->PreCache(false); -} - -vector< pair<string, int> > cTemplate::GetUsedFonts(void) { - vector< pair<string, int> > usedFonts; - - GetUsedFonts(rootView, usedFonts); - - rootView->InitSubViewIterator(); - cTemplateView *subView = NULL; - while(subView = rootView->GetNextSubView()) { - GetUsedFonts(subView, usedFonts); - } - - return usedFonts; -} - - -void cTemplate::CacheImages(void) { - CacheImages(rootView); - rootView->InitSubViewIterator(); - cTemplateView *subView = NULL; - while(subView = rootView->GetNextSubView()) { - CacheImages(subView); - } -} - -bool cTemplate::SetSubViews(string plugName, int viewID) { - map <int,string> subViews = config.GetPluginSubViews(plugName, viewID); - - if (subViews.size() == 0) { - return true; - } - - for (map<int,string>::iterator it = subViews.begin(); it != subViews.end(); it ++) { - int subViewID = it->first; - stringstream templateName; - templateName << "plug-" << plugName << "-" << it->second; - string subViewTemplate = templateName.str(); - cTemplateView *plgTemplateView = new cTemplateViewPlugin(plugName, subViewID); - plgTemplateView->SetGlobals(globals); - cXmlParser parser; - if (!parser.ReadView(plgTemplateView, subViewTemplate)) { - esyslog("skindesigner: error reading plugin %s template", plugName.c_str()); - delete plgTemplateView; - return false; - } - if (!parser.ParseView()) { - esyslog("skindesigner: error reading plugin %s template", plugName.c_str()); - delete plgTemplateView; - return false; - } - stringstream svid; - svid << subViewID; - rootView->AddSubView(svid.str(), plgTemplateView); - } - return true; -} - - -void cTemplate::Debug(void) { - rootView->Debug(); -} - -/******************************************************************* -* Private Functions -*******************************************************************/ - -void cTemplate::CreateView(string pluginName, int viewID) { - switch (viewType) { - case vtDisplayChannel: - rootView = new cTemplateViewChannel(); - break; - case vtDisplayMenu: - rootView = new cTemplateViewMenu(); - break; - case vtDisplayReplay: - rootView = new cTemplateViewReplay(); - break; - case vtDisplayVolume: - rootView = new cTemplateViewVolume(); - break; - case vtDisplayAudioTracks: - rootView = new cTemplateViewAudioTracks(); - break; - case vtDisplayMessage: - rootView = new cTemplateViewMessage(); - break; - case vtDisplayPlugin: - rootView = new cTemplateViewPlugin(pluginName, viewID); - break; - default: - esyslog("skindesigner: unknown view %d", viewType); - } -} - -void cTemplate::GetUsedFonts(cTemplateView *view, vector< pair<string, int> > &usedFonts) { - //used fonts in viewElements - view->InitViewElementIterator(); - cTemplateViewElement *viewElement = NULL; - while(viewElement = view->GetNextViewElement()) { - viewElement->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } - } - //used fonts in viewLists pixmaps - view->InitViewListIterator(); - cTemplateViewList *viewList = NULL; - while(viewList = view->GetNextViewList()) { - viewList->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewList->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } - cTemplateViewElement *listElement = viewList->GetListElement(); - listElement->InitPixmapIterator(); - while(pix = listElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } - } - //used fonts in viewTabs - view->InitViewTabIterator(); - cTemplateViewTab *viewTab = NULL; - while(viewTab = view->GetNextViewTab()) { - viewTab->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = viewTab->GetNextFunction()) { - if (func->GetType() == ftDrawText) { - usedFonts.push_back(pair<string,int>(func->GetFontName(), func->GetNumericParameter(ptFontSize))); - } - } - } -} - -void cTemplate::CacheImages(cTemplateView *view) { - //used images in viewElements - view->InitViewElementIterator(); - cTemplateViewElement *viewElement = NULL; - while(viewElement = view->GetNextViewElement()) { - viewElement->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewElement->GetNextPixmap()) { - CachePixmapImages(pix); - } - } - //used images in viewLists pixmaps - view->InitViewListIterator(); - cTemplateViewList *viewList = NULL; - while(viewList = view->GetNextViewList()) { - viewList->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewList->GetNextPixmap()) { - CachePixmapImages(pix); - } - cTemplateViewElement *listElement = viewList->GetListElement(); - listElement->InitPixmapIterator(); - while(pix = listElement->GetNextPixmap()) { - CachePixmapImages(pix); - } - cTemplateViewElement *currentElement = viewList->GetListElementCurrent(); - if (!currentElement) { - continue; - } - currentElement->InitPixmapIterator(); - while(pix = currentElement->GetNextPixmap()) { - CachePixmapImages(pix); - } - } - //used images in viewTabs - view->InitViewTabIterator(); - cTemplateViewTab *viewTab = NULL; - while(viewTab = view->GetNextViewTab()) { - CachePixmapImages(viewTab); - } -} - -void cTemplate::CachePixmapImages(cTemplatePixmap *pix) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawImage) { - CacheImage(func); - } - } -} - -void cTemplate::CacheImage(cTemplateFunction *func) { - eImageType imgType = (eImageType)func->GetNumericParameter(ptImageType); - int width = func->GetNumericParameter(ptWidth); - int height = func->GetNumericParameter(ptHeight); - - switch (imgType) { - case itIcon: - case itMenuIcon: { - string path = func->GetParameter(ptPath); - imgCache->CacheIcon(imgType, path, width, height); - break; } - case itChannelLogo: { - string doCache = func->GetParameter(ptCache); - if (!doCache.compare("true")) { - imgCache->CacheLogo(width, height); - } - break; } - case itSkinPart: { - string path = func->GetParameter(ptPath); - imgCache->CacheSkinpart(path, width, height); - break; } - default: - break; - } -} diff --git a/libtemplate/template.h b/libtemplate/template.h deleted file mode 100644 index 75dce5c..0000000 --- a/libtemplate/template.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __TEMPLATE_H -#define __TEMPLATE_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" -#include "templateview.h" -#include "templateviewelement.h" -#include "templatepixmap.h" -#include "templatefunction.h" - -using namespace std; - -// --- cTemplate ------------------------------------------------------------- -enum eViewType { - vtDisplayChannel, - vtDisplayMenu, - vtDisplayReplay, - vtDisplayVolume, - vtDisplayAudioTracks, - vtDisplayMessage, - vtDisplayPlugin -}; - -class cTemplate { -private: - eViewType viewType; - void CachePixmapImages(cTemplatePixmap *pix); - void CacheImage(cTemplateFunction *func); -protected: - cGlobals *globals; - cTemplateView *rootView; - void CreateView(string pluginName, int viewID); - void GetUsedFonts(cTemplateView *view, vector< pair<string, int> > &usedFonts); - void CacheImages(cTemplateView *view); -public: - cTemplate(eViewType viewType, string pluginName = "", int viewID = -1); - virtual ~cTemplate(void); - bool ReadFromXML(string xmlfile = ""); - void SetGlobals(cGlobals *globals); - cTemplateView *GetRootView(void) { return rootView; }; - void Translate(void); - void PreCache(void); - //get fonts for pre caching - vector< pair<string, int> > GetUsedFonts(void); - void CacheImages(void); - //Set Plugin Subviews - bool SetSubViews(string plugName, int viewID); - //Debug - void Debug(void); -}; - -#endif //__TEMPLATE_H
\ No newline at end of file diff --git a/libtemplate/templatefunction.c b/libtemplate/templatefunction.c deleted file mode 100644 index 0adc754..0000000 --- a/libtemplate/templatefunction.c +++ /dev/null @@ -1,1856 +0,0 @@ -#include "templatefunction.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-
-using namespace std;
-
-// --- cTemplateFunction -------------------------------------------------------------
-
-cTemplateFunction::cTemplateFunction(eFuncType type) {
- this->type = type;
- debug = false;
- containerX = 0;
- containerY = 0;
- containerWidth = 0;
- containerHeight = 0;
- columnWidth = -1;
- rowHeight = -1;
- globals = NULL;
- condParam = NULL;
- parsedCompletely = false;
- updated = false;
- alreadyCutted = false;
- parsedTextWidth = 0;
- fontName = "";
- imgPath = "";
- textboxHeight = 0;
- stringTokens = NULL;
- intTokens = NULL;
- parsedText = "";
- cuttedText = "";
-}
-
-cTemplateFunction::~cTemplateFunction(void) {
- if (condParam)
- delete condParam;
-}
-
-/*******************************************************************
-* Public Functions
-*******************************************************************/
-
-void cTemplateFunction::SetParameters(vector<pair<string, string> > params) {
- for (vector<pair<string, string> >::iterator it = params.begin(); it != params.end(); it++) {
- string name = it->first;
- pair< eParamType, string > p;
- if (!name.compare("debug")) {
- string value = it->second;
- if (!value.compare("true")) {
- debug = true;
- }
- continue;
- } else if (!name.compare("debuggrid")) {
- string value = it->second;
- SetDebugGrid(value);
- continue;
- } else if (!name.compare("condition")) {
- p.first = ptCond;
- } else if (!name.compare("name")) {
- p.first = ptName;
- } else if (!name.compare("mode")) {
- p.first = ptMode;
- } else if (!name.compare("x")) {
- p.first = ptX;
- } else if (!name.compare("y")) {
- p.first = ptY;
- } else if (!name.compare("width")) {
- p.first = ptWidth;
- } else if (!name.compare("height")) {
- p.first = ptHeight;
- } else if (!name.compare("menuitemwidth")) {
- p.first = ptMenuItemWidth;
- } else if (!name.compare("detached")) {
- p.first = ptDetached;
- } else if (!name.compare("fadetime")) {
- p.first = ptFadeTime;
- } else if (!name.compare("shifttime")) {
- p.first = ptShiftTime;
- } else if (!name.compare("shifttype")) {
- p.first = ptShiftType;
- } else if (!name.compare("shiftmode")) {
- p.first = ptShiftMode;
- } else if (!name.compare("startx")) {
- p.first = ptStartX;
- } else if (!name.compare("starty")) {
- p.first = ptStartY;
- } else if (!name.compare("imagetype")) {
- p.first = ptImageType;
- } else if (!name.compare("path")) {
- p.first = ptPath;
- } else if (!name.compare("color")) {
- p.first = ptColor;
- } else if (!name.compare("font")) {
- p.first = ptFont;
- } else if (!name.compare("fontsize")) {
- p.first = ptFontSize;
- } else if (!name.compare("text")) {
- p.first = ptText;
- } else if (!name.compare("layer")) {
- p.first = ptLayer;
- } else if (!name.compare("transparency")) {
- p.first = ptTransparency;
- } else if (!name.compare("background")) {
- p.first = ptBackground;
- } else if (!name.compare("quadrant")) {
- p.first = ptQuadrant;
- } else if (!name.compare("type")) {
- p.first = ptType;
- } else if (!name.compare("align")) {
- p.first = ptAlign;
- } else if (!name.compare("valign")) {
- p.first = ptValign;
- } else if (!name.compare("delay")) {
- p.first = ptDelay;
- } else if (!name.compare("mode")) {
- p.first = ptScrollMode;
- } else if (!name.compare("scrollspeed")) {
- p.first = ptScrollSpeed;
- } else if (!name.compare("orientation")) {
- p.first = ptOrientation;
- } else if (!name.compare("numlistelements")) {
- p.first = ptNumElements;
- } else if (!name.compare("scrollelement")) {
- p.first = ptScrollElement;
- } else if (!name.compare("scrollheight")) {
- p.first = ptScrollHeight;
- } else if (!name.compare("float")) {
- p.first = ptFloat;
- } else if (!name.compare("floatwidth")) {
- p.first = ptFloatWidth;
- } else if (!name.compare("floatheight")) {
- p.first = ptFloatHeight;
- } else if (!name.compare("maxlines")) {
- p.first = ptMaxLines;
- } else if (!name.compare("columnwidth")) {
- p.first = ptColumnWidth;
- } else if (!name.compare("rowheight")) {
- p.first = ptRowHeight;
- } else if (!name.compare("overflow")) {
- p.first = ptOverflow;
- } else if (!name.compare("scaletvx")) {
- p.first = ptScaleTvX;
- } else if (!name.compare("scaletvy")) {
- p.first = ptScaleTvY;
- } else if (!name.compare("scaletvwidth")) {
- p.first = ptScaleTvWidth;
- } else if (!name.compare("scaletvheight")) {
- p.first = ptScaleTvHeight;
- } else if (!name.compare("hideroot")) {
- p.first = ptHideRoot;
- } else if (!name.compare("cache")) {
- p.first = ptCache;
- } else if (!name.compare("determinatefont")) {
- p.first = ptDeterminateFont;
- } else if (!name.compare("direction")) {
- p.first = ptDirection;
- } else if (!name.compare("animtype")) {
- p.first = ptAnimType;
- } else if (!name.compare("animfreq")) {
- p.first = ptAnimFreq;
- } else {
- p.first = ptNone;
- }
- p.second = it->second;
- nativeParameters.insert(p);
- }
-}
-
-void cTemplateFunction::SetParameter(eParamType type, string value) {
- nativeParameters.erase(type);
- nativeParameters.insert(pair<eParamType, string>(type, value));
-}
-
-void cTemplateFunction::SetContainer(int x, int y, int w, int h) {
- containerX = x;
- containerY = y;
- containerWidth = w;
- containerHeight = h;
-}
-
-void cTemplateFunction::SetLoopContainer(int columnWidth, int rowHeight) {
- this->columnWidth = columnWidth;
- this->rowHeight = rowHeight;
-}
-
-void cTemplateFunction::SetWidthManually(string width) {
- nativeParameters.erase(ptWidth);
- nativeParameters.insert(pair<eParamType, string>(ptWidth, width));
-}
-
-void cTemplateFunction::SetHeightManually(string height) {
- nativeParameters.erase(ptHeight);
- nativeParameters.insert(pair<eParamType, string>(ptHeight, height));
-}
-
-void cTemplateFunction::SetXManually(int newX) {
- numericParameters.erase(ptX);
- numericParameters.insert(pair<eParamType, int>(ptX, newX));
-}
-
-void cTemplateFunction::SetYManually(int newY) {
- numericParameters.erase(ptY);
- numericParameters.insert(pair<eParamType, int>(ptY, newY));
-}
-
-void cTemplateFunction::SetTextboxHeight(int boxHeight) {
- numericParameters.erase(ptHeight);
- numericParameters.insert(pair<eParamType, int>(ptHeight, boxHeight));
-}
-
-void cTemplateFunction::SetTranslatedText(string translation) {
- if (type != ftDrawText && type != ftDrawTextBox && type != ftDrawTextVertical)
- return;
- if (translation.size() == 0)
- return;
- nativeParameters.erase(ptText);
- nativeParameters.insert(pair<eParamType, string>(ptText, translation));
-}
-
-void cTemplateFunction::SetMaxTextWidth(int maxWidth) {
- if (type != ftDrawText)
- return;
- numericParameters.erase(ptWidth);
- numericParameters.insert(pair<eParamType, int>(ptWidth, maxWidth));
-}
-
-bool cTemplateFunction::CalculateParameters(void) {
- bool paramValid = true;
- bool paramsValid = true;
- for (map< eParamType, string >::iterator param = nativeParameters.begin(); param != nativeParameters.end(); param++) {
- paramValid = true;
- eParamType type = param->first;
- string value = param->second;
- switch (type) {
- case ptCond:
- paramValid = SetCondition(value);
- break;
- case ptX:
- case ptY:
- case ptWidth:
- case ptHeight:
- case ptMenuItemWidth:
- case ptFadeTime:
- case ptShiftTime:
- case ptDelay:
- case ptStartX:
- case ptStartY:
- case ptFontSize:
- case ptLayer:
- case ptTransparency:
- case ptQuadrant:
- case ptType:
- case ptNumElements:
- case ptFloatWidth:
- case ptFloatHeight:
- case ptMaxLines:
- case ptColumnWidth:
- case ptRowHeight:
- case ptScaleTvX:
- case ptScaleTvY:
- case ptScaleTvWidth:
- case ptScaleTvHeight:
- case ptAnimFreq:
- SetNumericParameter(type, value);
- break;
- case ptAlign:
- case ptValign:
- paramValid = SetAlign(type, value);
- break;
- case ptImageType:
- paramValid = SetImageType(type, value);
- break;
- case ptColor:
- paramValid = SetColor(type, value);
- break;
- case ptFont:
- paramValid = SetFont(type, value);
- break;
- case ptText:
- paramValid = SetTextTokens(value);
- break;
- case ptScrollMode:
- paramValid = SetScrollMode(value);
- break;
- case ptScrollSpeed:
- paramValid = SetScrollSpeed(value);
- break;
- case ptOrientation:
- paramValid = SetOrientation(value);
- break;
- case ptFloat:
- paramValid = SetFloating(value);
- break;
- case ptOverflow:
- paramValid = SetOverflow(value);
- break;
- case ptHideRoot:
- paramValid = SetHideRoot(value);
- break;
- case ptDetached:
- paramValid = SetDetached(value);
- break;
- case ptBackground:
- paramValid = SetBackground(value);
- break;
- case ptDirection:
- paramValid = SetDirection(value);
- break;
- case ptAnimType:
- paramValid = SetAnimType(value);
- break;
- case ptShiftType:
- paramValid = SetShiftType(value);
- break;
- case ptShiftMode:
- paramValid = SetShiftMode(value);
- break;
- default:
- paramValid = true;
- break;
- }
- if (!paramValid) {
- paramsValid = false;
- esyslog("skindesigner: %s: invalid parameter %d, value %s", GetFuncName().c_str(), type, value.c_str());
- }
- }
- return paramsValid;
-}
-
-bool cTemplateFunction::ReCalculateParameters(void) {
- bool paramValid = true;
- bool paramsValid = true;
- for (map< eParamType, string >::iterator param = nativeParameters.begin(); param != nativeParameters.end(); param++) {
- paramValid = true;
- eParamType type = param->first;
- string value = param->second;
- switch (type) {
- case ptX:
- case ptY:
- case ptWidth:
- case ptHeight:
- case ptMenuItemWidth:
- case ptFontSize:
- case ptFloatWidth:
- case ptFloatHeight:
- case ptMaxLines:
- case ptColumnWidth:
- case ptRowHeight:
- SetNumericParameter(type, value);
- break;
- default:
- break;
- }
- if (!paramValid) {
- paramsValid = false;
- esyslog("skindesigner: %s: invalid parameter %d, value %s", GetFuncName().c_str(), type, value.c_str());
- }
- }
- return paramsValid;
-}
-
-void cTemplateFunction::CompleteParameters(void) {
- switch (type) {
- case ftDrawImage: {
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- if (imgPath.size() == 0) {
- imgPath = GetParameter(ptPath);
- }
- break; }
- case ftDrawRectangle:
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- break;
- case ftDrawEllipse:
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- break;
- case ftDrawSlope:
- CalculateAlign(GetNumericParameter(ptWidth), GetNumericParameter(ptHeight));
- break;
- case ftDrawText:
- CalculateAlign(GetWidth(), GetHeight());
- break;
- default:
- break;
- }
-}
-
-void cTemplateFunction::ClearDynamicParameters(void) {
- parsedText = "";
- cuttedText = "";
- alreadyCutted = false;
- parsedTextWidth = 0;
- textboxHeight = 0;
-
- //clear dynamically parsed int parameters
- for (map<eParamType,string>::iterator it = numericDynamicParameters.begin(); it != numericDynamicParameters.end(); it++) {
- numericParameters.erase(it->first);
- }
- //restoring dynamic numeric parameters only if x, y, width or height of other elements is needed dynamically
- for (map<eParamType,string>::iterator it = nativeParameters.begin(); it != nativeParameters.end(); it++) {
- eParamType paramType = it->first;
- if (paramType == ptX ||
- paramType == ptY ||
- paramType == ptWidth ||
- paramType == ptHeight ||
- paramType == ptFloatWidth ||
- paramType == ptFloatHeight)
- {
- string value = it->second;
- if (value.find("{width(") != string::npos || value.find("{height(") != string::npos || value.find("{posx(") != string::npos || value.find("{posy(") != string::npos) {
- numericDynamicParameters.erase(paramType);
- SetNumericParameter(paramType, value);
- }
- }
- }
-
-}
-
-bool cTemplateFunction::ParseParameters(void) {
- updated = false;
- parsedCompletely = true;
-
- if (stringTokens) {
- ParseStringParameters();
- }
-
- if (intTokens && numericDynamicParameters.size() > 0) {
- ParseNumericalParameters();
- }
-
- if (condParam) {
- condParam->Evaluate(intTokens, stringTokens);
- }
-
- return parsedCompletely;
-}
-
-string cTemplateFunction::GetParameter(eParamType type) {
- map<eParamType,string>::iterator hit = nativeParameters.find(type);
- if (hit == nativeParameters.end())
- return "";
- return hit->second;
-}
-
-int cTemplateFunction::GetNumericParameter(eParamType type) {
- map<eParamType,int>::iterator hit = numericParameters.find(type);
- if (hit == numericParameters.end()) {
- //Set Default Value for Integer Parameters
- if (type == ptLayer)
- return 1;
- else if (type == ptTransparency)
- return 0;
- else if (type == ptDelay)
- return 0;
- else if (type == ptFadeTime)
- return 0;
- else if (type == ptShiftTime)
- return 0;
- else if (type == ptMenuItemWidth)
- return 0;
- else if (type == ptHideRoot)
- return 0;
- else if (type == ptDetached)
- return 0;
- else if (type == ptBackground)
- return 0;
- else if (type == ptDrawDebugGrid)
- return 0;
- else if (type == ptDirection)
- return diBottomUp;
- else if (type == ptStartX)
- return 0;
- else if (type == ptStartY)
- return 0;
- else if (type == ptShiftType)
- return stNone;
- else if (type == ptShiftMode)
- return smLinear;
- //default default ;)
- return -1;
- }
- return hit->second;
-}
-
-string cTemplateFunction::GetText(bool cut) {
- if (!cut) {
- return parsedText;
- }
- if (alreadyCutted && cuttedText.size() > 0) {
- return cuttedText;
- }
- alreadyCutted = true;
- int maxWidth = GetNumericParameter(ptWidth);
- if (maxWidth > 0) {
- parsedTextWidth = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- if (parsedTextWidth > maxWidth) {
- cuttedText = CutText(parsedText, maxWidth, fontName, GetNumericParameter(ptFontSize));
- return cuttedText;
- }
- }
- return parsedText;
-}
-
-
-tColor cTemplateFunction::GetColorParameter(eParamType type) {
- map<eParamType,tColor>::iterator hit = colorParameters.find(type);
- if (hit == colorParameters.end())
- return 0x00000000;
- return hit->second;
-}
-
-int cTemplateFunction::GetWidth(bool cutted) {
- int funcWidth = 0;
- switch (type) {
- case ftDrawText: {
- if (cutted) {
- if (!alreadyCutted) {
- alreadyCutted = true;
- int maxWidth = GetNumericParameter(ptWidth);
- if (maxWidth > 0) {
- parsedTextWidth = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- if (parsedTextWidth > maxWidth) {
- cuttedText = CutText(parsedText, maxWidth, fontName, GetNumericParameter(ptFontSize));
- }
- }
- }
- if (cuttedText.size() > 0)
- return fontManager->Width(fontName, GetNumericParameter(ptFontSize), cuttedText.c_str());
- }
- if (parsedTextWidth > 0)
- funcWidth = parsedTextWidth;
- else
- funcWidth = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- break; }
- case ftDrawTextVertical:
- funcWidth = GetNumericParameter(ptFontSize)*1.2;
- break;
- case ftFill:
- case ftDrawImage:
- case ftDrawRectangle:
- case ftDrawEllipse:
- case ftDrawSlope:
- case ftDrawTextBox:
- funcWidth = GetNumericParameter(ptWidth);
- break;
- default:
- esyslog("skindesigner: GetWidth not implemented for funcType %d", type);
- break;
- }
- return funcWidth;
-}
-
-int cTemplateFunction::GetHeight(map < string, vector< map< string, string > > > *loopTokens) {
- int funcHeight = 0;
- switch (type) {
- case ftDrawText:
- funcHeight = fontManager->Height(fontName, GetNumericParameter(ptFontSize));
- break;
- case ftDrawTextVertical:
- funcHeight = fontManager->Width(fontName, GetNumericParameter(ptFontSize), parsedText.c_str());
- break;
- case ftFill:
- case ftDrawImage:
- case ftDrawRectangle:
- case ftDrawEllipse:
- case ftDrawSlope:
- funcHeight = GetNumericParameter(ptHeight);
- break;
- case ftDrawTextBox: {
- int maxLines = GetNumericParameter(ptMaxLines);
- int fixedBoxHeight = GetNumericParameter(ptHeight);
- if (maxLines > 0) {
- funcHeight = maxLines * fontManager->Height(fontName, GetNumericParameter(ptFontSize));
- } else if (fixedBoxHeight > 0) {
- funcHeight = fixedBoxHeight;
- } else if (textboxHeight > 0) {
- funcHeight = textboxHeight;
- } else {
- funcHeight = CalculateTextBoxHeight();
- textboxHeight = funcHeight;
- }
- break; }
- case ftLoop: {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(this);
- if (loopFunc) {
- funcHeight = loopFunc->CalculateHeight(loopTokens);
- }
- break; }
- default:
- esyslog("skindesigner: GetHeight not implemented for funcType %d", type);
- break;
- }
- return funcHeight;
-}
-
-void cTemplateFunction::GetNeededWidths(multimap<eParamType,string> *widths) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{width(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart+1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart+7, posEnd - posStart - 7);
- widths->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{width(");
- }
- }
-}
-
-void cTemplateFunction::GetNeededHeights(multimap<eParamType,string> *heights) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{height(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart + 1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart + 8, posEnd - posStart - 8);
- heights->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{height(");
- }
- }
-}
-
-void cTemplateFunction::GetNeededPosX(multimap<eParamType,string> *posXs) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{posx(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart+1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart+6, posEnd - posStart - 6);
- posXs->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{posx(");
- }
- }
-}
-
-void cTemplateFunction::GetNeededPosY(multimap<eParamType,string> *posYs) {
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- size_t posStart = val.find("{posy(");
- while (posStart != string::npos) {
- size_t posEnd = val.find(")", posStart+1);
- if (posEnd != string::npos) {
- string label = val.substr(posStart+6, posEnd - posStart - 6);
- posYs->insert(pair<eParamType,string>(param->first, label));
- val = val.replace(posStart, posEnd - posStart, "");
- } else {
- break;
- }
- posStart = val.find("{posy(");
- }
- }
-}
-
-void cTemplateFunction::SetWidth(eParamType type, string label, int funcWidth) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{width(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcWidth;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-void cTemplateFunction::SetHeight(eParamType type, string label, int funcHeight) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{height(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcHeight;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-void cTemplateFunction::SetX(eParamType type, string label, int funcX) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{posx(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcX;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-void cTemplateFunction::SetY(eParamType type, string label, int funcY) {
- updated = false;
- map< eParamType, string >::iterator hit = numericDynamicParameters.find(type);
- if (hit == numericDynamicParameters.end())
- return;
- stringstream needle;
- needle << "{posy(" << label << ")}";
- size_t posFound = (hit->second).find(needle.str());
- if (posFound == string::npos)
- return;
- stringstream repl;
- repl << funcY;
- string parsedVal = (hit->second).replace(posFound, needle.str().size(), repl.str());
-
- cNumericParameter param(parsedVal);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetGlobals(globals);
- int val = param.Parse(parsedVal);
- if (param.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedVal));
- }
-}
-
-bool cTemplateFunction::DoExecute(void) {
- if (!condParam)
- return true;
- return condParam->IsTrue();
-}
-
-bool cTemplateFunction::IsAnimated(void) {
- map< eParamType, int >::iterator hit = numericParameters.find(ptAnimType);
- if (hit == numericParameters.end())
- return false;
- eAnimType type = (eAnimType)hit->second;
- if (type > atNone)
- return true;
- return false;
-}
-
-/*******************************************************************
-* Private Functions
-*******************************************************************/
-
-bool cTemplateFunction::SetCondition(string cond) {
- if (condParam)
- delete condParam;
- condParam = new cConditionalParameter(globals, cond);
- condParam->Tokenize();
- return true;
-}
-
-
-bool cTemplateFunction::SetNumericParameter(eParamType type, string value) {
- if (config.replaceDecPoint) {
- if (value.find_first_of('.') != string::npos) {
- std::replace( value.begin(), value.end(), '.', config.decPoint);
- }
- }
-
- cNumericParameter param(value);
- param.SetAreaSize(containerWidth, containerHeight);
- param.SetLoopContainer(columnWidth, rowHeight);
- param.SetGlobals(globals);
- switch (type) {
- case ptX:
- case ptStartX:
- case ptWidth:
- case ptMenuItemWidth:
- case ptScaleTvX:
- case ptScaleTvWidth:
- param.SetHorizontal();
- break;
- case ptY:
- case ptStartY:
- case ptHeight:
- case ptScaleTvY:
- case ptScaleTvHeight:
- param.SetVertical();
- break;
- case ptFontSize: {
- if (this->type == ftDrawTextVertical)
- param.SetHorizontal();
- else
- param.SetVertical();
- break; }
- case ptLayer:
- param.SetDefault(1);
- break;
- default:
- break;
- }
- string parsedValue = "";
- int val = param.Parse(parsedValue);
- if (param.Valid()) {
- if (this->type < ftLoop && type == ptX) {
- val += containerX;
- }
- if (this->type < ftLoop && type == ptY) {
- val += containerY;
- }
- numericParameters.erase(type);
- numericDynamicParameters.erase(type);
- numericParameters.insert(pair<eParamType, int>(type, val));
- } else {
- numericDynamicParameters.erase(type);
- numericDynamicParameters.insert(pair<eParamType, string>(type, parsedValue));
- }
- return param.Valid();
-}
-
-bool cTemplateFunction::SetAlign(eParamType type, string value) {
- eAlign align = alLeft;
- bool ok = true;
- if (!value.compare("center")) {
- align = alCenter;
- } else if (!value.compare("right")) {
- align = alRight;
- } else if (!value.compare("top")) {
- align = alTop;
- } else if (!value.compare("bottom")) {
- align = alBottom;
- } else if (!value.compare("left")) {
- align = alLeft;
- } else {
- ok = false;
- }
- numericParameters.insert(pair<eParamType, int>(type, align));
- return ok;
-}
-
-bool cTemplateFunction::SetFont(eParamType type, string value) {
- //check if token
- if (IsToken(value)) {
- if (!globals->GetFont(value, fontName)) {
- if (!globals->GetFont("{vdrOsd}", fontName)) {
- return false;
- }
- }
- } else {
- //if no token, directly use input
- fontName = value;
- }
- return true;
-}
-
-bool cTemplateFunction::SetImageType(eParamType type, string value) {
- eImageType imgType = itImage;
- bool ok = true;
- if (!value.compare("channellogo")) {
- imgType = itChannelLogo;
- } else if (!value.compare("seplogo")) {
- imgType = itSepLogo;
- } else if (!value.compare("skinpart")) {
- imgType = itSkinPart;
- } else if (!value.compare("menuicon")) {
- imgType = itMenuIcon;
- } else if (!value.compare("icon")) {
- imgType = itIcon;
- } else if (!value.compare("image")) {
- imgType = itImage;
- } else {
- ok = false;
- }
- numericParameters.insert(pair<eParamType, int>(ptImageType, imgType));
- return ok;
-}
-
-
-bool cTemplateFunction::SetColor(eParamType type, string value) {
- if (globals) {
- tColor colVal = 0x00000000;
- if (globals->GetColor(value, colVal)) {
- colorParameters.insert(pair<eParamType, tColor>(type, colVal));
- return true;
- }
- }
- if (value.size() != 8)
- return false;
- std::stringstream str;
- str << value;
- tColor colVal;
- str >> std::hex >> colVal;
- colorParameters.insert(pair<eParamType, tColor>(type, colVal));
- return true;
-}
-
-bool cTemplateFunction::SetTextTokens(string value) {
- textTokens.clear();
- //first replace globals
- globals->ReplaceStringVars(value);
- //now tokenize
- bool tokenFound = true;
- while (tokenFound) {
- //search for conditional token or normal token
- size_t tokenStart = value.find_first_of('{');
- size_t conditionStart = value.find_first_of('|');
- size_t printfStart = value.find("{printf(");
- if (tokenStart == string::npos && conditionStart == string::npos) {
- //find constant strings
- if (value.size() > 0) {
- cTextToken token;
- token.type = ttConstString;
- token.value = value;
- textTokens.push_back(token);
- }
- tokenFound = false;
- continue;
- } else if (tokenStart != string::npos && conditionStart == string::npos) {
- size_t tokenEnd = value.find_first_of('}');
- if (printfStart != string::npos && printfStart <= tokenStart) {
- //replace printf text token
- ParsePrintfTextToken(value, printfStart, tokenEnd);
- } else {
- //replace normal text token
- ParseTextToken(value, tokenStart, tokenEnd);
- }
- } else if (tokenStart != string::npos && conditionStart != string::npos) {
- if (tokenStart < conditionStart) {
- size_t tokenEnd = value.find_first_of('}');
- if (printfStart != string::npos && printfStart <= tokenStart) {
- //replace printf text token
- ParsePrintfTextToken(value, printfStart, tokenEnd);
- } else {
- //replace normal text token
- ParseTextToken(value, tokenStart, tokenEnd);
- }
- } else {
- //replace conditional text token
- size_t conditionEnd = value.find_first_of('|', conditionStart+1);
- ParseConditionalTextToken(value, conditionStart, conditionEnd);
- }
- }
- }
- return true;
-}
-
-void cTemplateFunction::ParseTextToken(string &value, size_t start, size_t end) {
- cTextToken token;
- if (start > 0) {
- string constString = value.substr(0, start);
- value = value.replace(0, start, "");
- token.type = ttConstString;
- token.value = constString;
- } else {
- string tokenName = value.substr(1, end - start - 1);
- value = value.replace(0, end - start + 1, "");
- token.type = ttToken;
- token.value = tokenName;
- }
- textTokens.push_back(token);
-}
-
-void cTemplateFunction::ParseConditionalTextToken(string &value, size_t start, size_t end) {
- cTextToken token;
- if (start > 0) {
- string constString = value.substr(0, start);
- value = value.replace(0, start, "");
- token.type = ttConstString;
- token.value = constString;
- } else {
- string condToken = value.substr(start + 1, end - start - 1);
- value = value.replace(0, end - start + 1, "");
- size_t tokenStart = condToken.find_first_of('{');
- size_t tokenEnd = condToken.find_first_of('}');
- vector<cTextToken> subTokens;
- if (tokenStart > 0) {
- cTextToken subToken;
- string constString = condToken.substr(0, tokenStart);
- condToken = condToken.replace(0, tokenStart, "");
- subToken.type = ttConstString;
- subToken.value = constString;
- subTokens.push_back(subToken);
- }
- string tokenName = condToken.substr(1, tokenEnd - tokenStart - 1);
- condToken = condToken.replace(0, tokenEnd - tokenStart + 1, "");
-
- cTextToken subToken2;
- subToken2.type = ttToken;
- subToken2.value = tokenName;
- subTokens.push_back(subToken2);
-
- if (condToken.size() > 0) {
- cTextToken subToken3;
- subToken3.type = ttConstString;
- subToken3.value = condToken;
- subTokens.push_back(subToken3);
- }
-
- token.type = ttConditionalToken;
- token.value = tokenName;
- token.subTokens = subTokens;
- }
- textTokens.push_back(token);
-}
-
-void cTemplateFunction::ParsePrintfTextToken(string &value, size_t start, size_t end) {
- cTextToken token;
- if (start > 0) {
- string constString = value.substr(0, start);
- value = value.replace(0, start, "");
- token.type = ttConstString;
- token.value = constString;
- } else {
- token.type = ttPrintfToken;
- //fetch parameter list from printf
- string printfParams = value.substr(start + 8, end - start - 9);
- value = value.replace(0, end - start + 1, "");
- splitstring s(printfParams.c_str());
- vector<string> flds = s.split(',', 1);
-
- int numParams = flds.size();
- if (numParams < 1)
- return;
- string formatString = trim(flds[0]);
- token.value = formatString.substr(1, formatString.size() - 2);
- for (int i=1; i < numParams; i++) {
- token.parameters.push_back(trim(flds[i]));
- }
- }
- textTokens.push_back(token);
-}
-
-bool cTemplateFunction::SetScrollMode(string value) {
- eScrollMode mode = smNone;
- bool ok = true;
- if (!value.compare("forthandback"))
- mode = smForthAndBack;
- else if (!value.compare("carriagereturn"))
- mode = smCarriageReturn;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptScrollMode, mode));
- return ok;
-}
-
-bool cTemplateFunction::SetScrollSpeed(string value) {
- eScrollSpeed speed = ssMedium;
- bool ok = true;
- if (!value.compare("slow"))
- speed = ssSlow;
- else if (!value.compare("fast"))
- speed = ssFast;
- else if (!value.compare("medium"))
- speed = ssMedium;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptScrollSpeed, speed));
- return ok;
-
-}
-
-bool cTemplateFunction::SetOrientation(string value) {
- eOrientation orientation = orNone;
- bool ok = true;
- if (!value.compare("horizontal"))
- orientation = orHorizontal;
- else if (!value.compare("vertical"))
- orientation = orVertical;
- else if (!value.compare("absolute"))
- orientation = orAbsolute;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptOrientation, orientation));
- return ok;
-}
-
-bool cTemplateFunction::SetFloating(string value) {
- eFloatType floatType = flNone;
- bool ok = true;
- if (!value.compare("topleft"))
- floatType = flTopLeft;
- else if (!value.compare("topright"))
- floatType = flTopRight;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptFloat, floatType));
- return ok;
-}
-
-bool cTemplateFunction::SetOverflow(string value) {
- eOverflowType overflowType = otNone;
- bool ok = true;
- if (!value.compare("linewrap"))
- overflowType = otWrap;
- else if (!value.compare("cut"))
- overflowType = otCut;
- else
- ok = false;
- numericParameters.insert(pair<eParamType, int>(ptOverflow, overflowType));
- return ok;
-}
-
-bool cTemplateFunction::SetHideRoot(string value) {
- int hideRoot = 0;
- if (!value.compare("true"))
- hideRoot = 1;
- numericParameters.insert(pair<eParamType, int>(ptHideRoot, hideRoot));
- return true;
-}
-
-bool cTemplateFunction::SetDetached(string value) {
- int detached = 0;
- if (!value.compare("true"))
- detached = 1;
- numericParameters.insert(pair<eParamType, int>(ptDetached, detached));
- return true;
-}
-
-bool cTemplateFunction::SetBackground(string value) {
- int back = 0;
- if (!value.compare("true"))
- back = 1;
- numericParameters.insert(pair<eParamType, int>(ptBackground, back));
- return true;
-}
-
-bool cTemplateFunction::SetDirection(string value) {
- int direction = diNone;
- if (!value.compare("bottomup"))
- direction = diBottomUp;
- else if (!value.compare("topdown"))
- direction = diTopDown;
- numericParameters.insert(pair<eParamType, int>(ptDirection, direction));
- return true;
-}
-
-bool cTemplateFunction::SetAnimType(string value) {
- int animType = atNone;
- if (!value.compare("blink"))
- animType = atBlink;
- else if (!value.compare("animated"))
- animType = atAnimated;
- numericParameters.insert(pair<eParamType, int>(ptAnimType, animType));
- return true;
-}
-
-bool cTemplateFunction::SetShiftType(string value) {
- int shiftType = stNone;
- if (!value.compare("left"))
- shiftType = stLeft;
- else if (!value.compare("right"))
- shiftType = stRight;
- else if (!value.compare("top"))
- shiftType = stTop;
- else if (!value.compare("bottom"))
- shiftType = stBottom;
- numericParameters.insert(pair<eParamType, int>(ptShiftType, shiftType));
- return true;
-}
-
-bool cTemplateFunction::SetShiftMode(string value) {
- int shiftMode = smLinear;
- if (!value.compare("slowed"))
- shiftMode = smSlowedDown;
- numericParameters.insert(pair<eParamType, int>(ptShiftMode, shiftMode));
- return true;
-}
-
-void cTemplateFunction::SetDebugGrid(string value) {
- int numGridsX = 0;
- int numGridsY = 0;
- size_t posSep = value.find("x");
- if (posSep != string::npos) {
- string x = value.substr(0, posSep);
- string y = value.substr(posSep+1);
- numGridsX = atoi(x.c_str());
- numGridsY = atoi(y.c_str());
- }
- if (numGridsX < 1)
- numGridsX = 10;
- if (numGridsY < 1)
- numGridsY = 10;
- numericParameters.insert(pair<eParamType, int>(ptDebugGridX, numGridsX));
- numericParameters.insert(pair<eParamType, int>(ptDebugGridY, numGridsY));
- numericParameters.insert(pair<eParamType, int>(ptDrawDebugGrid, 1));
-}
-
-void cTemplateFunction::ParseStringParameters(void) {
- //first replace stringtokens in Text (drawText)
- stringstream text;
- for (vector<cTextToken>::iterator it = textTokens.begin(); it !=textTokens.end(); it++) {
- updated = true;
- if ((*it).type == ttConstString) {
- text << (*it).value;
- } else if ((*it).type == ttToken) {
- bool found = false;
- string tokenName = (*it).value;
- if (stringTokens) {
- map < string, string >::iterator hit = stringTokens->find(tokenName);
- if (hit != stringTokens->end()) {
- text << hit->second;
- found = true;
- }
- }
- if (!found && intTokens) {
- map < string, int >::iterator hitInt = intTokens->find(tokenName);
- if (hitInt != intTokens->end()) {
- text << hitInt->second;
- found = true;
- }
- }
- if (!found) {
- text << "{" << tokenName << "}";
- }
- } else if ((*it).type == ttConditionalToken) {
- bool found = false;
- string tokenName = (*it).value;
- if (stringTokens) {
- map < string, string >::iterator hit = stringTokens->find(tokenName);
- if (hit != stringTokens->end()) {
- string replaceText = hit->second;
- if (replaceText.size() > 0) {
- for (vector<cTextToken>::iterator it2 = (*it).subTokens.begin(); it2 != (*it).subTokens.end(); it2++) {
- if ((*it2).type == ttConstString) {
- text << (*it2).value;
- } else {
- text << replaceText;
- }
- }
- }
- found = true;
- }
- }
- if (!found && intTokens) {
- map < string, int >::iterator hitInt = intTokens->find(tokenName);
- if (hitInt != intTokens->end()) {
- int intVal = hitInt->second;
- if (intVal > 0) {
- for (vector<cTextToken>::iterator it2 = (*it).subTokens.begin(); it2 != (*it).subTokens.end(); it2++) {
- if ((*it2).type == ttConstString) {
- text << (*it2).value;
- } else {
- text << intVal;
- }
- }
- }
- found = true;
- }
- }
- } else if ((*it).type == ttPrintfToken) {
- cTextToken token = *it;
- int paramCount = token.parameters.size();
- string printfResult = "";
- switch (paramCount) {
- case 1: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- printfResult = *cString::sprintf(token.value.c_str(), param1);
- break; }
- case 2: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2);
- break; }
- case 3: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- int param3 = ReplaceIntToken(token.parameters[2]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2, param3);
- break; }
- case 4: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- int param3 = ReplaceIntToken(token.parameters[2]);
- int param4 = ReplaceIntToken(token.parameters[3]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2, param3, param4);
- break; }
- case 5: {
- int param1 = ReplaceIntToken(token.parameters[0]);
- int param2 = ReplaceIntToken(token.parameters[1]);
- int param3 = ReplaceIntToken(token.parameters[2]);
- int param4 = ReplaceIntToken(token.parameters[3]);
- int param5 = ReplaceIntToken(token.parameters[4]);
- printfResult = *cString::sprintf(token.value.c_str(), param1, param2, param3, param4, param5);
- break; }
- default:
- break;
- }
- text << printfResult;
- }
- }
- parsedText = text.str();
-
- string path = GetParameter(ptPath);
- if (GetNumericParameter(ptImageType) == itImage && path.size() > 0) {
- //no absolute pathes allowed
- if (!startswith(path.c_str(), "{")) {
- esyslog("skindesigner: no absolute pathes allowed for images - %s", path.c_str());
- }
- if (startswith(path.c_str(), "{ressourcedir}")) {
- imgPath = path.replace(0, 14, *config.GetSkinRessourcePath());
- }
- }
- //now check further possible string variables
- if (stringTokens && path.size() > 0 && path.find("{") != string::npos) {
- for (map < string, string >::iterator it = stringTokens->begin(); it != stringTokens->end(); it++) {
- size_t found = path.find(it->first);
- if (found != string::npos) {
- size_t posEndBracket = found + (it->first).size();
- if (posEndBracket < path.size()) {
- string endChar = path.substr(posEndBracket, 1);
- if (endChar.compare("}"))
- continue;
- }
- updated = true;
- imgPath = path;
- if (found > 0 && ((it->first).size() + 2 <= imgPath.size()))
- imgPath.replace(found-1, (it->first).size() + 2, it->second);
- break;
- }
- }
- for (map < string, int >::iterator it = intTokens->begin(); it != intTokens->end(); it++) {
- size_t found = path.find(it->first);
- if (found != string::npos) {
- size_t posEndBracket = found + (it->first).size();
- if (posEndBracket < path.size()) {
- string endChar = path.substr(posEndBracket, 1);
- if (endChar.compare("}"))
- continue;
- }
- updated = true;
- imgPath = path;
- if (found > 0 && ((it->first).size() + 2 <= imgPath.size())) {
- stringstream intVal;
- intVal << it->second;
- imgPath.replace(found-1, (it->first).size() + 2, intVal.str());
- }
- break;
- }
- }
- }
-}
-
-void cTemplateFunction::ParseNumericalParameters(void) {
- parsedCompletely = true;
- for (map<eParamType, string>::iterator param = numericDynamicParameters.begin(); param !=numericDynamicParameters.end(); param++) {
- string val = param->second;
- for (map<string,int >::iterator tok = intTokens->begin(); tok != intTokens->end(); tok++) {
- stringstream sToken;
- sToken << "{" << tok->first << "}";
- string token = sToken.str();
- size_t foundToken = val.find(token);
- //replace token as often as it appears
- while (foundToken != string::npos) {
- stringstream sVal;
- sVal << tok->second;
- val = val.replace(foundToken, token.size(), sVal.str());
- foundToken = val.find(token);
- }
- }
- cNumericParameter p(val);
- string parsedVal = "";
- int newVal = p.Parse(parsedVal);
- if (p.Valid()) {
- updated = true;
- numericParameters.insert(pair<eParamType, int>(param->first, newVal));
- } else {
- parsedCompletely = false;
- }
- }
-}
-
-void cTemplateFunction::CalculateAlign(int elementWidth, int elementHeight) {
- int align = GetNumericParameter(ptAlign);
- //if element is used in a loop, use loop box width
- int boxWidth = (columnWidth > 0) ? columnWidth : containerWidth;
- int boxHeight = (rowHeight > 0) ? rowHeight : containerHeight;
- if (align == alCenter) {
- int xNew = (boxWidth - elementWidth) / 2;
- numericParameters.erase(ptX);
- numericParameters.insert(pair<eParamType,int>(ptX, xNew));
- } else if (align == alRight) {
- int xNew = boxWidth - elementWidth;
- numericParameters.erase(ptX);
- numericParameters.insert(pair<eParamType,int>(ptX, xNew));
- }
-
- int vAlign = GetNumericParameter(ptValign);
- if (vAlign == alCenter) {
- int yNew = (boxHeight - elementHeight) / 2;
- numericParameters.erase(ptY);
- numericParameters.insert(pair<eParamType,int>(ptY, yNew));
- } else if (vAlign == alBottom) {
- int yNew = boxHeight - elementHeight;
- numericParameters.erase(ptY);
- numericParameters.insert(pair<eParamType,int>(ptY, yNew));
- }
-}
-
-int cTemplateFunction::CalculateTextBoxHeight(void) {
- int width = GetNumericParameter(ptWidth);
- string fontName = GetFontName();
- int fontSize = GetNumericParameter(ptFontSize);
- string text = GetText(false);
- const cFont *font = fontManager->Font(fontName, fontSize);
- if (!font)
- return 0;
-
- int fontHeight = fontManager->Height(fontName, fontSize);
- int floatType = GetNumericParameter(ptFloat);
-
- if (floatType == flNone) {
- fontManager->Lock();
- cTextWrapper wrapper;
- wrapper.Set(text.c_str(), font, width);
- fontManager->Unlock();
- int lines = wrapper.Lines();
- return (lines * fontHeight);
- }
-
- int floatWidth = GetNumericParameter(ptFloatWidth);
- int floatHeight = GetNumericParameter(ptFloatHeight);
-
- cTextWrapper wTextTall;
- cTextWrapper wTextFull;
-
- int linesNarrow = floatHeight / fontHeight;
- int widthNarrow = width - floatWidth;
- int linesDrawn = 0;
- int curY = 0;
- bool drawNarrow = true;
-
- splitstring s(text.c_str());
- vector<string> flds = s.split('\n', 1);
-
- if (flds.size() < 1)
- return 0;
-
- stringstream sstrTextTall;
- 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";
- }
- }
- }
- fontManager->Lock();
- wTextTall.Set(sstrTextTall.str().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();
-
- return ((textLinesTall+textLinesFull) * fontHeight);
-}
-
-int cTemplateFunction::ReplaceIntToken(string intTok) {
- if (intTokens) {
- map<string,int>::iterator hit = intTokens->find(intTok);
- if (hit != intTokens->end())
- return hit->second;
- }
- if (stringTokens) {
- map<string,string>::iterator hit = stringTokens->find(intTok);
- if (hit != stringTokens->end()) {
- return atoi(hit->second.c_str());
- }
- }
- return 0;
-}
-
-/*******************************************************************
-* Helper Functions
-*******************************************************************/
-
-string cTemplateFunction::GetFuncName(void) {
- string name;
- switch (type) {
- case ftOsd:
- name = "OSD Parameters";
- break;
- case ftView:
- name = "View Parameters";
- break;
- case ftViewElement:
- name = "View Element Parameters";
- break;
- case ftPixmapContainer:
- name = "Pixmap Container Parameters";
- break;
- case ftPixmap:
- name = "Pixmap Parameters";
- break;
- case ftPixmapScroll:
- name = "ScrollPixmap Parameters";
- break;
- case ftLoop:
- name = "Looping Function";
- break;
- case ftFill:
- name = "Function Fill";
- break;
- case ftDrawText:
- name = "Function DrawText";
- break;
- case ftDrawTextBox:
- name = "Function DrawTextBox";
- break;
- case ftDrawTextVertical:
- name = "Function DrawTextVertical";
- break;
- case ftDrawImage:
- name = "Function DrawImage";
- break;
- case ftDrawRectangle:
- name = "Function DrawRectangle";
- break;
- case ftDrawEllipse:
- name = "Function DrawEllipse";
- break;
- case ftDrawSlope:
- name = "Function DrawSlope";
- break;
- case ftNone:
- name = "Undefined";
- break;
- default:
- name = "Unknown";
- break;
- };
- return name;
-}
-
-string cTemplateFunction::GetParamName(eParamType pt) {
- string name;
- switch (pt) {
- case ptCond:
- name = "Condition";
- break;
- case ptName:
- name = "Name";
- break;
- case ptMode:
- name = "Mode";
- break;
- case ptX:
- name = "X";
- break;
- case ptY:
- name = "Y";
- break;
- case ptWidth:
- name = "Width";
- break;
- case ptHeight:
- name = "Height";
- break;
- case ptMenuItemWidth:
- name = "Menu Item Width";
- break;
- case ptDetached:
- name = "Detached";
- break;
- case ptFadeTime:
- name = "Fade Time";
- break;
- case ptShiftTime:
- name = "Shift Time";
- break;
- case ptShiftType:
- name = "Shift Type";
- break;
- case ptShiftMode:
- name = "Shift Mode";
- break;
- case ptStartX:
- name = "Startpos X";
- break;
- case ptStartY:
- name = "Startpos Y";
- break;
- case ptDelay:
- name = "Delay";
- break;
- case ptImageType:
- name = "Image Type";
- break;
- case ptPath:
- name = "Image Path";
- break;
- case ptColor:
- name = "Color";
- break;
- case ptFont:
- name = "Font";
- break;
- case ptFontSize:
- name = "FontSize";
- break;
- case ptText:
- name = "Text";
- break;
- case ptLayer:
- name = "Layer";
- break;
- case ptTransparency:
- name = "Transparency";
- break;
- case ptQuadrant:
- name = "Quadrant";
- break;
- case ptType:
- name = "Type";
- break;
- case ptAlign:
- name = "Align";
- break;
- case ptValign:
- name = "Vertical Align";
- break;
- case ptScrollMode:
- name = "Scroll Mode";
- break;
- case ptScrollSpeed:
- name = "Scroll Speed";
- break;
- case ptOrientation:
- name = "Orientation";
- break;
- case ptNumElements:
- name = "NumElements";
- break;
- case ptScrollElement:
- name = "Scroll Element";
- break;
- case ptScrollHeight:
- name = "Scroll Height";
- break;
- case ptFloat:
- name = "Floating Type";
- break;
- case ptFloatWidth:
- name = "Floating Width";
- break;
- case ptFloatHeight:
- name = "Floating Height";
- break;
- case ptMaxLines:
- name = "Max num of lines";
- break;
- case ptColumnWidth:
- name = "Column Width";
- break;
- case ptRowHeight:
- name = "Row Height";
- break;
- case ptOverflow:
- name = "Overflow Mode";
- break;
- case ptScaleTvX:
- name = "Scale TV Picture X";
- break;
- case ptScaleTvY:
- name = "Scale TV Picture Y";
- break;
- case ptScaleTvWidth:
- name = "Scale TV Picture Width";
- break;
- case ptScaleTvHeight:
- name = "Scale TV Picture Height";
- break;
- case ptHideRoot:
- name = "Hide Root View";
- break;
- case ptCache:
- name = "Cache Image";
- break;
- case ptDeterminateFont:
- name = "Determinate Font";
- break;
- case ptDirection:
- name = "Text Direction";
- break;
- case ptAnimType:
- name = "Animation Type";
- break;
- case ptAnimFreq:
- name = "Animation Frequency";
- break;
- default:
- name = "Unknown";
- break;
- };
- return name;
-}
-
-void cTemplateFunction::Debug(void) {
- esyslog("skindesigner: Debugging %s, Container: x = %d, y = %d, Size: %dx%d", GetFuncName().c_str(), containerX, containerY, containerWidth, containerHeight);
- esyslog("skindesigner: --- Native Parameters:");
-
- if (condParam) {
- condParam->Debug();
- }
- esyslog("skindesigner: --- Native Parameters:");
- for (map<eParamType,string>::iterator it = nativeParameters.begin(); it != nativeParameters.end(); it++) {
- esyslog("skindesigner: \"%s\" = \"%s\"", GetParamName(it->first).c_str(), (it->second).c_str());
- }
- if (numericParameters.size() > 0) {
- esyslog("skindesigner: --- Integer Parameters: ");
- for (map<eParamType,int>::iterator it = numericParameters.begin(); it != numericParameters.end(); it++) {
- esyslog("skindesigner: %s = %d", GetParamName(it->first).c_str(), it->second);
- }
- }
- if (numericDynamicParameters.size() > 0) {
- esyslog("skindesigner: --- Dynamic Integer Parameters: ");
- for (map<eParamType,string>::iterator it = numericDynamicParameters.begin(); it != numericDynamicParameters.end(); it++) {
- esyslog("skindesigner: %s = %s", GetParamName(it->first).c_str(), (it->second).c_str());
- }
- }
- if (colorParameters.size() > 0) {
- esyslog("skindesigner: --- Color Parameters:");
- for (map<eParamType,tColor>::iterator it = colorParameters.begin(); it != colorParameters.end(); it++) {
- esyslog("skindesigner: %s = %x", GetParamName(it->first).c_str(), it->second);
- }
- }
- if (textTokens.size() > 0) {
- esyslog("skindesigner: --- Text Tokens:");
- int i=0;
- for (vector<cTextToken>::iterator it = textTokens.begin(); it != textTokens.end(); it++) {
- eTextTokenType tokenType = (*it).type;
- string tokType = "";
- if (tokenType == ttConstString)
- tokType = "Const";
- else if (tokenType == ttToken)
- tokType = "Token";
- else if (tokenType == ttConditionalToken)
- tokType = "Conditional Token";
- else if (tokenType == ttPrintfToken)
- tokType = "PrintF Token";
- esyslog("skindesigner: Token %d Type %s : \"%s\"", i++, tokType.c_str(), (*it).value.c_str());
- if (tokenType == ttConditionalToken) {
- for (vector<cTextToken>::iterator it2 = (*it).subTokens.begin(); it2 != (*it).subTokens.end(); it2++) {
- eTextTokenType tokenTypeCond = (*it2).type;
- string tokTypeCond = "";
- if (tokenTypeCond == ttConstString)
- tokTypeCond = "Const: ";
- else if (tokenTypeCond == ttToken)
- tokTypeCond = "Token: ";
- esyslog("skindesigner: %s \"%s\"", tokTypeCond.c_str(), (*it2).value.c_str());
- }
- }
- if (tokenType == ttPrintfToken) {
- for (vector<string>::iterator it2 = (*it).parameters.begin(); it2 != (*it).parameters.end(); it2++) {
- esyslog("skindesigner: PrintF parameter: %s", (*it2).c_str());
- }
- }
- }
- }
- if (fontName.size() > 0) {
- esyslog("skindesigner: --- Font Name: \"%s\"", fontName.c_str());
- }
- if (parsedText.size() > 0) {
- esyslog("skindesigner: --- Parsed Text: \"%s\"", parsedText.c_str());
- }
- if (type == ftDrawText) {
- esyslog("skindesigner: --- Cutted Text: \"%s\"", cuttedText.c_str());
- esyslog("skindesigner: --- Parsed Text Width: %d", parsedTextWidth);
- esyslog("skindesigner: --- Already Cutted: %s", alreadyCutted ? "true" : "false");
- }
- if (imgPath.size() > 0) {
- esyslog("skindesigner: --- Image Path: \"%s\"", imgPath.c_str());
- }
-}
diff --git a/libtemplate/templatefunction.h b/libtemplate/templatefunction.h deleted file mode 100644 index d800c5f..0000000 --- a/libtemplate/templatefunction.h +++ /dev/null @@ -1,270 +0,0 @@ -#ifndef __TEMPLATEFUNCTION_H -#define __TEMPLATEFUNCTION_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" -#include "parameter.h" - -using namespace std; - -// --- cTemplateFunction ------------------------------------------------------------- - -enum eFuncType { - ftOsd, - ftView, - ftViewElement, - ftViewList, - ftPixmapContainer, - ftPixmap, - ftPixmapScroll, - ftLoop, - ftFill, - ftDrawText, - ftDrawTextBox, - ftDrawTextVertical, - ftDrawImage, - ftDrawRectangle, - ftDrawEllipse, - ftDrawSlope, - ftNone -}; - -enum eParamType { - ptCond, - ptName, - ptMode, - ptDrawDebugGrid, - ptDebugGridX, - ptDebugGridY, - ptX, - ptY, - ptWidth, - ptHeight, - ptMenuItemWidth, - ptDetached, - ptFadeTime, - ptShiftTime, - ptShiftType, - ptShiftMode, - ptStartX, - ptStartY, - ptDelay, - ptImageType, - ptPath, - ptColor, - ptFont, - ptFontSize, - ptText, - ptLayer, - ptTransparency, - ptBackground, - ptQuadrant, - ptType, - ptAlign, - ptValign, - ptScrollMode, - ptScrollSpeed, - ptOrientation, - ptNumElements, - ptScrollElement, - ptScrollHeight, - ptFloat, - ptFloatWidth, - ptFloatHeight, - ptMaxLines, - ptColumnWidth, - ptRowHeight, - ptOverflow, - ptScaleTvX, - ptScaleTvY, - ptScaleTvWidth, - ptScaleTvHeight, - ptHideRoot, - ptCache, - ptDeterminateFont, - ptDirection, - ptAnimType, - ptAnimFreq, - ptNone -}; - -enum eImageType { - itChannelLogo, - itSepLogo, - itSkinPart, - itMenuIcon, - itIcon, - itImage -}; - -enum eShiftType { - stNone, - stLeft, - stRight, - stTop, - stBottom -}; - -enum eShiftMode { - smLinear, - smSlowedDown -}; - -enum eAnimType { - atNone, - atBlink, - atAnimated -}; - -enum eFloatType { - flNone, - flTopLeft, - flTopRight -}; - -enum eOverflowType { - otNone, - otWrap, - otCut -}; - -enum eDirection { - diNone, - diBottomUp, - diTopDown -}; - -class cTemplateFunction { -protected: - eFuncType type; - bool debug; - int containerX; //X of parent container - int containerY; //Y of parent container - int containerWidth; //width of parent container - int containerHeight; //height of parent container - int columnWidth; //if func is executed in a loop, width of loop column - int rowHeight; //if func is executed in a loop, height of loop row - cGlobals *globals; //globals - map< eParamType, string > nativeParameters; //native parameters directly from xml - map< eParamType, int > numericParameters; //sucessfully parsed numeric parameters - map< eParamType, string > numericDynamicParameters; //numeric parameters with dynamic tokens - bool parsedCompletely; - bool updated; - map< eParamType, tColor > colorParameters; - cConditionalParameter *condParam; - //drawimage parameters - string imgPath; - //drawtext parameters - string fontName; - vector<cTextToken> textTokens; - string parsedText; - int parsedTextWidth; - string cuttedText; - bool alreadyCutted; - //drawtextbox parameters - int textboxHeight; - //dynamic tokens - map < string, string > *stringTokens; - map < string, int > *intTokens; - //private functions - bool SetCondition(string cond); - bool SetNumericParameter(eParamType type, string value); - bool SetAlign(eParamType type, string value); - bool SetFont(eParamType type, string value); - bool SetImageType(eParamType type, string value); - bool SetColor(eParamType type, string value); - bool SetTextTokens(string value); - void ParseTextToken(string &value, size_t start, size_t end); - void ParseConditionalTextToken(string &value, size_t start, size_t end); - void ParsePrintfTextToken(string &value, size_t start, size_t end); - bool SetScrollMode(string value); - bool SetScrollSpeed(string value); - bool SetOrientation(string value); - bool SetFloating(string value); - bool SetOverflow(string value); - bool SetHideRoot(string value); - bool SetDetached(string value); - bool SetBackground(string value); - bool SetDirection(string value); - bool SetAnimType(string value); - bool SetShiftType(string value); - bool SetShiftMode(string value); - void SetDebugGrid(string value); - void ParseStringParameters(void); - void ParseNumericalParameters(void); - void CalculateAlign(int elementWidth, int elementHeight); - int CalculateTextBoxHeight(void); - int ReplaceIntToken(string intTok); -public: - cTemplateFunction(eFuncType type); - virtual ~cTemplateFunction(void); - //Setter Functions - void SetParameters(vector<pair<string, string> > params); - void SetParameter(eParamType type, string value); - void SetContainer(int x, int y, int w, int h); - void SetLoopContainer(int columnWidth, int rowHeight); - void SetWidthManually(string width); - void SetHeightManually(string height); - void SetXManually(int newX); - void SetYManually(int newY); - void SetMaxTextWidth(int maxWidth); - void SetTextboxHeight(int boxHeight); - void SetGlobals(cGlobals *globals) { this->globals = globals; }; - void SetTranslatedText(string translation); - //PreCache Parameters - bool CalculateParameters(void); - //Complete Parameters - bool ReCalculateParameters(void); - void CompleteParameters(void); - //Set and Unset Dynamic Tokens from view - void SetStringTokens(map < string, string > *tok) { stringTokens = tok; }; - void SetIntTokens(map < string, int > *tok) { intTokens = tok; }; - void UnsetIntTokens(void) { intTokens = NULL; }; - void UnsetStringTokens(void) { stringTokens = NULL; }; - //Clear dynamically parameters - void ClearDynamicParameters(void); - //Parse parameters with dynamically set Tokens - bool ParseParameters(void); - //Getter Functions - eFuncType GetType(void) { return type; }; - bool DoDebug(void) { return debug; }; - string GetParameter(eParamType type); - int GetNumericParameter(eParamType type); - string GetText(bool cut = true); - string GetImagePath(void) { return imgPath; }; - tColor GetColorParameter(eParamType type); - string GetFontName(void) { return fontName; }; - string GetFuncName(void); - string GetParamName(eParamType pt); - //Dynamic width or height parameter - int GetWidth(bool cutted = true); - int GetHeight(map < string, vector< map< string, string > > > *loopTokens = NULL); - int GetContainerWidth(void) { return containerWidth; }; - int GetContainerHeight(void) { return containerHeight; }; - void GetNeededWidths(multimap<eParamType,string> *widths); - void GetNeededHeights(multimap<eParamType,string> *heights); - void GetNeededPosX(multimap<eParamType,string> *posXs); - void GetNeededPosY(multimap<eParamType,string> *posYs); - void SetWidth(eParamType type, string label, int funcWidth); - void SetHeight(eParamType type, string label, int funcHeight); - void SetX(eParamType type, string label, int funcX); - void SetY(eParamType type, string label, int funcY); - //Status Functions - bool ParsedCompletely(void) { return parsedCompletely; }; - bool DoExecute(void); - bool Updated(void) { return updated; }; - bool IsAnimated(void); - //Debug - void Debug(void); -}; - -#endif //__TEMPLATEFUNCTION_H
\ No newline at end of file diff --git a/libtemplate/templateloopfunction.c b/libtemplate/templateloopfunction.c deleted file mode 100644 index 07219ac..0000000 --- a/libtemplate/templateloopfunction.c +++ /dev/null @@ -1,248 +0,0 @@ -#include "templateloopfunction.h" -#include "../libcore/helpers.h" - -using namespace std; - -// --- cTemplateFunction ------------------------------------------------------------- - -cTemplateLoopFunction::cTemplateLoopFunction(void) : cTemplateFunction(ftLoop) { -} - -cTemplateLoopFunction::~cTemplateLoopFunction(void) { -} - -void cTemplateLoopFunction::InitIterator(void) { - funcIt = functions.begin(); -} - -void cTemplateLoopFunction::AddFunction(string name, vector<pair<string, string> > ¶ms) { - eFuncType type = ftNone; - - if (!name.compare("drawtext")) { - type = ftDrawText; - } else if (!name.compare("drawtextbox")) { - type = ftDrawTextBox; - } else if (!name.compare("drawimage")) { - type = ftDrawImage; - } else if (!name.compare("drawrectangle")) { - type = ftDrawRectangle; - } else if (!name.compare("drawellipse")) { - type = ftDrawEllipse; - } - - if (type == ftNone) { - return; - } - - cTemplateFunction *f = new cTemplateFunction(type); - f->SetParameters(params); - functions.push_back(f); -} - -void cTemplateLoopFunction::CalculateLoopFuncParameters(void) { - int columnWidth = GetNumericParameter(ptColumnWidth); - int rowHeight = GetNumericParameter(ptRowHeight); - for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) { - (*func)->SetGlobals(globals); - (*func)->SetContainer(0, 0, containerWidth, containerHeight); - (*func)->SetLoopContainer(columnWidth, rowHeight); - (*func)->CalculateParameters(); - (*func)->CompleteParameters(); - } -} - -cTemplateFunction *cTemplateLoopFunction::GetNextFunction(void) { - if (funcIt == functions.end()) - return NULL; - cTemplateFunction *func = *funcIt; - funcIt++; - return func; -} - -void cTemplateLoopFunction::ClearDynamicParameters(void) { - InitIterator(); - cTemplateFunction *func = NULL; - while(func = GetNextFunction()) { - func->ClearDynamicParameters(); - } -} - -void cTemplateLoopFunction::ParseDynamicParameters(map <string,string> *tokens) { - if (!tokens) - return; - InitIterator(); - cTemplateFunction *func = NULL; - - map <string,int> intTokens; - for (map <string,string>::iterator it = tokens->begin(); it != tokens->end(); it++) { - if (isNumber(it->second)) - intTokens.insert(pair<string, int>(it->first, atoi((it->second).c_str()))); - } - - bool completelyParsed = true; - while(func = GetNextFunction()) { - func->SetStringTokens(tokens); - func->SetIntTokens(&intTokens); - bool funcCompletelyParsed = func->ParseParameters(); - if (!funcCompletelyParsed) - completelyParsed = false; - if (func->Updated()) - func->CompleteParameters(); - func->UnsetStringTokens(); - func->UnsetIntTokens(); - } - if (completelyParsed) { - return; - } - - bool replacedWidth = ReplaceWidthFunctions(); - bool replacedHeight = ReplaceHeightFunctions(); - - if (!replacedWidth && !replacedHeight) - return; - - InitIterator(); - func = NULL; - while(func = GetNextFunction()) { - if (func->ParsedCompletely()) - continue; - func->SetStringTokens(tokens); - func->SetIntTokens(&intTokens); - func->ParseParameters(); - if (func->Updated()) - func->CompleteParameters(); - func->UnsetIntTokens(); - func->UnsetStringTokens(); - } -} - -int cTemplateLoopFunction::GetLoopElementsWidth(void) { - int cW = GetNumericParameter(ptColumnWidth); - if (cW > 0) { - return cW; - } - InitIterator(); - cTemplateFunction *func = NULL; - int maxWidth = 1; - while(func = GetNextFunction()) { - int funcWidth = func->GetWidth(true); - if (funcWidth > maxWidth) - maxWidth = funcWidth; - } - return maxWidth; -} - -int cTemplateLoopFunction::GetLoopElementsHeight(void) { - int rH = GetNumericParameter(ptRowHeight); - if (rH > 0) - return rH; - InitIterator(); - cTemplateFunction *func = NULL; - int maxHeight = 1; - while(func = GetNextFunction()) { - int funcY = func->GetNumericParameter(ptY); - int funcHeight = func->GetHeight(); - int totalHeight = funcY + funcHeight; - if (totalHeight > maxHeight) - maxHeight = totalHeight; - } - return maxHeight; -} - -int cTemplateLoopFunction::CalculateHeight(map < string, vector< map< string, string > > > *loopTokens) { - if (!loopTokens) { - return 0; - } - int rowHeight = GetLoopElementsHeight(); - string loopName = GetParameter(ptName); - map < string, vector< map< string, string > > >::iterator hit = loopTokens->find(loopName); - if (hit == loopTokens->end()) - return 0; - vector< map< string, string > > toks = hit->second; - int numElements = toks.size(); - - return numElements * rowHeight; -} - -bool cTemplateLoopFunction::ReplaceWidthFunctions(void) { - bool replaced = false; - InitIterator(); - cTemplateFunction *func = NULL; - while(func = GetNextFunction()) { - if (func->ParsedCompletely()) { - continue; - } - multimap<eParamType,string> widths; - func->GetNeededWidths(&widths); - for (map<eParamType, string>::iterator names = widths.begin(); names !=widths.end(); names++) { - eParamType type = names->first; - string label = names->second; - int funcWidth = 0; - for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) { - cTemplateFunction *myFunc = *it; - string myFuncName = myFunc->GetParameter(ptName); - if (!myFuncName.compare(label)) { - funcWidth = myFunc->GetWidth(); - func->SetWidth(type, label, funcWidth); - if (func->Updated()) { - func->CompleteParameters(); - } else { - replaced = true; - } - } - } - } - } - return replaced; -} - -bool cTemplateLoopFunction::ReplaceHeightFunctions(void) { - bool replaced = false; - InitIterator(); - cTemplateFunction *func = NULL; - while(func = GetNextFunction()) { - if (func->ParsedCompletely()) { - continue; - } - multimap<eParamType,string> heights; - func->GetNeededHeights(&heights); - for (map<eParamType, string>::iterator names = heights.begin(); names !=heights.end(); names++) { - eParamType type = names->first; - string label = names->second; - int funcHeight = 0; - for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) { - cTemplateFunction *myFunc = *it; - string myFuncName = myFunc->GetParameter(ptName); - if (!myFuncName.compare(label)) { - funcHeight = myFunc->GetHeight(); - func->SetHeight(type, label, funcHeight); - if (func->Updated()) { - func->CompleteParameters(); - } else { - replaced = true; - } - } - } - } - } - return replaced; -} - -bool cTemplateLoopFunction::Ready(void) { - bool isReady = true; - map< eParamType, string >::iterator hit = numericDynamicParameters.find(ptColumnWidth); - if (hit != numericDynamicParameters.end()) - isReady = false; - hit = numericDynamicParameters.find(ptRowHeight); - if (hit != numericDynamicParameters.end()) - isReady = false; - return isReady; -} - -void cTemplateLoopFunction::Debug(void) { - cTemplateFunction::Debug(); - esyslog("skindesigner: functions to be looped:"); - for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) { - (*func)->Debug(); - } -}
\ No newline at end of file diff --git a/libtemplate/templateloopfunction.h b/libtemplate/templateloopfunction.h deleted file mode 100644 index 1a28c65..0000000 --- a/libtemplate/templateloopfunction.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __TEMPLATELOOPFUNCTION_H -#define __TEMPLATELOOPFUNCTION_H - -#include "templatefunction.h" - -using namespace std; - -// --- cTemplateLoopFunction ------------------------------------------------------------- - -class cTemplateLoopFunction : public cTemplateFunction { -private: - vector<cTemplateFunction*> functions; - vector<cTemplateFunction*>::iterator funcIt; - bool ReplaceWidthFunctions(void); - bool ReplaceHeightFunctions(void); -public: - cTemplateLoopFunction(void); - virtual ~cTemplateLoopFunction(void); - void AddFunction(string name, vector<pair<string, string> > ¶ms); - void CalculateLoopFuncParameters(void); - void InitIterator(void); - cTemplateFunction *GetNextFunction(void); - void ClearDynamicParameters(void); - void ParseDynamicParameters(map <string,string> *tokens); - int GetLoopElementsWidth(void); - int GetLoopElementsHeight(void); - int GetContainerWidth(void) { return containerWidth; }; - int GetContainerHeight(void) { return containerHeight; }; - int CalculateHeight(map < string, vector< map< string, string > > > *loopTokens); - bool Ready(void); - void Debug(void); -}; - -#endif //__TEMPLATELOOPFUNCTION_H diff --git a/libtemplate/templatepixmap.c b/libtemplate/templatepixmap.c deleted file mode 100644 index 117ab25..0000000 --- a/libtemplate/templatepixmap.c +++ /dev/null @@ -1,739 +0,0 @@ -#include "templatepixmap.h"
-
-using namespace std;
-// --- cTemplatePixmapNode -------------------------------------------------------------
-
-cTemplatePixmapNode::cTemplatePixmapNode(void) {
- parameters = NULL;
- globals = NULL;
- containerX = 0;
- containerY = 0;
- containerWidth = 0;
- containerHeight = 0;
-}
-
-cTemplatePixmapNode::~cTemplatePixmapNode() {
- if (parameters)
- delete parameters;
-}
-
-void cTemplatePixmapNode::SetParameters(vector<stringpair> ¶ms) {
- parameters = new cTemplateFunction(isContainer?ftPixmapContainer:ftPixmap);
- parameters->SetGlobals(globals);
- parameters->SetParameters(params);
-}
-
-void cTemplatePixmapNode::SetContainer(int x, int y, int w, int h) {
- containerX = x;
- containerY = y;
- containerWidth = w;
- containerHeight = h;
-}
-
-// --- cTemplatePixmap -------------------------------------------------------------
-
-cTemplatePixmap::cTemplatePixmap(void) {
- pixContainer = NULL;
- isContainer = false;
- scrolling = false;
- background = false;
-}
-
-cTemplatePixmap::~cTemplatePixmap() {
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- delete (*it);
- }
-}
-
-void cTemplatePixmap::SetWidth(int width) {
- cString pWidth = cString::sprintf("%d", width);
- parameters->SetWidthManually(*pWidth);
-}
-
-void cTemplatePixmap::SetHeight(int height) {
- cString pHeight = cString::sprintf("%d", height);
- parameters->SetHeightManually(*pHeight);
-}
-
-void cTemplatePixmap::SetX(int x) {
- parameters->SetXManually(x);
-}
-
-void cTemplatePixmap::SetY(int y) {
- parameters->SetYManually(y);
-}
-
-void cTemplatePixmap::SetWidthPercent(double width) {
- int absWidth = containerWidth * width;
- cString pWidth = cString::sprintf("%d", absWidth);
- parameters->SetWidthManually(*pWidth);
-}
-
-void cTemplatePixmap::SetHeightPercent(double height) {
- int absHeight = containerHeight * height;
- cString pHeight = cString::sprintf("%d", absHeight);
- parameters->SetHeightManually(*pHeight);
-}
-
-void cTemplatePixmap::SetXPercent(double x) {
- int absX = containerX + containerWidth * x;
- parameters->SetXManually(absX);
-}
-
-void cTemplatePixmap::SetYPercent(double y) {
- int absY = containerY + containerHeight * y;
- parameters->SetYManually(absY);
-}
-
-void cTemplatePixmap::SetParameter(eParamType type, string value) {
- parameters->SetParameter(type, value);
-}
-
-
-void cTemplatePixmap::ClearDynamicParameters(void) {
- parameters->ClearDynamicParameters();
-}
-
-void cTemplatePixmap::ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens, bool initFuncs) {
- parameters->ClearDynamicParameters();
- parameters->SetIntTokens(intTokens);
- parameters->SetStringTokens(stringTokens);
- parameters->ParseParameters();
- parameters->UnsetIntTokens();
- parameters->UnsetStringTokens();
-
- if (!DoExecute()) {
- parameters->ClearDynamicParameters();
- return;
- }
-
- if (!initFuncs || !Ready())
- return;
-
- int x = parameters->GetNumericParameter(ptX);
- int y = parameters->GetNumericParameter(ptY);
- int width = parameters->GetNumericParameter(ptWidth);
- int height = parameters->GetNumericParameter(ptHeight);
-
- for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
- (*func)->SetContainer(x, y, width, height);
- (*func)->ReCalculateParameters();
- (*func)->CompleteParameters();
- if ((*func)->GetType() == ftLoop) {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(*func);
- if (!loopFunc->Ready()) {
- loopFunc->CalculateParameters();
- loopFunc->SetIntTokens(intTokens);
- loopFunc->ParseParameters();
- loopFunc->UnsetIntTokens();
- }
- loopFunc->CalculateLoopFuncParameters();
- }
- }
-}
-
-void cTemplatePixmap::AddFunction(string name, vector<pair<string, string> > ¶ms) {
- eFuncType type = ftNone;
-
- if (!name.compare("fill")) {
- type = ftFill;
- } else if (!name.compare("drawtext")) {
- type = ftDrawText;
- } else if (!name.compare("drawtextbox")) {
- type = ftDrawTextBox;
- } else if (!name.compare("drawtextvertical")) {
- type = ftDrawTextVertical;
- } else if (!name.compare("drawimage")) {
- type = ftDrawImage;
- } else if (!name.compare("drawrectangle")) {
- type = ftDrawRectangle;
- } else if (!name.compare("drawellipse")) {
- type = ftDrawEllipse;
- } else if (!name.compare("drawslope")) {
- type = ftDrawSlope;
- }
-
- if (type == ftNone) {
- return;
- }
-
- cTemplateFunction *f = new cTemplateFunction(type);
- f->SetParameters(params);
- functions.push_back(f);
-}
-
-void cTemplatePixmap::AddLoopFunction(cTemplateLoopFunction *lf) {
- functions.push_back(lf);
-}
-
-
-bool cTemplatePixmap::CalculateParameters(void) {
- bool paramsValid = true;
- //Calculate Pixmap Size
- parameters->SetContainer(containerX, containerY, containerWidth, containerHeight);
- parameters->SetGlobals(globals);
- paramsValid = parameters->CalculateParameters();
-
- int pixWidth = parameters->GetNumericParameter(ptWidth);
- int pixHeight = parameters->GetNumericParameter(ptHeight);
-
- for (vector<cTemplateFunction*>::iterator func = functions.begin(); func != functions.end(); func++) {
- (*func)->SetGlobals(globals);
- (*func)->SetContainer(0, 0, pixWidth, pixHeight);
- paramsValid = (*func)->CalculateParameters();
- (*func)->CompleteParameters();
- if ((*func)->GetType() == ftLoop) {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(*func);
- loopFunc->CalculateLoopFuncParameters();
- }
- }
-
- background = parameters->GetNumericParameter(ptBackground);
-
- return paramsValid;
-}
-
-void cTemplatePixmap::ClearDynamicFunctionParameters(void) {
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- func->ClearDynamicParameters();
- }
-}
-
-void cTemplatePixmap::ParseDynamicFunctionParameters(map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens) {
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- bool completelyParsed = true;
- while(func = GetNextFunction()) {
- func->SetStringTokens(stringTokens);
- func->SetIntTokens(intTokens);
- bool funcCompletelyParsed = func->ParseParameters();
- if (!funcCompletelyParsed)
- completelyParsed = false;
- if (func->Updated())
- func->CompleteParameters();
- func->UnsetIntTokens();
- func->UnsetStringTokens();
- }
-
- if (completelyParsed) {
- return;
- }
-
- bool replacedWidth = ReplaceWidthFunctions();
- bool replacedHeight = ReplaceHeightFunctions(loopTokens);
- bool replacedPosX = ReplacePosXFunctions();
- bool replacedPosY = ReplacePosYFunctions();
-
- if (!replacedWidth && !replacedHeight && !replacedPosX && !replacedPosY)
- return;
-
- InitFunctionIterator();
- func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely())
- continue;
- func->SetStringTokens(stringTokens);
- func->SetIntTokens(intTokens);
- func->ParseParameters();
- if (func->Updated())
- func->CompleteParameters();
- func->UnsetIntTokens();
- func->UnsetStringTokens();
- }
-}
-
-bool cTemplatePixmap::CalculateDrawPortSize(cSize &size, map < string, vector< map< string, string > > > *loopTokens) {
- int pixWidth = parameters->GetNumericParameter(ptWidth);
- int pixHeight = parameters->GetNumericParameter(ptHeight);
- int orientation = parameters->GetNumericParameter(ptOrientation);
- if (orientation < 0)
- orientation = orVertical;
- if (orientation == orHorizontal) {
- //get function which determinates drawport width
- cTemplateFunction *scrollFunc = GetScrollFunction();
- if (!scrollFunc)
- return false;
- int drawportWidth = scrollFunc->GetWidth(false) + scrollFunc->GetNumericParameter(ptX) + 10;
- if (drawportWidth > pixWidth) {
- size.SetWidth(drawportWidth);
- size.SetHeight(pixHeight);
- return true;
- }
- } else if (orientation == orVertical) {
- //check "last" element height
- InitFunctionIterator();
- cTemplateFunction *f = NULL;
- int drawportHeight = 1;
- while (f = GetNextFunction()) {
- if (f->GetType() == ftLoop) {
- cTemplateLoopFunction *loopFunc = dynamic_cast<cTemplateLoopFunction*>(f);
- //get number of loop tokens
- string loopTokenName = loopFunc->GetParameter(ptName);
- int numLoopTokens = 0;
- map < string, vector< map< string, string > > >::iterator hit = loopTokens->find(loopTokenName);
- if (hit != loopTokens->end()) {
- vector< map<string,string> > loopToken = hit->second;
- numLoopTokens = loopToken.size();
- //parse first loop token element to get correct height
- vector< map<string,string> >::iterator firstLoopToken = loopToken.begin();
- loopFunc->ClearDynamicParameters();
- loopFunc->ParseDynamicParameters(&(*firstLoopToken));
- }
- int orientation = loopFunc->GetNumericParameter(ptOrientation);
- int yFunc = loopFunc->GetNumericParameter(ptY);
- int heightFunc = loopFunc->GetLoopElementsHeight();
- if (loopTokens && orientation == orVertical) {
- //height is height of loop elements times num loop elements
- heightFunc = heightFunc * numLoopTokens;
- } else if (loopTokens && orientation == orHorizontal) {
- int overflow = loopFunc->GetNumericParameter(ptOverflow);
- if (overflow == otCut) {
- //do nothing, height is only height of one line
- } else if (overflow == otWrap) {
- int widthFunc = loopFunc->GetLoopElementsWidth();
- if (widthFunc <= 0)
- continue;
- int loopWidth = loopFunc->GetNumericParameter(ptWidth);
- if (loopWidth <= 0)
- loopWidth = loopFunc->GetContainerWidth();
- int elementsPerRow = loopWidth / widthFunc;
- int rest = loopWidth % widthFunc;
- if (rest > 0)
- elementsPerRow++;
- if (elementsPerRow <= 0)
- continue;
- int lines = numLoopTokens / elementsPerRow;
- rest = numLoopTokens % elementsPerRow;
- if (rest > 0)
- lines++;
- heightFunc = heightFunc * lines;
- }
- }
- int neededHeight = heightFunc + yFunc;
- if (neededHeight > drawportHeight)
- drawportHeight = neededHeight;
- } else {
- int yFunc = f->GetNumericParameter(ptY);
- int heightFunc = f->GetHeight();
- int neededHeight = heightFunc + yFunc;
- if (neededHeight > drawportHeight)
- drawportHeight = neededHeight;
- }
- }
- if (drawportHeight > pixHeight) {
- size.SetWidth(pixWidth);
- size.SetHeight(drawportHeight);
- return true;
- }
- }
- size.SetWidth(0);
- size.SetHeight(0);
- return false;
-}
-
-void cTemplatePixmap::SetScrollingTextWidth(void) {
- int orientation = parameters->GetNumericParameter(ptOrientation);
- if (orientation != orHorizontal)
- return;
- int pixWidth = parameters->GetNumericParameter(ptWidth);
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->GetType() == ftDrawText) {
- int offset = func->GetNumericParameter(ptX);
- func->SetMaxTextWidth(pixWidth - offset);
- }
- }
-}
-
-
-cTemplateFunction *cTemplatePixmap::GetScrollFunction(void) {
- string scrollElement = parameters->GetParameter(ptScrollElement);
- if (scrollElement.size() == 0)
- return NULL;
- InitFunctionIterator();
- cTemplateFunction *f = NULL;
- while (f = GetNextFunction()) {
- string funcName = f->GetParameter(ptName);
- if (!funcName.compare(scrollElement)) {
- return f;
- }
- }
- return NULL;
-}
-
-cRect cTemplatePixmap::GetPixmapSize(void) {
- cRect size;
- size.SetX(GetNumericParameter(ptX));
- size.SetY(GetNumericParameter(ptY));
- size.SetWidth(GetNumericParameter(ptWidth));
- size.SetHeight(GetNumericParameter(ptHeight));
- return size;
-}
-
-int cTemplatePixmap::GetNumericParameter(eParamType type) {
- if (!parameters)
- return -1;
- return parameters->GetNumericParameter(type);
-}
-
-void cTemplatePixmap::InitFunctionIterator(void) {
- funcIt = functions.begin();
-}
-
-cTemplateFunction *cTemplatePixmap::GetNextFunction(void) {
- if (funcIt == functions.end())
- return NULL;
- cTemplateFunction *func = *funcIt;
- funcIt++;
- return func;
-}
-
-bool cTemplatePixmap::Ready(void) {
- int myX = parameters->GetNumericParameter(ptX);
- if (myX < 0)
- return false;
- int myY = parameters->GetNumericParameter(ptY);
- if (myY < 0)
- return false;
- int myWidth = parameters->GetNumericParameter(ptWidth);
- if (myWidth < 1)
- return false;
- int myHeight = parameters->GetNumericParameter(ptHeight);
- if (myHeight < 1)
- return false;
- return true;
-}
-
-bool cTemplatePixmap::ParameterSet(eParamType type) {
- string value = parameters->GetParameter(type);
- if (value.size() > 0)
- return true;
- return false;
-}
-
-cTemplateFunction *cTemplatePixmap::GetFunction(string name) {
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- string funcName = (*it)->GetParameter(ptName);
- if (!name.compare(funcName))
- return *it;
- }
- return NULL;
-}
-
-bool cTemplatePixmap::ReplaceWidthFunctions(void) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> widths;
- func->GetNeededWidths(&widths);
- for (map<eParamType, string>::iterator names = widths.begin(); names !=widths.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcWidth = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcWidth = myFunc->GetWidth();
- func->SetWidth(type, label, funcWidth);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcWidth = myFunc->GetWidth();
- func->SetWidth(type, label, funcWidth);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-bool cTemplatePixmap::ReplaceHeightFunctions(map < string, vector< map< string, string > > > *loopTokens) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> heights;
- func->GetNeededHeights(&heights);
- for (map<eParamType, string>::iterator names = heights.begin(); names !=heights.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcHeight = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcHeight = myFunc->GetHeight(loopTokens);
- func->SetHeight(type, label, funcHeight);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcHeight = myFunc->GetHeight(loopTokens);
- func->SetHeight(type, label, funcHeight);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-bool cTemplatePixmap::ReplacePosXFunctions(void) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> posXs;
- func->GetNeededPosX(&posXs);
- for (map<eParamType, string>::iterator names = posXs.begin(); names !=posXs.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcX = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcX = myFunc->GetNumericParameter(ptX);
- if (funcX > -1) {
- func->SetX(type, label, funcX);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcX = myFunc->GetNumericParameter(ptX);
- if (funcX > -1) {
- func->SetX(type, label, funcX);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-bool cTemplatePixmap::ReplacePosYFunctions(void) {
- bool replaced = false;
- bool found = false;
- InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = GetNextFunction()) {
- if (func->ParsedCompletely()) {
- continue;
- }
- multimap<eParamType,string> posYs;
- func->GetNeededPosY(&posYs);
- for (map<eParamType, string>::iterator names = posYs.begin(); names !=posYs.end(); names++) {
- eParamType type = names->first;
- string label = names->second;
- int funcY = 0;
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- cTemplateFunction *myFunc = *it;
- string myFuncName = myFunc->GetParameter(ptName);
- if (!myFuncName.compare(label)) {
- found = true;
- funcY = myFunc->GetNumericParameter(ptY);
- if (funcY > -1) {
- func->SetY(type, label, funcY);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- if (!found && pixContainer) {
- cTemplateFunction *myFunc = pixContainer->GetFunction(label);
- if (myFunc) {
- funcY = myFunc->GetNumericParameter(ptY);
- if (funcY > -1) {
- func->SetY(type, label, funcY);
- if (func->Updated()) {
- func->CompleteParameters();
- } else {
- replaced = true;
- }
- }
- break;
- }
- }
- }
- }
- return replaced;
-}
-
-void cTemplatePixmap::Debug(void) {
- esyslog("skindesigner: pixmap container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight);
- parameters->Debug();
- for (vector<cTemplateFunction*>::iterator it = functions.begin(); it != functions.end(); it++) {
- (*it)->Debug();
- }
-}
-
-// --- cTemplatePixmapContainer -------------------------------------------------------------
-
-cTemplatePixmapContainer::cTemplatePixmapContainer(void) {
- isContainer = true;
-}
-
-cTemplatePixmapContainer::~cTemplatePixmapContainer() {
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- delete (*it);
- }
-}
-
-void cTemplatePixmapContainer::SetGlobals(cGlobals *globals) {
- this->globals = globals;
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetGlobals(globals);
- }
-}
-
-void cTemplatePixmapContainer::SetWidth(int width) {
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetWidth(width);
- }
-}
-
-void cTemplatePixmapContainer::SetHeight(int height) {
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetHeight(height);
- }
-}
-
-void cTemplatePixmapContainer::AddPixmap(cTemplatePixmap *pix) {
- //setting default parameters of container if parameter is not set in area
- string containerDefaultX = parameters->GetParameter(ptX);
- string containerDefaultY = parameters->GetParameter(ptY);
- string containerDefaultWidth = parameters->GetParameter(ptWidth);
- string containerDefaultHeight = parameters->GetParameter(ptHeight);
- if (containerDefaultX.size() > 0 && !pix->ParameterSet(ptX))
- pix->SetParameter(ptX, containerDefaultX);
- if (containerDefaultY.size() > 0 && !pix->ParameterSet(ptY))
- pix->SetParameter(ptY, containerDefaultY);
- if (containerDefaultWidth.size() > 0 && !pix->ParameterSet(ptWidth))
- pix->SetParameter(ptWidth, containerDefaultWidth);
- if (containerDefaultHeight.size() > 0 && !pix->ParameterSet(ptHeight))
- pix->SetParameter(ptHeight, containerDefaultHeight);
-
- pix->SetPixmapContainer(this);
- pixmaps.push_back(pix);
-}
-
-bool cTemplatePixmapContainer::CalculateParameters(void) {
- bool paramsValid = true;
- //Calculate Pixmap Size
- parameters->SetContainer(containerX, containerY, containerWidth, containerHeight);
- parameters->SetGlobals(globals);
- paramsValid = parameters->CalculateParameters();
-
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->SetContainer(containerX, containerY, containerWidth, containerHeight);
- (*it)->SetGlobals(globals);
- paramsValid = (*it)->CalculateParameters() && paramsValid;
- }
-
- return paramsValid;
-}
-
-void cTemplatePixmapContainer::ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens) {
- parameters->ClearDynamicParameters();
- parameters->SetIntTokens(intTokens);
- parameters->SetStringTokens(stringTokens);
- parameters->ParseParameters();
- parameters->UnsetIntTokens();
- parameters->UnsetStringTokens();
-}
-
-void cTemplatePixmapContainer::InitIterator(void) {
- pixmapIterator = pixmaps.begin();
-}
-
-cTemplatePixmap *cTemplatePixmapContainer::GetNextPixmap(void) {
- if (pixmapIterator == pixmaps.end())
- return NULL;
- cTemplatePixmap *pix = *pixmapIterator;
- pixmapIterator++;
- return pix;
-}
-
-cTemplateFunction *cTemplatePixmapContainer::GetFunction(string name) {
- cTemplateFunction *hit = NULL;
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- hit = (*it)->GetFunction(name);
- if (hit)
- return hit;
- }
- return NULL;
-}
-
-
-void cTemplatePixmapContainer::Debug(void) {
- esyslog("skindesigner: pixmapcontainer");
- parameters->Debug();
- for (vector<cTemplatePixmap*>::iterator it = pixmaps.begin(); it != pixmaps.end(); it++) {
- (*it)->Debug();
- }
-}
-
diff --git a/libtemplate/templatepixmap.h b/libtemplate/templatepixmap.h deleted file mode 100644 index f9c2f6f..0000000 --- a/libtemplate/templatepixmap.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef __TEMPLATEPIXMAP_H -#define __TEMPLATEPIXMAP_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "globals.h" -#include "templateloopfunction.h" -#include "../views/viewhelpers.h" - -using namespace std; - -// --- cTemplatePixmapNode ------------------------------------------------------------- -class cTemplatePixmapNode { -protected: - bool isContainer; - cGlobals *globals; - cTemplateFunction *parameters; - int containerX; - int containerY; - int containerWidth; - int containerHeight; -public: - cTemplatePixmapNode(void); - virtual ~cTemplatePixmapNode(void); - void SetParameters(vector<stringpair> ¶ms); - void SetContainer(int x, int y, int w, int h); - bool IsContainer(void) { return isContainer; }; - bool DoExecute(void) { return parameters->DoExecute(); }; - bool DoDebug(void) { return parameters->DoDebug(); }; - virtual void SetGlobals(cGlobals *globals) { this->globals = globals; }; - virtual bool CalculateParameters(void) { return false; }; - virtual void SetWidth(int width) {}; - virtual void SetHeight(int height) {}; - virtual int NumPixmaps(void) { return 0; }; - virtual void Debug(void) {}; -}; - -// --- cTemplatePixmap ------------------------------------------------------------- -class cTemplatePixmapContainer; - -class cTemplatePixmap : public cTemplatePixmapNode { -protected: - cTemplatePixmapContainer *pixContainer; - bool scrolling; - bool background; - vector<cTemplateFunction*> functions; - vector<cTemplateFunction*>::iterator funcIt; - //functions replacing {width(label)} and {height(label)} tokens - bool ReplaceWidthFunctions(void); - bool ReplaceHeightFunctions(map < string, vector< map< string, string > > > *loopTokens); - //functions replacing {posx(label)} and {posy(label)} tokens - bool ReplacePosXFunctions(void); - bool ReplacePosYFunctions(void); - //Get Scrolling Function - cTemplateFunction *GetScrollFunction(void); -public: - cTemplatePixmap(void); - virtual ~cTemplatePixmap(void); - //Setter Functions - void SetPixmapContainer(cTemplatePixmapContainer *pixContainer) { this->pixContainer = pixContainer; }; - void SetScrolling(void) { scrolling = true; }; - void SetWidth(int width); - void SetHeight(int height); - void SetX(int x); - void SetY(int y); - void SetWidthPercent(double width); - void SetHeightPercent(double height); - void SetXPercent(double x); - void SetYPercent(double y); - void SetParameter(eParamType type, string value); - void AddFunction(string name, vector<pair<string, string> > ¶ms); - void AddLoopFunction(cTemplateLoopFunction *lf); - //PreCache Parameters - bool CalculateParameters(void); - //clear dynamically set function parameters - void ClearDynamicFunctionParameters(void); - //Clear dynamically set pixmap parameters - void ClearDynamicParameters(void); - //Parse pixmap parameters with dynamically set Tokens - void ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens, bool initFuncs); - //Parse all function parameters with dynamically set Tokens - void ParseDynamicFunctionParameters(map <string,string> *stringTokens, map <string,int> *intTokens, map < string, vector< map< string, string > > > *loopTokens); - //Calculate size of drawport in case area scrolls - bool CalculateDrawPortSize(cSize &size, map < string, vector< map< string, string > > > *loopTokens = NULL); - //Set max width for text in scrollarea - void SetScrollingTextWidth(void); - //Getter Functions - int NumPixmaps(void) { return 1; }; - cRect GetPixmapSize(void); - int GetNumericParameter(eParamType type); - bool Scrolling(void) { return scrolling; }; - bool Ready(void); - bool BackgroundArea(void) { return background; }; - bool ParameterSet(eParamType type); - cTemplateFunction *GetFunction(string name); - //Traverse Functions - void InitFunctionIterator(void); - cTemplateFunction *GetNextFunction(void); - //Debug - void Debug(void); -}; - -class cTemplatePixmapContainer : public cTemplatePixmapNode { -private: - vector<cTemplatePixmap*> pixmaps; - vector<cTemplatePixmap*>::iterator pixmapIterator; -public: - cTemplatePixmapContainer(void); - virtual ~cTemplatePixmapContainer(void); - void SetGlobals(cGlobals *globals); - void SetWidth(int width); - void SetHeight(int height); - void AddPixmap(cTemplatePixmap *pix); - //PreCache Parameters - bool CalculateParameters(void); - void ParseDynamicParameters(map <string,string> *stringTokens, map <string,int> *intTokens); - int NumPixmaps(void) { return pixmaps.size(); }; - void InitIterator(void); - cTemplatePixmap *GetNextPixmap(void); - cTemplateFunction *GetFunction(string name); - void Debug(void); -}; - -#endif //__TEMPLATEPIXMAP_H
\ No newline at end of file diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c deleted file mode 100644 index 78d6fdf..0000000 --- a/libtemplate/templateview.c +++ /dev/null @@ -1,2148 +0,0 @@ -#include "../config.h" -#include "templateview.h" - -// --- cTemplateView ------------------------------------------------------------- - -cTemplateView::cTemplateView(void) { - globals = NULL; - parameters = NULL; - containerX = 0; - containerY = 0; - containerWidth = 0; - containerHeight = 0; - SetFunctionDefinitions(); -} - -cTemplateView::~cTemplateView() { - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - delete it->second; - } - - for (multimap < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { - delete it->second; - } - - for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) { - delete it->second; - } - - for (vector < cTemplateViewTab* >::iterator it = viewTabs.begin(); it != viewTabs.end(); it++) { - delete *it; - } - - for (map < eSubView, cTemplateView* >::iterator it = subViews.begin(); it != subViews.end(); it++) { - delete it->second; - } - - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - delete it2->second; - } - } - - if (parameters) - delete parameters; - -} - -/******************************************************************* -* Public Functions -*******************************************************************/ - -void cTemplateView::SetParameters(vector<pair<string, string> > ¶ms) { - parameters = new cTemplateFunction(ftView); - parameters->SetGlobals(globals); - parameters->SetParameters(params); -} - -void cTemplateView::SetContainer(int x, int y, int width, int height) { - containerX = x; - containerY = y; - containerWidth = width; - containerHeight = height; -} - -cTemplateViewElement *cTemplateView::GetViewElement(eViewElement ve) { - pair<multimap< eViewElement, cTemplateViewElement* >::iterator, multimap< eViewElement, cTemplateViewElement* >::iterator> rangeViewElements; - rangeViewElements = viewElements.equal_range(ve); - for (multimap<eViewElement, cTemplateViewElement*>::iterator it = rangeViewElements.first; it!=rangeViewElements.second; ++it) { - cTemplateViewElement *viewElement = it->second; - if (viewElement->Execute()) { - return viewElement; - } - } - return NULL; -} - -void cTemplateView::InitViewElementIterator(void) { - veIt = viewElements.begin(); -} - -cTemplateViewElement *cTemplateView::GetNextViewElement(void) { - if (veIt == viewElements.end()) - return NULL; - cTemplateViewElement *viewElement = veIt->second; - veIt++; - return viewElement; -} - -cTemplateViewGrid *cTemplateView::GetViewGrid(int gridID) { - map < int, cTemplateViewGrid* >::iterator hit = viewGrids.find(gridID); - if (hit == viewGrids.end()) { - return NULL; - } - return hit->second; -} - -void cTemplateView::InitViewGridIterator(void) { - geIt = viewGrids.begin(); -} - -cTemplateViewGrid *cTemplateView::GetNextViewGrid(void) { - if (geIt == viewGrids.end()) - return NULL; - cTemplateViewGrid *viewGrid = geIt->second; - geIt++; - return viewGrid; -} - -cTemplateViewList *cTemplateView::GetViewList(eViewList vl) { - if (viewLists.size() == 1) { - multimap < eViewList, cTemplateViewList* >::iterator hit = viewLists.find(vl); - if (hit == viewLists.end()) - return NULL; - return hit->second; - } - pair<multimap< eViewList, cTemplateViewList* >::iterator, multimap< eViewList, cTemplateViewList* >::iterator> rangeViewLists; - rangeViewLists = viewLists.equal_range(vl); - for (multimap<eViewList, cTemplateViewList*>::iterator it = rangeViewLists.first; it!=rangeViewLists.second; ++it) { - cTemplateViewList *viewList = it->second; - if (viewList->Execute()) { - return viewList; - } - } - return NULL; -} - -void cTemplateView::InitViewListIterator(void) { - vlIt = viewLists.begin(); -} - -cTemplateViewList *cTemplateView::GetNextViewList(void) { - if (vlIt == viewLists.end()) - return NULL; - cTemplateViewList *viewList = vlIt->second; - vlIt++; - return viewList; -} - -cTemplateView *cTemplateView::GetSubView(eSubView sv) { - map < eSubView, cTemplateView* >::iterator hit = subViews.find(sv); - if (hit == subViews.end()) - return NULL; - return hit->second; -} - -cTemplateView *cTemplateView::GetPluginView(string pluginName, int pluginMenu) { - map < string, map< int, cTemplateView*> >::iterator hit = pluginViews.find(pluginName); - - if (hit == pluginViews.end()) - return NULL; - - map< int, cTemplateView*> plugViews = hit->second; - map< int, cTemplateView*>::iterator hit2 = plugViews.find(pluginMenu); - - if (hit2 == plugViews.end()) - return NULL; - - return hit2->second; -} - - -void cTemplateView::InitViewTabIterator(void) { - vtIt = viewTabs.begin(); -} - -cTemplateViewTab *cTemplateView::GetNextViewTab(void) { - if (vtIt == viewTabs.end()) { - return NULL; - } - cTemplateViewTab *tab = *vtIt; - vtIt++; - return tab; -} - -void cTemplateView::InitSubViewIterator(void) { - svIt = subViews.begin(); -} - -cTemplateView *cTemplateView::GetNextSubView(void) { - if (svIt == subViews.end()) - return NULL; - cTemplateView *subView = svIt->second; - svIt++; - return subView; -} - -int cTemplateView::GetNumericParameter(eParamType type) { - if (!parameters) - return 0; - return parameters->GetNumericParameter(type); -} - -cRect cTemplateView::GetOsdSize(void) { - cRect osdSize; - if (!parameters) { - return osdSize; - } - osdSize.SetX(parameters->GetNumericParameter(ptX)); - osdSize.SetY(parameters->GetNumericParameter(ptY)); - osdSize.SetWidth(parameters->GetNumericParameter(ptWidth)); - osdSize.SetHeight(parameters->GetNumericParameter(ptHeight)); - return osdSize; -} - -int cTemplateView::GetNumPixmaps(void) { - int numPixmaps = 0; - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - cTemplateViewElement *viewElement = it->second; - numPixmaps += viewElement->GetNumPixmaps(); - } - return numPixmaps; -} - -int cTemplateView::GetNumPixmapsViewElement(eViewElement ve) { - cTemplateViewElement *viewElement = GetViewElement(ve); - if (!viewElement) - return 0; - return viewElement->GetNumPixmaps(); -} - -bool cTemplateView::HideView(void) { - if (!parameters) - return false; - return parameters->GetNumericParameter(ptHideRoot); -} - -bool cTemplateView::DrawGebugGrid(void) { - if (!parameters) - return false; - return parameters->GetNumericParameter(ptDrawDebugGrid); -} - -int cTemplateView::DebugGridX(void) { - if (!parameters) - return 0; - return parameters->GetNumericParameter(ptDebugGridX); -} - -int cTemplateView::DebugGridY(void) { - if (!parameters) - return 0; - return parameters->GetNumericParameter(ptDebugGridY); -} - -tColor cTemplateView::DebugGridColor(void) { - tColor col = 0xFFFF0000; - if (!globals) - return col; - string colName = "{clrDebugGrid}"; - globals->GetColor(colName, col); - return col; -} - -tColor cTemplateView::DebugGridFontColor(void) { - tColor col = 0xFFFF0000; - if (!globals) - return col; - string colName = "{clrFontDebugGrid}"; - globals->GetColor(colName, col); - return col; -} - -bool cTemplateView::ExecuteView(eViewElement ve) { - cTemplateViewElement *viewElement = GetViewElement(ve); - if (!viewElement) - return false; - return true; -} - -bool cTemplateView::DetachViewElement(eViewElement ve) { - multimap < eViewElement, cTemplateViewElement* >::iterator hit = viewElements.find(ve); - if (hit == viewElements.end()) - return false; - cTemplateViewElement *viewElement = hit->second; - return viewElement->Detach(); -} - -string cTemplateView::GetViewElementMode(eViewElement ve) { - cTemplateViewElement *viewElement = GetViewElement(ve); - if (!viewElement) - return ""; - return viewElement->GetMode(); -} - -int cTemplateView::GetNumListViewMenuItems(void) { - int numElements = 0; - cTemplateViewList *menuList = GetViewList(vlMenuItem); - if (!menuList) - return numElements; - return menuList->GetNumericParameter(ptNumElements); -} - -bool cTemplateView::GetScalingWindow(cRect &scalingWindow) { - if (!parameters) - return false; - bool doScale = false; - int scaleX = parameters->GetNumericParameter(ptScaleTvX) + cOsd::OsdLeft(); - int scaleY = parameters->GetNumericParameter(ptScaleTvY) + cOsd::OsdTop(); - int scaleWidth = parameters->GetNumericParameter(ptScaleTvWidth); - int scaleHeight = parameters->GetNumericParameter(ptScaleTvHeight); - if (scaleX > -1 && scaleY > -1 && scaleWidth > -1 && scaleHeight > -1) { - cRect suggestedScaleWindow(scaleX, scaleY, scaleWidth, scaleHeight); - scalingWindow = cDevice::PrimaryDevice()->CanScaleVideo(suggestedScaleWindow); - doScale = true; - } else { - scalingWindow = cDevice::PrimaryDevice()->CanScaleVideo(cRect::Null); - } - return doScale; -} - -bool cTemplateView::ValidViewElement(const char *viewElement) { - set<string>::iterator hit = viewElementsAllowed.find(viewElement); - if (hit == viewElementsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidSubView(const char *subView) { - set<string>::iterator hit = subViewsAllowed.find(subView); - if (hit == subViewsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidViewList(const char *viewList) { - set<string>::iterator hit = viewListsAllowed.find(viewList); - if (hit == viewListsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidViewGrid(const char *viewGrid) { - set<string>::iterator hit = viewGridsAllowed.find(viewGrid); - if (hit == viewGridsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidFunction(const char *func) { - map < string, set < string > >::iterator hit = funcsAllowed.find(func); - if (hit == funcsAllowed.end()) - return false; - return true; -} - -bool cTemplateView::ValidAttribute(const char *func, const char *att) { - map < string, set < string > >::iterator hit = funcsAllowed.find(func); - if (hit == funcsAllowed.end()) - return false; - - set<string>::iterator hitAtt = (hit->second).find(att); - if (hitAtt == (hit->second).end()) - return false; - - return true; -} - -void cTemplateView::Translate(void) { - //Translate ViewElements - InitViewElementIterator(); - cTemplateViewElement *viewElement = NULL; - while(viewElement = GetNextViewElement()) { - viewElement->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - } - //Translate viewLists - InitViewListIterator(); - cTemplateViewList *viewList = NULL; - while(viewList = GetNextViewList()) { - viewList->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewList->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - } - } - cTemplateViewElement *listElement = viewList->GetListElement(); - listElement->InitPixmapIterator(); - while(pix = listElement->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - } - } - - cTemplateViewElement *listElementCurrent = viewList->GetListElementCurrent(); - if (listElementCurrent) { - listElementCurrent->InitPixmapIterator(); - while(pix = listElementCurrent->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - } - } - - //Translate viewTabs - InitViewTabIterator(); - cTemplateViewTab *viewTab = NULL; - while(viewTab = GetNextViewTab()) { - string tabName = viewTab->GetName(); - string tabTrans; - bool translated = globals->Translate(tabName, tabTrans); - if (translated) { - viewTab->SetName(tabTrans); - } - viewTab->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = viewTab->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - - //Translate ViewGrids - InitViewGridIterator(); - cTemplateViewGrid *viewGrid = NULL; - while(viewGrid = GetNextViewGrid()) { - viewGrid->InitPixmapIterator(); - cTemplatePixmap *pix = NULL; - while(pix = viewGrid->GetNextPixmap()) { - pix->InitFunctionIterator(); - cTemplateFunction *func = NULL; - while(func = pix->GetNextFunction()) { - if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = func->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - func->SetTranslatedText(translation); - } - } - if (func->GetType() == ftLoop) { - cTemplateLoopFunction *funcsLoop = dynamic_cast<cTemplateLoopFunction*>(func); - funcsLoop->InitIterator(); - cTemplateFunction *loopFunc = NULL; - while(loopFunc = funcsLoop->GetNextFunction()) { - if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox || func->GetType() == ftDrawTextVertical) { - string text = loopFunc->GetParameter(ptText); - string translation; - bool translated = globals->Translate(text, translation); - if (translated) { - loopFunc->SetTranslatedText(translation); - } - } - } - } - } - } - } - - //Translate Plugin Views - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - cTemplateView *pluginView = it2->second; - pluginView->Translate(); - } - } - - //Translate Subviews - InitSubViewIterator(); - cTemplateView *subView = NULL; - while(subView = GetNextSubView()) { - subView->Translate(); - } -} - -void cTemplateView::PreCache(bool isSubview) { - - if (!isSubview) { - int osdW = cOsd::OsdWidth(); - int osdH = cOsd::OsdHeight(); - parameters->SetContainer(0, 0, osdW, osdH); - } else { - parameters->SetContainer(containerX, containerY, containerWidth, containerHeight); - } - //Calculate OSD Size - parameters->CalculateParameters(); - - int osdX = parameters->GetNumericParameter(ptX); - int osdY = parameters->GetNumericParameter(ptY); - int osdWidth = parameters->GetNumericParameter(ptWidth); - int osdHeight = parameters->GetNumericParameter(ptHeight); - int pixOffset = 0; - //Cache ViewElements - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - cTemplateViewElement *viewElement = it->second; - viewElement->SetGlobals(globals); - if (!isSubview) - viewElement->SetContainer(0, 0, osdWidth, osdHeight); - else - viewElement->SetContainer(osdX, osdY, osdWidth, osdHeight); - viewElement->CalculateParameters(); - viewElement->CalculatePixmapParameters(); - viewElement->SetPixOffset(pixOffset); - pixOffset += viewElement->GetNumPixmaps(); - } - - //Cache ViewGrids - for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) { - cTemplateViewGrid *viewGrid = it->second; - viewGrid->SetGlobals(globals); - viewGrid->SetContainer(0, 0, osdWidth, osdHeight); - viewGrid->CalculateParameters(); - viewGrid->CalculatePixmapParameters(); - } - - //Cache ViewLists - for (multimap < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { - cTemplateViewList *viewList = it->second; - viewList->SetGlobals(globals); - //viewlists in subviews need complete container information - if (isSubview) - viewList->SetContainer(osdX, osdY, osdWidth, osdHeight); - else - viewList->SetContainer(0, 0, osdWidth, osdHeight); - viewList->CalculateParameters(); - viewList->CalculateListParameters(); - } - - //Cache ViewTabs - for (vector<cTemplateViewTab*>::iterator tab = viewTabs.begin(); tab != viewTabs.end(); tab++) { - //viewtabs are only in subviews - (*tab)->SetContainer(osdX, osdY, osdWidth, osdHeight); - (*tab)->SetGlobals(globals); - (*tab)->CalculateParameters(); - } - - //Cache Subviews - for (map < eSubView, cTemplateView* >::iterator it = subViews.begin(); it != subViews.end(); it++) { - cTemplateView *subView = it->second; - subView->SetContainer(0, 0, osdWidth, osdHeight); - subView->PreCache(true); - } - - //Cache Plugin Subviews - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - cTemplateView *plugView = it2->second; - plugView->SetContainer(0, 0, osdWidth, osdHeight); - plugView->PreCache(true); - } - } -} - -void cTemplateView::Debug(void) { - - esyslog("skindesigner: TemplateView %s", viewName.c_str());; - - parameters->Debug(); - - for (multimap < eViewElement, cTemplateViewElement* >::iterator it = viewElements.begin(); it != viewElements.end(); it++) { - esyslog("skindesigner: ++++++++ ViewElement: %s", GetViewElementName(it->first).c_str()); - cTemplateViewElement *viewElement = it->second; - viewElement->Debug(); - } - - for (multimap < eViewList, cTemplateViewList* >::iterator it = viewLists.begin(); it != viewLists.end(); it++) { - esyslog("skindesigner: ++++++++ ViewList: %s", GetViewListName(it->first).c_str()); - cTemplateViewList *viewList = it->second; - viewList->Debug(); - } - - for (map < int, cTemplateViewGrid* >::iterator it = viewGrids.begin(); it != viewGrids.end(); it++) { - esyslog("skindesigner: ++++++++ ViewGrid %d:", it->first); - cTemplateViewGrid *viewGrid = it->second; - viewGrid->Debug(); - } - - for (vector<cTemplateViewTab*>::iterator tab = viewTabs.begin(); tab != viewTabs.end(); tab++) { - esyslog("skindesigner: ++++++++ ViewTab"); - (*tab)->Debug(); - } - - for (map < eSubView, cTemplateView* >::iterator it = subViews.begin(); it!= subViews.end(); it++) { - esyslog("skindesigner: ++++++++ SubView: %s", GetSubViewName(it->first).c_str()); - cTemplateView *subView = it->second; - subView->Debug(); - } - - for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it!= pluginViews.end(); it++) { - esyslog("skindesigner: ++++++++ Plugin: %s", it->first.c_str()); - map< int, cTemplateView*> plugViews = it->second; - for (map< int, cTemplateView*>::iterator it2 = plugViews.begin(); it2 != plugViews.end(); it2++) { - esyslog("skindesigner: Tmpl %d", it2->first); - ((cTemplateView*)it2->second)->Debug(); - } - } - -} - - -void cTemplateView::SetFunctionDefinitions(void) { - - string name = "viewelement"; - set<string> attributes; - attributes.insert("debug"); - attributes.insert("detached"); - attributes.insert("delay"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("name"); - attributes.insert("condition"); - attributes.insert("mode"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "listelement"; - attributes.clear(); - attributes.insert("debug"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "areacontainer"; - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("debug"); - attributes.insert("condition"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "area"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - attributes.insert("background"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "areascroll"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("orientation"); - attributes.insert("delay"); - attributes.insert("mode"); - attributes.insert("scrollspeed"); - attributes.insert("condition"); - attributes.insert("scrollelement"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "loop"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("name"); - attributes.insert("orientation"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("columnwidth"); - attributes.insert("rowheight"); - attributes.insert("overflow"); - attributes.insert("maxitems"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "fill"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("color"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawtext"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("font"); - attributes.insert("fontsize"); - attributes.insert("color"); - attributes.insert("text"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawtextbox"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("maxlines"); - attributes.insert("font"); - attributes.insert("fontsize"); - attributes.insert("color"); - attributes.insert("text"); - attributes.insert("float"); - attributes.insert("floatwidth"); - attributes.insert("floatheight"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawtextvertical"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("height"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("direction"); - attributes.insert("font"); - attributes.insert("fontsize"); - attributes.insert("color"); - attributes.insert("text"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawimage"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("imagetype"); - attributes.insert("path"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("cache"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawrectangle"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("color"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawellipse"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("color"); - attributes.insert("quadrant"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); - - name = "drawslope"; - attributes.clear(); - attributes.insert("debug"); - attributes.insert("condition"); - attributes.insert("name"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("align"); - attributes.insert("valign"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("color"); - attributes.insert("type"); - attributes.insert("animtype"); - attributes.insert("animfreq"); - funcsAllowed.insert(pair< string, set<string> >(name, attributes)); -} - -/************************************************************************************ -* cTemplateViewChannel -************************************************************************************/ - -cTemplateViewChannel::cTemplateViewChannel(void) { - - viewName = "displaychannel"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - SetViewElements(); -} - -cTemplateViewChannel::~cTemplateViewChannel() { -} - -void cTemplateViewChannel::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("channelinfo"); - viewElementsAllowed.insert("channelgroup"); - viewElementsAllowed.insert("epginfo"); - viewElementsAllowed.insert("progressbar"); - viewElementsAllowed.insert("progressbarback"); - viewElementsAllowed.insert("statusinfo"); - viewElementsAllowed.insert("audioinfo"); - viewElementsAllowed.insert("ecminfo"); - viewElementsAllowed.insert("screenresolution"); - viewElementsAllowed.insert("signalquality"); - viewElementsAllowed.insert("signalqualityback"); - viewElementsAllowed.insert("devices"); - viewElementsAllowed.insert("currentweather"); - viewElementsAllowed.insert("scrapercontent"); - viewElementsAllowed.insert("datetime"); - viewElementsAllowed.insert("time"); - viewElementsAllowed.insert("message"); - viewElementsAllowed.insert("customtokens"); -} - -string cTemplateViewChannel::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veChannelInfo: - name = "ChannelInfo"; - break; - case veChannelGroup: - name = "ChannelGroup"; - break; - case veEpgInfo: - name = "EpgInfo"; - break; - case veProgressBar: - name = "ProgressBar"; - break; - case veProgressBarBack: - name = "ProgressBar Background"; - break; - case veStatusInfo: - name = "StatusInfo"; - break; - case veAudioInfo: - name = "AudioInfo"; - break; - case veScreenResolution: - name = "Screen Resolution"; - break; - case veEcmInfo: - name = "ECM Info"; - break; - case veSignalQuality: - name = "Signal Quality"; - break; - case veSignalQualityBack: - name = "Signal Quality Background"; - break; - case veDevices: - name = "Devices"; - break; - case veCurrentWeather: - name = "Current Weather"; - break; - case veScraperContent: - name = "Scraper Content"; - break; - case veDateTime: - name = "DateTime"; - break; - case veTime: - name = "Time"; - break; - case veMessage: - name = "Message"; - break; - case veCustomTokens: - name = "Custom Tokens"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewChannel::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("channelinfo")) { - ve = veChannelInfo; - } else if (!sViewElement.compare("channelgroup")) { - ve = veChannelGroup; - } else if (!sViewElement.compare("epginfo")) { - ve = veEpgInfo; - } else if (!sViewElement.compare("progressbar")) { - ve = veProgressBar; - } else if (!sViewElement.compare("progressbarback")) { - ve = veProgressBarBack; - } else if (!sViewElement.compare("statusinfo")) { - ve = veStatusInfo; - } else if (!sViewElement.compare("audioinfo")) { - ve = veAudioInfo; - } else if (!sViewElement.compare("ecminfo")) { - ve = veEcmInfo; - } else if (!sViewElement.compare("screenresolution")) { - ve = veScreenResolution; - } else if (!sViewElement.compare("signalquality")) { - ve = veSignalQuality; - } else if (!sViewElement.compare("signalqualityback")) { - ve = veSignalQualityBack; - } else if (!sViewElement.compare("devices")) { - ve = veDevices; - } else if (!sViewElement.compare("currentweather")) { - ve = veCurrentWeather; - } else if (!sViewElement.compare("scrapercontent")) { - ve = veScraperContent; - } else if (!sViewElement.compare("datetime")) { - ve = veDateTime; - } else if (!sViewElement.compare("time")) { - ve = veTime; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } else if (!sViewElement.compare("customtokens")) { - ve = veCustomTokens; - } - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displaychannel: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -/************************************************************************************ -* cTemplateViewMenu -************************************************************************************/ - -cTemplateViewMenu::cTemplateViewMenu(void) { - - viewName = "displaymenu"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - string subViewName = "menudefault"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menumain"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menusetup"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menuschedules"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menuchannels"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menutimers"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menurecordings"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menudetailedepg"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menudetailedrecording"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - subViewName = "menudetailedtext"; - //definition of allowed parameters for subtemplate menumain - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(subViewName, attributes)); - - //definition of allowed parameters for menuitems viewlist - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("orientation"); - attributes.insert("align"); - attributes.insert("menuitemwidth"); - attributes.insert("determinatefont"); - attributes.insert("numlistelements"); - attributes.insert("condition"); - funcsAllowed.insert(pair< string, set<string> >("menuitems", attributes)); - - //definition of allowed parameters for currentitems viewlist - attributes.clear(); - attributes.insert("debug"); - attributes.insert("delay"); - attributes.insert("fadetime"); - attributes.insert("condition"); - funcsAllowed.insert(pair< string, set<string> >("currentelement", attributes)); - - //definition of allowed parameters for viewtab - attributes.clear(); - attributes.insert("debug"); - attributes.insert("name"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - attributes.insert("scrollheight"); - funcsAllowed.insert(pair< string, set<string> >("tab", attributes)); - - //definition of allowed parameters for plugin menus - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >("menuplugin", attributes)); - - SetSubViews(); - SetViewElements(); - SetViewLists(); - -} - -cTemplateViewMenu::~cTemplateViewMenu() { -} - -void cTemplateViewMenu::SetSubViews(void) { - subViewsAllowed.insert("menudefault"); - subViewsAllowed.insert("menumain"); - subViewsAllowed.insert("menusetup"); - subViewsAllowed.insert("menuschedules"); - subViewsAllowed.insert("menutimers"); - subViewsAllowed.insert("menurecordings"); - subViewsAllowed.insert("menuchannels"); - subViewsAllowed.insert("menudetailedepg"); - subViewsAllowed.insert("menudetailedrecording"); - subViewsAllowed.insert("menudetailedtext"); -} - -void cTemplateViewMenu::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("datetime"); - viewElementsAllowed.insert("time"); - viewElementsAllowed.insert("header"); - viewElementsAllowed.insert("colorbuttons"); - viewElementsAllowed.insert("message"); - viewElementsAllowed.insert("sortmode"); - viewElementsAllowed.insert("discusage"); - viewElementsAllowed.insert("systemload"); - viewElementsAllowed.insert("systemmemory"); - viewElementsAllowed.insert("vdrstatistics"); - viewElementsAllowed.insert("temperatures"); - viewElementsAllowed.insert("timers"); - viewElementsAllowed.insert("lastrecordings"); - viewElementsAllowed.insert("devices"); - viewElementsAllowed.insert("currentweather"); - viewElementsAllowed.insert("currentschedule"); - viewElementsAllowed.insert("customtokens"); - viewElementsAllowed.insert("scrollbar"); - viewElementsAllowed.insert("detailheader"); - viewElementsAllowed.insert("tablabels"); -} - -void cTemplateViewMenu::SetViewLists(void) { - viewListsAllowed.insert("menuitems"); -} - -string cTemplateViewMenu::GetSubViewName(eSubView sv) { - string name; - switch (sv) { - case svMenuDefault: - name = "Default Menu"; - break; - case svMenuMain: - name = "Main Menu"; - break; - case svMenuSetup: - name = "Setup Menu"; - break; - case svMenuSchedules: - name = "Schedules Menu"; - break; - case svMenuTimers: - name = "Timers Menu"; - break; - case svMenuRecordings: - name = "Recordings Menu"; - break; - case svMenuChannels: - name = "Channels Menu"; - break; - case svMenuDetailedEpg: - name = "Detailed EPG"; - break; - case svMenuDetailedRecording: - name = "Detailed Recording"; - break; - case svMenuDetailedText: - name = "Detailed Text"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - - -string cTemplateViewMenu::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veDateTime: - name = "DateTime"; - break; - case veTime: - name = "Time"; - break; - case veHeader: - name = "Header"; - break; - case veButtons: - name = "Color Buttons"; - break; - case veMessage: - name = "Message"; - break; - case veSortMode: - name = "Sort Mode"; - break; - case veDiscUsage: - name = "Disc Usage"; - break; - case veSystemLoad: - name = "System Load"; - break; - case veSystemMemory: - name = "System Memory"; - break; - case veVDRStats: - name = "VDR Statistics"; - break; - case veTemperatures: - name = "Temperatures"; - break; - case veTimers: - name = "Timers"; - break; - case veLastRecordings: - name = "Last Recordings"; - break; - case veCurrentSchedule: - name = "Current Schedule"; - break; - case veCurrentWeather: - name = "Current Weather"; - break; - case veCustomTokens: - name = "Custom Tokens"; - break; - case veDevices: - name = "Devices"; - break; - case veMenuItem: - name = "Menu Item"; - break; - case veMenuCurrentItemDetail: - name = "Menu Current Item Detail"; - break; - case veScrollbar: - name = "Scrollbar"; - break; - case veDetailHeader: - name = "Detail header"; - break; - case veTabLabels: - name = "tab labels"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -string cTemplateViewMenu::GetViewListName(eViewList vl) { - string name; - switch (vl) { - case vlMenuItem: - name = "Menu Item"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewMenu::AddSubView(string sSubView, cTemplateView *subView) { - eSubView sv = svUndefined; - - if (!sSubView.compare("menumain")) { - sv = svMenuMain; - } else if (!sSubView.compare("menudefault")) { - sv = svMenuDefault; - } else if (!sSubView.compare("menuschedules")) { - sv = svMenuSchedules; - } else if (!sSubView.compare("menusetup")) { - sv = svMenuSetup; - } else if (!sSubView.compare("menuschedules")) { - sv = svMenuSchedules; - } else if (!sSubView.compare("menutimers")) { - sv = svMenuTimers; - } else if (!sSubView.compare("menurecordings")) { - sv = svMenuRecordings; - } else if (!sSubView.compare("menuchannels")) { - sv = svMenuChannels; - } else if (!sSubView.compare("menudetailedepg")) { - sv = svMenuDetailedEpg; - } else if (!sSubView.compare("menudetailedrecording")) { - sv = svMenuDetailedRecording; - } else if (!sSubView.compare("menudetailedtext")) { - sv = svMenuDetailedText; - } - - if (sv == svUndefined) { - esyslog("skindesigner: unknown SubView in displayMenu: %s", sSubView.c_str()); - return; - } - subView->SetGlobals(globals); - subViews.insert(pair<eSubView, cTemplateView*>(sv, subView)); -} - -void cTemplateViewMenu::AddPluginView(string plugName, int templNo, cTemplateView *plugView) { - plugView->SetGlobals(globals); - - map < string, map< int, cTemplateView*> >::iterator hit = pluginViews.find(plugName); - - if (hit == pluginViews.end()) { - map< int, cTemplateView*> plugTemplates; - plugTemplates.insert(pair<int, cTemplateView*>(templNo, plugView)); - pluginViews.insert(pair< string, map< int, cTemplateView*> >(plugName, plugTemplates)); - } else { - hit->second.insert(pair<int, cTemplateView*>(templNo, plugView)); - } -} - -void cTemplateViewMenu::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("datetime")) { - ve = veDateTime; - } else if (!sViewElement.compare("time")) { - ve = veTime; - } else if (!sViewElement.compare("header")) { - ve = veHeader; - } else if (!sViewElement.compare("colorbuttons")) { - ve = veButtons; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } else if (!sViewElement.compare("sortmode")) { - ve = veSortMode; - } else if (!sViewElement.compare("discusage")) { - ve = veDiscUsage; - } else if (!sViewElement.compare("systemload")) { - ve = veSystemLoad; - } else if (!sViewElement.compare("systemmemory")) { - ve = veSystemMemory; - } else if (!sViewElement.compare("vdrstatistics")) { - ve = veVDRStats; - } else if (!sViewElement.compare("temperatures")) { - ve = veTemperatures; - } else if (!sViewElement.compare("timers")) { - ve = veTimers; - } else if (!sViewElement.compare("lastrecordings")) { - ve = veLastRecordings; - } else if (!sViewElement.compare("currentschedule")) { - ve = veCurrentSchedule; - } else if (!sViewElement.compare("customtokens")) { - ve = veCustomTokens; - } else if (!sViewElement.compare("devices")) { - ve = veDevices; - } else if (!sViewElement.compare("currentweather")) { - ve = veCurrentWeather; - } else if (!sViewElement.compare("scrollbar")) { - ve = veScrollbar; - } else if (!sViewElement.compare("detailheader")) { - ve = veDetailHeader; - } else if (!sViewElement.compare("tablabels")) { - ve = veTabLabels; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayMenu: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -void cTemplateViewMenu::AddViewList(string sViewList, cTemplateViewList *viewList) { - - eViewList vl = vlUndefined; - if (!sViewList.compare("menuitems")) { - vl = vlMenuItem; - } - - if (vl == vlUndefined) { - esyslog("skindesigner: unknown ViewList in displaymenu: %s", sViewList.c_str()); - return; - } - - viewList->SetGlobals(globals); - viewLists.insert(pair< eViewList, cTemplateViewList*>(vl, viewList)); -} - -void cTemplateViewMenu::AddViewTab(cTemplateViewTab *viewTab) { - viewTabs.push_back(viewTab); -} - -/************************************************************************************ -* cTemplateViewMessage -************************************************************************************/ - -cTemplateViewMessage::cTemplateViewMessage(void) { - - viewName = "displaymessage"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - SetViewElements(); -} - -cTemplateViewMessage::~cTemplateViewMessage() { -} - -void cTemplateViewMessage::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("message"); -} - -string cTemplateViewMessage::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veMessage: - name = "Message"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewMessage::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displaymessage: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -/************************************************************************************ -* cTemplateViewReplay -************************************************************************************/ - -cTemplateViewReplay::cTemplateViewReplay(void) { - - viewName = "displayreplay"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - //definition of allowed parameters for onpause and onpausemodeonly viewelement - attributes.clear(); - attributes.insert("debug"); - attributes.insert("delay"); - attributes.insert("fadetime"); - funcsAllowed.insert(pair< string, set<string> >("onpause", attributes)); - funcsAllowed.insert(pair< string, set<string> >("onpausemodeonly", attributes)); - - SetViewElements(); -} - -cTemplateViewReplay::~cTemplateViewReplay() { -} - -void cTemplateViewReplay::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("backgroundmodeonly"); - viewElementsAllowed.insert("datetime"); - viewElementsAllowed.insert("time"); - viewElementsAllowed.insert("rectitle"); - viewElementsAllowed.insert("recinfo"); - viewElementsAllowed.insert("scrapercontent"); - viewElementsAllowed.insert("currenttime"); - viewElementsAllowed.insert("totaltime"); - viewElementsAllowed.insert("endtime"); - viewElementsAllowed.insert("progressbar"); - viewElementsAllowed.insert("cutmarks"); - viewElementsAllowed.insert("controlicons"); - viewElementsAllowed.insert("controliconsmodeonly"); - viewElementsAllowed.insert("progressmodeonly"); - viewElementsAllowed.insert("jump"); - viewElementsAllowed.insert("message"); - viewElementsAllowed.insert("onpause"); - viewElementsAllowed.insert("onpausemodeonly"); - viewElementsAllowed.insert("customtokens"); -} - -string cTemplateViewReplay::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veDateTime: - name = "DateTime"; - break; - case veTime: - name = "DateTime"; - break; - case veRecTitle: - name = "Recording Title"; - break; - case veRecInfo: - name = "Recording Information"; - break; - case veRecCurrent: - name = "Recording current Time"; - break; - case veRecTotal: - name = "Recording total Time"; - break; - case veRecEnd: - name = "Recording end Time"; - break; - case veRecProgressBar: - name = "Rec Progress Bar"; - break; - case veCuttingMarks: - name = "Cutting Marks"; - break; - case veControlIcons: - name = "Control Icons"; - break; - case veControlIconsModeOnly: - name = "Control Icons Mode only"; - break; - case veProgressModeOnly: - name = "Progress Mode only"; - break; - case veBackgroundModeOnly: - name = "Background Mode only"; - break; - case veRecJump: - name = "Recording Jump"; - break; - case veScraperContent: - name = "Scraper Content"; - break; - case veOnPause: - name = "On Pause"; - break; - case veOnPauseModeOnly: - name = "On Pause Mode Only"; - break; - case veCustomTokens: - name = "Custom Tokens"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewReplay::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("datetime")) { - ve = veDateTime; - } else if (!sViewElement.compare("time")) { - ve = veTime; - } else if (!sViewElement.compare("rectitle")) { - ve = veRecTitle; - } else if (!sViewElement.compare("recinfo")) { - ve = veRecInfo; - } else if (!sViewElement.compare("scrapercontent")) { - ve = veScraperContent; - } else if (!sViewElement.compare("currenttime")) { - ve = veRecCurrent; - } else if (!sViewElement.compare("totaltime")) { - ve = veRecTotal; - } else if (!sViewElement.compare("endtime")) { - ve = veRecEnd; - } else if (!sViewElement.compare("progressbar")) { - ve = veRecProgressBar; - } else if (!sViewElement.compare("cutmarks")) { - ve = veCuttingMarks; - } else if (!sViewElement.compare("controlicons")) { - ve = veControlIcons; - } else if (!sViewElement.compare("controliconsmodeonly")) { - ve = veControlIconsModeOnly; - } else if (!sViewElement.compare("progressmodeonly")) { - ve = veProgressModeOnly; - } else if (!sViewElement.compare("backgroundmodeonly")) { - ve = veBackgroundModeOnly; - } else if (!sViewElement.compare("jump")) { - ve = veRecJump; - } else if (!sViewElement.compare("message")) { - ve = veMessage; - } else if (!sViewElement.compare("onpause")) { - ve = veOnPause; - } else if (!sViewElement.compare("onpausemodeonly")) { - ve = veOnPauseModeOnly; - } else if (!sViewElement.compare("customtokens")) { - ve = veCustomTokens; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayreplay: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - - -/************************************************************************************ -* cTemplateViewVolume -************************************************************************************/ - -cTemplateViewVolume::cTemplateViewVolume(void) { - - viewName = "displayvolume"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - SetViewElements(); -} - -cTemplateViewVolume::~cTemplateViewVolume() { -} - -void cTemplateViewVolume::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("volume"); -} - -string cTemplateViewVolume::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veVolume: - name = "Volume"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewVolume::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if (!sViewElement.compare("volume")) { - ve = veVolume; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayvolume: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -/************************************************************************************ -* cTemplateViewAudioTracks -************************************************************************************/ - -cTemplateViewAudioTracks::cTemplateViewAudioTracks(void) { - - viewName = "displayaudiotracks"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - //definition of allowed parameters for menuitems viewlist - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("orientation"); - attributes.insert("align"); - attributes.insert("menuitemwidth"); - attributes.insert("numlistelements"); - funcsAllowed.insert(pair< string, set<string> >("menuitems", attributes)); - - SetViewElements(); - SetViewLists(); -} - -cTemplateViewAudioTracks::~cTemplateViewAudioTracks() { -} - -void cTemplateViewAudioTracks::SetViewElements(void) { - viewElementsAllowed.insert("background"); - viewElementsAllowed.insert("header"); -} - -void cTemplateViewAudioTracks::SetViewLists(void) { - viewListsAllowed.insert("menuitems"); -} - -string cTemplateViewAudioTracks::GetViewElementName(eViewElement ve) { - string name; - switch (ve) { - case veBackground: - name = "Background"; - break; - case veHeader: - name = "Header"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -string cTemplateViewAudioTracks::GetViewListName(eViewList vl) { - string name; - switch (vl) { - case vlMenuItem: - name = "Menu Item"; - break; - default: - name = "Unknown"; - break; - }; - return name; -} - -void cTemplateViewAudioTracks::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - - if (!sViewElement.compare("background")) { - ve = veBackground; - } else if(!sViewElement.compare("header")) { - ve = veHeader; - } - - if (ve == veUndefined) { - esyslog("skindesigner: unknown ViewElement in displayaudiotracks: %s", sViewElement.c_str()); - return; - } - - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -void cTemplateViewAudioTracks::AddViewList(string sViewList, cTemplateViewList *viewList) { - - eViewList vl = vlUndefined; - if (!sViewList.compare("menuitems")) { - vl = vlMenuItem; - } - - if (vl == vlUndefined) { - esyslog("skindesigner: unknown ViewList in displaymenu: %s", sViewList.c_str()); - return; - } - - viewList->SetGlobals(globals); - viewLists.insert(pair< eViewList, cTemplateViewList*>(vl, viewList)); -} - -/************************************************************************************ -* cTemplateViewPlugin -************************************************************************************/ - -cTemplateViewPlugin::cTemplateViewPlugin(string pluginName, int viewID) { - this->pluginName = pluginName; - this->viewID = viewID; - viewName = "displayplugin"; - //definition of allowed parameters for class itself - set<string> attributes; - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("fadetime"); - attributes.insert("shifttime"); - attributes.insert("shifttype"); - attributes.insert("shiftmode"); - attributes.insert("startx"); - attributes.insert("starty"); - attributes.insert("scaletvx"); - attributes.insert("scaletvy"); - attributes.insert("scaletvwidth"); - attributes.insert("scaletvheight"); - attributes.insert("hideroot"); - attributes.insert("debuggrid"); - funcsAllowed.insert(pair< string, set<string> >(viewName, attributes)); - - //definition of allowed parameters for viewtab - attributes.clear(); - attributes.insert("debug"); - attributes.insert("name"); - attributes.insert("condition"); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("layer"); - attributes.insert("transparency"); - attributes.insert("scrollheight"); - funcsAllowed.insert(pair< string, set<string> >("tab", attributes)); - - attributes.clear(); - attributes.insert("x"); - attributes.insert("y"); - attributes.insert("width"); - attributes.insert("height"); - attributes.insert("name"); - funcsAllowed.insert(pair< string, set<string> >("grid", attributes)); - - viewElementsAllowed.insert("viewelement"); - viewElementsAllowed.insert("scrollbar"); - viewElementsAllowed.insert("tablabels"); - viewGridsAllowed.insert("grid"); -} - -cTemplateViewPlugin::~cTemplateViewPlugin() { -} - -void cTemplateViewPlugin::AddSubView(string sSubView, cTemplateView *subView) { - int subViewId = atoi(sSubView.c_str()); - subViews.insert(pair< eSubView, cTemplateView* >((eSubView)subViewId, subView)); -} - -void cTemplateViewPlugin::AddViewElement(string sViewElement, cTemplateViewElement *viewElement) { - eViewElement ve = veUndefined; - string viewElementName = ""; - int viewElementID = -1; - - bool found = viewElement->GetName(viewElementName); - - if (found) { - viewElementID = config.GetPluginViewElementID(pluginName, viewElementName, viewID); - } else { - //check for internal view elements - ePluginInteralViewElements pve = pveUndefined; - if (!sViewElement.compare("scrollbar")) { - pve = pveScrollbar; - } else if (!sViewElement.compare("tablabels")) { - pve = pveTablabels; - } - if (pve == pveUndefined) { - esyslog("skindesigner: %s: unknown ViewElement in displayplugin: %s", pluginName.c_str(), viewElementName.c_str()); - return; - } - viewElementID = pve; - } - - ve = (eViewElement)viewElementID; - viewElements.insert(pair< eViewElement, cTemplateViewElement*>(ve, viewElement)); -} - -void cTemplateViewPlugin::AddGrid(cTemplateViewGrid *viewGrid) { - string gridName = ""; - bool found = viewGrid->GetName(gridName); - - if (!found) { - esyslog("skindesigner: no name defined for plugin %s grid", pluginName.c_str()); - } - int gridID = config.GetPluginViewGridID(pluginName, gridName, viewID); - - if (gridID == -1) { - esyslog("skindesigner: %s: unknown Grid in displayplugin: %s", pluginName.c_str(), gridName.c_str()); - return; - } - - viewGrids.insert(pair< int, cTemplateViewGrid*>(gridID, viewGrid)); -} - -void cTemplateViewPlugin::AddViewTab(cTemplateViewTab *viewTab) { - viewTabs.push_back(viewTab); -} diff --git a/libtemplate/templateview.h b/libtemplate/templateview.h deleted file mode 100644 index 1713cdc..0000000 --- a/libtemplate/templateview.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef __TEMPLATEVIEW_H -#define __TEMPLATEVIEW_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "templateviewelement.h" -#include "templateviewlist.h" -#include "templateviewgrid.h" -#include "templatepixmap.h" -#include "templateviewtab.h" -#include "templatefunction.h" - -using namespace std; - -// --- cTemplateView ------------------------------------------------------------- - -enum eSubView { - svUndefined, - svMenuDefault, - svMenuMain, - svMenuSetup, - svMenuSchedules, - svMenuTimers, - svMenuRecordings, - svMenuChannels, - svMenuDetailedEpg, - svMenuDetailedRecording, - svMenuDetailedText, - svMenuPlugin, -}; - -class cTemplateView { -private: -protected: - cGlobals *globals; - //view parameters - string viewName; - cTemplateFunction *parameters; - int containerX; - int containerY; - int containerWidth; - int containerHeight; - //basic view data structures - multimap < eViewElement, cTemplateViewElement* > viewElements; - multimap < eViewList, cTemplateViewList* > viewLists; - map < int, cTemplateViewGrid* > viewGrids; - map < eSubView, cTemplateView* > subViews; - vector< cTemplateViewTab* > viewTabs; - map < string, map< int, cTemplateView*> > pluginViews; - //helpers to iterate data structures - map < eViewElement, cTemplateViewElement* >::iterator veIt; - map < eViewList, cTemplateViewList* >::iterator vlIt; - map < int, cTemplateViewGrid* >::iterator geIt; - map < eSubView, cTemplateView* >::iterator svIt; - vector< cTemplateViewTab* >::iterator vtIt; - //helpers to check valid xml templates - set<string> subViewsAllowed; - set<string> viewElementsAllowed; - set<string> viewListsAllowed; - set<string> viewGridsAllowed; - map < string, set < string > > funcsAllowed; - void SetFunctionDefinitions(void); -public: - cTemplateView(void); - virtual ~cTemplateView(void); - virtual string GetSubViewName(eSubView sv) { return ""; }; - virtual string GetViewElementName(eViewElement ve) { return ""; }; - virtual string GetViewListName(eViewList vl) { return ""; }; - virtual void AddSubView(string sSubView, cTemplateView *subView) {}; - virtual void AddPluginView(string plugName, int templNo, cTemplateView *plugView) {}; - virtual void AddViewElement(string sViewElement, cTemplateViewElement *viewElement) {}; - virtual void AddGrid(cTemplateViewGrid *viewGrid) {}; - virtual void AddViewList(string sViewList, cTemplateViewList *viewList) {}; - virtual void AddViewTab(cTemplateViewTab *viewTab) {}; - //Setter Functions - void SetGlobals(cGlobals *globals) { this->globals = globals; }; - void SetParameters(vector<pair<string, string> > ¶ms); - void SetContainer(int x, int y, int width, int height); - //access view elements - cTemplateViewElement *GetViewElement(eViewElement ve); - void InitViewElementIterator(void); - cTemplateViewElement *GetNextViewElement(void); - //access view grids - cTemplateViewGrid *GetViewGrid(int gridID); - void InitViewGridIterator(void); - cTemplateViewGrid *GetNextViewGrid(void); - //access list elements - cTemplateViewList *GetViewList(eViewList vl); - void InitViewListIterator(void); - cTemplateViewList *GetNextViewList(void); - bool IsListView(void) { return viewLists.size() > 0 ? true : false; }; - //access tabs - void InitViewTabIterator(void); - cTemplateViewTab *GetNextViewTab(void); - //access sub views - cTemplateView *GetSubView(eSubView sv); - void InitSubViewIterator(void); - cTemplateView *GetNextSubView(void); - //access plugin views - cTemplateView *GetPluginView(string pluginName, int pluginMenu); - //Getter Functions - const char *GetViewName(void) { return viewName.c_str(); }; - int GetNumericParameter(eParamType type); - cRect GetOsdSize(void); - int GetNumPixmaps(void); - int GetNumPixmapsViewElement(eViewElement ve); - bool DrawGebugGrid(void); - int DebugGridX(void); - int DebugGridY(void); - tColor DebugGridColor(void); - tColor DebugGridFontColor(void); - bool HideView(void); - bool ExecuteView(eViewElement ve); - bool DetachViewElement(eViewElement ve); - string GetViewElementMode(eViewElement ve); - int GetNumListViewMenuItems(void); - bool GetScalingWindow(cRect &scalingWindow); - map<string,string> GetCustomStringTokens(void) { return globals->GetCustomStringTokens(); }; - map<string,int> GetCustomIntTokens(void) { return globals->GetCustomIntTokens(); }; - bool CustomTokenChange(void) { return globals->CustomTokenChange(); }; - //Checks for parsing template XML files - bool ValidSubView(const char *subView); - bool ValidViewElement(const char *viewElement); - bool ValidViewList(const char *viewList); - bool ValidViewGrid(const char *viewGrid); - bool ValidFunction(const char *func); - bool ValidAttribute(const char *func, const char *att); - //Caching - void Translate(void); - void PreCache(bool isSubview); - //Debug - void Debug(void); -}; - -// --- cTemplateViewChannel ------------------------------------------------------------- - -class cTemplateViewChannel : public cTemplateView { -private: - void SetViewElements(void); - void SetViewLists(void); - eViewElement GetViewElementID(string sViewElement); -public: - cTemplateViewChannel(void); - virtual ~cTemplateViewChannel(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewMenu ------------------------------------------------------------- - -class cTemplateViewMenu : public cTemplateView { -private: - void SetSubViews(void); - void SetViewElements(void); - void SetViewLists(void); -public: - cTemplateViewMenu(void); - virtual ~cTemplateViewMenu(void); - string GetSubViewName(eSubView sv); - string GetViewElementName(eViewElement ve); - string GetViewListName(eViewList vl); - void AddSubView(string sSubView, cTemplateView *subView); - void AddPluginView(string plugName, int templNo, cTemplateView *plugView); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); - void AddViewList(string sViewList, cTemplateViewList *viewList); - void AddViewTab(cTemplateViewTab *viewTab); -}; - -// --- cTemplateViewMessage ------------------------------------------------------------- - -class cTemplateViewMessage : public cTemplateView { -private: - void SetViewElements(void); -public: - cTemplateViewMessage(void); - virtual ~cTemplateViewMessage(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewReplay ------------------------------------------------------------- - -class cTemplateViewReplay : public cTemplateView { -private: - void SetViewElements(void); -public: - cTemplateViewReplay(void); - virtual ~cTemplateViewReplay(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewVolume ------------------------------------------------------------- - -class cTemplateViewVolume : public cTemplateView { -private: - void SetViewElements(void); -public: - cTemplateViewVolume(void); - virtual ~cTemplateViewVolume(void); - string GetViewElementName(eViewElement ve); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); -}; - -// --- cTemplateViewAudioTracks ------------------------------------------------------------- - -class cTemplateViewAudioTracks : public cTemplateView { -private: - void SetViewElements(void); - void SetViewLists(void); -public: - cTemplateViewAudioTracks(void); - virtual ~cTemplateViewAudioTracks(void); - string GetViewElementName(eViewElement ve); - string GetViewListName(eViewList vl); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); - void AddViewList(string sViewList, cTemplateViewList *viewList); -}; - -// --- cTemplateViewPlugin ------------------------------------------------------------- - -class cTemplateViewPlugin : public cTemplateView { -private: - string pluginName; - int viewID; -public: - cTemplateViewPlugin(string pluginName, int viewID); - virtual ~cTemplateViewPlugin(void); - void AddSubView(string sSubView, cTemplateView *subView); - void AddViewElement(string sViewElement, cTemplateViewElement *viewElement); - void AddGrid(cTemplateViewGrid *viewGrid); - void AddViewTab(cTemplateViewTab *viewTab); -}; - -#endif //__TEMPLATEVIEW_H diff --git a/libtemplate/templateviewelement.c b/libtemplate/templateviewelement.c deleted file mode 100644 index 56672b8..0000000 --- a/libtemplate/templateviewelement.c +++ /dev/null @@ -1,236 +0,0 @@ -#include "templateviewelement.h"
-#include "../config.h"
-
-cTemplateViewElement::cTemplateViewElement(void) {
- debugTokens = false;
- parameters = NULL;
- containerX = 0;
- containerY = 0;
- containerWidth = 0;
- containerHeight = 0;
- pixOffset = -1;
- pixmapIterator = NULL;
- currentNode = NULL;
-}
-
-cTemplateViewElement::~cTemplateViewElement(void) {
- if (parameters)
- delete parameters;
- for (vector<cTemplatePixmapNode*>::iterator it = viewPixmapNodes.begin(); it != viewPixmapNodes.end(); it++) {
- delete (*it);
- }
-}
-
-void cTemplateViewElement::SetContainer(int x, int y, int width, int height) {
- containerX = x;
- containerY = y;
- containerWidth = width;
- containerHeight = height;
-}
-
-void cTemplateViewElement::SetGlobals(cGlobals *globals) {
- this->globals = globals;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetGlobals(globals);
- }
-}
-
-void cTemplateViewElement::SetParameters(vector<pair<string, string> > ¶ms) {
- parameters = new cTemplateFunction(ftViewElement);
- parameters->SetGlobals(globals);
- parameters->SetParameters(params);
-}
-
-bool cTemplateViewElement::CalculateParameters(void) {
- if (!parameters)
- return true;
- bool paramsValid = true;
- parameters->SetContainer(containerX, containerY, containerWidth, containerHeight);
- parameters->SetGlobals(globals);
- paramsValid = parameters->CalculateParameters();
- parameters->ParseParameters();
- return paramsValid;
-}
-
-bool cTemplateViewElement::CalculatePixmapParameters(void) {
- bool paramsValid = true;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetContainer(containerX, containerY, containerWidth, containerHeight);
- (*pix)->SetGlobals(globals);
- paramsValid = paramsValid && (*pix)->CalculateParameters();
- }
- return paramsValid;
-}
-
-bool cTemplateViewElement::CalculatePixmapParametersList(int orientation, int numElements) {
- bool paramsValid = true;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetContainer(containerX, containerY, containerWidth, containerHeight);
- (*pix)->SetGlobals(globals);
- if (orientation == orHorizontal) {
- if (numElements > 0) {
- int width = containerWidth / numElements;
- (*pix)->SetWidth(width);
- }
- } else if (orientation == orVertical) {
- if (numElements > 0) {
- int height = containerHeight / numElements;
- (*pix)->SetHeight(height);
- }
- }
- paramsValid = paramsValid && (*pix)->CalculateParameters();
- }
- return paramsValid;
-}
-
-int cTemplateViewElement::GetNumericParameter(eParamType type) {
- if (!parameters)
- return -1;
- return parameters->GetNumericParameter(type);
-}
-
-int cTemplateViewElement::GetNumPixmaps(void) {
- int numPixmaps = 0;
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- numPixmaps += (*pix)->NumPixmaps();
- }
- return numPixmaps;
-};
-
-bool cTemplateViewElement::GetName(string &name) {
- if (!parameters)
- return false;
- name = parameters->GetParameter(ptName);
- if (name.size() > 0)
- return true;
- return false;
-}
-
-void cTemplateViewElement::InitPixmapNodeIterator(void) {
- pixmapNodeIterator = viewPixmapNodes.begin();
-}
-
-cTemplatePixmapNode *cTemplateViewElement::GetNextPixmapNode(void) {
- if (pixmapNodeIterator == viewPixmapNodes.end())
- return NULL;
- cTemplatePixmapNode *pix = *pixmapNodeIterator;
- pixmapNodeIterator++;
- return pix;
-}
-
-void cTemplateViewElement::InitPixmapIterator(void) {
- pixmapNodeIterator = viewPixmapNodes.begin();
- if (pixmapNodeIterator == viewPixmapNodes.end())
- return;
- if (!(*pixmapNodeIterator)->IsContainer()) {
- //first node is a pixmap, use this
- pixmapIterator = dynamic_cast<cTemplatePixmap*>(*pixmapNodeIterator);
- return;
- }
- //first node is a container, so fetch first pixmap of this container
- currentNode = dynamic_cast<cTemplatePixmapContainer*>(*pixmapNodeIterator);
- currentNode->InitIterator();
- pixmapIterator = currentNode->GetNextPixmap();
-}
-
-cTemplatePixmap *cTemplateViewElement::GetNextPixmap(void) {
- if (!pixmapIterator)
- return NULL;
- cTemplatePixmap *current = pixmapIterator;
- //set next pixmap
- if (!currentNode) {
- //last node was a pixmap
- pixmapNodeIterator++;
- if (pixmapNodeIterator == viewPixmapNodes.end()) {
- pixmapIterator = NULL;
- return current;
- }
- if (!(*pixmapNodeIterator)->IsContainer()) {
- //node is a pixmap, use this
- pixmapIterator = dynamic_cast<cTemplatePixmap*>(*pixmapNodeIterator);
- return current;
- }
- //node is a container, so fetch first pixmap of this container
- currentNode = dynamic_cast<cTemplatePixmapContainer*>(*pixmapNodeIterator);
- currentNode->InitIterator();
- pixmapIterator = currentNode->GetNextPixmap();
- } else {
- pixmapIterator = currentNode->GetNextPixmap();
- if (pixmapIterator) {
- return current;
- }
- currentNode = NULL;
- pixmapNodeIterator++;
- if (pixmapNodeIterator == viewPixmapNodes.end()) {
- pixmapIterator = NULL;
- return current;
- }
- if (!(*pixmapNodeIterator)->IsContainer()) {
- //node is a pixmap, use this
- pixmapIterator = dynamic_cast<cTemplatePixmap*>(*pixmapNodeIterator);
- return current;
- }
- //node is a container, so fetch first pixmap of this container
- currentNode = dynamic_cast<cTemplatePixmapContainer*>(*pixmapNodeIterator);
- currentNode->InitIterator();
- pixmapIterator = currentNode->GetNextPixmap();
- }
- return current;
-}
-
-cTemplateFunction *cTemplateViewElement::GetFunction(string name) {
- InitPixmapIterator();
- cTemplatePixmap *pix = NULL;
- while (pix = GetNextPixmap()) {
- pix->InitFunctionIterator();
- cTemplateFunction *func = NULL;
- while(func = pix->GetNextFunction()) {
- if (func->GetType() == ftDrawText) {
- string funcName = func->GetParameter(ptName);
- if (!funcName.compare(name))
- return func;
- } else {
- continue;
- }
- }
- }
- return NULL;
-}
-
-bool cTemplateViewElement::Execute(void) {
- if (!parameters)
- return true;
- return parameters->DoExecute();
-}
-
-bool cTemplateViewElement::Detach(void) {
- if (!parameters)
- return false;
- int detached = parameters->GetNumericParameter(ptDetached);
- if (detached == 1)
- return true;
- return false;
-}
-
-string cTemplateViewElement::GetMode(void) {
- if (!parameters)
- return "";
- return parameters->GetParameter(ptMode);
-}
-
-bool cTemplateViewElement::DebugTokens(void) {
- if (!parameters)
- return false;
- return parameters->DoDebug();
-}
-
-
-void cTemplateViewElement::Debug(void) {
- esyslog("skindesigner: viewelement container size x: %d, y: %d, width: %d, height %d", containerX, containerY, containerWidth, containerHeight);
- if (parameters)
- parameters->Debug();
- return;
- for (vector<cTemplatePixmapNode*>::iterator it = viewPixmapNodes.begin(); it != viewPixmapNodes.end(); it++) {
- (*it)->Debug();
- }
-}
\ No newline at end of file diff --git a/libtemplate/templateviewelement.h b/libtemplate/templateviewelement.h deleted file mode 100644 index 189e9e5..0000000 --- a/libtemplate/templateviewelement.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef __TEMPLATEVIEWELEMENT_H
-#define __TEMPLATEVIEWELEMENT_H
-
-#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string>
-#include <vector>
-#include <map>
-#include <set>
-#include <sstream>
-
-#include "templatepixmap.h"
-#include "templatefunction.h"
-
-using namespace std;
-
-// --- cTemplateViewElement -------------------------------------------------------------
-
-enum eViewElement {
- //Common ViewElements
- veUndefined,
- veBackground,
- veDateTime,
- veTime,
- veMessage,
- veSortMode,
- veDevices,
- veCurrentWeather,
- veCustomTokens,
- //DisplayChannel ViewElements
- veChannelInfo,
- veChannelGroup,
- veEpgInfo,
- veProgressBar,
- veProgressBarBack,
- veStatusInfo,
- veAudioInfo,
- veScreenResolution,
- veSignalQuality,
- veSignalQualityBack,
- veScraperContent,
- veEcmInfo,
- //DisplayMenu ViewElements
- veHeader,
- veButtons,
- veDiscUsage,
- veSystemLoad,
- veSystemMemory,
- veVDRStats,
- veTemperatures,
- veTimers,
- veLastRecordings,
- veCurrentSchedule,
- veMenuItem,
- veMenuCurrentItemDetail,
- veScrollbar,
- veDetailHeader,
- veTabLabels,
- //DisplayReplay ViewElements
- veRecTitle,
- veRecInfo,
- veRecCurrent,
- veRecTotal,
- veRecEnd,
- veRecProgressBar,
- veCuttingMarks,
- veControlIcons,
- veControlIconsModeOnly,
- veProgressModeOnly,
- veBackgroundModeOnly,
- veRecJump,
- veOnPause,
- veOnPauseModeOnly,
- //DisplayVolume ViewElements
- veVolume
-};
-
-enum ePluginInteralViewElements {
- pveScrollbar = -1,
- pveTablabels = -2,
- pveUndefined = 0
-};
-
-class cTemplateViewElement {
-protected:
- bool debugTokens;
- cGlobals *globals;
- cTemplateFunction *parameters;
- int containerX;
- int containerY;
- int containerWidth;
- int containerHeight;
- vector<cTemplatePixmapNode*> viewPixmapNodes;
- vector<cTemplatePixmapNode*>::iterator pixmapNodeIterator;
- cTemplatePixmap *pixmapIterator;
- cTemplatePixmapContainer *currentNode;
- int pixOffset;
-public:
- cTemplateViewElement(void);
- virtual ~cTemplateViewElement(void);
- void SetContainer(int x, int y, int width, int height);
- virtual void SetGlobals(cGlobals *globals);
- void SetParameters(vector<pair<string, string> > ¶ms);
- bool CalculateParameters(void);
- virtual bool CalculatePixmapParameters(void);
- bool CalculatePixmapParametersList(int orientation, int numElements);
- void AddPixmap(cTemplatePixmapNode *pix) { viewPixmapNodes.push_back(pix); };
- int GetNumericParameter(eParamType type);
- void SetPixOffset(int offset) { pixOffset = offset; };
- int GetPixOffset(void) { return pixOffset; };
- virtual int GetNumPixmaps(void);
- bool GetName(string &name);
- void InitPixmapNodeIterator(void);
- cTemplatePixmapNode *GetNextPixmapNode(void);
- void InitPixmapIterator(void);
- cTemplatePixmap *GetNextPixmap(void);
- cTemplateFunction *GetFunction(string name);
- bool Execute(void);
- bool Detach(void);
- string GetMode(void);
- bool DebugTokens(void);
- virtual void Debug(void);
-};
-
-#endif //__TEMPLATEVIEWELEMENT_H
\ No newline at end of file diff --git a/libtemplate/templateviewgrid.c b/libtemplate/templateviewgrid.c deleted file mode 100644 index bd73d84..0000000 --- a/libtemplate/templateviewgrid.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "templateviewgrid.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-
-cTemplateViewGrid::cTemplateViewGrid(void) : cTemplateViewElement() {
-}
-
-cTemplateViewGrid::~cTemplateViewGrid(void) {
-}
-
-bool cTemplateViewGrid::CalculatePixmapParameters(void) {
- bool paramsValid = true;
- int gridX = parameters->GetNumericParameter(ptX);
- int gridY = parameters->GetNumericParameter(ptY);
- int gridWidth = parameters->GetNumericParameter(ptWidth);
- int gridHeight = parameters->GetNumericParameter(ptHeight);
-
- for (vector<cTemplatePixmapNode*>::iterator pix = viewPixmapNodes.begin(); pix != viewPixmapNodes.end(); pix++) {
- (*pix)->SetContainer(gridX, gridY, gridWidth, gridHeight);
- (*pix)->SetGlobals(globals);
- paramsValid = paramsValid && (*pix)->CalculateParameters();
- }
- return paramsValid;
-}
-
-void cTemplateViewGrid::Debug(void) {
- esyslog("skindesigner: --- Grid: ");
- cTemplateViewElement::Debug();
-}
\ No newline at end of file diff --git a/libtemplate/templateviewgrid.h b/libtemplate/templateviewgrid.h deleted file mode 100644 index 6b5c34a..0000000 --- a/libtemplate/templateviewgrid.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __TEMPLATEVIEWGRID_H -#define __TEMPLATEVIEWGRID_H - -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "templateviewelement.h" - -using namespace std; - -// --- cTemplateViewGrid ------------------------------------------------------------- - -class cTemplateViewGrid : public cTemplateViewElement { -private: -public: - cTemplateViewGrid(void); - ~cTemplateViewGrid(void); - bool CalculatePixmapParameters(void); - void Debug(void); -}; - -#endif //__TEMPLATEVIEWGRID_H
\ No newline at end of file diff --git a/libtemplate/templateviewlist.c b/libtemplate/templateviewlist.c deleted file mode 100644 index a831d2d..0000000 --- a/libtemplate/templateviewlist.c +++ /dev/null @@ -1,181 +0,0 @@ -#include "templateviewlist.h"
-#include "../config.h"
-#include "../libcore/helpers.h"
-
-cTemplateViewList::cTemplateViewList(void) : cTemplateViewElement() {
- listElement = NULL;
- currentElement = NULL;
-}
-
-cTemplateViewList::~cTemplateViewList(void) {
- if (listElement)
- delete listElement;
- if (currentElement)
- delete currentElement;
-}
-
-void cTemplateViewList::SetGlobals(cGlobals *globals) {
- cTemplateViewElement::SetGlobals(globals);
- if (listElement)
- listElement->SetGlobals(globals);
- if (currentElement)
- currentElement->SetGlobals(globals);
-}
-
-bool cTemplateViewList::CalculateListParameters(void) {
- if (!parameters)
- return false;
- bool paramsValid = false;
- if (!listElement)
- return false;
- listElement->SetContainer(parameters->GetNumericParameter(ptX),
- parameters->GetNumericParameter(ptY),
- parameters->GetNumericParameter(ptWidth),
- parameters->GetNumericParameter(ptHeight));
- paramsValid = listElement->CalculateParameters();
- paramsValid = listElement->CalculatePixmapParametersList(parameters->GetNumericParameter(ptOrientation),
- parameters->GetNumericParameter(ptNumElements));
- if (!currentElement)
- return paramsValid;
- currentElement->SetContainer(parameters->GetNumericParameter(ptX),
- parameters->GetNumericParameter(ptY),
- parameters->GetNumericParameter(ptWidth),
- parameters->GetNumericParameter(ptHeight));
- paramsValid = currentElement->CalculateParameters();
- paramsValid = currentElement->CalculatePixmapParameters();
- currentElement->SetPixOffset(0);
- return paramsValid;
-}
-
-bool cTemplateViewList::CalculateListParameters(map < string, int > *intTokens) {
- if (!parameters)
- return false;
- parameters->ClearDynamicParameters();
- parameters->SetIntTokens(intTokens);
- parameters->ParseParameters();
- parameters->UnsetIntTokens();
-
- listElement->SetContainer(parameters->GetNumericParameter(ptX),
- parameters->GetNumericParameter(ptY),
- parameters->GetNumericParameter(ptWidth),
- parameters->GetNumericParameter(ptHeight));
- bool paramsValid = listElement->CalculateParameters();
- paramsValid = listElement->CalculatePixmapParametersList(parameters->GetNumericParameter(ptOrientation),
- parameters->GetNumericParameter(ptNumElements));
- return paramsValid;
-}
-
-eOrientation cTemplateViewList::GetOrientation(void) {
- if (!parameters)
- return orNone;
- int orientation = parameters->GetNumericParameter(ptOrientation);
- return (eOrientation)orientation;
-}
-
-int cTemplateViewList::GetAverageFontWidth(void) {
- int defaultAverageFontWidth = 20;
-
- if (!listElement)
- return defaultAverageFontWidth;
-
- int numItems = GetNumericParameter(ptNumElements);
- int listHeight = GetNumericParameter(ptHeight);
- if (listHeight <= 0)
- return defaultAverageFontWidth;
- int itemHeight = (double)listHeight / (double)numItems;
- string fontFuncName = parameters->GetParameter(ptDeterminateFont);
-
- cTemplateFunction *fontFunc = listElement->GetFunction(fontFuncName);
- if (!fontFunc)
- return defaultAverageFontWidth;
-
- string fontNameToken = fontFunc->GetParameter(ptFont);
- string paramFontSize = fontFunc->GetParameter(ptFontSize);
-
- string fontName = "";
- if (IsToken(fontNameToken)) {
- if (!globals->GetFont(fontNameToken, fontName)) {
- if (!globals->GetFont("{vdrOsd}", fontName)) {
- return defaultAverageFontWidth;
- }
- }
- } else {
- //if no token, directly use input
- fontName = fontNameToken;
- }
-
- cNumericParameter pFontSize(paramFontSize);
- pFontSize.SetGlobals(globals);
- pFontSize.SetAreaSize(1000, itemHeight);
- pFontSize.SetVertical();
- int fontSize = pFontSize.Parse(paramFontSize);
- if (!pFontSize.Valid())
- return defaultAverageFontWidth;
-
- int averageFontWidth = fontManager->Width(fontName, fontSize, "x") + 3;
- return averageFontWidth;
-}
-
-cFont *cTemplateViewList::GetTextAreaFont(void) {
- if (!listElement)
- return NULL;
-
- int numItems = GetNumericParameter(ptNumElements);
- int listHeight = GetNumericParameter(ptHeight);
- if (listHeight <= 0)
- return NULL;
- int itemHeight = (double)listHeight / (double)numItems;
- string fontFuncName = parameters->GetParameter(ptDeterminateFont);
-
- cTemplateFunction *fontFunc = listElement->GetFunction(fontFuncName);
- if (!fontFunc)
- return NULL;
-
- string fontNameToken = fontFunc->GetParameter(ptFont);
- string paramFontSize = fontFunc->GetParameter(ptFontSize);
-
- string fontName = "";
- if (IsToken(fontNameToken)) {
- if (!globals->GetFont(fontNameToken, fontName)) {
- if (!globals->GetFont("{vdrOsd}", fontName)) {
- return NULL;
- }
- }
- } else {
- //if no token, directly use input
- fontName = fontNameToken;
- }
-
- cNumericParameter pFontSize(paramFontSize);
- pFontSize.SetGlobals(globals);
- pFontSize.SetAreaSize(1000, itemHeight);
- pFontSize.SetVertical();
- int fontSize = pFontSize.Parse(paramFontSize);
- if (!pFontSize.Valid())
- return NULL;
-
- return fontManager->FontUncached(fontName, fontSize);
-}
-
-
-int cTemplateViewList::GetMenuItemWidth(void) {
- return GetNumericParameter(ptMenuItemWidth);
-}
-
-
-int cTemplateViewList::GetNumPixmaps(void) {
- if (!listElement)
- return 0;
- return listElement->GetNumPixmaps();
-}
-
-void cTemplateViewList::Debug(void) {
- if (parameters)
- parameters->Debug();
- esyslog("skindesigner: --- listelement: ");
- if (listElement)
- listElement->Debug();
- esyslog("skindesigner: --- currentelement: ");
- if (currentElement)
- currentElement->Debug();
-}
\ No newline at end of file diff --git a/libtemplate/templateviewlist.h b/libtemplate/templateviewlist.h deleted file mode 100644 index 4cc4ccb..0000000 --- a/libtemplate/templateviewlist.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __TEMPLATEVIEWLIST_H -#define __TEMPLATEVIEWLIST_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> -#include <sstream> - -#include "templateviewelement.h" - -using namespace std; - -// --- cTemplateViewList ------------------------------------------------------------- - -enum eViewList { - vlUndefined, - vlMenuItem -}; - -class cTemplateViewList : public cTemplateViewElement { -private: - cTemplateViewElement *listElement; - cTemplateViewElement *currentElement; -public: - cTemplateViewList(void); - ~cTemplateViewList(void); - void SetGlobals(cGlobals *globals); - void AddListElement(cTemplateViewElement *listElement) { this->listElement = listElement; }; - void AddCurrentElement(cTemplateViewElement *currentElement) { this->currentElement = currentElement; }; - bool CalculateListParameters(void); - bool CalculateListParameters(map < string, int > *intTokens); - cTemplateViewElement *GetListElement(void) { return listElement; }; - cTemplateViewElement *GetListElementCurrent(void) { return currentElement; }; - eOrientation GetOrientation(void); - int GetAverageFontWidth(void); - cFont *GetTextAreaFont(void); - int GetMenuItemWidth(void); - int GetNumPixmaps(void); - void Debug(void); -}; - -#endif //__TEMPLATEVIEWLIST_H
\ No newline at end of file diff --git a/libtemplate/templateviewtab.c b/libtemplate/templateviewtab.c deleted file mode 100644 index 1e9f463..0000000 --- a/libtemplate/templateviewtab.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "templateviewtab.h" - -cTemplateViewTab::cTemplateViewTab(void) : cTemplatePixmap() { - scrollStep = -1; -} - -cTemplateViewTab::~cTemplateViewTab(void) { -} - -int cTemplateViewTab::GetScrollStep(void) { - if (scrollStep > 0) - return scrollStep; - int pixWidth = GetNumericParameter(ptWidth); - int pixHeight = GetNumericParameter(ptHeight); - string scrollHeight = parameters->GetParameter(ptScrollHeight); - - cNumericParameter p(scrollHeight); - p.SetAreaSize(pixWidth, pixHeight); - string parsedValue = ""; - scrollStep = p.Parse(parsedValue); - if (scrollStep < 1) - scrollStep = 50; - return scrollStep; -} - -string cTemplateViewTab::GetName(void) { - return parameters->GetParameter(ptName); -} - -void cTemplateViewTab::SetName(string trans) { - parameters->SetParameter(ptName, trans); -} - -void cTemplateViewTab::Debug(void) { - esyslog("skindesigner: cTemplateViewTab Debug %s", GetName().c_str()); - cTemplatePixmap::Debug(); - esyslog("skindesigner: -------------------------------------------------------"); -} diff --git a/libtemplate/templateviewtab.h b/libtemplate/templateviewtab.h deleted file mode 100644 index 8514cad..0000000 --- a/libtemplate/templateviewtab.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __TEMPLATEVIEWTAB_H -#define __TEMPLATEVIEWTAB_H - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> -#include <set> - -#include "templatepixmap.h" - -using namespace std; - -// --- cTemplateViewTab ------------------------------------------------------------- - -class cTemplateViewTab : public cTemplatePixmap { -private: - int scrollStep; -public: - cTemplateViewTab(void); - ~cTemplateViewTab(void); - int GetScrollStep(void); - string GetName(void); - void SetName(string trans); - void Debug(void); -}; - -#endif //__TEMPLATEVIEWTAB_H
\ No newline at end of file diff --git a/po/de_DE.po b/po/de_DE.po index a46d874..b5db7ab 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-skindesigner 0.0.1\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2015-08-14 17:20+0200\n" +"POT-Creation-Date: 2016-01-20 18:31+0100\n" "PO-Revision-Date: 2014-09-27 11:02+0200\n" "Last-Translator: Louis Braun <louis.braun@gmx.de>\n" "Language-Team: \n" @@ -46,7 +46,7 @@ msgid "at one go" msgstr "alle auf einmal" msgid "Downloading Skin Screenshots..." -msgstr "Lade Screenshots herunter..." +msgstr "" msgid "Install Skin" msgstr "Installiere Skin" @@ -84,11 +84,8 @@ msgstr "Skin gelöscht" msgid "Plugin Setup" msgstr "" -msgid "Menu Item display method" -msgstr "Art der Ausgabe der Menüelemente" - -msgid "Frames per Second (fading and shifting)" -msgstr "Frames pro Sekunde (fading und shifting)" +msgid "Maximum number of custom tokens" +msgstr "Maximale Anzahl Custom Tokens" msgid "Reruns" msgstr "Wiederholungen" @@ -111,6 +108,9 @@ msgstr "Bilder" msgid "Debug Image Loading" msgstr "Debugausgabe für das Laden der Bilder" +msgid "Cache icons, skinparts and logos at start" +msgstr "Icons, Skinparts und Logos beim Start cachen" + msgid "Limit Channel Logo Cache" msgstr "Größe des Kanallogo Caches bechränken" @@ -132,8 +132,14 @@ msgstr "Icons" msgid "size" msgstr "Größe" -msgid "byte" -msgstr "Byte" +msgid "MB" +msgstr "" + +msgid "int. memory" +msgstr "int. Speicher" + +msgid "high level memory" +msgstr "High Level Speicher" msgid "logos" msgstr "Logos" @@ -163,7 +169,7 @@ msgid "Author" msgstr "Autor" msgid "Used Fonts" -msgstr "Benutze Schriften" +msgstr "Benutze Schriftarten" msgid "Supported Plugins" msgstr "Unterstützte Plugins" diff --git a/po/fi_FI.po b/po/fi_FI.po index 12b3ed7..fb5754b 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr-skindesigner 0.2.0\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2015-08-14 17:20+0200\n" +"POT-Creation-Date: 2016-01-20 18:31+0100\n" "PO-Revision-Date: 2015-01-25 01:25+0200\n" "Last-Translator: Rolf Ahrenberg\n" "Language-Team: Finnish\n" @@ -84,10 +84,7 @@ msgstr "" msgid "Plugin Setup" msgstr "Yleiset" -msgid "Menu Item display method" -msgstr "Valikkorivien esitystapa" - -msgid "Frames per Second (fading and shifting)" +msgid "Maximum number of custom tokens" msgstr "" msgid "Reruns" @@ -111,6 +108,9 @@ msgstr "Kuvat" msgid "Debug Image Loading" msgstr "Debuggaa kuvien latausta" +msgid "Cache icons, skinparts and logos at start" +msgstr "" + msgid "Limit Channel Logo Cache" msgstr "Rajoita kanavalogojen välimuistia" @@ -132,8 +132,14 @@ msgstr "ikoni(a)" msgid "size" msgstr "koko" -msgid "byte" -msgstr "tavu(a)" +msgid "MB" +msgstr "" + +msgid "int. memory" +msgstr "" + +msgid "high level memory" +msgstr "" msgid "logos" msgstr "logo(a)" @@ -167,3 +173,9 @@ msgstr "" msgid "Supported Plugins" msgstr "" + +#~ msgid "byte" +#~ msgstr "tavu(a)" + +#~ msgid "Menu Item display method" +#~ msgstr "Valikkorivien esitystapa" @@ -1,5 +1,5 @@ #include <vdr/interface.h> -#include "libcore/curlfuncs.h" +#include "extensions/curlfuncs.h" #include <vdr/menu.h> #include "setup.h" @@ -119,16 +119,17 @@ eOSState cInstallManager::ProcessInstallationStatus(void) { } // --- cSkinDesignerSetup ----------------------------------------------------------- -cSkinDesignerSetup::cSkinDesignerSetup() { +cSkinDesignerSetup::cSkinDesignerSetup(skindesignerapi::cPluginStructure *skinPreviewStruct) { + this->skinPreviewStruct = skinPreviewStruct; numLogosPerSizeInitial = config.numLogosPerSizeInitial; + cacheImagesInitial = config.cacheImagesInitial; limitLogoCache = config.limitLogoCache; numLogosMax = config.numLogosMax; debugImageLoading = config.debugImageLoading; rerunAmount = config.rerunAmount; rerunDistance = config.rerunDistance; rerunMaxChannel = config.rerunMaxChannel; - blockFlush = config.blockFlush; - framesPerSecond = config.framesPerSecond; + numCustomTokens = config.numCustomTokens; menuDisplayStyle[0] = tr("after one another"); menuDisplayStyle[1] = tr("at one go"); Setup(); @@ -179,7 +180,7 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) { state = osContinue; } else if (type == itSkinRepo) { Skins.Message(mtStatus, tr("Downloading Skin Screenshots...")); - cSkindesignerSkinPreview *prev = new cSkindesignerSkinPreview(currentSkin); + cSkindesignerSkinPreview *prev = new cSkindesignerSkinPreview(currentSkin, skinPreviewStruct); Skins.Message(mtStatus, NULL); state = AddSubMenu(prev); } @@ -254,14 +255,14 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) { void cSkinDesignerSetup::Store(void) { config.numLogosPerSizeInitial = numLogosPerSizeInitial; + config.cacheImagesInitial = cacheImagesInitial; config.limitLogoCache = limitLogoCache; config.numLogosMax = numLogosMax; config.debugImageLoading = debugImageLoading; config.rerunAmount = rerunAmount; config.rerunDistance = rerunDistance; config.rerunMaxChannel = rerunMaxChannel; - config.blockFlush = blockFlush; - config.framesPerSecond = framesPerSecond; + config.numCustomTokens = numCustomTokens; config.InitSetupIterator(); cSkinSetup *skinSetup = NULL; @@ -278,14 +279,14 @@ void cSkinDesignerSetup::Store(void) { config.UpdateGlobals(); SetupStore("DebugImageLoading", debugImageLoading); + SetupStore("CacheImagesInitial", cacheImagesInitial); SetupStore("LimitChannelLogoCache", limitLogoCache); SetupStore("NumberLogosInitially", numLogosPerSizeInitial); SetupStore("NumberLogosMax", numLogosMax); SetupStore("RerunAmount", rerunAmount); SetupStore("RerunDistance", rerunDistance); SetupStore("RerunMaxChannel", rerunMaxChannel); - SetupStore("BlockFlush", blockFlush); - SetupStore("FramesPerSecond", framesPerSecond); + SetupStore("NumCustomTokens", numCustomTokens); } cOsdItem *cSkinDesignerSetup::InfoItem(const char *label) { @@ -298,8 +299,7 @@ cOsdItem *cSkinDesignerSetup::InfoItem(const char *label) { void cSkinDesignerSetup::PluginSetup(void) { Add(InfoItem(tr("Plugin Setup"))); - Add(new cMenuEditStraItem(tr("Menu Item display method"), &blockFlush, 2, menuDisplayStyle)); - Add(new cMenuEditIntItem(tr("Frames per Second (fading and shifting)"), &framesPerSecond, 10, 100)); + Add(new cMenuEditIntItem(tr("Maximum number of custom tokens"), &numCustomTokens, 0, 100)); Add(InfoItem(tr("Reruns"))); Add(new cMenuEditIntItem(tr("Maximum number of reruns to display"), &rerunAmount, 1, 100)); @@ -308,6 +308,7 @@ void cSkinDesignerSetup::PluginSetup(void) { Add(InfoItem(tr("Image Loading"))); Add(new cMenuEditBoolItem(tr("Debug Image Loading"), &debugImageLoading)); + Add(new cMenuEditBoolItem(tr("Cache icons, skinparts and logos at start"), &cacheImagesInitial)); Add(new cMenuEditBoolItem(tr("Limit Channel Logo Cache"), &limitLogoCache)); Add(new cMenuEditIntItem(tr("Number to cache initially (per size)"), &numLogosPerSizeInitial, 0, 1000)); Add(new cMenuEditIntItem(tr("Number to cache in maximum"), &numLogosMax, 0, 1000)); @@ -319,24 +320,26 @@ void cSkinDesignerSetup::ImageCacheStatistics(void) { } Add(InfoItem(tr("Cache Statistics"))); - int sizeIconCache = 0; + float sizeIconCacheInt = 0; + float sizeIconCacheExt = 0; int numIcons = 0; - imgCache->GetIconCacheSize(numIcons, sizeIconCache); - cString iconCacheInfo = cString::sprintf("%s %d %s - %s %d %s", tr("cached"), numIcons, tr("icons"), tr("size"), sizeIconCache, tr("byte")); + imgCache->GetIconCacheSize(numIcons, sizeIconCacheInt, sizeIconCacheExt); + cString iconCacheInfo = cString::sprintf("%s %d %s - %s %.2f%s %s, %.2f%s %s", tr("cached"), numIcons, tr("icons"), tr("size"), sizeIconCacheInt, tr("MB"), tr("int. memory"), sizeIconCacheExt, tr("MB"), tr("high level memory")); Add(new cOsdItem(*iconCacheInfo)); cList<cOsdItem>::Last()->SetSelectable(false); - int sizeLogoCache = 0; + float sizeLogoCache = 0; int numLogos = 0; imgCache->GetLogoCacheSize(numLogos, sizeLogoCache); - cString logoCacheInfo = cString::sprintf("%s %d %s - %s %d %s", tr("cached"), numLogos, tr("logos"), tr("size"), sizeLogoCache, tr("byte")); + cString logoCacheInfo = cString::sprintf("%s %d %s - %s %.2f%s %s", tr("cached"), numLogos, tr("logos"), tr("size"), sizeLogoCache, tr("MB"), tr("int. memory")); Add(new cOsdItem(*logoCacheInfo)); cList<cOsdItem>::Last()->SetSelectable(false); - int sizeSkinpartCache = 0; + float sizeSkinpartCacheInt = 0; + float sizeSkinpartCacheExt = 0; int numSkinparts = 0; - imgCache->GetSkinpartsCacheSize(numSkinparts, sizeSkinpartCache); - cString skinpartCacheInfo = cString::sprintf("%s %d %s - %s %d %s", tr("cached"), numSkinparts, tr("skinparts"), tr("size"), sizeSkinpartCache, tr("byte")); + imgCache->GetSkinpartsCacheSize(numSkinparts, sizeSkinpartCacheInt, sizeSkinpartCacheExt); + cString skinpartCacheInfo = cString::sprintf("%s %d %s - %s %.2f%s %s, %.2f%s %s", tr("cached"), numSkinparts, tr("skinparts"), tr("MB"), sizeSkinpartCacheInt, tr("MB"), tr("int. memory"), sizeSkinpartCacheExt, tr("MB"), tr("high level memory")); Add(new cOsdItem(*skinpartCacheInfo)); cList<cOsdItem>::Last()->SetSelectable(false); } @@ -518,10 +521,9 @@ void cSkindesignerSkinSetup::ShowButtons(int current, bool force) { // --- cSkindesignerSkinPreview ----------------------------------------------------------- -cSkindesignerSkinPreview::cSkindesignerSkinPreview(string skinName) : -cSkindesignerOsdMenu(*cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), skinName.c_str())) { - currentSkin = skinName; - SetPluginName("setup"); +cSkindesignerSkinPreview::cSkindesignerSkinPreview(string skin, skindesignerapi::cPluginStructure *plugStruct) : +cSkindesignerOsdMenu(plugStruct, *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), skin.c_str())) { + currentSkin = skin; FirstCallCleared(); Set(); } @@ -584,64 +586,89 @@ void cSkindesignerSkinPreview::Display(void) { void cSkindesignerSkinPreview::Set(void) { SetPluginMenu(0, skindesignerapi::mtText); - ClearTokens(); Clear(); + skindesignerapi::cTokenContainer *tk = GetTokenContainer(0); + SetTokenContainer(tk); + ClearTokens(); + cSkinRepo *skinRepo = config.GetSkinRepo(currentSkin); if (!skinRepo) { esyslog("skindesigner: no valid skin repository found for skin %s", currentSkin.c_str()); return; } - AddStringToken("menuheader", *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), currentSkin.c_str())); - AddStringToken("skinname", currentSkin); - AddStringToken("author", skinRepo->Author()); + + int fontsIndex = GetLoopIndex("fonts"); + int pluginIndex = GetLoopIndex("plugins"); + int screenshotIndex = GetLoopIndex("screenshots"); + + vector<string> *specialFonts = skinRepo->SpecialFonts(); + vector<string> *supportedPlugins = skinRepo->SupportedPlugins(); + vector< pair < string, string > > *screenshots = skinRepo->Screenshots(); + + vector<int> loopInfo; + loopInfo.push_back((int)specialFonts->size()); + loopInfo.push_back((int)supportedPlugins->size()); + loopInfo.push_back((int)screenshots->size()); + SetLoop(loopInfo); + + AddStringToken((int)eDmSkinPreviewST::menuheader, *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), currentSkin.c_str())); + AddStringToken((int)eDmSkinPreviewST::skinname, currentSkin.c_str()); + AddStringToken((int)eDmSkinPreviewST::author, skinRepo->Author().c_str()); stringstream plainText; plainText << *cString::sprintf("%s: %s \"%s\"", trVDR("Preview"), tr("Skin"), currentSkin.c_str()) << "\n\n"; plainText << tr("Author") << ": " << skinRepo->Author() << "\n"; - plainText << tr("Used Fonts") << ": \n"; - vector<string> specialFonts = skinRepo->SpecialFonts(); - for (vector<string>::iterator it = specialFonts.begin(); it != specialFonts.end(); it++) { - map<string,string> usedFonts; - usedFonts.insert(pair<string,string>("fonts[name]", *it)); - usedFonts.insert(pair<string,string>("fonts[installed]", CheckFontInstalled(*it))); - AddLoopToken("fonts", usedFonts); + + int i = 0; + for (vector<string>::iterator it = specialFonts->begin(); it != specialFonts->end(); it++) { + AddLoopToken(fontsIndex, i, (int)eDmSkinPreviewFontsLT::name, (*it).c_str()); + AddLoopToken(fontsIndex, i, (int)eDmSkinPreviewFontsLT::installed, CheckFontInstalled(*it)); plainText << *it << "\n"; + i++; } plainText << tr("Supported Plugins") << ": \n"; - vector<string> supportedPlugins = skinRepo->SupportedPlugins(); - for (vector<string>::iterator it = supportedPlugins.begin(); it != supportedPlugins.end(); it++) { - map<string,string> plugins; - plugins.insert(pair<string,string>("plugins[name]", *it)); - AddLoopToken("plugins", plugins); + i = 0; + for (vector<string>::iterator it = supportedPlugins->begin(); it != supportedPlugins->end(); it++) { + AddLoopToken(pluginIndex, i, (int)eDmSkinPreviewPluginsLT::name, (*it).c_str()); plainText << *it << "\n"; + i++; } SetText(plainText.str().c_str()); - vector< pair < string, string > > screenshots = skinRepo->Screenshots(); - int i = 0; - for (vector< pair < string, string > >::iterator it = screenshots.begin(); it != screenshots.end(); it++) { + i = 0; + for (vector< pair < string, string > >::iterator it = screenshots->begin(); it != screenshots->end(); it++) { string url = it->second; string imgType = ".jpg"; if (url.find(".png") != string::npos) imgType = ".png"; - stringstream tempName; - tempName << "/tmp/screenshot_" << currentSkin << "_" << i++ << imgType; - dsyslog("skindesigner: download screenshot name %s url %s", tempName.str().c_str(), url.c_str()); - CurlGetUrlFile(url.c_str(), tempName.str().c_str()); - map<string,string> img; - img.insert(pair<string,string>("screenshots[desc]", it->first)); - img.insert(pair<string,string>("screenshots[path]", tempName.str())); - AddLoopToken("screenshots", img); + cString tempName = cString::sprintf("/tmp/screenshot_%s_%d%s", currentSkin.c_str(), i, imgType.c_str()); + dsyslog("skindesigner: download screenshot name %s url %s", *tempName, url.c_str()); + CurlGetUrlFile(url.c_str(), *tempName); + AddLoopToken(screenshotIndex, i, (int)eDmSkinPreviewScreenshotsLT::desc, (it->first).c_str()); + AddLoopToken(screenshotIndex, i, (int)eDmSkinPreviewScreenshotsLT::path, *tempName); + i++; } } -string cSkindesignerSkinPreview::CheckFontInstalled(string fontName) { +void cSkindesignerSkinPreview::DefineTokens(skindesignerapi::cTokenContainer *tk) { + tk->DefineStringToken("{menuheader}", (int)eDmSkinPreviewST::menuheader); + tk->DefineStringToken("{skinname}", (int)eDmSkinPreviewST::skinname); + tk->DefineStringToken("{author}", (int)eDmSkinPreviewST::author); + tk->DefineLoopToken("{fonts[name]}", (int)eDmSkinPreviewFontsLT::name); + tk->DefineLoopToken("{fonts[installed]}", (int)eDmSkinPreviewFontsLT::installed); + tk->DefineLoopToken("{plugins[name]}", (int)eDmSkinPreviewPluginsLT::name); + tk->DefineLoopToken("{screenshots[desc]}", (int)eDmSkinPreviewScreenshotsLT::desc); + tk->DefineLoopToken("{screenshots[path]}", (int)eDmSkinPreviewScreenshotsLT::path); +} + +const char *cSkindesignerSkinPreview::CheckFontInstalled(string fontName) { if (fontManager->FontInstalled(fontName)) return "1"; return "0"; } + @@ -38,15 +38,16 @@ public: // --- cSkinDesignerSetup ----------------------------------------------------------- class cSkinDesignerSetup : public cMenuSetupPage, cInstallManager { private: + skindesignerapi::cPluginStructure *skinPreviewStruct; int numLogosPerSizeInitial; + int cacheImagesInitial; int limitLogoCache; int numLogosMax; int debugImageLoading; int rerunAmount; int rerunDistance; int rerunMaxChannel; - int blockFlush; - int framesPerSecond; + int numCustomTokens; const char *menuDisplayStyle[2]; void Setup(void); virtual void Store(void); @@ -57,7 +58,7 @@ private: void SkinSetup(void); void InstallSkins(void); public: - cSkinDesignerSetup(void); + cSkinDesignerSetup(skindesignerapi::cPluginStructure *skinPreviewStruct); virtual ~cSkinDesignerSetup(void); }; @@ -110,16 +111,15 @@ public: }; // --- cSkindesignerSkinPreview ----------------------------------------------------------- - class cSkindesignerSkinPreview : public skindesignerapi::cSkindesignerOsdMenu, cInstallManager { protected: virtual eOSState ProcessKey(eKeys Key); void Set(void); - string CheckFontInstalled(string fontName); + const char *CheckFontInstalled(string fontName); public: - cSkindesignerSkinPreview(string skin); + cSkindesignerSkinPreview(string skin, skindesignerapi::cPluginStructure *plugStruct); virtual ~cSkindesignerSkinPreview(); + static void DefineTokens(skindesignerapi::cTokenContainer *tk); void Display(void); }; - #endif //__SKINDESIGNER_SETUP_H
\ No newline at end of file diff --git a/skindesigner.c b/skindesigner.c index de93231..c6049bb 100644 --- a/skindesigner.c +++ b/skindesigner.c @@ -7,28 +7,29 @@ */ #include <getopt.h> #include <vdr/plugin.h> -#include "libskindesignerapi/skindesignerapi.h" #define DEFINE_CONFIG 1 #include "config.h" #include "designer.h" #include "setup.h" +#include "libskindesignerapi/skindesignerapi.h" #if defined(APIVERSNUM) && APIVERSNUM < 20000 #error "VDR-2.0.0 API version or greater is required!" #endif -static const char *VERSION = "0.7.2"; +static const char *VERSION = "0.8.0"; static const char *DESCRIPTION = trNOOP("Skin Designer"); class cPluginSkinDesigner : public cPlugin, public skindesignerapi::SkindesignerAPI { private: string libskindesignerApiVersion; + skindesignerapi::cPluginStructure *skinPreviewStruct; protected: bool ServiceRegisterPlugin(skindesignerapi::cPluginStructure *plugStructure); skindesignerapi::ISDDisplayMenu *ServiceGetDisplayMenu(void); - skindesignerapi::ISkinDisplayPlugin *ServiceGetDisplayPlugin(string pluginName, int viewID, int subViewID); + skindesignerapi::ISkinDisplayPlugin *ServiceGetDisplayPlugin(int plugId); public: cPluginSkinDesigner(void); virtual ~cPluginSkinDesigner(); @@ -55,9 +56,11 @@ public: cPluginSkinDesigner::cPluginSkinDesigner(void) { libskindesignerApiVersion = "undefined"; config.SetVersion(VERSION); + skinPreviewStruct = NULL; } cPluginSkinDesigner::~cPluginSkinDesigner() { + delete skinPreviewStruct; } const char *cPluginSkinDesigner::CommandLineHelp(void) { @@ -115,15 +118,19 @@ bool cPluginSkinDesigner::Start(void) { } else dsyslog("skindesigner: TrueColor OSD found"); + plgManager = new cSDPluginManager(); libskindesignerApiVersion = LIBSKINDESIGNERAPIVERSION; dsyslog("skindesigner: using libskindesigner API Version %s", libskindesignerApiVersion.c_str()); - //register template for skin preview page - skindesignerapi::cPluginStructure plugStruct; - plugStruct.name = "setup"; - plugStruct.libskindesignerAPIVersion = LIBSKINDESIGNERAPIVERSION; - plugStruct.SetMenu(0, "skinpreview.xml"); - ServiceRegisterPlugin(&plugStruct); + skinPreviewStruct = new skindesignerapi::cPluginStructure(); + skinPreviewStruct->name = "setup"; + skinPreviewStruct->libskindesignerAPIVersion = LIBSKINDESIGNERAPIVERSION; + skindesignerapi::cTokenContainer *tkSkinPreview = new skindesignerapi::cTokenContainer(); + cSkindesignerSkinPreview::DefineTokens(tkSkinPreview); + skinPreviewStruct->RegisterMenu(0, skindesignerapi::mtText, "skinpreview.xml", tkSkinPreview); + if (RegisterPlugin(skinPreviewStruct)) { + dsyslog("skindesigner: skinsetup template successfully registered at skindesigner, id %d", skinPreviewStruct->id); + } config.SetOsdLanguage(); config.SetPathes(); @@ -153,6 +160,7 @@ bool cPluginSkinDesigner::Start(void) { void cPluginSkinDesigner::Stop(void) { delete imgCache; delete fontManager; + delete plgManager; cXmlParser::CleanupLibXML(); } @@ -175,7 +183,7 @@ cOsdObject *cPluginSkinDesigner::MainMenuAction(void) { } cMenuSetupPage *cPluginSkinDesigner::SetupMenu(void) { - return new cSkinDesignerSetup(); + return new cSkinDesignerSetup(skinPreviewStruct); } bool cPluginSkinDesigner::SetupParse(const char *Name, const char *Value) { @@ -190,8 +198,10 @@ const char **cPluginSkinDesigner::SVDRPHelpPages(void) { static const char *HelpPages[] = { "RELD\n" " force reload of templates and caches", - "SCTK\n" - " Set custom Token name = value", + "SCIT\n" + " Set custom Integer Token key = value", + "SCST\n" + " Set custom String Token key = value", "LCTK\n" " List custom Tokens", "LSTF\n" @@ -236,18 +246,31 @@ cString cPluginSkinDesigner::SVDRPCommand(const char *Command, const char *Optio activeSkin->ListAvailableFonts(); ReplyCode = 250; return "SKINDESIGNER available fonts listed in syslog."; - } else if (strcasecmp(Command, "SCTK") == 0) { + } else if (strcasecmp(Command, "SCIT") == 0) { if (!Option) { ReplyCode = 501; - return "SKINDESIGNER SCTK Error: no Token name = value set"; + return "SKINDESIGNER SCIK Error: no Token name = value set"; } - bool optionOk = activeSkin->SetCustomToken(Option); + bool optionOk = activeSkin->SetCustomIntToken(Option); if (optionOk) { ReplyCode = 250; - return cString::sprintf("SKINDESIGNER Set custom Token %s", Option); + return cString::sprintf("SKINDESIGNER Set custom Int Token %s", Option); } else { ReplyCode = 501; - return cString::sprintf("SKINDESIGNER Invalid custom Token %s", Option); + return cString::sprintf("SKINDESIGNER Invalid custom Int Token %s", Option); + } + } else if (strcasecmp(Command, "SCST") == 0) { + if (!Option) { + ReplyCode = 501; + return "SKINDESIGNER SCSK Error: no Token name = value set"; + } + bool optionOk = activeSkin->SetCustomStringToken(Option); + if (optionOk) { + ReplyCode = 250; + return cString::sprintf("SKINDESIGNER Set custom String Token %s", Option); + } else { + ReplyCode = 501; + return cString::sprintf("SKINDESIGNER Invalid custom String Token %s", Option); } } else if (strcasecmp(Command, "LCTK") == 0) { activeSkin->ListCustomTokens(); @@ -258,18 +281,18 @@ cString cPluginSkinDesigner::SVDRPCommand(const char *Command, const char *Optio return ""; } + bool cPluginSkinDesigner::ServiceRegisterPlugin(skindesignerapi::cPluginStructure *plugStructure) { - if (plugStructure->menus.size() < 1 && plugStructure->views.size() < 1) { + if (plugStructure->menus.size() < 1 && plugStructure->rootview.size() < 1) { esyslog("skindesigner: error - plugin without menus or views registered"); return false; } - dsyslog("skindesigner: plugin %s uses libskindesigner API Version %s", plugStructure->name.c_str(), plugStructure->libskindesignerAPIVersion.c_str()); - config.AddPluginMenus(plugStructure->name, plugStructure->menus); - config.AddPluginViews(plugStructure->name, plugStructure->views, plugStructure->subViews, plugStructure->viewElements, plugStructure->viewGrids); + //basic plugin interface if (plugStructure->menus.size() > 0) - dsyslog("skindesigner: plugin %s has registered %ld menus", plugStructure->name.c_str(), plugStructure->menus.size()); - if (plugStructure->views.size() > 0) - dsyslog("skindesigner: plugin %s has registered %ld views", plugStructure->name.c_str(), plugStructure->views.size()); + plgManager->RegisterBasicPlugin(plugStructure); + //advanced plugin interface + if (plugStructure->rootview.size() > 0) + plgManager->RegisterAdvancedPlugin(plugStructure); return true; } @@ -290,20 +313,13 @@ skindesignerapi::ISDDisplayMenu *cPluginSkinDesigner::ServiceGetDisplayMenu(void return NULL; } -skindesignerapi::ISkinDisplayPlugin *cPluginSkinDesigner::ServiceGetDisplayPlugin(string pluginName, int viewID, int subViewID) { - if (pluginName.size() == 0 || viewID < 0) - return NULL; +skindesignerapi::ISkinDisplayPlugin *cPluginSkinDesigner::ServiceGetDisplayPlugin(int plugId) { cSkin *current = Skins.Current(); cSkinDesigner *availableSkin = NULL; config.InitSkinRefsIterator(); while (availableSkin = config.GetNextSkinRef()) { if (availableSkin == current) { - cSkinDisplayPlugin *displayPlugin = availableSkin->DisplayPlugin(pluginName, viewID, subViewID); - if (displayPlugin) { - return displayPlugin; - } else { - return NULL; - } + return availableSkin->GetDisplayPlugin(plugId); } } return NULL; diff --git a/skins/metrixhd/xmlfiles/displaychannel.xml b/skins/metrixhd/xmlfiles/displaychannel.xml index 9817b9d..3a68bc9 100644 --- a/skins/metrixhd/xmlfiles/displaychannel.xml +++ b/skins/metrixhd/xmlfiles/displaychannel.xml @@ -4,7 +4,7 @@ <displaychannel x="0" y="0" width="100%" height="100%" fadetime="{fadetime}" shifttime="{shifttimechannel}" shifttype="bottom" shiftmode="slowed"> <background> <!-- background infobar --> - <area x="0" y="80%" width="100%" height="20%" layer="1"> + <area x="20%" y="80%" width="80%" height="20%" layer="1"> <fill color="{clrTransBlack}" /> </area> <!-- background channellogo --> @@ -61,8 +61,8 @@ <drawimage name="txt" condition="{hasVT}" imagetype="icon" path="ico_txt_on" x="{posx(dolby)} - 15 - {width(txt)}" valign="center" width="{areaheight}*0.8*1.3" height="{areaheight}*0.8"/> <drawimage condition="not{hasVT}" imagetype="icon" path="ico_txt_off" x="{posx(dolby)} - 15 - {width(txt)}" valign="center" width="{areaheight}*0.8*1.3" height="{areaheight}*0.8"/> <!-- recording icon --> - <drawimage name="rec" condition="{isRecording}" imagetype="icon" path="ico_rec_on" x="{posx(txt)} - 15 - {width(rec)}" valign="center" width="{areaheight}*0.8*1.96" height="{areaheight}*0.8"/> - <drawimage condition="not{isRecording}" imagetype="icon" path="ico_rec_off" x="{posx(txt)} - 15 - {width(rec)}" valign="center" width="{areaheight}*0.8*1.96" height="{areaheight}*0.8"/> + <drawimage animtype="blink" animfreq="500" name="rec" condition="{isRecording}" imagetype="icon" path="ico_rec_on" x="{posx(txt)} - 15 - {width(rec)}" valign="center" width="{areaheight}*0.8*1.96" height="{areaheight}*0.8"/> + <drawimage condition="not{isRecording}" imagetype="icon" path="ico_rec_off" x="{posx(txt)} - 15 - {width(rec)}" valign="center" width="{areaheight}*0.8*1.95652" height="{areaheight}*0.8"/> </area> </statusinfo> @@ -100,10 +100,7 @@ </area> </signalquality> - <signalqualityback> - </signalqualityback> - - <devices condition="{showdevices}" detached="true" delay="100" shifttime="{shifttimedatetime}" shifttype="right" shiftmode="slowed"> + <devices condition="{showdevices}" shifttime="{shifttimedatetime}" shifttype="right" shiftmode="slowed"> <area x="70%" y="30%" width="30%" height="{areaheight}/12 * {numdevices}" layer="1" background="true"> <fill color="{clrTransBlack}"/> </area> @@ -121,7 +118,7 @@ </area> </devices> - <currentweather detached="true" delay="100" shifttime="{shifttimedatetime}" shifttype="right" shiftmode="slowed"> + <currentweather shifttime="{shifttimedatetime}" shifttype="right" shiftmode="slowed"> <area background="true" x="70%" y="15%" width="30%" height="13%" layer="1"> <fill color="{clrTransBlack}" /> <drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" /> @@ -138,16 +135,16 @@ </area> </currentweather> - <scrapercontent detached="true" delay="0" fadetime="0"> + <scrapercontent shifttime="{shifttimedatetime}" shifttype="left" shiftmode="slowed"> <area condition="{isbanner}" x="0" y="0" width="{areaheight}*0.13*{mediawidth}/{mediaheight}" height="13%" layer="2"> - <drawimage imagetype="image" path="{mediapath}" align="center" valign="center" width="{areawidth}" height="{areaheight}"/> + <drawimage imagetype="image" path="{mediapath}" align="center" valign="center" width="{areawidth}" height="{areaheight}"/> </area> <area condition="not{isbanner}" x="0" y="0" width="{areaheight}*0.5*{mediawidth}/{mediaheight}" height="50%" layer="2"> <drawimage imagetype="image" path="{mediapath}" x="5" y="5" width="{areawidth}-10" height="{areaheight}-10"/> </area> </scrapercontent> - <datetime detached="true" delay="100" shifttime="{shifttimedatetime}" shifttype="right" shiftmode="slowed"> + <datetime shifttime="{shifttimedatetime}" shifttype="right" shiftmode="slowed"> <area background="true" x="70%" y="0" width="30%" height="13%" layer="1"> <fill color="{clrTransBlack}" /> <drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" /> @@ -172,7 +169,4 @@ </area> </message> - <customtokens> - </customtokens> - </displaychannel> diff --git a/skins/metrixhd/xmlfiles/displaymenu.xml b/skins/metrixhd/xmlfiles/displaymenu.xml index 53b70fb..da903ba 100644 --- a/skins/metrixhd/xmlfiles/displaymenu.xml +++ b/skins/metrixhd/xmlfiles/displaymenu.xml @@ -12,11 +12,11 @@ <!ENTITY displaymenudetailtext SYSTEM "displaymenudetailtext.xml"> ]> -<displaymenu x="3%" y="5%" width="94%" height="90%" fadetime="0"> +<displaymenu x="3%" y="5%" width="94%" height="90%"> <background> <!-- background left Menu --> - <area x="0" y="0" width="63%" height="100%" layer="1"> + <area x="0" y="0" width="63%" height="100%" layer="2"> <fill color="{clrTransBlack}" /> </area> <!-- background right detail view --> @@ -64,7 +64,7 @@ </sortmode> <colorbuttons> - <area x="0" y="92%" width="15%" height="8%" layer="2"> + <area x="0" y="92%" width="15%" height="8%" layer="6"> <drawtext condition="{red1}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{red}" /> <drawrectangle condition="{red1}" x="0" y="0" width="10" height="100%" color="{clrRed}" /> <drawtext condition="{green1}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{green}" /> @@ -74,7 +74,7 @@ <drawtext condition="{blue1}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{blue}" /> <drawrectangle condition="{blue1}" x="0" y="0" width="10" height="100%" color="{clrBlue}" /> </area> - <area x="15%" y="92%" width="15%" height="8%" layer="2"> + <area x="15%" y="92%" width="15%" height="8%" layer="6"> <drawtext condition="{red2}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{red}" /> <drawrectangle condition="{red2}" x="0" y="0" width="10" height="100%" color="{clrRed}" /> <drawtext condition="{green2}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{green}" /> @@ -84,7 +84,7 @@ <drawtext condition="{blue2}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{blue}" /> <drawrectangle condition="{blue2}" x="0" y="0" width="10" height="100%" color="{clrBlue}" /> </area> - <area x="30%" y="92%" width="15%" height="8%" layer="2"> + <area x="30%" y="92%" width="15%" height="8%" layer="6"> <drawtext condition="{red3}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{red}" /> <drawrectangle condition="{red3}" x="0" y="0" width="10" height="100%" color="{clrRed}" /> <drawtext condition="{green3}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{green}" /> @@ -94,7 +94,7 @@ <drawtext condition="{blue3}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{blue}" /> <drawrectangle condition="{blue3}" x="0" y="0" width="10" height="100%" color="{clrBlue}" /> </area> - <area x="45%" y="92%" width="15%" height="8%" layer="2"> + <area x="45%" y="92%" width="15%" height="8%" layer="6"> <drawtext condition="{red4}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{red}" /> <drawrectangle condition="{red4}" x="0" y="0" width="10" height="100%" color="{clrRed}" /> <drawtext condition="{green4}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{green}" /> @@ -105,6 +105,14 @@ <drawrectangle condition="{blue4}" x="0" y="0" width="10" height="100%" color="{clrBlue}" /> </area> </colorbuttons> + + <scrollbar> + <area x="60%" y="10%" width="2%" height="82%" layer="3"> + <fill color="{clrWhite}" /> + <drawrectangle x="2" y="2" width="{areawidth} - 4" height="{areaheight} - 4" color="{clrTransparent}" /> + <drawrectangle x="4" y="4 + {areaheight} * {offset} / 1000" width="{areawidth} - 8" height="{areaheight} * {height} / 1000 - 8" color="{clrWhite}" /> + </area> + </scrollbar> &displaymenudefault; &displaymenumain; &displaymenusetup; diff --git a/skins/metrixhd/xmlfiles/displaymenuchannels.xml b/skins/metrixhd/xmlfiles/displaymenuchannels.xml index 5b3a184..21999fc 100644 --- a/skins/metrixhd/xmlfiles/displaymenuchannels.xml +++ b/skins/metrixhd/xmlfiles/displaymenuchannels.xml @@ -17,7 +17,7 @@ <drawtext x="20" valign="center" font="{light}" fontsize="95%" color="{clrWhite}" text="{name}" /> </area> </listelement> - <currentelement delay="500" fadetime="0"> + <currentelement fadetime="300"> <area x="63%" y="0" width="36%" height="85%" layer="2"> <drawimage name="logo" imagetype="channellogo" path="{channelid}" x="10" y="0" width="30%" height="10%" /> <drawtext name="channame" align="right" y="{height(logo)}/2 - {height(channame)}/2" width="65%" font="{semibold}" fontsize="10%" color="{clrWhite}" text="{name}" /> diff --git a/skins/metrixhd/xmlfiles/displaymenudetailtext.xml b/skins/metrixhd/xmlfiles/displaymenudetailtext.xml index 08c37b2..81600bd 100644 --- a/skins/metrixhd/xmlfiles/displaymenudetailtext.xml +++ b/skins/metrixhd/xmlfiles/displaymenudetailtext.xml @@ -4,6 +4,11 @@ <fill color="{clrTransBlack}" /> </area> </background> + <header> + <area x="0" y="0" width="41%" height="10%" layer="2"> + <drawtext x="5" width="{areawidth}-10" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{title}" /> + </area> + </header> <datetime> <area x="75%" y="0" width="12%" height="10%" layer="2"> <drawtext align="right" y="15%" font="{light}" fontsize="30%" color="{clrWhite}" text="{dayname}" /> diff --git a/skins/metrixhd/xmlfiles/displaymenumain.xml b/skins/metrixhd/xmlfiles/displaymenumain.xml index 7bd8e33..f9dd6c6 100644 --- a/skins/metrixhd/xmlfiles/displaymenumain.xml +++ b/skins/metrixhd/xmlfiles/displaymenumain.xml @@ -1,4 +1,4 @@ -<menumain x="0" y="0" width="100%" height="100%" fadetime="0"> +<menumain x="0" y="0" width="100%" height="100%" fadetime="0" orientation="{mainmenuorientation}"> <background> <!-- main menu background --> <area x="0" y="0" width="71%" height="70%" layer="1"> @@ -9,6 +9,19 @@ <drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" /> <drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" /> </area> + <!-- system load background --> + <area x="75%" y="40%" width="25%" height="5%" layer="1"> + <fill color="{clrTransBlack}"/> + </area> + <!-- disc usage background --> + <area x="75%" y="26%" width="25%" height="10%" layer="1"> + <fill color="{clrTransBlack}"/> + </area> + <!-- weather background --> + <area x="75%" y="13%" width="25%" height="10%" layer="2"> + <drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" /> + <drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" /> + </area> </background> <header> @@ -70,7 +83,7 @@ </area> </colorbuttons> - <timers detached="true" delay="100" shifttime="{shifttimetimers}" startx="0" starty="100%"> + <timers shifttime="{shifttimetimers}" startx="0" starty="100%"> <area x="0" y="75%" width="{areawidth}/8 - 5" height="25%" layer="1"> <fill color="{clrTransBlack}" /> </area> @@ -109,16 +122,15 @@ <area x="{areawidth}/8" y="75%" width="{areawidth}*0.875" height="25%" layer="2"> <loop name="timers" x="0" y="0" orientation="horizontal" columnwidth="{areawidth}/7" rowheight="{areaheight}" overflow="cut"> <drawrectangle condition="{timers[recording]}" x="0" y="0" width="{columnwidth}-5" height="{rowheight}" color="{clrRed}" /> - <drawimage cache="true" name="logo" imagetype="channellogo" path="{timers[channelid]}" width="{columnwidth}-15" height="40%" align="center" y="10" /> + <drawimage cache="true" name="logo" imagetype="channellogo" path="{timers[channelid]}" width="{columnwidth}-15" height="40%" align="center" y="10" /> <drawtextbox x="5" y="{height(logo)} + 10" width="{columnwidth}-10" align="center" maxlines="2" font="{light}" fontsize="15%" color="{clrWhite}" text="{timers[title]}" /> <drawtext align="center" y="75%" font="{light}" fontsize="20%" color="{clrWhite}" text="{timers[datetime]}" /> </loop> </area> </timers> - <discusage detached="true" delay="100" fadetime="0"> + <discusage> <area background="true" x="75%" y="26%" width="25%" height="10%" layer="1"> - <fill condition="not{discalert}" color="{clrTransBlack}"/> <fill condition="{discalert}" color="{clrRed}"/> </area> <area x="75%" y="26%" width="25%" height="10%" layer="2"> @@ -128,11 +140,7 @@ </area> </discusage> - <currentweather detached="true" delay="100" fadetime="0"> - <area x="75%" y="13%" width="25%" height="10%" layer="2"> - <drawrectangle x="0" y="0" width="53%" height="100%" color="{clrTransBlueLight}" /> - <drawrectangle x="53%" y="0" width="47%" height="100%" color="{clrTransBlack}" /> - </area> + <currentweather> <area x="75%" y="13%" width="12%" height="10%" layer="2"> <drawimage imagetype="icon" path="{icon}" align="center" valign="center" width="{areaheight}*0.9" height="{areaheight}*0.9"/> </area> @@ -145,7 +153,7 @@ </area> </currentweather> - <devices condition="{showdevices}" detached="true" delay="100" fadetime="0"> + <devices condition="{showdevices}"> <area background="true" x="75%" y="48%" width="25%" height="{areaheight}/12 * {numdevices}" layer="1"> <fill color="{clrTransBlack}"/> </area> @@ -163,19 +171,13 @@ </area> </devices> - <systemload detached="true" delay="100" fadetime="0"> - <area background="true" x="75%" y="40%" width="25%" height="5%" layer="1"> - <fill color="{clrTransBlack}"/> - </area> + <systemload> <area x="75%" y="40%" width="25%" height="5%" layer="2"> <drawtext x="5" valign="center" font="{light}" fontsize="100%" color="{clrWhite}" text="System Load: {load}" /> </area> </systemload> - <customtokens> - </customtokens> - - <menuitems condition="strequal({mainmenuorientation}, 'vertical')" x="0" y="7%" orientation="vertical" width="70%" height="56%" align="center" numlistelements="8"> + <menuitems x="0" y="7%" orientation="vertical" width="70%" height="56%" align="center" numlistelements="8"> <listelement> <area x="0" width="60%" layer="2"> <fill condition="not{current}" color="{clrTransparent}" /> @@ -185,7 +187,7 @@ <drawtext name="menutext" x="20" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{number} {label}" /> </areascroll> </listelement> - <currentelement delay="50" fadetime="0"> + <currentelement fadetime="300"> <area x="61%" y="22%" width="36%" height="52%" layer="2"> <fill color="{clrTransBlueLight}" /> </area> @@ -195,7 +197,7 @@ </currentelement> </menuitems> - <menuitems condition="strequal({mainmenuorientation}, 'horizontal')" x="0" y="7%" orientation="horizontal" width="70%" height="56%" align="center" numlistelements="1"> + <menuitems x="0" y="7%" orientation="horizontal" width="70%" height="56%" align="center" numlistelements="1"> <listelement> <area y="10%" height="80%" layer="2"> <drawrectangle condition="{current}" x="20%" y="0" width="60%" height="100%" color="{clrTransBlueLight}" /> @@ -209,7 +211,15 @@ </listelement> </menuitems> - <scrollbar condition="strequal({mainmenuorientation}, 'horizontal')"> + <scrollbar orientation="vertical"> + <area x="68%" y="7%" width="2%" height="56%" layer="2"> + <fill color="{clrWhite}" /> + <drawrectangle x="2" y="2" width="{areawidth} - 4" height="{areaheight} - 4" color="{clrTransparent}" /> + <drawrectangle x="4" y="4 + {areaheight} * {offset} / 1000" width="{areawidth} - 8" height="{areaheight} * {height} / 1000 - 8" color="{clrWhite}" /> + </area> + </scrollbar> + + <scrollbar orientation="horizontal"> <area condition="{hasprev}" x="0" y="7%" width="14%" height="56%" layer="2"> <drawimage imagetype="icon" path="ico_arrow_left" align="center" valign="center" width="{areawidth}*0.8" height="{areawidth}*0.8"/> </area> @@ -217,11 +227,5 @@ <drawimage imagetype="icon" path="ico_arrow_right" align="center" valign="center" width="{areawidth}*0.8" height="{areawidth}*0.8"/> </area> </scrollbar> - <scrollbar condition="strequal({mainmenuorientation}, 'vertical')"> - <area x="68%" y="7%" width="2%" height="56%" layer="2"> - <fill color="{clrWhite}" /> - <drawrectangle x="2" y="2" width="{areawidth} - 4" height="{areaheight} - 4" color="{clrTransparent}" /> - <drawrectangle x="4" y="4 + {areaheight} * {offset} / 1000" width="{areawidth} - 8" height="{areaheight} * {height} / 1000 - 8" color="{clrWhite}" /> - </area> - </scrollbar> + </menumain> diff --git a/skins/metrixhd/xmlfiles/displaymenurecordings.xml b/skins/metrixhd/xmlfiles/displaymenurecordings.xml index 9cef713..276c10f 100644 --- a/skins/metrixhd/xmlfiles/displaymenurecordings.xml +++ b/skins/metrixhd/xmlfiles/displaymenurecordings.xml @@ -1,6 +1,6 @@ -<menurecordings x="0" y="0" width="100%" height="100%" fadetime="0"> +<menurecordings x="0" y="0" width="100%" height="100%" fadetime="0" orientation="{recmenuorientation}"> - <background condition="strequal({recmenuorientation}, 'horizontal')"> + <background orientation="horizontal"> <!-- horizontal menu --> <area x="0" y="0" width="100%" height="10%" layer="1"> <fill color="{clrTransBlack}" /> @@ -13,7 +13,7 @@ </area> </background> - <header condition="strequal({recmenuorientation}, 'horizontal')"> + <header orientation="horizontal"> <!-- horizontal menu --> <area x="0" y="0" width="70%" height="10%" layer="2"> <drawtext condition="not{hasicon}" x="5" width="{areawidth}-10" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{title}" /> @@ -22,7 +22,7 @@ </area> </header> - <datetime condition="strequal({recmenuorientation}, 'horizontal')"> + <datetime orientation="horizontal"> <!-- horizontal menu --> <area x="70%" y="0" width="15%" height="10%" layer="2"> <drawtext align="right" y="5%" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname}" /> @@ -33,7 +33,7 @@ </area> </datetime> - <sortmode condition="strequal({recmenuorientation}, 'horizontal')"> + <sortmode orientation="horizontal"> <!-- horizontal menu --> <area x="60%" y="2%" width="6%" height="6%" layer="4"> <drawimage condition="{sortnumber}" imagetype="icon" path="ico_sort_number" x="0" y="0" width="100%" height="100%"/> @@ -43,13 +43,13 @@ </area> </sortmode> - <menuitems condition="strequal({recmenuorientation}, 'vertical')" x="0" y="10%" orientation="vertical" width="100%" height="82%" align="center" numlistelements="16"> + <menuitems x="0" y="10%" orientation="vertical" width="100%" height="82%" align="center" numlistelements="16"> <listelement> <!-- Background --> <area x="1%" width="58%" layer="2"> <fill condition="not{current}" color="{clrTransparent}" /> + <fill condition="{folder}" color="{clrSemiTransBlack}" /> <fill condition="{current}" color="{clrTransBlueLight}" /> - <fill condition="{separator}" color="{clrSemiTransBlack}" /> </area> <!-- recording folder --> <area condition="{folder}" x="1%" width="58%" layer="2"> @@ -65,7 +65,7 @@ <drawimage condition="not{new}++{cutted}" imagetype="icon" path="ico_cutted" x="{areawidth} - {areaheight}" width="0.9*{areaheight}" height="0.9*{areaheight}" valign="center" /> </area> </listelement> - <currentelement delay="500" fadetime="0"> + <currentelement fadetime="300"> <area x="63%" y="0" width="36%" height="100%" layer="2"> <!-- header --> <drawtext name="title" x="1%" y="0" width="98%" font="{semibold}" fontsize="8%" color="{clrWhite}" text="{epgname}" /> @@ -80,27 +80,27 @@ </currentelement> </menuitems> - <menuitems condition="strequal({recmenuorientation}, 'horizontal')" x="0" y="10%" orientation="horizontal" width="100%" height="82%" align="center" numlistelements="10"> + <menuitems x="0" y="10%" orientation="horizontal" width="100%" height="82%" align="center" numlistelements="10"> <listelement> <!-- Background --> <area y="64%" height="36%" layer="2"> <fill condition="not{current}" color="{clrTransparent}" /> + <fill condition="{folder}" color="{clrSemiTransBlack}" /> <fill condition="{current}" color="{clrTransBlueLight}" /> - <fill condition="{separator}" color="{clrSemiTransBlack}" /> </area> <!-- recording folder --> <area condition="{folder}" y="64%" height="36%" layer="3"> <drawimage name="foldericon" imagetype="icon" path="ico_recfolder" align="center" y="0" width="0.6*{areaheight} * 92 / 136" height="0.6*{areaheight}" /> - <drawtextbox align="center" valign="center" maxlines="3" x="1%" y="63%" width="98%" height="37%" font="{light}" fontsize="12%" color="{clrWhite}" text="{name} ({numrecordingsfolder}, {newrecordingsfolder} new)" /> + <drawtextbox align="center" maxlines="3" x="1%" y="63%" width="98%" height="37%" font="{light}" fontsize="12%" color="{clrWhite}" text="{name} ({numrecordingsfolder}, {newrecordingsfolder} new)" /> </area> <!-- recording item --> <area condition="not{folder}" y="64%" height="36%" layer="3"> - <drawimage condition="{hasposterthumbnail}" imagetype="image" path="{thumbnailpath}" align="center" y="8" width="{areaheight}*0.6 * {thumbnailbwidth} / {thumbnailheight}" height="{areaheight}*0.6"/> - <drawimage condition="not{hasposterthumbnail}" imagetype="icon" path="ico_recording" align="center" y="8" width="{areaheight}*0.5 * {thumbnailbwidth} / {thumbnailheight}" height="{areaheight}*0.6"/> - <drawtextbox align="center" valign="center" maxlines="3" x="1%" y="63%" width="98%" height="37%" font="{light}" fontsize="12%" color="{clrWhite}" text="{name}" /> + <drawimage condition="{hasposterthumbnail}" imagetype="image" path="{thumbnailpath}" align="center" y="8" width="{areaheight}*0.6 * {thumbnailwidth} / {thumbnailheight}" height="{areaheight}*0.6"/> + <drawimage condition="not{hasposterthumbnail}" imagetype="icon" path="ico_recording" align="center" y="8" width="{areaheight}*0.5 * {thumbnailwidth} / {thumbnailheight}" height="{areaheight}*0.6"/> + <drawtextbox align="center" maxlines="3" x="1%" y="63%" width="98%" height="37%" font="{light}" fontsize="12%" color="{clrWhite}" text="{name}" /> </area> </listelement> - <currentelement delay="500" fadetime="0"> + <currentelement fadetime="300"> <area x="5%" y="0" width="90%" height="61%" layer="2"> <!-- scraper poster --> <drawimage condition="{hasposter}" name="poster" imagetype="image" path="{posterpath}" x="1%" y="2%" width="{areaheight}*0.96 * {posterwidth} / {posterheight}" height="96%"/> @@ -119,23 +119,23 @@ </currentelement> </menuitems> - <scrollbar condition="strequal({recmenuorientation}, 'vertical')"> - <area x="60%" y="10%" width="2%" height="82%" layer="3"> + <scrollbar orientation="horizontal"> + <area x="0" y="{areaheight}*0.6" width="100%" height="{areaheight}*0.025" layer="3"> <fill color="{clrWhite}" /> <drawrectangle x="2" y="2" width="{areawidth} - 4" height="{areaheight} - 4" color="{clrTransparent}" /> - <drawrectangle x="4" y="4 + {areaheight} * {offset} / 1000" width="{areawidth} - 8" height="{areaheight} * {height} / 1000 - 8" color="{clrWhite}" /> + <drawrectangle x="4 + {areawidth} * {offset} / 1000" y="4" width="{areawidth} * {height} / 1000 - 8" height="{areaheight} - 8" color="{clrWhite}" /> </area> </scrollbar> - <scrollbar condition="strequal({recmenuorientation}, 'horizontal')"> - <area x="0" y="{areaheight}*0.6" width="100%" height="{areaheight}*0.025" layer="3"> + <scrollbar orientation="vertical"> + <area x="60%" y="10%" width="2%" height="82%" layer="3"> <fill color="{clrWhite}" /> <drawrectangle x="2" y="2" width="{areawidth} - 4" height="{areaheight} - 4" color="{clrTransparent}" /> - <drawrectangle x="4 + {areawidth} * {offset} / 1000" y="4" width="{areawidth} * {height} / 1000 - 8" height="{areaheight} - 8" color="{clrWhite}" /> + <drawrectangle x="4" y="4 + {areaheight} * {offset} / 1000" width="{areawidth} - 8" height="{areaheight} * {height} / 1000 - 8" color="{clrWhite}" /> </area> </scrollbar> - <colorbuttons condition="strequal({recmenuorientation}, 'horizontal')"> + <colorbuttons orientation="horizontal"> <!-- horizontal menu --> <area x="0" y="92%" width="25%" height="8%" layer="2"> <drawtext condition="{red1}" x="20" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{red}" /> diff --git a/skins/metrixhd/xmlfiles/displaymenuschedules.xml b/skins/metrixhd/xmlfiles/displaymenuschedules.xml index b32ea99..a592e76 100644 --- a/skins/metrixhd/xmlfiles/displaymenuschedules.xml +++ b/skins/metrixhd/xmlfiles/displaymenuschedules.xml @@ -21,7 +21,7 @@ <areascroll condition="not{running}" scrollelement="menutext" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" layer="3"> <drawtext name="menutext" x="20" valign="center" font="{light}" fontsize="95%" color="{clrWhite}" text="{start} {title}" /> </areascroll> - <areascroll condition="{running}" scrollelement="menutext" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" width="48%" layer="3"> + <areascroll condition="{running}" scrollelement="menutext" mode="forthandback" orientation="horizontal" delay="1000" scrollspeed="medium" width="80%" layer="3"> <drawtext name="menutext" x="20" valign="center" font="{light}" fontsize="95%" color="{clrWhite}" text="{start} {title}" /> </areascroll> <area layer="3"> @@ -88,8 +88,8 @@ <drawtext x="20" valign="center" font="{light}" fontsize="95%" color="{clrBlueLight}" text="{title}" /> </area> </listelement> - <currentelement delay="500" fadetime="0"> - <area condition="{whatson}" x="63%" y="0" width="36%" height="100%" layer="2"> + <currentelement fadetime="300"> + <area condition="{whatson}" x="63%" y="0" width="36%" height="100%" layer="5"> <!-- title --> <drawtext align="center" y="0" font="{semibold}" width="{areawidth}-20" fontsize="8%" color="{clrWhite}" text="{title}" /> <!-- progress bar if event is running --> @@ -103,7 +103,7 @@ <drawimage condition="{hasposter}" name="poster" imagetype="image" path="{posterpath}" x="10" y="{posy(start)} + {height(start)} + 20" width="{areawidth}/3" height="{areawidth}/3 * {posterheight} / {posterwidth}"/> <!-- description --> <drawtextbox condition="{hasposter}" x="10" y="{posy(poster)}" width="99%" height="{areaheight} - {posy(poster)}" float="topleft" floatwidth="{width(poster)} + 10" floatheight="{height(poster)} + 20" font="{light}" fontsize="{areaheight}/20" color="{clrWhite}" text="{description}" /> - <drawtextbox condition="not{hasposter}" x="10" y="{posy(poster)}" width="99%" height="{areaheight} - {posy(poster)}" font="{light}" fontsize="{areaheight}/20" color="{clrWhite}" text="{description}" /> + <drawtextbox condition="not{hasposter}" x="10" y="{posy(poster)}" width="{areawidth} - 20" height="{areaheight} - {posy(poster)}" font="{light}" fontsize="{areaheight}/20" color="{clrWhite}" text="{description}" /> </area> <areacontainer condition="{whatsonnow}||{whatsonnext}"> <area x="63%" y="0" width="36%" height="85%" layer="2"> @@ -132,11 +132,4 @@ </currentelement> </menuitems> - <scrollbar> - <area x="60%" y="10%" width="2%" height="82%" layer="3"> - <fill color="{clrWhite}" /> - <drawrectangle x="2" y="2" width="{areawidth} - 4" height="{areaheight} - 4" color="{clrTransparent}" /> - <drawrectangle x="4" y="4 + {areaheight} * {offset} / 1000" width="{areawidth} - 8" height="{areaheight} * {height} / 1000 - 8" color="{clrWhite}" /> - </area> - </scrollbar> </menuschedules> diff --git a/skins/metrixhd/xmlfiles/displaymenusetup.xml b/skins/metrixhd/xmlfiles/displaymenusetup.xml index 4e2ae0f..0bd8aa2 100644 --- a/skins/metrixhd/xmlfiles/displaymenusetup.xml +++ b/skins/metrixhd/xmlfiles/displaymenusetup.xml @@ -54,7 +54,7 @@ <drawtext name="menutext" x="20" valign="center" font="{light}" fontsize="90%" color="{clrWhite}" text="{number} {label}" /> </areascroll> </listelement> - <currentelement delay="50" fadetime="0"> + <currentelement fadetime="300"> <area x="61%" y="30%" width="37%" height="36%" layer="2"> <fill color="{clrTransBlueLight}" /> </area> diff --git a/skins/metrixhd/xmlfiles/displaymenutimers.xml b/skins/metrixhd/xmlfiles/displaymenutimers.xml index b9be696..7d65f64 100644 --- a/skins/metrixhd/xmlfiles/displaymenutimers.xml +++ b/skins/metrixhd/xmlfiles/displaymenutimers.xml @@ -15,7 +15,7 @@ <drawtext name="timertext" x="10" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{dayname} {day}. {timerstart} - {timerstop}: {title}" /> </areascroll> </listelement> - <currentelement delay="500" fadetime="0"> + <currentelement fadetime="300"> <area x="63%" y="0" width="36%" height="15%" layer="2"> <drawimage name="logo" imagetype="channellogo" path="{channelid}" x="10" y="0" width="30%" height="100%" /> <drawtext name="channum" x="{width(logo)} + 20" y="{areaheight}/6" width="{areawidth} - {width(logo)} - 30" font="{light}" fontsize="40%" color="{clrWhite}" text="Channel No. {channelnumber}" /> diff --git a/skins/metrixhd/xmlfiles/displaymessage.xml b/skins/metrixhd/xmlfiles/displaymessage.xml index 1ab2bd5..04be966 100644 --- a/skins/metrixhd/xmlfiles/displaymessage.xml +++ b/skins/metrixhd/xmlfiles/displaymessage.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE displaymessage SYSTEM "../../../dtd/displaymessage.dtd">
-<displaymessage x="5%" y="80%" width="90%" height="15%" shifttime="{fadetime}" shifttype="bottom" shiftmode="slowed">
+<displaymessage x="5%" y="80%" width="90%" height="15%" fadetime="{fadetime}" shifttime="{shifttimechannel}" shifttype="bottom" shiftmode="slowed">
<background>
<area x="0" y="0" width="100%" height="100%" layer="1">
<fill color="{clrTransBlack}" />
diff --git a/skins/metrixhd/xmlfiles/displayreplay.xml b/skins/metrixhd/xmlfiles/displayreplay.xml index d2fa71b..4842c39 100644 --- a/skins/metrixhd/xmlfiles/displayreplay.xml +++ b/skins/metrixhd/xmlfiles/displayreplay.xml @@ -1,17 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE displayreplay SYSTEM "../../../dtd/displayreplay.dtd"> -<displayreplay x="0" y="0" width="100%" height="100%" fadetime="{fadetime}"> +<displayreplay x="0" y="0" width="100%" height="100%" fadetime="{fadetime}" shifttime="{shifttimechannel}" shifttype="bottom" shiftmode="slowed"> <background> <!-- background infobar --> <area x="0" y="80%" width="100%" height="20%" layer="1"> <fill color="{clrTransBlack}" /> </area> - <!-- background datetime --> - <area x="70%" y="0" width="30%" height="13%" layer="1"> - <fill color="{clrTransBlack}" /> - <drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" /> - </area> </background> <backgroundmodeonly> @@ -21,7 +16,11 @@ </area> </backgroundmodeonly> - <datetime> + <datetime shifttime="0"> + <area x="70%" y="0" width="30%" height="13%" layer="1"> + <fill color="{clrTransBlack}" /> + <drawrectangle x="0" y="0" width="45%" height="100%" color="{clrTransBlueLight}" /> + </area> <area x="70%" y="0" width="13%" height="13%" layer="2"> <drawtext align="right" y="0" font="{light}" fontsize="50%" color="{clrWhite}" text="{dayname}" /> <drawtext align="right" y="48%" font="{light}" fontsize="50%" color="{clrWhite}" text="{day}. {monthnameshort}" /> @@ -31,7 +30,7 @@ </area> </datetime> - <scrapercontent> + <scrapercontent shifttime="0"> <area condition="{isbanner}" x="0" y="0" width="{areaheight}*0.13*{mediawidth}/{mediaheight}" height="13%" layer="2"> <drawimage imagetype="image" path="{mediapath}" align="center" valign="center" width="{areawidth}" height="{areaheight}"/> </area> @@ -183,13 +182,13 @@ </area> </jump> - <onpause delay="60" fadetime="{fadeTime}"> + <onpause delay="30" fadetime="{fadetime}"> <area x="0" y="0" width="100%" height="100%" layer="7"> <fill color="{clrSemiTransBlack}" /> </area> </onpause> - <onpausemodeonly delay="20" fadetime="{fadeTime}"> + <onpausemodeonly delay="20" fadetime="{fadetime}"> <area x="0" y="0" width="100%" height="100%" layer="7"> <fill color="{clrSemiTransBlack}" /> </area> diff --git a/skins/metrixhd/xmlfiles/displayvolume.xml b/skins/metrixhd/xmlfiles/displayvolume.xml index db78bde..814bacd 100644 --- a/skins/metrixhd/xmlfiles/displayvolume.xml +++ b/skins/metrixhd/xmlfiles/displayvolume.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE displayvolume SYSTEM "../../../dtd/displayvolume.dtd"> -<displayvolume x="20%" y="75%" width="60%" height="20%" shifttime="{fadetime}" shifttype="bottom" shiftmode="slowed"> +<displayvolume x="20%" y="75%" width="60%" height="20%" fadetime="{fadetime}"> <background> <area x="0" y="0" width="100%" height="100%" layer="1"> <fill color="{clrTransBlack}" /> diff --git a/skins/metrixhd/xmlfiles/plug-tvguideng-recmenu.xml b/skins/metrixhd/xmlfiles/plug-tvguideng-recmenu.xml index 058f1f5..21ae64c 100644 --- a/skins/metrixhd/xmlfiles/plug-tvguideng-recmenu.xml +++ b/skins/metrixhd/xmlfiles/plug-tvguideng-recmenu.xml @@ -60,17 +60,17 @@ </areacontainer> <area condition="{intselector}" layer="6"> <drawtext x="1%" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{text}" /> - <drawtext align="right" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{value} " /> + <drawtext align="right" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{stringvalue} " /> </area> <area condition="{boolselector}" layer="6"> <drawtext x="1%" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{text}" /> - <drawimage condition="{value}" imagetype="icon" path="ico_yes" x="{areawidth} - {areaheight}*0.8" y="10%" width="{areaheight}*0.8" height="{areaheight}*0.8"/> - <drawimage condition="not{value}" imagetype="icon" path="ico_no" x="{areawidth} - {areaheight}*0.8" y="10%" width="{areaheight}*0.8" height="{areaheight}*0.8"/> + <drawimage condition="{intvalue}" imagetype="icon" path="ico_yes" x="{areawidth} - {areaheight}*0.8" y="10%" width="{areaheight}*0.8" height="{areaheight}*0.8"/> + <drawimage condition="not{intvalue}" imagetype="icon" path="ico_no" x="{areawidth} - {areaheight}*0.8" y="10%" width="{areaheight}*0.8" height="{areaheight}*0.8"/> </area> <area condition="{stringselector}" layer="6"> <drawtext x="1%" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{text}" /> <drawimage imagetype="icon" path="ico_arrow_right" x="{areawidth} - {areaheight}*0.8" y="10%" width="{areaheight}*0.8" height="{areaheight}*0.8"/> - <drawtext name="value" x="{areawidth} - {width(value)} - {areaheight}" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{value}" /> + <drawtext name="value" x="{areawidth} - {width(value)} - {areaheight}" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{stringvalue}" /> <drawimage imagetype="icon" path="ico_arrow_left" x="{areawidth} - {width(value)} - 2*{areaheight}" y="10%" width="{areaheight}*0.8" height="{areaheight}*0.8"/> </area> <areacontainer condition="{textinput}"> @@ -80,16 +80,16 @@ <drawrectangle condition="{editmode}" x="1%" y="55%" width="98%" height="40%" color="{clrRed}"/> </area> <area layer="7"> - <drawtext align="right" y="55%" font="{light}" fontsize="40%" color="{clrBlack}" text="{value} " /> + <drawtext align="right" y="55%" font="{light}" fontsize="40%" color="{clrBlack}" text="{stringvalue} " /> </area> </areacontainer> <area condition="{timeselector}" layer="6"> <drawtext x="1%" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{text}" /> - <drawtext align="right" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{value} " /> + <drawtext align="right" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{stringvalue} " /> </area> <area condition="{dayselector}" layer="6"> <drawtext x="1%" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{text}" /> - <drawtext align="right" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{value} " /> + <drawtext align="right" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{stringvalue} " /> </area> <area condition="{channelselector}" layer="6"> <drawtext x="1%" valign="center" font="{light}" fontsize="80%" color="{clrWhite}" text="{text}" /> @@ -176,7 +176,7 @@ <drawimage condition="not{current}||not{editactive}" imagetype="icon" path="ico_edit_inactive" x="{areaheight}*1.15" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> <drawimage condition="{current}++{searchactive}" imagetype="icon" path="ico_search_active" x="{areaheight}*1.7" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> <drawimage condition="not{current}||not{searchactive}" imagetype="icon" path="ico_search_inactive" x="{areaheight}*1.7" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> - <drawtext x="{areaheight}*2.3" width="{areawidth}*0.7 - {areaheight}*2.4" y="0" font="{regular}" fontsize="40%" color="{clrWhite}" text="{timertitle}" /> + <drawtext x="{areaheight}*2.3" width="{areawidth}*0.7 - {areaheight}*2.4" y="0" font="{light}" fontsize="40%" color="{clrWhite}" text="{timertitle}" /> <drawtext x="{areaheight}*2.3" y="40%" font="{light}" fontsize="30%" color="{clrWhite}" text="{weekday} {date} {starttime} - {stoptime}" /> <drawtext x="{areaheight}*2.3" y="70%" font="{light}" fontsize="30%" color="{clrWhite}" text="{channelname}, Transp. {transponder}" /> <drawrectangle x="70%" y="0" width="30%" height="100%" color="{clrWhite}"/> @@ -191,7 +191,7 @@ <drawimage condition="not{current}" imagetype="icon" path="ico_info_inactive" x="{areaheight}*0.05" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> <drawimage condition="{channellogoexisis}" imagetype="channellogo" path="{channelid}" x="{areaheight}*0.8" valign="center" width="{areaheight}" height="{areaheight}" /> <drawtext x="{areaheight}*2.2" y="2" font="{light}" fontsize="30%" color="{clrWhite}" text="{weekday} {date} {starttime} - {stoptime} {channelname}" /> - <drawtext x="{areaheight}*2.2" y="30%" width="{areawidth} - 3*{areaheight}" font="{regular}" fontsize="45%" color="{clrWhite}" text="{title}" /> + <drawtext x="{areaheight}*2.2" y="30%" width="{areawidth} - 3*{areaheight}" font="{light}" fontsize="45%" color="{clrWhite}" text="{title}" /> <drawtext x="{areaheight}*2.2" y="69%" width="{areawidth} - 3*{areaheight}" font="{light}" fontsize="30%" color="{clrWhite}" text="{shorttext}" /> <drawimage condition="{current}++not{hastimer}" imagetype="icon" path="ico_record_active" x="{areawidth} - {areaheight}*0.6" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> <drawimage condition="not{current}++not{hastimer}" imagetype="icon" path="ico_record_inactive" x="{areawidth} - {areaheight}*0.6" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> @@ -208,13 +208,13 @@ <drawimage condition="not{current}||not{editactive}" imagetype="icon" path="ico_edit_inactive" x="{areaheight}*0.6" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> <drawimage condition="{current}++{deleteactive}" imagetype="icon" path="ico_delete_active" x="{areaheight}*1.15" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> <drawimage condition="not{current}||not{deleteactive}" imagetype="icon" path="ico_delete_inactive" x="{areaheight}*1.15" valign="center" width="{areaheight}*0.5" height="{areaheight}*0.5"/> - <drawtext x="{areaheight}*1.8" width="{areawidth} - {areaheight}*2" y="5%" font="{regular}" fontsize="45%" color="{clrWhite}" text="{searchstring}" /> - <drawtext condition="{timeractive}" align="right" y="5%" font="{regular}" fontsize="35%" color="{clrWhite}" text="active " /> + <drawtext x="{areaheight}*1.8" width="{areawidth} - {areaheight}*2" y="5%" font="{light}" fontsize="45%" color="{clrWhite}" text="{searchstring}" /> + <drawtext condition="{timeractive}" align="right" y="5%" font="{light}" fontsize="35%" color="{clrWhite}" text="active " /> <drawtext x="{areaheight}*1.8" y="55%" font="{light}" fontsize="35%" color="{clrWhite}" text="Active Timers: {activetimers}, Recordings: {recordingsdone}" /> </area> <areacontainer condition="{timelineheader}"> <area layer="5"> - <drawtext align="center" y="1%" font="{regular}" fontsize="35%" color="{clrWhite}" text="Timer for {date}" /> + <drawtext align="center" y="1%" font="{light}" fontsize="35%" color="{clrWhite}" text="Timer for {date}" /> <drawrectangle x="{areawidth}*0.05" y="80%" width="{areawidth}*0.0375" height="20%" color="{clrBlack}"/> <drawrectangle x="{areawidth}*0.0875" y="80%" width="{areawidth}*0.0375" height="20%" color="{clrWhite}"/> <drawrectangle x="{areawidth}*0.125" y="80%" width="{areawidth}*0.0375" height="20%" color="{clrBlack}"/> @@ -241,30 +241,30 @@ <drawrectangle x="{areawidth}*0.9125" y="80%" width="{areawidth}*0.0375" height="20%" color="{clrWhite}"/> </area> <area layer="6"> - <drawtext name="text0" x="{areawidth}*0.05 + {areawidth}*0.0375/2 - {width(text0)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="0"/> - <drawtext name="text1" x="{areawidth}*0.0875 + {areawidth}*0.0375/2 - {width(text1)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="1"/> - <drawtext name="text2" x="{areawidth}*0.125 + {areawidth}*0.0375/2 - {width(text2)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="2"/> - <drawtext name="text3" x="{areawidth}*0.1625 + {areawidth}*0.0375/2 - {width(text3)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="3"/> - <drawtext name="text4" x="{areawidth}*0.2 + {areawidth}*0.0375/2 - {width(text4)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="4"/> - <drawtext name="text5" x="{areawidth}*0.2375 + {areawidth}*0.0375/2 - {width(text5)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="5"/> - <drawtext name="text6" x="{areawidth}*0.275 + {areawidth}*0.0375/2 - {width(text6)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="6"/> - <drawtext name="text7" x="{areawidth}*0.3125 + {areawidth}*0.0375/2 - {width(text7)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="7"/> - <drawtext name="text8" x="{areawidth}*0.35 + {areawidth}*0.0375/2 - {width(text8)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="8"/> - <drawtext name="text9" x="{areawidth}*0.3875 + {areawidth}*0.0375/2 - {width(text9)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="9"/> - <drawtext name="text10" x="{areawidth}*0.425 + {areawidth}*0.0375/2 - {width(text10)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="10"/> - <drawtext name="text11" x="{areawidth}*0.4625 + {areawidth}*0.0375/2 - {width(text11)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="11"/> - <drawtext name="text12" x="{areawidth}*0.5 + {areawidth}*0.0375/2 - {width(text12)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="12"/> - <drawtext name="text13" x="{areawidth}*0.5375 + {areawidth}*0.0375/2 - {width(text13)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="13"/> - <drawtext name="text14" x="{areawidth}*0.575 + {areawidth}*0.0375/2 - {width(text14)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="14"/> - <drawtext name="text15" x="{areawidth}*0.6125 + {areawidth}*0.0375/2 - {width(text15)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="15"/> - <drawtext name="text16" x="{areawidth}*0.65 + {areawidth}*0.0375/2 - {width(text16)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="16"/> - <drawtext name="text17" x="{areawidth}*0.6875 + {areawidth}*0.0375/2 - {width(text17)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="17"/> - <drawtext name="text18" x="{areawidth}*0.725 + {areawidth}*0.0375/2 - {width(text18)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="18"/> - <drawtext name="text19" x="{areawidth}*0.7625 + {areawidth}*0.0375/2 - {width(text19)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="19"/> - <drawtext name="text20" x="{areawidth}*0.8 + {areawidth}*0.0375/2 - {width(text20)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="20"/> - <drawtext name="text21" x="{areawidth}*0.8375 + {areawidth}*0.0375/2 - {width(text21)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="21"/> - <drawtext name="text22" x="{areawidth}*0.875 + {areawidth}*0.0375/2 - {width(text22)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrWhite}" text="22"/> - <drawtext name="text23" x="{areawidth}*0.9125 + {areawidth}*0.0375/2 - {width(text23)}/2" y="80%" font="{regular}" fontsize="20%" color="{clrBlack}" text="23"/> + <drawtext name="text0" x="{areawidth}*0.05 + {areawidth}*0.0375/2 - {width(text0)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="0"/> + <drawtext name="text1" x="{areawidth}*0.0875 + {areawidth}*0.0375/2 - {width(text1)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="1"/> + <drawtext name="text2" x="{areawidth}*0.125 + {areawidth}*0.0375/2 - {width(text2)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="2"/> + <drawtext name="text3" x="{areawidth}*0.1625 + {areawidth}*0.0375/2 - {width(text3)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="3"/> + <drawtext name="text4" x="{areawidth}*0.2 + {areawidth}*0.0375/2 - {width(text4)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="4"/> + <drawtext name="text5" x="{areawidth}*0.2375 + {areawidth}*0.0375/2 - {width(text5)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="5"/> + <drawtext name="text6" x="{areawidth}*0.275 + {areawidth}*0.0375/2 - {width(text6)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="6"/> + <drawtext name="text7" x="{areawidth}*0.3125 + {areawidth}*0.0375/2 - {width(text7)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="7"/> + <drawtext name="text8" x="{areawidth}*0.35 + {areawidth}*0.0375/2 - {width(text8)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="8"/> + <drawtext name="text9" x="{areawidth}*0.3875 + {areawidth}*0.0375/2 - {width(text9)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="9"/> + <drawtext name="text10" x="{areawidth}*0.425 + {areawidth}*0.0375/2 - {width(text10)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="10"/> + <drawtext name="text11" x="{areawidth}*0.4625 + {areawidth}*0.0375/2 - {width(text11)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="11"/> + <drawtext name="text12" x="{areawidth}*0.5 + {areawidth}*0.0375/2 - {width(text12)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="12"/> + <drawtext name="text13" x="{areawidth}*0.5375 + {areawidth}*0.0375/2 - {width(text13)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="13"/> + <drawtext name="text14" x="{areawidth}*0.575 + {areawidth}*0.0375/2 - {width(text14)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="14"/> + <drawtext name="text15" x="{areawidth}*0.6125 + {areawidth}*0.0375/2 - {width(text15)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="15"/> + <drawtext name="text16" x="{areawidth}*0.65 + {areawidth}*0.0375/2 - {width(text16)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="16"/> + <drawtext name="text17" x="{areawidth}*0.6875 + {areawidth}*0.0375/2 - {width(text17)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="17"/> + <drawtext name="text18" x="{areawidth}*0.725 + {areawidth}*0.0375/2 - {width(text18)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="18"/> + <drawtext name="text19" x="{areawidth}*0.7625 + {areawidth}*0.0375/2 - {width(text19)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="19"/> + <drawtext name="text20" x="{areawidth}*0.8 + {areawidth}*0.0375/2 - {width(text20)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="20"/> + <drawtext name="text21" x="{areawidth}*0.8375 + {areawidth}*0.0375/2 - {width(text21)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="21"/> + <drawtext name="text22" x="{areawidth}*0.875 + {areawidth}*0.0375/2 - {width(text22)}/2" y="80%" font="{light}" fontsize="20%" color="{clrWhite}" text="22"/> + <drawtext name="text23" x="{areawidth}*0.9125 + {areawidth}*0.0375/2 - {width(text23)}/2" y="80%" font="{light}" fontsize="20%" color="{clrBlack}" text="23"/> </area> <area condition="{timerset}" layer="6"> <drawimage condition="{channellogoexisis}" imagetype="channellogo" path="{channelid}" x="1%" y="30%" width="{areaheight}*0.5" height="{areaheight}*0.5" /> @@ -280,7 +280,7 @@ <drawrectangle x="5%" y="{areaheight}-1" width="90%" height="1" color="{clrBlack}"/> </area> <area layer="6"> - <drawrectangle x="{areawidth}*0.05 + {timerstart}*{areawidth}*0.9/1000" y="25%" width="{timerwidth}*{areawidth}*0.9/1000" height="50%" color="{clrBlack}"/> + <drawrectangle x="{areawidth}*0.05 + {timerstart}*{areawidth}*0.9/1000" y="25%" width="{timerwidth}*{areawidth}*0.9/1000" height="50%" color="{clrWhite}"/> </area> </areacontainer> <area condition="{favorite}" layer="6"> diff --git a/skins/metrixhd/xmlfiles/plug-tvguideng-root.xml b/skins/metrixhd/xmlfiles/plug-tvguideng-root.xml index 442c921..9914a80 100644 --- a/skins/metrixhd/xmlfiles/plug-tvguideng-root.xml +++ b/skins/metrixhd/xmlfiles/plug-tvguideng-root.xml @@ -30,8 +30,8 @@ <viewelement name="header_hor"> <areascroll condition="not{isdummy}++not{hasposter}" orientation="vertical" mode="forthandback" delay="1000" scrollspeed="medium" x="1%" y="1%" width="68%" height="19%" layer="2"> <drawtext x="0" y="0" font="{semibold}" width="100%" fontsize="25%" color="{clrWhite}" text="{day} {daynumeric}.{month} {start} - {stop}" /> - <drawtext x="0" y="20%" font="{semibold}" width="100%" fontsize="30%" color="{clrWhite}" text="{title}" /> - <drawtextbox name="shorttext" x="0" y="50%" width="100%" font="{light}" fontsize="20%" color="{clrWhite}" text="{shorttext}" /> + <drawtext x="0" y="25%" font="{semibold}" width="100%" fontsize="30%" color="{clrWhite}" text="{title}" /> + <drawtextbox name="shorttext" x="0" y="55%" width="100%" font="{light}" fontsize="20%" color="{clrWhite}" text="{shorttext}" /> <drawtextbox x="0" y="{posy(shorttext)} + {height(shorttext)} - {areaheight}*0.15" width="100%" font="{light}" fontsize="20%" color="{clrWhite}" text="{description}" /> </areascroll> <area condition="not{isdummy}++{hasposter}" x="1%" y="1%" width="{areaheight}*0.2*{posterwidth}/{posterheight}" height="19%" layer="2"> @@ -282,7 +282,7 @@ <drawtext condition="not{dummy}" x="3" y="2%" font="{light}" fontsize="{areawidth}*0.16" color="{clrWhite}" text="{start} - {stop}" /> <drawtextbox name="title" condition="not{dummy}" x="2%" y="{areawidth}*0.16" width="96%" font="{semibold}" fontsize="{areawidth}*0.15" color="{clrWhite}" text="{title}" /> <drawtextbox condition="not{dummy}" x="2%" y="{posy(title)} + {height(title)} - {areawidth}*0.1" width="96%" height="{areaheight}*1.1 - {posy(title)} - {height(title)}" font="{light}" fontsize="{areawidth}*0.12" color="{clrWhite}" text="{shorttext}" /> - <drawtextbox condition="{dummy}" x="2%" y="5%" width="96%" font="{regular}" fontsize="{areawidth}*0.2" color="{clrWhite}" text="{title}" /> + <drawtextbox condition="{dummy}" x="2%" y="5%" width="96%" font="{light}" fontsize="{areawidth}*0.2" color="{clrWhite}" text="{title}" /> <drawimage condition="{timer}" imagetype="icon" path="ico_rec_on" x="{areawidth} - {areaheight}*0.32*45/23" y="68%" width="{areaheight}*0.3*45/23" height="{areaheight}*0.3"/> <drawimage condition="{switchtimer}++not{timer}" imagetype="icon" path="ico_switchtimer" x="{areawidth} - {areaheight}*0.32*45/23" y="68%" width="{areaheight}*0.3*45/23" height="{areaheight}*0.3"/> <drawimage condition="{switchtimer}++{timer}" imagetype="icon" path="ico_switchtimer" x="{areawidth} - {areaheight}*0.32*45/23*2 - 5" y="68%" width="{areaheight}*0.3*45/23" height="{areaheight}*0.3" /> diff --git a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml index 08b85ab..078353c 100644 --- a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml +++ b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecast.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE menuplugin SYSTEM "../../../dtd/displaymenuplugin.dtd"> -<menuplugin x="0" y="0" width="100%" height="100%" fadetime="0"> - <background condition="eq({indexweathermenuorientation}, 1)"> +<menuplugin x="0" y="0" width="100%" height="100%" fadetime="0" orientation="{weathermenuorientation}"> + <background orientation="vertical"> <area x="0" y="0" width="50%" height="100%" layer="1"> <fill color="{clrTransBlack}" /> </area> @@ -10,7 +10,7 @@ <fill color="{clrTransBlueLight}" /> </area> </background> - <background condition="eq({indexweathermenuorientation}, 0)"> + <background orientation="horizontal"> <area x="0" y="0" width="100%" height="10%" layer="1"> <fill color="{clrTransBlack}" /> </area> @@ -42,7 +42,13 @@ </area> </colorbuttons> - <menuitems condition="strequal({weathermenuorientation}, 'vertical')" x="0" y="10%" orientation="vertical" width="100%" height="82%" align="center" numlistelements="10"> + <scrollbar> + <area x="0" y="0" width="1" height="1" layer="1"> + <fill color="{clrTransparent}" /> + </area> + </scrollbar> + + <menuitems x="0" y="10%" orientation="vertical" width="100%" height="82%" align="center" numlistelements="10"> <listelement> <!-- Background --> <area x="1%" width="46%" layer="2"> @@ -53,7 +59,7 @@ <drawtext x="10" valign="center" font="{light}" fontsize="95%" color="{clrWhite}" text="{menuitemtext}" /> </area> </listelement> - <currentelement delay="100" fadetime="0"> + <currentelement delay="100" fadetime="300"> <area condition="{iscurrent}" x="51%" y="0" width="48%" height="100%" layer="3"> <drawimage name="weathericon" imagetype="icon" path="{icon}" x="2%" y="0" width="{areawidth}*0.3" height="{areawidth}*0.3"/> <drawtext align="right" y="0" font="{semibold}" fontsize="8%" color="{clrWhite}" text="{city}" /> @@ -88,7 +94,7 @@ </area> </currentelement> </menuitems> - <menuitems condition="strequal({weathermenuorientation}, 'horizontal')" x="0" y="10%" orientation="horizontal" width="100%" height="90%" align="center" numlistelements="3"> + <menuitems x="0" y="10%" orientation="horizontal" width="100%" height="90%" align="center" numlistelements="3"> <listelement> <!-- Background --> <area y="80%" height="20%" layer="2"> @@ -99,7 +105,7 @@ <drawtextbox x="0" y="0" width="100%" height="100%" align="center" valign="center" font="{light}" fontsize="40%" color="{clrWhite}" text="{menuitemtext}" /> </area> </listelement> - <currentelement delay="100" fadetime="0"> + <currentelement debug="true" delay="100" fadetime="300"> <area condition="{iscurrent}" x="10%" y="5%" width="80%" height="70%" layer="3"> <drawimage name="weathericon" imagetype="icon" path="{icon}" x="2%" y="0" width="{areaheight}*0.4" height="{areaheight}*0.4"/> <drawtext align="right" y="0" font="{semibold}" fontsize="10%" color="{clrWhite}" text="{city}" /> diff --git a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailcurrent.xml b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailcurrent.xml index 365abf7..52746ca 100644 --- a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailcurrent.xml +++ b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailcurrent.xml @@ -8,7 +8,7 @@ </area> </background> - <header> + <header> <area x="0" y="0" width="1" height="1" layer="1"> <fill color="{clrTransparent}" /> </area> diff --git a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetaildaily.xml b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetaildaily.xml index 802fa90..52f027d 100644 --- a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetaildaily.xml +++ b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetaildaily.xml @@ -48,8 +48,8 @@ <tab name="current" x="2%" y="20%" width="94%" height="65%" layer="2" scrollheight="{areaheight}/4"> <drawtextbox name="summary" x="0" y="5%" width="{areawidth}" font="{semibold}" fontsize="10%" color="{clrWhite}" text="{summary}" /> - <drawrectangle x="0" y="{height(summary)}" width="{areawidth}" height="1" color="{clrWhite}" /> - <loop name="daily" x="0" y="{height(summary)}" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight}/5"> + <drawrectangle x="0" y="{posy(summary)} + {height(summary)} + 10" width="{areawidth}" height="1" color="{clrWhite}" /> + <loop name="daily" x="0" y="{posy(summary)} + {height(summary)} + 10" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight}/5"> <drawtext x="0" font="{semibold}" fontsize="9%" valign="center" color="{clrWhite}" text="{daily[dayname]} {daily[day]}" /> <drawimage imagetype="icon" path="{daily[icon]}" x="2*{rowheight}" valign="center" width="{rowheight}*0.8" height="{rowheight}*0.8"/> <drawtext x="3.5*{rowheight}" font="{light}" fontsize="{rowheight}*0.3" y="0" color="{clrWhite}" text="{daily[temperaturemin]}°C - {daily[temperaturemax]}°C ({tr(max)} {daily[temperaturemaxtime]}, {tr(min)} {daily[temperaturemintime]})" /> diff --git a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailhourly.xml b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailhourly.xml index 86670fa..e54551c 100644 --- a/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailhourly.xml +++ b/skins/metrixhd/xmlfiles/plug-weatherforecast-weatherforecastdetailhourly.xml @@ -48,8 +48,8 @@ <tab name="current" x="2%" y="20%" width="94%" height="65%" layer="2" scrollheight="{areaheight}/4"> <drawtextbox name="summary" x="0" y="5%" width="{areawidth}" font="{semibold}" fontsize="10%" color="{clrWhite}" text="{summary}" /> - <drawrectangle x="0" y="{height(summary)}" width="{areawidth}" height="1" color="{clrWhite}" /> - <loop name="hourly" x="0" y="{height(summary)}" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight}/5"> + <drawrectangle x="0" y="{posy(summary)} + {height(summary)} + 10" width="{areawidth}" height="1" color="{clrWhite}" /> + <loop name="hourly" x="0" y="{posy(summary)} + {height(summary)} + 10" orientation="vertical" columnwidth="{areawidth}" rowheight="{areaheight}/5"> <drawtext x="0" font="{semibold}" fontsize="9%" valign="center" color="{clrWhite}" text="{hourly[timestamp]}" /> <drawimage imagetype="icon" path="{hourly[icon]}" x="{rowheight}" valign="center" width="{rowheight}*0.8" height="{rowheight}*0.8"/> <drawtext name="temp" x="2*{rowheight} + 0.75*{rowheight} - {width(temp)}/2" font="{light}" fontsize="13%" y="0" color="{clrWhite}" text="{hourly[temperature]}°C" /> diff --git a/skinskeleton/xmlfiles/displayaudiotracks.xml b/skinskeleton/xmlfiles/displayaudiotracks.xml index 1989bb9..2e3d994 100644 --- a/skinskeleton/xmlfiles/displayaudiotracks.xml +++ b/skinskeleton/xmlfiles/displayaudiotracks.xml @@ -15,7 +15,7 @@ <header> </header> - <!-- Available Variables header: + <!-- Available Variables menuitems: {numelements} number of displayed tracks --> <menuitems x="0" y="{areaheight} - {numelements} * {areaheight} / 10" orientation="vertical" width="100%" height="{numelements} * {areaheight} / 10" align="top" numlistelements="{numelements}"> diff --git a/skinskeleton/xmlfiles/displaychannel.xml b/skinskeleton/xmlfiles/displaychannel.xml index 319ff20..c4519dd 100644 --- a/skinskeleton/xmlfiles/displaychannel.xml +++ b/skinskeleton/xmlfiles/displaychannel.xml @@ -98,7 +98,7 @@ <screenresolution> </screenresolution> - <!-- Available Variables dvbdeviceinfo: + <!-- Available Variables channelgroup: {prevAvailable} true if previous Channel Group is avaialble {nextAvailable} true if next Channel Group is avaialble {group} Name of current Channel Group @@ -117,10 +117,6 @@ <signalquality> </signalquality> - <!-- background of signalmeter, will only be drawn if signalquality was deleted --> - <signalqualityback> - </signalqualityback> - <!-- Available Variables devices: signalstrength and -quality are only set if not mode="light" is used in <devices> {numdevices} number of available devices diff --git a/skinskeleton/xmlfiles/displaymenu.xml b/skinskeleton/xmlfiles/displaymenu.xml index 0962e99..2f4193f 100644 --- a/skinskeleton/xmlfiles/displaymenu.xml +++ b/skinskeleton/xmlfiles/displaymenu.xml @@ -96,6 +96,14 @@ --> <colorbuttons> </colorbuttons> + <!-- Available Variables scrollbar: + {height} height of scrollbar in tenth of percent + {offset} offset from top in tenth percent + {hasprev} true if list elements before currently displayed exist + {hasnext} true if list elements after currently displayed exist + --> + <scrollbar> + </scrollbar> &displaymenudefault; &displaymenumain; &displaymenusetup; diff --git a/skinskeleton/xmlfiles/displaymenumain.xml b/skinskeleton/xmlfiles/displaymenumain.xml index 7ba9aee..6124c25 100644 --- a/skinskeleton/xmlfiles/displaymenumain.xml +++ b/skinskeleton/xmlfiles/displaymenumain.xml @@ -21,7 +21,7 @@ </timers> <!-- Available Variables lastrecordings: 10 newest recordings - {numtimers} number of active timers + {numtimers} number of active timers (to align lastrecordings at timers viewelement) {recordings[]} array with 10 newest recordings {recordings[name]} name of recording {recordings[seriesname]} series name if available @@ -109,7 +109,7 @@ {stop} End of current Schedule in hh:mm (empty for recordings) {duration} Duration of current Schedule in min {durationhours} Duration, full hours - {minutes} Duration, rest of minutes + {minutes} Duration, rest in minutes {elapsed} Elapsed time of current Schedule in min (0 for recordings) {remaining} Remaining time of current Schedule in min (0 for recordings) {hasposter} true if poster is available diff --git a/skinskeleton/xmlfiles/displayreplay.xml b/skinskeleton/xmlfiles/displayreplay.xml index 911b6be..908ee0f 100644 --- a/skinskeleton/xmlfiles/displayreplay.xml +++ b/skinskeleton/xmlfiles/displayreplay.xml @@ -23,11 +23,20 @@ <datetime> </datetime> + <!-- Available Variables time: + {sec} current seconds + {min} current minutes + {hour} current hours + {hmins} current "hourminutes" to display an hour hand + --> + <time> + </time> + <!-- Available Variables scrapercontent: {posterpath} Full Path of Poster to use in image path attribute {posterwidth} width of poster in pixel {posterheight} height of poster in pixel - {hasPoster} true if poster is available + {hasposter} true if poster is available {bannerpath} Full Path of banner to use in image path attribute {bannerwidth} width of banner in pixel {bannerheight} height of banner in pixel 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", ¤tWeather)) { - 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 |