Make Litehtml's curl write function a regular function instead of a static member...
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 29 Jan 2019 22:52:36 +0000 (23:52 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 12 Feb 2019 18:38:10 +0000 (19:38 +0100)
src/plugins/litehtml_viewer/http.cpp
src/plugins/litehtml_viewer/http.h

index 12e8636..c6260b4 100644 (file)
@@ -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) {
index d0ae4c8..0e36212 100644 (file)
@@ -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();
 };