summaryrefslogtreecommitdiff
path: root/vdr-vdrmanager/handler.cpp
diff options
context:
space:
mode:
authorbju <bju@maxi.fritz.box>2014-01-22 02:28:34 +0100
committerbju <bju@maxi.fritz.box>2014-01-22 02:28:34 +0100
commit321bebe669a5aafc2c4ff0e9f59e60de2fa79bac (patch)
treef8b81b463027a60481f8f41939eaa5a18824ce19 /vdr-vdrmanager/handler.cpp
parentbc2c9e64787d4682bd9f3a3340f8b46497f63bb3 (diff)
downloadvdr-manager-321bebe669a5aafc2c4ff0e9f59e60de2fa79bac.tar.gz
vdr-manager-321bebe669a5aafc2c4ff0e9f59e60de2fa79bac.tar.bz2
http://projects.vdr-developer.org/issues/1267:
- some fixes on client side certificate validation - added SSL server side support to the plugin
Diffstat (limited to 'vdr-vdrmanager/handler.cpp')
-rw-r--r--vdr-vdrmanager/handler.cpp177
1 files changed, 85 insertions, 92 deletions
diff --git a/vdr-vdrmanager/handler.cpp b/vdr-vdrmanager/handler.cpp
index ea15296..4a787c7 100644
--- a/vdr-vdrmanager/handler.cpp
+++ b/vdr-vdrmanager/handler.cpp
@@ -17,104 +17,97 @@ bool cHandler::HandleNewClient(cVdrmanagerClientSocket * sock)
bool cHandler::HandleClientRequest(cVdrmanagerClientSocket * sock)
{
- bool closeSocket = true;
+ while (!sock->IsLineComplete() && sock->Read())
+ ;
- while(sock->Read())
- {
- // get lines
- while (sock->IsLineComplete())
- {
- string line;
- sock->GetLine(line);
+ if (sock->IsLineComplete()) {
- // 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 = "";
- }
+ string line;
+ sock->GetLine(line);
- 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();
- }
+ isyslog("[vdrmanager] got %s", line.c_str());
- if (closeSocket) {
- sock->Disconnect();
- }
+ // 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 = "";
+ }
- sock->Flush();
+ if (!sock->IsLoggedIn() && cmd != "PASSWD") {
+ sock->Write("!ERROR\r\n");
}
+ else if (cmd == "PASSWD")
+ {
+ if (args != sock->GetPassword()) {
+ sock->Write("!ERROR\r\n");
+ } else {
+ sock->SetLoggedIn();
+ sock->Write("!OK\r\n");
+ }
+ }
+ else if (cmd == "COMPRESS")
+ {
+ sock->ActivateCompression();
+ }
+ else if (cmd == "TIMERS")
+ {
+ string text = cHelpers::GetTimers(args);
+ sock->Write(text);
+ }
+ else if (cmd == "CHANNELS")
+ {
+ string text = cHelpers::GetChannels(args);
+ sock->Write(text);
+ }
+ else if (cmd == "TEVENTS")
+ {
+ string text = cHelpers::GetTimeEvents(args);
+ sock->Write(text);
+ }
+ else if (cmd == "CEVENTS")
+ {
+ string text = cHelpers::GetChannelEvents(args);
+ sock->Write(text);
+ }
+ else if (cmd == "TIMER")
+ {
+ string text = cHelpers::SetTimer(args);
+ sock->Write(text);
+ }
+ else if (cmd == "SEARCH")
+ {
+ string text = cHelpers::SearchEvents(args);
+ sock->Write(text);
+ }
+ else if(cmd == "RECORDINGS")
+ {
+ string text = cHelpers::GetRecordings(args);
+ sock->Write(text);
+ }
+ else if(cmd == "DRECORDING")
+ {
+ string text = cHelpers::DelRecording(args);
+ sock->Write(text);
+ }
+ else if (cmd == "SETCHANNEL")
+ {
+ string text = cHelpers::SetChannel(args);
+ sock->Write(text);
+ }
+ else if (cmd == "QUIT")
+ {
+ // close socket
+ sock->Write(string("Good bye! :-)\r\n"));
+ sock->Disconnect();
+ }
+
+ sock->Flush();
}
return true;