#include <curl/curl.h>
+#include "background.h"
#include "file.h"
#include "globals.h"
#include "curl_download.h"
return fwrite(ptr, size, nmemb, stream);
}
+static int curl_progress_func(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
+{
+ return a_background_testcancel(NULL);
+}
+
static gchar *get_cookie_file(gboolean init)
{
static gchar *cookie_file = NULL;
if (vik_verbose)
curl_easy_setopt ( curl, CURLOPT_VERBOSE, 1 );
curl_easy_setopt(curl, CURLOPT_URL, "http://maps.google.com/"); /* google.com sets "PREF" cookie */
- curl_easy_setopt ( curl, CURLOPT_FILE, out_file );
+ curl_easy_setopt ( curl, CURLOPT_WRITEDATA, out_file );
curl_easy_setopt ( curl, CURLOPT_WRITEFUNCTION, curl_write_func);
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookie_file);
res = curl_easy_perform(curl);
if (vik_verbose)
curl_easy_setopt ( curl, CURLOPT_VERBOSE, 1 );
curl_easy_setopt ( curl, CURLOPT_URL, uri );
- curl_easy_setopt ( curl, CURLOPT_FILE, f );
+ curl_easy_setopt ( curl, CURLOPT_WRITEDATA, f );
curl_easy_setopt ( curl, CURLOPT_WRITEFUNCTION, curl_write_func);
+ curl_easy_setopt ( curl, CURLOPT_NOPROGRESS, 0 );
+ curl_easy_setopt ( curl, CURLOPT_PROGRESSDATA, NULL );
+ curl_easy_setopt ( curl, CURLOPT_PROGRESSFUNCTION, curl_progress_func);
if (options != NULL) {
if(options->referer != NULL)
curl_easy_setopt ( curl, CURLOPT_REFERER, options->referer);