Skip to content

Commit

Permalink
Add new filter support to RecordingRule.
Browse files Browse the repository at this point in the history
  • Loading branch information
gigem committed Jun 7, 2011
1 parent 70f6471 commit 5241f65
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20110605-1"
#define MYTH_BINARY_VERSION "0.25.20110607-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
23 changes: 22 additions & 1 deletion mythtv/libs/libmythtv/recordingrule.cpp
Expand Up @@ -32,6 +32,7 @@ RecordingRule::RecordingRule()
m_dupMethod(static_cast<RecordingDupMethodType>(
gCoreContext->GetNumSetting("prefDupMethod", kDupCheckSubDesc))),
m_dupIn(kDupsInAll),
m_filter(GetDefaultFilter()),
m_recProfile(QObject::tr("Default")),
m_recGroup("Default"),
m_storageGroup("Default"),
Expand Down Expand Up @@ -73,7 +74,7 @@ bool RecordingRule::Load()
"parentid, title, subtitle, description, category, "
"starttime, startdate, endtime, enddate, seriesid, programid, "
"chanid, station, findday, findtime, findid, "
"next_record, last_record, last_delete, avg_delay "
"next_record, last_record, last_delete, avg_delay, filter "
"FROM record WHERE recordid = :RECORDID ;");

query.bindValue(":RECORDID", m_recordID);
Expand All @@ -96,6 +97,7 @@ bool RecordingRule::Load()
m_dupMethod = static_cast<RecordingDupMethodType>
(query.value(6).toInt());
m_dupIn = static_cast<RecordingDupInType>(query.value(7).toInt());
m_filter = query.value(43).toUInt();
m_isInactive = query.value(8).toBool();
// Storage
m_recProfile = query.value(9).toString();
Expand Down Expand Up @@ -289,6 +291,7 @@ bool RecordingRule::Save(bool sendSig)
"recpriority = :RECPRIORITY, prefinput = :INPUT, "
"startoffset = :STARTOFFSET, endoffset = :ENDOFFSET, "
"dupmethod = :DUPMETHOD, dupin = :DUPIN, "
"filter = :FILTER, "
"inactive = :INACTIVE, profile = :RECPROFILE, "
"recgroup = :RECGROUP, storagegroup = :STORAGEGROUP, "
"playgroup = :PLAYGROUP, autoexpire = :AUTOEXPIRE, "
Expand Down Expand Up @@ -327,6 +330,7 @@ bool RecordingRule::Save(bool sendSig)
query.bindValue(":ENDOFFSET", m_endOffset);
query.bindValue(":DUPMETHOD", m_dupMethod);
query.bindValue(":DUPIN", m_dupIn);
query.bindValue(":FILTER", m_filter);
query.bindValue(":INACTIVE", m_isInactive);
query.bindValue(":RECPROFILE", m_recProfile);
query.bindValue(":RECGROUP", m_recGroup);
Expand Down Expand Up @@ -587,3 +591,20 @@ void RecordingRule::AssignProgramInfo()
}
m_category = m_progInfo->GetCategory();
}

unsigned RecordingRule::GetDefaultFilter(void)
{
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("SELECT SUM(1 << filterid) FROM recordfilter "
"WHERE filterid >= 0 AND filterid < :NUMFILTERS AND "
" TRIM(clause) <> '' AND newruledefault <> 0");
query.bindValue(":NUMFILTERS", RecordingRule::kNumFilters);
if (!query.exec())
{
MythDB::DBError("GetDefaultFilter", query);
return 0;
}
query.next();
return query.value(0).toUInt();
}

4 changes: 4 additions & 0 deletions mythtv/libs/libmythtv/recordingrule.h
Expand Up @@ -30,6 +30,8 @@ class MTV_PUBLIC RecordingRule
{

public:
static const int kNumFilters = 12;

RecordingRule();
~RecordingRule() {};

Expand All @@ -47,6 +49,7 @@ class MTV_PUBLIC RecordingRule

bool IsLoaded() const { return m_loaded; }
void UseTempTable(bool usetemp, QString table = "record_tmp");
static unsigned GetDefaultFilter(void);

void ToMap(InfoMap &infoMap) const;

Expand Down Expand Up @@ -88,6 +91,7 @@ class MTV_PUBLIC RecordingRule
int m_endOffset;
RecordingDupMethodType m_dupMethod;
RecordingDupInType m_dupIn;
unsigned m_filter;

// Storage Options
// TODO: These should all be converted to integer IDs instead
Expand Down
4 changes: 3 additions & 1 deletion mythtv/programs/mythbackend/scheduler.cpp
Expand Up @@ -38,6 +38,7 @@ using namespace std;
#include "compat.h"
#include "storagegroup.h"
#include "recordinginfo.h"
#include "recordingrule.h"
#include "scheduledrecording.h"
#include "cardutil.h"
#include "mythdb.h"
Expand Down Expand Up @@ -3227,8 +3228,9 @@ void Scheduler::UpdateMatches(int recordid) {

QString filterClause;
query.prepare("SELECT filterid, clause FROM recordfilter "
"WHERE filterid >= 0 AND filterid < 12 AND "
"WHERE filterid >= 0 AND filterid < :NUMFILTERS AND "
" TRIM(clause) <> ''");
query.bindValue(":NUMFILTERS", RecordingRule::kNumFilters);
if (!query.exec())
{
MythDB::DBError("UpdateMatches", query);
Expand Down

0 comments on commit 5241f65

Please sign in to comment.