diff options
author | bju <bju@maxi.fritz.box> | 2014-01-11 05:03:11 +0100 |
---|---|---|
committer | bju <bju@maxi.fritz.box> | 2014-01-11 05:03:11 +0100 |
commit | 2676b99b3a7cae3ea8ebe827ac20684a90a84d07 (patch) | |
tree | f9fe3565bba7a77f7e75535ca6516bfd01438aa8 /vdr-vdrmanager/helpers.cpp | |
parent | f8ef6e8fbb2865ce53e3deee6015bef97c6125a1 (diff) | |
download | vdr-manager-2676b99b3a7cae3ea8ebe827ac20684a90a84d07.tar.gz vdr-manager-2676b99b3a7cae3ea8ebe827ac20684a90a84d07.tar.bz2 |
http://projects.vdr-developer.org/issues/1674 (mark conflicting timers in list)
Diffstat (limited to 'vdr-vdrmanager/helpers.cpp')
-rw-r--r-- | vdr-vdrmanager/helpers.cpp | 78 |
1 files changed, 73 insertions, 5 deletions
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 <vdr/cutter.h> #include <vdr/sources.h> #include <fstream> +#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<string> 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<string> 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<string>()); } return result; @@ -1178,3 +1200,49 @@ int cHelpers::ConvertWeekdays(std::string v) { res += 1; return res; } + +set<string> cHelpers::GetTimerConflicts() { + + Epgsearch_services_v1_1 service; + set<string> timers; + if (cPluginManager::CallFirstService(ServiceInterface, &service)) { + cServiceHandler_v1_1* handler = dynamic_cast<cServiceHandler_v1_1*>(service.handler.get()); + if (handler) { + list< string > conflicts = service.handler->TimerConflictList(); + for (list<string>::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; +} |