mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
- controlapi: add /getchannelid function to get full id too
This commit is contained in:
@@ -171,7 +171,8 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]=
|
|||||||
{"epg", &CControlAPI::EpgCGI, ""},
|
{"epg", &CControlAPI::EpgCGI, ""},
|
||||||
{"zapto", &CControlAPI::ZaptoCGI, "text/plain"},
|
{"zapto", &CControlAPI::ZaptoCGI, "text/plain"},
|
||||||
{"signal", &CControlAPI::SignalInfoCGI, "text/plain"},
|
{"signal", &CControlAPI::SignalInfoCGI, "text/plain"},
|
||||||
{"getonidsid", &CControlAPI::GetChannel_IDCGI, "text/plain"},
|
{"getonidsid", &CControlAPI::GetChannelIDCGI, "text/plain"},
|
||||||
|
{"getchannelid", &CControlAPI::GetChannelIDCGI, ""},
|
||||||
{"currenttpchannels", &CControlAPI::GetTPChannel_IDCGI, "text/plain"},
|
{"currenttpchannels", &CControlAPI::GetTPChannel_IDCGI, "text/plain"},
|
||||||
// boxcontrol - system
|
// boxcontrol - system
|
||||||
{"standby", &CControlAPI::StandbyCGI, "text/plain"},
|
{"standby", &CControlAPI::StandbyCGI, "text/plain"},
|
||||||
@@ -238,28 +239,29 @@ void CControlAPI::Execute(CyhookHandler *hh)
|
|||||||
for(unsigned int i = 0; i < filename.length(); i++)
|
for(unsigned int i = 0; i < filename.length(); i++)
|
||||||
filename[i] = tolower(filename[i]);
|
filename[i] = tolower(filename[i]);
|
||||||
|
|
||||||
|
func_req = filename;
|
||||||
|
|
||||||
// debugging informations
|
// debugging informations
|
||||||
if(CLogging::getInstance()->getDebug())
|
if(CLogging::getInstance()->getDebug())
|
||||||
{
|
{
|
||||||
dprintf("Execute CGI : %s\n",filename.c_str());
|
dprintf("Execute CGI : %s\n", func_req.c_str());
|
||||||
for(CStringList::iterator it = hh->ParamList.begin() ;
|
for(CStringList::iterator it = hh->ParamList.begin(); it != hh->ParamList.end(); ++it)
|
||||||
it != hh->ParamList.end() ; ++it)
|
dprintf(" Parameter %s : %s\n", it->first.c_str(), it->second.c_str());
|
||||||
dprintf(" Parameter %s : %s\n",it->first.c_str(), it->second.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get function index
|
// get function index
|
||||||
for(unsigned int i = 0; i < (sizeof(yCgiCallList)/sizeof(yCgiCallList[0])); i++)
|
for(unsigned int i = 0; i < (sizeof(yCgiCallList)/sizeof(yCgiCallList[0])); i++)
|
||||||
if (filename == yCgiCallList[i].func_name)
|
if (func_req == yCgiCallList[i].func_name)
|
||||||
{
|
{
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index == -1) // function not found
|
if(index == -1) // function not found
|
||||||
{
|
{
|
||||||
hh->SetError(HTTP_NOT_IMPLEMENTED, HANDLED_NOT_IMPLEMENTED);
|
hh->SetError(HTTP_NOT_IMPLEMENTED, HANDLED_NOT_IMPLEMENTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send header
|
// send header
|
||||||
else if(std::string(yCgiCallList[index].mime_type).empty()) // decide in function
|
else if(std::string(yCgiCallList[index].mime_type).empty()) // decide in function
|
||||||
;
|
;
|
||||||
@@ -270,6 +272,7 @@ void CControlAPI::Execute(CyhookHandler *hh)
|
|||||||
hh->SetHeader(HTTP_OK, "text/html; charset=UTF-8");
|
hh->SetHeader(HTTP_OK, "text/html; charset=UTF-8");
|
||||||
else
|
else
|
||||||
hh->SetHeader(HTTP_OK, yCgiCallList[index].mime_type);
|
hh->SetHeader(HTTP_OK, yCgiCallList[index].mime_type);
|
||||||
|
|
||||||
// response
|
// response
|
||||||
hh->status = HANDLED_READY;
|
hh->status = HANDLED_READY;
|
||||||
if (hh->Method == M_HEAD) // HEAD or function call
|
if (hh->Method == M_HEAD) // HEAD or function call
|
||||||
@@ -610,13 +613,24 @@ void CControlAPI::GetUBouquetsxmlCGI(CyhookHandler *hh)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// get actual channel_id
|
// get actual channel_id
|
||||||
void CControlAPI::GetChannel_IDCGI(CyhookHandler *hh)
|
void CControlAPI::GetChannelIDCGI(CyhookHandler *hh)
|
||||||
{
|
{
|
||||||
CZapitClient::CCurrentServiceInfo current_pids = NeutrinoAPI->Zapit->getCurrentServiceInfo();
|
t_channel_id channel_id = CZapit::getInstance()->GetCurrentChannelID();
|
||||||
hh->printf("%x%04x%04x\n",current_pids.tsid, current_pids.onid, current_pids.sid);
|
if (func_req == "getonidsid") //what a terrible name!
|
||||||
|
{
|
||||||
|
hh->WriteLn(string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id & 0xFFFFFFFFFFFFULL));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hh->outStart();
|
||||||
|
std::string result = "";
|
||||||
|
result = hh->outPair("id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id), true);
|
||||||
|
result += hh->outPair("short_id", string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id & 0xFFFFFFFFFFFFULL), false);
|
||||||
|
result = hh->outObject("id", result);
|
||||||
|
hh->SendResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get actual channel_id
|
//-----------------------------------------------------------------------------
|
||||||
void CControlAPI::GetTPChannel_IDCGI(CyhookHandler *hh)
|
void CControlAPI::GetTPChannel_IDCGI(CyhookHandler *hh)
|
||||||
{
|
{
|
||||||
SendChannelList(hh, true);
|
SendChannelList(hh, true);
|
||||||
|
@@ -19,6 +19,7 @@ class CControlAPI : public Cyhook
|
|||||||
private:
|
private:
|
||||||
// Dispatcher Array
|
// Dispatcher Array
|
||||||
typedef void (CControlAPI::*TyFunc)(CyhookHandler *hh);
|
typedef void (CControlAPI::*TyFunc)(CyhookHandler *hh);
|
||||||
|
std::string func_req;
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *func_name;
|
const char *func_name;
|
||||||
@@ -83,7 +84,7 @@ private:
|
|||||||
void GetServicesxmlCGI(CyhookHandler *hh);
|
void GetServicesxmlCGI(CyhookHandler *hh);
|
||||||
void GetBouquetsxmlCGI(CyhookHandler *hh);
|
void GetBouquetsxmlCGI(CyhookHandler *hh);
|
||||||
void GetUBouquetsxmlCGI(CyhookHandler *hh);
|
void GetUBouquetsxmlCGI(CyhookHandler *hh);
|
||||||
void GetChannel_IDCGI(CyhookHandler *hh);
|
void GetChannelIDCGI(CyhookHandler *hh);
|
||||||
void GetTPChannel_IDCGI(CyhookHandler *hh);
|
void GetTPChannel_IDCGI(CyhookHandler *hh);
|
||||||
void MessageCGI(CyhookHandler *hh);
|
void MessageCGI(CyhookHandler *hh);
|
||||||
void InfoCGI(CyhookHandler *hh);
|
void InfoCGI(CyhookHandler *hh);
|
||||||
|
Reference in New Issue
Block a user