[mythtv] composite 6544 patch. time, upcoming, disk space, currently recording

Kirby Vandivort kvandivo at ks.uiuc.edu
Tue Sep 23 17:36:38 EDT 2003


I've attached a patch for mainserver.cpp/h that combines the 2 patches I
had sent earlier (which added the name of the currently recording show,
as well as info on disk space) along with new patches that show the
current server time in the title of the page returned as well as a list
of upcoming shows that myth is going to be recording.

This patch is against current cvs.


Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.81
diff -b -u -2 -r1.81 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	20 Sep 2003 04:52:36 -0000	1.81
+++ programs/mythbackend/mainserver.cpp	23 Sep 2003 21:30:23 -0000
@@ -1047,10 +1052,7 @@
 }
 
-void MainServer::HandleQueryFreeSpace(PlaybackSock *pbs)
+void MainServer::getFreeSpace(int &totalspace, int &usedspace)
 {
-    QSocket *pbssock = pbs->getSocket();
-
     struct statfs statbuf;
-    int totalspace = -1, usedspace = -1;
     if (statfs(recordfileprefix.ascii(), &statbuf) == 0) 
     {
@@ -1078,6 +1080,6 @@
     }
 
-    QStringList strlist;
-    QString filename = gContext->GetSetting("RecordFilePrefix") + "/nfslockfile.lock";
+    QString filename = gContext->GetSetting("RecordFilePrefix") + 
+                                             "/nfslockfile.lock";
     QFile checkFile(filename);
 
@@ -1090,5 +1092,15 @@
         }
     }
+}
 
+void MainServer::HandleQueryFreeSpace(PlaybackSock *pbs)
+{
+    QSocket *pbssock = pbs->getSocket();
+
+    int totalspace = -1, usedspace = -1;
+
+    getFreeSpace(totalspace, usedspace);
+
+    QStringList strlist;
     strlist << QString::number(totalspace) << QString::number(usedspace);
     SendResponse(pbssock, strlist);
@@ -2289,6 +2325,11 @@
 {
     QTextStream os(socket);
+    QString shortdateformat = gContext->GetSetting("ShortDateFormat", "M/d");
+    QString timeformat = gContext->GetSetting("TimeFormat", "h:mm AP");
+
     os.setEncoding(QTextStream::UnicodeUTF8);
 
+    QDateTime qdtNow = QDateTime::currentDateTime();
+
     os << "HTTP/1.0 200 Ok\r\n"
        << "Content-Type: text/html; charset=\"utf-8\"\r\n"
@@ -2297,8 +2338,12 @@
     os << "<HTTP>\r\n"
        << "<HEAD>\r\n"
-       << "  <TITLE>MythTV Status</TITLE>\r\n"
+       << "  <TITLE>MythTV Status - " 
+            << qdtNow.toString(shortdateformat) 
+            << " " << qdtNow.toString(timeformat) << "</TITLE>\r\n"
        << "</HEAD>\r\n"
        << "<BODY>\r\n";
 
+
+    // encoder information ---------------------
     QMap<int, EncoderLink *>::Iterator iter = encoderList->begin();
     for (; iter != encoderList->end(); ++iter)
@@ -2320,5 +2365,13 @@
 
         if (elink->IsBusyRecording())
-            os << "is recording.\r\n";
+	{
+            os << "is recording";
+            if (elink->isLocal())
+	    {
+               ProgramInfo *pi = elink->GetRecording();
+	       os << " '" << pi->title << "'";
+	    }
+            os << ".\r\n";
+	}
         else
             os << "is not recording.\r\n";
@@ -2327,4 +2380,76 @@
     }
 
+    // upcoming shows ---------------------
+    dblock.lock();
+    MythContext::KickDatabase(m_db);
+    Scheduler *sched = new Scheduler(false, encoderList, m_db);
+    sched->FillRecordLists(false);
+    list<ProgramInfo *> *recordinglist = sched->getAllPending();
+    dblock.unlock();
+
+    unsigned int iNum = 3;
+    if (recordinglist->size() < iNum) 
+    {
+       iNum = recordinglist->size();
+    }
+
+    if (0 == iNum)
+    {
+       os << "<P>There are no shows scheduled for recording.\r\n";
+    }
+    else
+    {
+
+       os << "<P>The next " << iNum << " show" << (iNum == 1 ? "" : "s" )
+          << " that " << (iNum == 1 ? "is" : "are") 
+	  << " scheduled for recording:<BR>\r\n";
+
+       os << "<TABLE WIDTH=80%>\r\n"; 
+       os << "<TR><TH>Start Time</TH><TH>Show</TH><TH>Encoder</TH></TR>\r\n";
+       list<ProgramInfo *>::iterator iter = recordinglist->begin();
+       for (unsigned int i=0; (iter != recordinglist->end()) && i<iNum; 
+                                                          iter++,i++)
+       {
+          if (! (*iter)->recording) // skip it, and don't count it as
+	  {                          // one of our number
+	     i--;
+	  }
+	  else
+	  {
+             os << "<TR>" 
+	        << "<TD>" << ((*iter)->startts).toString(shortdateformat) 
+                  << " " << ((*iter)->startts).toString(timeformat) << "</TD>" 
+                << "<TD>" << (*iter)->title << "</TD>"
+                << "<TD>" << (*iter)->cardid << "</TD></TR>\r\n";
+	  }
+       }
+       os << "</TABLE>";
+    }
+
+
+
+    // drive space   ---------------------
+    int iTotal = -1, iUsed = -1;
+    QString rep;
+
+    getFreeSpace(iTotal, iUsed);
+
+    os << "<P>Disk Usage:\r\n";
+
+    os << "<UL><LI>Total Space: ";
+    rep.sprintf(tr("%d,%03d MB "), (iTotal) / 1000,
+                                             (iTotal) % 1000);
+    os << rep << "\r\n";
+
+    os << "<LI>Space Used: ";
+    rep.sprintf(tr("%d,%03d MB "), (iUsed) / 1000,
+                                             (iUsed) % 1000);
+    os << rep << "\r\n";
+
+    os << "<LI>Space Free: ";
+    rep.sprintf(tr("%d,%03d MB "), (iTotal - iUsed) / 1000,
+                                             (iTotal - iUsed) % 1000);
+    os << rep << "</UL>\r\n";
+
     os << "</BODY>\r\n"
        << "</HTTP>\r\n";
Index: programs/mythbackend/mainserver.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.h,v
retrieving revision 1.33
diff -b -u -2 -r1.33 mainserver.h
--- programs/mythbackend/mainserver.h	20 Sep 2003 01:38:07 -0000	1.33
+++ programs/mythbackend/mainserver.h	23 Sep 2003 21:30:23 -0000
@@ -81,4 +82,6 @@
     void SendResponse(QSocket *pbs, QStringList &commands);
 
+    void getFreeSpace(int &total, int &used);
+
     PlaybackSock *getSlaveByHostname(QString &hostname);
     PlaybackSock *getPlaybackBySock(QSocket *socket);


-- 

Kirby Vandivort                      Theoretical and 
Senior Research Programmer            Computational Biophysics 
Email: kvandivo at ks.uiuc.edu          3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
Phone: (217) 244-5711                405 N. Mathews Ave
Fax  : (217) 244-6078                Urbana, IL  61801, USA


More information about the mythtv-dev mailing list