diff options
author | lado <herrlado@gmail.com> | 2011-10-20 04:02:38 +0200 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2011-10-20 04:02:38 +0200 |
commit | 7f28775e74babd24aba04fc3f5cf2f0e118d2ad5 (patch) | |
tree | af5a6c5d65ddf1815153754de658eb93299afe03 | |
parent | 2d2b88862e96220a4a7befa5fa5fae8909857e1d (diff) | |
download | vdr-manager-7f28775e74babd24aba04fc3f5cf2f0e118d2ad5.tar.gz vdr-manager-7f28775e74babd24aba04fc3f5cf2f0e118d2ad5.tar.bz2 |
better handling of timer commands, now with own C D M commands. Old impl had bug with -0
-rw-r--r-- | vdr-vdrmanager/helpers.cpp | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/vdr-vdrmanager/helpers.cpp b/vdr-vdrmanager/helpers.cpp index 63f2ac9..1b7b548 100644 --- a/vdr-vdrmanager/helpers.cpp +++ b/vdr-vdrmanager/helpers.cpp @@ -177,38 +177,48 @@ string cHelpers::SetTimerIntern(string args) { // separete timer number size_t sep = args.find(':'); if (sep == string::npos) { - return "!ERROR\r\n"; - } - int number = atoi(args.c_str()); - bool delTimer = number < 0; - if (delTimer) { - number = -number; + return "!ERROR:no separator found\r\n"; } - string params = args.substr(sep+1); + + char c = args[0]; + string numberstr = args.substr(sep-1,1); + + int number = atoi(numberstr.c_str()); + + string params = args.substr(sep+1); + + // parse timer cTimer * timer = new cTimer; if (!timer->Parse(params.c_str())) { delete timer; - return "!ERROR\r\n"; + return "!ERROR:can not parse params '"+params+"'\r\n"; } - - if (!number) { - // new timer + + cTimer * oldTimer; + switch(c){ + case 'C': // new timer + case 'c': Timers.Add(timer); - } else { - // modify timer + break; + case 'D': + case 'd': + // delete timer delete timer; - cTimer * oldTimer = Timers.Get(number); - if (!oldTimer) { - return "!ERROR\r\n"; - } - if (delTimer) { - Timers.Del(oldTimer, true); - } else { - oldTimer->Parse(params.c_str()); - } + oldTimer = Timers.Get(number); + Timers.Del(oldTimer, true); + break; + case 'M': + case 'm': + // modify + oldTimer = Timers.Get(number); + oldTimer->Parse(params.c_str()); + break; + default: + return "!ERROR:unknown timer command\r\n"; } + Timers.Save(); return "START\r\nEND\r\n"; @@ -314,7 +324,10 @@ string cHelpers::ToText(cTimer * timer) { const cList<cEvent> * events = schedule->Events(); cEvent * match = NULL; for(cEvent * event = events->First(); event; event = events->Next(event)) { - if (IsWantedTime(timer->StartTime(), event)) { + + time_t startTime = event->StartTime(); + time_t stopTime = startTime + event->Duration(); + if(startTime <= timer->StartTime() && timer->StopTime() >= stopTime){ match = event; break; } @@ -348,7 +361,7 @@ string cHelpers::ToText(cTimer * timer) { result += MapSpecialChars(timer->File()); result += ":"; result += MapSpecialChars(timer->Aux() ? timer->Aux() : ""); - if(match){ + if(match && false){ result += ":"; result += MapSpecialChars(match->ShortText() ? match->ShortText() : ""); result += ":"; |