2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "mvpclient.h"
23 #include "responsepacket.h"
25 // This is here else it causes compile errors with something in libdvbmpeg
26 //#include <vdr/menu.h>
28 pthread_mutex_t threadClientMutex;
29 int MVPClient::nr_clients = 0;
32 MVPClient::MVPClient(Config* cfgBase, char* tconfigDirExtra, int tsocket)
35 #ifndef VOMPSTANDALONE
38 recordingManager = NULL;
41 log = Log::getInstance();
43 configDirExtra = tconfigDirExtra;
48 MVPClient::~MVPClient()
50 log->log("Client", Log::DEBUG, "MVP client destructor");
51 #ifndef VOMPSTANDALONE
62 delete recordingManager;
64 recordingManager = NULL;
67 if (loggedIn) cleanConfig();
71 void MVPClient::incClients()
73 pthread_mutex_lock(&threadClientMutex);
74 MVPClient::nr_clients++;
75 pthread_mutex_unlock(&threadClientMutex);
78 void MVPClient::decClients()
80 pthread_mutex_lock(&threadClientMutex);
81 MVPClient::nr_clients--;
82 pthread_mutex_unlock(&threadClientMutex);
85 int MVPClient::getNrClients()
88 pthread_mutex_lock(&threadClientMutex);
89 nrClients = MVPClient::nr_clients;
90 pthread_mutex_unlock(&threadClientMutex);
94 ULLONG MVPClient::ntohll(ULLONG a)
99 ULLONG MVPClient::htonll(ULLONG a)
101 #if BYTE_ORDER == BIG_ENDIAN
106 b = ((a << 56) & 0xFF00000000000000ULL)
107 | ((a << 40) & 0x00FF000000000000ULL)
108 | ((a << 24) & 0x0000FF0000000000ULL)
109 | ((a << 8) & 0x000000FF00000000ULL)
110 | ((a >> 8) & 0x00000000FF000000ULL)
111 | ((a >> 24) & 0x0000000000FF0000ULL)
112 | ((a >> 40) & 0x000000000000FF00ULL)
113 | ((a >> 56) & 0x00000000000000FFULL) ;
119 #ifndef VOMPSTANDALONE
120 cChannel* MVPClient::channelFromNumber(ULONG channelNumber)
122 cChannel* channel = NULL;
124 for (channel = Channels.First(); channel; channel = Channels.Next(channel))
126 if (!channel->GroupSep())
128 log->log("Client", Log::DEBUG, "Looking for channel %lu::: number: %i name: '%s'", channelNumber, channel->Number(), channel->Name());
130 if (channel->Number() == (int)channelNumber)
132 int vpid = channel->Vpid();
133 #if VDRVERSNUM < 10300
134 int apid1 = channel->Apid1();
136 int apid1 = channel->Apid(0);
138 log->log("Client", Log::DEBUG, "Found channel number %lu, vpid = %i, apid1 = %i", channelNumber, vpid, apid1);
146 log->log("Client", Log::DEBUG, "Channel not found");
152 void MVPClient::writeResumeData()
154 config.setValueLong("ResumeData",
155 (char*)recplayer->getCurrentRecording()->FileName(),
156 recplayer->frameNumberFromPosition(recplayer->getLastPosition()) );
160 void MVPClient::cleanConfig()
162 log->log("Client", Log::DEBUG, "Clean config");
164 #ifndef VOMPSTANDALONE
166 cRecordings Recordings;
171 char* resumes = config.getSectionKeyNames("ResumeData", numReturns, length);
172 char* position = resumes;
173 for(int k = 0; k < numReturns; k++)
175 log->log("Client", Log::DEBUG, "EXAMINING: %i %i %p %s", k, numReturns, position, position);
177 cRecording* recording = Recordings.GetByName(position);
180 // doesn't exist anymore
181 log->log("Client", Log::DEBUG, "Found a recording that doesn't exist anymore");
182 config.deleteValue("ResumeData", position);
186 log->log("Client", Log::DEBUG, "This recording still exists");
189 position += strlen(position) + 1;
196 void MVPClientStartThread(void* arg)
198 MVPClient* m = (MVPClient*)arg;
200 // Nothing external to this class has a reference to it
201 // This is the end of the thread.. so delete m
208 if (pthread_create(&runThread, NULL, (void*(*)(void*))MVPClientStartThread, (void *)this) == -1) return 0;
209 log->log("Client", Log::DEBUG, "MVPClient run success");
213 void MVPClient::run2()
218 pthread_sigmask(SIG_BLOCK, &sigset, NULL);
219 pthread_detach(runThread); // Detach
221 tcp.disableReadTimeout();
223 tcp.setSoKeepTime(3);
224 tcp.setNonBlocking();
229 ULONG extraDataLength;
236 log->log("Client", Log::DEBUG, "Waiting");
238 if (!tcp.readData((UCHAR*)&channelID, sizeof(ULONG))) break;
239 channelID = ntohl(channelID);
242 log->log("Client", Log::ERR, "Incoming channel number not 1!");
246 log->log("Client", Log::DEBUG, "Got chan");
248 if (!tcp.readData((UCHAR*)&requestID, sizeof(ULONG))) break;
249 requestID = ntohl(requestID);
251 log->log("Client", Log::DEBUG, "Got ser");
253 if (!tcp.readData((UCHAR*)&opcode, sizeof(ULONG))) break;
254 opcode = ntohl(opcode);
256 log->log("Client", Log::DEBUG, "Got op %lu", opcode);
258 if (!tcp.readData((UCHAR*)&extraDataLength, sizeof(ULONG))) break;
259 extraDataLength = ntohl(extraDataLength);
260 if (extraDataLength > 200000)
262 log->log("Client", Log::ERR, "ExtraDataLength > 200000!");
266 log->log("Client", Log::DEBUG, "Got edl %lu", extraDataLength);
270 data = (UCHAR*)malloc(extraDataLength);
273 log->log("Client", Log::ERR, "Extra data buffer malloc error");
277 if (!tcp.readData(data, extraDataLength))
279 log->log("Client", Log::ERR, "Could not read extradata");
289 log->log("Client", Log::DEBUG, "Received chan=%lu, ser=%lu, op=%lu, edl=%lu", channelID, requestID, opcode, extraDataLength);
291 if (!loggedIn && (opcode != 1))
293 log->log("Client", Log::ERR, "Not logged in and opcode != 1");
294 if (data) free(data);
298 ResponsePacket* rp = new ResponsePacket();
299 if (!rp->init(requestID))
301 log->log("Client", Log::ERR, "response packet init fail");
308 result = processLogin(data, extraDataLength, rp);
310 #ifndef VOMPSTANDALONE
312 result = processGetRecordingsList(data, extraDataLength, rp);
315 result = processDeleteRecording(data, extraDataLength, rp);
318 result = processGetChannelsList(data, extraDataLength, rp);
321 result = processStartStreamingChannel(data, extraDataLength, requestID, rp);
324 result = processGetBlock(data, extraDataLength, rp);
327 result = processStopStreaming(data, extraDataLength, rp);
330 result = processStartStreamingRecording(data, extraDataLength, rp);
334 result = processGetChannelSchedule(data, extraDataLength, rp);
337 result = processConfigSave(data, extraDataLength, rp);
340 result = processConfigLoad(data, extraDataLength, rp);
342 #ifndef VOMPSTANDALONE
344 result = processReScanRecording(data, extraDataLength, rp); // FIXME obselete
347 result = processGetTimers(data, extraDataLength, rp);
350 result = processSetTimer(data, extraDataLength, rp);
353 result = processPositionFromFrameNumber(data, extraDataLength, rp);
356 result = processFrameNumberFromPosition(data, extraDataLength, rp);
359 result = processMoveRecording(data, extraDataLength, rp);
362 result = processGetIFrame(data, extraDataLength, rp);
365 result = processGetRecInfo(data, extraDataLength, rp);
368 result = processGetMarks(data, extraDataLength, rp);
371 result = processGetChannelPids(data, extraDataLength, rp);
374 result = processDeleteTimer(data, extraDataLength, rp);
378 result = processGetMediaList(data, extraDataLength, rp);
381 result = processGetPicture(data, extraDataLength, rp);
384 result = processGetImageBlock(data, extraDataLength, rp);
388 if (data) free(data);
393 int MVPClient::processLogin(UCHAR* buffer, int length, ResponsePacket* rp)
395 if (length != 6) return 0;
399 #ifndef VOMPSTANDALONE
400 const char* configDir = cPlugin::ConfigDirectory(configDirExtra);
402 const char* configDir = ".";
406 log->log("Client", Log::DEBUG, "No config dir!");
410 char configFileName[PATH_MAX];
411 snprintf(configFileName, PATH_MAX, "%s/vomp-%02X-%02X-%02X-%02X-%02X-%02X.conf", configDir, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
412 config.init(configFileName);
414 // Send the login reply
416 time_t timeNow = time(NULL);
417 struct tm* timeStruct = localtime(&timeNow);
418 int timeOffset = timeStruct->tm_gmtoff;
420 rp->addULONG(timeNow);
421 rp->addLONG(timeOffset);
423 tcp.sendPacket(rp->getPtr(), rp->getLen());
424 log->log("Client", Log::DEBUG, "written login reply len %lu", rp->getLen());
431 #ifndef VOMPSTANDALONE
432 int MVPClient::processGetRecordingsList(UCHAR* data, int length, ResponsePacket* rp)
435 int Percent = VideoDiskSpace(&FreeMB);
436 int Total = (FreeMB / (100 - Percent)) * 100;
439 rp->addULONG(FreeMB);
440 rp->addULONG(Percent);
442 cRecordings Recordings;
445 for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording))
447 rp->addULONG(recording->start);
448 rp->addString(recording->Name());
449 rp->addString(recording->FileName());
453 tcp.sendPacket(rp->getPtr(), rp->getLen());
456 log->log("Client", Log::DEBUG, "Written recordings list");
461 int MVPClient::processDeleteRecording(UCHAR* data, int length, ResponsePacket* rp)
463 // data is a pointer to the fileName string
465 cRecordings Recordings;
466 Recordings.Load(); // probably have to do this
468 cRecording* recording = Recordings.GetByName((char*)data);
470 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
474 log->log("Client", Log::DEBUG, "deleting recording: %s", recording->Name());
476 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
479 if (recording->Delete())
481 // Copy svdrp's way of doing this, see if it works
482 #if VDRVERSNUM > 10300
483 ::Recordings.DelByName(recording->FileName());
503 tcp.sendPacket(rp->getPtr(), rp->getLen());
509 int MVPClient::processMoveRecording(UCHAR* data, int length, ResponsePacket* rp)
511 log->log("Client", Log::DEBUG, "Process move recording");
512 char* fileName = (char*)data;
513 char* newPath = NULL;
515 for (int k = 0; k < length; k++)
519 newPath = (char*)&data[k+1];
523 if (!newPath) return 0;
525 cRecordings Recordings;
526 Recordings.Load(); // probably have to do this
528 cRecording* recording = Recordings.GetByName((char*)fileName);
530 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
534 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
537 log->log("Client", Log::DEBUG, "moving recording: %s", recording->Name());
538 log->log("Client", Log::DEBUG, "moving recording: %s", recording->FileName());
539 log->log("Client", Log::DEBUG, "to: %s", newPath);
541 const char* t = recording->FileName();
543 char* dateDirName = NULL; int k;
544 char* titleDirName = NULL; int j;
546 // Find the datedirname
547 for(k = strlen(t) - 1; k >= 0; k--)
551 log->log("Client", Log::DEBUG, "l1: %i", strlen(&t[k+1]) + 1);
552 dateDirName = new char[strlen(&t[k+1]) + 1];
553 strcpy(dateDirName, &t[k+1]);
558 // Find the titledirname
560 for(j = k-1; j >= 0; j--)
564 log->log("Client", Log::DEBUG, "l2: %i", (k - j - 1) + 1);
565 titleDirName = new char[(k - j - 1) + 1];
566 memcpy(titleDirName, &t[j+1], k - j - 1);
567 titleDirName[k - j - 1] = '\0';
572 log->log("Client", Log::DEBUG, "datedirname: %s", dateDirName);
573 log->log("Client", Log::DEBUG, "titledirname: %s", titleDirName);
575 log->log("Client", Log::DEBUG, "viddir: %s", VideoDirectory);
577 char* newContainer = new char[strlen(VideoDirectory) + strlen(newPath) + strlen(titleDirName) + 1];
578 log->log("Client", Log::DEBUG, "l10: %i", strlen(VideoDirectory) + strlen(newPath) + strlen(titleDirName) + 1);
579 sprintf(newContainer, "%s%s%s", VideoDirectory, newPath, titleDirName);
581 // FIXME Check whether this already exists before mkdiring it
583 log->log("Client", Log::DEBUG, "%s", newContainer);
587 int statret = stat(newContainer, &dstat);
588 if ((statret == -1) && (errno == ENOENT)) // Dir does not exist
590 log->log("Client", Log::DEBUG, "new dir does not exist");
591 int mkdirret = mkdir(newContainer, 0755);
594 delete[] dateDirName;
595 delete[] titleDirName;
596 delete[] newContainer;
600 tcp.sendPacket(rp->getPtr(), rp->getLen());
605 else if ((statret == 0) && (! (dstat.st_mode && S_IFDIR))) // Something exists but it's not a dir
607 delete[] dateDirName;
608 delete[] titleDirName;
609 delete[] newContainer;
613 tcp.sendPacket(rp->getPtr(), rp->getLen());
618 // Ok, the directory container has been made, or it pre-existed.
620 char* newDir = new char[strlen(newContainer) + 1 + strlen(dateDirName) + 1];
621 sprintf(newDir, "%s/%s", newContainer, dateDirName);
623 log->log("Client", Log::DEBUG, "doing rename '%s' '%s'", t, newDir);
624 int renameret = rename(t, newDir);
627 // Success. Test for remove old dir containter
628 char* oldTitleDir = new char[k+1];
629 memcpy(oldTitleDir, t, k);
630 oldTitleDir[k] = '\0';
631 log->log("Client", Log::DEBUG, "len: %i, cp: %i, strlen: %i, oldtitledir: %s", k+1, k, strlen(oldTitleDir), oldTitleDir);
632 rmdir(oldTitleDir); // can't do anything about a fail result at this point.
633 delete[] oldTitleDir;
638 #if VDRVERSNUM > 10311
640 ::Recordings.Update();
642 // Success. Send a different packet from just a ulong
643 rp->addULONG(1); // success
644 rp->addString(newDir);
652 tcp.sendPacket(rp->getPtr(), rp->getLen());
655 delete[] dateDirName;
656 delete[] titleDirName;
657 delete[] newContainer;
664 tcp.sendPacket(rp->getPtr(), rp->getLen());
672 tcp.sendPacket(rp->getPtr(), rp->getLen());
679 int MVPClient::processGetChannelsList(UCHAR* data, int length, ResponsePacket* rp)
683 char* chanConfig = config.getValueString("General", "Channels");
685 if (chanConfig) allChans = strcasecmp(chanConfig, "FTA only");
687 for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel))
689 #if VDRVERSNUM < 10300
690 if (!channel->GroupSep() && (!channel->Ca() || allChans))
692 if (!channel->GroupSep() && (!channel->Ca(0) || allChans))
695 log->log("Client", Log::DEBUG, "name: '%s'", channel->Name());
697 if (channel->Vpid()) type = 1;
698 #if VDRVERSNUM < 10300
701 else if (channel->Apid(0)) type = 2;
705 rp->addULONG(channel->Number());
707 rp->addString(channel->Name());
712 tcp.sendPacket(rp->getPtr(), rp->getLen());
715 log->log("Client", Log::DEBUG, "Written channels list");
720 int MVPClient::processGetChannelPids(UCHAR* data, int length, ResponsePacket* rp)
722 ULONG channelNumber = ntohl(*(ULONG*)data);
724 cChannel* channel = channelFromNumber(channelNumber);
729 tcp.sendPacket(rp->getPtr(), rp->getLen());
736 #if VDRVERSNUM < 10300
738 log->log("Client", Log::DEBUG, "Apid1: %i", channel->Apid1());
739 log->log("Client", Log::DEBUG, "Apid2: %i", channel->Apid2());
741 if (channel->Apid2())
743 else if (channel->Apid1())
750 for (const int *Apid = channel->Apids(); *Apid; Apid++)
757 // Format of response
765 rp->addULONG(channel->Vpid());
766 rp->addULONG(numApids);
768 #if VDRVERSNUM < 10300
771 rp->addULONG(channel->Apid1());
776 rp->addULONG(channel->Apid2());
780 for (ULONG i = 0; i < numApids; i++)
782 rp->addULONG(channel->Apid(i));
783 rp->addString(channel->Alang(i));
788 tcp.sendPacket(rp->getPtr(), rp->getLen());
791 log->log("Client", Log::DEBUG, "Written channels pids");
796 int MVPClient::processStartStreamingChannel(UCHAR* data, int length, ULONG streamID, ResponsePacket* rp)
798 log->log("Client", Log::DEBUG, "length = %i", length);
799 ULONG channelNumber = ntohl(*(ULONG*)data);
801 cChannel* channel = channelFromNumber(channelNumber);
806 tcp.sendPacket(rp->getPtr(), rp->getLen());
811 // get the priority we should use
813 int priority = config.getValueLong("General", "Live priority", &fail);
816 log->log("Client", Log::DEBUG, "Config: Live TV priority: %i", priority);
820 log->log("Client", Log::DEBUG, "Config: Live TV priority config fail");
825 if (priority < 0) priority = 0;
826 if (priority > 99) priority = 99;
828 log->log("Client", Log::DEBUG, "Using live TV priority %i", priority);
829 lp = MVPReceiver::create(channel, priority);
835 tcp.sendPacket(rp->getPtr(), rp->getLen());
840 if (!lp->init(&tcp, streamID))
846 tcp.sendPacket(rp->getPtr(), rp->getLen());
853 tcp.sendPacket(rp->getPtr(), rp->getLen());
858 int MVPClient::processStopStreaming(UCHAR* data, int length, ResponsePacket* rp)
860 log->log("Client", Log::DEBUG, "STOP STREAMING RECEIVED");
871 delete recordingManager;
873 recordingManager = NULL;
878 tcp.sendPacket(rp->getPtr(), rp->getLen());
883 int MVPClient::processGetBlock(UCHAR* data, int length, ResponsePacket* rp)
885 if (!lp && !recplayer)
887 log->log("Client", Log::DEBUG, "Get block called when no streaming happening!");
891 ULLONG position = ntohll(*(ULLONG*)data);
892 data += sizeof(ULLONG);
893 ULONG amount = ntohl(*(ULONG*)data);
895 log->log("Client", Log::DEBUG, "getblock pos = %llu length = %lu", position, amount);
897 UCHAR sendBuffer[amount];
898 ULONG amountReceived = 0; // compiler moan.
901 log->log("Client", Log::DEBUG, "getting from live");
902 amountReceived = lp->getBlock(&sendBuffer[0], amount);
906 // vdr has possibly disconnected the receiver
907 log->log("Client", Log::DEBUG, "VDR has disconnected the live receiver");
914 log->log("Client", Log::DEBUG, "getting from recording");
915 amountReceived = recplayer->getBlock(&sendBuffer[0], position, amount);
921 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
925 rp->copyin(sendBuffer, amountReceived);
926 log->log("Client", Log::DEBUG, "written %lu", amountReceived);
930 tcp.sendPacket(rp->getPtr(), rp->getLen());
931 log->log("Client", Log::DEBUG, "Finished getblock, have sent %lu", rp->getLen());
936 int MVPClient::processStartStreamingRecording(UCHAR* data, int length, ResponsePacket* rp)
938 // data is a pointer to the fileName string
940 recordingManager = new cRecordings;
941 recordingManager->Load();
943 cRecording* recording = recordingManager->GetByName((char*)data);
945 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
949 recplayer = new RecPlayer(recording);
951 rp->addULONG(recplayer->getLengthBytes());
952 rp->addULONG(recplayer->getLengthFrames());
954 tcp.sendPacket(rp->getPtr(), rp->getLen());
957 log->log("Client", Log::DEBUG, "written totalLength");
961 delete recordingManager;
962 recordingManager = NULL;
967 int MVPClient::processPositionFromFrameNumber(UCHAR* data, int length, ResponsePacket* rp)
971 ULONG frameNumber = ntohl(*(ULONG*)data);
976 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
980 retval = recplayer->positionFromFrameNumber(frameNumber);
983 rp->addULONG(retval);
985 tcp.sendPacket(rp->getPtr(), rp->getLen());
988 log->log("Client", Log::DEBUG, "Wrote posFromFrameNum reply to client");
992 int MVPClient::processFrameNumberFromPosition(UCHAR* data, int length, ResponsePacket* rp)
996 ULLONG position = ntohll(*(ULLONG*)data);
1001 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
1005 retval = recplayer->frameNumberFromPosition(position);
1008 rp->addULONG(retval);
1010 tcp.sendPacket(rp->getPtr(), rp->getLen());
1013 log->log("Client", Log::DEBUG, "Wrote frameNumFromPos reply to client");
1017 int MVPClient::processGetIFrame(UCHAR* data, int length, ResponsePacket* rp)
1019 bool success = false;
1021 ULONG frameNumber = ntohl(*(ULONG*)data);
1023 ULONG direction = ntohl(*(ULONG*)data);
1026 ULLONG rfilePosition = 0;
1027 ULONG rframeNumber = 0;
1028 ULONG rframeLength = 0;
1032 log->log("Client", Log::DEBUG, "GetIFrame recording called when no recording being played!");
1036 success = recplayer->getNextIFrame(frameNumber, direction, &rfilePosition, &rframeNumber, &rframeLength);
1039 // returns file position, frame number, length
1043 rp->addULLONG(rfilePosition);
1044 rp->addULONG(rframeNumber);
1045 rp->addULONG(rframeLength);
1053 tcp.sendPacket(rp->getPtr(), rp->getLen());
1056 log->log("Client", Log::DEBUG, "Wrote GNIF reply to client %llu %lu %lu", rfilePosition, rframeNumber, rframeLength);
1060 int MVPClient::processGetChannelSchedule(UCHAR* data, int length, ResponsePacket* rp)
1062 ULONG channelNumber = ntohl(*(ULONG*)data);
1064 ULONG startTime = ntohl(*(ULONG*)data);
1066 ULONG duration = ntohl(*(ULONG*)data);
1068 log->log("Client", Log::DEBUG, "get schedule called for channel %lu", channelNumber);
1070 cChannel* channel = channelFromNumber(channelNumber);
1075 tcp.sendPacket(rp->getPtr(), rp->getLen());
1078 log->log("Client", Log::DEBUG, "written 0 because channel = NULL");
1082 log->log("Client", Log::DEBUG, "Got channel");
1084 #if VDRVERSNUM < 10300
1085 cMutexLock MutexLock;
1086 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1088 cSchedulesLock MutexLock;
1089 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1095 tcp.sendPacket(rp->getPtr(), rp->getLen());
1098 log->log("Client", Log::DEBUG, "written 0 because Schedule!s! = NULL");
1102 log->log("Client", Log::DEBUG, "Got schedule!s! object");
1104 const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
1109 tcp.sendPacket(rp->getPtr(), rp->getLen());
1112 log->log("Client", Log::DEBUG, "written 0 because Schedule = NULL");
1116 log->log("Client", Log::DEBUG, "Got schedule object");
1118 const char* empty = "";
1119 bool atLeastOneEvent = false;
1122 ULONG thisEventTime;
1123 ULONG thisEventDuration;
1124 const char* thisEventTitle;
1125 const char* thisEventSubTitle;
1126 const char* thisEventDescription;
1128 #if VDRVERSNUM < 10300
1130 const cEventInfo *event;
1131 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1133 event = Schedule->GetEventNumber(eventNumber);
1135 thisEventID = event->GetEventID();
1136 thisEventTime = event->GetTime();
1137 thisEventDuration = event->GetDuration();
1138 thisEventTitle = event->GetTitle();
1139 thisEventSubTitle = event->GetSubtitle();
1140 thisEventDescription = event->GetExtendedDescription();
1144 for (const cEvent* event = Schedule->Events()->First(); event; event = Schedule->Events()->Next(event))
1146 thisEventID = event->EventID();
1147 thisEventTime = event->StartTime();
1148 thisEventDuration = event->Duration();
1149 thisEventTitle = event->Title();
1150 thisEventSubTitle = NULL;
1151 thisEventDescription = event->Description();
1155 log->log("Client", Log::DEBUG, "Got an event object %p", event);
1157 //in the past filter
1158 if ((thisEventTime + thisEventDuration) < (ULONG)time(NULL)) continue;
1161 if ((thisEventTime + thisEventDuration) <= startTime) continue;
1164 if (thisEventTime >= (startTime + duration)) continue;
1166 if (!thisEventTitle) thisEventTitle = empty;
1167 if (!thisEventSubTitle) thisEventSubTitle = empty;
1168 if (!thisEventDescription) thisEventDescription = empty;
1170 rp->addULONG(thisEventID);
1171 rp->addULONG(thisEventTime);
1172 rp->addULONG(thisEventDuration);
1174 rp->addString(thisEventTitle);
1175 rp->addString(thisEventSubTitle);
1176 rp->addString(thisEventDescription);
1178 atLeastOneEvent = true;
1179 log->log("Client", Log::DEBUG, "Done s3");
1182 log->log("Client", Log::DEBUG, "Got all event data");
1184 if (!atLeastOneEvent)
1187 log->log("Client", Log::DEBUG, "Written 0 because no data");
1191 tcp.sendPacket(rp->getPtr(), rp->getLen());
1194 log->log("Client", Log::DEBUG, "written schedules packet");
1199 #endif //VOMPSTANDALONE
1201 int MVPClient::processConfigSave(UCHAR* buffer, int length, ResponsePacket* rp)
1203 char* section = (char*)buffer;
1207 for (int k = 0; k < length; k++)
1209 if (buffer[k] == '\0')
1213 key = (char*)&buffer[k+1];
1217 value = (char*)&buffer[k+1];
1223 // if the last string (value) doesnt have null terminator, give up
1224 if (buffer[length - 1] != '\0') return 0;
1226 log->log("Client", Log::DEBUG, "Config save: %s %s %s", section, key, value);
1227 if (config.setValueString(section, key, value))
1237 tcp.sendPacket(rp->getPtr(), rp->getLen());
1243 int MVPClient::processConfigLoad(UCHAR* buffer, int length, ResponsePacket* rp)
1245 char* section = (char*)buffer;
1248 for (int k = 0; k < length; k++)
1250 if (buffer[k] == '\0')
1252 key = (char*)&buffer[k+1];
1257 char* value = config.getValueString(section, key);
1261 rp->addString(value);
1262 log->log("Client", Log::DEBUG, "Written config load packet");
1268 log->log("Client", Log::DEBUG, "Written config load failed packet");
1272 tcp.sendPacket(rp->getPtr(), rp->getLen());
1278 #ifndef VOMPSTANDALONE
1280 int MVPClient::processGetTimers(UCHAR* buffer, int length, ResponsePacket* rp)
1283 int numTimers = Timers.Count();
1285 rp->addULONG(numTimers);
1287 for (int i = 0; i < numTimers; i++)
1289 timer = Timers.Get(i);
1291 #if VDRVERSNUM < 10300
1292 rp->addULONG(timer->Active());
1294 rp->addULONG(timer->HasFlags(tfActive));
1296 rp->addULONG(timer->Recording());
1297 rp->addULONG(timer->Pending());
1298 rp->addULONG(timer->Priority());
1299 rp->addULONG(timer->Lifetime());
1300 rp->addULONG(timer->Channel()->Number());
1301 rp->addULONG(timer->StartTime());
1302 rp->addULONG(timer->StopTime());
1303 rp->addULONG(timer->Day());
1304 rp->addULONG(timer->WeekDays());
1305 rp->addString(timer->File());
1309 tcp.sendPacket(rp->getPtr(), rp->getLen());
1312 log->log("Client", Log::DEBUG, "Written timers list");
1317 int MVPClient::processSetTimer(UCHAR* buffer, int length, ResponsePacket* rp)
1319 char* timerString = new char[strlen((char*)buffer) + 1];
1320 strcpy(timerString, (char*)buffer);
1322 #if VDRVERSNUM < 10300
1324 // If this is VDR 1.2 the date part of the timer string must be reduced
1325 // to just DD rather than YYYY-MM-DD
1327 int s = 0; // source
1328 int d = 0; // destination
1330 while(c != 2) // copy up to date section, including the second ':'
1332 timerString[d] = buffer[s];
1333 if (buffer[s] == ':') c++;
1337 // now it has copied up to the date section
1339 while(c != 2) // waste YYYY-MM-
1341 if (buffer[s] == '-') c++;
1344 // now source is at the DD
1345 memcpy(&timerString[d], &buffer[s], length - s);
1347 timerString[d] = '\0';
1349 log->log("Client", Log::DEBUG, "Timer string after 1.2 conversion:");
1350 log->log("Client", Log::DEBUG, "%s", timerString);
1354 cTimer *timer = new cTimer;
1355 if (timer->Parse((char*)timerString))
1357 cTimer *t = Timers.GetTimer(timer);
1361 #if VDRVERSNUM < 10300
1364 Timers.SetModified();
1368 tcp.sendPacket(rp->getPtr(), rp->getLen());
1376 tcp.sendPacket(rp->getPtr(), rp->getLen());
1384 tcp.sendPacket(rp->getPtr(), rp->getLen());
1391 int MVPClient::processDeleteTimer(UCHAR* buffer, int length, ResponsePacket* rp)
1393 log->log("Client", Log::DEBUG, "Delete timer called");
1398 INT delChannel = ntohl(*(ULONG*)&buffer[position]); position += 4;
1399 INT delWeekdays = ntohl(*(ULONG*)&buffer[position]); position += 4;
1400 INT delDay = ntohl(*(ULONG*)&buffer[position]); position += 4;
1401 INT delStart = ntohl(*(ULONG*)&buffer[position]); position += 4;
1402 INT delStop = ntohl(*(ULONG*)&buffer[position]); position += 4;
1405 for (ti = Timers.First(); ti; ti = Timers.Next(ti))
1407 if ( (ti->Channel()->Number() == delChannel)
1408 && ((ti->WeekDays() && (ti->WeekDays() == delWeekdays)) || (!ti->WeekDays() && (ti->Day() == delDay)))
1409 && (ti->StartTime() == delStart)
1410 && (ti->StopTime() == delStop) )
1418 tcp.sendPacket(rp->getPtr(), rp->getLen());
1423 if (!Timers.BeingEdited())
1425 if (!ti->Recording())
1428 Timers.SetModified();
1431 tcp.sendPacket(rp->getPtr(), rp->getLen());
1437 log->log("Client", Log::ERR, "Unable to delete timer - timer is running");
1440 tcp.sendPacket(rp->getPtr(), rp->getLen());
1447 log->log("Client", Log::ERR, "Unable to delete timer - timers being edited at VDR");
1450 tcp.sendPacket(rp->getPtr(), rp->getLen());
1456 int MVPClient::processGetRecInfo(UCHAR* data, int length, ResponsePacket* rp)
1458 // data is a pointer to the fileName string
1460 cRecordings Recordings;
1461 Recordings.Load(); // probably have to do this
1463 cRecording *recording = Recordings.GetByName((char*)data);
1465 time_t timerStart = 0;
1466 time_t timerStop = 0;
1467 char* summary = NULL;
1468 ULONG resumePoint = 0;
1472 log->log("Client", Log::ERR, "GetRecInfo found no recording");
1475 tcp.sendPacket(rp->getPtr(), rp->getLen());
1481 4 bytes: start time for timer
1482 4 bytes: end time for timer
1483 4 bytes: resume point
1485 4 bytes: num components
1495 // Get current timer
1497 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
1500 timerStart = rc->Timer()->StartTime();
1501 timerStop = rc->Timer()->StopTime();
1502 log->log("Client", Log::DEBUG, "GRI: RC: %lu %lu", timerStart, timerStop);
1505 rp->addULONG(timerStart);
1506 rp->addULONG(timerStop);
1510 char* value = config.getValueString("ResumeData", (char*)data);
1513 resumePoint = strtoul(value, NULL, 10);
1516 log->log("Client", Log::DEBUG, "GRI: RP: %lu", resumePoint);
1518 rp->addULONG(resumePoint);
1523 #if VDRVERSNUM < 10300
1524 summary = (char*)recording->Summary();
1526 const cRecordingInfo *Info = recording->Info();
1527 summary = (char*)Info->ShortText();
1528 if (isempty(summary)) summary = (char*)Info->Description();
1530 log->log("Client", Log::DEBUG, "GRI: S: %s", summary);
1533 rp->addString(summary);
1542 #if VDRVERSNUM < 10300
1544 // Send 0 for numchannels - this signals the client this info is not available
1548 const cComponents* components = Info->Components();
1550 log->log("Client", Log::DEBUG, "GRI: D1: %p", components);
1558 rp->addULONG(components->NumComponents());
1560 tComponent* component;
1561 for (int i = 0; i < components->NumComponents(); i++)
1563 component = components->Component(i);
1565 log->log("Client", Log::DEBUG, "GRI: C: %i %u %u %s %s", i, component->stream, component->type, component->language, component->description);
1567 rp->addUCHAR(component->stream);
1568 rp->addUCHAR(component->type);
1570 if (component->language)
1572 rp->addString(component->language);
1578 if (component->description)
1580 rp->addString(component->description);
1594 tcp.sendPacket(rp->getPtr(), rp->getLen());
1597 log->log("Client", Log::DEBUG, "Written getrecinfo");
1607 int MVPClient::processReScanRecording(UCHAR* data, int length, ResponsePacket* rp)
1611 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
1617 rp->addULLONG(recplayer->getLengthBytes());
1618 rp->addULONG(recplayer->getLengthFrames());
1620 tcp.sendPacket(rp->getPtr(), rp->getLen());
1622 log->log("Client", Log::DEBUG, "Rescan recording, wrote new length to client");
1626 // FIXME without client calling rescan, getblock wont work even tho more data is avail
1629 int MVPClient::processGetMarks(UCHAR* data, int length, ResponsePacket* rp)
1631 // data is a pointer to the fileName string
1634 cRecordings Recordings;
1635 Recordings.Load(); // probably have to do this
1637 cRecording *recording = Recordings.GetByName((char*)data);
1639 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
1643 Marks.Load(recording->FileName());
1646 for (const cMark *m = Marks.First(); m; m = Marks.Next(m))
1648 log->log("Client", Log::DEBUG, "found Mark %i", m->position);
1650 rp->addULONG(m->position);
1655 log->log("Client", Log::DEBUG, "no marks found, sending 0-mark");
1661 tcp.sendPacket(rp->getPtr(), rp->getLen());
1664 log->log("Client", Log::DEBUG, "Written Marks list");
1669 #endif //VOMPSTANDALONE
1672 * media List Request:
1674 * 4 VDR_GETMEDIALIST
1675 * 4 flags (currently unused)
1678 * Media List response:
1686 * 4 strlen (incl. 0 Byte)
1691 int MVPClient::processGetMediaList(UCHAR* data, int length, ResponsePacket* rp)
1694 log->log("Client", Log::ERR, "getMediaList packet too short %d", length);
1697 char * dirname=NULL;
1699 //we have a dirname provided
1700 dirname=(char *)&data[4];
1701 log->log("Client", Log::DEBUG, "getMediaList for %s", dirname);
1704 MediaList * ml=MediaList::readList(baseConfig,dirname);
1706 log->log("Client", Log::ERR, "getMediaList returned NULL");
1710 //response code (not yet set)
1714 rp->addULONG(ml->size());
1716 for (MediaList::iterator nm=ml->begin(); nm<ml->end(); nm++)
1719 log->log("Client", Log::DEBUG, "found media entry %s, type=%d",m->getFilename(),m->getType());
1720 rp->addULONG(m->getType());
1722 rp->addULONG(m->getTime());
1725 int len=strlen(m->getFilename());
1727 rp->addULONG(len+1);
1728 rp->addString(m->getFilename());
1733 tcp.sendPacket(rp->getPtr(), rp->getLen());
1736 log->log("Client", Log::DEBUG, "Written Media list");
1741 * get image Request:
1742 * 4 flags (currently unused)
1747 * get image response:
1753 int MVPClient::processGetPicture(UCHAR* data, int length, ResponsePacket* rp)
1756 log->log("Client", Log::ERR, "getPicture packet too short %d", length);
1763 char * filename=NULL;
1765 //we have a dirname provided
1766 filename=(char *)&data[12];
1767 log->log("Client", Log::DEBUG, "getPicture %s", filename);
1770 log->log("Client", Log::ERR, "getPicture empty filename");
1773 imageFile=fopen(filename,"r");
1774 if (!imageFile) log->log("Client", Log::ERR, "getPicture unable to open %s",filename);
1779 if ( fstat(fileno(imageFile),&st) == 0) size=st.st_size;
1781 //response code (not yet set)
1786 log->log("Client", Log::DEBUG, "getPicture size %u", size);
1789 tcp.sendPacket(rp->getPtr(), rp->getLen());
1792 log->log("Client", Log::DEBUG, "Written getPicture");
1798 int MVPClient::processGetImageBlock(UCHAR* data, int length, ResponsePacket* rp)
1802 log->log("Client", Log::DEBUG, "Get image block called when no image active");
1806 ULLONG position = ntohll(*(ULLONG*)data);
1807 data += sizeof(ULLONG);
1808 ULONG amount = ntohl(*(ULONG*)data);
1810 log->log("Client", Log::DEBUG, "getImageblock pos = %llu length = %lu", position, amount);
1812 UCHAR sendBuffer[amount];
1813 ULONG amountReceived = 0; // compiler moan.
1814 ULLONG cpos=ftell(imageFile);
1815 if (position != cpos) {
1816 fseek(imageFile,position-cpos,SEEK_CUR);
1818 if (position != (ULLONG)ftell(imageFile)) {
1819 log->log("Client", Log::DEBUG, "getImageblock pos = %llu not available", position);
1822 amountReceived=fread(&sendBuffer[0],1,amount,imageFile);
1825 if (!amountReceived)
1828 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
1832 rp->copyin(sendBuffer, amount);
1833 log->log("Client", Log::DEBUG, "written %lu", amountReceived);
1837 tcp.sendPacket(rp->getPtr(), rp->getLen());
1854 event = Schedule->GetPresentEvent();
1856 fprintf(f, "\n\nCurrent event\n\n");
1858 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", 0, event->GetEventID(), event->GetTime(), event->GetDuration());
1859 fprintf(f, "Event %i title = %s subtitle = %s\n", 0, event->GetTitle(), event->GetSubtitle());
1860 fprintf(f, "Event %i extendeddescription = %s\n", 0, event->GetExtendedDescription());
1861 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", 0, event->IsFollowing(), event->IsPresent());
1863 event = Schedule->GetFollowingEvent();
1865 fprintf(f, "\n\nFollowing event\n\n");
1867 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", 0, event->GetEventID(), event->GetTime(), event->GetDuration());
1868 fprintf(f, "Event %i title = %s subtitle = %s\n", 0, event->GetTitle(), event->GetSubtitle());
1869 fprintf(f, "Event %i extendeddescription = %s\n", 0, event->GetExtendedDescription());
1870 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", 0, event->IsFollowing(), event->IsPresent());
1874 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", eventNumber, event->GetEventID(), event->GetTime(), event->GetDuration());
1875 fprintf(f, "Event %i title = %s subtitle = %s\n", eventNumber, event->GetTitle(), event->GetSubtitle());
1876 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
1877 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", eventNumber, event->IsFollowing(), event->IsPresent());
1883 void MVPClient::test2()
1885 FILE* f = fopen("/tmp/s.txt", "w");
1887 #if VDRVERSNUM < 10300
1888 cMutexLock MutexLock;
1889 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1891 cSchedulesLock MutexLock;
1892 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1897 fprintf(f, "Schedules = NULL\n");
1902 fprintf(f, "Schedules dump:\n");
1906 const cSchedule *Schedule;
1907 int scheduleNumber = 0;
1910 cChannel *thisChannel;
1912 #if VDRVERSNUM < 10300
1913 const cEventInfo *event;
1914 int eventNumber = 0;
1916 const cEvent *event;
1919 // Schedule = Schedules->GetSchedule(channel->GetChannelID());
1920 // Schedule = Schedules->GetSchedule();
1921 Schedule = Schedules->First();
1924 fprintf(f, "First Schedule = NULL\n");
1931 fprintf(f, "Schedule #%i\n", scheduleNumber);
1932 fprintf(f, "-------------\n\n");
1934 #if VDRVERSNUM < 10300
1935 tchid = Schedule->GetChannelID();
1937 tchid = Schedule->ChannelID();
1940 #if VDRVERSNUM < 10300
1941 fprintf(f, "ChannelID.ToString() = %s\n", tchid.ToString());
1942 fprintf(f, "NumEvents() = %i\n", Schedule->NumEvents());
1944 // put the count at the end.
1947 thisChannel = Channels.GetByChannelID(tchid, true);
1950 fprintf(f, "Channel Number: %p %i\n", thisChannel, thisChannel->Number());
1954 fprintf(f, "thisChannel = NULL for tchid\n");
1957 #if VDRVERSNUM < 10300
1958 for (eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1960 event = Schedule->GetEventNumber(eventNumber);
1961 fprintf(f, "Event %i tableid = %i timestring = %s endtimestring = %s\n", eventNumber, event->GetTableID(), event->GetTimeString(), event->GetEndTimeString());
1962 fprintf(f, "Event %i date = %s isfollowing = %i ispresent = %i\n", eventNumber, event->GetDate(), event->IsFollowing(), event->IsPresent());
1963 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
1964 fprintf(f, "Event %i subtitle = %s title = %s\n", eventNumber, event->GetSubtitle(), event->GetTitle());
1965 fprintf(f, "Event %i eventid = %u duration = %li time = %lu channelnumber = %i\n", eventNumber, event->GetEventID(), event->GetDuration(), event->GetTime(), event->GetChannelNumber());
1966 fprintf(f, "Event %u dump:\n", eventNumber);
1971 // This whole section needs rewriting to walk the list.
1972 event = Schedule->Events()->First();
1974 event = Schedule->Events()->Next(event);
1979 fprintf(f, "\nDump from object:\n");
1981 fprintf(f, "\nEND\n");
1986 fprintf(f, "End of current Schedule\n\n\n");
1988 Schedule = (const cSchedule *)Schedules->Next(Schedule);
1996 const cEventInfo *GetPresentEvent(void) const;
1997 const cEventInfo *GetFollowingEvent(void) const;
1998 const cEventInfo *GetEvent(unsigned short uEventID, time_t tTime = 0) const;
1999 const cEventInfo *GetEventAround(time_t tTime) const;
2000 const cEventInfo *GetEventNumber(int n) const { return Events.Get(n); }
2003 const unsigned char GetTableID(void) const;
2004 const char *GetTimeString(void) const;
2005 const char *GetEndTimeString(void) const;
2006 const char *GetDate(void) const;
2007 bool IsFollowing(void) const;
2008 bool IsPresent(void) const;
2009 const char *GetExtendedDescription(void) const;
2010 const char *GetSubtitle(void) const;
2011 const char *GetTitle(void) const;
2012 unsigned short GetEventID(void) const;
2013 long GetDuration(void) const;
2014 time_t GetTime(void) const;
2015 tChannelID GetChannelID(void) const;
2016 int GetChannelNumber(void) const { return nChannelNumber; }
2017 void SetChannelNumber(int ChannelNumber) const { ((cEventInfo *)this)->nChannelNumber = ChannelNumber; } // doesn't modify the EIT data, so it's ok to make it 'const'
2018 void Dump(FILE *f, const char *Prefix = "") const;
2022 void MVPClient::test(int channelNumber)
2024 FILE* f = fopen("/tmp/test.txt", "w");
2026 cMutexLock MutexLock;
2027 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
2031 fprintf(f, "Schedules = NULL\n");
2036 fprintf(f, "Schedules dump:\n");
2037 // Schedules->Dump(f);
2039 const cSchedule *Schedule;
2040 cChannel *thisChannel;
2041 const cEventInfo *event;
2043 thisChannel = channelFromNumber(channelNumber);
2046 fprintf(f, "thisChannel = NULL\n");
2051 Schedule = Schedules->GetSchedule(thisChannel->GetChannelID());
2052 // Schedule = Schedules->GetSchedule();
2053 // Schedule = Schedules->First();
2056 fprintf(f, "First Schedule = NULL\n");
2061 fprintf(f, "NumEvents() = %i\n\n", Schedule->NumEvents());
2063 // For some channels VDR seems to pick a random point in time to
2064 // start dishing out events, but they are in order
2065 // at some point in the list the time snaps to the current event
2070 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
2072 event = Schedule->GetEventNumber(eventNumber);
2073 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", eventNumber, event->GetEventID(), event->GetTime(), event->GetDuration());
2074 fprintf(f, "Event %i title = %s subtitle = %s\n", eventNumber, event->GetTitle(), event->GetSubtitle());
2075 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
2079 fprintf(f, "\nEND\n");
2088 Schedules = the collection of all the Schedule objects
2089 Schedule = One schedule, contants all the events for a channel
2090 Event = One programme
2099 Subtitle (used for "Programmes resume at ...")
2102 IsPresent ? easy to work out tho. Oh it doesn't always work
2105 void MVPClient::test2()
2107 log->log("-", Log::DEBUG, "Timers List");
2109 for (int i = 0; i < Timers.Count(); i++)
2111 cTimer *timer = Timers.Get(i);
2112 //Reply(i < Timers.Count() - 1 ? -250 : 250, "%d %s", timer->Index() + 1, timer->ToText());
2113 log->log("-", Log::DEBUG, "i=%i count=%i index=%d", i, Timers.Count(), timer->Index() + 1);
2114 #if VDRVERSNUM < 10300
2115 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());
2117 log->log("-", Log::DEBUG, "active=%i recording=%i pending=%i start=%li stop=%li priority=%i lifetime=%i", timer->HasFlags(tfActive), timer->Recording(), timer->Pending(), timer->StartTime(), timer->StopTime(), timer->Priority(), timer->Lifetime());
2119 log->log("-", Log::DEBUG, "channel=%i file=%s summary=%s", timer->Channel()->Number(), timer->File(), timer->Summary());
2120 log->log("-", Log::DEBUG, "");
2123 // asprintf(&buffer, "%d:%s:%s :%04d:%04d:%d:%d:%s:%s\n",
2124 // active, (UseChannelID ? Channel()->GetChannelID().ToString() : itoa(Channel()->Number())),
2125 // PrintDay(day, firstday), start, stop, priority, lifetime, file, summary ? summary : "");
2129 Active seems to be a bool - whether the timer should be done or not. If set to inactive it stays around after its time
2130 recording is a bool, 0 for not currently recording, 1 for currently recording
2131 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