]> git.vomp.tv Git - vompserver.git/commitdiff
Get timers function
authorChris Tallon <chris@vomp.tv>
Tue, 3 Jan 2006 17:53:38 +0000 (17:53 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 3 Jan 2006 17:53:38 +0000 (17:53 +0000)
mvpclient.c
mvpclient.h

index ce6b385784cbaaa6462e201daaaa525ec65ea87c..dd4a66c084450e5644d0361f4de1feee1736ad01 100644 (file)
@@ -61,6 +61,8 @@ MVPClient::MVPClient(int tsocket)
 
 //test(14);
 
+  test2();
+
 }
 
 MVPClient::~MVPClient()
@@ -230,6 +232,9 @@ void MVPClient::run2()
       case 13:
         result = processReScanRecording(data, packetLength);
         break;
+      case 14:
+        result = processGetTimers(data, packetLength);
+        break;
     }
 
     free(buffer);
@@ -1166,3 +1171,77 @@ Description
 IsPresent ? easy to work out tho. Oh it doesn't always work
 
 */
+
+
+void MVPClient::test2()
+{
+  log->log("-", Log::DEBUG, "Timers List");
+
+  for (int i = 0; i < Timers.Count(); i++)
+  {
+    cTimer *timer = Timers.Get(i);
+    //Reply(i < Timers.Count() - 1 ? -250 : 250, "%d %s", timer->Index() + 1, timer->ToText());
+    log->log("-", Log::DEBUG, "i=%i count=%i index=%d", i, Timers.Count(), timer->Index() + 1);
+    log->log("-", Log::DEBUG, "active=%i recording=%i pending=%i start=%li stop=%li priority=%i lifetime=%i", timer->Active(), timer->Recording(), timer->Pending(), timer->StartTime(), timer->StopTime(), timer->Priority(), timer->Lifetime());
+    log->log("-", Log::DEBUG, "channel=%i file=%s summary=%s", timer->Channel()->Number(), timer->File(), timer->Summary());
+    log->log("-", Log::DEBUG, "");
+  }
+
+  // asprintf(&buffer, "%d:%s:%s  :%04d:%04d:%d:%d:%s:%s\n",
+//            active, (UseChannelID ? Channel()->GetChannelID().ToString() : itoa(Channel()->Number())),
+//            PrintDay(day, firstday), start, stop, priority, lifetime, file, summary ? summary : "");
+}
+
+
+/*
+Active seems to be a bool - whether the timer should be done or not. If set to inactive it stays around after its time
+recording is a bool, 0 for not currently recording, 1 for currently recording
+pending is a bool, 0 for would not be trying to record this right now, 1 for would/is trying to record this right now
+*/
+
+
+int MVPClient::processGetTimers(UCHAR* buffer, int length)
+{
+  UCHAR* sendBuffer = new UCHAR[50000]; // FIXME hope this is enough
+  int count = 4; // leave space for the packet length
+
+  const char* string;
+  cTimer *timer;
+  int numTimers = Timers.Count();
+
+//  *(ULONG*)&sendBuffer[count] = htonl(numTimers);    count += 4;
+
+  for (int i = 0; i < numTimers; i++)
+  {
+    if (count > 49000) break;
+
+    timer = Timers.Get(i);
+
+    *(ULONG*)&sendBuffer[count] = htonl(timer->Active());                 count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->Recording());              count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->Pending());                count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->Priority());               count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->Lifetime());               count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->Channel()->Number());      count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->StartTime());              count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->StopTime());               count += 4;
+
+    string = timer->File();
+    strcpy((char*)&sendBuffer[count], string);
+    count += strlen(string) + 1;
+
+    string = timer->Summary();
+    strcpy((char*)&sendBuffer[count], string);
+    count += strlen(string) + 1;
+  }
+
+  *(ULONG*)&sendBuffer[0] = htonl(count - 4); // -4 :  take off the size field
+
+  log->log("Client", Log::DEBUG, "recorded size as %u", ntohl(*(ULONG*)&sendBuffer[0]));
+
+  tcp.sendPacket(sendBuffer, count);
+  delete[] sendBuffer;
+  log->log("Client", Log::DEBUG, "Written timers list");
+
+  return 1;
+}
index c48e937ec86ed6d9c21760adc912d7da87c5f9c2..b069f573e7107aa49bb5c7e0349c1c58c89b67f8 100644 (file)
@@ -32,6 +32,7 @@
 #include <vdr/channels.h>
 #include <vdr/videodir.h>
 #include <vdr/plugin.h>
+#include <vdr/timers.h>
 
 #include "defines.h"
 #include "tcp.h"
@@ -75,6 +76,7 @@ class MVPClient
     int processGetChannelSchedule(UCHAR* data, int length);
     int processConfigSave(UCHAR* data, int length);
     int processConfigLoad(UCHAR* data, int length);
+    int processGetTimers(UCHAR* data, int length);
 
     cChannel* channelFromNumber(ULONG channelNumber);
     void writeResumeData();