commit c1e6a8576a79425cd8ab10aaa8e9336c12f3f2f8
parent dd14edcc4d78952eed3daa5ce60e59fb44020b50
Author: Andrej Kacian <ticho@claws-mail.org>
Date: Tue, 29 Jan 2019 23:52:36 +0100
Make Litehtml's curl write function a regular function instead of a static member function of the http class
Diffstat:
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/src/plugins/litehtml_viewer/http.cpp b/src/plugins/litehtml_viewer/http.cpp
@@ -12,26 +12,7 @@ struct Data {
size_t size;
};
-http::http()
-{
- curl = curl_easy_init();
- curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, HTTP_GET_TIMEOUT);
- curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
- curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
- curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
- curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http::curl_write_data);
- stream = NULL;
-}
-
-http::~http()
-{
- curl_easy_cleanup(curl);
- destroy_giostream();
-}
-
-size_t http::curl_write_data(char* ptr, size_t size, size_t nmemb, void* data_ptr) {
+static size_t write_data(char* ptr, size_t size, size_t nmemb, void* data_ptr) {
struct Data* data = (struct Data *) data_ptr;
size_t realsize = size * nmemb;
@@ -50,6 +31,25 @@ size_t http::curl_write_data(char* ptr, size_t size, size_t nmemb, void* data_pt
return realsize;
}
+http::http()
+{
+ curl = curl_easy_init();
+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, HTTP_GET_TIMEOUT);
+ curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
+ stream = NULL;
+}
+
+http::~http()
+{
+ curl_easy_cleanup(curl);
+ destroy_giostream();
+}
+
void http::destroy_giostream() {
debug_print("destroy_giostream called.\n");
if (stream) {
diff --git a/src/plugins/litehtml_viewer/http.h b/src/plugins/litehtml_viewer/http.h
@@ -20,7 +20,6 @@ public:
GInputStream *load_url(const gchar *url, GError **error);
private:
- static size_t curl_write_data(char* ptr, size_t size, size_t nmemb, void* data_ptr);
void destroy_giostream();
};