blob: ea15296b24bc1a17010545f295850386114dfafe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* event und message handler
*/
#include <unistd.h>
#include <vdr/plugin.h>
#include <vdr/timers.h>
#include "sock.h"
#include "select.h"
#include "vdrmanagerthread.h"
#include "helpers.h"
bool cHandler::HandleNewClient(cVdrmanagerClientSocket * sock)
{
return true;
}
bool cHandler::HandleClientRequest(cVdrmanagerClientSocket * sock)
{
bool closeSocket = true;
while(sock->Read())
{
// get lines
while (sock->IsLineComplete())
{
string line;
sock->GetLine(line);
// parse request
size_t space = line.find(' ');
string cmd;
string args;
if (space != string::npos) {
cmd = cHelpers::ToUpper(line.substr(0, space));
args = cHelpers::Trim(line.substr(space+1));
} else {
cmd = cHelpers::ToUpper(line);
args = "";
}
if (!sock->IsLoggedIn() && cmd != "PASSWD") {
sock->PutLine("!ERROR\r\n");
}
else if (cmd == "PASSWD")
{
if (args != sock->GetPassword()) {
sock->PutLine("!ERROR\r\n");
} else {
sock->SetLoggedIn();
sock->PutLine("!OK\r\n");
}
closeSocket = false;
}
else if (cmd == "COMPRESS")
{
sock->ActivateCompression();
closeSocket = false;
}
else if (cmd == "TIMERS")
{
string text = cHelpers::GetTimers(args);
sock->PutLine(text);
}
else if (cmd == "CHANNELS")
{
string text = cHelpers::GetChannels(args);
sock->PutLine(text);
}
else if (cmd == "TEVENTS")
{
string text = cHelpers::GetTimeEvents(args);
sock->PutLine(text);
}
else if (cmd == "CEVENTS")
{
string text = cHelpers::GetChannelEvents(args);
sock->PutLine(text);
}
else if (cmd == "TIMER")
{
string text = cHelpers::SetTimer(args);
sock->PutLine(text);
}
else if (cmd == "SEARCH")
{
string text = cHelpers::SearchEvents(args);
sock->PutLine(text);
}
else if(cmd == "RECORDINGS")
{
string text = cHelpers::GetRecordings(args);
sock->PutLine(text);
}
else if(cmd == "DRECORDING")
{
string text = cHelpers::DelRecording(args);
sock->PutLine(text);
}
else if (cmd == "SETCHANNEL")
{
string text = cHelpers::SetChannel(args);
sock->PutLine(text);
}
else if (cmd == "QUIT")
{
// close socket
sock->PutLine(string("Good bye! :-)\r\n"));
sock->Disconnect();
}
if (closeSocket) {
sock->Disconnect();
}
sock->Flush();
}
}
return true;
}
|