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* tconfigDir, int tsocket)
35 #ifndef VOMPSTANDALONE
38 recordingManager = NULL;
41 log = Log::getInstance();
43 configDir = tconfigDir;
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 char configFileName[PATH_MAX];
400 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]);
401 config.init(configFileName);
403 // Send the login reply
405 time_t timeNow = time(NULL);
406 struct tm* timeStruct = localtime(&timeNow);
407 int timeOffset = timeStruct->tm_gmtoff;
409 rp->addULONG(timeNow);
410 rp->addLONG(timeOffset);
412 tcp.sendPacket(rp->getPtr(), rp->getLen());
413 log->log("Client", Log::DEBUG, "written login reply len %lu", rp->getLen());
420 #ifndef VOMPSTANDALONE
421 int MVPClient::processGetRecordingsList(UCHAR* data, int length, ResponsePacket* rp)
424 int Percent = VideoDiskSpace(&FreeMB);
425 int Total = (FreeMB / (100 - Percent)) * 100;
428 rp->addULONG(FreeMB);
429 rp->addULONG(Percent);
431 cRecordings Recordings;
434 for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording))
436 rp->addULONG(recording->start);
437 rp->addString(recording->Name());
438 rp->addString(recording->FileName());
442 tcp.sendPacket(rp->getPtr(), rp->getLen());
445 log->log("Client", Log::DEBUG, "Written recordings list");
450 int MVPClient::processDeleteRecording(UCHAR* data, int length, ResponsePacket* rp)
452 // data is a pointer to the fileName string
454 cRecordings Recordings;
455 Recordings.Load(); // probably have to do this
457 cRecording* recording = Recordings.GetByName((char*)data);
459 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
463 log->log("Client", Log::DEBUG, "deleting recording: %s", recording->Name());
465 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
468 if (recording->Delete())
470 // Copy svdrp's way of doing this, see if it works
471 #if VDRVERSNUM > 10300
472 ::Recordings.DelByName(recording->FileName());
492 tcp.sendPacket(rp->getPtr(), rp->getLen());
498 int MVPClient::processMoveRecording(UCHAR* data, int length, ResponsePacket* rp)
500 log->log("Client", Log::DEBUG, "Process move recording");
501 char* fileName = (char*)data;
502 char* newPath = NULL;
504 for (int k = 0; k < length; k++)
508 newPath = (char*)&data[k+1];
512 if (!newPath) return 0;
514 cRecordings Recordings;
515 Recordings.Load(); // probably have to do this
517 cRecording* recording = Recordings.GetByName((char*)fileName);
519 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
523 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
526 log->log("Client", Log::DEBUG, "moving recording: %s", recording->Name());
527 log->log("Client", Log::DEBUG, "moving recording: %s", recording->FileName());
528 log->log("Client", Log::DEBUG, "to: %s", newPath);
530 const char* t = recording->FileName();
532 char* dateDirName = NULL; int k;
533 char* titleDirName = NULL; int j;
535 // Find the datedirname
536 for(k = strlen(t) - 1; k >= 0; k--)
540 log->log("Client", Log::DEBUG, "l1: %i", strlen(&t[k+1]) + 1);
541 dateDirName = new char[strlen(&t[k+1]) + 1];
542 strcpy(dateDirName, &t[k+1]);
547 // Find the titledirname
549 for(j = k-1; j >= 0; j--)
553 log->log("Client", Log::DEBUG, "l2: %i", (k - j - 1) + 1);
554 titleDirName = new char[(k - j - 1) + 1];
555 memcpy(titleDirName, &t[j+1], k - j - 1);
556 titleDirName[k - j - 1] = '\0';
561 log->log("Client", Log::DEBUG, "datedirname: %s", dateDirName);
562 log->log("Client", Log::DEBUG, "titledirname: %s", titleDirName);
564 log->log("Client", Log::DEBUG, "viddir: %s", VideoDirectory);
566 char* newContainer = new char[strlen(VideoDirectory) + strlen(newPath) + strlen(titleDirName) + 1];
567 log->log("Client", Log::DEBUG, "l10: %i", strlen(VideoDirectory) + strlen(newPath) + strlen(titleDirName) + 1);
568 sprintf(newContainer, "%s%s%s", VideoDirectory, newPath, titleDirName);
570 // FIXME Check whether this already exists before mkdiring it
572 log->log("Client", Log::DEBUG, "%s", newContainer);
576 int statret = stat(newContainer, &dstat);
577 if ((statret == -1) && (errno == ENOENT)) // Dir does not exist
579 log->log("Client", Log::DEBUG, "new dir does not exist");
580 int mkdirret = mkdir(newContainer, 0755);
583 delete[] dateDirName;
584 delete[] titleDirName;
585 delete[] newContainer;
589 tcp.sendPacket(rp->getPtr(), rp->getLen());
594 else if ((statret == 0) && (! (dstat.st_mode && S_IFDIR))) // Something exists but it's not a dir
596 delete[] dateDirName;
597 delete[] titleDirName;
598 delete[] newContainer;
602 tcp.sendPacket(rp->getPtr(), rp->getLen());
607 // Ok, the directory container has been made, or it pre-existed.
609 char* newDir = new char[strlen(newContainer) + 1 + strlen(dateDirName) + 1];
610 sprintf(newDir, "%s/%s", newContainer, dateDirName);
612 log->log("Client", Log::DEBUG, "doing rename '%s' '%s'", t, newDir);
613 int renameret = rename(t, newDir);
616 // Success. Test for remove old dir containter
617 char* oldTitleDir = new char[k+1];
618 memcpy(oldTitleDir, t, k);
619 oldTitleDir[k] = '\0';
620 log->log("Client", Log::DEBUG, "len: %i, cp: %i, strlen: %i, oldtitledir: %s", k+1, k, strlen(oldTitleDir), oldTitleDir);
621 rmdir(oldTitleDir); // can't do anything about a fail result at this point.
622 delete[] oldTitleDir;
627 #if VDRVERSNUM > 10311
629 ::Recordings.Update();
631 // Success. Send a different packet from just a ulong
632 rp->addULONG(1); // success
633 rp->addString(newDir);
641 tcp.sendPacket(rp->getPtr(), rp->getLen());
644 delete[] dateDirName;
645 delete[] titleDirName;
646 delete[] newContainer;
653 tcp.sendPacket(rp->getPtr(), rp->getLen());
661 tcp.sendPacket(rp->getPtr(), rp->getLen());
668 int MVPClient::processGetChannelsList(UCHAR* data, int length, ResponsePacket* rp)
672 char* chanConfig = config.getValueString("General", "Channels");
674 if (chanConfig) allChans = strcasecmp(chanConfig, "FTA only");
676 for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel))
678 #if VDRVERSNUM < 10300
679 if (!channel->GroupSep() && (!channel->Ca() || allChans))
681 if (!channel->GroupSep() && (!channel->Ca(0) || allChans))
684 log->log("Client", Log::DEBUG, "name: '%s'", channel->Name());
686 if (channel->Vpid()) type = 1;
687 #if VDRVERSNUM < 10300
690 else if (channel->Apid(0)) type = 2;
694 rp->addULONG(channel->Number());
696 rp->addString(channel->Name());
701 tcp.sendPacket(rp->getPtr(), rp->getLen());
704 log->log("Client", Log::DEBUG, "Written channels list");
709 int MVPClient::processGetChannelPids(UCHAR* data, int length, ResponsePacket* rp)
711 ULONG channelNumber = ntohl(*(ULONG*)data);
713 cChannel* channel = channelFromNumber(channelNumber);
718 tcp.sendPacket(rp->getPtr(), rp->getLen());
725 #if VDRVERSNUM < 10300
727 log->log("Client", Log::DEBUG, "Apid1: %i", channel->Apid1());
728 log->log("Client", Log::DEBUG, "Apid2: %i", channel->Apid2());
730 if (channel->Apid2())
732 else if (channel->Apid1())
739 for (const int *Apid = channel->Apids(); *Apid; Apid++)
746 // Format of response
754 rp->addULONG(channel->Vpid());
755 rp->addULONG(numApids);
757 #if VDRVERSNUM < 10300
760 rp->addULONG(channel->Apid1());
765 rp->addULONG(channel->Apid2());
769 for (ULONG i = 0; i < numApids; i++)
771 rp->addULONG(channel->Apid(i));
772 rp->addString(channel->Alang(i));
777 tcp.sendPacket(rp->getPtr(), rp->getLen());
780 log->log("Client", Log::DEBUG, "Written channels pids");
785 int MVPClient::processStartStreamingChannel(UCHAR* data, int length, ULONG streamID, ResponsePacket* rp)
789 log->log("Client", Log::ERR, "Client called start streaming twice");
793 log->log("Client", Log::DEBUG, "length = %i", length);
794 ULONG channelNumber = ntohl(*(ULONG*)data);
796 cChannel* channel = channelFromNumber(channelNumber);
801 tcp.sendPacket(rp->getPtr(), rp->getLen());
806 // get the priority we should use
808 int priority = config.getValueLong("General", "Live priority", &fail);
811 log->log("Client", Log::DEBUG, "Config: Live TV priority: %i", priority);
815 log->log("Client", Log::DEBUG, "Config: Live TV priority config fail");
820 if (priority < 0) priority = 0;
821 if (priority > 99) priority = 99;
823 log->log("Client", Log::DEBUG, "Using live TV priority %i", priority);
824 lp = MVPReceiver::create(channel, priority);
830 tcp.sendPacket(rp->getPtr(), rp->getLen());
835 if (!lp->init(&tcp, streamID))
841 tcp.sendPacket(rp->getPtr(), rp->getLen());
848 tcp.sendPacket(rp->getPtr(), rp->getLen());
853 int MVPClient::processStopStreaming(UCHAR* data, int length, ResponsePacket* rp)
855 log->log("Client", Log::DEBUG, "STOP STREAMING RECEIVED");
866 delete recordingManager;
868 recordingManager = NULL;
873 tcp.sendPacket(rp->getPtr(), rp->getLen());
878 int MVPClient::processGetBlock(UCHAR* data, int length, ResponsePacket* rp)
880 if (!lp && !recplayer)
882 log->log("Client", Log::DEBUG, "Get block called when no streaming happening!");
886 ULLONG position = ntohll(*(ULLONG*)data);
887 data += sizeof(ULLONG);
888 ULONG amount = ntohl(*(ULONG*)data);
890 log->log("Client", Log::DEBUG, "getblock pos = %llu length = %lu", position, amount);
892 UCHAR sendBuffer[amount];
893 ULONG amountReceived = 0; // compiler moan.
896 log->log("Client", Log::DEBUG, "getting from live");
897 amountReceived = lp->getBlock(&sendBuffer[0], amount);
901 // vdr has possibly disconnected the receiver
902 log->log("Client", Log::DEBUG, "VDR has disconnected the live receiver");
909 log->log("Client", Log::DEBUG, "getting from recording");
910 amountReceived = recplayer->getBlock(&sendBuffer[0], position, amount);
916 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
920 rp->copyin(sendBuffer, amountReceived);
921 log->log("Client", Log::DEBUG, "written %lu", amountReceived);
925 tcp.sendPacket(rp->getPtr(), rp->getLen());
926 log->log("Client", Log::DEBUG, "Finished getblock, have sent %lu", rp->getLen());
931 int MVPClient::processStartStreamingRecording(UCHAR* data, int length, ResponsePacket* rp)
933 // data is a pointer to the fileName string
935 recordingManager = new cRecordings;
936 recordingManager->Load();
938 cRecording* recording = recordingManager->GetByName((char*)data);
940 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
944 recplayer = new RecPlayer(recording);
946 rp->addULLONG(recplayer->getLengthBytes());
947 rp->addULONG(recplayer->getLengthFrames());
949 tcp.sendPacket(rp->getPtr(), rp->getLen());
952 log->log("Client", Log::DEBUG, "written totalLength");
956 delete recordingManager;
957 recordingManager = NULL;
962 int MVPClient::processPositionFromFrameNumber(UCHAR* data, int length, ResponsePacket* rp)
966 ULONG frameNumber = ntohl(*(ULONG*)data);
971 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
975 retval = recplayer->positionFromFrameNumber(frameNumber);
978 rp->addULLONG(retval);
980 tcp.sendPacket(rp->getPtr(), rp->getLen());
983 log->log("Client", Log::DEBUG, "Wrote posFromFrameNum reply to client");
987 int MVPClient::processFrameNumberFromPosition(UCHAR* data, int length, ResponsePacket* rp)
991 ULLONG position = ntohll(*(ULLONG*)data);
996 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
1000 retval = recplayer->frameNumberFromPosition(position);
1003 rp->addULONG(retval);
1005 tcp.sendPacket(rp->getPtr(), rp->getLen());
1008 log->log("Client", Log::DEBUG, "Wrote frameNumFromPos reply to client");
1012 int MVPClient::processGetIFrame(UCHAR* data, int length, ResponsePacket* rp)
1014 bool success = false;
1016 ULONG frameNumber = ntohl(*(ULONG*)data);
1018 ULONG direction = ntohl(*(ULONG*)data);
1021 ULLONG rfilePosition = 0;
1022 ULONG rframeNumber = 0;
1023 ULONG rframeLength = 0;
1027 log->log("Client", Log::DEBUG, "GetIFrame recording called when no recording being played!");
1031 success = recplayer->getNextIFrame(frameNumber, direction, &rfilePosition, &rframeNumber, &rframeLength);
1034 // returns file position, frame number, length
1038 rp->addULLONG(rfilePosition);
1039 rp->addULONG(rframeNumber);
1040 rp->addULONG(rframeLength);
1048 tcp.sendPacket(rp->getPtr(), rp->getLen());
1051 log->log("Client", Log::DEBUG, "Wrote GNIF reply to client %llu %lu %lu", rfilePosition, rframeNumber, rframeLength);
1055 int MVPClient::processGetChannelSchedule(UCHAR* data, int length, ResponsePacket* rp)
1057 ULONG channelNumber = ntohl(*(ULONG*)data);
1059 ULONG startTime = ntohl(*(ULONG*)data);
1061 ULONG duration = ntohl(*(ULONG*)data);
1063 log->log("Client", Log::DEBUG, "get schedule called for channel %lu", channelNumber);
1065 cChannel* channel = channelFromNumber(channelNumber);
1070 tcp.sendPacket(rp->getPtr(), rp->getLen());
1073 log->log("Client", Log::DEBUG, "written 0 because channel = NULL");
1077 log->log("Client", Log::DEBUG, "Got channel");
1079 #if VDRVERSNUM < 10300
1080 cMutexLock MutexLock;
1081 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1083 cSchedulesLock MutexLock;
1084 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1090 tcp.sendPacket(rp->getPtr(), rp->getLen());
1093 log->log("Client", Log::DEBUG, "written 0 because Schedule!s! = NULL");
1097 log->log("Client", Log::DEBUG, "Got schedule!s! object");
1099 const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
1104 tcp.sendPacket(rp->getPtr(), rp->getLen());
1107 log->log("Client", Log::DEBUG, "written 0 because Schedule = NULL");
1111 log->log("Client", Log::DEBUG, "Got schedule object");
1113 const char* empty = "";
1114 bool atLeastOneEvent = false;
1117 ULONG thisEventTime;
1118 ULONG thisEventDuration;
1119 const char* thisEventTitle;
1120 const char* thisEventSubTitle;
1121 const char* thisEventDescription;
1123 #if VDRVERSNUM < 10300
1125 const cEventInfo *event;
1126 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1128 event = Schedule->GetEventNumber(eventNumber);
1130 thisEventID = event->GetEventID();
1131 thisEventTime = event->GetTime();
1132 thisEventDuration = event->GetDuration();
1133 thisEventTitle = event->GetTitle();
1134 thisEventSubTitle = event->GetSubtitle();
1135 thisEventDescription = event->GetExtendedDescription();
1139 for (const cEvent* event = Schedule->Events()->First(); event; event = Schedule->Events()->Next(event))
1141 thisEventID = event->EventID();
1142 thisEventTime = event->StartTime();
1143 thisEventDuration = event->Duration();
1144 thisEventTitle = event->Title();
1145 thisEventSubTitle = NULL;
1146 thisEventDescription = event->Description();
1150 log->log("Client", Log::DEBUG, "Got an event object %p", event);
1152 //in the past filter
1153 if ((thisEventTime + thisEventDuration) < (ULONG)time(NULL)) continue;
1156 if ((thisEventTime + thisEventDuration) <= startTime) continue;
1159 if (thisEventTime >= (startTime + duration)) continue;
1161 if (!thisEventTitle) thisEventTitle = empty;
1162 if (!thisEventSubTitle) thisEventSubTitle = empty;
1163 if (!thisEventDescription) thisEventDescription = empty;
1165 rp->addULONG(thisEventID);
1166 rp->addULONG(thisEventTime);
1167 rp->addULONG(thisEventDuration);
1169 rp->addString(thisEventTitle);
1170 rp->addString(thisEventSubTitle);
1171 rp->addString(thisEventDescription);
1173 atLeastOneEvent = true;
1174 log->log("Client", Log::DEBUG, "Done s3");
1177 log->log("Client", Log::DEBUG, "Got all event data");
1179 if (!atLeastOneEvent)
1182 log->log("Client", Log::DEBUG, "Written 0 because no data");
1186 tcp.sendPacket(rp->getPtr(), rp->getLen());
1189 log->log("Client", Log::DEBUG, "written schedules packet");
1194 #endif //VOMPSTANDALONE
1196 int MVPClient::processConfigSave(UCHAR* buffer, int length, ResponsePacket* rp)
1198 char* section = (char*)buffer;
1202 for (int k = 0; k < length; k++)
1204 if (buffer[k] == '\0')
1208 key = (char*)&buffer[k+1];
1212 value = (char*)&buffer[k+1];
1218 // if the last string (value) doesnt have null terminator, give up
1219 if (buffer[length - 1] != '\0') return 0;
1221 log->log("Client", Log::DEBUG, "Config save: %s %s %s", section, key, value);
1222 if (config.setValueString(section, key, value))
1232 tcp.sendPacket(rp->getPtr(), rp->getLen());
1238 int MVPClient::processConfigLoad(UCHAR* buffer, int length, ResponsePacket* rp)
1240 char* section = (char*)buffer;
1243 for (int k = 0; k < length; k++)
1245 if (buffer[k] == '\0')
1247 key = (char*)&buffer[k+1];
1252 char* value = config.getValueString(section, key);
1256 rp->addString(value);
1257 log->log("Client", Log::DEBUG, "Written config load packet");
1263 log->log("Client", Log::DEBUG, "Written config load failed packet");
1267 tcp.sendPacket(rp->getPtr(), rp->getLen());
1273 #ifndef VOMPSTANDALONE
1275 int MVPClient::processGetTimers(UCHAR* buffer, int length, ResponsePacket* rp)
1278 int numTimers = Timers.Count();
1280 rp->addULONG(numTimers);
1282 for (int i = 0; i < numTimers; i++)
1284 timer = Timers.Get(i);
1286 #if VDRVERSNUM < 10300
1287 rp->addULONG(timer->Active());
1289 rp->addULONG(timer->HasFlags(tfActive));
1291 rp->addULONG(timer->Recording());
1292 rp->addULONG(timer->Pending());
1293 rp->addULONG(timer->Priority());
1294 rp->addULONG(timer->Lifetime());
1295 rp->addULONG(timer->Channel()->Number());
1296 rp->addULONG(timer->StartTime());
1297 rp->addULONG(timer->StopTime());
1298 rp->addULONG(timer->Day());
1299 rp->addULONG(timer->WeekDays());
1300 rp->addString(timer->File());
1304 tcp.sendPacket(rp->getPtr(), rp->getLen());
1307 log->log("Client", Log::DEBUG, "Written timers list");
1312 int MVPClient::processSetTimer(UCHAR* buffer, int length, ResponsePacket* rp)
1314 char* timerString = new char[strlen((char*)buffer) + 1];
1315 strcpy(timerString, (char*)buffer);
1317 #if VDRVERSNUM < 10300
1319 // If this is VDR 1.2 the date part of the timer string must be reduced
1320 // to just DD rather than YYYY-MM-DD
1322 int s = 0; // source
1323 int d = 0; // destination
1325 while(c != 2) // copy up to date section, including the second ':'
1327 timerString[d] = buffer[s];
1328 if (buffer[s] == ':') c++;
1332 // now it has copied up to the date section
1334 while(c != 2) // waste YYYY-MM-
1336 if (buffer[s] == '-') c++;
1339 // now source is at the DD
1340 memcpy(&timerString[d], &buffer[s], length - s);
1342 timerString[d] = '\0';
1344 log->log("Client", Log::DEBUG, "Timer string after 1.2 conversion:");
1345 log->log("Client", Log::DEBUG, "%s", timerString);
1349 cTimer *timer = new cTimer;
1350 if (timer->Parse((char*)timerString))
1352 cTimer *t = Timers.GetTimer(timer);
1356 #if VDRVERSNUM < 10300
1359 Timers.SetModified();
1363 tcp.sendPacket(rp->getPtr(), rp->getLen());
1371 tcp.sendPacket(rp->getPtr(), rp->getLen());
1379 tcp.sendPacket(rp->getPtr(), rp->getLen());
1386 int MVPClient::processDeleteTimer(UCHAR* buffer, int length, ResponsePacket* rp)
1388 log->log("Client", Log::DEBUG, "Delete timer called");
1393 INT delChannel = ntohl(*(ULONG*)&buffer[position]); position += 4;
1394 INT delWeekdays = ntohl(*(ULONG*)&buffer[position]); position += 4;
1395 INT delDay = ntohl(*(ULONG*)&buffer[position]); position += 4;
1396 INT delStart = ntohl(*(ULONG*)&buffer[position]); position += 4;
1397 INT delStop = ntohl(*(ULONG*)&buffer[position]); position += 4;
1400 for (ti = Timers.First(); ti; ti = Timers.Next(ti))
1402 if ( (ti->Channel()->Number() == delChannel)
1403 && ((ti->WeekDays() && (ti->WeekDays() == delWeekdays)) || (!ti->WeekDays() && (ti->Day() == delDay)))
1404 && (ti->StartTime() == delStart)
1405 && (ti->StopTime() == delStop) )
1413 tcp.sendPacket(rp->getPtr(), rp->getLen());
1418 if (!Timers.BeingEdited())
1420 if (!ti->Recording())
1423 Timers.SetModified();
1426 tcp.sendPacket(rp->getPtr(), rp->getLen());
1432 log->log("Client", Log::ERR, "Unable to delete timer - timer is running");
1435 tcp.sendPacket(rp->getPtr(), rp->getLen());
1442 log->log("Client", Log::ERR, "Unable to delete timer - timers being edited at VDR");
1445 tcp.sendPacket(rp->getPtr(), rp->getLen());
1451 int MVPClient::processGetRecInfo(UCHAR* data, int length, ResponsePacket* rp)
1453 // data is a pointer to the fileName string
1455 cRecordings Recordings;
1456 Recordings.Load(); // probably have to do this
1458 cRecording *recording = Recordings.GetByName((char*)data);
1460 time_t timerStart = 0;
1461 time_t timerStop = 0;
1462 char* summary = NULL;
1463 ULONG resumePoint = 0;
1467 log->log("Client", Log::ERR, "GetRecInfo found no recording");
1470 tcp.sendPacket(rp->getPtr(), rp->getLen());
1476 4 bytes: start time for timer
1477 4 bytes: end time for timer
1478 4 bytes: resume point
1480 4 bytes: num components
1490 // Get current timer
1492 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
1495 timerStart = rc->Timer()->StartTime();
1496 timerStop = rc->Timer()->StopTime();
1497 log->log("Client", Log::DEBUG, "GRI: RC: %lu %lu", timerStart, timerStop);
1500 rp->addULONG(timerStart);
1501 rp->addULONG(timerStop);
1505 char* value = config.getValueString("ResumeData", (char*)data);
1508 resumePoint = strtoul(value, NULL, 10);
1511 log->log("Client", Log::DEBUG, "GRI: RP: %lu", resumePoint);
1513 rp->addULONG(resumePoint);
1518 #if VDRVERSNUM < 10300
1519 summary = (char*)recording->Summary();
1521 const cRecordingInfo *Info = recording->Info();
1522 summary = (char*)Info->ShortText();
1523 if (isempty(summary)) summary = (char*)Info->Description();
1525 log->log("Client", Log::DEBUG, "GRI: S: %s", summary);
1528 rp->addString(summary);
1537 #if VDRVERSNUM < 10300
1539 // Send 0 for numchannels - this signals the client this info is not available
1543 const cComponents* components = Info->Components();
1545 log->log("Client", Log::DEBUG, "GRI: D1: %p", components);
1553 rp->addULONG(components->NumComponents());
1555 tComponent* component;
1556 for (int i = 0; i < components->NumComponents(); i++)
1558 component = components->Component(i);
1560 log->log("Client", Log::DEBUG, "GRI: C: %i %u %u %s %s", i, component->stream, component->type, component->language, component->description);
1562 rp->addUCHAR(component->stream);
1563 rp->addUCHAR(component->type);
1565 if (component->language)
1567 rp->addString(component->language);
1573 if (component->description)
1575 rp->addString(component->description);
1589 tcp.sendPacket(rp->getPtr(), rp->getLen());
1592 log->log("Client", Log::DEBUG, "Written getrecinfo");
1602 int MVPClient::processReScanRecording(UCHAR* data, int length, ResponsePacket* rp)
1606 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
1612 rp->addULLONG(recplayer->getLengthBytes());
1613 rp->addULONG(recplayer->getLengthFrames());
1615 tcp.sendPacket(rp->getPtr(), rp->getLen());
1617 log->log("Client", Log::DEBUG, "Rescan recording, wrote new length to client");
1621 // FIXME without client calling rescan, getblock wont work even tho more data is avail
1624 int MVPClient::processGetMarks(UCHAR* data, int length, ResponsePacket* rp)
1626 // data is a pointer to the fileName string
1629 cRecordings Recordings;
1630 Recordings.Load(); // probably have to do this
1632 cRecording *recording = Recordings.GetByName((char*)data);
1634 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
1638 Marks.Load(recording->FileName());
1641 for (const cMark *m = Marks.First(); m; m = Marks.Next(m))
1643 log->log("Client", Log::DEBUG, "found Mark %i", m->position);
1645 rp->addULONG(m->position);
1650 log->log("Client", Log::DEBUG, "no marks found, sending 0-mark");
1656 tcp.sendPacket(rp->getPtr(), rp->getLen());
1659 log->log("Client", Log::DEBUG, "Written Marks list");
1664 #endif //VOMPSTANDALONE
1667 * media List Request:
1669 * 4 VDR_GETMEDIALIST
1670 * 4 flags (currently unused)
1673 * Media List response:
1681 * 4 strlen (incl. 0 Byte)
1686 int MVPClient::processGetMediaList(UCHAR* data, int length, ResponsePacket* rp)
1689 log->log("Client", Log::ERR, "getMediaList packet too short %d", length);
1692 char * dirname=NULL;
1694 //we have a dirname provided
1695 dirname=(char *)&data[4];
1696 log->log("Client", Log::DEBUG, "getMediaList for %s", dirname);
1699 MediaList * ml=MediaList::readList(baseConfig,dirname);
1701 log->log("Client", Log::ERR, "getMediaList returned NULL");
1705 //response code (not yet set)
1709 rp->addULONG(ml->size());
1711 for (MediaList::iterator nm=ml->begin(); nm<ml->end(); nm++)
1714 log->log("Client", Log::DEBUG, "found media entry %s, type=%d",m->getFilename(),m->getType());
1715 rp->addULONG(m->getType());
1717 rp->addULONG(m->getTime());
1720 int len=strlen(m->getFilename());
1722 rp->addULONG(len+1);
1723 rp->addString(m->getFilename());
1728 tcp.sendPacket(rp->getPtr(), rp->getLen());
1731 log->log("Client", Log::DEBUG, "Written Media list");
1736 * get image Request:
1737 * 4 flags (currently unused)
1742 * get image response:
1748 int MVPClient::processGetPicture(UCHAR* data, int length, ResponsePacket* rp)
1751 log->log("Client", Log::ERR, "getPicture packet too short %d", length);
1758 char * filename=NULL;
1760 //we have a dirname provided
1761 filename=(char *)&data[12];
1762 log->log("Client", Log::DEBUG, "getPicture %s", filename);
1765 log->log("Client", Log::ERR, "getPicture empty filename");
1768 imageFile=fopen(filename,"r");
1769 if (!imageFile) log->log("Client", Log::ERR, "getPicture unable to open %s",filename);
1774 if ( fstat(fileno(imageFile),&st) == 0) size=st.st_size;
1776 //response code (not yet set)
1781 log->log("Client", Log::DEBUG, "getPicture size %u", size);
1784 tcp.sendPacket(rp->getPtr(), rp->getLen());
1787 log->log("Client", Log::DEBUG, "Written getPicture");
1793 int MVPClient::processGetImageBlock(UCHAR* data, int length, ResponsePacket* rp)
1797 log->log("Client", Log::DEBUG, "Get image block called when no image active");
1801 ULLONG position = ntohll(*(ULLONG*)data);
1802 data += sizeof(ULLONG);
1803 ULONG amount = ntohl(*(ULONG*)data);
1805 log->log("Client", Log::DEBUG, "getImageblock pos = %llu length = %lu", position, amount);
1807 UCHAR sendBuffer[amount];
1808 ULONG amountReceived = 0; // compiler moan.
1809 ULLONG cpos=ftell(imageFile);
1810 if (position != cpos) {
1811 fseek(imageFile,position-cpos,SEEK_CUR);
1813 if (position != (ULLONG)ftell(imageFile)) {
1814 log->log("Client", Log::DEBUG, "getImageblock pos = %llu not available", position);
1817 amountReceived=fread(&sendBuffer[0],1,amount,imageFile);
1820 if (!amountReceived)
1823 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
1827 rp->copyin(sendBuffer, amount);
1828 log->log("Client", Log::DEBUG, "written %lu", amountReceived);
1832 tcp.sendPacket(rp->getPtr(), rp->getLen());
1849 event = Schedule->GetPresentEvent();
1851 fprintf(f, "\n\nCurrent event\n\n");
1853 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", 0, event->GetEventID(), event->GetTime(), event->GetDuration());
1854 fprintf(f, "Event %i title = %s subtitle = %s\n", 0, event->GetTitle(), event->GetSubtitle());
1855 fprintf(f, "Event %i extendeddescription = %s\n", 0, event->GetExtendedDescription());
1856 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", 0, event->IsFollowing(), event->IsPresent());
1858 event = Schedule->GetFollowingEvent();
1860 fprintf(f, "\n\nFollowing event\n\n");
1862 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", 0, event->GetEventID(), event->GetTime(), event->GetDuration());
1863 fprintf(f, "Event %i title = %s subtitle = %s\n", 0, event->GetTitle(), event->GetSubtitle());
1864 fprintf(f, "Event %i extendeddescription = %s\n", 0, event->GetExtendedDescription());
1865 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", 0, event->IsFollowing(), event->IsPresent());
1869 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", eventNumber, event->GetEventID(), event->GetTime(), event->GetDuration());
1870 fprintf(f, "Event %i title = %s subtitle = %s\n", eventNumber, event->GetTitle(), event->GetSubtitle());
1871 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
1872 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", eventNumber, event->IsFollowing(), event->IsPresent());
1878 void MVPClient::test2()
1880 FILE* f = fopen("/tmp/s.txt", "w");
1882 #if VDRVERSNUM < 10300
1883 cMutexLock MutexLock;
1884 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1886 cSchedulesLock MutexLock;
1887 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1892 fprintf(f, "Schedules = NULL\n");
1897 fprintf(f, "Schedules dump:\n");
1901 const cSchedule *Schedule;
1902 int scheduleNumber = 0;
1905 cChannel *thisChannel;
1907 #if VDRVERSNUM < 10300
1908 const cEventInfo *event;
1909 int eventNumber = 0;
1911 const cEvent *event;
1914 // Schedule = Schedules->GetSchedule(channel->GetChannelID());
1915 // Schedule = Schedules->GetSchedule();
1916 Schedule = Schedules->First();
1919 fprintf(f, "First Schedule = NULL\n");
1926 fprintf(f, "Schedule #%i\n", scheduleNumber);
1927 fprintf(f, "-------------\n\n");
1929 #if VDRVERSNUM < 10300
1930 tchid = Schedule->GetChannelID();
1932 tchid = Schedule->ChannelID();
1935 #if VDRVERSNUM < 10300
1936 fprintf(f, "ChannelID.ToString() = %s\n", tchid.ToString());
1937 fprintf(f, "NumEvents() = %i\n", Schedule->NumEvents());
1939 // put the count at the end.
1942 thisChannel = Channels.GetByChannelID(tchid, true);
1945 fprintf(f, "Channel Number: %p %i\n", thisChannel, thisChannel->Number());
1949 fprintf(f, "thisChannel = NULL for tchid\n");
1952 #if VDRVERSNUM < 10300
1953 for (eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1955 event = Schedule->GetEventNumber(eventNumber);
1956 fprintf(f, "Event %i tableid = %i timestring = %s endtimestring = %s\n", eventNumber, event->GetTableID(), event->GetTimeString(), event->GetEndTimeString());
1957 fprintf(f, "Event %i date = %s isfollowing = %i ispresent = %i\n", eventNumber, event->GetDate(), event->IsFollowing(), event->IsPresent());
1958 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
1959 fprintf(f, "Event %i subtitle = %s title = %s\n", eventNumber, event->GetSubtitle(), event->GetTitle());
1960 fprintf(f, "Event %i eventid = %u duration = %li time = %lu channelnumber = %i\n", eventNumber, event->GetEventID(), event->GetDuration(), event->GetTime(), event->GetChannelNumber());
1961 fprintf(f, "Event %u dump:\n", eventNumber);
1966 // This whole section needs rewriting to walk the list.
1967 event = Schedule->Events()->First();
1969 event = Schedule->Events()->Next(event);
1974 fprintf(f, "\nDump from object:\n");
1976 fprintf(f, "\nEND\n");
1981 fprintf(f, "End of current Schedule\n\n\n");
1983 Schedule = (const cSchedule *)Schedules->Next(Schedule);
1991 const cEventInfo *GetPresentEvent(void) const;
1992 const cEventInfo *GetFollowingEvent(void) const;
1993 const cEventInfo *GetEvent(unsigned short uEventID, time_t tTime = 0) const;
1994 const cEventInfo *GetEventAround(time_t tTime) const;
1995 const cEventInfo *GetEventNumber(int n) const { return Events.Get(n); }
1998 const unsigned char GetTableID(void) const;
1999 const char *GetTimeString(void) const;
2000 const char *GetEndTimeString(void) const;
2001 const char *GetDate(void) const;
2002 bool IsFollowing(void) const;
2003 bool IsPresent(void) const;
2004 const char *GetExtendedDescription(void) const;
2005 const char *GetSubtitle(void) const;
2006 const char *GetTitle(void) const;
2007 unsigned short GetEventID(void) const;
2008 long GetDuration(void) const;
2009 time_t GetTime(void) const;
2010 tChannelID GetChannelID(void) const;
2011 int GetChannelNumber(void) const { return nChannelNumber; }
2012 void SetChannelNumber(int ChannelNumber) const { ((cEventInfo *)this)->nChannelNumber = ChannelNumber; } // doesn't modify the EIT data, so it's ok to make it 'const'
2013 void Dump(FILE *f, const char *Prefix = "") const;
2017 void MVPClient::test(int channelNumber)
2019 FILE* f = fopen("/tmp/test.txt", "w");
2021 cMutexLock MutexLock;
2022 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
2026 fprintf(f, "Schedules = NULL\n");
2031 fprintf(f, "Schedules dump:\n");
2032 // Schedules->Dump(f);
2034 const cSchedule *Schedule;
2035 cChannel *thisChannel;
2036 const cEventInfo *event;
2038 thisChannel = channelFromNumber(channelNumber);
2041 fprintf(f, "thisChannel = NULL\n");
2046 Schedule = Schedules->GetSchedule(thisChannel->GetChannelID());
2047 // Schedule = Schedules->GetSchedule();
2048 // Schedule = Schedules->First();
2051 fprintf(f, "First Schedule = NULL\n");
2056 fprintf(f, "NumEvents() = %i\n\n", Schedule->NumEvents());
2058 // For some channels VDR seems to pick a random point in time to
2059 // start dishing out events, but they are in order
2060 // at some point in the list the time snaps to the current event
2065 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
2067 event = Schedule->GetEventNumber(eventNumber);
2068 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", eventNumber, event->GetEventID(), event->GetTime(), event->GetDuration());
2069 fprintf(f, "Event %i title = %s subtitle = %s\n", eventNumber, event->GetTitle(), event->GetSubtitle());
2070 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
2074 fprintf(f, "\nEND\n");
2083 Schedules = the collection of all the Schedule objects
2084 Schedule = One schedule, contants all the events for a channel
2085 Event = One programme
2094 Subtitle (used for "Programmes resume at ...")
2097 IsPresent ? easy to work out tho. Oh it doesn't always work
2100 void MVPClient::test2()
2102 log->log("-", Log::DEBUG, "Timers List");
2104 for (int i = 0; i < Timers.Count(); i++)
2106 cTimer *timer = Timers.Get(i);
2107 //Reply(i < Timers.Count() - 1 ? -250 : 250, "%d %s", timer->Index() + 1, timer->ToText());
2108 log->log("-", Log::DEBUG, "i=%i count=%i index=%d", i, Timers.Count(), timer->Index() + 1);
2109 #if VDRVERSNUM < 10300
2110 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());
2112 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());
2114 log->log("-", Log::DEBUG, "channel=%i file=%s summary=%s", timer->Channel()->Number(), timer->File(), timer->Summary());
2115 log->log("-", Log::DEBUG, "");
2118 // asprintf(&buffer, "%d:%s:%s :%04d:%04d:%d:%d:%s:%s\n",
2119 // active, (UseChannelID ? Channel()->GetChannelID().ToString() : itoa(Channel()->Number())),
2120 // PrintDay(day, firstday), start, stop, priority, lifetime, file, summary ? summary : "");
2124 Active seems to be a bool - whether the timer should be done or not. If set to inactive it stays around after its time
2125 recording is a bool, 0 for not currently recording, 1 for currently recording
2126 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