[mythtv] [PATCH] Fix autoexpire bugs, special display of suggestions

Brad Templeton brad+mydev at templetons.com
Thu Jun 2 23:21:32 UTC 2005


This patch does a few things:

a) Autoexpire is an integer in the database, but it is sometimes treated
as a boolean in the code, particularly when it was being copied from
record to recorded.  This is changed so now it is copied correctly.  It
is still treated as a boolean for the user interface.

In addition, an additional flag has been put into the programflags to
indicate an autoexpire of > 100.  Long term I would prefer to just have
the autoexpire be available in the programinfo but don't wish to alter
the protocol at this time.  (Can you add fields without altering the
protocol?)

b) Code is added so that recordings with autoexpire >= 100 are flagged
with a different font on display in the list of current recordings.
Autoexpire >= 100 is a sign of special "suggestion" recordings (and
possibly other recordings scheduled for quick deletion)  

Patches have been applied to the themes that come with mythtv to display
these recordings in a dim blue.   Todo -- offer sorting them to the
end of the all-programs list.

c) Code is added so that recordings with recpriority <= -90 are also
flagged with a different font for display in the list of upcoming recordings.
These super-low priority recordings should be shown differently.  Currently
they don't show differently if they won't record.


This is all in the aid of the "suggestions" concept -- recordings that
are suggested rather that explicitly requested, as in Tivo.  Suggestions
record with low priority and high autoexpire so they don't interfere
with ordinary recordings.

Suggestions are currently generated by the tvwish program
    http://www.templetons.com/brad/myth/tvwish.html




-------------- next part --------------
? configit
Index: libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.212
diff -u -r1.212 programinfo.cpp
--- libs/libmythtv/programinfo.cpp	26 May 2005 22:57:26 -0000	1.212
+++ libs/libmythtv/programinfo.cpp	27 May 2005 21:24:28 -0000
@@ -1571,11 +1571,11 @@
         MythContext::DBError("PreserveEpisode update", query);
 }
 
-/** \fn ProgramInfo::SetAutoExpire(bool autoExpire) const
+/** \fn ProgramInfo::SetAutoExpire(int autoExpire) const
  *  \brief Set "autoexpire" field in "recorded" table to "autoExpire".
  *  \param autoEpisode value to set auto expire field to.
  */
