This patch, against current CVS, adds a QUERY_GUIDEDATATHROUGH to the backend protocol. This allows for querying the number of days of guidedata available. Currently used for the LED box that James Armstrong and I made.

There is another part which adds a QUERY_NEWMESSAGES, but most people won't find it useful at all so I figured I would leave that part out.

If you think this might be useful for others please apply, but feel free to ignore :-)

--
David
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.171
diff -u -r1.171 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	27 Jan 2005 09:37:20 -0000	1.171
+++ programs/mythbackend/mainserver.cpp	28 Jan 2005 02:40:23 -0000
@@ -254,6 +254,10 @@
     {
         HandleQueryCheckFile(listline, pbs);
     }
+    else if (command == "QUERY_GUIDEDATATHROUGH")
+    {
+        HandleQueryGuideDataThrough(pbs);
+    }
     else if (command == "QUEUE_TRANSCODE")
     {
         HandleQueueTranscode(listline, pbs, TRANSCODE_QUEUED);
@@ -1654,6 +1658,41 @@
     delete pginfo;
 }
 
+void MainServer::getGuideDataThrough(QDateTime &GuideDataThrough)
+{
+    QString querytext;
+
+    querytext = QString("SELECT max(endtime) FROM program;");
+
+    dblock.lock();
+    QSqlQuery query = m_db->exec(querytext);
+
+    if (query.isActive() && query.numRowsAffected())
+    {
+        query.next();
+        if (query.isValid())
+            GuideDataThrough = QDateTime::fromString(query.value(0).toString(),
+                                                     Qt::ISODate);
+    }
+    dblock.unlock();
+}
+
+void MainServer::HandleQueryGuideDataThrough(PlaybackSock *pbs)
+{
+    QDateTime GuideDataThrough;
+    QSocket *pbssock = pbs->getSocket();
+    QStringList strlist;
+
+    getGuideDataThrough(GuideDataThrough);
+
+    if (GuideDataThrough.isNull())
+        strlist << QString("0000-00-00 00:00");
+    else
+        strlist << QDateTime(GuideDataThrough).toString("yyyy-MM-dd hh:mm");
+
+    SendResponse(pbssock, strlist);
+}
+
 void MainServer::HandleGetPendingRecordings(PlaybackSock *pbs)
 {
     QSocket *pbssock = pbs->getSocket();
Index: programs/mythbackend/mainserver.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.h,v
retrieving revision 1.51
diff -u -r1.51 mainserver.h
--- programs/mythbackend/mainserver.h	24 Jan 2005 22:19:45 -0000	1.51
+++ programs/mythbackend/mainserver.h	28 Jan 2005 02:40:23 -0000
@@ -72,6 +72,7 @@
     void HandleRescheduleRecordings(int recordid, PlaybackSock *pbs);
     void HandleQueryFreeSpace(PlaybackSock *pbs);
     void HandleQueryCheckFile(QStringList &slist, PlaybackSock *pbs);
+    void HandleQueryGuideDataThrough(PlaybackSock *pbs);
     void HandleGetPendingRecordings(PlaybackSock *pbs);
     void HandleGetScheduledRecordings(PlaybackSock *pbs);
     void HandleGetConflictingRecordings(QStringList &slist, PlaybackSock *pbs);
@@ -104,6 +105,7 @@
     void SendResponse(QSocket *pbs, QStringList &commands);
 
     void getFreeSpace(int &total, int &used);
+    void getGuideDataThrough(QDateTime &GuideDataThrough);
 
     void PrintDVBStatus(QTextStream &os);
 
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

Reply via email to