From 427915ab830e0716c4b78a71a5e8bddd3dfe6e90 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 6 May 2015 22:07:35 +0200 Subject: [PATCH] src/nhttpd/tuxboxapi: remove unused dbox code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/e59f8adccc378aa0386081775dfd737a9bb9b349 Author: vanhofen Date: 2015-05-06 (Wed, 06 May 2015) Origin message was: ------------------ - src/nhttpd/tuxboxapi: remove unused dbox code ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- configure.ac | 1 - src/nhttpd/tuxboxapi/AUTHORS | 20 - src/nhttpd/tuxboxapi/Makefile.am | 34 +- .../tuxboxapi/{coolstream => }/controlapi.cpp | 0 .../tuxboxapi/{coolstream => }/controlapi.h | 0 src/nhttpd/tuxboxapi/coolstream/Makefile.am | 34 - src/nhttpd/tuxboxapi/dbox/Makefile.am | 20 - src/nhttpd/tuxboxapi/dbox/controlapi.cpp | 2249 ----------------- src/nhttpd/tuxboxapi/dbox/controlapi.h | 117 - src/nhttpd/tuxboxapi/dbox/lcdapi.cpp | 220 -- src/nhttpd/tuxboxapi/dbox/lcdapi.h | 61 - src/nhttpd/tuxboxapi/dbox/neutrinoapi.cpp | 424 ---- src/nhttpd/tuxboxapi/dbox/neutrinoapi.h | 90 - src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp | 1068 -------- src/nhttpd/tuxboxapi/dbox/neutrinoyparser.h | 70 - .../{coolstream => }/neutrinoapi.cpp | 0 .../tuxboxapi/{coolstream => }/neutrinoapi.h | 0 .../{coolstream => }/neutrinoyparser.cpp | 0 .../{coolstream => }/neutrinoyparser.h | 0 19 files changed, 33 insertions(+), 4375 deletions(-) delete mode 100644 src/nhttpd/tuxboxapi/AUTHORS rename src/nhttpd/tuxboxapi/{coolstream => }/controlapi.cpp (100%) rename src/nhttpd/tuxboxapi/{coolstream => }/controlapi.h (100%) delete mode 100644 src/nhttpd/tuxboxapi/coolstream/Makefile.am delete mode 100644 src/nhttpd/tuxboxapi/dbox/Makefile.am delete mode 100644 src/nhttpd/tuxboxapi/dbox/controlapi.cpp delete mode 100644 src/nhttpd/tuxboxapi/dbox/controlapi.h delete mode 100644 src/nhttpd/tuxboxapi/dbox/lcdapi.cpp delete mode 100644 src/nhttpd/tuxboxapi/dbox/lcdapi.h delete mode 100644 src/nhttpd/tuxboxapi/dbox/neutrinoapi.cpp delete mode 100644 src/nhttpd/tuxboxapi/dbox/neutrinoapi.h delete mode 100644 src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp delete mode 100644 src/nhttpd/tuxboxapi/dbox/neutrinoyparser.h rename src/nhttpd/tuxboxapi/{coolstream => }/neutrinoapi.cpp (100%) rename src/nhttpd/tuxboxapi/{coolstream => }/neutrinoapi.h (100%) rename src/nhttpd/tuxboxapi/{coolstream => }/neutrinoyparser.cpp (100%) rename src/nhttpd/tuxboxapi/{coolstream => }/neutrinoyparser.h (100%) diff --git a/configure.ac b/configure.ac index e16249227..6cba26b12 100644 --- a/configure.ac +++ b/configure.ac @@ -266,7 +266,6 @@ src/nhttpd/web/scripts/Makefile src/nhttpd/web/languages/Makefile src/nhttpd/web/styles/Makefile src/nhttpd/tuxboxapi/Makefile -src/nhttpd/tuxboxapi/coolstream/Makefile src/nhttpd/yhttpd_core/Makefile src/nhttpd/yhttpd_mods/Makefile src/nhttpd/nhttpd.conf diff --git a/src/nhttpd/tuxboxapi/AUTHORS b/src/nhttpd/tuxboxapi/AUTHORS deleted file mode 100644 index 302b5f340..000000000 --- a/src/nhttpd/tuxboxapi/AUTHORS +++ /dev/null @@ -1,20 +0,0 @@ -AUTHORS -in order of appearance (bottom up) - - -Johannes Golombek [yjogol@cvs.tuxbox.org] -Bengt Martensson [barf@cvs.tuxbox.org] -Jacek Jendrzej [metallica@cvs.tuxbox.org] -Henning Behrend [sat_man@cvs.tuxbox.org] -Axel Buehning [diemade@cvs.tuxbox.org] -Michael Schuele [chakazulu@cvs.tuxbox.org] -Peter Reich [digi_casi@cvs.tuxbox.org] -H.Heinold [heinold@physik.tu-cottbus.de] -Sven Traenkle [zwen@cvs.tuxbox.org] -gagga -wjoost -Ralf Gandy -Michael Lantzen -Andreas Oberritter -Dirk Szymanski [dirch@cvs.tuxbox.org] -Steffen Hehn diff --git a/src/nhttpd/tuxboxapi/Makefile.am b/src/nhttpd/tuxboxapi/Makefile.am index 5ad38190f..6f30cdb4a 100644 --- a/src/nhttpd/tuxboxapi/Makefile.am +++ b/src/nhttpd/tuxboxapi/Makefile.am @@ -1,2 +1,34 @@ -SUBDIRS = coolstream +AM_CPPFLAGS = -fno-rtti -fno-exceptions -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64 +AM_CPPFLAGS += \ + -I$(top_builddir) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src/zapit/include \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/nhttpd \ + -I$(top_srcdir)/src/nhttpd/yhttpd_core \ + -I$(top_srcdir)/src/nhttpd/yhttpd_mods \ + -I$(top_srcdir)/lib/connection \ + -I$(top_srcdir)/lib/libeventserver \ + -I$(top_srcdir)/lib/libconfigfile \ + -I$(top_srcdir)/lib/xmltree \ + @SIGC_CFLAGS@ \ + @FREETYPE_CFLAGS@ + +if BOXTYPE_COOL +if BOXMODEL_APOLLO +AM_CPPFLAGS += -I$(top_srcdir)/lib/libcoolstream2 +else +AM_CPPFLAGS += -I$(top_srcdir)/lib/libcoolstream +endif +endif +if BOXTYPE_TRIPLE +AM_CPPFLAGS += -I$(top_srcdir)/lib/libtriple +endif + +noinst_LIBRARIES = libnhttpd_tuxboxapi.a + +libnhttpd_tuxboxapi_a_SOURCES = \ + neutrinoapi.cpp neutrinoyparser.cpp controlapi.cpp + diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp similarity index 100% rename from src/nhttpd/tuxboxapi/coolstream/controlapi.cpp rename to src/nhttpd/tuxboxapi/controlapi.cpp diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.h b/src/nhttpd/tuxboxapi/controlapi.h similarity index 100% rename from src/nhttpd/tuxboxapi/coolstream/controlapi.h rename to src/nhttpd/tuxboxapi/controlapi.h diff --git a/src/nhttpd/tuxboxapi/coolstream/Makefile.am b/src/nhttpd/tuxboxapi/coolstream/Makefile.am deleted file mode 100644 index 6f30cdb4a..000000000 --- a/src/nhttpd/tuxboxapi/coolstream/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -AM_CPPFLAGS = -fno-rtti -fno-exceptions -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64 - -AM_CPPFLAGS += \ - -I$(top_builddir) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/src/zapit/include \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/nhttpd \ - -I$(top_srcdir)/src/nhttpd/yhttpd_core \ - -I$(top_srcdir)/src/nhttpd/yhttpd_mods \ - -I$(top_srcdir)/lib/connection \ - -I$(top_srcdir)/lib/libeventserver \ - -I$(top_srcdir)/lib/libconfigfile \ - -I$(top_srcdir)/lib/xmltree \ - @SIGC_CFLAGS@ \ - @FREETYPE_CFLAGS@ - -if BOXTYPE_COOL -if BOXMODEL_APOLLO -AM_CPPFLAGS += -I$(top_srcdir)/lib/libcoolstream2 -else -AM_CPPFLAGS += -I$(top_srcdir)/lib/libcoolstream -endif -endif -if BOXTYPE_TRIPLE -AM_CPPFLAGS += -I$(top_srcdir)/lib/libtriple -endif - -noinst_LIBRARIES = libnhttpd_tuxboxapi.a - -libnhttpd_tuxboxapi_a_SOURCES = \ - neutrinoapi.cpp neutrinoyparser.cpp controlapi.cpp - diff --git a/src/nhttpd/tuxboxapi/dbox/Makefile.am b/src/nhttpd/tuxboxapi/dbox/Makefile.am deleted file mode 100644 index 9c9e45cea..000000000 --- a/src/nhttpd/tuxboxapi/dbox/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -AM_CPPFLAGS = -fno-rtti -fno-exceptions -D_FILE_OFFSET_BITS=64 - -AM_CPPFLAGS += \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/src/zapit/include \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/nhttpd \ - -I$(top_srcdir)/src/nhttpd/yhttpd_core \ - -I$(top_srcdir)/src/nhttpd/yhttpd_mods \ - -I$(top_srcdir)/lib/connection \ - -I$(top_srcdir)/lib/libeventserver \ - -I$(top_srcdir)/lib/libconfigfile \ - -I$(top_srcdir)/lib/xmltree \ - @FREETYPE_CFLAGS@ - -noinst_LIBRARIES = libnhttpd_tuxboxapi.a - -libnhttpd_tuxboxapi_a_SOURCES = \ - neutrinoapi.cpp neutrinoyparser.cpp lcdapi.cpp controlapi.cpp - diff --git a/src/nhttpd/tuxboxapi/dbox/controlapi.cpp b/src/nhttpd/tuxboxapi/dbox/controlapi.cpp deleted file mode 100644 index af2dd1b62..000000000 --- a/src/nhttpd/tuxboxapi/dbox/controlapi.cpp +++ /dev/null @@ -1,2249 +0,0 @@ -//============================================================================= -// NHTTPD -// Neutrino ControlAPI -//============================================================================= -#include -// C -#include -#include -// C++ -#include -#include -#include -// system -#include -#include -// tuxbox -#include -#include -#include -#include -#include -// yhttpd -#include "yhttpd.h" -#include "ytypes_globals.h" -#include "ylogging.h" -#include "helper.h" -// nhttpd -#include "neutrinoapi.h" -#include "controlapi.h" -#include "lcdapi.h" - -#define EVENTDEV "/dev/input/event0" -//----------------------------------------------------------------------------- -enum { // not defined in input.h but used like that, at least in 2.4.22 - KEY_RELEASED = 0, - KEY_PRESSED, - KEY_AUTOREPEAT -}; - -//============================================================================= -// Initialization of static variables -//============================================================================= -std::string CControlAPI::PLUGIN_DIRS[PLUGIN_DIR_COUNT]; - -//============================================================================= -// constructor und destructor -//============================================================================= -CControlAPI::CControlAPI(CNeutrinoAPI *_NeutrinoAPI) -{ - NeutrinoAPI = _NeutrinoAPI; -} -//----------------------------------------------------------------------------- -void CControlAPI::init(CyhookHandler *hh) -{ - if(PLUGIN_DIRS[0] == "") - { // given in nhttpd.conf - PLUGIN_DIRS[0]=hh->WebserverConfigList["WebsiteMain.override_directory"]; - PLUGIN_DIRS[0].append("/scripts"); - PLUGIN_DIRS[1]=hh->WebserverConfigList["WebsiteMain.directory"]; - PLUGIN_DIRS[1].append("/scripts"); - PLUGIN_DIRS[2]="/var/tuxbox/plugins"; - PLUGIN_DIRS[3]=PLUGINDIR; - PLUGIN_DIRS[4]="/mnt/plugins"; - } -} - -//============================================================================= -// Hooks! -//============================================================================= -//----------------------------------------------------------------------------- -THandleStatus CControlAPI::Hook_PrepareResponse(CyhookHandler *hh) -{ - init(hh); - - if(hh->UrlData["path"] == "/control/" - || hh->UrlData["path"] == "/cgi-bin/" - || hh->UrlData["path"] == "/fb/" - ) - return HANDLED_READY; - else - return HANDLED_NONE; -} -//----------------------------------------------------------------------------- -// HOOK: response_hook Handler -// This is the main dispatcher for this module -//----------------------------------------------------------------------------- -THandleStatus CControlAPI::Hook_SendResponse(CyhookHandler *hh) -{ - hh->status = HANDLED_NONE; - -// log_level_printfX(4,"CControlAPI hook start url:%s\n",hh->UrlData["url"].c_str()); - init(hh); - - if(hh->UrlData["path"] == "/control/" - || hh->UrlData["path"] == "/cgi-bin/") - Execute(hh); - if(hh->UrlData["path"] == "/fb/") // fb-compatibility for timer-calls - compatibility_Timer(hh); -// log_level_printfX(4,"CControlAPI hook ende status:%d\n",(int)hh->status); -// log_level_printfX(5,"CControlAPI hook result:%s\n",hh->yresult.c_str()); - - return hh->status; -} - -//============================================================================= -//------------------------------------------------------------------------- -// timer compatibility -// do add/modify/remove and Return (redirect) Timerlist -//------------------------------------------------------------------------- -void CControlAPI::compatibility_Timer(CyhookHandler *hh) -{ - log_level_printf(4,"CControlAPI Compatibility Timer Start url:%s\n",hh->UrlData["url"].c_str()); - if(NeutrinoAPI->Timerd->isTimerdAvailable() && !hh->ParamList.empty() ) - { - if(hh->ParamList["action"] == "remove") - { - unsigned removeId = atoi(hh->ParamList["id"].c_str()); - NeutrinoAPI->Timerd->removeTimerEvent(removeId); - } - else if(hh->ParamList["action"] == "modify") - doModifyTimer(hh); - else if(hh->ParamList["action"] == "new") - doNewTimer(hh); - } - hh->SendRedirect("/Y_Timer_List.yhtm"); -} - -//============================================================================= -// Main Dispatcher / Call definitions -//============================================================================= -const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]= -{ - // channel & bouquet & epg & zapping handling - {"getservicesxml", &CControlAPI::GetServicesxmlCGI,""}, - {"getbouquetsxml", &CControlAPI::GetBouquetsxmlCGI,""}, - {"channellist", &CControlAPI::ChannellistCGI, "text/plain"}, - {"getbouquet", &CControlAPI::GetBouquetCGI, "+xml"}, - {"getbouquets", &CControlAPI::GetBouquetsCGI, "text/plain"}, - {"getmode", &CControlAPI::GetModeCGI, "text/plain"}, - {"setmode", &CControlAPI::SetModeCGI, "text/plain"}, - {"epg", &CControlAPI::EpgCGI, ""}, - {"zapto", &CControlAPI::ZaptoCGI, "text/plain"}, - {"getonidsid", &CControlAPI::GetChannel_IDCGI, "text/plain"}, - // boxcontrol - system - {"standby", &CControlAPI::StandbyCGI, "text/plain"}, - {"shutdown", &CControlAPI::ShutdownCGI, "text/plain"}, - {"reboot", &CControlAPI::RebootCGI, "text/plain"}, - {"esound", &CControlAPI::EsoundCGI, "text/plain"}, - {"getdate", &CControlAPI::GetDateCGI, "text/plain"}, - {"gettime", &CControlAPI::GetTimeCGI, "text/plain"}, - {"settings", &CControlAPI::SettingsCGI, "text/plain"}, - {"info", &CControlAPI::InfoCGI, "text/plain"}, - {"version", &CControlAPI::VersionCGI, ""}, - // boxcontrol - devices - {"volume", &CControlAPI::VolumeCGI, "text/plain"}, - {"lcd", &CControlAPI::LCDAction, "text/plain"}, - {"system", &CControlAPI::SystemCGI, "text/plain"}, - {"message", &CControlAPI::MessageCGI, "text/plain"}, - {"rc", &CControlAPI::RCCGI, "text/plain"}, - {"rcem", &CControlAPI::RCEmCGI, "text/plain"}, - // Start skripts, plugins - {"startplugin", &CControlAPI::StartPluginCGI, "text/plain"}, - {"exec", &CControlAPI::ExecCGI, "+xml"}, - {"yweb", &CControlAPI::YWebCGI, "text/plain"}, - // video handling - {"aspectratio", &CControlAPI::AspectRatioCGI, "text/plain"}, - {"videoformat", &CControlAPI::VideoFormatCGI, "text/plain"}, - {"videooutput", &CControlAPI::VideoOutputCGI, "text/plain"}, - {"vcroutput", &CControlAPI::VCROutputCGI, "text/plain"}, - {"scartmode", &CControlAPI::ScartModeCGI, "text/plain"}, - // timer - {"timer", &CControlAPI::TimerCGI, "text/plain"}, - // bouquet editing - {"setbouquet", &CControlAPI::setBouquetCGI, "text/plain"}, - {"savebouquet", &CControlAPI::saveBouquetCGI, "text/plain"}, - {"movebouquet", &CControlAPI::moveBouquetCGI, "text/plain"}, - {"deletebouquet", &CControlAPI::deleteBouquetCGI, "text/plain"}, - {"addbouquet", &CControlAPI::addBouquetCGI, "text/plain"}, - {"renamebouquet", &CControlAPI::renameBouquetCGI, "text/plain"}, - {"changebouquet", &CControlAPI::changeBouquetCGI, "text/plain"}, - {"updatebouquet", &CControlAPI::updateBouquetCGI, "text/plain"}, - // utils - {"build_live_url", &CControlAPI::build_live_url, ""}, - - -}; -//----------------------------------------------------------------------------- -// Main Dispatcher -//----------------------------------------------------------------------------- -void CControlAPI::Execute(CyhookHandler *hh) -{ - int index = -1; - std::string yresult; - std::string filename = hh->UrlData["filename"]; - - log_level_printf(4,"ControlAPI.Execute filename:(%s)\n",filename.c_str()); - // tolower(filename) - for(unsigned int i = 0; i < filename.length(); i++) - filename[i] = tolower(filename[i]); - - // debugging informations - if(CLogging::getInstance()->getDebug()) - { - dprintf("Execute CGI : %s\n",filename.c_str()); - for(CStringList::iterator it = hh->ParamList.begin() ; - it != hh->ParamList.end() ; it++) - dprintf(" Parameter %s : %s\n",it->first.c_str(), it->second.c_str()); - } - - // get function index - for(unsigned int i = 0;i < (sizeof(yCgiCallList)/sizeof(yCgiCallList[0])); i++) - if (filename == yCgiCallList[i].func_name) - { - index = i; - break; - } - if(index == -1) // function not found - { - hh->SetError(HTTP_NOT_IMPLEMENTED, HANDLED_NOT_IMPLEMENTED); - return; - } - - // send header - else if(std::string(yCgiCallList[index].mime_type) == "") // decide in function - ; - else if(std::string(yCgiCallList[index].mime_type) == "+xml") // Parameter xml? - if (hh->ParamList["xml"] != "") - hh->SetHeader(HTTP_OK, "text/xml; charset=UTF-8"); - else - hh->SetHeader(HTTP_OK, "text/html; charset=UTF-8"); - else - hh->SetHeader(HTTP_OK, yCgiCallList[index].mime_type); - // response - hh->status = HANDLED_READY; - if (hh->Method == M_HEAD) // HEAD or function call - return; - else - { - (this->*yCgiCallList[index].pfunc)(hh); - return; - } -} - -//============================================================================= -// CGI Functions -// CyhookHandler contains input/output abstractions -//============================================================================= -void CControlAPI::TimerCGI(CyhookHandler *hh) -{ - if (NeutrinoAPI->Timerd->isTimerdAvailable()) - { - if (!hh->ParamList.empty() && hh->ParamList["format"].empty()) - { - if (hh->ParamList["action"] == "new") - doNewTimer(hh); - else if (hh->ParamList["action"] == "modify") - doModifyTimer(hh); - else if (hh->ParamList["action"] == "remove") - { - unsigned removeId = atoi(hh->ParamList["id"].c_str()); - NeutrinoAPI->Timerd->removeTimerEvent(removeId); - hh->SendOk(); - } - else if(hh->ParamList["get"] != "") - { - int pre=0,post=0; - NeutrinoAPI->Timerd->getRecordingSafety(pre,post); - if(hh->ParamList["get"] == "pre") - hh->printf("%d\n", pre); - else if(hh->ParamList["get"] == "post") - hh->printf("%d\n", post); - else - hh->SendError(); - } - - } - else - SendTimers(hh); - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::SetModeCGI(CyhookHandler *hh) -{ - if (!(hh->ParamList.empty())) - { - if (hh->ParamList["1"] == "status") // display recoding status - { - if (NeutrinoAPI->Zapit->isRecordModeActive()) - hh->WriteLn("on"); - else - hh->WriteLn("off"); - return; - } - - if (hh->ParamList["1"] == "radio") // switch to radio mode - { - int mode = NeutrinoMessages::mode_radio; - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::CHANGEMODE, CEventServer::INITID_HTTPD, (void *)&mode,sizeof(int)); - sleep(1); - NeutrinoAPI->UpdateBouquets(); - } - else if (hh->ParamList["1"] == "tv") // switch to tv mode - { - int mode = NeutrinoMessages::mode_tv; - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::CHANGEMODE, CEventServer::INITID_HTTPD, (void *)&mode,sizeof(int)); - sleep(1); - NeutrinoAPI->UpdateBouquets(); - } - else if (hh->ParamList["record"] == "start") // start record mode - { - if(hh->ParamList["stopplayback"] == "true") - NeutrinoAPI->Zapit->stopPlayBack(); - NeutrinoAPI->Sectionsd->setPauseScanning(true); - NeutrinoAPI->Zapit->setRecordMode(true); - } - else if (hh->ParamList["record"] == "stop") // stop record mode - { - NeutrinoAPI->Zapit->setRecordMode(false); - NeutrinoAPI->Sectionsd->setPauseScanning(false); - if (!NeutrinoAPI->Zapit->isPlayBackActive()) - NeutrinoAPI->Zapit->startPlayBack(); - } - hh->SendOk(); - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::GetModeCGI(CyhookHandler *hh) -{ - int mode = NeutrinoAPI->Zapit->getMode(); - if ( mode == CZapitClient::MODE_TV) - hh->WriteLn("tv"); - else if ( mode == CZapitClient::MODE_RADIO) - return hh->WriteLn("radio"); - else - return hh->WriteLn("unknown"); -} - -//----------------------------------------------------------------------------- -void CControlAPI::ExecCGI(CyhookHandler *hh) -{ - bool res = false; - std::string script, result; - // override standard header - if (hh->ParamList.size() > 1 && hh->ParamList["xml"].empty()) - hh->SetHeader(HTTP_OK, "text/html; charset=UTF-8"); - else if (hh->ParamList.size() > 1 && !hh->ParamList["xml"].empty()) - hh->SetHeader(HTTP_OK, "text/xml; charset=UTF-8"); - else - hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8"); - if ( !hh->ParamList.empty() ) - { - script = hh->ParamList["1"]; - unsigned int len = hh->ParamList.size(); - for(unsigned int y=2;y<=len;y++) - if(!hh->ParamList[itoa(y)].empty()) - { - script += " "; - script += hh->ParamList[itoa(y)]; - } - result = YexecuteScript(hh, script); - } - else - printf("[CControlAPI] no script given\n"); - - res = (result != "error"); - if (res) - hh->Write(result); - else - hh->SetError(HTTP_NOT_FOUND); -} - -//----------------------------------------------------------------------------- -void CControlAPI::SystemCGI(CyhookHandler *hh) -{ - if (!(hh->ParamList.empty())) - { - - if (hh->ParamList["1"] == "getAViAExtIec") { - hh->printf("%d\n", NeutrinoAPI->Zapit->IecState()); - } - else if (hh->ParamList["setAViAExtIec"] == "on") - { - NeutrinoAPI->Zapit->IecOn(); - hh->SendOk(); - } - else if (hh->ParamList["setAViAExtIec"] == "off") - { - NeutrinoAPI->Zapit->IecOff(); - hh->SendOk(); - } - else if (hh->ParamList["1"] == "getAViAExtPlayBack") - hh->printf("%d\n", NeutrinoAPI->Zapit->PlaybackState()); - else if (hh->ParamList["setAViAExtPlayBack"] == "pes") - { - NeutrinoAPI->Zapit->PlaybackPES(); - hh->SendOk(); - } - else if (hh->ParamList["setAViAExtPlayBack"] == "spts") - { - NeutrinoAPI->Zapit->PlaybackSPTS(); - hh->SendOk(); - } - else - hh->SendError(); - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::StandbyCGI(CyhookHandler *hh) -{ - if (!(hh->ParamList.empty())) - { - if (hh->ParamList["1"] == "on") // standby mode on - { - 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(); - } - else - hh->SendError(); - } - else - if(NeutrinoAPI->Controld->getVideoPowerDown()) - hh->WriteLn("on"); - else - hh->WriteLn("off"); -} - -//----------------------------------------------------------------------------- -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 - hh->SendError(); - } - hh->SendOk(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::EsoundCGI(CyhookHandler *hh) -{ - if (!(hh->ParamList.empty())) - { - if (hh->ParamList["1"] == "on") // esound on - { - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::ESOUND_ON, CEventServer::INITID_HTTPD); - } - else if (hh->ParamList["1"] == "off") // esound off - { - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::ESOUND_OFF, CEventServer::INITID_HTTPD); - } - else - hh->SendError(); - } - hh->SendOk(); -} - -//----------------------------------------------------------------------------- -// Get actual Date -// security: strftime has buffer-overflow limit. ok! -//----------------------------------------------------------------------------- -void CControlAPI::GetDateCGI(CyhookHandler *hh) -{ - if (hh->ParamList.empty()) - { - //paramlos - char *timestr = new char[50]; - struct timeval tm; - gettimeofday(&tm, NULL); - strftime(timestr, 20, "%d.%m.%Y\n", localtime(&tm.tv_sec) ); - hh->Write(timestr); - delete[] timestr; - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -// Get actual Time -// security: strftime has buffer-overflow limit. ok! -//----------------------------------------------------------------------------- -void CControlAPI::GetTimeCGI(CyhookHandler *hh) -{ - time_t now = time(NULL); - - if (hh->ParamList.empty()) - { - //paramlos - char *timestr = new char[50]; - struct tm *tm = localtime(&now); - strftime(timestr, 20, "%H:%M:%S\n", tm ); - hh->Write(timestr); - delete[] timestr; - } - else if (hh->ParamList["1"].compare("rawtime") == 0) - hh->printf("%ld\n",now); - else - hh->SendError(); -} -//----------------------------------------------------------------------------- -// send settings -void CControlAPI::SettingsCGI(CyhookHandler *hh) -{ - SendSettings(hh); -} -//----------------------------------------------------------------------------- -// send services.xml -void CControlAPI::GetServicesxmlCGI(CyhookHandler *hh) -{ - hh->SendFile(CONFIGDIR "/zapit/services.xml"); -} - -//----------------------------------------------------------------------------- -// send bouquets.xml -void CControlAPI::GetBouquetsxmlCGI(CyhookHandler *hh) -{ - hh->SendFile(CONFIGDIR "/zapit/bouquets.xml"); -} - -//----------------------------------------------------------------------------- -// get actual channel_id -void CControlAPI::GetChannel_IDCGI(CyhookHandler *hh) -{ - CZapitClient::CCurrentServiceInfo current_pids = NeutrinoAPI->Zapit->getCurrentServiceInfo(); - hh->printf("%x%04x%04x\n",current_pids.tsid, current_pids.onid, current_pids.sid); -} - -//----------------------------------------------------------------------------- -void CControlAPI::MessageCGI(CyhookHandler *hh) -{ - std::string message; - int event = 0; - - if (!(hh->ParamList["popup"].empty())) - { - message = hh->ParamList["popup"]; - event = NeutrinoMessages::EVT_POPUP; - } - else if (!(hh->ParamList["nmsg"].empty())) - { - message = hh->ParamList["nmsg"]; - event = NeutrinoMessages::EVT_EXTMSG; - } - else - { - hh->SendError(); - return; - } - - if (event != 0) - { - message=decodeString(message); - NeutrinoAPI->EventServer->sendEvent(event, CEventServer::INITID_HTTPD, (void *) message.c_str(), message.length() + 1); - hh->SendOk(); - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::InfoCGI(CyhookHandler *hh) -{ - if (hh->ParamList.empty()) - hh->Write("Neutrino\n"); - else - { - if (hh->ParamList["1"] == "streaminfo") // print streaminfo - SendStreamInfo(hh); - else if (hh->ParamList["1"] == "settings") // print settings - SendSettings(hh); - else if (hh->ParamList["1"] == "version") // send version file - hh->SendFile("/.version"); - else if (hh->ParamList["1"] == "httpdversion") // print httpd version typ (only ffor comptibility) - hh->Write("3"); - else if (hh->ParamList["1"] == "nhttpd_version")// print nhttpd version - hh->printf("%s\n", HTTPD_VERSION); - else - hh->SendError(); - } -} -//----------------------------------------------------------------------------- -void CControlAPI::ShutdownCGI(CyhookHandler *hh) -{ - if (hh->ParamList.empty()) - { - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::SHUTDOWN, CEventServer::INITID_HTTPD); - hh->SendOk(); - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::RebootCGI(CyhookHandler *hh) -{ - FILE *f = fopen("/tmp/.reboot", "w"); - fclose(f); - return ShutdownCGI(hh); -} - -//----------------------------------------------------------------------------- -int CControlAPI::rc_send(int ev, unsigned int code, unsigned int value) -{ - struct input_event iev; - iev.type=EV_KEY; - iev.code=code; - iev.value=value; - return write(ev,&iev,sizeof(iev)); -} - -//----------------------------------------------------------------------------- -// security: use const char-Pointers -struct key { - const char *name; - const int code; -}; - -#ifndef KEY_TOPLEFT -#define KEY_TOPLEFT 0x1a2 -#endif - -#ifndef KEY_TOPRIGHT -#define KEY_TOPRIGHT 0x1a3 -#endif - -#ifndef KEY_BOTTOMLEFT -#define KEY_BOTTOMLEFT 0x1a4 -#endif - -#ifndef KEY_BOTTOMRIGHT -#define KEY_BOTTOMRIGHT 0x1a5 -#endif - -static const struct key keynames[] = { - {"KEY_0", KEY_0}, - {"KEY_1", KEY_1}, - {"KEY_2", KEY_2}, - {"KEY_3", KEY_3}, - {"KEY_4", KEY_4}, - {"KEY_5", KEY_5}, - {"KEY_6", KEY_6}, - {"KEY_7", KEY_7}, - {"KEY_8", KEY_8}, - {"KEY_9", KEY_9}, - {"KEY_BACKSPACE", KEY_BACKSPACE}, - {"KEY_HOME", KEY_HOME}, - {"KEY_UP", KEY_UP}, - {"KEY_PAGEUP", KEY_PAGEUP}, - {"KEY_LEFT", KEY_LEFT}, - {"KEY_RIGHT", KEY_RIGHT}, - {"KEY_DOWN", KEY_DOWN}, - {"KEY_PAGEDOWN", KEY_PAGEDOWN}, - {"KEY_MUTE", KEY_MUTE}, - {"KEY_VOLUMEDOWN", KEY_VOLUMEDOWN}, - {"KEY_VOLUMEUP", KEY_VOLUMEUP}, - {"KEY_POWER", KEY_POWER}, - {"KEY_HELP", KEY_HELP}, - {"KEY_SETUP", KEY_SETUP}, - {"KEY_OK", KEY_OK}, - {"KEY_RED", KEY_RED}, - {"KEY_GREEN", KEY_GREEN}, - {"KEY_YELLOW", KEY_YELLOW}, - {"KEY_BLUE", KEY_BLUE}, - {"KEY_TOPLEFT", KEY_TOPLEFT}, - {"KEY_TOPRIGHT", KEY_TOPRIGHT}, - {"KEY_BOTTOMLEFT", KEY_BOTTOMLEFT}, - {"KEY_BOTTOMRIGHT", KEY_BOTTOMRIGHT}, - - //////////////// Keys on the IR Keyboard - {"KEY_ESC", KEY_ESC}, - - {"KEY_MINUS", KEY_MINUS}, - {"KEY_EQUAL", KEY_EQUAL}, - {"KEY_TAB", KEY_TAB}, - {"KEY_Q", KEY_Q}, - {"KEY_W", KEY_W}, - {"KEY_E", KEY_E}, - {"KEY_R", KEY_R}, - {"KEY_T", KEY_T}, - {"KEY_Y", KEY_Y}, - {"KEY_U", KEY_U}, - {"KEY_I", KEY_I}, - {"KEY_O", KEY_O}, - {"KEY_P", KEY_P}, - {"KEY_LEFTBRACE", KEY_LEFTBRACE}, - {"KEY_RIGHTBRACE", KEY_RIGHTBRACE}, - {"KEY_ENTER", KEY_ENTER}, - {"KEY_LEFTCTRL", KEY_LEFTCTRL}, - {"KEY_A", KEY_A}, - {"KEY_S", KEY_S}, - {"KEY_D", KEY_D}, - {"KEY_F", KEY_F}, - {"KEY_G", KEY_G}, - {"KEY_H", KEY_H}, - {"KEY_J", KEY_J}, - {"KEY_K", KEY_K}, - {"KEY_L", KEY_L}, - {"KEY_SEMICOLON", KEY_SEMICOLON}, - {"KEY_APOSTROPHE", KEY_APOSTROPHE}, - {"KEY_GRAVE", KEY_GRAVE}, - {"KEY_LEFTSHIFT", KEY_LEFTSHIFT}, - {"KEY_BACKSLASH", KEY_BACKSLASH}, - {"KEY_Z", KEY_Z}, - {"KEY_X", KEY_X}, - {"KEY_C", KEY_C}, - {"KEY_V", KEY_V}, - {"KEY_B", KEY_B}, - {"KEY_N", KEY_N}, - {"KEY_M", KEY_M}, - {"KEY_COMMA", KEY_COMMA}, - {"KEY_DOT", KEY_DOT}, - {"KEY_SLASH", KEY_SLASH}, - {"KEY_RIGHTSHIFT", KEY_RIGHTSHIFT}, - {"KEY_KPASTERISK", KEY_KPASTERISK}, - {"KEY_LEFTALT", KEY_LEFTALT}, - {"KEY_SPACE", KEY_SPACE}, - {"KEY_CAPSLOCK", KEY_CAPSLOCK}, - {"KEY_F1", KEY_F1}, - {"KEY_F2", KEY_F2}, - {"KEY_F3", KEY_F3}, - {"KEY_F4", KEY_F4}, - {"KEY_F5", KEY_F5}, - {"KEY_F6", KEY_F6}, - {"KEY_F7", KEY_F7}, - {"KEY_F8", KEY_F8}, - {"KEY_F9", KEY_F9}, - {"KEY_F10", KEY_F10}, - {"KEY_NUMLOCK", KEY_NUMLOCK}, - {"KEY_SCROLLLOCK", KEY_SCROLLLOCK}, - {"KEY_KP7", KEY_KP7}, - {"KEY_KP8", KEY_KP8}, - {"KEY_KP9", KEY_KP9}, - {"KEY_KPMINUS", KEY_KPMINUS}, - {"KEY_KP4", KEY_KP4}, - {"KEY_KP5", KEY_KP5}, - {"KEY_KP6", KEY_KP6}, - {"KEY_KPPLUS", KEY_KPPLUS}, - {"KEY_KP1", KEY_KP1}, - {"KEY_KP2", KEY_KP2}, - {"KEY_KP3", KEY_KP3}, - {"KEY_KP0", KEY_KP0}, - {"KEY_KPDOT", KEY_KPDOT}, - {"KEY_102ND", KEY_102ND}, - {"KEY_KPENTER", KEY_KPENTER}, - {"KEY_KPSLASH", KEY_KPSLASH}, - {"KEY_SYSRQ", KEY_SYSRQ}, - {"KEY_RIGHTALT", KEY_RIGHTALT}, - {"KEY_END", KEY_END}, - {"KEY_INSERT", KEY_INSERT}, - {"KEY_DELETE", KEY_DELETE}, - - {"KEY_PAUSE", KEY_PAUSE}, - - {"KEY_LEFTMETA", KEY_LEFTMETA}, - {"KEY_RIGHTMETA", KEY_RIGHTMETA}, - - {"BTN_LEFT", BTN_LEFT}, - {"BTN_RIGHT", BTN_RIGHT} -}; - -// The code here is based on rcsim. Thx Carjay! -void CControlAPI::RCEmCGI(CyhookHandler *hh) -{ - if (hh->ParamList.empty()) { - hh->SendError(); - return; - } - std::string keyname = hh->ParamList["1"]; - int sendcode = -1; - for (unsigned int i = 0; sendcode == -1 && i < sizeof(keynames)/sizeof(key); i++) { - if (!strcmp(keyname.c_str(), keynames[i].name)) - sendcode = keynames[i].code; - } - - if (sendcode == -1) { - printf("[nhttpd] Key %s not found\n", keyname.c_str()); - hh->SendError(); - return; - } - unsigned int repeat = 1; - unsigned int delay = 250; - if (hh->ParamList["delay"] != "") - delay = atoi(hh->ParamList["delay"].c_str()); - if (hh->ParamList["duration"] != "") - repeat = atoi(hh->ParamList["duration"].c_str())*1000/delay; - if (hh->ParamList["repeat"] != "") - repeat = atoi(hh->ParamList["repeat"].c_str()); - - int evd = open(EVENTDEV, O_RDWR); - if (evd < 0) { - hh->SendError(); - perror("opening event0 failed"); - return; - } - if (rc_send(evd, sendcode, KEY_PRESSED) < 0){ - perror("writing 'KEY_PRESSED' event failed"); - hh->SendError(); - close(evd); - return; - } - for (unsigned int i = 0; i < repeat - 1; i++) { - usleep(delay*1000); - if (rc_send(evd, sendcode, KEY_AUTOREPEAT) < 0){ - perror("writing 'KEY_AUTOREPEAT' event failed"); - close(evd); - hh->SendError(); - return; - } - } - if (rc_send(evd, sendcode, KEY_RELEASED)<0){ - perror("writing 'KEY_RELEASED' event failed"); - close(evd); - hh->SendError(); - return; - } - close(evd); - hh->SendOk(); -} -//----------------------------------------------------------------------------- -void CControlAPI::AspectRatioCGI(CyhookHandler *hh) -{ - hh->printf("%s", NeutrinoAPI->Controld->getAspectRatio() == '\0' ? "4:3" : "16:9"); -} -//----------------------------------------------------------------------------- -void CControlAPI::VideoFormatCGI(CyhookHandler *hh) -{ - if (hh->ParamList.empty() || hh->ParamList["1"] == "status") { - hh->WriteLn(NeutrinoAPI->videoformat_names[(unsigned int)NeutrinoAPI->Controld->getVideoFormat()]); - return; - } - - int new_video_format = -1; - if (hh->ParamList["1"] == "automatic") - new_video_format = CControldClient::VIDEOFORMAT_AUTO; - else if (hh->ParamList["1"] == "16:9") - new_video_format = CControldClient::VIDEOFORMAT_16_9; - else if (hh->ParamList["1"] == "4:3" - || hh->ParamList["1"] == "4:3-LB") - new_video_format = CControldClient::VIDEOFORMAT_4_3; - else if (hh->ParamList["1"] == "4:3-PS") - new_video_format = CControldClient::VIDEOFORMAT_4_3_PS; - - if (new_video_format != -1) { - NeutrinoAPI->Controld->setVideoFormat(new_video_format); - hh->SendOk(); - } else { - hh->SendError(); - } - hh->SendOk(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::VideoOutputCGI(CyhookHandler *hh) -{ - unsigned int videooutput=0; - if (hh->ParamList.empty() || hh->ParamList["1"] == "status") { - hh->WriteLn(NeutrinoAPI->videooutput_names[(unsigned int) NeutrinoAPI->Controld->getVideoOutput()]); - return ; - } else if (hh->ParamList["1"] == "cvbs") - videooutput = CControldClient::VIDEOOUTPUT_COMPOSITE; - else if (hh->ParamList["1"] == "rgb") - videooutput = CControldClient::VIDEOOUTPUT_RGB; - else if (hh->ParamList["1"] == "s-video") - videooutput = CControldClient::VIDEOOUTPUT_SVIDEO; - else if (hh->ParamList["1"] == "yuv-vbs") - videooutput = CControldClient::VIDEOOUTPUT_YUV_VBS; - else if (hh->ParamList["1"] == "yuv-cvbs") - videooutput = CControldClient::VIDEOOUTPUT_YUV_CVBS; - else { - hh->SendError(); - return; - } - - NeutrinoAPI->Controld->setVideoOutput(videooutput); - hh->SendOk(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::VCROutputCGI(CyhookHandler *hh) -{ - unsigned int vcroutput; - if (hh->ParamList.empty() || hh->ParamList["1"] == "status") { - hh->WriteLn(NeutrinoAPI->videooutput_names[(unsigned char)NeutrinoAPI->Controld->getVCROutput()]); - - return; - } else if (hh->ParamList["1"] == "cvbs") - vcroutput = CControldClient::VIDEOOUTPUT_COMPOSITE; - else if (hh->ParamList["1"] == "s-video") - vcroutput = CControldClient::VIDEOOUTPUT_SVIDEO; - else { - hh->SendError(); - return; - } - - // S-Video on VCR only possible when S-Video or CVBS on TV; enforce - if (vcroutput == CControldClient::VIDEOOUTPUT_SVIDEO - && (NeutrinoAPI->Controld->getVideoOutput() != CControldClient::VIDEOOUTPUT_COMPOSITE) - && (NeutrinoAPI->Controld->getVideoOutput() != CControldClient::VIDEOOUTPUT_SVIDEO)) { - hh->SendError(); - return; - } - NeutrinoAPI->Controld->setVCROutput(vcroutput); - hh->SendOk(); - - return; -} - -//----------------------------------------------------------------------------- -void CControlAPI::ScartModeCGI(CyhookHandler *hh) -{ - bool new_status; - if (hh->ParamList.empty() || hh->ParamList["1"] == "status") { - hh->printf(NeutrinoAPI->Controld->getScartMode() ? "on" : "off"); - return; - } else if (hh->ParamList["1"] == "on") - new_status = true; - else if (hh->ParamList["1"] == "off") - new_status = false; - else { - hh->SendError(); - return; - } - NeutrinoAPI->Controld->setScartMode(new_status); - hh->SendOk(); -} - -//------------------------------------------------------------------------- -void CControlAPI::VolumeCGI(CyhookHandler *hh) -{ - if (hh->ParamList.empty()) {//without param: show actual volumen - hh->printf("%d", NeutrinoAPI->Controld->getVolume()); - } - else if (hh->ParamList["1"].compare("mute") == 0) - { - NeutrinoAPI->Controld->setMute(true); - hh->SendOk(); - } - else if (hh->ParamList["1"].compare("unmute") == 0) - { - NeutrinoAPI->Controld->setMute(false); - hh->SendOk(); - } - else if (hh->ParamList["1"].compare("status") == 0) - { - hh->Write((char *) (NeutrinoAPI->Controld->getMute() ? "1" : "0")); // mute - } - else if(hh->ParamList["1"]!="") - { //set volume - char vol = atol( hh->ParamList["1"].c_str() ); - NeutrinoAPI->Controld->setVolume(vol); - hh->SendOk(); - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::ChannellistCGI(CyhookHandler *hh) -{ - SendChannelList(hh); -} - -//----------------------------------------------------------------------------- -void CControlAPI::GetBouquetCGI(CyhookHandler *hh) -{ - if (!(hh->ParamList.empty())) - { - int mode = CZapitClient::MODE_CURRENT; - - if (!(hh->ParamList["mode"].empty())) - { - if (hh->ParamList["mode"].compare("TV") == 0) - mode = CZapitClient::MODE_TV; - if (hh->ParamList["mode"].compare("RADIO") == 0) - mode = CZapitClient::MODE_RADIO; - } - - // Get Bouquet Number. First matching current channel - if (hh->ParamList["1"] == "actual") - { - int actual=0; - CZapitClient::BouquetChannelList *bouquet; - CZapitClient::BouquetList blist; - //easier? - for (unsigned int i = 0; i < NeutrinoAPI->BouquetList.size() && actual == 0;i++) - { - //hh->printf("%u %s\n", (NeutrinoAPI->BouquetList[i].bouquet_nr) + 1, NeutrinoAPI->BouquetList[i].name); - bouquet = NeutrinoAPI->GetBouquet((NeutrinoAPI->BouquetList[i].bouquet_nr) + 1, mode); - CZapitClient::BouquetChannelList::iterator channel = bouquet->begin(); - for (unsigned int j = 0; channel != bouquet->end() && actual == 0; channel++,j++) - { - if(channel->channel_id == NeutrinoAPI->Zapit->getCurrentServiceID()) - actual=i+1; - } - } - hh->printf("%d",actual); - } - else if (!(hh->ParamList["xml"].empty())) - { - hh->WriteLn(""); - hh->WriteLn(""); - hh->printf("\n\t%s\n\n",hh->ParamList["bouquet"].c_str()); - CZapitClient::BouquetChannelList *bouquet; - bouquet = NeutrinoAPI->GetBouquet(atoi(hh->ParamList["bouquet"].c_str()), mode); - CZapitClient::BouquetChannelList::iterator channel = bouquet->begin(); - - for (unsigned int i = 0; channel != bouquet->end(); channel++,i++) - hh->printf("\n\t%u\n\t" - PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - "\n\t\n\n", - channel->nr, - channel->channel_id, - channel->name); - hh->WriteLn(""); - } - else - { - CZapitClient::BouquetChannelList *bouquet; - bouquet = NeutrinoAPI->GetBouquet(atoi(hh->ParamList["bouquet"].c_str()), mode); - CZapitClient::BouquetChannelList::iterator channel = bouquet->begin(); - - for (unsigned int i = 0; channel != bouquet->end(); channel++,i++) - hh->printf("%u " - PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - " %s\n", - channel->nr, - channel->channel_id, - channel->name); - } - } - else - hh->WriteLn("error"); -} - -//----------------------------------------------------------------------------- -void CControlAPI::GetBouquetsCGI(CyhookHandler *hh) -{ - for (unsigned int i = 0; i < NeutrinoAPI->BouquetList.size();i++) - hh->printf("%u %s\n", (NeutrinoAPI->BouquetList[i].bouquet_nr) + 1, NeutrinoAPI->BouquetList[i].name); -} - -//----------------------------------------------------------------------------- -void CControlAPI::EpgCGI(CyhookHandler *hh) -{ - CChannelEvent *event; - NeutrinoAPI->GetChannelEvents(); - - if (hh->ParamList.empty()) - { - hh->SetHeader(HTTP_OK, "text/plain"); - CZapitClient::BouquetChannelList *channellist = NeutrinoAPI->GetChannelList(CZapitClient::MODE_CURRENT); - CZapitClient::BouquetChannelList::iterator channel = channellist->begin(); - for(; channel != channellist->end();channel++) - { - event = NeutrinoAPI->ChannelListEvents[channel->channel_id]; - if (event) - hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - " %llu %s\n", - channel->channel_id, - event->eventID, - event->description.c_str()); - } - } - else if (hh->ParamList["xml"].empty()) - { - hh->SetHeader(HTTP_OK, "text/plain"); - if (hh->ParamList["1"] == "ext") - { - CZapitClient::BouquetChannelList *channellist = NeutrinoAPI->GetChannelList(CZapitClient::MODE_CURRENT); - CZapitClient::BouquetChannelList::iterator channel = channellist->begin(); - for(; channel != channellist->end();channel++) - { - event = NeutrinoAPI->ChannelListEvents[channel->channel_id]; - if(event) - hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - " %ld %u %llu %s\n", - channel->channel_id, - event->startTime, - event->duration, - event->eventID, - event->description.c_str()); - } - } - else if (hh->ParamList["eventid"] != "") - { - //special epg query - unsigned long long epgid; - sscanf( hh->ParamList["eventid"].c_str(), "%llu", &epgid); - CShortEPGData epg; - if (NeutrinoAPI->Sectionsd->getEPGidShort(epgid,&epg)) - { - hh->WriteLn(epg.title); - hh->WriteLn(epg.info1); - hh->WriteLn(epg.info2); - } - } - else if (hh->ParamList["eventid2fsk"] != "") - { - if (hh->ParamList["starttime"] != "") - { - unsigned long long epgid; - time_t starttime; - sscanf( hh->ParamList["fskid"].c_str(), "%llu", &epgid); - sscanf( hh->ParamList["starttime"].c_str(), "%lu", &starttime); - CEPGData longepg; - if(NeutrinoAPI->Sectionsd->getEPGid(epgid, starttime, &longepg)) - { - hh->printf("%u\n", longepg.fsk); - return; - } - } - hh->SendError(); - } - else if (!(hh->ParamList["id"].empty())) - { - t_channel_id channel_id; - sscanf(hh->ParamList["id"].c_str(), - SCANF_CHANNEL_ID_TYPE, - &channel_id); - NeutrinoAPI->eList = NeutrinoAPI->Sectionsd->getEventsServiceKey(channel_id); - CChannelEventList::iterator eventIterator; - for (eventIterator = NeutrinoAPI->eList.begin(); eventIterator != NeutrinoAPI->eList.end(); eventIterator++) - { - CShortEPGData epg; - if (NeutrinoAPI->Sectionsd->getEPGidShort(eventIterator->eventID,&epg)) - { - hh->printf("%llu %ld %d\n", eventIterator->eventID, eventIterator->startTime, eventIterator->duration); - hh->printf("%s\n",epg.title.c_str()); - hh->printf("%s\n",epg.info1.c_str()); - hh->printf("%s\n\n",epg.info2.c_str()); - } - } - } - else - { - //eventlist for a chan - t_channel_id channel_id; - sscanf(hh->ParamList["1"].c_str(), - SCANF_CHANNEL_ID_TYPE, - &channel_id); - SendEventList(hh, channel_id); - } - } - // xml=true&channelid=|channelname=[&details=true][&max=][&stoptime=] - // details=true : Show EPG Info1 and info2 - // stoptime : show only items until stoptime reached - else if (!(hh->ParamList["xml"].empty())) - { - hh->SetHeader(HTTP_OK, "text/xml"); - - t_channel_id channel_id = (t_channel_id)-1; - - if (!(hh->ParamList["channelid"].empty())) - { - sscanf(hh->ParamList["channelid"].c_str(), - SCANF_CHANNEL_ID_TYPE, - &channel_id); - } - else if (!(hh->ParamList["channelname"].empty())) - { - channel_id = NeutrinoAPI->ChannelNameToChannelId( hh->ParamList["channelname"].c_str() ); - } - if(channel_id != (t_channel_id)-1) - { - hh->WriteLn(""); - hh->WriteLn(""); - NeutrinoAPI->eList = NeutrinoAPI->Sectionsd->getEventsServiceKey(channel_id); - hh->printf("" - PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - "\r\n", channel_id); - hh->printf("\r\n", NeutrinoAPI->GetServiceName(channel_id).c_str()); - - // max = maximal output items - int max = -1; - if (!(hh->ParamList["max"].empty())) - max = atoi( hh->ParamList["max"].c_str() ); - - // stoptime = maximal output items until starttime >= stoptime - long stoptime = -1; - if (!(hh->ParamList["stoptime"].empty())) - stoptime = atol( hh->ParamList["stoptime"].c_str() ); - int i=0; - CChannelEventList::iterator eventIterator; - for (eventIterator = NeutrinoAPI->eList.begin(); eventIterator != NeutrinoAPI->eList.end(); eventIterator++, i++) - { - if( (max != -1 && i >= max) || ( stoptime != -1 && eventIterator->startTime >= stoptime)) - break; - hh->WriteLn(""); - hh->printf("\t%llu\r\n", eventIterator->eventID); - hh->printf("\t%llx\r\n", eventIterator->eventID); - hh->printf("\t%ld\r\n", eventIterator->startTime); - char zbuffer[25] = {0}; - struct tm *mtime = localtime(&eventIterator->startTime); - strftime(zbuffer,20,"%H:%M",mtime); - hh->printf("\t%s\r\n", zbuffer); - memset(zbuffer, 0, 25); - strftime(zbuffer,20,"%d.%m.%Y",mtime); - hh->printf("\t%s\r\n", zbuffer); - hh->printf("\t%ld\r\n", eventIterator->startTime+eventIterator->duration); - long _stoptime = eventIterator->startTime+eventIterator->duration; - mtime = localtime(&_stoptime); - strftime(zbuffer,20,"%H:%M",mtime); - hh->printf("\t%s\r\n", zbuffer); - hh->printf("\t%d\r\n", (int)(eventIterator->duration/60)); - hh->printf("\t\r\n", eventIterator->description.c_str()); - - if (!(hh->ParamList["details"].empty())) - { - CShortEPGData epg; - if (NeutrinoAPI->Sectionsd->getEPGidShort(eventIterator->eventID,&epg)) - { - hh->printf("\t\r\n",epg.info1.c_str()); - hh->printf("\t\r\n",epg.info2.c_str()); - } - } - hh->WriteLn(""); - } - hh->WriteLn(""); - } - } -} - -//----------------------------------------------------------------------------- -void CControlAPI::VersionCGI(CyhookHandler *hh) -{ - hh->SendFile("/.version"); -} - -//----------------------------------------------------------------------------- -void CControlAPI::ZaptoCGI(CyhookHandler *hh) -{ - if (hh->ParamList.empty()) - { - hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - "\n", - NeutrinoAPI->Zapit->getCurrentServiceID()); - return; - } - else - { - if (hh->ParamList["1"] == "getpids") // getpids ! - SendcurrentVAPid(hh); - else if (hh->ParamList["1"] == "getallpids") // getpids ! - SendAllCurrentVAPid(hh); - else if (hh->ParamList["1"] == "stopplayback") - { - 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(); - } - else if (hh->ParamList["1"] == "statusplayback") - hh->Write((char *) (NeutrinoAPI->Zapit->isPlayBackActive() ? "1" : "0")); - else if (hh->ParamList["1"] == "stopsectionsd") - { - NeutrinoAPI->Sectionsd->setPauseScanning(true); - hh->SendOk(); - } - else if (hh->ParamList["1"] == "startsectionsd") - { - NeutrinoAPI->Sectionsd->setPauseScanning(false); - hh->SendOk(); - } - else if (hh->ParamList["1"] == "statussectionsd") - hh->Write((char *) (NeutrinoAPI->Sectionsd->getIsScanningActive() ? "scanning active" : "scanning paused\n")); - else if (hh->ParamList["1"] == "restartsectionsd") - { - NeutrinoAPI->Sectionsd->Restart(); - hh->printf("--> restarting sectionsd...
"); - NeutrinoAPI->Sectionsd->RegisterNeutrino(); - hh->printf("--> registering neutrino...
"); - NeutrinoAPI->Sectionsd->setPauseScanning(false); - hh->printf("--> set scanning active...
"); - NeutrinoAPI->Sectionsd->setServiceChanged(NeutrinoAPI->Zapit->getCurrentServiceID(), false); - hh->printf("--> send sectionsd ServiceChanged...
"); - hh->printf("
"); - hh->Write((char *) (NeutrinoAPI->Sectionsd->getIsScanningActive() ? "sectionsd restarted, scanning active!" : "sectionsd restarted, scanning paused")); - } - else if (hh->ParamList["1"] == "freememsectionsd") - { - NeutrinoAPI->Sectionsd->freeMemory(); - hh->printf("freeing memory... done!\n"); - } - else if (hh->ParamList["1"] == "getallsubchannels") - { - t_channel_id current_channel = NeutrinoAPI->Zapit->getCurrentServiceID(); - CSectionsdClient::LinkageDescriptorList desc; - CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo; - NeutrinoAPI->Sectionsd->getCurrentNextServiceKey(current_channel, currentNextInfo); - if (NeutrinoAPI->Sectionsd->getLinkageDescriptorsUniqueKey(currentNextInfo.current_uniqueKey,desc)) - { - for(unsigned int i=0;i< desc.size();i++) - { - t_channel_id sub_channel_id = - CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID( - desc[i].serviceId, desc[i].originalNetworkId, desc[i].transportStreamId); - hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - " %s\n", - sub_channel_id, - (desc[i].name).c_str()); - } - } - } - else if (hh->ParamList["name"] != "") - { - t_channel_id channel_id; - channel_id = NeutrinoAPI->ChannelNameToChannelId(hh->ParamList["name"]); - if(channel_id != (t_channel_id)-1) - { - NeutrinoAPI->ZapToChannelId(channel_id); - hh->SendOk(); - } - else - hh->SendError(); - } - else - { - NeutrinoAPI->ZapTo(hh->ParamList["1"].c_str()); - - hh->SendOk(); - } - return; - } - hh->SendError(); - return; -} - -//----------------------------------------------------------------------------- -void CControlAPI::StartPluginCGI(CyhookHandler *hh) -{ - std::string pluginname; - if (!(hh->ParamList.empty())) - { - if (hh->ParamList["name"] != "") - { - pluginname = hh->ParamList["name"]; - pluginname=decodeString(pluginname); - NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::EVT_START_PLUGIN, - CEventServer::INITID_HTTPD, - (void *) pluginname.c_str(), - pluginname.length() + 1); - - hh->SendOk(); - } - else - hh->SendError(); - - } - else - hh->SendError(); -} - -//----------------------------------------------------------------------------- -void CControlAPI::LCDAction(CyhookHandler *hh) -{ - int tval; - int error=0; - int xpos=10, ypos=10, size=12, color=1, font=0; - int x1,y1,x2,y2,coll,colf; - - if (hh->ParamList.empty()) - { - hh->SendError(); - return; - } - - if (hh->ParamList["lock"] != "") { - if(sscanf( hh->ParamList["lock"].c_str(), "%d", &tval)) - NeutrinoAPI->LcdAPI->LockDisplay(tval); - else - error=1; - } - if (hh->ParamList["clear"] != "") { - if(sscanf( hh->ParamList["clear"].c_str(), "%d", &tval)){ - if(tval) - NeutrinoAPI->LcdAPI->Clear(); - } - else - error=1; - } - if (hh->ParamList["png"] != "") { - if(! NeutrinoAPI->LcdAPI->ShowPng((char*)hh->ParamList["png"].c_str())) - error=1; - } - if (hh->ParamList["raw"] != "") { - char *sptr=strdup((char*)hh->ParamList["raw"].c_str()),*pptr; - int loop=4; - pptr=sptr; - error=1; - if(sscanf(pptr, "%d,%d,%d,%d",&x1,&y1,&x2,&y2)==4) { - while(loop-- && ((pptr=strchr(pptr,','))!=NULL)) - ++pptr; - if(pptr) { - NeutrinoAPI->LcdAPI->ShowRaw(x1,y1,x2,y2,pptr); - error=0; - } - } - if(sptr) - free(sptr); - } - if (hh->ParamList["line"] != "") { - if(sscanf( hh->ParamList["line"].c_str(), "%d,%d,%d,%d,%d",&x1,&y1,&x2,&y2,&coll)==5) - NeutrinoAPI->LcdAPI->DrawLine(x1,y1,x2,y2,coll); - else - error=1; - } - if (hh->ParamList["rect"] != "") { - if(sscanf( hh->ParamList["rect"].c_str(), "%d,%d,%d,%d,%d,%d",&x1,&y1,&x2,&y2,&coll,&colf)==6) - NeutrinoAPI->LcdAPI->DrawRect(x1,y1,x2,y2,coll,colf); - else - error=1; - } - if (hh->ParamList["xpos"] != "") { - if(sscanf( hh->ParamList["xpos"].c_str(), "%d", &tval)) - xpos=tval; - else - error=1; - } - if (hh->ParamList["ypos"] != "") { - if(sscanf( hh->ParamList["ypos"].c_str(), "%d", &tval)) - ypos=tval; - else - error=1; - } - if (hh->ParamList["size"] != "") { - if(sscanf( hh->ParamList["size"].c_str(), "%d", &tval)) - size=tval; - else - error=1; - } - if (hh->ParamList["color"] != "") { - if(sscanf( hh->ParamList["color"].c_str(), "%d", &tval)) - color=tval; - else - error=1; - } - if (hh->ParamList["font"] != "") { - if(sscanf( hh->ParamList["font"].c_str(), "%d", &tval) && tval>=0 && tval<3) - font=tval; - else - error=1; - } - if (hh->ParamList["text"] != "") - NeutrinoAPI->LcdAPI->DrawText(xpos, ypos, size, color, font, (char*)hh->ParamList["text"].c_str()); - if (hh->ParamList["update"] != "") { - if(sscanf( hh->ParamList["update"].c_str(), "%d", &tval)) { - if(tval) - NeutrinoAPI->LcdAPI->Update(); - } - else - error=1; - } - - if(error) hh->SendError(); - else hh->SendOk(); -} - -//------------------------------------------------------------------------- -// Send functions (for ExecuteCGI) -//------------------------------------------------------------------------- -void CControlAPI::SendEventList(CyhookHandler *hh, t_channel_id channel_id) -{ - int pos; - NeutrinoAPI->eList = NeutrinoAPI->Sectionsd->getEventsServiceKey(channel_id); - CChannelEventList::iterator eventIterator; - - for (eventIterator = NeutrinoAPI->eList.begin(); eventIterator != NeutrinoAPI->eList.end(); eventIterator++, pos++) - hh->printf("%llu %ld %d %s\n", eventIterator->eventID, eventIterator->startTime, eventIterator->duration, eventIterator->description.c_str()); -} - -//----------------------------------------------------------------------------- -void CControlAPI::SendChannelList(CyhookHandler *hh) -{ - CZapitClient::BouquetChannelList *channellist = NeutrinoAPI->GetChannelList(CZapitClient::MODE_CURRENT); - CZapitClient::BouquetChannelList::iterator channel = channellist->begin(); - - for(; channel != channellist->end();channel++) - hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - " %s\n", - channel->channel_id, - channel->name); -} - -//----------------------------------------------------------------------------- -void CControlAPI::SendStreamInfo(CyhookHandler *hh) -{ - - int bitInfo[10]; - NeutrinoAPI->GetStreamInfo(bitInfo); - hh->printf("%d\n%d\n", bitInfo[0], bitInfo[1] ); //Resolution x y - hh->printf("%d\n", bitInfo[4]*50); //Bitrate bit/sec - - switch (bitInfo[2]) //format - { - case 2: hh->Write("4:3\n"); break; - case 3: hh->Write("16:9\n"); break; - case 4: hh->Write("2.21:1\n"); break; - default: hh->Write("unknown\n"); break; - } - switch (bitInfo[3]) //fps - { - case 3: hh->Write("25\n"); break; - case 6: hh->Write("50\n"); break; - default: hh->Write("unknown\n"); - } - hh->WriteLn(NeutrinoAPI->audiotype_names[bitInfo[6]]); -} - -//----------------------------------------------------------------------------- -void CControlAPI::SendcurrentVAPid(CyhookHandler *hh) -{ - CZapitClient::responseGetPIDs pids; - pids.PIDs.vpid=0; - NeutrinoAPI->Zapit->getPIDS(pids); - - hh->printf("%u\n", pids.PIDs.vpid); - if(!pids.APIDs.empty()) - hh->printf("%u\n", pids.APIDs[0].pid); - else - hh->printf("0\n"); -} - -//----------------------------------------------------------------------------- -void CControlAPI::SendAllCurrentVAPid(CyhookHandler *hh) -{ - static bool init_iso=true; - if(init_iso) - { - if(_initialize_iso639_map()) - init_iso=false; - } - bool eit_not_ok=true; - CZapitClient::responseGetPIDs pids; - - CSectionsdClient::ComponentTagList tags; - pids.PIDs.vpid=0; - NeutrinoAPI->Zapit->getPIDS(pids); - - hh->printf("%05u\n", pids.PIDs.vpid); - - t_channel_id current_channel = NeutrinoAPI->Zapit->getCurrentServiceID(); - CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo; - NeutrinoAPI->Sectionsd->getCurrentNextServiceKey(current_channel, currentNextInfo); - if (NeutrinoAPI->Sectionsd->getComponentTagsUniqueKey(currentNextInfo.current_uniqueKey,tags)) - { - for (unsigned int i=0; i< tags.size(); i++) - { - for (unsigned short j=0; j< pids.APIDs.size(); j++) - { - if ( pids.APIDs[j].component_tag == tags[i].componentTag ) - { - if(!tags[i].component.empty()) - { - if(!(isalnum(tags[i].component[0]))) - tags[i].component=tags[i].component.substr(1,tags[i].component.length()-1); - hh->printf("%05u %s\n",pids.APIDs[j].pid,tags[i].component.c_str()); - } - else - { - if(!(init_iso)) - { - strcpy( pids.APIDs[j].desc, _getISO639Description( pids.APIDs[j].desc ) ); - } - hh->printf("%05u %s %s\n",pids.APIDs[j].pid,pids.APIDs[j].desc,pids.APIDs[j].is_ac3 ? " (AC3)": " "); - } - eit_not_ok=false; - break; - } - } - } - } - if(eit_not_ok) - { - unsigned short i = 0; - for (CZapitClient::APIDList::iterator it = pids.APIDs.begin(); it!=pids.APIDs.end(); it++) - { - if(!(init_iso)) - { - strcpy( pids.APIDs[i].desc, _getISO639Description( pids.APIDs[i].desc ) ); - } - hh->printf("%05u %s %s\n",it->pid,pids.APIDs[i].desc,pids.APIDs[i].is_ac3 ? " (AC3)": " "); - i++; - } - } - - if(pids.APIDs.empty()) - hh->printf("0\n"); // shouldnt happen, but print at least one apid - if(pids.PIDs.vtxtpid) - hh->printf("%05u vtxt\n",pids.PIDs.vtxtpid); - if (pids.PIDs.pmtpid) - hh->printf("%05u pmt\n",pids.PIDs.pmtpid); - -} -//----------------------------------------------------------------------------- -void CControlAPI::SendSettings(CyhookHandler *hh) -{ - hh->WriteLn( - "Boxtype " + - NeutrinoAPI->Dbox_Hersteller[NeutrinoAPI->Controld->getBoxType()] + - "\n" - "videooutput " + - NeutrinoAPI->videooutput_names[(unsigned char)NeutrinoAPI->Controld->getVideoOutput()] + - "\n" - "videoformat " + - NeutrinoAPI->videoformat_names[(unsigned char)NeutrinoAPI->Controld->getVideoFormat()] - ); -} -//----------------------------------------------------------------------------- -void CControlAPI::SendTimers(CyhookHandler *hh) -{ - CTimerd::TimerList timerlist; // List of bouquets - bool send_id = false; - - if (hh->ParamList["format"] == "id") - send_id = true; - - timerlist.clear(); - NeutrinoAPI->Timerd->getTimerList(timerlist); - - CTimerd::TimerList::iterator timer = timerlist.begin(); - - for(; timer != timerlist.end();timer++) - { - // Add Data - char zAddData[22+1] = { 0 }; - if (send_id) - { - zAddData[0] = '0'; - zAddData[1] = 0; - } - - switch(timer->eventType) { - case CTimerd::TIMER_NEXTPROGRAM: - case CTimerd::TIMER_ZAPTO: - case CTimerd::TIMER_RECORD: - if (!send_id) - { - strncpy(zAddData, NeutrinoAPI->Zapit->getChannelName(timer->channel_id).c_str(), 22); - if (zAddData[0] == 0) - strcpy(zAddData, NeutrinoAPI->Zapit->isChannelTVChannel(timer->channel_id) ? "Unbekannter TV-Kanal" : "Unbekannter Radiokanal"); - } - else - sprintf(zAddData, PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer->channel_id); - - zAddData[22]=0; - - break; - - case CTimerd::TIMER_STANDBY: - if (!send_id) - sprintf(zAddData,"Standby: %s",(timer->standby_on ? "ON" : "OFF")); - break; - - case CTimerd::TIMER_REMIND : - if (!send_id) - strncpy(zAddData, timer->message, 22); - zAddData[22]=0; - break; - - default: - break; - } - - hh->printf("%d %d %d %d %d %d %d %s\n", - timer->eventID, - (int)timer->eventType, - (int)timer->eventRepeat, - (int)timer->repeatCount, - (int)timer->announceTime, - (int)timer->alarmTime, - (int)timer->stopTime, - zAddData); - } -} - -//----------------------------------------------------------------------------- -// yweb : Extentions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Dispatcher -//----------------------------------------------------------------------------- -void CControlAPI::YWebCGI(CyhookHandler *hh) -{ - bool status=true; - int para; - if (hh->ParamList["video_stream_pids"] != "") - { - para=0; - sscanf( hh->ParamList["video_stream_pids"].c_str(), "%d", ¶); - YWeb_SendVideoStreamingPids(hh, para); - } - else if (hh->ParamList["1"] == "radio_stream_pid") - YWeb_SendRadioStreamingPid(hh); - - if(!status) - hh->SendError(); -} - -//----------------------------------------------------------------------------- -// Get Streaming Pids 0x$pmt,0x$vpid,0x$apid with apid_no is the Number of Audio-Pid -//----------------------------------------------------------------------------- -void CControlAPI::YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no) -{ - CZapitClient::responseGetPIDs pids; - int apid=0,apid_idx=0; - pids.PIDs.vpid=0; - NeutrinoAPI->Zapit->getPIDS(pids); - - if( apid_no < (int)pids.APIDs.size()) - apid_idx=apid_no; - if(!pids.APIDs.empty()) - apid = pids.APIDs[apid_idx].pid; - if(hh->ParamList["no_commas"] != "") - hh->printf("0x%04x 0x%04x 0x%04x",pids.PIDs.pmtpid,pids.PIDs.vpid,apid); - else - hh->printf("0x%04x,0x%04x,0x%04x",pids.PIDs.pmtpid,pids.PIDs.vpid,apid); -} - -//----------------------------------------------------------------------------- -// Get Streaming Pids 0x$pmt,0x$vpid,0x$apid with apid_no is the Number of Audio-Pid -//----------------------------------------------------------------------------- -void CControlAPI::YWeb_SendRadioStreamingPid(CyhookHandler *hh) -{ - CZapitClient::responseGetPIDs pids; - int apid=0; - NeutrinoAPI->Zapit->getPIDS(pids); - - if(!pids.APIDs.empty()) - apid = pids.APIDs[0].pid; - hh->printf("0x%04x",apid); -} - -//----------------------------------------------------------------------------- -std::string CControlAPI::YexecuteScript(CyhookHandler *, std::string cmd) -{ - std::string script, para, result; - bool found = false; - - // split script and parameters - int pos; - if ((pos = cmd.find_first_of(" ")) > 0) - { - script = cmd.substr(0, pos); - para = cmd.substr(pos+1,cmd.length() - (pos+1)); // snip - } - else - script=cmd; - // get file - std::string fullfilename; - script += ".sh"; //add script extention - char cwd[255]; - getcwd(cwd, 254); - - for (unsigned int i=0;iParamList["update"]="1"; - doNewTimer(hh); -} -//------------------------------------------------------------------------- -void CControlAPI::doNewTimer(CyhookHandler *hh) -{ - time_t announceTimeT = 0, - stopTimeT = 0, - alarmTimeT = 0, - tnull = 0; - unsigned int repCount = 0; - int alHour=0; - - // if alarm given then in parameters im time_t format - if(hh->ParamList["alarm"] != "") - { - alarmTimeT = atoi(hh->ParamList["alarm"].c_str()); - if(hh->ParamList["stop"] != "") - stopTimeT = atoi(hh->ParamList["stop"].c_str()); - if(hh->ParamList["announce"] != "") - announceTimeT = atoi(hh->ParamList["announce"].c_str()); - else - announceTimeT = alarmTimeT; - } - else if(hh->ParamList["alDate"] != "") //given formatted - { - // Alarm Date - Format exact! DD.MM.YYYY - tnull = time(NULL); - struct tm *alarmTime=localtime(&tnull); - alarmTime->tm_sec = 0; - if(sscanf(hh->ParamList["alDate"].c_str(),"%2d.%2d.%4d",&(alarmTime->tm_mday), &(alarmTime->tm_mon), &(alarmTime->tm_year)) == 3) - { - alarmTime->tm_mon -= 1; - alarmTime->tm_year -= 1900; - } - - // Alarm Time - Format exact! HH:MM - if(hh->ParamList["alTime"] != "") - sscanf(hh->ParamList["alTime"].c_str(),"%2d.%2d",&(alarmTime->tm_hour), &(alarmTime->tm_min)); - alHour = alarmTime->tm_hour; - correctTime(alarmTime); - alarmTimeT = mktime(alarmTime); - announceTimeT = alarmTimeT; - struct tm *stopTime = localtime(&alarmTimeT); - stopTime->tm_sec = 0; - // Stop Time - Format exact! HH:MM - if(hh->ParamList["stTime"] != "") - sscanf(hh->ParamList["stTime"].c_str(),"%2d.%2d",&(stopTime->tm_hour), &(stopTime->tm_min)); - - // Stop Date - Format exact! DD.MM.YYYY - if(hh->ParamList["stDate"] != "") - if(sscanf(hh->ParamList["stDate"].c_str(),"%2d.%2d.%4d",&(stopTime->tm_mday), &(stopTime->tm_mon), &(stopTime->tm_year)) == 3) - { - stopTime->tm_mon -= 1; - stopTime->tm_year -= 1900; - } - correctTime(stopTime); - stopTimeT = mktime(stopTime); - if(hh->ParamList["stDate"] == "" && alHour > stopTime->tm_hour) - stopTimeT += 24* 60 * 60; // add 1 Day - } - else // alarm/stop time given in pieces - { - // alarm time - time_t now = time(NULL); - struct tm *alarmTime=localtime(&now); - if(hh->ParamList["ad"] != "") - alarmTime->tm_mday = atoi(hh->ParamList["ad"].c_str()); - if(hh->ParamList["amo"] != "") - alarmTime->tm_mon = atoi(hh->ParamList["amo"].c_str())-1; - if(hh->ParamList["ay"] != "") - alarmTime->tm_year = atoi(hh->ParamList["ay"].c_str())-1900; - if(hh->ParamList["ah"] != "") - alarmTime->tm_hour = atoi(hh->ParamList["ah"].c_str()); - if(hh->ParamList["ami"] != "") - alarmTime->tm_min = atoi(hh->ParamList["ami"].c_str()); - alarmTime->tm_sec = 0; - correctTime(alarmTime); - alarmTimeT = mktime(alarmTime); - announceTimeT = alarmTimeT; - - // stop time - struct tm *stopTime = alarmTime; - if(hh->ParamList["sd"] != "") - stopTime->tm_mday = atoi(hh->ParamList["sd"].c_str()); - if(hh->ParamList["smo"] != "") - stopTime->tm_mon = atoi(hh->ParamList["smo"].c_str())-1; - if(hh->ParamList["sy"] != "") - stopTime->tm_year = atoi(hh->ParamList["sy"].c_str())-1900; - if(hh->ParamList["sh"] != "") - stopTime->tm_hour = atoi(hh->ParamList["sh"].c_str()); - if(hh->ParamList["smi"] != "") - stopTime->tm_min = atoi(hh->ParamList["smi"].c_str()); - stopTime->tm_sec = 0; - correctTime(stopTime); - stopTimeT = mktime(stopTime); - } - - if(announceTimeT != 0) - announceTimeT -= 60; - - CTimerd::CTimerEventTypes type; - if(hh->ParamList["type"] != "") - type = (CTimerd::CTimerEventTypes) atoi(hh->ParamList["type"].c_str()); - else // default is: record - type = CTimerd::TIMER_RECORD; - - // repeat - if(hh->ParamList["repcount"] != "") - { - repCount = atoi(hh->ParamList["repcount"].c_str()); - } - CTimerd::CTimerEventRepeat rep; - if(hh->ParamList["rep"] != "") - rep = (CTimerd::CTimerEventRepeat) atoi(hh->ParamList["rep"].c_str()); - else // default: no repeat - rep = (CTimerd::CTimerEventRepeat)0; - - if(((int)rep) >= ((int)CTimerd::TIMERREPEAT_WEEKDAYS) && hh->ParamList["wd"] != "") - NeutrinoAPI->Timerd->getWeekdaysFromStr((int*)&rep, hh->ParamList["wd"].c_str()); - // apids - bool changeApids=false; - unsigned char apids=0; - if(hh->ParamList["apcf"] == "on") - { - changeApids=true; - apids=0; - } - else - { - if(hh->ParamList["apst"] == "on") - { - changeApids=true; - apids |= TIMERD_APIDS_STD; - } - if(hh->ParamList["apal"] == "on") - { - changeApids=true; - apids |= TIMERD_APIDS_ALT; - } - if(hh->ParamList["apac"] == "on") - { - changeApids=true; - apids |= TIMERD_APIDS_AC3; - } - } - - CTimerd::RecordingInfo recinfo; - CTimerd::EventInfo eventinfo; - eventinfo.epgID = 0; - eventinfo.epg_starttime = 0; - eventinfo.apids = TIMERD_APIDS_CONF; - eventinfo.recordingSafety = (hh->ParamList["rs"] == "1"); - - // channel by Id or name - if(hh->ParamList["channel_id"] != "") - sscanf(hh->ParamList["channel_id"].c_str(), - SCANF_CHANNEL_ID_TYPE, - &eventinfo.channel_id); - else - eventinfo.channel_id = NeutrinoAPI->ChannelNameToChannelId(hh->ParamList["channel_name"]); - - std::string _rec_dir = hh->ParamList["rec_dir"]; - void *data=NULL; - if(type == CTimerd::TIMER_RECORD) - announceTimeT-=120; - if(type == CTimerd::TIMER_STANDBY) - { - bool standby_on = (hh->ParamList["sbon"]=="1"); - data=&standby_on; - } - else if(type==CTimerd::TIMER_NEXTPROGRAM || type==CTimerd::TIMER_ZAPTO) - data= &eventinfo; - else if (type==CTimerd::TIMER_RECORD) - { - if(_rec_dir == "") - { - // get Default Recordingdir - CConfigFile *Config = new CConfigFile(','); - Config->loadConfig(NEUTRINO_CONFIGFILE); - _rec_dir = Config->getString("recording_dir_0", "/mnt/filme"); - delete Config; - } - if(changeApids) - eventinfo.apids = apids; - recinfo = eventinfo; - strncpy(recinfo.recordingDir, _rec_dir.c_str(), RECORD_DIR_MAXLEN-1); - data = &recinfo; - } - else if(type==CTimerd::TIMER_REMIND) - { - char msg[REMINDER_MESSAGE_MAXLEN]; - memset(msg, 0, sizeof(msg)); - strncpy(msg, hh->ParamList["msg"].c_str(),REMINDER_MESSAGE_MAXLEN-1); - data=msg; - } - else if(type==CTimerd::TIMER_EXEC_PLUGIN) - { - char msg[EXEC_PLUGIN_NAME_MAXLEN]; - memset(msg, 0, sizeof(msg)); - strncpy(msg, hh->ParamList["PluginName"].c_str(),EXEC_PLUGIN_NAME_MAXLEN-1); - data=msg; - } - // update or add timer - if(hh->ParamList["update"]=="1") - { - if(hh->ParamList["id"] != "") - { - unsigned modyId = atoi(hh->ParamList["id"].c_str()); - if(type == CTimerd::TIMER_RECORD) - NeutrinoAPI->Timerd->modifyRecordTimerEvent(modyId, announceTimeT, alarmTimeT, stopTimeT, rep,repCount,_rec_dir.c_str()); - else - NeutrinoAPI->Timerd->modifyTimerEvent(modyId, announceTimeT, alarmTimeT, stopTimeT, rep,repCount); -// NeutrinoAPI->Timerd->removeTimerEvent(modyId); - if(changeApids) - NeutrinoAPI->Timerd->modifyTimerAPid(modyId,apids); - } - else - { - CTimerd::TimerList timerlist; - timerlist.clear(); - NeutrinoAPI->Timerd->getTimerList(timerlist); - CTimerd::TimerList::iterator timer = timerlist.begin(); - - // Look for Recording Safety Timers too - time_t real_alarmTimeT = alarmTimeT; - if(eventinfo.recordingSafety) - { - int pre,post; - NeutrinoAPI->Timerd->getRecordingSafety(pre,post); - real_alarmTimeT -= pre; - } - - for(; timer != timerlist.end();timer++) - if(timer->alarmTime == real_alarmTimeT) - { - NeutrinoAPI->Timerd->removeTimerEvent(timer->eventID); - break; - } - NeutrinoAPI->Timerd->addTimerEvent(type,data,announceTimeT,alarmTimeT,stopTimeT,rep,repCount); - } - } - else - NeutrinoAPI->Timerd->addTimerEvent(type,data,announceTimeT,alarmTimeT,stopTimeT,rep,repCount); - - hh->SendOk(); -} -//------------------------------------------------------------------------- -void CControlAPI::setBouquetCGI(CyhookHandler *hh) -{ - if (hh->ParamList["selected"] != "") { - int selected = atoi(hh->ParamList["selected"].c_str()); - if(hh->ParamList["action"].compare("hide") == 0) - NeutrinoAPI->Zapit->setBouquetHidden(selected - 1,true); - else if(hh->ParamList["action"].compare("show") == 0) - NeutrinoAPI->Zapit->setBouquetHidden(selected - 1,false); - else if(hh->ParamList["action"].compare("lock") == 0) - NeutrinoAPI->Zapit->setBouquetLock(selected - 1,true); - else if(hh->ParamList["action"].compare("unlock") == 0) - NeutrinoAPI->Zapit->setBouquetLock(selected - 1,false); - hh->SendOk(); - } - else - hh->SendError(); -} -//------------------------------------------------------------------------- -void CControlAPI::saveBouquetCGI(CyhookHandler *hh) -{ - NeutrinoAPI->Zapit->saveBouquets(); - NeutrinoAPI->UpdateBouquets(); - hh->SendOk(); -} -//------------------------------------------------------------------------- -void CControlAPI::moveBouquetCGI(CyhookHandler *hh) -{ - if (hh->ParamList["selected"] != "" && ( - hh->ParamList["action"] == "up" || - hh->ParamList["action"] == "down")) - { - int selected = atoi(hh->ParamList["selected"].c_str()); - if (hh->ParamList["action"] == "up") { - NeutrinoAPI->Zapit->moveBouquet(selected - 1, (selected - 1) - 1); - selected--; - } else { - NeutrinoAPI->Zapit->moveBouquet(selected - 1, (selected + 1) - 1); - selected++; - } - hh->SendOk(); - } - else - hh->SendError(); -} -//------------------------------------------------------------------------- -void CControlAPI::deleteBouquetCGI(CyhookHandler *hh) -{ - int selected = -1; - - if (hh->ParamList["selected"] != "") { - selected = atoi(hh->ParamList["selected"].c_str()); - NeutrinoAPI->Zapit->deleteBouquet(selected - 1); - hh->SendOk(); - } - else - hh->SendError(); -} -//------------------------------------------------------------------------- -void CControlAPI::addBouquetCGI(CyhookHandler *hh) -{ - if (!hh->ParamList["name"].empty()) - { - std::string tmp = hh->ParamList["name"]; - if (NeutrinoAPI->Zapit->existsBouquet(tmp.c_str()) == -1) - { - NeutrinoAPI->Zapit->addBouquet(tmp.c_str()); - hh->SendOk(); - } - else - hh->SendError(); - } -} -//------------------------------------------------------------------------- -void CControlAPI::renameBouquetCGI(CyhookHandler *hh) -{ - if (hh->ParamList["selected"] != "") - { - if (hh->ParamList["nameto"] != "") - { - if (NeutrinoAPI->Zapit->existsBouquet((hh->ParamList["nameto"]).c_str()) == -1) - { - NeutrinoAPI->Zapit->renameBouquet(atoi(hh->ParamList["selected"].c_str()) - 1, ZapitTools::Latin1_to_UTF8(hh->ParamList["nameto"].c_str()).c_str()); - hh->SendOk(); - return; - } - } - } - hh->SendError(); -} -//------------------------------------------------------------------------- -void CControlAPI::changeBouquetCGI(CyhookHandler *hh) -{ - if (!(hh->ParamList["selected"].empty())) - { - int selected = atoi(hh->ParamList["selected"].c_str()); - CZapitClient::BouquetChannelList BChannelList; - NeutrinoAPI->Zapit->getBouquetChannels(selected - 1, BChannelList, CZapitClient::MODE_CURRENT); - CZapitClient::BouquetChannelList::iterator channels = BChannelList.begin(); - for(; channels != BChannelList.end();channels++) - { - NeutrinoAPI->Zapit->removeChannelFromBouquet(selected - 1, channels->channel_id); - } - - t_channel_id channel_id; - int delta; - const char * bchannels = hh->ParamList["bchannels"].c_str(); - while (sscanf(bchannels, - SCANF_CHANNEL_ID_TYPE - "%n", - &channel_id, - &delta) > 0) - { - NeutrinoAPI->Zapit->addChannelToBouquet(selected - 1, channel_id); - bchannels += (delta + 1); // skip the separating ',', too - } - - NeutrinoAPI->Zapit->renumChannellist(); - NeutrinoAPI->UpdateBouquets(); - if(hh->ParamList["redirect"] != "") - hh->SendRewrite(hh->ParamList["redirect"]); - else - hh->SendOk(); - } - else - hh->SendError(); -} -//------------------------------------------------------------------------- -void CControlAPI::updateBouquetCGI(CyhookHandler *hh) -{ - NeutrinoAPI->UpdateBouquets(); - hh->SendOk(); -} -//------------------------------------------------------------------------- -// audio_no : (optional) audio channel -// host : (optional) ip of dbox -void CControlAPI::build_live_url(CyhookHandler *hh) -{ - std::string xpids,port,yresult; - int mode = NeutrinoAPI->Zapit->getMode(); - - if ( mode == CZapitClient::MODE_TV) - { - CZapitClient::responseGetPIDs pids; - int apid=0,apid_no=0,apid_idx=0; - pids.PIDs.vpid=0; - - if(hh->ParamList["audio_no"] !="") - apid_no = atoi(hh->ParamList["audio_no"].c_str()); - NeutrinoAPI->Zapit->getPIDS(pids); - - if( apid_no < (int)pids.APIDs.size()) - apid_idx=apid_no; - if(!pids.APIDs.empty()) - apid = pids.APIDs[apid_idx].pid; - xpids = string_printf("0x%04x,0x%04x,0x%04x",pids.PIDs.pmtpid,pids.PIDs.vpid,apid); - } - else if ( mode == CZapitClient::MODE_RADIO) - { - CZapitClient::responseGetPIDs pids; - int apid=0; - - NeutrinoAPI->Zapit->getPIDS(pids); - if(!pids.APIDs.empty()) - apid = pids.APIDs[0].pid; - - xpids = string_printf("0x%04x",apid); - } - else - hh->SendError(); - // build url - std::string url = ""; - if(hh->ParamList["host"] !="") - url = "http://"+hh->ParamList["host"]; - else - url = "http://"+hh->HeaderList["Host"]; - url += (mode == CZapitClient::MODE_TV) ? ":31339/0," : ":31338/"; - url += xpids; - // response url - if(hh->ParamList["vlc_link"] !="") - { - write_to_file("/tmp/vlc.m3u", url); - hh->SendRedirect("/tmp/vlc.m3u"); - } - else - { - hh->SetHeader(HTTP_OK, "text/html"); - hh->Write(url); - } -} diff --git a/src/nhttpd/tuxboxapi/dbox/controlapi.h b/src/nhttpd/tuxboxapi/dbox/controlapi.h deleted file mode 100644 index 9374e2353..000000000 --- a/src/nhttpd/tuxboxapi/dbox/controlapi.h +++ /dev/null @@ -1,117 +0,0 @@ -//============================================================================= -// NHTTPD -// Neutrino ControlAPI -//============================================================================= -#ifndef __nhttpd_neutrinocontrolapi_hpp__ -#define __nhttpd_neutrinocontrolapi_hpp__ -// C++ -#include -// yhttpd -#include "yhook.h" - -// forward declaration -class CNeutrinoAPI; - -//----------------------------------------------------------------------------- -class CControlAPI : public Cyhook -{ -private: - // Dispatcher Array - typedef void (CControlAPI::*TyFunc)(CyhookHandler *hh); - typedef struct - { - const char *func_name; - TyFunc pfunc; - const char *mime_type; - } TyCgiCall; - const static TyCgiCall yCgiCallList[]; - - int rc_send(int ev, unsigned int code, unsigned int value); - - // send functions for ExecuteCGI (controld api) - void SendEventList(CyhookHandler *hh,t_channel_id channel_id); - void SendcurrentVAPid(CyhookHandler *hh); - void SendAllCurrentVAPid(CyhookHandler *hh); - void SendSettings(CyhookHandler *hh); - void SendStreamInfo(CyhookHandler *hh); - void SendBouquets(CyhookHandler *hh); - void SendBouquet(CyhookHandler *hh,int BouquetNr); - void SendChannelList(CyhookHandler *hh); - void SendTimers(CyhookHandler *hh); - - // subs - friend class CNeutrinoWebserver; // for timer /fb/ compatibility - void doModifyTimer(CyhookHandler *hh); - void doNewTimer(CyhookHandler *hh); - - //yweb - void YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no); - void YWeb_SendRadioStreamingPid(CyhookHandler *hh); - void compatibility_Timer(CyhookHandler *hh); - std::string YexecuteScript(CyhookHandler *hh, std::string cmd); - - // CGI functions for ExecuteCGI - void TimerCGI(CyhookHandler *hh); - void SetModeCGI(CyhookHandler *hh); - void GetModeCGI(CyhookHandler *hh); - void ExecCGI(CyhookHandler *hh); - void SystemCGI(CyhookHandler *hh); - void StandbyCGI(CyhookHandler *hh); - void EsoundCGI(CyhookHandler *hh); - void RCCGI(CyhookHandler *hh); - void GetDateCGI(CyhookHandler *hh); - void GetTimeCGI(CyhookHandler *hh); - void SettingsCGI(CyhookHandler *hh); - void GetServicesxmlCGI(CyhookHandler *hh); - void GetBouquetsxmlCGI(CyhookHandler *hh); - void GetChannel_IDCGI(CyhookHandler *hh); - void MessageCGI(CyhookHandler *hh); - void InfoCGI(CyhookHandler *hh); - void ShutdownCGI(CyhookHandler *hh); - void VolumeCGI(CyhookHandler *hh); - void ChannellistCGI(CyhookHandler *hh); - void GetBouquetCGI(CyhookHandler *hh); - void GetBouquetsCGI(CyhookHandler *hh); - void EpgCGI(CyhookHandler *hh); - void VersionCGI(CyhookHandler *hh); - void ZaptoCGI(CyhookHandler *hh); - void StartPluginCGI(CyhookHandler *hh); - void LCDAction(CyhookHandler *hh); - void YWebCGI(CyhookHandler *hh); - void RebootCGI(CyhookHandler *hh); - void RCEmCGI(CyhookHandler *hh); - void AspectRatioCGI(CyhookHandler *hh); - void VideoFormatCGI(CyhookHandler *hh); - void VideoOutputCGI(CyhookHandler *hh); - void VCROutputCGI(CyhookHandler *hh); - void ScartModeCGI(CyhookHandler *hh); - void setBouquetCGI(CyhookHandler *hh); - void saveBouquetCGI(CyhookHandler *hh); - void moveBouquetCGI(CyhookHandler *hh); - void deleteBouquetCGI(CyhookHandler *hh); - void addBouquetCGI(CyhookHandler *hh); - void renameBouquetCGI(CyhookHandler *hh); - void changeBouquetCGI(CyhookHandler *hh); - void updateBouquetCGI(CyhookHandler *hh); - void build_live_url(CyhookHandler *hh); - -protected: - static const unsigned int PLUGIN_DIR_COUNT = 5; - static std::string PLUGIN_DIRS[PLUGIN_DIR_COUNT]; - CNeutrinoAPI *NeutrinoAPI; - - void init(CyhookHandler *hh); - void Execute(CyhookHandler *hh); - -public: - // constructor & deconstructor - CControlAPI(CNeutrinoAPI *_NeutrinoAPI); - - // virtual functions for HookHandler/Hook - virtual std::string getHookName(void) {return std::string("mod_ControlAPI");} - virtual std::string getHookVersion(void) {return std::string("$Revision$");} - virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); - virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); -}; - -#endif /* __nhttpd_neutrinocontrolapi_hpp__ */ diff --git a/src/nhttpd/tuxboxapi/dbox/lcdapi.cpp b/src/nhttpd/tuxboxapi/dbox/lcdapi.cpp deleted file mode 100644 index e75454868..000000000 --- a/src/nhttpd/tuxboxapi/dbox/lcdapi.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - nhttpd - DBoxII-Project - - Copyright (C) 2001/2002 Dirk Szymanski 'Dirch' - Copyright (C) 2005 SnowHead - - $Id: lcdapi.cpp,v 1.1.2.1 2010/02/21 10:10:12 cvs Exp $ - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -// c++ -#include -#include - -#include -// tuxbox -#if HAVE_LCD -#include -#endif -#include -#include -#include - -#if HAVE_LCD -#include -#endif - -#include -#include - -// nhttpd -//#include "ylogging.h" -#include "lcdapi.h" - -#if HAVE_LCD -static char font_name[3][10]={"Micron","Micron","Pakenham"}; -#endif - -//------------------------------------------------------------------------- - -void CLCDAPI::Clear(void) -{ -#if HAVE_LCD - display.draw_fill_rect(-1, -1, 120, 64, CLCDDisplay::PIXEL_OFF); // clear lcd -#endif -} - -void CLCDAPI::Update(void) -{ -#if HAVE_LCD - display.update(); -#endif -} - -void CLCDAPI::LockDisplay(int plock) -{ - if (plock) - { - FILE *lfh=fopen("/tmp/lcd.locked","w"); - if(lfh) - { - fprintf(lfh,"lcdlock"); - fclose(lfh); - usleep(100000L); - } - } - else - { - remove("/tmp/lcd.locked"); - } -} - -void CLCDAPI::DrawLine(int x1, int y1, int x2, int y2, int col) -{ -#if HAVE_LCD - int color=(col==0)?(CLCDDisplay::PIXEL_OFF):((col==2)?(CLCDDisplay::PIXEL_INV):(CLCDDisplay::PIXEL_ON)); - display.draw_line(x1,y1,x2,y2,color); -#endif -} - -void CLCDAPI::DrawRect(int x1, int y1, int x2, int y2, int coll, int colf) -{ -#if HAVE_LCD - int colorl=(coll==0)?(CLCDDisplay::PIXEL_OFF):((coll==2)?(CLCDDisplay::PIXEL_INV):(CLCDDisplay::PIXEL_ON)); - int colorf=(colf==0)?(CLCDDisplay::PIXEL_OFF):((colf==2)?(CLCDDisplay::PIXEL_INV):(CLCDDisplay::PIXEL_ON)); - display.draw_rectangle(x1,y1,x2,y2,colorl,colorf); -#endif -} - -void CLCDAPI::DrawText(int px, int py, int psize, int pcolor, int pfont, char *pmsg) -{ -#if HAVE_LCD - int color=(pcolor==0)?(CLCDDisplay::PIXEL_OFF):((pcolor==2)?(CLCDDisplay::PIXEL_INV):(CLCDDisplay::PIXEL_ON)); - if(!(font = fontRenderer->getFont(font_name[pfont], style_name[pfont], psize))) - { - printf("[nhttpd] Kein Font gefunden.\n"); - return; - } - font->RenderString(px, py, 130, pmsg, color, 0, true); // UTF-8 -#endif -} - -bool CLCDAPI::ShowPng(char *filename) -{ -#if HAVE_LCD - return display.load_png(filename); -#endif - return 0; -} - -void CLCDAPI::ShowRaw(int xpos, int ypos, int xsize, int ysize, char *ascreen) -{ -#if HAVE_LCD - int sbyte,dbit,dxpos,dypos,wasinc=0,gotval; - char *sptr=ascreen; - raw_display_t rscreen; - - display.dump_screen(&rscreen); - gotval=sscanf(sptr,"%d",&sbyte); - for(dypos=ypos; gotval && (dypos<(ypos+ysize)); dypos++) - { - dbit=7; - for(dxpos=xpos; gotval && (dxpos<(xpos+xsize)); dxpos++) - { - wasinc=0; - if((dyposAddFont("/share/fonts/micron.ttf"); - style_name[1] = fontRenderer->AddFont("/share/fonts/micron_bold.ttf"); - style_name[2] = fontRenderer->AddFont("/share/fonts/pakenham.ttf"); - fontRenderer->InitFontCache(); -/* for(i=0; i<3; i++) - { - if(font=fontRenderer->getFont(font_name[i], style_name[i], 14)) - { - font->RenderString(10, 10, 30, "X", CLCDDisplay::PIXEL_OFF, 0, true); - } - } -*/ - -#endif -} -//------------------------------------------------------------------------- - -CLCDAPI::~CLCDAPI(void) -{ -#if HAVE_LCD - if(fontRenderer) - { - delete fontRenderer; - } -/* if(display) - { - delete display; - } -*/ -#endif -} diff --git a/src/nhttpd/tuxboxapi/dbox/lcdapi.h b/src/nhttpd/tuxboxapi/dbox/lcdapi.h deleted file mode 100644 index 9190b5822..000000000 --- a/src/nhttpd/tuxboxapi/dbox/lcdapi.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - nhttpd - DBoxII-Project - - Copyright (C) 2001/2002 Dirk Szymanski 'Dirch' - Copyright (C) 2005 SnowHead - - $Id: lcdapi.h,v 1.1.2.1 2010/02/21 10:10:12 cvs Exp $ - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ -#ifndef __nhttpd_lcdapi_h__ -#define __nhttpd_lcdapi_h__ - -// tuxbox -#if HAVE_LCD -#include -#include -#include -#endif - -class CLCDDisplay; -class LcdFontRenderClass; - -//------------------------------------------------------------------------- -class CLCDAPI -{ -#if HAVE_LCD - CLCDDisplay display; - LcdFontRenderClass *fontRenderer; - LcdFont *font; -#endif - const char *style_name[3]; -public: - CLCDAPI(); - ~CLCDAPI(void); - void LockDisplay(int lock); - void DrawText(int px, int py, int psize, int pcolor, int pfont, char *pmsg); - void DrawLine(int x1, int y1, int x2, int y2, int col); - void DrawRect(int x1, int y1, int x2, int y2, int coll, int colf); - bool ShowPng(char *filename); - void ShowRaw(int xpos, int ypos, int xsize, int ysize, char *screen); - void Update(void); - void Clear(void); -}; - -#endif /* __nhttpd_lcdapi_h__ */ diff --git a/src/nhttpd/tuxboxapi/dbox/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/dbox/neutrinoapi.cpp deleted file mode 100644 index 930830a4c..000000000 --- a/src/nhttpd/tuxboxapi/dbox/neutrinoapi.cpp +++ /dev/null @@ -1,424 +0,0 @@ -//============================================================================= -// NHTTPD -// NeutrionAPI -// -// Aggregates: NeutrinoYParser, NeutrinoControlAPI -// Defines Interfaces to:CControldClient, CSectionsdClient, CZapitClient, -// CTimerdClient,CLCDAPI -// Place for common used Neutrino-functions used by NeutrinoYParser, NeutrinoControlAPI -//============================================================================= - -// C -#include -#include - -// C++ -#include -#include -#include - -// tuxbox -#include - -#include -#include -#include -extern tallchans allchans; -extern CBouquetManager *g_bouquetManager; - -// yhttpd -#include "ylogging.h" - -// nhttpd -#include "neutrinoapi.h" -#include "lcdapi.h" -void sectionsd_getChannelEvents(CChannelEventList &eList, const bool tv_mode = true, t_channel_id *chidlist = NULL, int clen = 0); - -//============================================================================= -// No Class Helpers -//============================================================================= - -static std::map iso639; -#ifndef initialize_iso639_map -bool _initialize_iso639_map(void) -{ - std::string s, t, u, v; - std::ifstream in("/share/iso-codes/iso-639.tab"); - if (in.is_open()) - { - while (in.peek() == '#') - getline(in, s); - while (in >> s >> t >> u >> std::ws) - { - getline(in, v); - iso639[s] = v; - if (s != t) - iso639[t] = v; - } - in.close(); - return true; - } - else - return false; -} -#endif -//----------------------------------------------------------------------------- -const char * _getISO639Description(const char * const iso) -{ - std::map::const_iterator it = iso639.find(std::string(iso)); - if (it == iso639.end()) - return iso; - else - return it->second.c_str(); -} - -//============================================================================= -// Initialization of static variables -//============================================================================= -std::string CNeutrinoAPI::Dbox_Hersteller[4] = {"none", "Nokia", "Philips", "Sagem"}; -std::string CNeutrinoAPI::videooutput_names[5] = {"CVBS", "RGB with CVBS", "S-Video", "YUV with VBS", "YUV with CVBS"}; -std::string CNeutrinoAPI::videoformat_names[4] = {"automatic", "16:9", "4:3 (LB)", "4:3 (PS)"}; -std::string CNeutrinoAPI::audiotype_names[5] = {"none", "single channel","dual channel","joint stereo","stereo"}; - -//============================================================================= -// Constructor & Destructor -//============================================================================= -CNeutrinoAPI::CNeutrinoAPI() -{ - Controld = new CControldClient(); - Sectionsd = new CSectionsdClient(); - Zapit = new CZapitClient(); - Timerd = new CTimerdClient(); - - NeutrinoYParser = new CNeutrinoYParser(this); - ControlAPI = new CControlAPI(this); - LcdAPI = new CLCDAPI(); - - UpdateBouquets(); - - EventServer = new CEventServer; - EventServer->registerEvent2( NeutrinoMessages::SHUTDOWN, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::STANDBY_ON, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::STANDBY_OFF, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::STANDBY_TOGGLE, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::EVT_POPUP, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::EVT_EXTMSG, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::CHANGEMODE, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::EVT_START_PLUGIN, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::LOCK_RC, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::UNLOCK_RC, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::ESOUND_ON, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); - EventServer->registerEvent2( NeutrinoMessages::ESOUND_OFF, CEventServer::INITID_HTTPD, "/tmp/neutrino.sock"); -} -//------------------------------------------------------------------------- - -CNeutrinoAPI::~CNeutrinoAPI(void) -{ - if (LcdAPI) - delete LcdAPI; - if (NeutrinoYParser) - delete NeutrinoYParser; - if (ControlAPI) - delete ControlAPI; - if (Controld) - delete Controld; - if (Sectionsd) - delete Sectionsd; - if (Zapit) - delete Zapit; - if (Timerd) - delete Timerd; - if (EventServer) - delete EventServer; -} - -//------------------------------------------------------------------------- - -void CNeutrinoAPI::UpdateBouquets(void) -{ - BouquetList.clear(); - Zapit->getBouquets(BouquetList, true); - for (unsigned int i = 1; i <= BouquetList.size(); i++) - UpdateBouquet(i); - - UpdateChannelList(); -} - -//------------------------------------------------------------------------- -void CNeutrinoAPI::ZapTo(const char * const target) -{ - t_channel_id channel_id; - - sscanf(target, - SCANF_CHANNEL_ID_TYPE, - &channel_id); - - ZapToChannelId(channel_id); -} -//------------------------------------------------------------------------- -void CNeutrinoAPI::ZapToChannelId(t_channel_id channel_id) -{ - if (channel_id == Zapit->getCurrentServiceID()) - { - //printf("Kanal ist aktuell\n"); - return; - } - - if (Zapit->zapTo_serviceID(channel_id) != CZapitClient::ZAP_INVALID_PARAM) - Sectionsd->setServiceChanged(channel_id, false); -} -//------------------------------------------------------------------------- - -void CNeutrinoAPI::ZapToSubService(const char * const target) -{ - t_channel_id channel_id; - - sscanf(target, - SCANF_CHANNEL_ID_TYPE, - &channel_id); - - if (Zapit->zapTo_subServiceID(channel_id) != CZapitClient::ZAP_INVALID_PARAM) - Sectionsd->setServiceChanged(channel_id, false); -} -//------------------------------------------------------------------------- -t_channel_id CNeutrinoAPI::ChannelNameToChannelId(std::string search_channel_name) -{ -//FIXME depending on mode missing - //int mode = Zapit->getMode(); - t_channel_id channel_id = (t_channel_id)-1; - CStringArray channel_names = ySplitStringVector(search_channel_name, ","); - CZapitClient::BouquetChannelList *channellist = GetChannelList(CZapitClient::MODE_CURRENT); - CZapitClient::BouquetChannelList::iterator channel = channellist->begin(); - for(; channel != channellist->end();channel++) - { - std::string channel_name = channel->name; - for(unsigned int j=0;jchannel_id; - break; - } - } - } - return channel_id; -} - -//------------------------------------------------------------------------- -// Get functions -//------------------------------------------------------------------------- - -bool CNeutrinoAPI::GetStreamInfo(int bitInfo[10]) -{ - char *key, *tmpptr, buf[100]; - long value; - int pos = 0; - - memset(bitInfo, 0, sizeof(bitInfo)); - - FILE *fd = fopen("/proc/bus/bitstream", "rt"); - - if (fd == NULL) - { - dprintf("error while opening proc-bitstream\n" ); - return false; - } - - fgets(buf,35,fd);//dummy - while(!feof(fd)) - { - if(fgets(buf,35,fd)!=NULL) - { - buf[strlen(buf)-1]=0; - tmpptr=buf; - key=strsep(&tmpptr,":"); - value=strtoul(tmpptr,NULL,0); - bitInfo[pos]= value; - pos++; - } - } - bitInfo[4] = 37500; - bitInfo[6] = 3; - fclose(fd); - - return true; -} - -//------------------------------------------------------------------------- - -bool CNeutrinoAPI::GetChannelEvents(void) -{ - eList = Sectionsd->getChannelEvents(); - CChannelEventList::iterator eventIterator; - - ChannelListEvents.clear(); - - if (eList.begin() == eList.end()) - return false; - - for (eventIterator = eList.begin(); eventIterator != eList.end(); eventIterator++) - ChannelListEvents[(*eventIterator).get_channel_id()] = &(*eventIterator); - - return true; -} - -//------------------------------------------------------------------------- - -std::string CNeutrinoAPI::GetServiceName(t_channel_id channel_id) -{ - unsigned int i; - - for (i = 0; i < TVChannelList.size(); i++) - if (TVChannelList[i].channel_id == channel_id) - return TVChannelList[i].name; - for (i = 0; i < RadioChannelList.size(); i++) - if (RadioChannelList[i].channel_id == channel_id) - return RadioChannelList[i].name; - return ""; -} - -//------------------------------------------------------------------------- - -CZapitClient::BouquetChannelList *CNeutrinoAPI::GetBouquet(unsigned int BouquetNr, int Mode) -{ - int mode; - - if (Mode == CZapitClient::MODE_CURRENT) - mode = Zapit->getMode(); - else - mode = Mode; - - if (mode == CZapitClient::MODE_TV) - return &TVBouquetsList[BouquetNr]; - else - return &RadioBouquetsList[BouquetNr]; -} - -//------------------------------------------------------------------------- - -CZapitClient::BouquetChannelList *CNeutrinoAPI::GetChannelList(int Mode) -{ - int mode; - - if (Mode == CZapitClient::MODE_CURRENT) - mode = Zapit->getMode(); - else - mode = Mode; - - if (mode == CZapitClient::MODE_TV) - return &TVChannelList; - else - return &RadioChannelList; -} - -//------------------------------------------------------------------------- -void CNeutrinoAPI::UpdateBouquet(unsigned int BouquetNr) -{ - TVBouquetsList[BouquetNr].clear(); - RadioBouquetsList[BouquetNr].clear(); - Zapit->getBouquetChannels(BouquetNr - 1, TVBouquetsList[BouquetNr], CZapitClient::MODE_TV); - Zapit->getBouquetChannels(BouquetNr - 1, RadioBouquetsList[BouquetNr], CZapitClient::MODE_RADIO); -} - -//------------------------------------------------------------------------- -void CNeutrinoAPI::UpdateChannelList(void) -{ - TVChannelList.clear(); - RadioChannelList.clear(); - Zapit->getChannels(RadioChannelList, CZapitClient::MODE_RADIO); - Zapit->getChannels(TVChannelList, CZapitClient::MODE_TV); -} - -//------------------------------------------------------------------------- - -std::string CNeutrinoAPI::timerEventType2Str(CTimerd::CTimerEventTypes type) -{ - std::string result; - switch (type) { - case CTimerd::TIMER_SHUTDOWN: - result = "Shutdown"; - break; - case CTimerd::TIMER_NEXTPROGRAM: - result = "Next program"; - break; - case CTimerd::TIMER_ZAPTO: - result = "Zap to"; - break; - case CTimerd::TIMER_STANDBY: - result = "Standby"; - break; - case CTimerd::TIMER_RECORD: - result = "Record"; - break; - case CTimerd::TIMER_REMIND: - result = "Reminder"; - break; - case CTimerd::TIMER_EXEC_PLUGIN: - result = "Execute plugin"; - break; - case CTimerd::TIMER_SLEEPTIMER: - result = "Sleeptimer"; - break; - default: - result = "Unknown"; - break; - } - return result; -} - -//------------------------------------------------------------------------- - -std::string CNeutrinoAPI::timerEventRepeat2Str(CTimerd::CTimerEventRepeat rep) -{ - std::string result; - switch (rep) { - case CTimerd::TIMERREPEAT_ONCE: - result = "once"; - break; - case CTimerd::TIMERREPEAT_DAILY: - result = "daily"; - break; - case CTimerd::TIMERREPEAT_WEEKLY: - result = "weekly"; - break; - case CTimerd::TIMERREPEAT_BIWEEKLY: - result = "2-weekly"; - break; - case CTimerd::TIMERREPEAT_FOURWEEKLY: - result = "4-weekly"; - break; - case CTimerd::TIMERREPEAT_MONTHLY: - result = "monthly"; - break; - case CTimerd::TIMERREPEAT_BYEVENTDESCRIPTION: - result = "event"; - break; - case CTimerd::TIMERREPEAT_WEEKDAYS: - result = "weekdays"; - break; - default: - if (rep > CTimerd::TIMERREPEAT_WEEKDAYS) - { - if (rep & 0x0200) - result += "Mo "; - if (rep & 0x0400) - result += "Tu "; - if (rep & 0x0800) - result += "We "; - if (rep & 0x1000) - result += "Th "; - if (rep & 0x2000) - result += "Fr "; - if (rep & 0x4000) - result += "Sa "; - if (rep & 0x8000) - result += "Su "; - } - else - result = "Unknown"; - } - return result; -} - diff --git a/src/nhttpd/tuxboxapi/dbox/neutrinoapi.h b/src/nhttpd/tuxboxapi/dbox/neutrinoapi.h deleted file mode 100644 index 4c3a0cf0c..000000000 --- a/src/nhttpd/tuxboxapi/dbox/neutrinoapi.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef __nhttpd_neutrinoapi_h__ -#define __nhttpd_neutrinoapi_h__ - -// c++ -#include -#include - -// tuxbox -#include -#include -#include -#include -#include - -// nhttpd -#include "helper.h" -#include "lcdapi.h" -#include "neutrinoyparser.h" -#include "controlapi.h" -#include "lcdapi.h" - -//------------------------------------------------------------------------- -// No Class Helpers -const char * _getISO639Description(const char * const iso); -bool _initialize_iso639_map(void); - -//------------------------------------------------------------------------- -class CNeutrinoAPI -{ - // Clientlibs - CControldClient *Controld; - CSectionsdClient *Sectionsd; - CZapitClient *Zapit; - CTimerdClient *Timerd; - CLCDAPI *LcdAPI; - CEventServer *EventServer; - - // complete channellists - CZapitClient::BouquetChannelList RadioChannelList,TVChannelList; - // events of actual channel - std::map ChannelListEvents; - // List of available tv bouquets - std::map TVBouquetsList; - // List of available radio bouquets - std::map RadioBouquetsList; - // List of bouquets - CZapitClient::BouquetList BouquetList; - - //bool standby_mode; - - // some constants - static std::string Dbox_Hersteller[4]; - static std::string videooutput_names[5]; - static std::string videoformat_names[4]; - static std::string audiotype_names[5]; - - // get functions to collect data - bool GetChannelEvents(void); - bool GetStreamInfo(int bitinfo[10]); - std::string GetServiceName(t_channel_id channel_id); - CZapitClient::BouquetChannelList *GetBouquet(unsigned int BouquetNr, int Mode); - CZapitClient::BouquetChannelList *GetChannelList(int Mode); - - // support functions - void ZapTo (const char * const target); - void ZapToSubService(const char * const target); - void ZapToChannelId (t_channel_id channel_id); - t_channel_id ChannelNameToChannelId(std::string search_channel_name); - - void UpdateBouquet(unsigned int BouquetNr); - void UpdateChannelList(void); - void UpdateBouquets(void); - - std::string timerEventType2Str(CTimerd::CTimerEventTypes type); - std::string timerEventRepeat2Str(CTimerd::CTimerEventRepeat rep); - -public: - CNeutrinoAPI(); - ~CNeutrinoAPI(void); - - CChannelEventList eList; - CNeutrinoYParser *NeutrinoYParser; - CControlAPI *ControlAPI; - - friend class CNeutrinoYParser; // Backreference - friend class CNeutrinoYParserCoolstream; // Backreference - friend class CControlAPI; -}; - -#endif /*__nhttpd_neutrinoapi_h__*/ diff --git a/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp deleted file mode 100644 index 9eba2014b..000000000 --- a/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.cpp +++ /dev/null @@ -1,1068 +0,0 @@ -//============================================================================= -// NHTTPD -// Neutrino yParser Extenstion -//============================================================================= -// c++ -#include -#include -#include -#include -#include -// system -#include //ntohs -#include //ntohs -#include //ntohs -// yhttpd -#include "yhttpd.h" -#include "ytypes_globals.h" -#include "mod_yparser.h" -// tuxbox -#include //timer list -// nhttpd -#include "neutrinoyparser.h" -#include "neutrinoapi.h" - -//============================================================================= -// Constructor & Destructor & Initialization -//============================================================================= -CNeutrinoYParser::CNeutrinoYParser(CNeutrinoAPI *_NeutrinoAPI) -{ - NeutrinoAPI = _NeutrinoAPI; -} -//------------------------------------------------------------------------- -CNeutrinoYParser::~CNeutrinoYParser(void) -{ -} -//============================================================================= -// Hooks! -//============================================================================= -//----------------------------------------------------------------------------- -// HOOK: response_hook Handler -// This is the main dispatcher for this module -//----------------------------------------------------------------------------- -THandleStatus CNeutrinoYParser::Hook_SendResponse(CyhookHandler *hh) -{ - hh->status = HANDLED_NONE; - - log_level_printf(4,"Neutrinoparser Hook Start url:%s\n",hh->UrlData["url"].c_str()); - init(hh); - - CNeutrinoYParser *yP = new CNeutrinoYParser(NeutrinoAPI); // create a Session - if(hh->UrlData["fileext"] == "yhtm") // yParser for yhtm-File - yP->ParseAndSendFile(hh); - else if(hh->UrlData["path"] == "/y/") // /y/ commands - { - yP->Execute(hh); - if(hh->status == HANDLED_NOT_IMPLEMENTED) - hh->status = HANDLED_NONE; // y-calls can be implemented anywhere - } - - delete yP; - - log_level_printf(4,"Neutrinoparser Hook Ende status:%d\n",(int)hh->status); -// log_level_printf(5,"Neutrinoparser Hook Result:%s\n",hh->yresult.c_str()); - - return hh->status; -} -//----------------------------------------------------------------------------- -// HOOK: webserver_readconfig_hook Handler -// This hook ist called from ReadCong (webserver) -//----------------------------------------------------------------------------- -THandleStatus CNeutrinoYParser::Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList) -{ - ConfigList["ExtrasDocumentRoot"]= Config->getString("ExtrasDocRoot", EXTRASDOCUMENTROOT); - ConfigList["ExtrasDocumentURL"] = Config->getString("ExtrasDocURL", EXTRASDOCUMENTURL); - ConfigList["TUXBOX_LOGOS_URL"]= Config->getString("Tuxbox.LogosURL", TUXBOX_LOGOS_URL); - - if (Config->getInt32("configfile.version") < 3) - { - Config->setString("Tuxbox.LogosURL", Config->getString("ExtrasDocURL", EXTRASDOCUMENTURL) +"/logos"); - Config->setInt32("configfile.version", CONF_VERSION); - Config->saveConfig(HTTPD_CONFIGFILE); - } - - return HANDLED_CONTINUE; -} - -//============================================================================= -// y-func : Dispatching -//============================================================================= -const CNeutrinoYParser::TyFuncCall CNeutrinoYParser::yFuncCallList[]= -{ - {"mount-get-list", &CNeutrinoYParser::func_mount_get_list}, - {"mount-set-values", &CNeutrinoYParser::func_mount_set_values}, - {"get_bouquets_as_dropdown", &CNeutrinoYParser::func_get_bouquets_as_dropdown}, - {"get_bouquets_as_templatelist",&CNeutrinoYParser::func_get_bouquets_as_templatelist}, - {"get_actual_bouquet_number", &CNeutrinoYParser::func_get_actual_bouquet_number}, - {"get_channels_as_dropdown", &CNeutrinoYParser::func_get_channels_as_dropdown}, - {"get_bouquets_with_epg", &CNeutrinoYParser::func_get_bouquets_with_epg}, - {"get_actual_channel_id", &CNeutrinoYParser::func_get_actual_channel_id}, - {"get_mode", &CNeutrinoYParser::func_get_mode}, - {"get_video_pids", &CNeutrinoYParser::func_get_video_pids}, - {"get_audio_pid", &CNeutrinoYParser::func_get_radio_pid}, - {"get_audio_pids_as_dropdown", &CNeutrinoYParser::func_get_audio_pids_as_dropdown}, - {"umount_get_list", &CNeutrinoYParser::func_unmount_get_list}, - {"get_partition_list", &CNeutrinoYParser::func_get_partition_list}, - {"get_boxtype", &CNeutrinoYParser::func_get_boxtype}, - {"get_current_stream_info", &CNeutrinoYParser::func_get_current_stream_info}, - {"get_timer_list", &CNeutrinoYParser::func_get_timer_list}, - {"set_timer_form", &CNeutrinoYParser::func_set_timer_form}, - {"bouquet_editor_main", &CNeutrinoYParser::func_bouquet_editor_main}, - {"set_bouquet_edit_form", &CNeutrinoYParser::func_set_bouquet_edit_form}, - -}; -//------------------------------------------------------------------------- -// y-func : dispatching and executing -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::YWeb_cgi_func(CyhookHandler *hh, std::string ycmd) -{ - std::string func="", para="", yresult="ycgi func not found"; - bool found = false; - ySplitString(ycmd," ",func, para); - - log_level_printf(4,"NeutrinoYParser: func:(%s)\n", func.c_str()); - for(unsigned int i = 0;i < (sizeof(yFuncCallList)/sizeof(yFuncCallList[0])); i++) - if (func == yFuncCallList[i].func_name) - { - yresult = (this->*yFuncCallList[i].pfunc)(hh, para); - found = true; - break; - } - log_level_printf(8,"NeutrinoYParser: func:(%s) para:(%s) Result:(%s)\n", func.c_str(), para.c_str(), yresult.c_str() ); - if(!found) - yresult = CyParser::YWeb_cgi_func(hh, ycmd); - return yresult; -} -//============================================================================= -// y-func : Functions for Neutrino -//============================================================================= -//------------------------------------------------------------------------- -// y-func : mount_get_list -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_mount_get_list(CyhookHandler *, std::string) -{ - CConfigFile *Config = new CConfigFile(','); - std::string ysel, ytype, yip, ylocal_dir, ydir, ynr, yresult; - int yitype; - - Config->loadConfig(NEUTRINO_CONFIGFILE); - for(unsigned int i=0; i <= 7; i++) - { - ynr=itoa(i); - ysel = ((i==0) ? "checked=\"checked\"" : ""); - yitype = Config->getInt32("network_nfs_type_"+ynr,0); - ytype = ( (yitype==0) ? "NFS" :((yitype==1) ? "CIFS" : "FTPFS") ); - yip = Config->getString("network_nfs_ip_"+ynr,""); - ydir = Config->getString("network_nfs_dir_"+ynr,""); - ylocal_dir = Config->getString("network_nfs_local_dir_"+ynr,""); - if(ydir != "") - ydir="("+ydir+")"; - - yresult += string_printf("%d %s - %s %s %s
", - i,ysel.c_str(),i,ytype.c_str(),yip.c_str(),ylocal_dir.c_str(), ydir.c_str()); - } - delete Config; - return yresult; -} - -//------------------------------------------------------------------------- -// y-func : mount_set_values -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_mount_set_values(CyhookHandler *hh, std::string) -{ - CConfigFile *Config = new CConfigFile(','); - std::string ynr, yresult; - - Config->loadConfig(NEUTRINO_CONFIGFILE); - ynr = hh->ParamList["nr"]; - Config->setString("network_nfs_type_"+ynr,hh->ParamList["type"]); - Config->setString("network_nfs_ip_"+ynr,hh->ParamList["ip"]); - Config->setString("network_nfs_dir_"+ynr,hh->ParamList["dir"]); - Config->setString("network_nfs_local_dir_"+ynr,hh->ParamList["localdir"]); - Config->setString("network_nfs_mac_"+ynr,hh->ParamList["mac"]); - Config->setString("network_nfs_mount_options1_"+ynr,hh->ParamList["opt1"]); - Config->setString("network_nfs_mount_options2_"+ynr,hh->ParamList["opt2"]); - Config->setString("network_nfs_automount_"+ynr,hh->ParamList["automount"]); - Config->setString("network_nfs_username_"+ynr,hh->ParamList["username"]); - Config->setString("network_nfs_password_"+ynr,hh->ParamList["password"]); - Config->saveConfig(NEUTRINO_CONFIGFILE); - - delete Config; - return yresult; -} -//------------------------------------------------------------------------- -// y-func : get_bouquets_as_dropdown [] -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_bouquets_as_dropdown(CyhookHandler *, std::string para) -{ - std::string ynr, yresult, sel, nr_str, do_show_hidden; - unsigned int nr=1; - - ySplitString(para," ",nr_str, do_show_hidden); - if(nr_str != "") - nr = atoi(nr_str.c_str()); - for (unsigned int i = 0; i < NeutrinoAPI->BouquetList.size();i++) - { - sel=(nr==(i+1)) ? "selected=\"selected\"" : ""; - if(!NeutrinoAPI->BouquetList[i].hidden || do_show_hidden == "true") - yresult += string_printf("\n", (NeutrinoAPI->BouquetList[i].bouquet_nr) + 1, sel.c_str(), (encodeString(std::string(NeutrinoAPI->BouquetList[i].name))).c_str()); - } - return yresult; -} - -//------------------------------------------------------------------------- -// y-func : get_bouquets_as_templatelist [~] -// TODO: select actual Bouquet -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_bouquets_as_templatelist(CyhookHandler *, std::string para) -{ - std::string yresult, ytemplate, do_show_hidden; - log_level_printf(4,"func_get_bouquets_as_templatelist STARt\n"); - - ySplitString(para,"~",ytemplate, do_show_hidden); - //ytemplate += "\n"; //FIXME add newline to printf - for (unsigned int i = 0; i < NeutrinoAPI->BouquetList.size();i++) - { - if(!NeutrinoAPI->BouquetList[i].hidden || do_show_hidden == "true") - { - yresult += string_printf(ytemplate.c_str(), (NeutrinoAPI->BouquetList[i].bouquet_nr) + 1, NeutrinoAPI->BouquetList[i].name); - yresult += "\r\n"; - } - } - log_level_printf(4,"func_get_bouquets_as_templatelist END\n"); - - return yresult; -} -//------------------------------------------------------------------------- -// y-func : get_actual_bouquet_number -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_actual_bouquet_number(CyhookHandler *, std::string) -{ - int actual=0; - CZapitClient::BouquetChannelList *bouquet; - int mode = CZapitClient::MODE_CURRENT; - - for (unsigned int i = 0; i < NeutrinoAPI->BouquetList.size() && actual == 0;i++) - { - bouquet = NeutrinoAPI->GetBouquet((NeutrinoAPI->BouquetList[i].bouquet_nr) + 1, mode); - CZapitClient::BouquetChannelList::iterator channel = bouquet->begin(); - for (unsigned int j = 0; channel != bouquet->end() && actual == 0; channel++,j++) - { - if(channel->channel_id == NeutrinoAPI->Zapit->getCurrentServiceID()) - actual=i+1; - } - } - return std::string(itoa(actual)); -} - -//------------------------------------------------------------------------- -// y-func : get_channel_dropdown [ []] -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_channels_as_dropdown(CyhookHandler *, std::string para) -{ - CZapitClient::BouquetChannelList *bouquet; - CZapitClient::BouquetList blist; - std::string abouquet, achannel_id, yresult, sel, sid; - - int bnumber = 1; - int mode = CZapitClient::MODE_CURRENT; - - ySplitString(para," ",abouquet, achannel_id); - if(abouquet != "") - bnumber = atoi(abouquet.c_str()); - if(bnumber != 0) //Bouquet View - { - bouquet = NeutrinoAPI->GetBouquet(bnumber, mode); - CZapitClient::BouquetChannelList::iterator channel = bouquet->begin(); - CEPGData epg; - - for (unsigned int i = 0; channel != bouquet->end(); channel++,i++) - { - sid = string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS,channel->channel_id); - sel = (sid == achannel_id) ? "selected=\"selected\"" : ""; - NeutrinoAPI->Sectionsd->getActualEPGServiceKey(channel->channel_id, &epg); - std::string encoded_channel_name = encodeString(std::string(channel->name).substr(0,19)); - std::string encoded_title = encodeString((epg.title).substr(0,29)); - yresult += string_printf("\n", channel->channel_id, sel.c_str(), encoded_channel_name.c_str(),encoded_title.c_str()); - } - } - return yresult; -} -//------------------------------------------------------------------------- -// TODO: clean up code -// use templates? -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std::string para) -{ - int BouquetNr = 0; - std::string abnumber, tmp,yresult; - CZapitClient::BouquetChannelList *channellist; - - ySplitString(para," ",abnumber, tmp); - if(abnumber != "") - BouquetNr = atoi(abnumber.c_str()); - if (BouquetNr > 0) - channellist = NeutrinoAPI->GetBouquet(BouquetNr, CZapitClient::MODE_CURRENT); - else - channellist = NeutrinoAPI->GetChannelList(CZapitClient::MODE_CURRENT); - - NeutrinoAPI->GetChannelEvents(); - - int i = 1; - char classname; - t_channel_id current_channel = NeutrinoAPI->Zapit->getCurrentServiceID(); - int prozent; - CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo; - std::string timestr; - bool have_logos = false; - - if(hh->WebserverConfigList["TUXBOX_LOGOS_URL"] != "" ||hh->WebserverConfigList["ExtrasDocumentRoot"] == "web" || (access(hh->WebserverConfigList["ExtrasDocumentRoot"]+"/logos",R_OK)==0) ) - have_logos = true; - CZapitClient::BouquetChannelList::iterator channel = channellist->begin(); - for (; channel != channellist->end();channel++) - { - CChannelEvent *event; - event = NeutrinoAPI->ChannelListEvents[channel->channel_id]; - - classname = (i++ & 1) ? 'a' : 'b'; - if (channel->channel_id == current_channel) - classname = 'c'; - - std::string bouquetstr = (BouquetNr >= 0) ? ("&bouquet=" + itoa(BouquetNr)) : ""; - yresult += ""; - if(have_logos) - yresult += string_printf("\"%s\"/", classname, channel->channel_id, - (hh->WebserverConfigList["TUXBOX_LOGOS_URL"]).c_str(), - channel->channel_id, channel->name); - /* timer slider */ - if(event && event->duration > 0) - prozent = 100 * (time(NULL) - event->startTime) / event->duration; - else - prozent = 100; - yresult += string_printf("\n" - , classname - , (prozent / 10) * 3 - , (10 - (prozent / 10))*3 - ); - - /* channel name and buttons */ - yresult += string_printf("
\n" - "\t" - "" - "" - "" - "" - "
\n
\n%s %d. %s%s %s\n", - ((channel->channel_id == current_channel) ? "" : " "), - channel->channel_id, - channel->nr, - channel->name, - (channel->service_type == ST_NVOD_REFERENCE_SERVICE) ? " (NVOD)" : "", - channel->channel_id, - ((NeutrinoAPI->ChannelListEvents[channel->channel_id]) ? "\"Programmvorschau\"" : "")); - - if (channel->channel_id == current_channel) - yresult += string_printf("\n  \"Streaminfo\""); - - yresult += string_printf("
\n\n\n"); - - if (channel->service_type == ST_NVOD_REFERENCE_SERVICE) - { - CSectionsdClient::NVODTimesList nvod_list; - if (NeutrinoAPI->Sectionsd->getNVODTimesServiceKey(channel->channel_id, nvod_list)) - { - CZapitClient::subServiceList subServiceList; - - for (CSectionsdClient::NVODTimesList::iterator ni = nvod_list.begin(); ni != nvod_list.end(); ni++) - { - CZapitClient::commandAddSubServices cmd; - CEPGData epg; - - // Byte Sequence by ntohs - cmd.original_network_id = ntohs(ni->original_network_id); - cmd.service_id = ntohs(ni->service_id); - cmd.transport_stream_id = ntohs(ni->transport_stream_id); - - t_channel_id channel_id = CREATE_CHANNEL_ID_FROM_SERVICE_ORIGINALNETWORK_TRANSPORTSTREAM_ID(cmd.service_id, cmd.original_network_id, cmd.transport_stream_id); - - timestr = timeString(ni->zeit.startzeit); // FIXME: time is wrong (at least on little endian)! - NeutrinoAPI->Sectionsd->getActualEPGServiceKey(channel_id, &epg); // FIXME: der scheissendreck geht nit!!! - yresult += string_printf("\n ", classname); - yresult += string_printf("%s ", classname, timestr.c_str()); - yresult += string_printf("%s%04x:%04x:%04x %s", // FIXME: get name - (channel_id == current_channel) ? "" : " ", - channel_id, - bouquetstr.c_str(), - cmd.transport_stream_id, - cmd.original_network_id, - cmd.service_id, - epg.title.c_str()); - yresult += string_printf("\n"); - - subServiceList.push_back(cmd); - } - - if (!(subServiceList.empty())) - NeutrinoAPI->Zapit->setSubServices(subServiceList); - } - } - - else if ((event = NeutrinoAPI->ChannelListEvents[channel->channel_id])) - { - bool has_current_next = NeutrinoAPI->Sectionsd->getCurrentNextServiceKey(channel->channel_id, currentNextInfo); - timestr = timeString(event->startTime); - - yresult += string_printf("",classname); - yresult += string_printf("%s %s " - "(%ld von %d min, %d%%)" - , timestr.c_str() - , event->description.c_str() - , (time(NULL) - event->startTime)/60 - , event->duration / 60,prozent); - - if ((has_current_next) && (currentNextInfo.flags & CSectionsdClient::epgflags::has_next)) { - timestr = timeString(currentNextInfo.next_zeit.startzeit); - yresult += string_printf("
%s %s", timestr.c_str(), currentNextInfo.next_name.c_str()); - } - - yresult += string_printf("\n"); - } - else - yresult += string_printf("\n"); - } - return yresult; -} - -//------------------------------------------------------------------------- -// y-func : get_actual_channel_id -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_actual_channel_id(CyhookHandler *, std::string) -{ - return string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS,NeutrinoAPI->Zapit->getCurrentServiceID()); -} -//------------------------------------------------------------------------- -// y-func : get_mode (returns tv|radio|unknown) -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_mode(CyhookHandler *, std::string) -{ - std::string yresult; - int mode = NeutrinoAPI->Zapit->getMode(); - - if ( mode == CZapitClient::MODE_TV) - yresult = "tv"; - else if ( mode == CZapitClient::MODE_RADIO) - yresult = "radio"; - else - yresult = "unknown"; - return yresult; -} - -//------------------------------------------------------------------------- -// y-func : get_video_pids (para=audio channel, returns: 0x0000,0x0000,0x0000) -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_video_pids(CyhookHandler *, std::string para) -{ - CZapitClient::responseGetPIDs pids; - int apid=0,apid_no=0,apid_idx=0; - pids.PIDs.vpid=0; - - if(para != "") - apid_no = atoi(para.c_str()); - NeutrinoAPI->Zapit->getPIDS(pids); - - if( apid_no < (int)pids.APIDs.size()) - apid_idx=apid_no; - if(!pids.APIDs.empty()) - apid = pids.APIDs[apid_idx].pid; - return string_printf("0x%04x,0x%04x,0x%04x",pids.PIDs.pmtpid,pids.PIDs.vpid,apid); -} -//------------------------------------------------------------------------- -// y-func : get_radio_pids (returns: 0x0000) -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_radio_pid(CyhookHandler *, std::string) -{ - CZapitClient::responseGetPIDs pids; - int apid=0; - - NeutrinoAPI->Zapit->getPIDS(pids); - if(!pids.APIDs.empty()) - apid = pids.APIDs[0].pid; - - return string_printf("0x%04x",apid); -} - -//------------------------------------------------------------------------- -// y-func : get_audio_pids_as_dropdown (from controlapi) -// prara: [apid] option value = apid-Value. Default apid-Index -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_audio_pids_as_dropdown(CyhookHandler *, std::string para) -{ - std::string yresult; - static bool init_iso=true; - bool idx_as_id=true; - - if(para == "apid") - idx_as_id=false; - if(init_iso) - { - if(_initialize_iso639_map()) - init_iso=false; - } - bool eit_not_ok=true; - CZapitClient::responseGetPIDs pids; - - CSectionsdClient::ComponentTagList tags; - pids.PIDs.vpid=0; - NeutrinoAPI->Zapit->getPIDS(pids); - - t_channel_id current_channel = NeutrinoAPI->Zapit->getCurrentServiceID(); - CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo; - NeutrinoAPI->Sectionsd->getCurrentNextServiceKey(current_channel, currentNextInfo); - if (NeutrinoAPI->Sectionsd->getComponentTagsUniqueKey(currentNextInfo.current_uniqueKey,tags)) - { - for (unsigned int i=0; i< tags.size(); i++) - { - for (unsigned short j=0; j< pids.APIDs.size(); j++) - { - if ( pids.APIDs[j].component_tag == tags[i].componentTag ) - { - if(!tags[i].component.empty()) - { - if(!(isalnum(tags[i].component[0]))) - tags[i].component=tags[i].component.substr(1,tags[i].component.length()-1); - yresult += string_printf("\r\n",idx_as_id ? j : pids.APIDs[j].pid,encodeString(tags[i].component).c_str()); - } - else - { - if(!(init_iso)) - { - strcpy( pids.APIDs[j].desc, _getISO639Description( pids.APIDs[j].desc ) ); - } - yresult += string_printf("\r\n",idx_as_id ? j : pids.APIDs[j].pid,encodeString(std::string(pids.APIDs[j].desc)).c_str(),pids.APIDs[j].is_ac3 ? " (AC3)": " "); - } - eit_not_ok=false; - break; - } - } - } - } - if(eit_not_ok) - { - unsigned short i = 0; - for (CZapitClient::APIDList::iterator it = pids.APIDs.begin(); it!=pids.APIDs.end(); it++) - { - if(!(init_iso)) - { - strcpy( pids.APIDs[i].desc, _getISO639Description( pids.APIDs[i].desc ) ); - } - yresult += string_printf("\r\n",idx_as_id ? i : it->pid,pids.APIDs[i].desc,pids.APIDs[i].is_ac3 ? " (AC3)": " "); - i++; - } - } - - if(pids.APIDs.empty()) - yresult = "00000"; // shouldnt happen, but print at least one apid - return yresult; -} - -//------------------------------------------------------------------------- -// y-func : build umount list -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_unmount_get_list(CyhookHandler *, std::string) -{ - std::string ysel, ymount, ylocal_dir, yfstype, ynr, yresult, mounts; - - std::ifstream in; - in.open("/proc/mounts", std::ifstream::in); - int j=0; - while(in.good() && (j<8)) - { - yfstype=""; - in >> ymount >> ylocal_dir >> yfstype; - in.ignore(std::numeric_limits::max(), '\n'); - yfstype = trim(yfstype); - if( (yfstype == "nfs") << (yfstype == "ftp") || (yfstype == "lufsd") ) - { - mounts=ylocal_dir +" on "+ ymount + " ("+yfstype+")"; - ysel = ((j==0) ? "checked=\"checked\"" : ""); - yresult += string_printf("%d %.120s
", - ylocal_dir.c_str(),ysel.c_str(),j,mounts.c_str()); - j++; - } - } - return yresult; -} - -//------------------------------------------------------------------------- -// y-func : build partition list -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_partition_list(CyhookHandler *, std::string) -{ - std::string ysel, ymtd, yname, dummy, yresult; - char ytmp[200]; - - std::ifstream in; - in.open("/proc/mtd", std::ifstream::in); - int j=0; - while(in.good() && (j<8)) - { - ymtd=""; - in >> ymtd >> dummy >> dummy; //format: mtd# start end "name " - in.getline(ytmp, 200); // Rest of line is the mtd description - yname = ytmp; - if((j>0) && (ymtd != ""))// iggnore first line - { - ysel = ((j==1) ? "checked=\"checked\"" : ""); - yresult += string_printf("%d %s
", - j-1,ysel.c_str(),yname.c_str(),j-1,yname.c_str()); - } - j++; - } - return yresult; -} -//------------------------------------------------------------------------- -// y-func : get boxtypetext (Nokia, Philips, Sagem) -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_boxtype(CyhookHandler *, std::string) -{ - return NeutrinoAPI->Dbox_Hersteller[NeutrinoAPI->Controld->getBoxType()]; -} -//------------------------------------------------------------------------- -// y-func : get stream info -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_current_stream_info(CyhookHandler *hh, std::string) -{ - int bitInfo[10]; - CZapitClient::CCurrentServiceInfo serviceinfo; - - serviceinfo = NeutrinoAPI->Zapit->getCurrentServiceInfo(); - hh->ParamList["onid"] = itoh(serviceinfo.onid); - hh->ParamList["sid"] = itoh(serviceinfo.sid); - hh->ParamList["tsid"] = itoh(serviceinfo.tsid); - hh->ParamList["vpid"] = itoh(serviceinfo.vpid); - hh->ParamList["apid"] = itoh(serviceinfo.apid); - hh->ParamList["vtxtpid"] = (serviceinfo.vtxtpid != 0)?itoh(serviceinfo.vtxtpid):"nicht verfügbar"; - hh->ParamList["pmtpid"] = (serviceinfo.pmtpid != 0)?itoh(serviceinfo.pmtpid):"nicht verfügbar"; - hh->ParamList["tsfrequency"] = string_printf("%d.%d MHz", serviceinfo.tsfrequency/1000, serviceinfo.tsfrequency%1000); - hh->ParamList["polarisation"] = serviceinfo.polarisation==1?"h":"v"; - hh->ParamList["ServiceName"] = NeutrinoAPI->GetServiceName(NeutrinoAPI->Zapit->getCurrentServiceID()); - NeutrinoAPI->GetStreamInfo(bitInfo); - - hh->ParamList["VideoFormat"] = string_printf("%d x %d", bitInfo[0], bitInfo[1] ); - hh->ParamList["BitRate"] = string_printf("%d\n", bitInfo[4]*50); - - switch ( bitInfo[2] ) //format - { - case 2: hh->ParamList["AspectRatio"] = "4:3"; break; - case 3: hh->ParamList["AspectRatio"] = "16:9"; break; - case 4: hh->ParamList["AspectRatio"] = "2.21:1"; break; - default: hh->ParamList["AspectRatio"]= "unknown"; break; - } - - switch ( bitInfo[3] ) //fps - { - case 3: hh->ParamList["FPS"] = "25"; break; - case 6: hh->ParamList["FPS"] = "50"; break; - default: hh->ParamList["FPS"]= "unknown"; - } - - if (!bitInfo[7]) hh->ParamList["AudioType"]="unknown"; - else { - const char* layernames[4]={"res","III","II","I"}; - const char* sampfreqnames[4]={"44,1k","48k","32k","res"}; - const char* modenames[4]={"stereo","joint_st","dual_ch","single_ch"}; - - long header = bitInfo[7]; - - unsigned char layer = (header>>17)&3; - unsigned char sampfreq =(header>>10)&3; - unsigned char mode = (header>> 6)&3; - unsigned char copy = (header>> 3)&1; - - hh->ParamList["AudioType"] = - string_printf("%s (%s/%s) %s", modenames[mode], sampfreqnames[sampfreq], - layernames[layer], copy?"c":""); - } - return ""; -} -//------------------------------------------------------------------------- -// Template 1:classname, 2:zAlarmTime, 3: zStopTime, 4:zRep, 5:zRepCouunt -// 6:zType, 7:sAddData, 8:timer->eventID, 9:timer->eventID -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_get_timer_list(CyhookHandler *, std::string para) -{ - std::string yresult; - CTimerd::TimerList timerlist; // List of bouquets - - timerlist.clear(); - NeutrinoAPI->Timerd->getTimerList(timerlist); - sort(timerlist.begin(), timerlist.end()); - - CZapitClient::BouquetChannelList channellist_tv; - CZapitClient::BouquetChannelList channellist_radio; - channellist_tv.clear(); - channellist_radio.clear(); - - int i = 1; - char classname= 'a'; - CTimerd::TimerList::iterator timer = timerlist.begin(); - for(; timer != timerlist.end();timer++) - { - classname = (i++&1)?'a':'b'; - - // build alarm/stoptime - char zAlarmTime[25] = {0}; - struct tm *alarmTime = localtime(&(timer->alarmTime)); - strftime(zAlarmTime,20,"%d.%m. %H:%M",alarmTime); - - char zAnnounceTime[25] = {0}; - struct tm *announceTime = localtime(&(timer->announceTime)); - strftime(zAnnounceTime,20,"%d.%m. %H:%M",announceTime); - - char zStopTime[25] = {0}; - if(timer->stopTime > 0) - { - struct tm *stopTime = localtime(&(timer->stopTime)); - strftime(zStopTime,20,"%d.%m. %H:%M",stopTime); - } - // repeat - std::string zRep = NeutrinoAPI->timerEventRepeat2Str(timer->eventRepeat); - std::string zRepCount; - if (timer->eventRepeat == CTimerd::TIMERREPEAT_ONCE) - zRepCount = "-"; - else - zRepCount = (timer->repeatCount == 0) ? "∞" : string_printf("%dx",timer->repeatCount); - // timer type - std::string zType = NeutrinoAPI->timerEventType2Str(timer->eventType); - // Add Data - std::string sAddData=""; - switch(timer->eventType) - { - case CTimerd::TIMER_NEXTPROGRAM : - case CTimerd::TIMER_ZAPTO : - case CTimerd::TIMER_RECORD : - { - sAddData = ZapitTools::UTF8_to_Latin1(NeutrinoAPI->Zapit->getChannelName(timer->channel_id).c_str()); - if (sAddData.empty()) - sAddData = NeutrinoAPI->Zapit->isChannelTVChannel(timer->channel_id) ? "Unbekannter TV-Kanal" : "Unbekannter Radiokanal"; - - if( timer->apids != TIMERD_APIDS_CONF) - { - std::string separator = ""; - sAddData += '('; - if( timer->apids & TIMERD_APIDS_STD ) - { - sAddData += "STD"; - separator = "/"; - } - if( timer->apids & TIMERD_APIDS_ALT ) - { - sAddData += separator; - sAddData += "ALT"; - separator = "/"; - } - if( timer->apids & TIMERD_APIDS_AC3 ) - { - sAddData += separator; - sAddData += "AC3"; - separator = "/"; - } - sAddData += ')'; - } - if(timer->epgID!=0) - { - CSectionsdClient sdc; - CEPGData epgdata; - if (sdc.getEPGid(timer->epgID, timer->epg_starttime, &epgdata)) - sAddData+="
" + epgdata.title; - else - sAddData+=std::string("
")+timer->epgTitle; - } - else - sAddData+=std::string("
")+timer->epgTitle; - } - break; - case CTimerd::TIMER_STANDBY : - { - sAddData = "Standby: "; - if(timer->standby_on) - sAddData+= "An"; - else - sAddData+="Aus"; - } - break; - case CTimerd::TIMER_REMIND : - sAddData = std::string(timer->message).substr(0,20); - break; - case CTimerd::TIMER_EXEC_PLUGIN : - sAddData = std::string(timer->pluginName); - break; - - default:{} - } - yresult += string_printf(para.c_str(), classname, zAlarmTime, zStopTime, zRep.c_str(), zRepCount.c_str(), - zType.c_str(), sAddData.c_str(),timer->eventID,timer->eventID); - } - classname = (i++&1)?'a':'b'; - - return yresult; -} -/*------------------------------------------------------------------------------ - CTimerd::TIMER_RECORD = 5 - CTimerd::TIMER_STANDBY = 4 - CTimerd::TIMER_NEXTPROGRAM = 2 - CTimerd::TIMER_ZAPTO = 3 - CTimerd::TIMER_REMIND = 6 - CTimerd::TIMER_EXEC_PLUGIN = 8 - CTimerd::TIMERREPEAT_WEEKDAYS = 256 - CTimerd::TIMERREPEAT_ONCE = 0 - */ -// para ::= [timerid] -std::string CNeutrinoYParser::func_set_timer_form(CyhookHandler *hh, std::string para) -{ - unsigned timerId=0; - std::string cmd, stimerid; - CTimerd::responseGetTimer timer; // Timer - time_t now_t = time(NULL); - ySplitString(para, " ", cmd, stimerid); - if(cmd != "new") - { - // init timerid - if(stimerid != "") - timerId = (unsigned)atoi(stimerid.c_str()); - - NeutrinoAPI->Timerd->getTimer(timer, timerId); - std::string zType = NeutrinoAPI->timerEventType2Str(timer.eventType); - - hh->ParamList["timerId"] = itoa(timerId); - hh->ParamList["zType"] = zType; - } - // Alarm/StopTime - struct tm *alarmTime = (cmd == "new") ? localtime(&now_t) : localtime(&(timer.alarmTime)); - - hh->ParamList["alarm_mday"] = string_printf("%02d", alarmTime->tm_mday); - hh->ParamList["alarm_mon"] = string_printf("%02d", alarmTime->tm_mon +1); - hh->ParamList["alarm_year"] = string_printf("%04d", alarmTime->tm_year + 1900); - hh->ParamList["alarm_hour"] = string_printf("%02d", alarmTime->tm_hour); - hh->ParamList["alarm_min"] = string_printf("%02d", alarmTime->tm_min); - - struct tm *stopTime = (cmd == "new") ? alarmTime : ( (timer.stopTime > 0) ? localtime(&(timer.stopTime)) : NULL ); - if(stopTime != NULL) - { - hh->ParamList["stop_mday"] = string_printf("%02d", stopTime->tm_mday); - hh->ParamList["stop_mon"] = string_printf("%02d", stopTime->tm_mon +1); - hh->ParamList["stop_year"] = string_printf("%04d", stopTime->tm_year + 1900); - hh->ParamList["stop_hour"] = string_printf("%02d", stopTime->tm_hour); - hh->ParamList["stop_min"] = string_printf("%02d", stopTime->tm_min); - - // APid settings for Record - if(timer.apids == TIMERD_APIDS_CONF) - hh->ParamList["TIMERD_APIDS_CONF"] = "y"; - if(timer.apids & TIMERD_APIDS_STD) - hh->ParamList["TIMERD_APIDS_STD"] = "y"; - if(timer.apids & TIMERD_APIDS_ALT) - hh->ParamList["TIMERD_APIDS_ALT"] = "y"; - if(timer.apids & TIMERD_APIDS_AC3) - hh->ParamList["TIMERD_APIDS_AC3"] = "y"; - } - else - hh->ParamList["stop_mday"] = "0"; - // event type - std::string sel; - for(int i=1; i<=8;i++) - { - if(i!=(int)CTimerd::TIMER_NEXTPROGRAM) - { - std::string zType = NeutrinoAPI->timerEventType2Str((CTimerd::CTimerEventTypes) i); - if(cmd != "new") - sel = (i==(int)timer.eventType) ? "selected=\"selected\"" : ""; - else - sel = (i==(int)CTimerd::TIMER_RECORD) ? "selected=\"selected\"" : ""; - hh->ParamList["timertype"] += - string_printf("\n",i,sel.c_str(),zRep.c_str()); - } - } - // Repeat Weekdays - zRep = NeutrinoAPI->timerEventRepeat2Str(CTimerd::TIMERREPEAT_WEEKDAYS); - if(timer.eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS && cmd != "new") - sel = "selected=\"selected\""; - else - sel = ""; - hh->ParamList["repeat"] += - string_printf("\n",(int)CTimerd::TIMERREPEAT_WEEKDAYS, sel.c_str(), zRep.c_str()); - - // Weekdays - char weekdays[8]; - NeutrinoAPI->Timerd->setWeekdaysToStr(timer.eventRepeat, weekdays); - hh->ParamList["weekdays"]= weekdays; - - // timer repeats - if (timer.eventRepeat == CTimerd::TIMERREPEAT_ONCE) - hh->ParamList["TIMERREPEAT_ONCE"] = "y"; - hh->ParamList["timer_repeatCount"] = itoa(timer.repeatCount); - - // program row - CZapitClient::BouquetChannelList channellist; - channellist.clear(); - NeutrinoAPI->Zapit->getChannels(channellist,CZapitClient::MODE_TV); - t_channel_id current_channel = (cmd == "new") ? NeutrinoAPI->Zapit->getCurrentServiceID() : timer.channel_id; - CZapitClient::BouquetChannelList::iterator channel = channellist.begin(); - for(; channel != channellist.end();channel++) - { - sel = (channel->channel_id == current_channel) ? "selected=\"selected\"" : ""; - hh->ParamList["program_row"] += - string_printf("\n", - channel->channel_id, sel.c_str(), channel->name); - } - channellist.clear(); - NeutrinoAPI->Zapit->getChannels(channellist,CZapitClient::MODE_RADIO); - for (channel = channellist.begin(); channel != channellist.end(); channel++) - { - sel = (channel->channel_id == current_channel) ? "selected=\"selected\"" : ""; - hh->ParamList["program_row"] += - string_printf("\n", - channel->channel_id, sel.c_str(), channel->name); - } - // recordingDir - hh->ParamList["RECORD_DIR_MAXLEN"] = itoa(RECORD_DIR_MAXLEN-1); - if(cmd != "new") { - if(timer.eventType == CTimerd::TIMER_RECORD) - hh->ParamList["timer_recordingDir"] = timer.recordingDir; - } - else - { - // get Default Recordingdir - CConfigFile *Config = new CConfigFile(','); - Config->loadConfig(NEUTRINO_CONFIGFILE); - hh->ParamList["timer_recordingDir"] = Config->getString("network_nfs_recordingdir", "/mnt/filme"); - delete Config; - } - hh->ParamList["standby"] = (cmd == "new")? "0" : ((timer.standby_on)?"1":"0"); - hh->ParamList["message"] = (cmd == "new")? "" : timer.message; - hh->ParamList["pluginname"] = (cmd == "new")? "" : timer.pluginName; - - return ""; -} - -//------------------------------------------------------------------------- -// func: Bouquet Editor List -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_bouquet_editor_main(CyhookHandler *hh, std::string para) -{ - std::string yresult; - int selected = -1; - if (hh->ParamList["saved"] == "1") - hh->ParamList["have_saved"]="true"; - - if (hh->ParamList["selected"] != "") - selected = atoi(hh->ParamList["selected"].c_str()); - - // List of all bouquets - CZapitClient::BouquetList AllBouquetList; - - NeutrinoAPI->Zapit->getBouquets(AllBouquetList, true, true); // UTF-8 - CZapitClient::BouquetList::iterator bouquet = AllBouquetList.begin(); - - unsigned int bouquetSize = AllBouquetList.size(); - - for(; bouquet != AllBouquetList.end();bouquet++) - { - char classname = ((bouquet->bouquet_nr & 1) == 0) ? 'a' : 'b'; - classname = (selected == (int) bouquet->bouquet_nr + 1)?'c':classname; - - std::string akt = (selected == (int) (bouquet->bouquet_nr + 1)) ? "" : ""; - // lock/unlock - std::string lock_action = (bouquet->locked) ? "unlock" : "lock"; - std::string lock_img = (bouquet->locked) ? "lock" : "unlock"; - std::string lock_alt = (bouquet->locked) ? "entsperren" : "sperren"; - // hide/show - std::string hidden_action= (bouquet->hidden) ? "show" : "hide"; - std::string hidden_img = (bouquet->hidden) ? "hidden" : "visible"; - std::string hidden_alt = (bouquet->hidden) ? "verstecken" : "anzeigen"; - // move down - std::string down_show = (bouquet->bouquet_nr + 1 < bouquetSize) ? "visible" : "hidden"; - //move up - std::string up_show = (bouquet->bouquet_nr > 0) ? "visible" : "hidden"; - // build from template - yresult += string_printf(para.c_str(), classname, akt.c_str(), - bouquet->bouquet_nr + 1, lock_action.c_str(), lock_img.c_str(), lock_alt.c_str(), //lock - bouquet->bouquet_nr + 1, hidden_action.c_str(), hidden_img.c_str(), hidden_alt.c_str(), //hhidden - bouquet->bouquet_nr + 1, bouquet->name, bouquet->name, //link - bouquet->bouquet_nr + 1, bouquet->name, //rename - bouquet->bouquet_nr + 1, bouquet->name, //delete - down_show.c_str(), bouquet->bouquet_nr + 1, //down arrow - up_show.c_str(), bouquet->bouquet_nr + 1); //up arrow - } - return yresult; -} - -//------------------------------------------------------------------------- -// func: Bouquet Edit -//------------------------------------------------------------------------- -std::string CNeutrinoYParser::func_set_bouquet_edit_form(CyhookHandler *hh, std::string) -{ - if (!(hh->ParamList["selected"].empty())) - { - CZapitClient::BouquetChannelList BChannelList; - CZapitClient::BouquetChannelList::iterator channels; - - int selected = atoi(hh->ParamList["selected"].c_str()) - 1; - - // List channels in bouquet - NeutrinoAPI->Zapit->getBouquetChannels(selected, BChannelList, CZapitClient::MODE_CURRENT, true); // UTF-8 - for(channels = BChannelList.begin(); channels != BChannelList.end(); channels++) - { - hh->ParamList["bouquet_channels"] += - string_printf("\n", - channels->channel_id, - channels->name); - } - // List all channels - NeutrinoAPI->Zapit->getChannels(BChannelList, CZapitClient::MODE_CURRENT, CZapitClient::SORT_ALPHA, true); // UTF-8 - for(channels = BChannelList.begin(); channels != BChannelList.end(); channels++) - { - if (!NeutrinoAPI->Zapit->existsChannelInBouquet(selected, channels->channel_id)){ - hh->ParamList["all_channels"] += - string_printf("\n", - channels->channel_id, - channels->name); - } - } - return ""; - } - else - return "No Bouquet selected"; -} diff --git a/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.h b/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.h deleted file mode 100644 index dff2e6a96..000000000 --- a/src/nhttpd/tuxboxapi/dbox/neutrinoyparser.h +++ /dev/null @@ -1,70 +0,0 @@ -//============================================================================= -// NHTTPD -// Neutrino yParser Extenstion -//============================================================================= - -#ifndef __nhttpd_neutrinoyparser_h__ -#define __nhttpd_neutrinoyparser_h__ - -// c++ -#include -// yhttpd -#include "yhttpd.h" -#include "ytypes_globals.h" -#include "mod_yparser.h" - -// forward declaration -class CNeutrinoAPI; -//----------------------------------------------------------------------------- -class CNeutrinoYParser : public CyParser -{ -private: - // yParser funcs for Tuxbox - typedef std::string (CNeutrinoYParser::*TyFunc)(CyhookHandler *hh, std::string para); - typedef struct - { - const char *func_name; - TyFunc pfunc; - } TyFuncCall; - const static TyFuncCall yFuncCallList[]; - - // func TUXBOX - std::string func_mount_get_list(CyhookHandler *hh, std::string para); - std::string func_mount_set_values(CyhookHandler *hh, std::string para); - std::string func_get_bouquets_as_dropdown(CyhookHandler *hh, std::string para); - std::string func_get_bouquets_as_templatelist(CyhookHandler *hh, std::string para); - std::string func_get_actual_bouquet_number(CyhookHandler *hh, std::string para); - std::string func_get_channels_as_dropdown(CyhookHandler *hh, std::string para); - std::string func_get_actual_channel_id(CyhookHandler *hh, std::string para); - std::string func_get_bouquets_with_epg(CyhookHandler *hh, std::string para); - std::string func_get_mode(CyhookHandler *hh, std::string para); - std::string func_get_video_pids(CyhookHandler *hh, std::string para); - std::string func_get_radio_pid(CyhookHandler *hh, std::string para); - std::string func_get_audio_pids_as_dropdown(CyhookHandler *hh, std::string para); - std::string func_unmount_get_list(CyhookHandler *hh, std::string para); - std::string func_get_partition_list(CyhookHandler *hh, std::string para); - std::string func_get_boxtype(CyhookHandler *hh, std::string para); - std::string func_get_current_stream_info(CyhookHandler *hh, std::string para); - std::string func_get_timer_list(CyhookHandler *hh, std::string para); - std::string func_set_timer_form(CyhookHandler *hh, std::string para); - std::string func_bouquet_editor_main(CyhookHandler *hh, std::string para); - std::string func_set_bouquet_edit_form(CyhookHandler *hh, std::string para); - -protected: - CNeutrinoAPI *NeutrinoAPI; - -public: - // constructor & deconstructor - CNeutrinoYParser(CNeutrinoAPI *_NeutrinoAPI); - virtual ~CNeutrinoYParser(void); - - // virtual functions for BaseClass - virtual std::string YWeb_cgi_func(CyhookHandler *hh, std::string ycmd); - // virtual functions for HookHandler/Hook - virtual std::string getHookName(void) {return std::string("mod_NeutrinoYParser");} - virtual std::string getHookVersion(void) {return std::string("$Revision$");} - virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); - virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList); -}; - -#endif /*__nhttpd_neutrinoyparser_h__*/ diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/neutrinoapi.cpp similarity index 100% rename from src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp rename to src/nhttpd/tuxboxapi/neutrinoapi.cpp diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.h b/src/nhttpd/tuxboxapi/neutrinoapi.h similarity index 100% rename from src/nhttpd/tuxboxapi/coolstream/neutrinoapi.h rename to src/nhttpd/tuxboxapi/neutrinoapi.h diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp similarity index 100% rename from src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp rename to src/nhttpd/tuxboxapi/neutrinoyparser.cpp diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.h b/src/nhttpd/tuxboxapi/neutrinoyparser.h similarity index 100% rename from src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.h rename to src/nhttpd/tuxboxapi/neutrinoyparser.h