From 9e3567dc09e4555003de68f01271c5ce6152d989 Mon Sep 17 00:00:00 2001 From: satbaby Date: Mon, 22 Oct 2012 14:00:01 +0200 Subject: [PATCH] nhttpd::controlapi.cpp:execute more comands on/off only once (fix doubleclick) --- .../tuxboxapi/coolstream/controlapi.cpp | 66 ++++++++++++++----- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index d737dbf0a..f3afbad54 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -425,13 +425,21 @@ void CControlAPI::StandbyCGI(CyhookHandler *hh) { if (hh->ParamList["1"] == "on") // standby mode on { - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::STANDBY_ON, CEventServer::INITID_HTTPD); - hh->SendOk(); + if(CNeutrinoApp::getInstance()->getMode() == 4){ + hh->WriteLn("standby is already on"); + }else { + NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::STANDBY_ON, CEventServer::INITID_HTTPD); + hh->SendOk(); + } } else if (hh->ParamList["1"] == "off")// standby mode off { - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::STANDBY_OFF, CEventServer::INITID_HTTPD); - hh->SendOk(); + if(CNeutrinoApp::getInstance()->getMode() != 4){ + hh->WriteLn("standby is already off"); + }else { + NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::STANDBY_OFF, CEventServer::INITID_HTTPD); + hh->SendOk(); + } } else hh->SendError(); @@ -448,12 +456,29 @@ void CControlAPI::RCCGI(CyhookHandler *hh) { if (!(hh->ParamList.empty())) { - if (hh->ParamList["1"] == "lock") // lock remote control - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::LOCK_RC, CEventServer::INITID_HTTPD); - else if (hh->ParamList["1"] == "unlock")// unlock remote control - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::UNLOCK_RC, CEventServer::INITID_HTTPD); - else + static bool on_off = false; + if (hh->ParamList["1"] == "lock"){ // lock remote control + if(!on_off){ + NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::LOCK_RC, CEventServer::INITID_HTTPD); + on_off = true; + }else{ + hh->WriteLn("remote is already locked"); + return; + } + } + else if (hh->ParamList["1"] == "unlock"){// unlock remote control + if(on_off){ + NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::UNLOCK_RC, CEventServer::INITID_HTTPD); + on_off = false; + + }else{ + hh->WriteLn("remote is already unlocked"); + return; + } + } + else{ hh->SendError(); + } } hh->SendOk(); } @@ -1472,16 +1497,25 @@ void CControlAPI::ZaptoCGI(CyhookHandler *hh) SendAllCurrentVAPid(hh); else if (hh->ParamList["1"] == "stopplayback") { - NeutrinoAPI->Zapit->stopPlayBack(); - NeutrinoAPI->Sectionsd->setPauseScanning(true); - hh->SendOk(); + if(!NeutrinoAPI->Zapit->isPlayBackActive()){ + hh->WriteLn("playback is already off"); + }else{ + NeutrinoAPI->Zapit->stopPlayBack(); + NeutrinoAPI->Sectionsd->setPauseScanning(true); + hh->SendOk(); + } } else if (hh->ParamList["1"] == "startplayback") { - NeutrinoAPI->Zapit->startPlayBack(); - NeutrinoAPI->Sectionsd->setPauseScanning(false); - dprintf("start playback requested..\n"); - hh->SendOk(); + if(NeutrinoAPI->Zapit->isPlayBackActive()){ + hh->WriteLn("playback is already on"); + }else{ + NeutrinoAPI->Zapit->startPlayBack(); + NeutrinoAPI->Sectionsd->setPauseScanning(false); + dprintf("start playback requested..\n"); + hh->SendOk(); + } + } else if (hh->ParamList["1"] == "statusplayback") hh->Write((char *) (NeutrinoAPI->Zapit->isPlayBackActive() ? "1" : "0"));