-void ProgramInfo::SetAutoExpire(bool autoExpire) const
+void ProgramInfo::SetAutoExpire(int autoExpire) const
 {
     MSqlQuery query(MSqlQuery::InitCon());
 
@@ -1595,7 +1595,7 @@
 /** \fn ProgramInfo::GetAutoExpireFromRecorded(void) const
  *  \brief Returns "autoexpire" field from "recorded" table.
  */
-bool ProgramInfo::GetAutoExpireFromRecorded(void) const
+int ProgramInfo::GetAutoExpireFromRecorded(void) const
 {
     MSqlQuery query(MSqlQuery::InitCon());
 
@@ -1608,7 +1608,7 @@
     if (query.exec() && query.isActive() && query.size() > 0)
     {
         query.next();
-        return query.value(0).toBool();
+        return query.value(0).toInt();
     }
 
     return false;
@@ -2789,7 +2789,9 @@
 
         flags |= (query.value(0).toInt() == COMM_FLAG_DONE) ? FL_COMMFLAG : 0;
         flags |= query.value(1).toString().length() > 1 ? FL_CUTLIST : 0;
-        flags |= query.value(2).toInt() ? FL_AUTOEXP : 0;
+        int autoexp = query.value(2).toInt();
+        flags |= autoexp > 0? FL_AUTOEXP : 0;
+        flags |= autoexp >= 100 ? FL_SUGGEST : 0;
         if ((query.value(3).toInt()) ||
             (query.value(0).toInt() == COMM_FLAG_PROCESSING))
             flags |= FL_EDITING;
@@ -2799,6 +2801,14 @@
     return flags;
 }
 
+/** \fn ProgramInfo::IsSuggestion() const
+ *  \brief Indicates if the recording was an automatic suggestion
+ */
+bool ProgramInfo::IsSuggestion(void) const
+{
+    return (programflags & FL_SUGGEST) != 0; 
+}
+
 void ProgramInfo::ShowRecordingDialog(void)
 {
     QDateTime now = QDateTime::currentDateTime();
Index: libs/libmythtv/programinfo.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.h,v
retrieving revision 1.109
diff -u -r1.109 programinfo.h
--- libs/libmythtv/programinfo.h	26 May 2005 22:57:26 -0000	1.109
+++ libs/libmythtv/programinfo.h	27 May 2005 21:24:29 -0000
@@ -55,7 +55,8 @@
     FL_CUTLIST   = 0x02,
     FL_AUTOEXP   = 0x04,
     FL_EDITING   = 0x08,
-    FL_BOOKMARK  = 0x10
+    FL_BOOKMARK  = 0x10,
+    FL_SUGGEST   = 0x20
 };
 
 enum RecStatusType {
@@ -167,10 +168,12 @@
     bool IsEditing(void) const;
     bool IsCommFlagged(void) const;
     bool IsCommProcessing(void) const;
-    bool GetAutoExpireFromRecorded(void) const;
+    int GetAutoExpireFromRecorded(void) const;
     bool GetPreserveEpisodeFromRecorded(void) const;
     bool UsesMaxEpisodes(void) const;
     int getProgramFlags(void) const;
+    // Abstract test of suggestion 
+    bool IsSuggestion(void) const;
 
     // DB sets
     void SetFilesize(long long fsize);
@@ -178,7 +181,7 @@
     void SetEditing(bool edit) const;
     void SetDeleteFlag(bool deleteFlag) const;
     void SetCommFlagged(int flag) const; // 1 = flagged, 2 = processing
-    void SetAutoExpire(bool autoExpire) const;
+    void SetAutoExpire(int autoExpire) const;
     void SetPreserveEpisode(bool preserveEpisode) const;
 
     // Commercial/Edit flagging maps
Index: libs/libmythtv/scheduledrecording.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.cpp,v
retrieving revision 1.141
diff -u -r1.141 scheduledrecording.cpp
--- libs/libmythtv/scheduledrecording.cpp	26 May 2005 22:57:26 -0000	1.141
+++ libs/libmythtv/scheduledrecording.cpp	27 May 2005 21:24:29 -0000
@@ -337,11 +337,11 @@
                               search->intValue() == kManualSearch);
 }
 
-bool ScheduledRecording::GetAutoExpire(void) const {
+int ScheduledRecording::GetAutoExpire(void) const {
     return(autoexpire->getValue().toInt());
 }
 
-void ScheduledRecording::SetAutoExpire(bool expire) {
+void ScheduledRecording::SetAutoExpire(int expire) {
     autoexpire->setValue(expire);
 }
 
Index: libs/libmythtv/scheduledrecording.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.h,v
retrieving revision 1.55
diff -u -r1.55 scheduledrecording.h
--- libs/libmythtv/scheduledrecording.h	26 May 2005 22:57:26 -0000	1.55
+++ libs/libmythtv/scheduledrecording.h	27 May 2005 21:24:29 -0000
@@ -71,8 +71,8 @@
     RecSearchType getSearchType(void) const;
     void setSearchType(RecSearchType);
 
-    bool GetAutoExpire(void) const;
-    void SetAutoExpire(bool expire);
+    int GetAutoExpire(void) const;
+    void SetAutoExpire(int expire);
 
     int GetMaxEpisodes(void) const;
     bool GetMaxNewest(void) const;
Index: libs/libmythtv/sr_items.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/sr_items.h,v
retrieving revision 1.30
diff -u -r1.30 sr_items.h
--- libs/libmythtv/sr_items.h	26 May 2005 22:57:26 -0000	1.30
+++ libs/libmythtv/sr_items.h	27 May 2005 21:24:30 -0000
@@ -652,6 +652,8 @@
         }
 };
 
+// This remains boolean here as user only is concerned about yes/no
+
 class SRAutoExpire: public SRBoolSetting
 {
     public:
Index: libs/libmythtv/tv_play.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/tv_play.cpp,v
retrieving revision 1.270
diff -u -r1.270 tv_play.cpp
--- libs/libmythtv/tv_play.cpp	27 May 2005 00:59:21 -0000	1.270
+++ libs/libmythtv/tv_play.cpp	27 May 2005 21:24:32 -0000
@@ -4091,7 +4091,7 @@
                                      (autoCommercialSkip == 1) ? 1 : 0, NULL,
                                      "COMMSKIPGROUP");
 
