[mythtv] [PATCH] Use callsign for scheduling

David Engel gigem at comcast.net
Tue Apr 6 23:15:52 EDT 2004


On Thu, Mar 18, 2004 at 09:01:42PM -0600, David Engel wrote:
> Well, now that you mention it, backward compatibility could be rather
> easy.  Instead of renaming and replacing chanid in the record table
> with callsign, callsign could be added as a new column and the new
> code could continue to populate it even though it only use callsign.
> So, if the user downgraded, the chanid would still be there for the
> old code to use.

I've finally gotten a little time to work on this, so here is the
first part of this change.  It updates the database to add the new
columns but doesn't change anything else yet.

It seems to work OK for me, but I'd like a few more eyes to give it a
once over before I commit it.  I'd especially like to hear from
someone (most likely outside the US) who doesn't have callsigns in
their channel table to make sure they get filled in with the chanid.

David
-- 
David Engel
gigem at comcast.net
-------------- next part --------------
Index: libs/libmythtv/dbcheck.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dbcheck.cpp,v
retrieving revision 1.37
diff -u -r1.37 dbcheck.cpp
--- libs/libmythtv/dbcheck.cpp	14 Mar 2004 07:35:32 -0000	1.37
+++ libs/libmythtv/dbcheck.cpp	7 Apr 2004 02:57:34 -0000
@@ -8,7 +8,7 @@
 
 #include "mythcontext.h"
 
-const QString currentDatabaseVersion = "1035";
+const QString currentDatabaseVersion = "1036";
 
 void UpdateDBVersionNumber(const QString &newnumber)
 {
@@ -670,6 +670,22 @@
 };
         performActualUpdate(updates, "1035", dbver);
     }
+
+    if (dbver == "1035")
+    {
+        const QString updates[] = {
+"ALTER TABLE channel CHANGE callsign callsign VARCHAR(20) NOT NULL;",
+"UPDATE channel SET callsign=chanid WHERE callsign IS NULL OR callsign='';",
+"ALTER TABLE record ADD COLUMN callsign VARCHAR(20) NOT NULL;",
+"UPDATE record,channel SET record.callsign=channel.callsign "
+    "WHERE record.chanid=channel.chanid;",
+"ALTER TABLE recordoverride ADD COLUMN callsign VARCHAR(20) NOT NULL;",
+"UPDATE recordoverride,channel SET recordoverride.callsign=channel.callsign "
+    "WHERE recordoverride.chanid=channel.chanid;",
+""
+};
+        performActualUpdate(updates, "1036", dbver);
+    }
 }
 
 void InitializeDatabase(void)
Index: libs/libmythtv/programinfo.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.cpp,v
retrieving revision 1.121
diff -u -r1.121 programinfo.cpp
--- libs/libmythtv/programinfo.cpp	23 Mar 2004 22:04:34 -0000	1.121
+++ libs/libmythtv/programinfo.cpp	7 Apr 2004 02:57:36 -0000
@@ -1524,9 +1524,9 @@
     QSqlQuery query;
 
     thequery = QString("DELETE FROM recordoverride WHERE "
-       "recordid = %2 AND chanid = %3 AND starttime = %4 AND endtime = %5 AND "
+       "recordid = %2 AND callsign = \"%3\" AND starttime = %4 AND endtime = %5 AND "
        "title = \"%6\" AND subtitle = \"%7\" AND description = \"%8\";")
-        .arg(recordid).arg(chanid)
+        .arg(recordid).arg(chansign.utf8())
         .arg(startts.toString("yyyyMMddhhmmss").ascii())
         .arg(endts.toString("yyyyMMddhhmmss").ascii())
         .arg(sqltitle.utf8()).arg(sqlsubtitle.utf8())
@@ -1539,12 +1539,13 @@
     {
         thequery = QString("INSERT INTO recordoverride SET type = %1, "
             "recordid = %2, chanid = %3, starttime = %4, endtime = %5, "
-            "title = \"%6\", subtitle = \"%7\", description = \"%8\";")
+            "title = \"%6\", subtitle = \"%7\", description = \"%8\", " 
+            "callsign = \"%9\";")
             .arg(override).arg(recordid).arg(chanid)
             .arg(startts.toString("yyyyMMddhhmmss").ascii())
             .arg(endts.toString("yyyyMMddhhmmss").ascii())
             .arg(sqltitle.utf8()).arg(sqlsubtitle.utf8())
-            .arg(sqldescription.utf8());
+            .arg(sqldescription.utf8()).arg(chansign.utf8());
         query = db->exec(thequery);
         if (!query.isActive())
             MythContext::DBError("record override update", thequery);
