diff options
author | lado <herrlado@gmail.com> | 2011-10-20 04:03:16 +0200 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2011-10-20 04:03:16 +0200 |
commit | 0342f25d24a2a2534c26e7588aac6eba00d0950a (patch) | |
tree | 7c53dd8db7bfed6eccfc8862c9ef4fdd471131e8 /vdr-vdrmanager/helpers.cpp | |
parent | dc30d3e986f31046779b00d56514a02a268a645d (diff) | |
parent | 7f28775e74babd24aba04fc3f5cf2f0e118d2ad5 (diff) | |
download | vdr-manager-0342f25d24a2a2534c26e7588aac6eba00d0950a.tar.gz vdr-manager-0342f25d24a2a2534c26e7588aac6eba00d0950a.tar.bz2 |
Merge branch 'master' of ssh://projects.vdr-developer.org/vdr-manager
Diffstat (limited to 'vdr-vdrmanager/helpers.cpp')
-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 += ":"; |