Changed: Don't include curl.h in headers to avoid dependencies on CURL for more files that required
--HG-- branch : develop
This commit is contained in:
parent
40dc2188f2
commit
58efd082c1
5 changed files with 57 additions and 53 deletions
|
@ -17,8 +17,6 @@
|
||||||
#ifndef CL_GROUP_HTML_H
|
#ifndef CL_GROUP_HTML_H
|
||||||
#define CL_GROUP_HTML_H
|
#define CL_GROUP_HTML_H
|
||||||
|
|
||||||
#include <curl/curl.h>
|
|
||||||
|
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
#include "nel/gui/interface_group.h"
|
#include "nel/gui/interface_group.h"
|
||||||
#include "nel/gui/group_scrolltext.h"
|
#include "nel/gui/group_scrolltext.h"
|
||||||
|
@ -27,6 +25,9 @@
|
||||||
#include "nel/gui/group_table.h"
|
#include "nel/gui/group_table.h"
|
||||||
#include "nel/gui/libwww_types.h"
|
#include "nel/gui/libwww_types.h"
|
||||||
|
|
||||||
|
// forward declaration
|
||||||
|
typedef void CURLM;
|
||||||
|
|
||||||
typedef std::map<std::string, std::string> TStyle;
|
typedef std::map<std::string, std::string> TStyle;
|
||||||
|
|
||||||
namespace NLGUI
|
namespace NLGUI
|
||||||
|
@ -856,11 +857,6 @@ namespace NLGUI
|
||||||
|
|
||||||
// HtmlType download finished
|
// HtmlType download finished
|
||||||
void htmlDownloadFinished(const std::string &content, const std::string &type, long code);
|
void htmlDownloadFinished(const std::string &content, const std::string &type, long code);
|
||||||
|
|
||||||
// cURL transfer callbacks
|
|
||||||
static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData);
|
|
||||||
static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData);
|
|
||||||
static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// adapter group that store y offset for inputs inside an html form
|
// adapter group that store y offset for inputs inside an html form
|
||||||
|
|
|
@ -20,11 +20,12 @@
|
||||||
#ifndef CL_LIB_WWW_H
|
#ifndef CL_LIB_WWW_H
|
||||||
#define CL_LIB_WWW_H
|
#define CL_LIB_WWW_H
|
||||||
|
|
||||||
#include <curl/curl.h>
|
|
||||||
|
|
||||||
#include "nel/misc/rgba.h"
|
#include "nel/misc/rgba.h"
|
||||||
#include "nel/gui/libwww_types.h"
|
#include "nel/gui/libwww_types.h"
|
||||||
|
|
||||||
|
// forward declaration to avoid curl.h inclusion everywhere
|
||||||
|
typedef void CURL;
|
||||||
|
|
||||||
namespace NLGUI
|
namespace NLGUI
|
||||||
{
|
{
|
||||||
class CCtrlBaseButton;
|
class CCtrlBaseButton;
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
#include "nel/gui/http_hsts.h"
|
#include "nel/gui/http_hsts.h"
|
||||||
#include "nel/gui/curl_certificates.h"
|
#include "nel/gui/curl_certificates.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
|
||||||
|
@ -205,6 +207,47 @@ namespace NLGUI
|
||||||
std::map<std::string, std::string> HeadersRecv;
|
std::map<std::string, std::string> HeadersRecv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// cURL transfer callbacks
|
||||||
|
// ***************************************************************************
|
||||||
|
static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData)
|
||||||
|
{
|
||||||
|
CCurlWWWData * me = static_cast<CCurlWWWData *>(pCCurlWWWData);
|
||||||
|
if (me)
|
||||||
|
{
|
||||||
|
std::string header;
|
||||||
|
header.append(buffer, size * nmemb);
|
||||||
|
me->setRecvHeader(header.substr(0, header.find_first_of("\n\r")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData)
|
||||||
|
{
|
||||||
|
CCurlWWWData * me = static_cast<CCurlWWWData *>(pCCurlWWWData);
|
||||||
|
if (me)
|
||||||
|
me->Content.append(buffer, size * nmemb);
|
||||||
|
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
||||||
|
{
|
||||||
|
CCurlWWWData * me = static_cast<CCurlWWWData *>(pCCurlWWWData);
|
||||||
|
if (me)
|
||||||
|
{
|
||||||
|
if (dltotal > 0 || dlnow > 0 || ultotal > 0 || ulnow > 0)
|
||||||
|
{
|
||||||
|
nlwarning("> dltotal %d, dlnow %d, ultotal %d, ulnow %d, url '%s'", dltotal, dlnow, ultotal, ulnow, me->Url.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return 1 to cancel download
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if domain is on TrustedDomain
|
// Check if domain is on TrustedDomain
|
||||||
bool CGroupHTML::isTrustedDomain(const string &domain)
|
bool CGroupHTML::isTrustedDomain(const string &domain)
|
||||||
{
|
{
|
||||||
|
@ -423,7 +466,7 @@ namespace NLGUI
|
||||||
download.data->sendHeaders(headers);
|
download.data->sendHeaders(headers);
|
||||||
|
|
||||||
// catch headers
|
// catch headers
|
||||||
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback);
|
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, NLGUI::curlHeaderCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, download.data);
|
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, download.data);
|
||||||
|
|
||||||
std::string userAgent = options.appName + "/" + options.appVersion;
|
std::string userAgent = options.appName + "/" + options.appVersion;
|
||||||
|
@ -5476,17 +5519,17 @@ namespace NLGUI
|
||||||
_CurlWWW->sendHeaders(headers);
|
_CurlWWW->sendHeaders(headers);
|
||||||
|
|
||||||
// catch headers for redirect
|
// catch headers for redirect
|
||||||
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback);
|
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, NLGUI::curlHeaderCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, _CurlWWW);
|
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, _CurlWWW);
|
||||||
|
|
||||||
// catch body
|
// catch body
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlDataCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NLGUI::curlDataCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, _CurlWWW);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, _CurlWWW);
|
||||||
|
|
||||||
#if LOG_DL
|
#if LOG_DL
|
||||||
// progress callback
|
// progress callback
|
||||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, curlProgressCallback);
|
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, NLGUI::curlProgressCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, _CurlWWW);
|
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, _CurlWWW);
|
||||||
#else
|
#else
|
||||||
// progress off
|
// progress off
|
||||||
|
@ -6472,46 +6515,6 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
size_t CGroupHTML::curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData)
|
|
||||||
{
|
|
||||||
CCurlWWWData * me = static_cast<CCurlWWWData *>(pCCurlWWWData);
|
|
||||||
if (me)
|
|
||||||
{
|
|
||||||
std::string header;
|
|
||||||
header.append(buffer, size * nmemb);
|
|
||||||
me->setRecvHeader(header.substr(0, header.find_first_of("\n\r")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return size * nmemb;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
size_t CGroupHTML::curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData)
|
|
||||||
{
|
|
||||||
CCurlWWWData * me = static_cast<CCurlWWWData *>(pCCurlWWWData);
|
|
||||||
if (me)
|
|
||||||
me->Content.append(buffer, size * nmemb);
|
|
||||||
|
|
||||||
return size * nmemb;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
size_t CGroupHTML::curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
|
||||||
{
|
|
||||||
CCurlWWWData * me = static_cast<CCurlWWWData *>(pCCurlWWWData);
|
|
||||||
if (me)
|
|
||||||
{
|
|
||||||
if (dltotal > 0 || dlnow > 0 || ultotal > 0 || ulnow > 0)
|
|
||||||
{
|
|
||||||
nlwarning("> dltotal %d, dlnow %d, ultotal %d, ulnow %d, url '%s'", dltotal, dlnow, ultotal, ulnow, me->Url.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return 1 to cancel download
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
std::string CGroupHTML::HTMLOListElement::getListMarkerText() const
|
std::string CGroupHTML::HTMLOListElement::getListMarkerText() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "nel/gui/libwww.h"
|
#include "nel/gui/libwww.h"
|
||||||
#include "nel/gui/group_html.h"
|
#include "nel/gui/group_html.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
|
||||||
#ifdef DEBUG_NEW
|
#ifdef DEBUG_NEW
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "../net_manager.h"
|
#include "../net_manager.h"
|
||||||
#include "../connection.h"
|
#include "../connection.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue