Skip to content

Commit

Permalink
Service API: Fix bug where "New Episodes Only" corrupts value of DupIn
Browse files Browse the repository at this point in the history
DupIn value carries two meanings, "New Episodes Only" flag as well as
flag for searching in current, old or both when cheing duplicates.
Changed the API methods to have one more parameter, for new episodes
only.

(cherry picked from commit 9d084c2)
  • Loading branch information
bennettpeter committed Sep 2, 2020
1 parent 40841f5 commit b282809
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 8 deletions.
23 changes: 20 additions & 3 deletions mythtv/libs/libmyth/recordingtypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ QString toString(RecordingDupInType recdupin)
return QObject::tr("Previous Recordings");
case kDupsInAll:
return QObject::tr("All Recordings");
// TODO: This is wrong, kDupsNewEpi is returned in conjunction with
// one of the other values.
case kDupsNewEpi:
return QObject::tr("New Episodes Only");
default:
Expand All @@ -179,6 +181,8 @@ QString toDescription(RecordingDupInType recdupin)
case kDupsInAll:
return QObject::tr("Look for duplicates in current and previous "
"recordings");
// TODO: This is wrong, kDupsNewEpi is returned in conjunction with
// one of the other values.
case kDupsNewEpi:
return QObject::tr("Record new episodes only");
default:
Expand All @@ -188,6 +192,8 @@ QString toDescription(RecordingDupInType recdupin)

QString toRawString(RecordingDupInType recdupin)
{
// Remove "New Episodes" flag
recdupin = (RecordingDupInType) (recdupin & (-1 - kDupsNewEpi));
switch (recdupin)
{
case kDupsInRecorded:
Expand All @@ -196,13 +202,17 @@ QString toRawString(RecordingDupInType recdupin)
return QString("Previous Recordings");
case kDupsInAll:
return QString("All Recordings");
case kDupsNewEpi:
return QString("New Episodes Only");
default:
return QString("Unknown");
}
}

// New Episodes Only is a flag added to DupIn
bool newEpifromDupIn(RecordingDupInType recdupin)
{
return (recdupin & kDupsNewEpi);
}

RecordingDupInType dupInFromString(const QString& type)
{
if (type.toLower() == "current recordings" || type.toLower() == "current")
Expand All @@ -212,10 +222,17 @@ RecordingDupInType dupInFromString(const QString& type)
if (type.toLower() == "all recordings" || type.toLower() == "all")
return kDupsInAll;
if (type.toLower() == "new episodes only" || type.toLower() == "new")
return kDupsNewEpi;
return static_cast<RecordingDupInType> (kDupsInAll | kDupsNewEpi);
return kDupsInAll;
}

RecordingDupInType dupInFromStringAndBool(const QString& type, bool newEpisodesOnly) {
RecordingDupInType result = dupInFromString(type);
if (newEpisodesOnly)
result = static_cast<RecordingDupInType> (result | kDupsNewEpi);
return result;
}

