mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 00:11:14 +02:00
check if channel is present (send + fetch)
This commit is contained in:
@@ -335,7 +335,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
}
|
}
|
||||||
return menu_return::RETURN_EXIT;
|
return menu_return::RETURN_EXIT;
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "send_remotetimer") == 0)
|
else if ((strcmp(key, "send_remotetimer") == 0) && remoteChanExists(timerlist[selected].channel_id))
|
||||||
{
|
{
|
||||||
CHTTPTool httpTool;
|
CHTTPTool httpTool;
|
||||||
std::string r_url;
|
std::string r_url;
|
||||||
@@ -354,7 +354,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
if (r_url=="ok")
|
if (r_url=="ok")
|
||||||
Timer->removeTimerEvent(timerlist[selected].eventID);
|
Timer->removeTimerEvent(timerlist[selected].eventID);
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "fetch_remotetimer") == 0)
|
else if ((strcmp(key, "fetch_remotetimer") == 0) && localChanExists(timerlist[selected].channel_id))
|
||||||
{
|
{
|
||||||
CHTTPTool httpTool;
|
CHTTPTool httpTool;
|
||||||
std::string r_url;
|
std::string r_url;
|
||||||
@@ -570,6 +570,41 @@ void CTimerList::updateEvents(void)
|
|||||||
y = getScreenStartY(height);
|
y = getScreenStartY(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CTimerList::remoteChanExists(t_channel_id channel_id)
|
||||||
|
{
|
||||||
|
if (g_settings.remotebox_address.empty())
|
||||||
|
return false;
|
||||||
|
CHTTPTool httpTool;
|
||||||
|
std::string r_url;
|
||||||
|
r_url = "http://";
|
||||||
|
r_url += g_settings.remotebox_address;
|
||||||
|
r_url += "/control/getchannel?format=json&id=";
|
||||||
|
r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id);
|
||||||
|
r_url = httpTool.downloadString(r_url);
|
||||||
|
|
||||||
|
Json::Value root;
|
||||||
|
Json::Reader reader;
|
||||||
|
bool parsedSuccess = reader.parse(r_url, root, false);
|
||||||
|
if (!parsedSuccess) {
|
||||||
|
printf("Failed to parse JSON\n");
|
||||||
|
printf("%s\n", reader.getFormattedErrorMessages().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
r_url = root.get("success","false").asString();
|
||||||
|
return (r_url == "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CTimerList::localChanExists(t_channel_id channel_id)
|
||||||
|
{
|
||||||
|
if (g_settings.remotebox_address.empty())
|
||||||
|
return false;
|
||||||
|
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
|
||||||
|
if (channel)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
|
void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
|
||||||
{
|
{
|
||||||
if (g_settings.remotebox_address.empty())
|
if (g_settings.remotebox_address.empty())
|
||||||
|
@@ -87,6 +87,8 @@ class CTimerList : public CMenuTarget, public CListHelpers
|
|||||||
int saved_dispmode;
|
int saved_dispmode;
|
||||||
void remoteTimerList(CTimerd::TimerList &timerlist);
|
void remoteTimerList(CTimerd::TimerList &timerlist);
|
||||||
void enterRemoteBox();
|
void enterRemoteBox();
|
||||||
|
bool remoteChanExists(t_channel_id channel_id);
|
||||||
|
bool localChanExists(t_channel_id channel_id);
|
||||||
int rem_pre,rem_post;
|
int rem_pre,rem_post;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user