Fixed moving currently recording timers between machines

This commit is contained in:
Klaus Schmidinger 2015-09-13 13:57:51 +02:00
parent 2b20b9e064
commit bfc3f1f4b2
5 changed files with 33 additions and 11 deletions

View File

@ -8804,6 +8804,8 @@ Video Disk Recorder Revision History
because cTimer::ToText() is now also needed in a context where the terminating
newline can't be used. Consequently, cChannel::ToText() and cMark::ToText() have
been modified accordingly.
- All timer related response strings from SVDRP commands now use the channel ID
instead of channel numbers.
- The "Edit timer" menu now has a new parameter "Record on", which can be used to
select the VDR on which this timer shall record. Timers can be freely moved
between connected VDRs by simply selecting the desired machine in this field.

22
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.c 4.10 2015/09/13 10:39:02 kls Exp $
* $Id: menu.c 4.11 2015/09/13 13:54:27 kls Exp $
*/
#include "menu.h"
@ -1075,11 +1075,14 @@ bool cMenuEditTimer::HandleRemoteModifications(cTimer *OldTimer, cTimer *NewTime
if (NewTimer->Local()) { // timer stays local, nothing to do
}
else { // timer is moved from local to remote
if (NewTimer->Recording())
NewTimer->SetRecording(false); // in case it was recording on the local machine
if (!ExecSVDRPCommand(NewTimer->Remote(), cString::sprintf("NEWT %s", *NewTimer->ToText(true)), &Response) || SVDRPCode(Response[0]) != 250)
return RemoteTimerError(NewTimer);
int RemoteId = atoi(SVDRPValue(Response[0]));
if (RemoteId <= 0)
return RemoteTimerError(NewTimer);
cRecordControls::Stop(OldTimer);
NewTimer->SetId(RemoteId);
isyslog("moved timer %s to %d@%s", *OldTimer->ToDescr(), NewTimer->Id(), NewTimer->Remote());
}
@ -1090,6 +1093,8 @@ bool cMenuEditTimer::HandleRemoteModifications(cTimer *OldTimer, cTimer *NewTime
return RemoteTimerError(OldTimer);
}
NewTimer->SetId(cTimers::NewTimerId());
if (NewTimer->Recording())
NewTimer->SetRecording(false); // in case it was recording on the remote machine
isyslog("moved timer %d@%s to %s", OldTimer->Id(), OldTimer->Remote(), *NewTimer->ToDescr());
}
else if (strcmp(OldTimer->Remote(), NewTimer->Remote()) == 0) { // timer stays remote on same machine
@ -1109,6 +1114,8 @@ bool cMenuEditTimer::HandleRemoteModifications(cTimer *OldTimer, cTimer *NewTime
}
}
else { // timer is moved from one remote machine to an other
if (NewTimer->Recording())
NewTimer->SetRecording(false); // in case it was recording on the remote machine
if (!ExecSVDRPCommand(NewTimer->Remote(), cString::sprintf("NEWT %s", *NewTimer->ToText(true)), &Response) || SVDRPCode(Response[0]) != 250)
return RemoteTimerError(NewTimer);
int RemoteId = atoi(SVDRPValue(Response[0]));
@ -5250,6 +5257,19 @@ void cRecordControls::Stop(const char *InstantId)
}
}
void cRecordControls::Stop(cTimer *Timer)
{
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
if (RecordControls[i]) {
if (RecordControls[i]->Timer() == Timer) {
DELETENULL(RecordControls[i]);
ChangeState();
break;
}
}
}
}
bool cRecordControls::PauseLiveVideo(void)
{
Skins.Message(mtStatus, tr("Pausing live video..."));

3
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.h 4.2 2015/09/08 14:04:27 kls Exp $
* $Id: menu.h 4.3 2015/09/13 12:27:50 kls Exp $
*/
#ifndef __MENU_H
@ -262,6 +262,7 @@ public:
static bool Start(cTimers *Timers, cTimer *Timer, bool Pause = false);
static bool Start(bool Pause = false);
static void Stop(const char *InstantId);
static void Stop(cTimer *Timer);
static bool PauseLiveVideo(void);
static const char *GetInstantId(const char *LastInstantId);
static cRecordControl *GetRecordControl(const char *FileName);

View File

@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
* $Id: svdrp.c 4.7 2015/09/10 10:39:45 kls Exp $
* $Id: svdrp.c 4.8 2015/09/13 13:57:51 kls Exp $
*/
#include "svdrp.h"
@ -1858,7 +1858,7 @@ void cSVDRPServer::CmdMODT(const char *Option)
*Timer = t;
Timers->SetModified();
isyslog("SVDRP < %s modified timer %s (%s)", *connection, *Timer->ToDescr(), Timer->HasFlags(tfActive) ? "active" : "inactive");
Reply(250, "%d %s", Timer->Id(), *Timer->ToText());
Reply(250, "%d %s", Timer->Id(), *Timer->ToText(true));
}
else
Reply(501, "Timer \"%d\" not defined", Id);
@ -2002,7 +2002,7 @@ void cSVDRPServer::CmdNEWT(const char *Option)
LOCK_TIMERS_WRITE;
Timers->Add(Timer);
isyslog("SVDRP < %s added timer %s", *connection, *Timer->ToDescr());
Reply(250, "%d %s", Timer->Id(), *Timer->ToText());
Reply(250, "%d %s", Timer->Id(), *Timer->ToText(true));
return;
}
else
@ -2261,7 +2261,7 @@ void cSVDRPServer::CmdUPDT(const char *Option)
Timers->Add(Timer);
isyslog("SVDRP < %s added timer %s", *connection, *Timer->ToDescr());
}
Reply(250, "%d %s", Timer->Id(), *Timer->ToText());
Reply(250, "%d %s", Timer->Id(), *Timer->ToText(true));
return;
}
else

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: timers.c 4.4 2015/09/09 10:42:18 kls Exp $
* $Id: timers.c 4.5 2015/09/13 13:10:24 kls Exp $
*/
#include "timers.h"
@ -33,7 +33,7 @@ cTimer::cTimer(bool Instant, bool Pause, const cChannel *Channel)
flags = tfNone;
*file = 0;
aux = NULL;
remote = *Setup.SVDRPDefaultHost ? strdup(Setup.SVDRPDefaultHost) : NULL;
remote = NULL;
event = NULL;
if (Instant)
SetFlags(tfActive | tfInstant);
@ -91,7 +91,7 @@ cTimer::cTimer(const cEvent *Event)
flags = tfActive;
*file = 0;
aux = NULL;
remote = *Setup.SVDRPDefaultHost ? strdup(Setup.SVDRPDefaultHost) : NULL;
remote = NULL;
event = NULL;
if (Event->Vps() && Setup.UseVps)
SetFlags(tfVps);
@ -142,14 +142,13 @@ cTimer& cTimer::operator= (const cTimer &Timer)
{
if (&Timer != this) {
id = Timer.id;
uint OldFlags = flags & tfRecording;
startTime = Timer.startTime;
stopTime = Timer.stopTime;
scheduleState = -1;
deferred = 0;
pending = Timer.pending;
inVpsMargin = Timer.inVpsMargin;
flags = Timer.flags | OldFlags;
flags = Timer.flags;
channel = Timer.channel;
day = Timer.day;
weekdays = Timer.weekdays;