-        if (playbackinfo->GetAutoExpireFromRecorded())
+        if (playbackinfo->GetAutoExpireFromRecorded() > 0)
             item = new OSDGenericTree(treeMenu, tr("Turn Auto-Expire OFF"),
                                       "TOGGLEAUTOEXPIRE");
         else
@@ -4204,14 +4204,14 @@
 {
     QString desc = "";
 
-    if (playbackinfo->GetAutoExpireFromRecorded())
+    if (playbackinfo->GetAutoExpireFromRecorded() > 0)
     {
-        playbackinfo->SetAutoExpire(false);
+        playbackinfo->SetAutoExpire(0);
         desc = tr("Auto-Expire OFF");
     }
     else
     {
-        playbackinfo->SetAutoExpire(true);
+        playbackinfo->SetAutoExpire(1);
         desc = tr("Auto-Expire ON");
     }
 
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.213
diff -u -r1.213 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	27 May 2005 14:58:17 -0000	1.213
+++ programs/mythbackend/mainserver.cpp	27 May 2005 21:24:34 -0000
@@ -971,11 +971,14 @@
             int flags = 0;
             flags |= (query.value(10).toInt() == 1) ? FL_COMMFLAG : 0;
             flags |= query.value(11).toString().length() > 1 ? FL_CUTLIST : 0;
-            flags |= query.value(12).toInt() ? FL_AUTOEXP : 0;
+            int autoexp = query.value(12).toInt();
+            flags |= autoexp > 0? FL_AUTOEXP : 0;
+            flags |= autoexp >= 100 ? FL_SUGGEST : 0;
             if (query.value(13).toInt() || (query.value(10).toInt() == 2))
                 flags |= FL_EDITING;
             flags |= query.value(14).toString().length() > 1 ? FL_BOOKMARK : 0;
 
+
             proginfo->programflags = flags;
 
             proginfo->category = QString::fromUtf8(query.value(15).toString());
Index: programs/mythfrontend/playbackbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/playbackbox.cpp,v
retrieving revision 1.215
diff -u -r1.215 playbackbox.cpp
--- programs/mythfrontend/playbackbox.cpp	24 May 2005 20:19:56 -0000	1.215
+++ programs/mythfrontend/playbackbox.cpp	27 May 2005 21:24:38 -0000
@@ -1048,6 +1048,8 @@
                 tempCurrent = RemoteGetRecordingStatus(tempInfo, overrectime,
                                                      underrectime);
 
+                // FIXME, when showing recording groups or category groups,
+                // Should display title + subtitle, not just subtitle!
                 if ((titleList[titleIndex] == "") || (!(titleView)))
                     tempSubTitle = tempInfo->title; 
                 else
@@ -1081,6 +1083,8 @@
                     ltype->EnableForcedFont(cnt, "recording");
                 else if (tempCurrent > 1)
                     ltype->EnableForcedFont(cnt, "recording"); // FIXME: change to overunderrecording, fall back to recording. 
+                else if( tempInfo->IsSuggestion() )
+                    ltype->EnableForcedFont(cnt, "suggestion");
 
                 QString key;
                 key = tempInfo->chanid + "_" +
@@ -2996,7 +3000,7 @@
 
     ProgramInfo *tmpItem = findMatchingProg(delitem);
     if (tmpItem)
-        tmpItem->programflags &= ~FL_AUTOEXP;
+        tmpItem->programflags &= ~(FL_AUTOEXP|FL_SUGGEST);
 
     delete delitem;
     delitem = NULL;
Index: programs/mythfrontend/viewscheduled.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/viewscheduled.cpp,v
retrieving revision 1.95
diff -u -r1.95 viewscheduled.cpp
--- programs/mythfrontend/viewscheduled.cpp	21 May 2005 19:22:33 -0000	1.95
+++ programs/mythfrontend/viewscheduled.cpp	27 May 2005 21:24:39 -0000
@@ -351,6 +351,10 @@
                     ltype->EnableForcedFont(i, "recording");
                 else if (p->recstatus == rsConflict)
                     ltype->EnableForcedFont(i, "conflictingrecording");
+                else if( p->recpriority <= -90 ) 
+                    ltype->EnableForcedFont(i, "suggestion" );
+                // Fixme: We need a concept of a suggestion that will record
+                // vs. a disbled/conflicted suggestion
                 else if (p->recstatus == rsWillRecord)
                     ltype->EnableForcedFont(i, "record");
                 else if (p->recstatus <= rsEarlierShowing ||
Index: themes/G.A.N.T./ui.xml
===================================================================
RCS file: /var/lib/mythcvs/mythtv/themes/G.A.N.T./ui.xml,v
retrieving revision 1.48
diff -u -r1.48 ui.xml
--- themes/G.A.N.T./ui.xml	25 Apr 2005 14:39:54 -0000	1.48
+++ themes/G.A.N.T./ui.xml	27 May 2005 21:24:40 -0000
@@ -745,6 +745,7 @@
         <fcnfont name="record_font" function="record"></fcnfont>
         <fcnfont name="recording_font" function="recording"></fcnfont>
         <fcnfont name="active_font" function="selected"></fcnfont>
+        <fcnfont name="-suggest_font" function="suggestion"></fcnfont>
         <columnpadding>10</columnpadding>
         <column number="1" width="160" context="-1"></column>
         <column number="2" width="120" context="-1"></column>
@@ -1231,6 +1232,13 @@
       <bold>yes</bold>
     </font>
 
+    <font name="suggest_font" face="Arial">
+      <color>#7777FF</color>
+      <size>15</size>
+      <size:small>10</size:small>
+      <bold>no</bold>
+    </font>
+
     <font name="overunderrecfont" face="Arial">
       <color>#ffffAA</color>
       <size>16</size>
@@ -1324,6 +1332,7 @@
         <fcnfont name="active" function="selected"></fcnfont>
         <fcnfont name="inactive" function="inactive"></fcnfont>
         <fcnfont name="tagged_font" function="tagged"></fcnfont>
+        <fcnfont name="suggest-font" function="suggestion"></fcnfont>
         <columnpadding>10</columnpadding>
         <column number="1" width="320" context="-1"></column>
         <column number="2" width="60" context="-1"></column>
Index: themes/blue/theme.xml
===================================================================
RCS file: /var/lib/mythcvs/mythtv/themes/blue/theme.xml,v
retrieving revision 1.39
diff -u -r1.39 theme.xml
--- themes/blue/theme.xml	15 Feb 2005 04:56:23 -0000	1.39
+++ themes/blue/theme.xml	27 May 2005 21:24:40 -0000
@@ -75,6 +75,10 @@
     <font name="list-conflict"  base="list-active">
       <color>#dddd33</color>
     </font>
+
+    <font name="list-suggest" base="list-active">
+      <color>#7777ff</color>
+    </font>
     
     <font name="list-tagged"  base="list-active">
       <color>#dddd33</color>
Index: themes/blue/ui.xml
===================================================================
RCS file: /var/lib/mythcvs/mythtv/themes/blue/ui.xml,v
retrieving revision 1.111
diff -u -r1.111 ui.xml
--- themes/blue/ui.xml	6 Apr 2005 21:03:37 -0000	1.111
+++ themes/blue/ui.xml	27 May 2005 21:24:41 -0000
@@ -616,6 +616,7 @@
         <fcnfont name="list-record" function="record"></fcnfont>
         <fcnfont name="list-recording" function="recording"></fcnfont>
         <fcnfont name="list-selected" function="selected"></fcnfont>
+        <fcnfont name="list-suggest" function="suggestion"></fcnfont>
         <columnpadding>10</columnpadding>
         <column number="1" width="165" context="-1"></column>
         <column number="2" width="110" context="-1"></column>
@@ -1045,6 +1046,7 @@
         <fcnfont name="list-selected" function="selected"></fcnfont>
         <fcnfont name="list-inactive" function="inactive"></fcnfont>
         <fcnfont name="list-tagged" function="tagged"></fcnfont>
+        <fcnfont name="list-suggest" function="suggestion"></fcnfont>
         <columnpadding>5</columnpadding>
         <column number="1" width="340" context="-1"></column>
         <column number="2" width="60" context="-1"></column>


More information about the mythtv-dev mailing list