From 2865936d776f42759e2b41ed152126b0b264eb32 Mon Sep 17 00:00:00 2001 From: David Engel Date: Wed, 1 May 2013 09:16:07 -0500 Subject: [PATCH] Rework recording rule handling in services API. Thanks to tafy/dev-team%40tikinou.com providing the initial patch and testing the end result. The existing AddRecordSchedule() and new UpdateRecordSchedule() calls essentially take complete, fully-specified rules and sanity check them before saving. AddRecordSchedule() is used to add new rules and UpdateRecordSchedule() is used to update existing rules. GetRecordSchedule() is changed to conveniently provide rules suitable for later calls to AddRecordSchedule() and UpdateRecordSchedule(). When given a valid RecordId, GetRecordSchedule() returns that rule. When given a Template name, GetRecordSchedule() returns an empty rule initialized with that template. When given a ChanId and StartTime, GetRecordSchedule() returns the rule for that program or a new one if no rule currently exists. If the MakeOverride parameter is true, the returned rule for the program will converted to an override rule if needed. Clients should always call GetRecordSchedule() with the appropriate parameters before modifying the rule and then calling AddRecordSchedule() or UpdateRecordSchedule(). In this way, clients do not need to know all of the details on how to initialize rules or update them for specific programs. Fixes #11495 --- mythtv/libs/libmythbase/mythversion.h | 2 +- .../datacontracts/recRule.h | 21 +- .../services/dvrServices.h | 64 +++- mythtv/libs/libmythtv/recordingrule.cpp | 176 ++++++++++ mythtv/libs/libmythtv/recordingrule.h | 2 + mythtv/programs/mythbackend/services/dvr.cpp | 303 +++++++++++++++--- mythtv/programs/mythbackend/services/dvr.h | 61 +++- .../mythbackend/services/serviceUtil.cpp | 5 +- 8 files changed, 564 insertions(+), 70 deletions(-) diff --git a/mythtv/libs/libmythbase/mythversion.h b/mythtv/libs/libmythbase/mythversion.h index 9ce25c3fcca..498b87076f7 100644 --- a/mythtv/libs/libmythbase/mythversion.h +++ b/mythtv/libs/libmythbase/mythversion.h @@ -12,7 +12,7 @@ /// Update this whenever the plug-in ABI changes. /// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and /// libmythui class methods in exported headers. -#define MYTH_BINARY_VERSION "0.27.20130426-1" +#define MYTH_BINARY_VERSION "0.27.20130430-1" /** \brief Increment this whenever the MythTV network protocol changes. * diff --git a/mythtv/libs/libmythservicecontracts/datacontracts/recRule.h b/mythtv/libs/libmythservicecontracts/datacontracts/recRule.h index 7626607560c..820cfc8f17f 100644 --- a/mythtv/libs/libmythservicecontracts/datacontracts/recRule.h +++ b/mythtv/libs/libmythservicecontracts/datacontracts/recRule.h @@ -15,7 +15,7 @@ namespace DTC class SERVICE_PUBLIC RecRule : public QObject { Q_OBJECT - Q_CLASSINFO( "version" , "1.10" ); + Q_CLASSINFO( "version" , "1.11" ); Q_PROPERTY( int Id READ Id WRITE setId ) Q_PROPERTY( int ParentId READ ParentId WRITE setParentId ) @@ -36,10 +36,8 @@ class SERVICE_PUBLIC RecRule : public QObject Q_PROPERTY( int ChanId READ ChanId WRITE setChanId ) Q_PROPERTY( QString CallSign READ CallSign WRITE setCallSign ) - Q_PROPERTY( int Day READ Day WRITE setDay ) - Q_PROPERTY( QTime Time READ Time WRITE setTime ) - Q_PROPERTY( int FindId READ FindId WRITE setFindId ) - + Q_PROPERTY( int FindDay READ FindDay WRITE setFindDay ) + Q_PROPERTY( QTime FindTime READ FindTime WRITE setFindTime ) Q_PROPERTY( QString Type READ Type WRITE setType ) Q_PROPERTY( QString SearchType READ SearchType WRITE setSearchType ) Q_PROPERTY( int RecPriority READ RecPriority WRITE setRecPriority ) @@ -89,9 +87,8 @@ class SERVICE_PUBLIC RecRule : public QObject PROPERTYIMP ( QString , Inetref ) PROPERTYIMP ( int , ChanId ) PROPERTYIMP ( QString , CallSign ) - PROPERTYIMP ( int , Day ) - PROPERTYIMP ( QTime , Time ) - PROPERTYIMP ( int , FindId ) + PROPERTYIMP ( int , FindDay ) + PROPERTYIMP ( QTime , FindTime ) PROPERTYIMP ( QString , Type ) PROPERTYIMP ( QString , SearchType ) PROPERTYIMP ( int , RecPriority ) @@ -135,8 +132,7 @@ class SERVICE_PUBLIC RecRule : public QObject m_Season ( 0 ), m_Episode ( 0 ), m_ChanId ( 0 ), - m_Day ( 0 ), - m_FindId ( 0 ), + m_FindDay ( 0 ), m_RecPriority ( 0 ), m_PreferredInput( 0 ), m_StartOffset ( 0 ), @@ -180,9 +176,8 @@ class SERVICE_PUBLIC RecRule : public QObject m_Inetref = src.m_Inetref ; m_ChanId = src.m_ChanId ; m_CallSign = src.m_CallSign ; - m_Day = src.m_Day ; - m_Time = src.m_Time ; - m_FindId = src.m_FindId ; + m_FindDay = src.m_FindDay ; + m_FindTime = src.m_FindTime ; m_Type = src.m_Type ; m_SearchType = src.m_SearchType ; m_RecPriority = src.m_RecPriority ; diff --git a/mythtv/libs/libmythservicecontracts/services/dvrServices.h b/mythtv/libs/libmythservicecontracts/services/dvrServices.h index d6803755802..e97cb88f0af 100644 --- a/mythtv/libs/libmythservicecontracts/services/dvrServices.h +++ b/mythtv/libs/libmythservicecontracts/services/dvrServices.h @@ -38,12 +38,13 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ??? { Q_OBJECT - Q_CLASSINFO( "version" , "1.6" ); + Q_CLASSINFO( "version" , "1.7" ); Q_CLASSINFO( "RemoveRecordedItem_Method", "POST" ) Q_CLASSINFO( "AddRecordSchedule_Method", "POST" ) Q_CLASSINFO( "RemoveRecordSchedule_Method", "POST" ) Q_CLASSINFO( "EnableRecordSchedule_Method", "POST" ) Q_CLASSINFO( "DisableRecordSchedule_Method", "POST" ) + Q_CLASSINFO( "UpdateRecordSchedule_Method", "POST" ) public: @@ -94,14 +95,65 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ??? // Recording Rules - virtual int AddRecordSchedule ( int ChanId, + virtual int AddRecordSchedule ( QString Title, + QString Subtitle, + QString Description, + QString Category, QDateTime StartTime, + QDateTime EndTime, + QString SeriesId, + QString ProgramId, + int ChanId, + QString Station, + int FindDay, + QTime FindTime, int ParentId, bool Inactive, uint Season, uint Episode, QString Inetref, - int FindId, + QString Type, + QString SearchType, + int RecPriority, + uint PreferredInput, + int StartOffset, + int EndOffset, + QString DupMethod, + QString DupIn, + uint Filter, + QString RecProfile, + QString RecGroup, + QString StorageGroup, + QString PlayGroup, + bool AutoExpire, + int MaxEpisodes, + bool MaxNewest, + bool AutoCommflag, + bool AutoTranscode, + bool AutoMetaLookup, + bool AutoUserJob1, + bool AutoUserJob2, + bool AutoUserJob3, + bool AutoUserJob4, + int Transcoder ) = 0; + + virtual bool UpdateRecordSchedule ( int RecordId, + QString Title, + QString Subtitle, + QString Description, + QString Category, + QDateTime StartTime, + QDateTime EndTime, + QString SeriesId, + QString ProgramId, + int ChanId, + QString Station, + int FindDay, + QTime FindTime, + bool Inactive, + uint Season, + uint Episode, + QString Inetref, QString Type, QString SearchType, int RecPriority, @@ -132,7 +184,11 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ??? virtual DTC::RecRuleList* GetRecordScheduleList ( int StartIndex, int Count ) = 0; - virtual DTC::RecRule* GetRecordSchedule ( uint RecordId ) = 0; + virtual DTC::RecRule* GetRecordSchedule ( uint RecordId, + QString Template, + int ChanId, + QDateTime StartTime, + bool MakeOverride ) = 0; virtual bool EnableRecordSchedule ( uint RecordId ) = 0; diff --git a/mythtv/libs/libmythtv/recordingrule.cpp b/mythtv/libs/libmythtv/recordingrule.cpp index 3bb1163c4df..ead947ef012 100644 --- a/mythtv/libs/libmythtv/recordingrule.cpp +++ b/mythtv/libs/libmythtv/recordingrule.cpp @@ -812,3 +812,179 @@ QStringList RecordingRule::GetTemplateNames(void) return result; } + +bool RecordingRule::IsValid(QString &msg) +{ + bool isOverride = false; + switch (m_type) + { + case kSingleRecord: + case kDailyRecord: + case kAllRecord: + case kWeeklyRecord: + case kOneRecord: + case kTemplateRecord: + break; + case kOverrideRecord: + case kDontRecord: + isOverride = true; + case kNotRecording: + default: + msg = QString("Invalid recording type."); + return false; + } + + bool isNormal = false; + bool isSearch = false; + bool isManual = false; + switch (m_searchType) + { + case kNoSearch: + isNormal = true; + break; + case kPowerSearch: + case kTitleSearch: + case kKeywordSearch: + case kPeopleSearch: + isSearch = true; + break; + case kManualSearch: + isManual = true; + break; + default: + msg = QString("Invalid search type."); + return false; + } + + if ((isNormal && (m_type == kDailyRecord || m_type == kWeeklyRecord)) || + (isSearch && (m_type != kDailyRecord && m_type != kWeeklyRecord && + m_type != kOneRecord && m_type != kAllRecord)) || + (isManual && (m_type != kDailyRecord && m_type != kWeeklyRecord && + m_type != kSingleRecord && m_type != kAllRecord))) + { + msg = QString("Invalid recording type/search type."); + return false; + } + + if ((m_parentRecID && !isOverride) || + (!m_parentRecID && isOverride)) + { + msg = QString("Invalid parentID/override."); + return false; + } + + if (m_title.isEmpty()) + { + msg = QString("Invalid title."); + return false; + } + + if (m_searchType == kPowerSearch) + { + MSqlQuery query(MSqlQuery::InitCon()); + query.prepare(QString("SELECT NULL FROM (program, channel) " + "%1 WHERE %2") + .arg(m_subtitle).arg(m_description)); + if (m_description.contains(';') || !query.exec()) + { + msg = QString("Invalid custom search values."); + return false; + } + } + else if (isSearch) + { + if (m_description.isEmpty()) + { + msg = QString("Invalid search value."); + return false; + } + } + + if (!isSearch) + { + if (!m_startdate.isValid() || !m_starttime.isValid() || + !m_enddate.isValid() || !m_endtime.isValid()) + { + msg = QString("Invalid start/end date/time."); + return false; + } + int secsto = QDateTime(m_startdate, m_starttime) + .secsTo(QDateTime(m_enddate, m_endtime)); + if (secsto <= 0 || secsto > (8 * 3600)) + { + msg = QString("Invalid duration."); + return false; + } + + if (!m_channelid || m_station.isEmpty()) + { + msg = QString("Invalid channel."); + return false; + } + } + + if (m_findday < 0 || m_findday > 6 || !m_findtime.isValid()) + { + msg = QString("Invalid find values."); + return false; + } + + if (m_recPriority < -99 || m_recPriority > 99) + { + msg = QString("Invalid priority."); + return false; + } + + if (m_startOffset < -480 || m_startOffset > 480 || + m_endOffset < -480 || m_endOffset > 480) + { + msg = QString("Invalid start/end offset."); + return false; + } + + if (m_prefInput < 0) + { + msg = QString("Invalid preferred input."); + return false; + } + + if (m_filter & (~0 << kNumFilters)) + { + msg = QString("Invalid filter value."); + return false; + } + + if (m_recProfile.isEmpty() || m_recGroup.isEmpty() || + m_storageGroup.isEmpty() || m_playGroup.isEmpty()) + { + msg = QString("Invalid group value."); + return false; + } + + if (m_maxEpisodes < 0) + { + msg = QString("Invalid max episodes value."); + return false; + } + + if (m_dupIn & ~(kDupsInAll | kDupsNewEpi)) + { + msg = QString("Invalid duplicate scope."); + return false; + } + + if (m_dupMethod & ~(kDupCheckNone | kDupCheckSub | + kDupCheckDesc | kDupCheckSubThenDesc)) + { + msg = QString("Invalid duplicate method."); + return false; + } + + if (m_transcoder < 0) + { + msg = QString("Invalid transcoder value."); + return false; + } + + return true; +} diff --git a/mythtv/libs/libmythtv/recordingrule.h b/mythtv/libs/libmythtv/recordingrule.h index 176b17262c1..b45e3c62206 100644 --- a/mythtv/libs/libmythtv/recordingrule.h +++ b/mythtv/libs/libmythtv/recordingrule.h @@ -59,6 +59,8 @@ class MTV_PUBLIC RecordingRule AutoExpireType GetAutoExpire(void) const { return m_autoExpire ? kNormalAutoExpire : kDisableAutoExpire; } + bool IsValid(QString &text); + static QString SearchTypeToString(const RecSearchType searchType); static QStringList GetTemplateNames(void); diff --git a/mythtv/programs/mythbackend/services/dvr.cpp b/mythtv/programs/mythbackend/services/dvr.cpp index 25df8b148f2..8d0bc5dddd7 100644 --- a/mythtv/programs/mythbackend/services/dvr.cpp +++ b/mythtv/programs/mythbackend/services/dvr.cpp @@ -492,14 +492,24 @@ DTC::ProgramList* Dvr::GetConflictList( int nStartIndex, return pPrograms; } -int Dvr::AddRecordSchedule ( int chanid, +int Dvr::AddRecordSchedule ( + QString sTitle, + QString sSubtitle, + QString sDescription, + QString sCategory, QDateTime recstarttsRaw, + QDateTime recendtsRaw, + QString sSeriesId, + QString sProgramId, + int nChanId, + QString sStation, + int nFindDay, + QTime tFindTime, int nParentId, bool bInactive, uint nSeason, uint nEpisode, QString sInetref, - int nFindId, QString sType, QString sSearchType, int nRecPriority, @@ -526,9 +536,9 @@ int Dvr::AddRecordSchedule ( int chanid, int nTranscoder) { QDateTime recstartts = recstarttsRaw.toUTC(); - RecordingInfo info(chanid, recstartts, false); - RecordingRule *rule = info.GetRecordingRule(); - // ^ rule is owned by info and deleted when it leaves scope + QDateTime recendts = recendtsRaw.toUTC(); + RecordingRule rule; + rule.LoadTemplate("Default"); if (sType.isEmpty()) sType = "single"; @@ -542,11 +552,14 @@ int Dvr::AddRecordSchedule ( int chanid, if (sDupIn.isEmpty()) sDupIn = "all"; - rule->m_title = info.GetTitle(); - rule->m_type = recTypeFromString(sType); - rule->m_searchType = searchTypeFromString(sSearchType); - rule->m_dupMethod = dupMethodFromString(sDupMethod); - rule->m_dupIn = dupInFromString(sDupIn); + rule.m_title = sTitle; + rule.m_subtitle = sSubtitle; + rule.m_description = sDescription; + + rule.m_type = recTypeFromString(sType); + rule.m_searchType = searchTypeFromString(sSearchType); + rule.m_dupMethod = dupMethodFromString(sDupMethod); + rule.m_dupIn = dupInFromString(sDupIn); if (sRecProfile.isEmpty()) sRecProfile = "Default"; @@ -560,53 +573,221 @@ int Dvr::AddRecordSchedule ( int chanid, if (sPlayGroup.isEmpty()) sPlayGroup = "Default"; - rule->m_recProfile = sRecProfile; - rule->m_recGroup = sRecGroup; - rule->m_storageGroup = sStorageGroup; - rule->m_playGroup = sPlayGroup; + rule.m_category = sCategory; + rule.m_seriesid = sSeriesId; + rule.m_programid = sProgramId; + + rule.m_station = sStation; + + rule.m_findday = nFindDay; + rule.m_findtime = tFindTime; + + rule.m_recProfile = sRecProfile; + rule.m_recGroup = sRecGroup; + rule.m_storageGroup = sStorageGroup; + rule.m_playGroup = sPlayGroup; - rule->m_parentRecID = nParentId; - rule->m_isInactive = bInactive; + rule.m_parentRecID = nParentId; + rule.m_isInactive = bInactive; - rule->m_season = nSeason; - rule->m_episode = nEpisode; - rule->m_inetref = sInetref; - rule->m_findid = nFindId; + rule.m_season = nSeason; + rule.m_episode = nEpisode; + rule.m_inetref = sInetref; - rule->m_recPriority = nRecPriority; - rule->m_prefInput = nPreferredInput; - rule->m_startOffset = nStartOffset; - rule->m_endOffset = nEndOffset; - rule->m_filter = nFilter; + rule.m_recPriority = nRecPriority; + rule.m_prefInput = nPreferredInput; + rule.m_startOffset = nStartOffset; + rule.m_endOffset = nEndOffset; + rule.m_filter = nFilter; - rule->m_autoExpire = bAutoExpire; - rule->m_maxEpisodes = nMaxEpisodes; - rule->m_maxNewest = bMaxNewest; + rule.m_autoExpire = bAutoExpire; + rule.m_maxEpisodes = nMaxEpisodes; + rule.m_maxNewest = bMaxNewest; - rule->m_autoCommFlag = bAutoCommflag; - rule->m_autoTranscode = bAutoTranscode; - rule->m_autoMetadataLookup = bAutoMetaLookup; + rule.m_autoCommFlag = bAutoCommflag; + rule.m_autoTranscode = bAutoTranscode; + rule.m_autoMetadataLookup = bAutoMetaLookup; - rule->m_autoUserJob1 = bAutoUserJob1; - rule->m_autoUserJob2 = bAutoUserJob2; - rule->m_autoUserJob3 = bAutoUserJob3; - rule->m_autoUserJob4 = bAutoUserJob4; + rule.m_autoUserJob1 = bAutoUserJob1; + rule.m_autoUserJob2 = bAutoUserJob2; + rule.m_autoUserJob3 = bAutoUserJob3; + rule.m_autoUserJob4 = bAutoUserJob4; - rule->m_transcoder = nTranscoder; + rule.m_transcoder = nTranscoder; - rule->Save(); + QString msg; + if (!rule.IsValid(msg)) + throw msg; - int recid = rule->m_recordID; + rule.Save(); + + int recid = rule.m_recordID; return recid; } +bool Dvr::UpdateRecordSchedule ( int nRecordId, + QString sTitle, + QString sSubtitle, + QString sDescription, + QString sCategory, + QDateTime dStartTimeRaw, + QDateTime dEndTimeRaw, + QString sSeriesId, + QString sProgramId, + int nChanId, + QString sStation, + int nFindDay, + QTime tFindTime, + bool bInactive, + uint nSeason, + uint nEpisode, + QString sInetref, + QString sType, + QString sSearchType, + int nRecPriority, + uint nPreferredInput, + int nStartOffset, + int nEndOffset, + QString sDupMethod, + QString sDupIn, + uint nFilter, + QString sRecProfile, + QString sRecGroup, + QString sStorageGroup, + QString sPlayGroup, + bool bAutoExpire, + int nMaxEpisodes, + bool bMaxNewest, + bool bAutoCommflag, + bool bAutoTranscode, + bool bAutoMetaLookup, + bool bAutoUserJob1, + bool bAutoUserJob2, + bool bAutoUserJob3, + bool bAutoUserJob4, + int nTranscoder) +{ + if (nRecordId <= 0 ) + throw QString("Record ID is invalid."); + + RecordingRule pRule; + pRule.m_recordID = nRecordId; + pRule.Load(); + + if (!pRule.IsLoaded()) + throw QString("Record ID does not exist."); + + QDateTime recstartts = dStartTimeRaw.toUTC(); + QDateTime recendts = dEndTimeRaw.toUTC(); + + pRule.m_isInactive = bInactive; + if (sType.isEmpty()) + sType = "single"; + + if (sSearchType.isEmpty()) + sSearchType = "none"; + + if (sDupMethod.isEmpty()) + sDupMethod = "subtitleanddescription"; + + if (sDupIn.isEmpty()) + sDupIn = "all"; + + pRule.m_type = recTypeFromString(sType); + pRule.m_searchType = searchTypeFromString(sSearchType); + pRule.m_dupMethod = dupMethodFromString(sDupMethod); + pRule.m_dupIn = dupInFromString(sDupIn); + + if (sRecProfile.isEmpty()) + sRecProfile = "Default"; + + if (sRecGroup.isEmpty()) + sRecGroup = "Default"; + + if (sStorageGroup.isEmpty()) + sStorageGroup = "Default"; + + if (sPlayGroup.isEmpty()) + sPlayGroup = "Default"; + + if (!sTitle.isEmpty()) + pRule.m_title = sTitle; + + if (!sSubtitle.isEmpty()) + pRule.m_subtitle = sSubtitle; + + if(!sDescription.isEmpty()) + pRule.m_description = sDescription; + + if (!sCategory.isEmpty()) + pRule.m_category = sCategory; + + if (!sSeriesId.isEmpty()) + pRule.m_seriesid = sSeriesId; + + if (!sProgramId.isEmpty()) + pRule.m_programid = sProgramId; + + if (!sStation.isEmpty()) + pRule.m_station = sStation; + + pRule.m_startdate = recstartts.date(); + pRule.m_starttime = recstartts.time(); + + pRule.m_enddate = recendts.date(); + pRule.m_endtime = recendts.time(); + + pRule.m_findday = nFindDay; + pRule.m_findtime = tFindTime; + + pRule.m_recProfile = sRecProfile; + pRule.m_recGroup = sRecGroup; + pRule.m_storageGroup = sStorageGroup; + pRule.m_playGroup = sPlayGroup; + + pRule.m_isInactive = bInactive; + + pRule.m_season = nSeason; + pRule.m_episode = nEpisode; + pRule.m_inetref = sInetref; + + pRule.m_recPriority = nRecPriority; + pRule.m_prefInput = nPreferredInput; + pRule.m_startOffset = nStartOffset; + pRule.m_endOffset = nEndOffset; + pRule.m_filter = nFilter; + + pRule.m_autoExpire = bAutoExpire; + pRule.m_maxEpisodes = nMaxEpisodes; + pRule.m_maxNewest = bMaxNewest; + + pRule.m_autoCommFlag = bAutoCommflag; + pRule.m_autoTranscode = bAutoTranscode; + pRule.m_autoMetadataLookup = bAutoMetaLookup; + + pRule.m_autoUserJob1 = bAutoUserJob1; + pRule.m_autoUserJob2 = bAutoUserJob2; + pRule.m_autoUserJob3 = bAutoUserJob3; + pRule.m_autoUserJob4 = bAutoUserJob4; + + pRule.m_transcoder = nTranscoder; + + QString msg; + if (!pRule.IsValid(msg)) + throw msg; + + pRule.Save(); + + return true; +} + bool Dvr::RemoveRecordSchedule ( uint nRecordId ) { bool bResult = false; if (nRecordId <= 0 ) - throw( QString("Record ID appears invalid.")); + throw QString("Record ID does not exist."); RecordingRule pRule; pRule.m_recordID = nRecordId; @@ -662,14 +843,44 @@ DTC::RecRuleList* Dvr::GetRecordScheduleList( int nStartIndex, return pRecRules; } -DTC::RecRule* Dvr::GetRecordSchedule( uint nRecordId ) +DTC::RecRule* Dvr::GetRecordSchedule( uint nRecordId, + QString sTemplate, + int nChanId, + QDateTime dStartTimeRaw, + bool bMakeOverride ) { - if (nRecordId <= 0 ) - throw( QString("Record ID appears invalid.")); + if (nRecordId < 0 ) + throw QString("Record ID is invalid."); RecordingRule rule; - rule.m_recordID = nRecordId; - rule.Load(); + + if (nRecordId > 0) + { + rule.m_recordID = nRecordId; + if (!rule.Load()) + throw QString("Record ID does not exist."); + } + else if (!sTemplate.isEmpty()) + { + if (!rule.LoadTemplate(sTemplate)) + throw QString("Template does not exist."); + } + else if (nChanId > 0 && dStartTimeRaw.isValid()) + { + RecordingInfo::LoadStatus status; + RecordingInfo info(nChanId, dStartTimeRaw, false, 0, &status); + if (status != RecordingInfo::kFoundProgram) + throw QString("Program does not exist."); + RecordingRule *pRule = info.GetRecordingRule(); + if (bMakeOverride && rule.m_type != kSingleRecord && + rule.m_type != kOverrideRecord && rule.m_type != kDontRecord) + pRule->MakeOverride(); + rule = *pRule; + } + else + { + throw QString("Invalid request."); + } DTC::RecRule *pRecRule = new DTC::RecRule(); FillRecRuleInfo( pRecRule, &rule ); @@ -682,7 +893,7 @@ bool Dvr::EnableRecordSchedule ( uint nRecordId ) bool bResult = false; if (nRecordId <= 0 ) - throw( QString("Record ID appears invalid.")); + throw QString("Record ID appears invalid."); RecordingRule pRule; pRule.m_recordID = nRecordId; @@ -703,7 +914,7 @@ bool Dvr::DisableRecordSchedule( uint nRecordId ) bool bResult = false; if (nRecordId <= 0 ) - throw( QString("Record ID appears invalid.")); + throw QString("Record ID appears invalid."); RecordingRule pRule; pRule.m_recordID = nRecordId; diff --git a/mythtv/programs/mythbackend/services/dvr.h b/mythtv/programs/mythbackend/services/dvr.h index 9e23e753d1d..42a172b5575 100644 --- a/mythtv/programs/mythbackend/services/dvr.h +++ b/mythtv/programs/mythbackend/services/dvr.h @@ -76,14 +76,23 @@ class Dvr : public DvrServices // Recording Rules - int AddRecordSchedule ( int ChanId, + int AddRecordSchedule ( QString Title, + QString Subtitle, + QString Description, + QString Category, QDateTime StartTime, + QDateTime EndTime, + QString SeriesId, + QString ProgramId, + int ChanId, + QString Station, + int FindDay, + QTime FindTime, int ParentId, bool Inactive, uint Season, uint Episode, QString Inetref, - int FindId, QString Type, QString SearchType, int RecPriority, @@ -109,12 +118,58 @@ class Dvr : public DvrServices bool AutoUserJob4, int Transcoder); + bool UpdateRecordSchedule ( int RecordId, + QString Title, + QString Subtitle, + QString Description, + QString Category, + QDateTime StartTime, + QDateTime EndTime, + QString SeriesId, + QString ProgramId, + int ChanId, + QString Station, + int FindDay, + QTime FindTime, + bool Inactive, + uint Season, + uint Episode, + QString Inetref, + QString Type, + QString SearchType, + int RecPriority, + uint PreferredInput, + int StartOffset, + int EndOffset, + QString DupMethod, + QString DupIn, + uint Filter, + QString RecProfile, + QString RecGroup, + QString StorageGroup, + QString PlayGroup, + bool AutoExpire, + int MaxEpisodes, + bool MaxNewest, + bool AutoCommflag, + bool AutoTranscode, + bool AutoMetaLookup, + bool AutoUserJob1, + bool AutoUserJob2, + bool AutoUserJob3, + bool AutoUserJob4, + int Transcoder); + bool RemoveRecordSchedule ( uint RecordId ); DTC::RecRuleList* GetRecordScheduleList( int StartIndex, int Count ); - DTC::RecRule* GetRecordSchedule ( uint RecordId ); + DTC::RecRule* GetRecordSchedule ( uint RecordId, + QString Template, + int ChanId, + QDateTime StartTime, + bool MakeOverride ); bool EnableRecordSchedule ( uint RecordId ); diff --git a/mythtv/programs/mythbackend/services/serviceUtil.cpp b/mythtv/programs/mythbackend/services/serviceUtil.cpp index 9a2a79942a0..0941e467002 100644 --- a/mythtv/programs/mythbackend/services/serviceUtil.cpp +++ b/mythtv/programs/mythbackend/services/serviceUtil.cpp @@ -191,9 +191,8 @@ void FillRecRuleInfo( DTC::RecRule *pRecRule, pRecRule->setInetref ( pRule->m_inetref ); pRecRule->setChanId ( pRule->m_channelid ); pRecRule->setCallSign ( pRule->m_station ); - pRecRule->setDay ( pRule->m_findday ); - pRecRule->setTime ( pRule->m_findtime ); - pRecRule->setFindId ( pRule->m_findid ); + pRecRule->setFindDay ( pRule->m_findday ); + pRecRule->setFindTime ( pRule->m_findtime ); pRecRule->setType ( toRawString(pRule->m_type) ); pRecRule->setSearchType ( toRawString(pRule->m_searchType)); pRecRule->setRecPriority ( pRule->m_recPriority );