From ea29b2231745dead10d8247de2e943aee5d64fff Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 21 Oct 2007 13:34:47 +0000 Subject: [PATCH] Delete timer function --- defines.h | 2 ++ mvpclient.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ mvpclient.h | 1 + 3 files changed, 60 insertions(+) diff --git a/defines.h b/defines.h index fc4e60f..81a9a3b 100644 --- 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 diff --git a/mvpclient.c b/mvpclient.c index 96f0676..cbe04aa 100644 --- a/mvpclient.c +++ b/mvpclient.c @@ -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; + } +} diff --git a/mvpclient.h b/mvpclient.h index a761ce0..33cc926 100644 --- a/mvpclient.h +++ b/mvpclient.h @@ -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 -- 2.39.2