CTimerList: Set httpConnectTimeout for remote timer = 3 sec

This commit is contained in:
M. Liebmann
2016-10-26 14:54:38 +02:00
parent f62a3ada8b
commit 4dceb70ce1
2 changed files with 10 additions and 8 deletions

View File

@@ -278,6 +278,7 @@ CTimerList::CTimerList()
Timer = new CTimerdClient(); Timer = new CTimerdClient();
timerNew_message = ""; timerNew_message = "";
timerNew_pluginName = ""; timerNew_pluginName = "";
httpConnectTimeout = 3;
/* most probable default */ /* most probable default */
saved_dispmode = (int)CVFD::MODE_TVRADIO; saved_dispmode = (int)CVFD::MODE_TVRADIO;
@@ -369,7 +370,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
r_url += "&rs=on"; r_url += "&rs=on";
r_url += "&id=" + to_string((int)timerlist[selected].eventID); r_url += "&id=" + to_string((int)timerlist[selected].eventID);
//printf("[remotetimer] url:%s\n",r_url.c_str()); //printf("[remotetimer] url:%s\n",r_url.c_str());
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
//printf("[remotetimer] status:%s\n",r_url.c_str()); //printf("[remotetimer] status:%s\n",r_url.c_str());
} else } else
{ {
@@ -394,7 +395,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
r_url += "&aj=on"; r_url += "&aj=on";
r_url += "&rs=on"; r_url += "&rs=on";
//printf("[remotetimer] url:%s\n",r_url.c_str()); //printf("[remotetimer] url:%s\n",r_url.c_str());
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
//printf("[remotetimer] status:%s\n",r_url.c_str()); //printf("[remotetimer] status:%s\n",r_url.c_str());
if (r_url=="ok") if (r_url=="ok")
Timer->removeTimerEvent(timerlist[selected].eventID); Timer->removeTimerEvent(timerlist[selected].eventID);
@@ -430,7 +431,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
r_url += "&id=" + eventID; r_url += "&id=" + eventID;
//printf("[remotetimer] url:%s\n",r_url.c_str()); //printf("[remotetimer] url:%s\n",r_url.c_str());
if (res > 0) if (res > 0)
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
//printf("[remotetimer] status:%s\n",r_url.c_str()); //printf("[remotetimer] status:%s\n",r_url.c_str());
} }
else if (strcmp(key, "del_remotetimer") == 0) else if (strcmp(key, "del_remotetimer") == 0)
@@ -442,7 +443,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
r_url += "/control/timer?action=remove"; r_url += "/control/timer?action=remove";
r_url += "&id=" + to_string((int)timerlist[selected].eventID); r_url += "&id=" + to_string((int)timerlist[selected].eventID);
//printf("[remotetimer] url:%s\n",r_url.c_str()); //printf("[remotetimer] url:%s\n",r_url.c_str());
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
//printf("[remotetimer] status:%s\n",r_url.c_str()); //printf("[remotetimer] status:%s\n",r_url.c_str());
} }
else if (strcmp(key, "update_remotetimer") == 0) else if (strcmp(key, "update_remotetimer") == 0)
@@ -459,7 +460,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
r_url += "&aj=on"; r_url += "&aj=on";
r_url += "&rs=on"; r_url += "&rs=on";
//printf("[remotetimer] url:%s\n",r_url.c_str()); //printf("[remotetimer] url:%s\n",r_url.c_str());
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
//printf("[remotetimer] status:%s\n",r_url.c_str()); //printf("[remotetimer] status:%s\n",r_url.c_str());
} }
else if (strcmp(key, "newtimer") == 0) else if (strcmp(key, "newtimer") == 0)
@@ -672,7 +673,7 @@ bool CTimerList::remoteChanExists(t_channel_id channel_id)
r_url += timerlist[selected].remotebox_ip; r_url += timerlist[selected].remotebox_ip;
r_url += "/control/getchannel?format=json&id="; r_url += "/control/getchannel?format=json&id=";
r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id); r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id);
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
Json::Value root; Json::Value root;
Json::Reader reader; Json::Reader reader;
@@ -712,7 +713,7 @@ void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
r_url = "http://"; r_url = "http://";
r_url += *it; r_url += *it;
r_url += "/control/timer?format=json"; r_url += "/control/timer?format=json";
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
//printf("[remotetimer] timers:%s\n",r_url.c_str()); //printf("[remotetimer] timers:%s\n",r_url.c_str());
Json::Value root; Json::Value root;
@@ -1149,7 +1150,7 @@ void CTimerList::paintItem(int pos)
r_url += std::string(timer.remotebox_ip); r_url += std::string(timer.remotebox_ip);
r_url += "/control/getchannel?format=json&id="; r_url += "/control/getchannel?format=json&id=";
r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer.channel_id); r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer.channel_id);
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout);
Json::Value root; Json::Value root;
Json::Reader reader; Json::Reader reader;

View File

@@ -59,6 +59,7 @@ class CTimerList : public CMenuTarget, public CListHelpers
int liststart; int liststart;
unsigned int listmaxshow; unsigned int listmaxshow;
bool visible; bool visible;
int httpConnectTimeout;
CTimerdClient *Timer; CTimerdClient *Timer;
CTimerd::TimerList timerlist; // List of timers CTimerd::TimerList timerlist; // List of timers