diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2018-02-25 13:26:17 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2018-02-25 13:26:17 +0100 |
commit | 6600478675add5e26e8af97c8de8b972a0cc1230 (patch) | |
tree | b4b639951b5b628fa857e650b6976c33ca700a26 /timers.c | |
parent | bbbc36a1e63b39db9fb985e9b5c5a4a24ea2f4a2 (diff) | |
download | vdr-6600478675add5e26e8af97c8de8b972a0cc1230.tar.gz vdr-6600478675add5e26e8af97c8de8b972a0cc1230.tar.bz2 |
Moved handling remote timers into cSVDRPClientHandler::ProcessConnections()
Diffstat (limited to 'timers.c')
-rw-r--r-- | timers.c | 94 |
1 files changed, 32 insertions, 62 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.c 4.14 2017/11/12 13:01:22 kls Exp $ + * $Id: timers.c 4.15 2018/02/25 13:05:03 kls Exp $ */ #include "timers.h" @@ -898,78 +898,48 @@ bool cTimers::DeleteExpired(void) return TimersModified; } -bool cTimers::GetRemoteTimers(const char *ServerName) +bool cTimers::StoreRemoteTimers(const char *ServerName, const cStringList *RemoteTimers) { + //TODO handle only new/deleted/modified timers? bool Result = false; - if (ServerName) { - Result = DelRemoteTimers(ServerName); - cStringList Response; - if (ExecSVDRPCommand(ServerName, "LSTT ID", &Response)) { - for (int i = 0; i < Response.Size(); i++) { - const char *s = Response[i]; - int Code = SVDRPCode(s); - if (Code == 250) { - if (const char *v = SVDRPValue(s)) { - int Id = atoi(v); - while (*v && *v != ' ') - v++; // skip id - cTimer *Timer = new cTimer; - if (Timer->Parse(v)) { - Timer->SetRemote(ServerName); - Timer->SetId(Id); - Add(Timer); - Result = true; - } - else { - esyslog("ERROR: %s: error in timer settings: %s", ServerName, v); - delete Timer; - } - } - } - else if (Code != 550) - esyslog("ERROR: %s: %s", ServerName, s); - } - return Result; - } - } - else { - cStringList ServerNames; - if (GetSVDRPServerNames(&ServerNames, sffTimers)) { - for (int i = 0; i < ServerNames.Size(); i++) - Result |= GetRemoteTimers(ServerNames[i]); - } - } - return Result; -} - -bool cTimers::DelRemoteTimers(const char *ServerName) -{ - bool Deleted = false; + // Delete old remote timers: cTimer *Timer = First(); while (Timer) { cTimer *t = Next(Timer); if (Timer->Remote() && (!ServerName || strcmp(Timer->Remote(), ServerName) == 0)) { Del(Timer); - Deleted = true; + Result = true; } Timer = t; } - return Deleted; -} - -void cTimers::TriggerRemoteTimerPoll(const char *ServerName) -{ - if (ServerName) { - if (!ExecSVDRPCommand(ServerName, cString::sprintf("POLL %s TIMERS", Setup.SVDRPHostName))) - esyslog("ERROR: can't send 'POLL %s TIMERS' to '%s'", Setup.SVDRPHostName, ServerName); - } - else { - cStringList ServerNames; - if (GetSVDRPServerNames(&ServerNames)) { - for (int i = 0; i < ServerNames.Size(); i++) - TriggerRemoteTimerPoll(ServerNames[i]); - } + // Add new remote timers: + if (ServerName && RemoteTimers) { + for (int i = 0; i < RemoteTimers->Size(); i++) { + const char *s = (*RemoteTimers)[i]; + int Code = SVDRPCode(s); + if (Code == 250) { + if (const char *v = SVDRPValue(s)) { + int Id = atoi(v); + while (*v && *v != ' ') + v++; // skip id + cTimer *Timer = new cTimer; + if (Timer->Parse(v)) { + Timer->SetRemote(ServerName); + Timer->SetId(Id); + Add(Timer); + Result = true; + } + else { + esyslog("ERROR: %s: error in timer settings: %s", ServerName, v); + delete Timer; + } + } + } + else if (Code != 550) + esyslog("ERROR: %s: %s", ServerName, s); + } } + return Result; } static bool RemoteTimerError(const cTimer *Timer, cString *Msg) |