diff options
| author | louis <louis.braun@gmx.de> | 2015-04-01 10:14:26 +0200 |
|---|---|---|
| committer | louis <louis.braun@gmx.de> | 2015-04-01 10:14:26 +0200 |
| commit | b98fee9668de46a82148bc6c3569e69c8819baed (patch) | |
| tree | ca46242c6c184b66beb0a2e8bd234ae916362cc2 /views | |
| parent | 203754e2047998185a177b177c5c46ccb265318e (diff) | |
| download | vdr-plugin-skindesigner-b98fee9668de46a82148bc6c3569e69c8819baed.tar.gz vdr-plugin-skindesigner-b98fee9668de46a82148bc6c3569e69c8819baed.tar.bz2 | |
use recording info for <currentschedule> viewelement in main menu if recording is replayed
Diffstat (limited to 'views')
| -rw-r--r-- | views/displaymenurootview.c | 3 | ||||
| -rw-r--r-- | views/displaymenurootview.h | 2 | ||||
| -rw-r--r-- | views/displaymenuview.c | 7 | ||||
| -rw-r--r-- | views/displaymenuview.h | 3 | ||||
| -rw-r--r-- | views/displayviewelements.c | 5 | ||||
| -rw-r--r-- | views/displayviewelements.h | 3 | ||||
| -rw-r--r-- | views/viewhelpers.c | 161 | ||||
| -rw-r--r-- | views/viewhelpers.h | 4 |
8 files changed, 146 insertions, 42 deletions
diff --git a/views/displaymenurootview.c b/views/displaymenurootview.c index 3455d09..3a5ee90 100644 --- a/views/displaymenurootview.c +++ b/views/displaymenurootview.c @@ -10,6 +10,7 @@ cDisplayMenuRootView::cDisplayMenuRootView(cTemplateView *rootView) : cView(root sortMode = msmUnknown; sortModeLast = msmUnknown; menuTitle = ""; + currentRecording = ""; viewType = svUndefined; subView = NULL; subViewAvailable = false; @@ -186,7 +187,7 @@ void cDisplayMenuRootView::SetMenu(eMenuCategory menuCat, bool menuInit) { //Create new View switch (newViewType) { case svMenuMain: - view = new cDisplayMenuMainView(subView, menuInit); + view = new cDisplayMenuMainView(subView, menuInit, currentRecording); break; case svMenuSchedules: if (subViewAvailable) diff --git a/views/displaymenurootview.h b/views/displaymenurootview.h index f636d90..3ec009f 100644 --- a/views/displaymenurootview.h +++ b/views/displaymenurootview.h @@ -27,6 +27,7 @@ private: cDisplayMenuView *view; cDisplayMenuListView *listView; cDisplayMenuDetailView *detailView; + string currentRecording; string menuTitle; string buttonTexts[4]; bool defaultBackgroundDrawn; @@ -50,6 +51,7 @@ public: bool createOsd(void); void SetMenu(eMenuCategory menuCat, bool menuInit); void SetSortMode(eMenuSortMode sortMode); + void SetCurrentRecording(string rec) { currentRecording = rec; }; void CorrectDefaultMenu(void); void SetPluginMenu(string name, int menu, int type); void SetTitle(const char *title); diff --git a/views/displaymenuview.c b/views/displaymenuview.c index 88192fa..31b691a 100644 --- a/views/displaymenuview.c +++ b/views/displaymenuview.c @@ -227,7 +227,8 @@ void cDisplayMenuView::Action(void) { * cDisplayMenuMainView ************************************************************************/ -cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit) : cDisplayMenuView(tmplView, menuInit) { +cDisplayMenuMainView::cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording) : cDisplayMenuView(tmplView, menuInit) { + this->currentRecording = currentRecording; initial = true; InitDevices(); } @@ -458,7 +459,7 @@ void cDisplayMenuMainView::DrawCurrentSchedule(void) { if (DetachViewElement(veCurrentSchedule)) { cViewElement *viewElement = GetViewElement(veCurrentSchedule); if (!viewElement) { - viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule)); + viewElement = new cViewElementCurrentSchedule(tmplView->GetViewElement(veCurrentSchedule), currentRecording); AddViewElement(veCurrentSchedule, viewElement); viewElement->Start(); } else { @@ -468,7 +469,7 @@ void cDisplayMenuMainView::DrawCurrentSchedule(void) { } else { map < string, string > stringTokens; map < string, int > intTokens; - SetCurrentSchedule(stringTokens, intTokens); + SetCurrentSchedule(currentRecording, stringTokens, intTokens); ClearViewElement(veCurrentSchedule); DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens); } diff --git a/views/displaymenuview.h b/views/displaymenuview.h index e75973b..d0d4b44 100644 --- a/views/displaymenuview.h +++ b/views/displaymenuview.h @@ -51,6 +51,7 @@ public: class cDisplayMenuMainView : public cDisplayMenuView { private: bool initial; + string currentRecording; void DrawTimers(void); void DrawLastRecordings(void); void DrawDiscUsage(void); @@ -62,7 +63,7 @@ private: void DrawCurrentWeather(void); void DrawCustomTokens(void); public: - cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit); + cDisplayMenuMainView(cTemplateView *tmplView, bool menuInit, string currentRecording); virtual ~cDisplayMenuMainView(); void DrawStaticViewElements(void); bool DrawDynamicViewElements(void); diff --git a/views/displayviewelements.c b/views/displayviewelements.c index 8f2b476..73b4b3b 100644 --- a/views/displayviewelements.c +++ b/views/displayviewelements.c @@ -212,12 +212,13 @@ bool cViewElementTemperature::Render(void) { /********************************************************************************************************************/ -cViewElementCurrentSchedule::cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement) : cViewElement(tmplViewElement) { +cViewElementCurrentSchedule::cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement, string currentRecording) : cViewElement(tmplViewElement) { + this->currentRecording = currentRecording; } bool cViewElementCurrentSchedule::Render(void) { ClearTokens(); - SetCurrentSchedule(stringTokens, intTokens); + SetCurrentSchedule(currentRecording, stringTokens, intTokens); ClearViewElement(veCurrentSchedule); DrawViewElement(veCurrentSchedule, &stringTokens, &intTokens); return true; diff --git a/views/displayviewelements.h b/views/displayviewelements.h index 5ccf2d9..500be9e 100644 --- a/views/displayviewelements.h +++ b/views/displayviewelements.h @@ -120,8 +120,9 @@ public: class cViewElementCurrentSchedule : public cViewElement, public cViewHelpers { private: + string currentRecording; public: - cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement); + cViewElementCurrentSchedule(cTemplateViewElement *tmplViewElement, string currentRecording); virtual ~cViewElementCurrentSchedule() {}; bool Render(void); }; diff --git a/views/viewhelpers.c b/views/viewhelpers.c index a41c71c..9ad437b 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -801,15 +801,62 @@ bool cViewHelpers::SetSystemTemperatures(map < string, string > &stringTokens, m return true; } -void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map < string, int > &intTokens) { +void cViewHelpers::SetCurrentSchedule(string recName, map < string, string > &stringTokens, map < string, int > &intTokens) { cDevice *device = cDevice::PrimaryDevice(); const cChannel *channel = NULL; if (!device->Replaying() || device->Transferring()) { channel = Channels.GetByNumber(device->CurrentChannel()); } - if (!channel) + 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; + } + } +} + +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, map < string, string > &stringTokens, map < string, int > &intTokens) { const cEvent *event = NULL; cSchedulesLock SchedulesLock; if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock)) @@ -818,6 +865,7 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map 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())); @@ -888,39 +936,86 @@ void cViewHelpers::SetCurrentSchedule(map < string, string > &stringTokens, map intTokens.insert(pair<string,int>("hasbanner", hasBanner)); } -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; +void cViewHelpers::SetCurrentScheduleFromRecording(const cRecording *recording, map < string, string > &stringTokens, map < string, int > &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)); } - folder = folder.substr(delim2+1); -} + 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)); -void cViewHelpers::RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster) { + 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) - 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; + 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)); } - diff --git a/views/viewhelpers.h b/views/viewhelpers.h index 1223a78..3e8fb1d 100644 --- a/views/viewhelpers.h +++ b/views/viewhelpers.h @@ -17,6 +17,8 @@ private: int lastMemUsage; 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, map < string, string > &stringTokens, map < string, int > &intTokens); + void SetCurrentScheduleFromRecording(const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens); protected: void InitDevices(void); bool SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices); @@ -34,7 +36,7 @@ protected: bool SetSystemLoad(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetSystemMemory(map < string, string > &stringTokens, map < string, int > &intTokens); bool SetSystemTemperatures(map < string, string > &stringTokens, map < string, int > &intTokens); - void SetCurrentSchedule(map < string, string > &stringTokens, map < string, int > &intTokens); + void SetCurrentSchedule(string recName, map < string, string > &stringTokens, map < string, int > &intTokens); public: cViewHelpers(void); virtual ~cViewHelpers(void); |
