]> git.vomp.tv Git - vompserver.git/commitdiff
Delete timer function
authorChris Tallon <chris@vomp.tv>
Sun, 21 Oct 2007 13:34:47 +0000 (13:34 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 21 Oct 2007 13:34:47 +0000 (13:34 +0000)
defines.h
mvpclient.c
mvpclient.h

index fc4e60f0a744908f87863c5191d92f1101de0db2..81a9a3b1d7b429f39e375e6f8eb186f298b2b254 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -29,4 +29,6 @@ typedef uint32_t UINT;
 typedef uint32_t ULONG;
 typedef uint64_t ULLONG;
 
+typedef int32_t INT;
+
 #endif
index 96f06768e100abc08f2c748f10026a2bee21b909..cbe04aab771b9ee76e600aee254f09c864c8ab6b 100644 (file)
@@ -260,6 +260,9 @@ void MVPClient::run2()
       case 22:
         result = processGetChannelPids(data, packetLength);
         break;
+      case 23:
+        result = processDeleteTimer(data, packetLength);
+        break;
       case 30:
         result = processGetMediaList(data, packetLength);
         break;
@@ -1566,6 +1569,8 @@ int MVPClient::processGetTimers(UCHAR* buffer, int length)
     *(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;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->Day());                    count += 4;
+    *(ULONG*)&sendBuffer[count] = htonl(timer->WeekDays());               count += 4;
 
     fileName = timer->File();
     strcpy((char*)&sendBuffer[count], fileName);
@@ -2126,4 +2131,56 @@ int MVPClient::processGetImageBlock(UCHAR* data, int length)
   return 1;
 }
 
+int MVPClient::processDeleteTimer(UCHAR* buffer, int length)
+{
+  log->log("Client", Log::DEBUG, "Delete timer called");
+  // get timer
+  
+  int position = 0;
+  
+  INT delChannel = ntohl(*(ULONG*)&buffer[position]); position += 4;
+  INT delWeekdays = ntohl(*(ULONG*)&buffer[position]); position += 4;
+  INT delDay = ntohl(*(ULONG*)&buffer[position]); position += 4;  
+  ULONG delStart = ntohl(*(ULONG*)&buffer[position]); position += 4;  
+  ULONG delStop = ntohl(*(ULONG*)&buffer[position]); position += 4;
+    
+  cTimer* ti = NULL;
+  for (ti = Timers.First(); ti; ti = Timers.Next(ti))
+  {
+    if  ( (ti->Channel()->Number() == delChannel)
+     &&   ((ti->WeekDays() && (ti->WeekDays() == delWeekdays)) || (!ti->WeekDays() && (ti->Day() == delDay)))
+     &&   (ti->StartTime() == delStart)
+     &&   (ti->StopTime() == delStop) )
+       break;
+  }
+  
+  if (!ti)
+  {
+    sendULONG(4);
+    return 1;
+  }
+          
+  if (!Timers.BeingEdited())
+  {
+    if (!ti->Recording())
+    {
+      Timers.Del(ti);
+      Timers.SetModified();
+      sendULONG(10);
+      return 1;
+    }
+    else
+    {
+      log->log("Client", Log::ERR, "Unable to delete timer - timer is running");
+      sendULONG(3);
+      return 1;
+    }  
+  }
+  else
+  {
+    log->log("Client", Log::ERR, "Unable to delete timer - timers being edited at VDR");
+    sendULONG(1);
+    return 1;
+  }  
+}
 
index a761ce00168f730201e610f519df57adf303a956..33cc926b751306571bcce5baf85d28c29c98463b 100644 (file)
@@ -93,6 +93,7 @@ class MVPClient
     int processGetMediaList(UCHAR* data, int length);
     int processGetPicture(UCHAR* data, int length);
     int processGetImageBlock(UCHAR* data, int length);
+    int processDeleteTimer(UCHAR* buffer, int length);
 
     int processReScanRecording(UCHAR* data, int length);           // FIXME obselete