mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 15:02:56 +02:00
fix for newer libcurl
This commit is contained in:
@@ -98,7 +98,11 @@ int CLuaInstCurl::CurlProgressFunc(void *p, curl_off_t dltotal, curl_off_t dlnow
|
||||
|
||||
double dlSpeed;
|
||||
long responseCode = 0;
|
||||
#if CURL_AT_LEAST_VERSION( 7,55,0 )
|
||||
curl_easy_getinfo(_pgd->curl, CURLINFO_SPEED_DOWNLOAD_T, &dlSpeed);
|
||||
#else
|
||||
curl_easy_getinfo(_pgd->curl, CURLINFO_SPEED_DOWNLOAD, &dlSpeed);
|
||||
#endif
|
||||
curl_easy_getinfo(_pgd->curl, CURLINFO_RESPONSE_CODE, &responseCode);
|
||||
|
||||
uint32_t MUL = 0x7FFF;
|
||||
@@ -124,7 +128,7 @@ int CLuaInstCurl::CurlProgressFunc(void *p, curl_off_t dltotal, curl_off_t dlnow
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
#if !CURL_AT_LEAST_VERSION( 7,32,0 )
|
||||
int CLuaInstCurl::CurlProgressFunc_old(void *p, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
{
|
||||
return CurlProgressFunc(p, (curl_off_t)dltotal, (curl_off_t)dlnow, (curl_off_t)ultotal, (curl_off_t)ulnow);
|
||||
@@ -324,7 +328,7 @@ Example:
|
||||
if (!silent) {
|
||||
pgd.curl = curl_handle;
|
||||
pgd.last_dlnow = -1;
|
||||
#if LIBCURL_VERSION_NUM >= 0x072000
|
||||
#if CURL_AT_LEAST_VERSION( 7,32,0 )
|
||||
curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, CLuaInstCurl::CurlProgressFunc);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, &pgd);
|
||||
#else
|
||||
@@ -349,7 +353,11 @@ Example:
|
||||
if (!silent) {
|
||||
double dsize, dtime;
|
||||
char *dredirect=NULL, *deffektive=NULL;
|
||||
#if CURL_AT_LEAST_VERSION( 7,55,0 )
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD_T, &dsize);
|
||||
#else
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD, &dsize);
|
||||
#endif
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME, &dtime);
|
||||
CURLcode res1 = curl_easy_getinfo(curl_handle, CURLINFO_EFFECTIVE_URL, &deffektive);
|
||||
CURLcode res2 = curl_easy_getinfo(curl_handle, CURLINFO_REDIRECT_URL, &dredirect);
|
||||
|
@@ -53,7 +53,7 @@ class CLuaInstCurl
|
||||
static CLuaCurl *CurlCheckData(lua_State *L, int n);
|
||||
static int CurlNew(lua_State *L);
|
||||
static size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data);
|
||||
#if LIBCURL_VERSION_NUM < 0x072000
|
||||
#if !CURL_AT_LEAST_VERSION( 7,32,0 )
|
||||
static int CurlProgressFunc_old(void *p, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
#endif
|
||||
static int CurlProgressFunc(void *p, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
|
||||
|
@@ -1866,7 +1866,11 @@ bool downloadUrl(std::string url, std::string file, std::string userAgent, unsig
|
||||
CURLcode httpres = curl_easy_perform(curl_handle);
|
||||
|
||||
double dsize;
|
||||
#if CURL_AT_LEAST_VERSION( 7,55,0 )
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD_T, &dsize);
|
||||
#else
|
||||
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD, &dsize);
|
||||
#endif
|
||||
curl_easy_cleanup(curl_handle);
|
||||
fclose(fp);
|
||||
|
||||
|
@@ -51,7 +51,7 @@ size_t CHTTPTool::CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *
|
||||
return size*nmemb;
|
||||
}
|
||||
|
||||
int CHTTPTool::show_progress( void *clientp, double dltotal, double dlnow, double /*ultotal*/, double /*ulnow*/ )
|
||||
int CHTTPTool::show_progress(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t /*ultotal*/, curl_off_t /*ulnow*/)
|
||||
{
|
||||
CHTTPTool* hTool = ((CHTTPTool*)clientp);
|
||||
if(hTool->statusViewer)
|
||||
@@ -66,6 +66,13 @@ int CHTTPTool::show_progress( void *clientp, double dltotal, double dlnow, doubl
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#if !CURL_AT_LEAST_VERSION( 7,32,0 )
|
||||
int CHTTPTool::show_progress_old(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
{
|
||||
return show_progress(clientp, (curl_off_t)dltotal, (curl_off_t)dlnow, (curl_off_t)ultotal , (curl_off_t)ulnow);
|
||||
}
|
||||
#endif
|
||||
|
||||
//#define DEBUG
|
||||
bool CHTTPTool::downloadFile(const std::string & URL, const char * const downloadTarget, int globalProgressEnd, int connecttimeout/*=10000*/, int timeout/*=1800*/)
|
||||
{
|
||||
@@ -94,7 +101,11 @@ printf("url is %s\n", URL.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL.c_str() );
|
||||
curl_easy_setopt(curl, CURLOPT_FILE, headerfile);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, show_progress);
|
||||
#if CURL_AT_LEAST_VERSION( 7,32,0 )
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, show_progress);
|
||||
#else
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, show_progress_old);
|
||||
#endif
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str());
|
||||
@@ -159,7 +170,11 @@ printf("url is %s\n", URL.c_str());
|
||||
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);
|
||||
#if CURL_AT_LEAST_VERSION( 7,32,0 )
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, show_progress);
|
||||
#else
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, show_progress_old);
|
||||
#endif
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str());
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#define __httptool__
|
||||
|
||||
#include <gui/widget/progresswindow.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -45,7 +46,10 @@ class CHTTPTool
|
||||
int iGlobalProgressBegin;
|
||||
|
||||
CProgressWindow* statusViewer;
|
||||
static int show_progress( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
#if !CURL_AT_LEAST_VERSION( 7,32,0 )
|
||||
static int show_progress_old(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
#endif
|
||||
static int show_progress(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
|
||||
static size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data);
|
||||
|
||||
public:
|
||||
|
Reference in New Issue
Block a user