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/.cproject | 19 +++++++++++ vdr-vdrmanager/helpers.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++--- vdr-vdrmanager/helpers.h | 7 +++-- 3 files changed, 96 insertions(+), 8 deletions(-) (limited to 'vdr-vdrmanager') diff --git a/vdr-vdrmanager/.cproject b/vdr-vdrmanager/.cproject index ea9fb6f..27812e3 100644 --- a/vdr-vdrmanager/.cproject +++ b/vdr-vdrmanager/.cproject @@ -24,10 +24,22 @@ + @@ -38,6 +50,13 @@ + 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; +} diff --git a/vdr-vdrmanager/helpers.h b/vdr-vdrmanager/helpers.h index 18576be..d6e2a14 100644 --- a/vdr-vdrmanager/helpers.h +++ b/vdr-vdrmanager/helpers.h @@ -12,6 +12,7 @@ #include #include #include +#include using namespace std; @@ -36,7 +37,7 @@ private: static string SafeCall(string (*)()); static string SafeCall(string (*)(string), string arg); static string SafeCall(string (*)(string, string), string arg1, string arg2); - static string GetTimersIntern(); + static string GetTimersIntern(string options); static string GetRecordingsIntern(); static string GetChannelsIntern(string wantedChannels); static string SetChannelIntern(string wantedChannel); @@ -51,7 +52,7 @@ private: static string MapSpecialChars(const cString text); static string MapSpecialChars(const string text); static string ToText(const cEvent * event); - static string ToText(cTimer * timer); + static string ToText(cTimer * timer, set conflicts); static string ToText(cRecording * recording); static string GetAudioTracks(const cChannel* channel); static string replaceAll(const string& where, const string& what, const string& replacement); @@ -63,5 +64,5 @@ private: static int ConvertWeekdays(string v); static queue ConvertToBinary(int v); static string DelRecording(cRecording * r); - + static set GetTimerConflicts(); }; -- cgit v1.2.3