22#include <netinet/in.h>
27#include <sys/socket.h>
45#define dbgsvdrp(a...) if (DumpSVDRPDataTransfer) fprintf(stderr, a)
70 void Set(
const sockaddr *SockAddr);
93 const sockaddr_in *Addr = (sockaddr_in *)SockAddr;
94 Set(inet_ntoa(Addr->sin_addr), ntohs(Addr->sin_port));
111 bool Connect(
const char *Address);
146 sock =
tcp ? socket(PF_INET, SOCK_STREAM, IPPROTO_IP) : socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
153 setsockopt(
sock, SOL_SOCKET, SO_REUSEADDR, &ReUseAddr,
sizeof(ReUseAddr));
156 memset(&Addr, 0,
sizeof(Addr));
157 Addr.sin_family = AF_INET;
158 Addr.sin_port = htons(
port);
160 if (bind(
sock, (sockaddr *)&Addr,
sizeof(Addr)) < 0) {
166 int Flags = fcntl(
sock, F_GETFL, 0);
172 if (fcntl(
sock, F_SETFL, Flags) < 0) {
178 if (listen(
sock, 1) < 0) {
192 sock = socket(PF_INET, SOCK_STREAM, IPPROTO_IP);
199 memset(&Addr, 0,
sizeof(Addr));
200 Addr.sin_family = AF_INET;
201 Addr.sin_port = htons(
port);
202 Addr.sin_addr.s_addr = inet_addr(Address);
203 if (connect(
sock, (sockaddr *)&Addr,
sizeof(Addr)) < 0) {
209 int Flags = fcntl(
sock, F_GETFL, 0);
215 if (fcntl(
sock, F_SETFL, Flags) < 0) {
219 dbgsvdrp(
"> %s:%d server connection established\n", Address,
port);
229 int Socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
236 if (setsockopt(
Socket, SOL_SOCKET, SO_BROADCAST, &One,
sizeof(One)) < 0) {
243 memset(&Addr, 0,
sizeof(Addr));
244 Addr.sin_family = AF_INET;
245 Addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
246 Addr.sin_port = htons(
Port);
248 dbgsvdrp(
"> %s:%d %s\n", inet_ntoa(Addr.sin_addr),
Port, Dgram);
250 int Length = strlen(Dgram);
251 int Sent = sendto(
Socket, Dgram, Length, 0, (sockaddr *)&Addr,
sizeof(Addr));
255 return Sent == Length;
262 uint Size =
sizeof(Addr);
263 int NewSock = accept(
sock, (sockaddr *)&Addr, &Size);
267 const char *s =
"Access denied!\n";
268 if (write(NewSock, s, strlen(s)) < 0)
289 uint Size =
sizeof(Addr);
290 int NumBytes = recvfrom(
sock, buf,
sizeof(buf), 0, (sockaddr *)&Addr, &Size);
328 bool Send(
const char *Command);
335 bool HasAddress(
const char *Address,
int Port)
const;
347:serverIpAddress(Address, Port)
353 timeout = Timeout * 1000 * 9 / 10;
403#define SVDRPResonseTimeout 5000
410 if (c ==
'\n' || c == 0x00) {
412 while (numChars > 0 && strchr(
" \t\r\n",
input[numChars - 1]))
413 input[--numChars] = 0;
420 switch (atoi(
input)) {
421 case 220:
if (numChars > 4) {
423 if (
char *t = strchr(n,
' ')) {
440 if (numChars >= 4 &&
input[3] !=
'-')
445 if (numChars >=
length - 1) {
446 int NewLength =
length + BUFSIZ;
447 if (
char *NewBuffer = (
char *)realloc(
input, NewLength)) {
457 input[numChars++] = c;
472 else if (!Response && numChars == 0)
505 if (
Execute(
"LSTT ID", &Response)) {
506 for (
int i = 0; i < Response.
Size(); i++) {
507 char *s = Response[i];
511 else if (Code == 550)
550 if (Params && *Params) {
568 error =
"invalid timeout";
571 error =
"missing server timeout";
574 error =
"missing server apiversion";
577 error =
"missing server vdrversion";
580 error =
"missing server port";
583 error =
"missing server name";
586 error =
"missing server parameters";
604 virtual void Action(
void);
609 bool Execute(
const char *ServerName,
const char *Command,
cStringList *Response = NULL);
617:
cThread(
"SVDRP client handler", true)
618,udpSocket(UdpPort, false)
665 bool TimersModified = Timers->StoreRemoteTimers(Client->
ServerName(), &RemoteTimers);
672 if (*PollTimersCmd) {
673 if (!Client->
Execute(PollTimersCmd))
707 if (ServerParams.
Ok())
734 return Client->Execute(Command, Response);
741 ServerNames->
Clear();
747 return ServerNames->
Size() > 0;
777 if ((
f = tmpfile()) != NULL) {
779 message =
"Enter EPG data, end with \".\" on a line by itself";
784 message =
"Error while opening temporary file";
797 if (strcmp(s,
".") != 0) {
807 message =
"EPG data processed";
811 message =
"Error while processing EPG data";
822#define MAXHELPTOPIC 10
823#define EITDISABLETIME 10
827 "CHAN [ + | - | <number> | <name> | <id> ]\n"
828 " Switch channel up, down or to the given channel number, name or id.\n"
829 " Without option (or after successfully switching to the channel)\n"
830 " it returns the current channel number and name.",
831 "CLRE [ <number> | <name> | <id> ]\n"
832 " Clear the EPG list of the given channel number, name or id.\n"
833 " Without option it clears the entire EPG list.\n"
834 " After a CLRE command, no further EPG processing is done for 10\n"
835 " seconds, so that data sent with subsequent PUTE commands doesn't\n"
836 " interfere with data from the broadcasters.",
837 "CONN name:<name> port:<port> vdrversion:<vdrversion> apiversion:<apiversion> timeout:<timeout>\n"
838 " Used by peer-to-peer connections between VDRs to tell the other VDR\n"
839 " to establish a connection to this VDR. The name is the SVDRP host name\n"
840 " of this VDR, which may differ from its DNS name.",
841 "CPYR <number> <new name>\n"
842 " Copy the recording with the given number. Before a recording can be\n"
843 " copied, an LSTR command must have been executed in order to retrieve\n"
844 " the recording numbers.\n",
845 "DELC <number> | <id>\n"
846 " Delete the channel with the given number or channel id.",
848 " Delete the recording with the given id. Before a recording can be\n"
849 " deleted, an LSTR command should have been executed in order to retrieve\n"
850 " the recording ids. The ids are unique and don't change while this\n"
851 " instance of VDR is running.\n"
852 " CAUTION: THERE IS NO CONFIRMATION PROMPT WHEN DELETING A\n"
853 " RECORDING - BE SURE YOU KNOW WHAT YOU ARE DOING!",
855 " Delete the timer with the given id. If this timer is currently recording,\n"
856 " the recording will be stopped without any warning.",
858 " Edit the recording with the given id. Before a recording can be\n"
859 " edited, an LSTR command should have been executed in order to retrieve\n"
860 " the recording ids.",
861 "GRAB <filename> [ <quality> [ <sizex> <sizey> ] ]\n"
862 " Grab the current frame and save it to the given file. Images can\n"
863 " be stored as JPEG or PNM, depending on the given file name extension.\n"
864 " The quality of the grabbed image can be in the range 0..100, where 100\n"
865 " (the default) means \"best\" (only applies to JPEG). The size parameters\n"
866 " define the size of the resulting image (default is full screen).\n"
867 " If the file name is just an extension (.jpg, .jpeg or .pnm) the image\n"
868 " data will be sent to the SVDRP connection encoded in base64. The same\n"
869 " happens if '-' (a minus sign) is given as file name, in which case the\n"
870 " image format defaults to JPEG.",
872 " The HELP command gives help info.",
873 "HITK [ <key> ... ]\n"
874 " Hit the given remote control key. Without option a list of all\n"
875 " valid key names is given. If more than one key is given, they are\n"
876 " entered into the remote control queue in the given sequence. There\n"
877 " can be up to 31 keys.",
878 "LSTC [ :ids ] [ :groups | <number> | <name> | <id> ]\n"
879 " List channels. Without option, all channels are listed. Otherwise\n"
880 " only the given channel is listed. If a name is given, all channels\n"
881 " containing the given string as part of their name are listed.\n"
882 " If ':groups' is given, all channels are listed including group\n"
883 " separators. The channel number of a group separator is always 0.\n"
884 " With ':ids' the channel ids are listed following the channel numbers.\n"
885 " The special number 0 can be given to list the current channel.",
887 " List all available devices. Each device is listed with its name and\n"
888 " whether it is currently the primary device ('P') or it implements a\n"
889 " decoder ('D') and can be used as output device.",
890 "LSTE [ <channel> ] [ now | next | at <time> ]\n"
891 " List EPG data. Without any parameters all data of all channels is\n"
892 " listed. If a channel is given (either by number or by channel ID),\n"
893 " only data for that channel is listed. 'now', 'next', or 'at <time>'\n"
894 " restricts the returned data to present events, following events, or\n"
895 " events at the given time (which must be in time_t form).",
896 "LSTR [ <id> [ path ] ]\n"
897 " List recordings. Without option, all recordings are listed. Otherwise\n"
898 " the information for the given recording is listed. If a recording\n"
899 " id and the keyword 'path' is given, the actual file name of that\n"
900 " recording's directory is listed.\n"
901 " Note that the ids of the recordings are not necessarily given in\n"
903 "LSTT [ <id> ] [ id ]\n"
904 " List timers. Without option, all timers are listed. Otherwise\n"
905 " only the timer with the given id is listed. If the keyword 'id' is\n"
906 " given, the channels will be listed with their unique channel ids\n"
907 " instead of their numbers. This command lists only the timers that are\n"
908 " defined locally on this VDR, not any remote timers from other VDRs.",
910 " Displays the given message on the OSD. The message will be queued\n"
911 " and displayed whenever this is suitable.\n",
912 "MODC <number> <settings>\n"
913 " Modify a channel. Settings must be in the same format as returned\n"
914 " by the LSTC command.",
915 "MODT <id> on | off | <settings>\n"
916 " Modify a timer. Settings must be in the same format as returned\n"
917 " by the LSTT command. The special keywords 'on' and 'off' can be\n"
918 " used to easily activate or deactivate a timer.",
919 "MOVC <number> <to>\n"
920 " Move a channel to a new position.",
921 "MOVR <id> <new name>\n"
922 " Move the recording with the given id. Before a recording can be\n"
923 " moved, an LSTR command should have been executed in order to retrieve\n"
924 " the recording ids. The ids don't change during subsequent MOVR\n"
927 " Create a new channel. Settings must be in the same format as returned\n"
928 " by the LSTC command.",
930 " Create a new timer. Settings must be in the same format as returned\n"
931 " by the LSTT command.",
932 "NEXT [ abs | rel ]\n"
933 " Show the next timer event. If no option is given, the output will be\n"
934 " in human readable form. With option 'abs' the absolute time of the next\n"
935 " event will be given as the number of seconds since the epoch (time_t\n"
936 " format), while with option 'rel' the relative time will be given as the\n"
937 " number of seconds from now until the event. If the absolute time given\n"
938 " is smaller than the current time, or if the relative time is less than\n"
939 " zero, this means that the timer is currently recording and has started\n"
940 " at the given time. The first value in the resulting line is the id\n"
943 " Used by peer-to-peer connections between VDRs to keep the connection\n"
944 " from timing out. May be used at any time and simply returns a line of\n"
945 " the form '<hostname> is alive'.",
946 "PLAY <id> [ begin | <position> ]\n"
947 " Play the recording with the given id. Before a recording can be\n"
948 " played, an LSTR command should have been executed in order to retrieve\n"
949 " the recording ids.\n"
950 " The keyword 'begin' plays the recording from its very beginning, while\n"
951 " a <position> (given as hh:mm:ss[.ff] or framenumber) starts at that\n"
952 " position. If neither 'begin' nor a <position> are given, replay is resumed\n"
953 " at the position where any previous replay was stopped, or from the beginning\n"
954 " by default. To control or stop the replay session, use the usual remote\n"
955 " control keypresses via the HITK command.",
956 "PLUG <name> [ help | main ] [ <command> [ <options> ]]\n"
957 " Send a command to a plugin.\n"
958 " The PLUG command without any parameters lists all plugins.\n"
959 " If only a name is given, all commands known to that plugin are listed.\n"
960 " If a command is given (optionally followed by parameters), that command\n"
961 " is sent to the plugin, and the result will be displayed.\n"
962 " The keyword 'help' lists all the SVDRP commands known to the named plugin.\n"
963 " If 'help' is followed by a command, the detailed help for that command is\n"
964 " given. The keyword 'main' initiates a call to the main menu function of the\n"
966 "POLL <name> timers\n"
967 " Used by peer-to-peer connections between VDRs to inform other machines\n"
968 " about changes to timers. The receiving VDR shall use LSTT to query the\n"
969 " remote machine with the given name about its timers and update its list\n"
970 " of timers accordingly.\n",
971 "PRIM [ <number> ]\n"
972 " Make the device with the given number the primary device.\n"
973 " Without option it returns the currently active primary device in the same\n"
974 " format as used by the LSTD command.",
976 " Put data into the EPG list. The data entered has to strictly follow the\n"
977 " format defined in vdr(5) for the 'epg.data' file. A '.' on a line\n"
978 " by itself terminates the input and starts processing of the data (all\n"
979 " entered data is buffered until the terminating '.' is seen).\n"
980 " If a file name is given, epg data will be read from this file (which\n"
981 " must be accessible under the given name from the machine VDR is running\n"
982 " on). In case of file input, no terminating '.' shall be given.\n",
983 "REMO [ on | off ]\n"
984 " Turns the remote control on or off. Without a parameter, the current\n"
985 " status of the remote control is reported.",
987 " Forces an EPG scan. If this is a single DVB device system, the scan\n"
988 " will be done on the primary device unless it is currently recording.",
990 " Return information about disk usage (total, free, percent).",
992 " Updates a timer. Settings must be in the same format as returned\n"
993 " by the LSTT command. If a timer with the same channel, day, start\n"
994 " and stop time does not yet exist, it will be created.",
996 " Initiates a re-read of the recordings directory, which is the SVDRP\n"
997 " equivalent to 'touch .update'.",
998 "VOLU [ <number> | + | - | mute ]\n"
999 " Set the audio volume to the given number (which is limited to the range\n"
1000 " 0...255). If the special options '+' or '-' are given, the volume will\n"
1001 " be turned up or down, respectively. The option 'mute' will toggle the\n"
1002 " audio muting. If no option is given, the current audio volume level will\n"
1005 " Exit vdr (SVDRP).\n"
1006 " You can also hit Ctrl-D to exit.",
1034 const char *q = HelpPage;
1037 uint n = q - HelpPage;
1038 if (n >=
sizeof(topic))
1039 n =
sizeof(topic) - 1;
1040 strncpy(topic, HelpPage, n);
1054 if (strcasecmp(Cmd, t) == 0)
1075 void Close(
bool SendReply =
false,
bool Timeout =
false);
1076 bool Send(
const char *s);
1079 void CmdCHAN(const
char *Option);
1080 void CmdCLRE(const
char *Option);
1081 void CmdCONN(const
char *Option);
1082 void CmdCPYR(const
char *Option);
1083 void CmdDELC(const
char *Option);
1084 void CmdDELR(const
char *Option);
1085 void CmdDELT(const
char *Option);
1086 void CmdEDIT(const
char *Option);
1087 void CmdGRAB(const
char *Option);
1088 void CmdHELP(const
char *Option);
1089 void CmdHITK(const
char *Option);
1090 void CmdLSTC(const
char *Option);
1091 void CmdLSTD(const
char *Option);
1092 void CmdLSTE(const
char *Option);
1093 void CmdLSTR(const
char *Option);
1094 void CmdLSTT(const
char *Option);
1095 void CmdMESG(const
char *Option);
1096 void CmdMODC(const
char *Option);
1097 void CmdMODT(const
char *Option);
1098 void CmdMOVC(const
char *Option);
1099 void CmdMOVR(const
char *Option);
1100 void CmdNEWC(const
char *Option);
1101 void CmdNEWT(const
char *Option);
1102 void CmdNEXT(const
char *Option);
1103 void CmdPING(const
char *Option);
1104 void CmdPLAY(const
char *Option);
1105 void CmdPLUG(const
char *Option);
1106 void CmdPOLL(const
char *Option);
1107 void CmdPRIM(const
char *Option);
1108 void CmdPUTE(const
char *Option);
1109 void CmdREMO(const
char *Option);
1110 void CmdSCAN(const
char *Option);
1111 void CmdSTAT(const
char *Option);
1112 void CmdUPDT(const
char *Option);
1113 void CmdUPDR(const
char *Option);
1114 void CmdVOLU(const
char *Option);
1137 time_t now = time(NULL);
1180 char *buffer = NULL;
1183 if (vasprintf(&buffer, fmt, ap) >= 0) {
1186 char *n = strchr(s,
'\n');
1190 if (Code < 0 || n && *(n + 1))
1194 s = n ? n + 1 : NULL;
1198 Reply(451,
"Bad format - looks like a programming error!");
1205 Reply(451,
"Zero return code - looks like a programming error!");
1221 const int TopicsPerLine = 5;
1223 for (
int y = 0; (y * TopicsPerLine + x) < NumPages; y++) {
1226 q += sprintf(q,
" ");
1227 for (x = 0; x < TopicsPerLine && (y * TopicsPerLine + x) < NumPages; x++) {
1228 const char *topic =
GetHelpTopic(hp[(y * TopicsPerLine + x)]);
1233 Reply(-214,
"%s", buffer);
1244 int o = strtol(Option, NULL, 10);
1248 else if (strcmp(Option,
"-") == 0) {
1255 else if (strcmp(Option,
"+") == 0) {
1263 n = Channel->Number();
1265 for (
const cChannel *Channel = Channels->First(); Channel; Channel = Channels->
Next(Channel)) {
1266 if (!Channel->GroupSep()) {
1267 if (strcasecmp(Channel->Name(), Option) == 0) {
1268 n = Channel->Number();
1275 Reply(501,
"Undefined channel \"%s\"", Option);
1279 if (
const cChannel *Channel = Channels->GetByNumber(n)) {
1281 Reply(554,
"Error switching to channel \"%d\"", Channel->Number());
1286 Reply(550,
"Unable to find channel \"%s\"", Option);
1294 Reply(250,
"%d %s", Channel->Number(), Channel->Name());
1306 int o = strtol(Option, NULL, 10);
1308 if (
const cChannel *Channel = Channels->GetByNumber(o))
1309 ChannelID = Channel->GetChannelID();
1315 for (
const cChannel *Channel = Channels->First(); Channel; Channel = Channels->
Next(Channel)) {
1316 if (!Channel->GroupSep()) {
1317 if (strcasecmp(Channel->Name(), Option) == 0) {
1318 ChannelID = Channel->GetChannelID();
1329 for (
cSchedule *p = Schedules->First(); p; p = Schedules->
Next(p)) {
1330 if (p->ChannelID() == ChannelID) {
1336 for (
cTimer *Timer = Timers->First(); Timer; Timer = Timers->
Next(Timer)) {
1337 if (ChannelID == Timer->Channel()->GetChannelID().
ClrRid())
1338 Timer->SetEvent(NULL);
1342 Reply(250,
"EPG data of channel \"%s\" cleared", Option);
1345 Reply(550,
"No EPG data found for channel \"%s\"", Option);
1350 Reply(501,
"Undefined channel \"%s\"", Option);
1355 for (
cTimer *Timer = Timers->First(); Timer; Timer = Timers->
Next(Timer))
1356 Timer->SetEvent(NULL);
1357 for (
cSchedule *Schedule = Schedules->First(); Schedule; Schedule = Schedules->
Next(Schedule))
1358 Schedule->Cleanup(INT_MAX);
1360 Reply(250,
"EPG data cleared");
1369 if (ServerParams.
Ok()) {
1375 Reply(501,
"Error in server parameters: %s", ServerParams.
Error());
1378 Reply(451,
"No SVDRP client handler");
1381 Reply(501,
"Missing server parameters");
1389 Channels->SetExplicitModify();
1392 Channel = Channels->GetByNumber(strtol(Option, NULL, 10));
1396 if (
const cTimer *Timer = Timers->UsesChannel(Channel)) {
1397 Reply(550,
"Channel \"%s\" is in use by timer %s", Option, *Timer->ToDescr());
1401 cChannel *CurrentChannel = Channels->GetByNumber(CurrentChannelNr);
1402 if (CurrentChannel && Channel == CurrentChannel) {
1403 int n = Channels->GetNextNormal(CurrentChannel->
Index());
1405 n = Channels->GetPrevNormal(CurrentChannel->
Index());
1407 Reply(501,
"Can't delete channel \"%s\" - list would be empty", Option);
1410 CurrentChannel = Channels->Get(n);
1411 CurrentChannelNr = 0;
1413 Channels->Del(Channel);
1414 Channels->ReNumber();
1415 Channels->SetModifiedByUser();
1416 Channels->SetModified();
1418 if (CurrentChannel && CurrentChannel->
Number() != CurrentChannelNr) {
1420 Channels->SwitchTo(CurrentChannel->
Number());
1424 Reply(250,
"Channel \"%s\" deleted", Option);
1427 Reply(501,
"Channel \"%s\" not defined", Option);
1430 Reply(501,
"Missing channel number or id");
1439 return cString::sprintf(
"Recording \"%s\" is being replayed", RecordingId);
1440 else if ((Reason &
ruCut) != 0)
1443 return cString::sprintf(
"Recording \"%s\" is being copied/moved", RecordingId);
1452 char *opt = strdup(Option);
1455 while (*option && !isspace(*option))
1461 Recordings->SetExplicitModify();
1462 if (
cRecording *Recording = Recordings->Get(strtol(num, NULL, 10) - 1)) {
1463 if (
int RecordingInUse = Recording->IsInUse())
1471 if (strcmp(newName, Recording->Name())) {
1476 Recordings->AddByName(fileName);
1477 Reply(250,
"Recording \"%s\" copied to \"%s\"", Recording->Name(), *newName);
1480 Reply(554,
"Error while copying recording \"%s\" to \"%s\"!", Recording->Name(), *newName);
1483 Reply(501,
"Identical new recording name");
1486 Reply(501,
"Missing new recording name");
1490 Reply(550,
"Recording \"%s\" not found", num);
1493 Reply(501,
"Error in recording number \"%s\"", num);
1497 Reply(501,
"Missing recording number");
1505 Recordings->SetExplicitModify();
1506 if (
cRecording *Recording = Recordings->GetById(strtol(Option, NULL, 10))) {
1507 if (
int RecordingInUse = Recording->IsInUse())
1510 if (Recording->Delete()) {
1511 Recordings->DelByName(Recording->FileName());
1512 Recordings->SetModified();
1514 Reply(250,
"Recording \"%s\" deleted", Option);
1517 Reply(554,
"Error while deleting recording!");
1521 Reply(550,
"Recording \"%s\" not found", Option);
1524 Reply(501,
"Error in recording id \"%s\"", Option);
1527 Reply(501,
"Missing recording id");
1535 Timers->SetExplicitModify();
1536 if (
cTimer *Timer = Timers->GetById(strtol(Option, NULL, 10))) {
1537 if (Timer->Recording()) {
1541 Timer->TriggerRespawn();
1543 Timers->SetModified();
1545 Reply(250,
"Timer \"%s\" deleted", Option);
1548 Reply(501,
"Timer \"%s\" not defined", Option);
1551 Reply(501,
"Error in timer number \"%s\"", Option);
1554 Reply(501,
"Missing timer number");
1562 if (
const cRecording *Recording = Recordings->GetById(strtol(Option, NULL, 10))) {
1564 if (Marks.
Load(Recording->FileName(), Recording->FramesPerSecond(), Recording->IsPesRecording()) && Marks.
Count()) {
1566 Reply(250,
"Editing recording \"%s\" [%s]", Option, Recording->Title());
1568 Reply(554,
"Can't start editing process");
1571 Reply(554,
"No editing marks defined");
1574 Reply(550,
"Recording \"%s\" not found", Option);
1577 Reply(501,
"Error in recording id \"%s\"", Option);
1580 Reply(501,
"Missing recording id");
1585 const char *FileName = NULL;
1587 int Quality = -1, SizeX = -1, SizeY = -1;
1589 char buf[strlen(Option) + 1];
1590 char *p = strcpy(buf, Option);
1591 const char *delim =
" \t";
1593 FileName = strtok_r(p, delim, &strtok_next);
1595 const char *Extension = strrchr(FileName,
'.');
1597 if (strcasecmp(Extension,
".jpg") == 0 || strcasecmp(Extension,
".jpeg") == 0)
1599 else if (strcasecmp(Extension,
".pnm") == 0)
1602 Reply(501,
"Unknown image type \"%s\"", Extension + 1);
1605 if (Extension == FileName)
1608 else if (strcmp(FileName,
"-") == 0)
1611 if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
1612 if (strcasecmp(p,
"JPEG") == 0 || strcasecmp(p,
"PNM") == 0) {
1614 p = strtok_r(NULL, delim, &strtok_next);
1620 Reply(501,
"Invalid quality \"%s\"", p);
1626 if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
1630 Reply(501,
"Invalid sizex \"%s\"", p);
1633 if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
1637 Reply(501,
"Invalid sizey \"%s\"", p);
1642 Reply(501,
"Missing sizey");
1646 if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
1647 Reply(501,
"Unexpected parameter \"%s\"", p);
1651 char RealFileName[PATH_MAX];
1656 const char *slash = strrchr(FileName,
'/');
1661 slash = strrchr(FileName,
'/');
1664 char *r = realpath(t, RealFileName);
1667 Reply(501,
"Invalid file name \"%s\"", FileName);
1670 strcat(RealFileName, slash);
1671 FileName = RealFileName;
1673 Reply(501,
"Invalid file name \"%s\"", FileName);
1678 Reply(550,
"Grabbing to file not allowed (use \"GRAB -\" instead)");
1687 int fd = open(FileName, O_WRONLY | O_CREAT | O_NOFOLLOW | O_TRUNC, DEFFILEMODE);
1689 if (
safe_write(fd, Image, ImageSize) == ImageSize) {
1691 Reply(250,
"Grabbed image %s", Option);
1695 Reply(451,
"Can't write to '%s'", FileName);
1701 Reply(451,
"Can't open '%s'", FileName);
1707 while ((s = Base64.
NextLine()) != NULL)
1708 Reply(-216,
"%s", s);
1709 Reply(216,
"Grabbed image %s", Option);
1714 Reply(451,
"Grab image failed");
1717 Reply(501,
"Missing filename");
1725 Reply(-214,
"%s", hp);
1727 Reply(504,
"HELP topic \"%s\" unknown", Option);
1733 Reply(-214,
"Topics:");
1742 Reply(-214,
"To report bugs in the implementation send email to");
1743 Reply(-214,
" vdr-bugs@tvdr.de");
1745 Reply(214,
"End of HELP info");
1752 Reply(550,
"Remote control currently disabled (key \"%s\" discarded)", Option);
1755 char buf[strlen(Option) + 1];
1756 strcpy(buf, Option);
1757 const char *delim =
" \t";
1759 char *p = strtok_r(buf, delim, &strtok_next);
1765 Reply(451,
"Too many keys in \"%s\" (only %d accepted)", Option, NumKeys);
1770 Reply(504,
"Unknown key: \"%s\"", p);
1774 p = strtok_r(NULL, delim, &strtok_next);
1776 Reply(250,
"Key%s \"%s\" accepted", NumKeys > 1 ?
"s" :
"", Option);
1779 Reply(-214,
"Valid <key> names for the HITK command:");
1780 for (
int i = 0; i <
kNone; i++) {
1783 Reply(214,
"End of key list");
1790 bool WithChannelIds =
startswith(Option,
":ids") && (Option[4] ==
' ' || Option[4] == 0);
1793 bool WithGroupSeps = strcasecmp(Option,
":groups") == 0;
1794 if (*Option && !WithGroupSeps) {
1796 int n = strtol(Option, NULL, 10);
1799 if (
const cChannel *Channel = Channels->GetByNumber(n))
1800 Reply(250,
"%d%s%s %s", Channel->Number(), WithChannelIds ?
" " :
"", WithChannelIds ? *Channel->GetChannelID().ToString() :
"", *Channel->ToText());
1802 Reply(501,
"Channel \"%s\" not defined", Option);
1807 for (
const cChannel *Channel = Channels->First(); Channel; Channel = Channels->
Next(Channel)) {
1808 if (!Channel->GroupSep()) {
1809 if (strcasestr(Channel->Name(), Option)) {
1820 Reply(501,
"Channel \"%s\" not defined", Option);
1824 for (
const cChannel *Channel = Channels->First(); Channel; Channel = Channels->
Next(Channel)) {
1826 Reply(Channel->Next() ? -250: 250,
"%d%s%s %s", Channel->GroupSep() ? 0 : Channel->Number(), (WithChannelIds && !Channel->GroupSep()) ?
" " :
"", (WithChannelIds && !Channel->GroupSep()) ? *Channel->GetChannelID().ToString() :
"", *Channel->ToText());
1827 else if (!Channel->GroupSep())
1828 Reply(Channel->Number() <
cChannels::MaxNumber() ? -250 : 250,
"%d%s%s %s", Channel->Number(), WithChannelIds ?
" " :
"", WithChannelIds ? *Channel->GetChannelID().ToString() :
"", *Channel->ToText());
1832 Reply(550,
"No channels defined");
1840 Reply(d->DeviceNumber() + 1 ==
cDevice::NumDevices() ? 250 : -250,
"%d [%s%s] %s", d->DeviceNumber() + 1, d->HasDecoder() ?
"D" :
"-", d->DeviceNumber() + 1 ==
Setup.
PrimaryDVB ?
"P" :
"-", *d->DeviceName());
1844 Reply(550,
"No devices found");
1855 char buf[strlen(Option) + 1];
1856 strcpy(buf, Option);
1857 const char *delim =
" \t";
1859 char *p = strtok_r(buf, delim, &strtok_next);
1860 while (p && DumpMode ==
dmAll) {
1861 if (strcasecmp(p,
"NOW") == 0)
1863 else if (strcasecmp(p,
"NEXT") == 0)
1865 else if (strcasecmp(p,
"AT") == 0) {
1867 if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) {
1869 AtTime = strtol(p, NULL, 10);
1871 Reply(501,
"Invalid time");
1876 Reply(501,
"Missing time");
1880 else if (!Schedule) {
1883 Channel = Channels->GetByNumber(strtol(Option, NULL, 10));
1887 Schedule = Schedules->GetSchedule(Channel);
1889 Reply(550,
"No schedule found");
1894 Reply(550,
"Channel \"%s\" not defined", p);
1899 Reply(501,
"Unknown option: \"%s\"", p);
1902 p = strtok_r(NULL, delim, &strtok_next);
1907 FILE *f = fdopen(fd,
"w");
1910 Schedule->
Dump(Channels, f,
"215-", DumpMode, AtTime);
1912 Schedules->Dump(f,
"215-", DumpMode, AtTime);
1914 Reply(215,
"End of EPG data");
1918 Reply(451,
"Can't open file connection");
1923 Reply(451,
"Can't dup stream descriptor");
1932 char buf[strlen(Option) + 1];
1933 strcpy(buf, Option);
1934 const char *delim =
" \t";
1936 char *p = strtok_r(buf, delim, &strtok_next);
1940 Number = strtol(p, NULL, 10);
1942 Reply(501,
"Error in recording id \"%s\"", Option);
1946 else if (strcasecmp(p,
"PATH") == 0)
1949 Reply(501,
"Unknown option: \"%s\"", p);
1952 p = strtok_r(NULL, delim, &strtok_next);
1955 if (
const cRecording *Recording = Recordings->GetById(strtol(Option, NULL, 10))) {
1956 FILE *f = fdopen(
file,
"w");
1959 Reply(250,
"%s", Recording->FileName());
1961 Recording->Info()->Write(f,
"215-");
1963 Reply(215,
"End of recording information");
1968 Reply(451,
"Can't open file connection");
1971 Reply(550,
"Recording \"%s\" not found", Option);
1974 else if (Recordings->Count()) {
1975 const cRecording *Recording = Recordings->First();
1977 Reply(Recording == Recordings->Last() ? 250 : -250,
"%d %s", Recording->
Id(), Recording->
Title(
' ',
true));
1978 Recording = Recordings->
Next(Recording);
1982 Reply(550,
"No recordings available");
1988 bool UseChannelId =
false;
1990 char buf[strlen(Option) + 1];
1991 strcpy(buf, Option);
1992 const char *delim =
" \t";
1994 char *p = strtok_r(buf, delim, &strtok_next);
1997 Id = strtol(p, NULL, 10);
1998 else if (strcasecmp(p,
"ID") == 0)
1999 UseChannelId =
true;
2001 Reply(501,
"Unknown option: \"%s\"", p);
2004 p = strtok_r(NULL, delim, &strtok_next);
2009 for (
const cTimer *Timer = Timers->First(); Timer; Timer = Timers->
Next(Timer)) {
2010 if (!Timer->Remote()) {
2011 if (Timer->Id() == Id) {
2012 Reply(250,
"%d %s", Timer->Id(), *Timer->ToText(UseChannelId));
2017 Reply(501,
"Timer \"%s\" not defined", Option);
2021 const cTimer *LastLocalTimer = Timers->Last();
2022 while (LastLocalTimer) {
2023 if (LastLocalTimer->
Remote())
2024 LastLocalTimer = Timers->
Prev(LastLocalTimer);
2028 if (LastLocalTimer) {
2029 for (
const cTimer *Timer = Timers->First(); Timer; Timer = Timers->
Next(Timer)) {
2030 if (!Timer->Remote())
2031 Reply(Timer != LastLocalTimer ? -250 : 250,
"%d %s", Timer->
Id(), *Timer->ToText(UseChannelId));
2032 if (Timer == LastLocalTimer)
2038 Reply(550,
"No timers defined");
2046 Reply(250,
"Message queued");
2049 Reply(501,
"Missing message");
2056 int n = strtol(Option, &tail, 10);
2057 if (tail && tail != Option) {
2060 Channels->SetExplicitModify();
2061 if (
cChannel *Channel = Channels->GetByNumber(n)) {
2063 if (ch.
Parse(tail)) {
2064 if (Channels->HasUniqueChannelID(&ch, Channel)) {
2066 Channels->ReNumber();
2067 Channels->SetModifiedByUser();
2068 Channels->SetModified();
2070 Reply(250,
"%d %s", Channel->Number(), *Channel->ToText());
2073 Reply(501,
"Channel settings are not unique");
2076 Reply(501,
"Error in channel settings");
2079 Reply(501,
"Channel \"%d\" not defined", n);
2082 Reply(501,
"Error in channel number");
2085 Reply(501,
"Missing channel settings");
2092 int Id = strtol(Option, &tail, 10);
2093 if (tail && tail != Option) {
2096 Timers->SetExplicitModify();
2097 if (
cTimer *Timer = Timers->GetById(Id)) {
2100 if (strcasecmp(tail,
"ON") == 0)
2102 else if (strcasecmp(tail,
"OFF") == 0)
2104 else if (!t.
Parse(tail)) {
2105 Reply(501,
"Error in timer settings");
2109 Reply(550,
"Timer is recording");
2117 Timers->SetModified();
2119 if (Timer->IsPatternTimer())
2120 Timer->SetEvent(NULL);
2121 Timer->TriggerRespawn();
2122 Reply(250,
"%d %s", Timer->Id(), *Timer->ToText(
true));
2125 Reply(501,
"Timer \"%d\" not defined", Id);
2128 Reply(501,
"Error in timer id");
2131 Reply(501,
"Missing timer settings");
2138 int From = strtol(Option, &tail, 10);
2139 if (tail && tail != Option) {
2141 if (tail && tail != Option) {
2144 Channels->SetExplicitModify();
2145 int To = strtol(tail, NULL, 10);
2147 const cChannel *CurrentChannel = Channels->GetByNumber(CurrentChannelNr);
2148 cChannel *FromChannel = Channels->GetByNumber(From);
2150 cChannel *ToChannel = Channels->GetByNumber(To);
2152 int FromNumber = FromChannel->
Number();
2153 int ToNumber = ToChannel->
Number();
2154 if (FromNumber != ToNumber) {
2155 if (Channels->MoveNeedsDecrement(FromChannel, ToChannel))
2156 ToChannel = Channels->
Prev(ToChannel);
2157 Channels->Move(FromChannel, ToChannel);
2158 Channels->ReNumber();
2159 Channels->SetModifiedByUser();
2160 Channels->SetModified();
2161 if (CurrentChannel && CurrentChannel->
Number() != CurrentChannelNr) {
2163 Channels->SwitchTo(CurrentChannel->
Number());
2168 Reply(250,
"Channel \"%d\" moved to \"%d\"", From, To);
2171 Reply(501,
"Can't move channel to same position");
2174 Reply(501,
"Channel \"%d\" not defined", To);
2177 Reply(501,
"Channel \"%d\" not defined", From);
2180 Reply(501,
"Error in channel number");
2183 Reply(501,
"Error in channel number");
2186 Reply(501,
"Missing channel number");
2192 char *opt = strdup(Option);
2195 while (*option && !isspace(*option))
2201 Recordings->SetExplicitModify();
2202 if (
cRecording *Recording = Recordings->GetById(strtol(num, NULL, 10))) {
2203 if (
int RecordingInUse = Recording->IsInUse())
2209 cString oldName = Recording->Name();
2210 if ((Recording = Recordings->GetByName(Recording->FileName())) != NULL && Recording->ChangeName(option)) {
2211 Recordings->SetModified();
2212 Recordings->TouchUpdate();
2213 Reply(250,
"Recording \"%s\" moved to \"%s\"", *oldName, Recording->Name());
2216 Reply(554,
"Error while moving recording \"%s\" to \"%s\"!", *oldName, option);
2219 Reply(501,
"Missing new recording name");
2223 Reply(550,
"Recording \"%s\" not found", num);
2226 Reply(501,
"Error in recording id \"%s\"", num);
2230 Reply(501,
"Missing recording id");
2237 if (ch.
Parse(Option)) {
2239 Channels->SetExplicitModify();
2240 if (Channels->HasUniqueChannelID(&ch)) {
2243 Channels->Add(channel);
2244 Channels->ReNumber();
2245 Channels->SetModifiedByUser();
2246 Channels->SetModified();
2251 Reply(501,
"Channel settings are not unique");
2254 Reply(501,
"Error in channel settings");
2257 Reply(501,
"Missing channel settings");
2264 if (Timer->
Parse(Option)) {
2273 Reply(501,
"Error in timer settings");
2277 Reply(501,
"Missing timer settings");
2283 if (
const cTimer *t = Timers->GetNextActiveTimer()) {
2284 time_t Start = t->StartTime();
2288 else if (strcasecmp(Option,
"ABS") == 0)
2289 Reply(250,
"%d %jd", Id, intmax_t(Start));
2290 else if (strcasecmp(Option,
"REL") == 0)
2291 Reply(250,
"%d %jd", Id, intmax_t(Start - time(NULL)));
2293 Reply(501,
"Unknown option: \"%s\"", Option);
2296 Reply(550,
"No active timers");
2307 char *opt = strdup(Option);
2310 while (*option && !isspace(*option))
2317 if (
const cRecording *Recording = Recordings->GetById(strtol(num, NULL, 10))) {
2318 cString FileName = Recording->FileName();
2319 cString Title = Recording->Title();
2320 int FramesPerSecond = Recording->FramesPerSecond();
2321 bool IsPesRecording = Recording->IsPesRecording();
2329 if (strcasecmp(option,
"BEGIN") != 0)
2340 Reply(250,
"Playing recording \"%s\" [%s]", num, *Title);
2344 Reply(550,
"Recording \"%s\" not found", num);
2349 Reply(501,
"Error in recording id \"%s\"", num);
2353 Reply(501,
"Missing recording id");
2359 char *opt = strdup(Option);
2361 char *option = name;
2362 while (*option && !isspace(*option))
2371 while (*option && !isspace(*option))
2377 if (!*cmd || strcasecmp(cmd,
"HELP") == 0) {
2378 if (*cmd && *option) {
2381 Reply(-214,
"%s", hp);
2382 Reply(214,
"End of HELP info");
2385 Reply(504,
"HELP topic \"%s\" for plugin \"%s\" unknown", option, plugin->
Name());
2391 Reply(-214,
"SVDRP commands:");
2393 Reply(214,
"End of HELP info");
2396 Reply(214,
"This plugin has no SVDRP commands");
2399 else if (strcasecmp(cmd,
"MAIN") == 0) {
2401 Reply(250,
"Initiated call to main menu function of plugin \"%s\"", plugin->
Name());
2403 Reply(550,
"A plugin call is already pending - please try again later");
2406 int ReplyCode = 900;
2409 Reply(abs(ReplyCode),
"%s", *s);
2411 Reply(500,
"Command unrecognized: \"%s\"", cmd);
2415 Reply(550,
"Plugin \"%s\" not found (use PLUG for a list of plugins)", name);
2419 Reply(-214,
"Available plugins:");
2423 Reply(214,
"End of plugin list");
2430 char buf[strlen(Option) + 1];
2431 char *p = strcpy(buf, Option);
2432 const char *delim =
" \t";
2434 char *RemoteName = strtok_r(p, delim, &strtok_next);
2435 char *ListName = strtok_r(NULL, delim, &strtok_next);
2438 if (strcasecmp(ListName,
"timers") == 0) {
2443 Reply(501,
"Unknown list name: \"%s\"", ListName);
2446 Reply(501,
"Missing list name");
2449 Reply(501,
"No SVDRP client connections");
2452 Reply(501,
"Missing parameters");
2460 int o = strtol(Option, NULL, 10);
2464 Reply(501,
"Invalid device number \"%s\"", Option);
2467 Reply(501,
"Invalid parameter \"%s\"", Option);
2470 Reply(250,
"Primary device set to %d", n);
2475 Reply(250,
"%d [%s%s] %s", d->DeviceNumber() + 1, d->HasDecoder() ?
"D" :
"-", d->DeviceNumber() + 1 ==
Setup.
PrimaryDVB ?
"P" :
"-", *d->DeviceName());
2477 Reply(501,
"Failed to get primary device");
2484 FILE *f = fopen(Option,
"r");
2488 Reply(250,
"EPG data processed from \"%s\"", Option);
2491 Reply(451,
"Error while processing EPG from \"%s\"", Option);
2495 Reply(501,
"Cannot open file \"%s\"", Option);
2509 if (!strcasecmp(Option,
"ON")) {
2511 Reply(250,
"Remote control enabled");
2513 else if (!strcasecmp(Option,
"OFF")) {
2515 Reply(250,
"Remote control disabled");
2518 Reply(501,
"Invalid Option \"%s\"", Option);
2527 Reply(250,
"EPG scan triggered");
2533 if (strcasecmp(Option,
"DISK") == 0) {
2536 Reply(250,
"%dMB %dMB %d%%", FreeMB + UsedMB, FreeMB, Percent);
2539 Reply(501,
"Invalid Option \"%s\"", Option);
2542 Reply(501,
"No option given");
2549 if (Timer->
Parse(Option)) {
2551 if (
cTimer *t = Timers->GetTimer(Timer)) {
2571 Reply(501,
"Error in timer settings");
2575 Reply(501,
"Missing timer settings");
2581 Recordings->Update(
false);
2582 Reply(250,
"Re-read of recordings directory triggered");
2590 else if (strcmp(Option,
"+") == 0)
2592 else if (strcmp(Option,
"-") == 0)
2594 else if (strcasecmp(Option,
"MUTE") == 0)
2597 Reply(501,
"Unknown option: \"%s\"", Option);
2602 Reply(250,
"Audio is mute");
2607#define CMD(c) (strcasecmp(Cmd, c) == 0)
2624 while (*s && !isspace(*s))
2665 else Reply(500,
"Command unrecognized: \"%s\"", Cmd);
2675 if (c ==
'\n' || c == 0x00) {
2691 else if (c == 0x04 &&
numChars == 0) {
2695 else if (c == 0x08 || c == 0x7F) {
2700 else if (c <= 0x03 || c == 0x0D) {
2705 int NewLength =
length + BUFSIZ;
2706 if (
char *NewBuffer = (
char *)realloc(
cmdLine, NewLength)) {
2755 virtual void Action(
void);
2765:
cThread(
"SVDRP server handler", true)
2766,tcpSocket(TcpPort, true)
2849 bool Result =
false;
2858 bool Result =
false;
2871 for (
int i = 0; i < ServerNames.
Size(); i++)
#define LOCK_CHANNELS_READ
#define LOCK_CHANNELS_WRITE
const char * NextLine(void)
Returns the next line of encoded data (terminated by '\0'), or NULL if there is no more encoded data.
bool Parse(const char *s)
static cString ToText(const cChannel *Channel)
tChannelID GetChannelID(void) const
static int MaxNumber(void)
static const char * SystemCharacterTable(void)
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
static void Shutdown(void)
static void Launch(cControl *Control)
virtual uchar * GrabImage(int &Size, bool Jpeg=true, int Quality=-1, int SizeX=-1, int SizeY=-1)
Grabs the currently visible screen image.
static cDevice * PrimaryDevice(void)
Returns the primary device.
static cDevice * GetDevice(int Index)
Gets the device with the given Index.
bool SwitchChannel(const cChannel *Channel, bool LiveView)
Switches the device to the given Channel, initiating transfer mode if necessary.
static int CurrentChannel(void)
Returns the number of the current channel on the primary device.
static void SetCurrentChannel(int ChannelNumber)
Sets the number of the current channel on the primary device, without actually switching to it.
void SetVolume(int Volume, bool Absolute=false)
Sets the volume to the given value, either absolutely or relative to the current volume.
static int NumDevices(void)
Returns the total number of devices.
static int CurrentVolume(void)
bool ToggleMute(void)
Turns the volume off or on and returns the new mute state.
static void SetDisableUntil(time_t Time)
bool Ready(bool Wait=true)
bool Open(const char *FileName, int Flags, mode_t Mode=DEFFILEMODE)
const char * Connection(void) const
const char * Address(void) const
void Set(const char *Address, int Port)
static const char * ToString(eKeys Key, bool Translate=false)
static eKeys FromString(const char *Name)
cListObject * Prev(void) const
cListObject * Next(void) const
bool Load(const char *RecordingFileName, double FramesPerSecond=DEFAULTFRAMESPERSECOND, bool IsPesRecording=false)
bool Process(const char *s)
const char * Message(void)
static cPlugin * GetPlugin(int Index)
virtual const char * Version(void)=0
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
virtual const char * Description(void)=0
virtual const char ** SVDRPHelpPages(void)
bool Add(int FileHandle, bool Out)
bool Poll(int TimeoutMs=0)
void Del(int FileHandle, bool Out)
static bool Process(cTimers *Timers, time_t t)
static cRecordControl * GetRecordControl(const char *FileName)
const char * FileName(void) const
Returns the full path name to the recording directory, including the video directory and the actual '...
const char * Title(char Delimiter=' ', bool NewIndicator=false, int Level=-1) const
bool Add(int Usage, const char *FileNameSrc, const char *FileNameDst=NULL)
Adds the given FileNameSrc to the recordings handler for (later) processing.
static const cRecordings * GetRecordingsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of recordings for read access.
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
static bool Enabled(void)
static bool CallPlugin(const char *Plugin)
Initiates calling the given plugin's main menu function.
static void SetEnabled(bool Enabled)
static void SetRecording(const char *FileName)
bool Execute(const char *ServerName, const char *Command, cStringList *Response=NULL)
void AddClient(cSVDRPServerParams &ServerParams, const char *IpAddress)
virtual ~cSVDRPClientHandler()
void ProcessConnections(void)
bool GetServerNames(cStringList *ServerNames)
cSVDRPClientHandler(int TcpPort, int UdpPort)
void HandleClientConnection(void)
cSVDRPClient * GetClientForServer(const char *ServerName)
cVector< cSVDRPClient * > clientConnections
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
bool TriggerFetchingTimers(const char *ServerName)
cIpAddress serverIpAddress
bool Connected(void) const
bool Execute(const char *Command, cStringList *Response=NULL)
bool HasAddress(const char *Address, int Port) const
const char * ServerName(void) const
bool Send(const char *Command)
cSVDRPClient(const char *Address, int Port, const char *ServerName, int Timeout)
bool GetRemoteTimers(cStringList &Response)
bool Process(cStringList *Response=NULL)
void SetFetchFlag(int Flag)
const char * Connection(void) const
bool HasFetchFlag(int Flag)
void HandleServerConnection(void)
void ProcessConnections(void)
cSVDRPServerHandler(int TcpPort)
void WaitUntilReady(void)
virtual ~cSVDRPServerHandler()
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
cVector< cSVDRPServer * > serverConnections
const char * Host(void) const
const int Timeout(void) const
const char * ApiVersion(void) const
cSVDRPServerParams(const char *Params)
const char * VdrVersion(void) const
const char * Name(void) const
const char * Error(void) const
const int Port(void) const
void CmdMESG(const char *Option)
const char * ClientName(void) const
void CmdPOLL(const char *Option)
void CmdLSTT(const char *Option)
void CmdCLRE(const char *Option)
void Reply(int Code, const char *fmt,...) __attribute__((format(printf
void CmdGRAB(const char *Option)
void CmdMODC(const char *Option)
cPUTEhandler * PUTEhandler
void CmdDELC(const char *Option)
void CmdPLUG(const char *Option)
void CmdMODT(const char *Option)
cIpAddress clientIpAddress
void CmdCPYR(const char *Option)
void CmdLSTC(const char *Option)
void CmdSCAN(const char *Option)
void Close(bool SendReply=false, bool Timeout=false)
void CmdPUTE(const char *Option)
void CmdLSTR(const char *Option)
void CmdSTAT(const char *Option)
void CmdCHAN(const char *Option)
void CmdHELP(const char *Option)
void CmdUPDT(const char *Option)
void CmdREMO(const char *Option)
void CmdLSTE(const char *Option)
void CmdCONN(const char *Option)
void CmdDELR(const char *Option)
void CmdUPDR(const char *Option)
void CmdVOLU(const char *Option)
void CmdNEWT(const char *Option)
void CmdEDIT(const char *Option)
void CmdPLAY(const char *Option)
void CmdDELT(const char *Option)
void CmdLSTD(const char *Option)
cSVDRPServer(int Socket, const cIpAddress *ClientIpAddress)
void CmdNEXT(const char *Option)
void CmdHITK(const char *Option)
void CmdNEWC(const char *Option)
void CmdPRIM(const char *Option)
void CmdMOVR(const char *Option)
void CmdPING(const char *Option)
void CmdMOVC(const char *Option)
void void PrintHelpTopics(const char **hp)
bool Acceptable(in_addr_t Address)
void Cleanup(time_t Time)
void Dump(const cChannels *Channels, FILE *f, const char *Prefix="", eDumpMode DumpMode=dmAll, time_t AtTime=0) const
static void Cleanup(bool Force=false)
static bool Read(FILE *f=NULL)
char SVDRPDefaultHost[HOST_NAME_MAX]
char SVDRPHostName[HOST_NAME_MAX]
int QueueMessage(eMessageType Type, const char *s, int Seconds=0, int Timeout=0)
Like Message(), but this function may be called from a background thread.
const cIpAddress * LastIpAddress(void) const
static bool SendDgram(const char *Dgram, int Port)
cSocket(int Port, bool Tcp)
bool Connect(const char *Address)
void Remove(bool IncState=true)
Removes this key from the lock it was previously used with.
bool TimedOut(void) const
Returns true if the last lock attempt this key was used with failed due to a timeout.
void SortNumerically(void)
cString & CompactChars(char c)
Compact any sequence of characters 'c' to a single character, and strip all of them from the beginnin...
static cString sprintf(const char *fmt,...) __attribute__((format(printf
cString & Truncate(int Index)
Truncate the string at the given Index (if Index is < 0 it is counted from the end of the string).
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
void Set(int Ms=0)
Sets the timer.
bool TimedOut(void) const
void ClrFlags(uint Flags)
void SetFlags(uint Flags)
bool IsPatternTimer(void) const
cString ToDescr(void) const
const char * Remote(void) const
bool Parse(const char *s)
cString ToText(bool UseChannelID=false) const
bool StoreRemoteTimers(const char *ServerName=NULL, const cStringList *RemoteTimers=NULL)
Stores the given list of RemoteTimers, which come from the VDR ServerName, in this list.
static cTimers * GetTimersWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of timers for write access.
static const cTimers * GetTimersRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of timers for read access.
virtual void Append(T Data)
virtual void Remove(int Index)
static int VideoDiskSpace(int *FreeMB=NULL, int *UsedMB=NULL)
#define LOCK_SCHEDULES_READ
#define LOCK_SCHEDULES_WRITE
char * ExchangeChars(char *s, bool ToFileSystem)
int HMSFToIndex(const char *HMSF, double FramesPerSecond)
cRecordingsHandler RecordingsHandler
struct __attribute__((packed))
#define LOCK_RECORDINGS_READ
#define LOCK_RECORDINGS_WRITE
tChannelID & ClrRid(void)
static const tChannelID InvalidID
static tChannelID FromString(const char *s)
cString ToString(void) const
void StopSVDRPHandler(void)
static cPoller SVDRPClientPoller
void SetSVDRPGrabImageDir(const char *GrabImageDir)
static cString grabImageDir
bool GetSVDRPServerNames(cStringList *ServerNames)
Gets a list of all available VDRs this VDR is connected to via SVDRP, and stores it in the given Serv...
static cString RecordingInUseMessage(int Reason, const char *RecordingId, cRecording *Recording)
static cMutex SVDRPHandlerMutex
bool ExecSVDRPCommand(const char *ServerName, const char *Command, cStringList *Response)
Sends the given SVDRP Command string to the remote VDR identified by ServerName and collects all of t...
static cPoller SVDRPServerPoller
static cSVDRPServerHandler * SVDRPServerHandler
void StartSVDRPHandler(void)
void BroadcastSVDRPCommand(const char *Command)
Sends the given SVDRP Command string to all remote VDRs.
#define SVDRPResonseTimeout
const char * GetHelpPage(const char *Cmd, const char **p)
static cSVDRPClientHandler * SVDRPClientHandler
static bool DumpSVDRPDataTransfer
const char * GetHelpTopic(const char *HelpPage)
void SetSVDRPPorts(int TcpPort, int UdpPort)
int SVDRPCode(const char *s)
Returns the value of the three digit reply code of the given SVDRP response string.
cStateKey StateKeySVDRPRemoteTimersPoll
Controls whether a change to the local list of timers needs to result in sending a POLL to the remote...
#define LOCK_TIMERS_WRITE