Permalink
Browse files

Services: Add UnDeleteRecording() method. Name may be subject to change.

  • Loading branch information...
1 parent 58c98b8 commit c05d238ebcd28505bb52e07d7f6ffb9248674ef6 @stuartm stuartm committed Nov 4, 2013
@@ -40,7 +40,7 @@
class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ???
{
Q_OBJECT
- Q_CLASSINFO( "version" , "2.0" );
+ Q_CLASSINFO( "version" , "2.1" );
Q_CLASSINFO( "RemoveRecordedItem_Method", "POST" )
Q_CLASSINFO( "AddRecordSchedule_Method", "POST" )
Q_CLASSINFO( "RemoveRecordSchedule_Method", "POST" )
@@ -81,6 +81,14 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ???
bool ForceDelete,
bool AllowRerecord ) = 0;
+ virtual bool DeleteRecording ( int ChanId,
+ const QDateTime &StartTime,
+ bool ForceDelete,
+ bool AllowRerecord ) = 0;
+
+ virtual bool UnDeleteRecording ( int ChanId,
+ const QDateTime &StartTime ) = 0;
+
virtual DTC::ProgramList* GetConflictList ( int StartIndex,
int Count ) = 0;
@@ -1085,6 +1085,37 @@ void MainServer::customEvent(QEvent *e)
return;
}
+ if (me->Message().startsWith("UNDELETE_RECORDING"))
+ {
+ QStringList tokens = me->Message().split(" ",
+ QString::SkipEmptyParts);
+
+
+ if (tokens.size() < 3 || tokens.size() > 3)
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("Bad UNDELETE_RECORDING message: %1")
+ .arg(me->Message()));
+ return;
+ }
+
+ QDateTime startts = MythDate::fromString(tokens[2]);
+ RecordingInfo recInfo(tokens[1].toUInt(), startts);
+
+ if (recInfo.GetChanID())
+ {
+ DoHandleUndeleteRecording(recInfo, NULL);
+ }
+ else
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("Cannot find program info for '%1' while "
+ "attempting to undelete.").arg(me->Message()));
+ }
+
+ return;
+ }
+
if (me->Message().startsWith("RESCHEDULE_RECORDINGS") && m_sched)
{
QStringList request = me->ExtraDataList();
@@ -151,6 +151,13 @@ DTC::Program* Dvr::GetRecorded(int chanid, const QDateTime &recstarttsRaw)
bool Dvr::RemoveRecorded(int chanid, const QDateTime &recstarttsRaw,
bool forceDelete, bool allowRerecord)
{
+ return DeleteRecording(chanid, recstarttsRaw, forceDelete, allowRerecord);
+}
+
+
+bool Dvr::DeleteRecording(int chanid, const QDateTime &recstarttsRaw,
+ bool forceDelete, bool allowRerecord)
+{
if (chanid <= 0 || !recstarttsRaw.isValid())
throw QString("Channel ID or StartTime appears invalid.");
@@ -176,6 +183,31 @@ bool Dvr::RemoveRecorded(int chanid, const QDateTime &recstarttsRaw,
//
/////////////////////////////////////////////////////////////////////////////
+bool Dvr::UnDeleteRecording(int chanid, const QDateTime &recstarttsRaw)
+{
+ if (chanid <= 0 || !recstarttsRaw.isValid())
+ throw QString("Channel ID or StartTime appears invalid.");
+
+ RecordingInfo ri(chanid, recstarttsRaw.toUTC());
+
+ if (ri.GetChanID() && ri.HasPathname())
+ {
+ QString cmd = QString("UNDELETE_RECORDING %1 %2")
+ .arg(ri.GetChanID())
+ .arg(ri.GetRecordingStartTime(MythDate::ISODate));
+ MythEvent me(cmd);
+
+ gCoreContext->dispatch(me);
+ return true;
+ }
+
+ return false;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+/////////////////////////////////////////////////////////////////////////////
+
DTC::ProgramList* Dvr::GetExpiringList( int nStartIndex,
int nCount )
{
@@ -59,6 +59,14 @@ class Dvr : public DvrServices
bool ForceDelete,
bool AllowRerecord );
+ bool DeleteRecording ( int ChanId,
+ const QDateTime &StartTime,
+ bool ForceDelete,
+ bool AllowRerecord );
+
+ bool UnDeleteRecording ( int ChanId,
+ const QDateTime &StartTime );
+
DTC::ProgramList* GetConflictList ( int StartIndex,
int Count );
@@ -240,6 +248,21 @@ class ScriptableDvr : public QObject
ForceDelete, AllowRerecord);
}
+ bool DeleteRecording ( int ChanId,
+ const QDateTime &StartTime,
+ bool ForceDelete,
+ bool AllowRerecord )
+ {
+ return m_obj.DeleteRecording(ChanId, StartTime,
+ ForceDelete, AllowRerecord);
+ }
+
+ bool UnDeleteRecording ( int ChanId,
+ const QDateTime &StartTime )
+ {
+ return m_obj.UnDeleteRecording(ChanId, StartTime);
+ }
+
QObject* GetConflictList ( int StartIndex,
int Count )
{

0 comments on commit c05d238

Please sign in to comment.