diff options
author | louis <louis.braun@gmx.de> | 2014-01-19 13:52:05 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2014-01-19 13:52:05 +0100 |
commit | fcb664da93677cf540d384ee1d377493a2b475ba (patch) | |
tree | 96f13cc83874e74b4d351a66f9ed8e7022e9c8cb /recmanager.c | |
parent | 475964a7810214229c9d60c79e00192fd65eb1a0 (diff) | |
download | vdr-plugin-tvguide-fcb664da93677cf540d384ee1d377493a2b475ba.tar.gz vdr-plugin-tvguide-fcb664da93677cf540d384ee1d377493a2b475ba.tar.bz2 |
Improved favorites menu with whats on now / next and up to four user defined times
Diffstat (limited to 'recmanager.c')
-rw-r--r-- | recmanager.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/recmanager.c b/recmanager.c index 043c6fd..b3b5973 100644 --- a/recmanager.c +++ b/recmanager.c @@ -594,3 +594,99 @@ void cRecManager::GetFavorites(std::vector<cTVGuideSearchTimer> *favorites) { } } + +const cEvent **cRecManager::WhatsOnNow(bool nowOrNext, int &numResults) { + std::vector<const cEvent*> tmpResults; + cSchedulesLock schedulesLock; + const cSchedules *schedules = cSchedules::Schedules(schedulesLock); + const cChannel *startChannel = NULL, *stopChannel = NULL; + if (tvguideConfig.favLimitChannels) { + startChannel = Channels.GetByNumber(tvguideConfig.favStartChannel); + stopChannel = Channels.GetByNumber(tvguideConfig.favStopChannel); + } + if (!startChannel) + startChannel = Channels.First(); + + for (const cChannel *channel = startChannel; channel; channel = Channels.Next(channel)) { + if (channel->GroupSep()) continue; + const cSchedule *Schedule = schedules->GetSchedule(channel); + if (!Schedule) continue; + + const cEvent *event = NULL; + if (nowOrNext) + event = Schedule->GetPresentEvent(); + else + event = Schedule->GetFollowingEvent(); + if (event) { + tmpResults.push_back(event); + } + if (stopChannel && (stopChannel->Number() <= channel->Number())) + break; + } + numResults = tmpResults.size(); + const cEvent **results = new const cEvent *[numResults]; + for (int i=0; i<numResults; i++) { + results[i] = tmpResults[i]; + } + + return results; +} + +const cEvent **cRecManager::UserDefinedTime(int userTime, int &numResults) { + std::vector<const cEvent*> tmpResults; + int favTime = 0; + if (userTime == 1) { + favTime = tvguideConfig.favTime1; + } else if (userTime == 2) { + favTime = tvguideConfig.favTime2; + } else if (userTime == 3) { + favTime = tvguideConfig.favTime3; + } else if (userTime == 4) { + favTime = tvguideConfig.favTime4; + } + + time_t now = time(0); + tm *midn = localtime(&now); + midn->tm_sec = 0; + midn->tm_min = 0; + midn->tm_hour = 0; + time_t midnight = mktime(midn); + int hours = favTime/100; + int mins = favTime - hours * 100; + time_t searchTime = midnight + hours*60*60 + mins*60; + if (searchTime < now) + searchTime += 24*60*60; + + cSchedulesLock schedulesLock; + const cSchedules *schedules = cSchedules::Schedules(schedulesLock); + const cChannel *startChannel = NULL, *stopChannel = NULL; + if (tvguideConfig.favLimitChannels) { + startChannel = Channels.GetByNumber(tvguideConfig.favStartChannel); + stopChannel = Channels.GetByNumber(tvguideConfig.favStopChannel); + } + if (!startChannel) + startChannel = Channels.First(); + + for (const cChannel *channel = startChannel; channel; channel = Channels.Next(channel)) { + if (channel->GroupSep()) continue; + const cSchedule *Schedule = schedules->GetSchedule(channel); + if (!Schedule) continue; + const cEvent *event = Schedule->GetEventAround(searchTime); + if (!event) continue; + //if event is more or less over (only 15mns left), take next + if ((event->EndTime() - searchTime) < 15*60) { + event = Schedule->Events()->Next(event); + } + if (event) + tmpResults.push_back(event); + if (stopChannel && (stopChannel->Number() <= channel->Number())) + break; + } + + numResults = tmpResults.size(); + const cEvent **results = new const cEvent *[numResults]; + for (int i=0; i<numResults; i++) { + results[i] = tmpResults[i]; + } + return results; +} |