Index: libs/libmythtv/scheduledrecording.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.cpp,v
retrieving revision 1.78
diff -u -r1.78 scheduledrecording.cpp
--- libs/libmythtv/scheduledrecording.cpp	27 Mar 2004 08:17:40 -0000	1.78
+++ libs/libmythtv/scheduledrecording.cpp	7 Apr 2004 02:57:36 -0000
@@ -173,6 +173,13 @@
     };
 };
 
+class SRCallSign: public LineEditSetting, public SRSetting {
+public:
+    SRCallSign(const ScheduledRecording& parent): SRSetting(parent, "callsign") {
+        setVisible(false);
+    };
+};
+
 class SRTitle: public LineEditSetting, public SRSetting {
 public:
     SRTitle(const ScheduledRecording& parent):
@@ -290,6 +297,7 @@
     addChild(endoffset = new SREndOffset(*this));
     addChild(maxnewest = new SRMaxNewest(*this));
     addChild(channel = new SRChannel(*this));
+    addChild(callsign = new SRCallSign(*this));
     addChild(title = new SRTitle(*this));
     addChild(subtitle = new SRSubtitle(*this));
     addChild(description = new SRDescription(*this));
@@ -307,6 +315,7 @@
 void ScheduledRecording::fromProgramInfo(ProgramInfo* proginfo)
 {
     channel->setValue(proginfo->chanid);
+    callsign->setValue(proginfo->chansign);
     title->setValue(proginfo->title);
     subtitle->setValue(proginfo->subtitle);
     description->setValue(proginfo->description);
@@ -356,7 +365,7 @@
 "OR record.type = %3) " // findonerecord
 " OR "
 " ((record.chanid = %4 " // channel matches
-" OR (callsign IS NOT NULL AND callsign <> '' AND callsign = '%5')) "
+" OR (channel.callsign IS NOT NULL AND channel.callsign <> '' AND channel.callsign = '%5')) "
 "  AND "
 "  ((record.type = %6) " // channelrecord
 "   OR"
Index: libs/libmythtv/scheduledrecording.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/scheduledrecording.h,v
retrieving revision 1.29
diff -u -r1.29 scheduledrecording.h
--- libs/libmythtv/scheduledrecording.h	23 Mar 2004 22:04:34 -0000	1.29
+++ libs/libmythtv/scheduledrecording.h	7 Apr 2004 02:57:36 -0000
@@ -121,6 +121,7 @@
     class SRMaxEpisodes* maxepisodes;
     class SRMaxNewest* maxnewest;
     class SRChannel* channel;
+    class SRCallSign* callsign;
     class SRTitle* title;
     class SRSubtitle* subtitle;
     class SRDescription* description;
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.130
diff -u -r1.130 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	14 Mar 2004 07:35:32 -0000	1.130
+++ programs/mythbackend/mainserver.cpp	7 Apr 2004 02:57:36 -0000
@@ -627,7 +627,7 @@
 
     thequery = "SELECT recorded.chanid,recorded.starttime,recorded.endtime,"
                "recorded.title,recorded.subtitle,recorded.description,"
-               "recorded.hostname,channum,name,callsign,commflagged,cutlist,"
+               "recorded.hostname,channum,name,record.callsign,commflagged,cutlist,"
                "recorded.autoexpire,editing,bookmark,recorded.category,"
                "recorded.recgroup,record.dupin,record.dupmethod,"
                "record.recordid "
Index: programs/mythfilldatabase/filldata.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfilldatabase/filldata.cpp,v
retrieving revision 1.96
diff -u -r1.96 filldata.cpp
--- programs/mythfilldatabase/filldata.cpp	14 Mar 2004 07:35:32 -0000	1.96
+++ programs/mythfilldatabase/filldata.cpp	7 Apr 2004 02:57:36 -0000
@@ -943,6 +943,9 @@
 
                 promptForChannelUpdates(i, atoi(chanid.ascii()));
 
+                if ((*i).callsign == QString::null || (*i).callsign == "")
+                    (*i).callsign = chanid;
+
                 if (name     != (*i).name ||
                     callsign != (*i).callsign ||
                     chanstr  != (*i).chanstr ||
@@ -1025,6 +1028,9 @@
 
                 unsigned int chanid = promptForChannelUpdates(i,0);
 
+                if ((*i).callsign == QString::null || (*i).callsign == "")
+                    (*i).callsign = chanid;
+
                 if (chanid > 0)
                 {
                     querystr = QString("INSERT INTO channel (chanid,name"
@@ -1085,6 +1091,9 @@
                         break;
                 }
 
+                if ((*i).callsign == QString::null || (*i).callsign == "")
+                    (*i).callsign = chanid;
+
                 querystr = QString("INSERT INTO channel (chanid,name,callsign,"
                                    "channum,finetune,icon,xmltvid,sourceid,"
                                    "freqid,tvformat) "


More information about the mythtv-dev mailing list