Skip to content
Browse files

Add new filter support to RecordingRule.

  • Loading branch information...
1 parent 70f6471 commit 5241f65c9201b57a83ee1a1423dde4a980035bc8 @gigem gigem committed Jun 7, 2011
View
2 mythtv/libs/libmythbase/mythversion.h
@@ -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.
*
View
23 mythtv/libs/libmythtv/recordingrule.cpp
@@ -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"),
@@ -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);
@@ -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();
@@ -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, "
@@ -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);
@@ -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();
+}
+
View
4 mythtv/libs/libmythtv/recordingrule.h
@@ -30,6 +30,8 @@ class MTV_PUBLIC RecordingRule
{
public:
+ static const int kNumFilters = 12;
+
RecordingRule();
~RecordingRule() {};
@@ -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;
@@ -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
View
4 mythtv/programs/mythbackend/scheduler.cpp
@@ -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"
@@ -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);

0 comments on commit 5241f65

Please sign in to comment.
Something went wrong with that request. Please try again.