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)
800 log->log("Client", Log::ERR, "Client called start streaming twice");
804 log->log("Client", Log::DEBUG, "length = %i", length);
805 ULONG channelNumber = ntohl(*(ULONG*)data);
807 cChannel* channel = channelFromNumber(channelNumber);
812 tcp.sendPacket(rp->getPtr(), rp->getLen());
817 // get the priority we should use
819 int priority = config.getValueLong("General", "Live priority", &fail);
822 log->log("Client", Log::DEBUG, "Config: Live TV priority: %i", priority);
826 log->log("Client", Log::DEBUG, "Config: Live TV priority config fail");
831 if (priority < 0) priority = 0;
832 if (priority > 99) priority = 99;
834 log->log("Client", Log::DEBUG, "Using live TV priority %i", priority);
835 lp = MVPReceiver::create(channel, priority);
841 tcp.sendPacket(rp->getPtr(), rp->getLen());
846 if (!lp->init(&tcp, streamID))
852 tcp.sendPacket(rp->getPtr(), rp->getLen());
859 tcp.sendPacket(rp->getPtr(), rp->getLen());
864 int MVPClient::processStopStreaming(UCHAR* data, int length, ResponsePacket* rp)
866 log->log("Client", Log::DEBUG, "STOP STREAMING RECEIVED");
877 delete recordingManager;
879 recordingManager = NULL;
884 tcp.sendPacket(rp->getPtr(), rp->getLen());
889 int MVPClient::processGetBlock(UCHAR* data, int length, ResponsePacket* rp)
891 if (!lp && !recplayer)
893 log->log("Client", Log::DEBUG, "Get block called when no streaming happening!");
897 ULLONG position = ntohll(*(ULLONG*)data);
898 data += sizeof(ULLONG);
899 ULONG amount = ntohl(*(ULONG*)data);
901 log->log("Client", Log::DEBUG, "getblock pos = %llu length = %lu", position, amount);
903 UCHAR sendBuffer[amount];
904 ULONG amountReceived = 0; // compiler moan.
907 log->log("Client", Log::DEBUG, "getting from live");
908 amountReceived = lp->getBlock(&sendBuffer[0], amount);
912 // vdr has possibly disconnected the receiver
913 log->log("Client", Log::DEBUG, "VDR has disconnected the live receiver");
920 log->log("Client", Log::DEBUG, "getting from recording");
921 amountReceived = recplayer->getBlock(&sendBuffer[0], position, amount);
927 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
931 rp->copyin(sendBuffer, amountReceived);
932 log->log("Client", Log::DEBUG, "written %lu", amountReceived);
936 tcp.sendPacket(rp->getPtr(), rp->getLen());
937 log->log("Client", Log::DEBUG, "Finished getblock, have sent %lu", rp->getLen());
942 int MVPClient::processStartStreamingRecording(UCHAR* data, int length, ResponsePacket* rp)
944 // data is a pointer to the fileName string
946 recordingManager = new cRecordings;
947 recordingManager->Load();
949 cRecording* recording = recordingManager->GetByName((char*)data);
951 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
955 recplayer = new RecPlayer(recording);
957 rp->addULLONG(recplayer->getLengthBytes());
958 rp->addULONG(recplayer->getLengthFrames());
960 tcp.sendPacket(rp->getPtr(), rp->getLen());
963 log->log("Client", Log::DEBUG, "written totalLength");
967 delete recordingManager;
968 recordingManager = NULL;
973 int MVPClient::processPositionFromFrameNumber(UCHAR* data, int length, ResponsePacket* rp)
977 ULONG frameNumber = ntohl(*(ULONG*)data);
982 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
986 retval = recplayer->positionFromFrameNumber(frameNumber);
989 rp->addULLONG(retval);
991 tcp.sendPacket(rp->getPtr(), rp->getLen());
994 log->log("Client", Log::DEBUG, "Wrote posFromFrameNum reply to client");
998 int MVPClient::processFrameNumberFromPosition(UCHAR* data, int length, ResponsePacket* rp)
1002 ULLONG position = ntohll(*(ULLONG*)data);
1007 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
1011 retval = recplayer->frameNumberFromPosition(position);
1014 rp->addULONG(retval);
1016 tcp.sendPacket(rp->getPtr(), rp->getLen());
1019 log->log("Client", Log::DEBUG, "Wrote frameNumFromPos reply to client");
1023 int MVPClient::processGetIFrame(UCHAR* data, int length, ResponsePacket* rp)
1025 bool success = false;
1027 ULONG frameNumber = ntohl(*(ULONG*)data);
1029 ULONG direction = ntohl(*(ULONG*)data);
1032 ULLONG rfilePosition = 0;
1033 ULONG rframeNumber = 0;
1034 ULONG rframeLength = 0;
1038 log->log("Client", Log::DEBUG, "GetIFrame recording called when no recording being played!");
1042 success = recplayer->getNextIFrame(frameNumber, direction, &rfilePosition, &rframeNumber, &rframeLength);
1045 // returns file position, frame number, length
1049 rp->addULLONG(rfilePosition);
1050 rp->addULONG(rframeNumber);
1051 rp->addULONG(rframeLength);
1059 tcp.sendPacket(rp->getPtr(), rp->getLen());
1062 log->log("Client", Log::DEBUG, "Wrote GNIF reply to client %llu %lu %lu", rfilePosition, rframeNumber, rframeLength);
1066 int MVPClient::processGetChannelSchedule(UCHAR* data, int length, ResponsePacket* rp)
1068 ULONG channelNumber = ntohl(*(ULONG*)data);
1070 ULONG startTime = ntohl(*(ULONG*)data);
1072 ULONG duration = ntohl(*(ULONG*)data);
1074 log->log("Client", Log::DEBUG, "get schedule called for channel %lu", channelNumber);
1076 cChannel* channel = channelFromNumber(channelNumber);
1081 tcp.sendPacket(rp->getPtr(), rp->getLen());
1084 log->log("Client", Log::DEBUG, "written 0 because channel = NULL");
1088 log->log("Client", Log::DEBUG, "Got channel");
1090 #if VDRVERSNUM < 10300
1091 cMutexLock MutexLock;
1092 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1094 cSchedulesLock MutexLock;
1095 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1101 tcp.sendPacket(rp->getPtr(), rp->getLen());
1104 log->log("Client", Log::DEBUG, "written 0 because Schedule!s! = NULL");
1108 log->log("Client", Log::DEBUG, "Got schedule!s! object");
1110 const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
1115 tcp.sendPacket(rp->getPtr(), rp->getLen());
1118 log->log("Client", Log::DEBUG, "written 0 because Schedule = NULL");
1122 log->log("Client", Log::DEBUG, "Got schedule object");
1124 const char* empty = "";
1125 bool atLeastOneEvent = false;
1128 ULONG thisEventTime;
1129 ULONG thisEventDuration;
1130 const char* thisEventTitle;
1131 const char* thisEventSubTitle;
1132 const char* thisEventDescription;
1134 #if VDRVERSNUM < 10300
1136 const cEventInfo *event;
1137 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1139 event = Schedule->GetEventNumber(eventNumber);
1141 thisEventID = event->GetEventID();
1142 thisEventTime = event->GetTime();
1143 thisEventDuration = event->GetDuration();
1144 thisEventTitle = event->GetTitle();
1145 thisEventSubTitle = event->GetSubtitle();
1146 thisEventDescription = event->GetExtendedDescription();
1150 for (const cEvent* event = Schedule->Events()->First(); event; event = Schedule->Events()->Next(event))
1152 thisEventID = event->EventID();
1153 thisEventTime = event->StartTime();
1154 thisEventDuration = event->Duration();
1155 thisEventTitle = event->Title();
1156 thisEventSubTitle = NULL;
1157 thisEventDescription = event->Description();
1161 log->log("Client", Log::DEBUG, "Got an event object %p", event);
1163 //in the past filter
1164 if ((thisEventTime + thisEventDuration) < (ULONG)time(NULL)) continue;
1167 if ((thisEventTime + thisEventDuration) <= startTime) continue;
1170 if (thisEventTime >= (startTime + duration)) continue;
1172 if (!thisEventTitle) thisEventTitle = empty;
1173 if (!thisEventSubTitle) thisEventSubTitle = empty;
1174 if (!thisEventDescription) thisEventDescription = empty;
1176 rp->addULONG(thisEventID);
1177 rp->addULONG(thisEventTime);
1178 rp->addULONG(thisEventDuration);
1180 rp->addString(thisEventTitle);
1181 rp->addString(thisEventSubTitle);
1182 rp->addString(thisEventDescription);
1184 atLeastOneEvent = true;
1185 log->log("Client", Log::DEBUG, "Done s3");
1188 log->log("Client", Log::DEBUG, "Got all event data");
1190 if (!atLeastOneEvent)
1193 log->log("Client", Log::DEBUG, "Written 0 because no data");
1197 tcp.sendPacket(rp->getPtr(), rp->getLen());
1200 log->log("Client", Log::DEBUG, "written schedules packet");
1205 #endif //VOMPSTANDALONE
1207 int MVPClient::processConfigSave(UCHAR* buffer, int length, ResponsePacket* rp)
1209 char* section = (char*)buffer;
1213 for (int k = 0; k < length; k++)
1215 if (buffer[k] == '\0')
1219 key = (char*)&buffer[k+1];
1223 value = (char*)&buffer[k+1];
1229 // if the last string (value) doesnt have null terminator, give up
1230 if (buffer[length - 1] != '\0') return 0;
1232 log->log("Client", Log::DEBUG, "Config save: %s %s %s", section, key, value);
1233 if (config.setValueString(section, key, value))
1243 tcp.sendPacket(rp->getPtr(), rp->getLen());
1249 int MVPClient::processConfigLoad(UCHAR* buffer, int length, ResponsePacket* rp)
1251 char* section = (char*)buffer;
1254 for (int k = 0; k < length; k++)
1256 if (buffer[k] == '\0')
1258 key = (char*)&buffer[k+1];
1263 char* value = config.getValueString(section, key);
1267 rp->addString(value);
1268 log->log("Client", Log::DEBUG, "Written config load packet");
1274 log->log("Client", Log::DEBUG, "Written config load failed packet");
1278 tcp.sendPacket(rp->getPtr(), rp->getLen());
1284 #ifndef VOMPSTANDALONE
1286 int MVPClient::processGetTimers(UCHAR* buffer, int length, ResponsePacket* rp)
1289 int numTimers = Timers.Count();
1291 rp->addULONG(numTimers);
1293 for (int i = 0; i < numTimers; i++)
1295 timer = Timers.Get(i);
1297 #if VDRVERSNUM < 10300
1298 rp->addULONG(timer->Active());
1300 rp->addULONG(timer->HasFlags(tfActive));
1302 rp->addULONG(timer->Recording());
1303 rp->addULONG(timer->Pending());
1304 rp->addULONG(timer->Priority());
1305 rp->addULONG(timer->Lifetime());
1306 rp->addULONG(timer->Channel()->Number());
1307 rp->addULONG(timer->StartTime());
1308 rp->addULONG(timer->StopTime());
1309 rp->addULONG(timer->Day());
1310 rp->addULONG(timer->WeekDays());
1311 rp->addString(timer->File());
1315 tcp.sendPacket(rp->getPtr(), rp->getLen());
1318 log->log("Client", Log::DEBUG, "Written timers list");
1323 int MVPClient::processSetTimer(UCHAR* buffer, int length, ResponsePacket* rp)
1325 char* timerString = new char[strlen((char*)buffer) + 1];
1326 strcpy(timerString, (char*)buffer);
1328 #if VDRVERSNUM < 10300
1330 // If this is VDR 1.2 the date part of the timer string must be reduced
1331 // to just DD rather than YYYY-MM-DD
1333 int s = 0; // source
1334 int d = 0; // destination
1336 while(c != 2) // copy up to date section, including the second ':'
1338 timerString[d] = buffer[s];
1339 if (buffer[s] == ':') c++;
1343 // now it has copied up to the date section
1345 while(c != 2) // waste YYYY-MM-
1347 if (buffer[s] == '-') c++;
1350 // now source is at the DD
1351 memcpy(&timerString[d], &buffer[s], length - s);
1353 timerString[d] = '\0';
1355 log->log("Client", Log::DEBUG, "Timer string after 1.2 conversion:");
1356 log->log("Client", Log::DEBUG, "%s", timerString);
1360 cTimer *timer = new cTimer;
1361 if (timer->Parse((char*)timerString))
1363 cTimer *t = Timers.GetTimer(timer);
1367 #if VDRVERSNUM < 10300
1370 Timers.SetModified();
1374 tcp.sendPacket(rp->getPtr(), rp->getLen());
1382 tcp.sendPacket(rp->getPtr(), rp->getLen());
1390 tcp.sendPacket(rp->getPtr(), rp->getLen());
1397 int MVPClient::processDeleteTimer(UCHAR* buffer, int length, ResponsePacket* rp)
1399 log->log("Client", Log::DEBUG, "Delete timer called");
1404 INT delChannel = ntohl(*(ULONG*)&buffer[position]); position += 4;
1405 INT delWeekdays = ntohl(*(ULONG*)&buffer[position]); position += 4;
1406 INT delDay = ntohl(*(ULONG*)&buffer[position]); position += 4;
1407 INT delStart = ntohl(*(ULONG*)&buffer[position]); position += 4;
1408 INT delStop = ntohl(*(ULONG*)&buffer[position]); position += 4;
1411 for (ti = Timers.First(); ti; ti = Timers.Next(ti))
1413 if ( (ti->Channel()->Number() == delChannel)
1414 && ((ti->WeekDays() && (ti->WeekDays() == delWeekdays)) || (!ti->WeekDays() && (ti->Day() == delDay)))
1415 && (ti->StartTime() == delStart)
1416 && (ti->StopTime() == delStop) )
1424 tcp.sendPacket(rp->getPtr(), rp->getLen());
1429 if (!Timers.BeingEdited())
1431 if (!ti->Recording())
1434 Timers.SetModified();
1437 tcp.sendPacket(rp->getPtr(), rp->getLen());
1443 log->log("Client", Log::ERR, "Unable to delete timer - timer is running");
1446 tcp.sendPacket(rp->getPtr(), rp->getLen());
1453 log->log("Client", Log::ERR, "Unable to delete timer - timers being edited at VDR");
1456 tcp.sendPacket(rp->getPtr(), rp->getLen());
1462 int MVPClient::processGetRecInfo(UCHAR* data, int length, ResponsePacket* rp)
1464 // data is a pointer to the fileName string
1466 cRecordings Recordings;
1467 Recordings.Load(); // probably have to do this
1469 cRecording *recording = Recordings.GetByName((char*)data);
1471 time_t timerStart = 0;
1472 time_t timerStop = 0;
1473 char* summary = NULL;
1474 ULONG resumePoint = 0;
1478 log->log("Client", Log::ERR, "GetRecInfo found no recording");
1481 tcp.sendPacket(rp->getPtr(), rp->getLen());
1487 4 bytes: start time for timer
1488 4 bytes: end time for timer
1489 4 bytes: resume point
1491 4 bytes: num components
1501 // Get current timer
1503 cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
1506 timerStart = rc->Timer()->StartTime();
1507 timerStop = rc->Timer()->StopTime();
1508 log->log("Client", Log::DEBUG, "GRI: RC: %lu %lu", timerStart, timerStop);
1511 rp->addULONG(timerStart);
1512 rp->addULONG(timerStop);
1516 char* value = config.getValueString("ResumeData", (char*)data);
1519 resumePoint = strtoul(value, NULL, 10);
1522 log->log("Client", Log::DEBUG, "GRI: RP: %lu", resumePoint);
1524 rp->addULONG(resumePoint);
1529 #if VDRVERSNUM < 10300
1530 summary = (char*)recording->Summary();
1532 const cRecordingInfo *Info = recording->Info();
1533 summary = (char*)Info->ShortText();
1534 if (isempty(summary)) summary = (char*)Info->Description();
1536 log->log("Client", Log::DEBUG, "GRI: S: %s", summary);
1539 rp->addString(summary);
1548 #if VDRVERSNUM < 10300
1550 // Send 0 for numchannels - this signals the client this info is not available
1554 const cComponents* components = Info->Components();
1556 log->log("Client", Log::DEBUG, "GRI: D1: %p", components);
1564 rp->addULONG(components->NumComponents());
1566 tComponent* component;
1567 for (int i = 0; i < components->NumComponents(); i++)
1569 component = components->Component(i);
1571 log->log("Client", Log::DEBUG, "GRI: C: %i %u %u %s %s", i, component->stream, component->type, component->language, component->description);
1573 rp->addUCHAR(component->stream);
1574 rp->addUCHAR(component->type);
1576 if (component->language)
1578 rp->addString(component->language);
1584 if (component->description)
1586 rp->addString(component->description);
1600 tcp.sendPacket(rp->getPtr(), rp->getLen());
1603 log->log("Client", Log::DEBUG, "Written getrecinfo");
1613 int MVPClient::processReScanRecording(UCHAR* data, int length, ResponsePacket* rp)
1617 log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!");
1623 rp->addULLONG(recplayer->getLengthBytes());
1624 rp->addULONG(recplayer->getLengthFrames());
1626 tcp.sendPacket(rp->getPtr(), rp->getLen());
1628 log->log("Client", Log::DEBUG, "Rescan recording, wrote new length to client");
1632 // FIXME without client calling rescan, getblock wont work even tho more data is avail
1635 int MVPClient::processGetMarks(UCHAR* data, int length, ResponsePacket* rp)
1637 // data is a pointer to the fileName string
1640 cRecordings Recordings;
1641 Recordings.Load(); // probably have to do this
1643 cRecording *recording = Recordings.GetByName((char*)data);
1645 log->log("Client", Log::DEBUG, "recording pointer %p", recording);
1649 Marks.Load(recording->FileName());
1652 for (const cMark *m = Marks.First(); m; m = Marks.Next(m))
1654 log->log("Client", Log::DEBUG, "found Mark %i", m->position);
1656 rp->addULONG(m->position);
1661 log->log("Client", Log::DEBUG, "no marks found, sending 0-mark");
1667 tcp.sendPacket(rp->getPtr(), rp->getLen());
1670 log->log("Client", Log::DEBUG, "Written Marks list");
1675 #endif //VOMPSTANDALONE
1678 * media List Request:
1680 * 4 VDR_GETMEDIALIST
1681 * 4 flags (currently unused)
1684 * Media List response:
1692 * 4 strlen (incl. 0 Byte)
1697 int MVPClient::processGetMediaList(UCHAR* data, int length, ResponsePacket* rp)
1700 log->log("Client", Log::ERR, "getMediaList packet too short %d", length);
1703 char * dirname=NULL;
1705 //we have a dirname provided
1706 dirname=(char *)&data[4];
1707 log->log("Client", Log::DEBUG, "getMediaList for %s", dirname);
1710 MediaList * ml=MediaList::readList(baseConfig,dirname);
1712 log->log("Client", Log::ERR, "getMediaList returned NULL");
1716 //response code (not yet set)
1720 rp->addULONG(ml->size());
1722 for (MediaList::iterator nm=ml->begin(); nm<ml->end(); nm++)
1725 log->log("Client", Log::DEBUG, "found media entry %s, type=%d",m->getFilename(),m->getType());
1726 rp->addULONG(m->getType());
1728 rp->addULONG(m->getTime());
1731 int len=strlen(m->getFilename());
1733 rp->addULONG(len+1);
1734 rp->addString(m->getFilename());
1739 tcp.sendPacket(rp->getPtr(), rp->getLen());
1742 log->log("Client", Log::DEBUG, "Written Media list");
1747 * get image Request:
1748 * 4 flags (currently unused)
1753 * get image response:
1759 int MVPClient::processGetPicture(UCHAR* data, int length, ResponsePacket* rp)
1762 log->log("Client", Log::ERR, "getPicture packet too short %d", length);
1769 char * filename=NULL;
1771 //we have a dirname provided
1772 filename=(char *)&data[12];
1773 log->log("Client", Log::DEBUG, "getPicture %s", filename);
1776 log->log("Client", Log::ERR, "getPicture empty filename");
1779 imageFile=fopen(filename,"r");
1780 if (!imageFile) log->log("Client", Log::ERR, "getPicture unable to open %s",filename);
1785 if ( fstat(fileno(imageFile),&st) == 0) size=st.st_size;
1787 //response code (not yet set)
1792 log->log("Client", Log::DEBUG, "getPicture size %u", size);
1795 tcp.sendPacket(rp->getPtr(), rp->getLen());
1798 log->log("Client", Log::DEBUG, "Written getPicture");
1804 int MVPClient::processGetImageBlock(UCHAR* data, int length, ResponsePacket* rp)
1808 log->log("Client", Log::DEBUG, "Get image block called when no image active");
1812 ULLONG position = ntohll(*(ULLONG*)data);
1813 data += sizeof(ULLONG);
1814 ULONG amount = ntohl(*(ULONG*)data);
1816 log->log("Client", Log::DEBUG, "getImageblock pos = %llu length = %lu", position, amount);
1818 UCHAR sendBuffer[amount];
1819 ULONG amountReceived = 0; // compiler moan.
1820 ULLONG cpos=ftell(imageFile);
1821 if (position != cpos) {
1822 fseek(imageFile,position-cpos,SEEK_CUR);
1824 if (position != (ULLONG)ftell(imageFile)) {
1825 log->log("Client", Log::DEBUG, "getImageblock pos = %llu not available", position);
1828 amountReceived=fread(&sendBuffer[0],1,amount,imageFile);
1831 if (!amountReceived)
1834 log->log("Client", Log::DEBUG, "written 4(0) as getblock got 0");
1838 rp->copyin(sendBuffer, amount);
1839 log->log("Client", Log::DEBUG, "written %lu", amountReceived);
1843 tcp.sendPacket(rp->getPtr(), rp->getLen());
1860 event = Schedule->GetPresentEvent();
1862 fprintf(f, "\n\nCurrent event\n\n");
1864 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", 0, event->GetEventID(), event->GetTime(), event->GetDuration());
1865 fprintf(f, "Event %i title = %s subtitle = %s\n", 0, event->GetTitle(), event->GetSubtitle());
1866 fprintf(f, "Event %i extendeddescription = %s\n", 0, event->GetExtendedDescription());
1867 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", 0, event->IsFollowing(), event->IsPresent());
1869 event = Schedule->GetFollowingEvent();
1871 fprintf(f, "\n\nFollowing event\n\n");
1873 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", 0, event->GetEventID(), event->GetTime(), event->GetDuration());
1874 fprintf(f, "Event %i title = %s subtitle = %s\n", 0, event->GetTitle(), event->GetSubtitle());
1875 fprintf(f, "Event %i extendeddescription = %s\n", 0, event->GetExtendedDescription());
1876 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", 0, event->IsFollowing(), event->IsPresent());
1880 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", eventNumber, event->GetEventID(), event->GetTime(), event->GetDuration());
1881 fprintf(f, "Event %i title = %s subtitle = %s\n", eventNumber, event->GetTitle(), event->GetSubtitle());
1882 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
1883 fprintf(f, "Event %i isFollowing = %i, isPresent = %i\n", eventNumber, event->IsFollowing(), event->IsPresent());
1889 void MVPClient::test2()
1891 FILE* f = fopen("/tmp/s.txt", "w");
1893 #if VDRVERSNUM < 10300
1894 cMutexLock MutexLock;
1895 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
1897 cSchedulesLock MutexLock;
1898 const cSchedules *Schedules = cSchedules::Schedules(MutexLock);
1903 fprintf(f, "Schedules = NULL\n");
1908 fprintf(f, "Schedules dump:\n");
1912 const cSchedule *Schedule;
1913 int scheduleNumber = 0;
1916 cChannel *thisChannel;
1918 #if VDRVERSNUM < 10300
1919 const cEventInfo *event;
1920 int eventNumber = 0;
1922 const cEvent *event;
1925 // Schedule = Schedules->GetSchedule(channel->GetChannelID());
1926 // Schedule = Schedules->GetSchedule();
1927 Schedule = Schedules->First();
1930 fprintf(f, "First Schedule = NULL\n");
1937 fprintf(f, "Schedule #%i\n", scheduleNumber);
1938 fprintf(f, "-------------\n\n");
1940 #if VDRVERSNUM < 10300
1941 tchid = Schedule->GetChannelID();
1943 tchid = Schedule->ChannelID();
1946 #if VDRVERSNUM < 10300
1947 fprintf(f, "ChannelID.ToString() = %s\n", tchid.ToString());
1948 fprintf(f, "NumEvents() = %i\n", Schedule->NumEvents());
1950 // put the count at the end.
1953 thisChannel = Channels.GetByChannelID(tchid, true);
1956 fprintf(f, "Channel Number: %p %i\n", thisChannel, thisChannel->Number());
1960 fprintf(f, "thisChannel = NULL for tchid\n");
1963 #if VDRVERSNUM < 10300
1964 for (eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
1966 event = Schedule->GetEventNumber(eventNumber);
1967 fprintf(f, "Event %i tableid = %i timestring = %s endtimestring = %s\n", eventNumber, event->GetTableID(), event->GetTimeString(), event->GetEndTimeString());
1968 fprintf(f, "Event %i date = %s isfollowing = %i ispresent = %i\n", eventNumber, event->GetDate(), event->IsFollowing(), event->IsPresent());
1969 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
1970 fprintf(f, "Event %i subtitle = %s title = %s\n", eventNumber, event->GetSubtitle(), event->GetTitle());
1971 fprintf(f, "Event %i eventid = %u duration = %li time = %lu channelnumber = %i\n", eventNumber, event->GetEventID(), event->GetDuration(), event->GetTime(), event->GetChannelNumber());
1972 fprintf(f, "Event %u dump:\n", eventNumber);
1977 // This whole section needs rewriting to walk the list.
1978 event = Schedule->Events()->First();
1980 event = Schedule->Events()->Next(event);
1985 fprintf(f, "\nDump from object:\n");
1987 fprintf(f, "\nEND\n");
1992 fprintf(f, "End of current Schedule\n\n\n");
1994 Schedule = (const cSchedule *)Schedules->Next(Schedule);
2002 const cEventInfo *GetPresentEvent(void) const;
2003 const cEventInfo *GetFollowingEvent(void) const;
2004 const cEventInfo *GetEvent(unsigned short uEventID, time_t tTime = 0) const;
2005 const cEventInfo *GetEventAround(time_t tTime) const;
2006 const cEventInfo *GetEventNumber(int n) const { return Events.Get(n); }
2009 const unsigned char GetTableID(void) const;
2010 const char *GetTimeString(void) const;
2011 const char *GetEndTimeString(void) const;
2012 const char *GetDate(void) const;
2013 bool IsFollowing(void) const;
2014 bool IsPresent(void) const;
2015 const char *GetExtendedDescription(void) const;
2016 const char *GetSubtitle(void) const;
2017 const char *GetTitle(void) const;
2018 unsigned short GetEventID(void) const;
2019 long GetDuration(void) const;
2020 time_t GetTime(void) const;
2021 tChannelID GetChannelID(void) const;
2022 int GetChannelNumber(void) const { return nChannelNumber; }
2023 void SetChannelNumber(int ChannelNumber) const { ((cEventInfo *)this)->nChannelNumber = ChannelNumber; } // doesn't modify the EIT data, so it's ok to make it 'const'
2024 void Dump(FILE *f, const char *Prefix = "") const;
2028 void MVPClient::test(int channelNumber)
2030 FILE* f = fopen("/tmp/test.txt", "w");
2032 cMutexLock MutexLock;
2033 const cSchedules *Schedules = cSIProcessor::Schedules(MutexLock);
2037 fprintf(f, "Schedules = NULL\n");
2042 fprintf(f, "Schedules dump:\n");
2043 // Schedules->Dump(f);
2045 const cSchedule *Schedule;
2046 cChannel *thisChannel;
2047 const cEventInfo *event;
2049 thisChannel = channelFromNumber(channelNumber);
2052 fprintf(f, "thisChannel = NULL\n");
2057 Schedule = Schedules->GetSchedule(thisChannel->GetChannelID());
2058 // Schedule = Schedules->GetSchedule();
2059 // Schedule = Schedules->First();
2062 fprintf(f, "First Schedule = NULL\n");
2067 fprintf(f, "NumEvents() = %i\n\n", Schedule->NumEvents());
2069 // For some channels VDR seems to pick a random point in time to
2070 // start dishing out events, but they are in order
2071 // at some point in the list the time snaps to the current event
2076 for (int eventNumber = 0; eventNumber < Schedule->NumEvents(); eventNumber++)
2078 event = Schedule->GetEventNumber(eventNumber);
2079 fprintf(f, "Event %i eventid = %u time = %lu duration = %li\n", eventNumber, event->GetEventID(), event->GetTime(), event->GetDuration());
2080 fprintf(f, "Event %i title = %s subtitle = %s\n", eventNumber, event->GetTitle(), event->GetSubtitle());
2081 fprintf(f, "Event %i extendeddescription = %s\n", eventNumber, event->GetExtendedDescription());
2085 fprintf(f, "\nEND\n");
2094 Schedules = the collection of all the Schedule objects
2095 Schedule = One schedule, contants all the events for a channel
2096 Event = One programme
2105 Subtitle (used for "Programmes resume at ...")
2108 IsPresent ? easy to work out tho. Oh it doesn't always work
2111 void MVPClient::test2()
2113 log->log("-", Log::DEBUG, "Timers List");
2115 for (int i = 0; i < Timers.Count(); i++)
2117 cTimer *timer = Timers.Get(i);
2118 //Reply(i < Timers.Count() - 1 ? -250 : 250, "%d %s", timer->Index() + 1, timer->ToText());
2119 log->log("-", Log::DEBUG, "i=%i count=%i index=%d", i, Timers.Count(), timer->Index() + 1);
2120 #if VDRVERSNUM < 10300
2121 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());
2123 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());
2125 log->log("-", Log::DEBUG, "channel=%i file=%s summary=%s", timer->Channel()->Number(), timer->File(), timer->Summary());
2126 log->log("-", Log::DEBUG, "");
2129 // asprintf(&buffer, "%d:%s:%s :%04d:%04d:%d:%d:%s:%s\n",
2130 // active, (UseChannelID ? Channel()->GetChannelID().ToString() : itoa(Channel()->Number())),
2131 // PrintDay(day, firstday), start, stop, priority, lifetime, file, summary ? summary : "");
2135 Active seems to be a bool - whether the timer should be done or not. If set to inactive it stays around after its time
2136 recording is a bool, 0 for not currently recording, 1 for currently recording
2137 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