QString toString(RecordingDupMethodType duptype)
{
switch (duptype)
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmyth/recordingtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ enum RecordingDupInType
MPUBLIC QString toString(RecordingDupInType rectype);
MPUBLIC QString toDescription(RecordingDupInType rectype);
MPUBLIC QString toRawString(RecordingDupInType rectype);
MPUBLIC bool newEpifromDupIn(RecordingDupInType recdupin);
MPUBLIC RecordingDupInType dupInFromString(const QString& type);
MPUBLIC RecordingDupInType dupInFromStringAndBool(const QString& type, bool newEpisodesOnly);

enum RecordingDupMethodType
{
Expand Down
6 changes: 5 additions & 1 deletion mythtv/libs/libmythservicecontracts/datacontracts/recRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace DTC
class SERVICE_PUBLIC RecRule : public QObject
{
Q_OBJECT
Q_CLASSINFO( "version" , "2.00" );
Q_CLASSINFO( "version" , "2.10" );

Q_PROPERTY( int Id READ Id WRITE setId )
Q_PROPERTY( int ParentId READ ParentId WRITE setParentId )
Expand Down Expand Up @@ -46,6 +46,7 @@ class SERVICE_PUBLIC RecRule : public QObject
Q_PROPERTY( int EndOffset READ EndOffset WRITE setEndOffset )
Q_PROPERTY( QString DupMethod READ DupMethod WRITE setDupMethod )
Q_PROPERTY( QString DupIn READ DupIn WRITE setDupIn )
Q_PROPERTY( bool NewEpisOnly READ NewEpisOnly WRITE setNewEpisOnly )
Q_PROPERTY( uint Filter READ Filter WRITE setFilter )

Q_PROPERTY( QString RecProfile READ RecProfile WRITE setRecProfile )
Expand Down Expand Up @@ -97,6 +98,7 @@ class SERVICE_PUBLIC RecRule : public QObject
PROPERTYIMP ( int , EndOffset )
PROPERTYIMP ( QString , DupMethod )
PROPERTYIMP ( QString , DupIn )
PROPERTYIMP ( bool , NewEpisOnly )
PROPERTYIMP ( uint , Filter )
PROPERTYIMP ( QString , RecProfile )
PROPERTYIMP ( QString , RecGroup )
Expand Down Expand Up @@ -135,6 +137,7 @@ class SERVICE_PUBLIC RecRule : public QObject
m_PreferredInput( 0 ),
m_StartOffset ( 0 ),
m_EndOffset ( 0 ),
m_NewEpisOnly ( false ),
m_Filter ( 0 ),
m_AutoExpire ( false ),
m_MaxEpisodes ( 0 ),
Expand Down Expand Up @@ -179,6 +182,7 @@ class SERVICE_PUBLIC RecRule : public QObject
m_EndOffset = src->m_EndOffset ;
m_DupMethod = src->m_DupMethod ;
m_DupIn = src->m_DupIn ;
m_NewEpisOnly = src->m_NewEpisOnly ;
m_Filter = src->m_Filter ;
m_RecProfile = src->m_RecProfile ;
m_RecGroup = src->m_RecGroup ;
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythservicecontracts/services/dvrServices.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ???
QDateTime LastRecorded,
QString DupMethod,
QString DupIn,
bool NewEpisOnly,
uint Filter,
QString RecProfile,
QString RecGroup,
Expand Down Expand Up @@ -255,6 +256,7 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ???
int EndOffset,
QString DupMethod,
QString DupIn,
bool NewEpisOnly,
uint Filter,
QString RecProfile,
QString RecGroup,
Expand Down
6 changes: 4 additions & 2 deletions mythtv/programs/mythbackend/services/dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ uint Dvr::AddRecordSchedule (
QDateTime lastrectsRaw,
QString sDupMethod,
QString sDupIn,
bool bNewEpisOnly,
uint nFilter,
QString sRecProfile,
QString sRecGroup,
Expand Down Expand Up @@ -1145,7 +1146,7 @@ uint Dvr::AddRecordSchedule (
rule.m_dupMethod = kDupCheckNone;
else
rule.m_dupMethod = dupMethodFromString(sDupMethod);
rule.m_dupIn = dupInFromString(sDupIn);
rule.m_dupIn = dupInFromStringAndBool(sDupIn, bNewEpisOnly);

if (sRecProfile.isEmpty())
sRecProfile = "Default";
Expand Down Expand Up @@ -1242,6 +1243,7 @@ bool Dvr::UpdateRecordSchedule ( uint nRecordId,
int nEndOffset,
QString sDupMethod,
QString sDupIn,
bool bNewEpisOnly,
uint nFilter,
QString sRecProfile,
QString sRecGroup,
Expand Down Expand Up @@ -1291,7 +1293,7 @@ bool Dvr::UpdateRecordSchedule ( uint nRecordId,
pRule.m_dupMethod = kDupCheckNone;
else
pRule.m_dupMethod = dupMethodFromString(sDupMethod);
pRule.m_dupIn = dupInFromString(sDupIn);
pRule.m_dupIn = dupInFromStringAndBool(sDupIn, bNewEpisOnly);

if (sRecProfile.isEmpty())
sRecProfile = "Default";
Expand Down
8 changes: 6 additions & 2 deletions mythtv/programs/mythbackend/services/dvr.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class Dvr : public DvrServices
QDateTime lastrectsRaw,
QString DupMethod,
QString DupIn,
bool NewEpisOnly,
uint Filter,
QString RecProfile,
QString RecGroup,
Expand Down Expand Up @@ -218,6 +219,7 @@ class Dvr : public DvrServices
int EndOffset,
QString DupMethod,
QString DupIn,
bool NewEpisOnly,
uint Filter,
QString RecProfile,
QString RecGroup,
Expand Down Expand Up @@ -494,7 +496,8 @@ class ScriptableDvr : public QObject
rule->PreferredInput(), rule->StartOffset(),
rule->EndOffset(), rule->LastRecorded(),
rule->DupMethod(),
rule->DupIn(), rule->Filter(),
rule->DupIn(), rule->NewEpisOnly(),
rule->Filter(),
rule->RecProfile(), rule->RecGroup(),
rule->StorageGroup(), rule->PlayGroup(),
rule->AutoExpire(), rule->MaxEpisodes(),
Expand Down Expand Up @@ -527,7 +530,8 @@ class ScriptableDvr : public QObject
rule->SearchType(), rule->RecPriority(),
rule->PreferredInput(), rule->StartOffset(),
rule->EndOffset(), rule->DupMethod(),
rule->DupIn(), rule->Filter(),
rule->DupIn(), rule->NewEpisOnly(),
rule->Filter(),
rule->RecProfile(), rule->RecGroup(),
rule->StorageGroup(), rule->PlayGroup(),
rule->AutoExpire(), rule->MaxEpisodes(),
Expand Down
1 change: 1 addition & 0 deletions mythtv/programs/mythbackend/services/serviceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ void FillRecRuleInfo( DTC::RecRule *pRecRule,
pRecRule->setEndOffset ( pRule->m_endOffset );
pRecRule->setDupMethod ( toRawString(pRule->m_dupMethod) );
pRecRule->setDupIn ( toRawString(pRule->m_dupIn) );
pRecRule->setNewEpisOnly ( newEpifromDupIn(pRule->m_dupIn) );
pRecRule->setFilter ( pRule->m_filter );
pRecRule->setRecProfile ( pRule->m_recProfile );
pRecRule->setRecGroup ( RecordingInfo::GetRecgroupString(pRule->m_recGroupID) );
Expand Down

0 comments on commit b282809

Please sign in to comment.