mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-02 10:21:10 +02:00
adding remote timer (experimental)
switch record timers to remote box or back with "play"-key
This commit is contained in:
@@ -41,6 +41,14 @@ void CHTTPTool::setStatusViewer( CProgressWindow* statusview )
|
||||
statusViewer = statusview;
|
||||
}
|
||||
|
||||
size_t CHTTPTool::CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
if (size * nmemb > 0) {
|
||||
std::string* pStr = (std::string*) data;
|
||||
pStr->append((char*) ptr, nmemb);
|
||||
}
|
||||
return size*nmemb;
|
||||
}
|
||||
|
||||
int CHTTPTool::show_progress( void *clientp, double dltotal, double dlnow, double /*ultotal*/, double /*ulnow*/ )
|
||||
{
|
||||
@@ -127,3 +135,62 @@ printf("download code %d\n", res);
|
||||
|
||||
return res==CURLE_OK;
|
||||
}
|
||||
|
||||
std::string CHTTPTool::downloadString(const std::string & URL, int globalProgressEnd)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
std::string retString = "";
|
||||
#ifdef DEBUG
|
||||
printf("url is %s\n", URL.c_str());
|
||||
#endif
|
||||
res = (CURLcode) 1;
|
||||
curl = curl_easy_init();
|
||||
if(curl)
|
||||
{
|
||||
iGlobalProgressEnd = globalProgressEnd;
|
||||
if(statusViewer)
|
||||
{
|
||||
iGlobalProgressBegin = statusViewer->getGlobalStatus();
|
||||
}
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL.c_str() );
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &CHTTPTool::CurlWriteToString);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&retString);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, show_progress);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1800);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
#ifdef DEBUG
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
#endif
|
||||
|
||||
if (!g_settings.softupdate_proxyserver.empty()) {//use proxyserver
|
||||
#ifdef DEBUG
|
||||
printf("use proxyserver : %s\n", g_settings.softupdate_proxyserver.c_str());
|
||||
#endif
|
||||
curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str());
|
||||
|
||||
if (!g_settings.softupdate_proxyusername.empty()) {//use auth
|
||||
//printf("use proxyauth\n");
|
||||
std::string tmp = g_settings.softupdate_proxyusername;
|
||||
tmp += ":";
|
||||
tmp += g_settings.softupdate_proxypassword;
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp.c_str());
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("going to download\n");
|
||||
#endif
|
||||
res = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("download code %d\n", res);
|
||||
#endif
|
||||
return (res==CURLE_OK) ? retString : "";
|
||||
}
|
||||
|
@@ -46,12 +46,14 @@ class CHTTPTool
|
||||
|
||||
CProgressWindow* statusViewer;
|
||||
static int show_progress( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
static size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data);
|
||||
|
||||
public:
|
||||
CHTTPTool();
|
||||
void setStatusViewer( CProgressWindow* statusview );
|
||||
|
||||
bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1 );
|
||||
std::string downloadString(const std::string & URL, int globalProgressEnd=-1 );
|
||||
|
||||
};
|
||||
|
||||
|
@@ -2382,6 +2382,7 @@ typedef enum
|
||||
LOCALE_TIMERLIST_TYPE_NEXTPROGRAM,
|
||||
LOCALE_TIMERLIST_TYPE_RECORD,
|
||||
LOCALE_TIMERLIST_TYPE_REMIND,
|
||||
LOCALE_TIMERLIST_TYPE_REMOTEBOX,
|
||||
LOCALE_TIMERLIST_TYPE_SHUTDOWN,
|
||||
LOCALE_TIMERLIST_TYPE_SLEEPTIMER,
|
||||
LOCALE_TIMERLIST_TYPE_STANDBY,
|
||||
|
@@ -2382,6 +2382,7 @@ const char * locale_real_names[] =
|
||||
"timerlist.type.nextprogram",
|
||||
"timerlist.type.record",
|
||||
"timerlist.type.remind",
|
||||
"timerlist.type.remotebox",
|
||||
"timerlist.type.shutdown",
|
||||
"timerlist.type.sleeptimer",
|
||||
"timerlist.type.standby",
|
||||
|
@@ -450,6 +450,7 @@ struct SNeutrinoSettings
|
||||
int recording_slow_warning;
|
||||
int recording_startstop_msg;
|
||||
int shutdown_timer_record_type;
|
||||
std::string remotebox_address;
|
||||
std::string recording_filename_template;
|
||||
int recording_already_found_check;
|
||||
|
||||
|
Reference in New Issue
Block a user