From 2676b99b3a7cae3ea8ebe827ac20684a90a84d07 Mon Sep 17 00:00:00 2001 From: bju Date: Sat, 11 Jan 2014 05:03:11 +0100 Subject: http://projects.vdr-developer.org/issues/1674 (mark conflicting timers in list) --- vdr-vdrmanager/helpers.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 5 deletions(-) (limited to 'vdr-vdrmanager/helpers.cpp') diff --git a/vdr-vdrmanager/helpers.cpp b/vdr-vdrmanager/helpers.cpp index 57dab9b..108ca85 100644 --- a/vdr-vdrmanager/helpers.cpp +++ b/vdr-vdrmanager/helpers.cpp @@ -18,18 +18,21 @@ #include #include #include +#include "epgsearch/services.h" #define TIMER_SEP "#|#|#" // Taken from vdr-ive #define INDEXFILESUFFIX "/index.vdr" #define LENGTHFILESUFFIX "/length.vdr" +static char ServiceInterface[] = "Epgsearch-services-v1.1"; + string cHelpers::GetRecordings(string args) { return SafeCall(GetRecordingsIntern); } string cHelpers::GetTimers(string args) { - return SafeCall(GetTimersIntern); + return SafeCall(GetTimersIntern, args); } string cHelpers::GetChannels(string args) { @@ -86,13 +89,22 @@ string cHelpers::SearchEvents(string args) { return SafeCall(SearchEventsIntern, Trim(wantedChannels), Trim(pattern)); } -string cHelpers::GetTimersIntern() { +string cHelpers::GetTimersIntern(string options) { + + // timer conflicts wanted? + set conflicts; + if (options.find("conflicts") != string::npos) { + conflicts = GetTimerConflicts(); + if (conflicts.empty()) { + conflicts.insert(""); + } + } string result = "START\r\n"; // iterate through all timers for (cTimer * timer = Timers.First(); timer; timer = Timers.Next(timer)) { - result += ToText(timer); + result += ToText(timer, conflicts); } return result + "END\r\n"; @@ -740,7 +752,7 @@ string cHelpers::ToText(cRecording * recording) { return result; } -string cHelpers::ToText(cTimer * timer) { +string cHelpers::ToText(cTimer * timer, set conflicts) { const cChannel * channel = timer->Channel(); const char * channelName = channel->Name(); @@ -835,6 +847,16 @@ string cHelpers::ToText(cTimer * timer) { result += ConvertWeekdays(timer->WeekDays()); + if (!conflicts.empty()) { + ostringstream index; + index << timer->Index()+1; + if (conflicts.find(index.str()) != conflicts.end()) { + result += ":1"; + } else { + result += ":0"; + } + } + result += "\r\n"; return result; @@ -900,7 +922,7 @@ string cHelpers::ToText(const cEvent * event) { result += "\r\n"; if (eventTimer) { - result += ToText(eventTimer); + result += ToText(eventTimer, set()); } return result; @@ -1178,3 +1200,49 @@ int cHelpers::ConvertWeekdays(std::string v) { res += 1; return res; } + +set cHelpers::GetTimerConflicts() { + + Epgsearch_services_v1_1 service; + set timers; + if (cPluginManager::CallFirstService(ServiceInterface, &service)) { + cServiceHandler_v1_1* handler = dynamic_cast(service.handler.get()); + if (handler) { + list< string > conflicts = service.handler->TimerConflictList(); + for (list::iterator it = conflicts.begin(); it != conflicts.end(); it++) { + string line = *it; + size_t sep = line.find(':'); + line = line.substr(sep+1); + + while (!line.empty()) { + sep = line.find(':'); + string conflict; + if (sep == string::npos) { + conflict = line; + line = ""; + } else { + conflict = line.substr(0, sep); + line = line.substr(sep+1); + } + + sep = conflict.rfind('|'); + conflict = conflict.substr(sep+1); + while(!conflict.empty()) { + sep = conflict.find('#'); + string timer; + if (sep == string::npos) { + timer = conflict; + conflict = ""; + } else { + timer = conflict.substr(0, sep); + conflict = conflict.substr(sep+1); + } + timers.insert(timer); + } + } + } + } + } + + return timers; +} -- cgit v1.2.3