mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
Use PBD::CCurl for libardour HTTP/S requests
This commit is contained in:
parent
7b6ca334df
commit
b92fa1d0e4
5 changed files with 20 additions and 20 deletions
|
|
@ -133,7 +133,8 @@ Downloader::download ()
|
|||
* progress meter
|
||||
*/
|
||||
|
||||
curl = curl_easy_init ();
|
||||
CURL* curl = _ccurl.curl ();
|
||||
|
||||
if (!curl) {
|
||||
_status = -1;
|
||||
return;
|
||||
|
|
@ -155,7 +156,7 @@ Downloader::download ()
|
|||
_download_size = dsize;
|
||||
}
|
||||
|
||||
curl_easy_cleanup (curl);
|
||||
_ccurl.reset ();
|
||||
|
||||
if (res != CURLE_OK ) {
|
||||
error << string_compose (_("Download failed, error code %1 (%2)"), curl_easy_strerror (res), curl_error) << endmsg;
|
||||
|
|
@ -164,7 +165,7 @@ Downloader::download ()
|
|||
}
|
||||
}
|
||||
|
||||
curl = curl_easy_init ();
|
||||
CURL* curl = _ccurl.curl ();
|
||||
if (!curl) {
|
||||
_status = -1;
|
||||
return;
|
||||
|
|
@ -175,7 +176,6 @@ Downloader::download ()
|
|||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_Downloader);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
|
||||
CURLcode res = curl_easy_perform (curl);
|
||||
curl_easy_cleanup (curl);
|
||||
|
||||
if (res == CURLE_OK) {
|
||||
_status = 1;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@
|
|||
#include "pbd/gstdio_compat.h"
|
||||
#include <glibmm.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "pbd/ccurl.h"
|
||||
#include "pbd/failed_constructor.h"
|
||||
#include "pbd/file_archive.h"
|
||||
#include "pbd/file_utils.h"
|
||||
|
|
@ -60,9 +59,9 @@ static void*
|
|||
get_url (void* arg)
|
||||
{
|
||||
FileArchive::Request* r = (FileArchive::Request*) arg;
|
||||
CURL* curl;
|
||||
PBD::CCurl ccurl;
|
||||
CURL* curl = ccurl.curl ();
|
||||
|
||||
curl = curl_easy_init ();
|
||||
curl_easy_setopt (curl, CURLOPT_URL, r->url);
|
||||
curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
|
||||
|
|
@ -81,7 +80,6 @@ get_url (void* arg)
|
|||
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
curl_easy_setopt (curl, CURLOPT_WRITEDATA, (void*) &r->mp);
|
||||
curl_easy_perform (curl);
|
||||
curl_easy_cleanup (curl);
|
||||
|
||||
r->mp.lock ();
|
||||
r->mp.done = 1;
|
||||
|
|
@ -190,7 +188,8 @@ FileArchive::fetch (const std::string & url, const std::string & destdir) const
|
|||
return std::string();
|
||||
}
|
||||
|
||||
CURL* curl = curl_easy_init ();
|
||||
PBD::CCurl ccurl;
|
||||
CURL* curl = ccurl.curl ();
|
||||
|
||||
if (!curl) {
|
||||
return std::string ();
|
||||
|
|
@ -199,7 +198,6 @@ FileArchive::fetch (const std::string & url, const std::string & destdir) const
|
|||
curl_easy_setopt (curl, CURLOPT_URL, url.c_str ());
|
||||
curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
CURLcode res = curl_easy_perform (curl);
|
||||
curl_easy_cleanup (curl);
|
||||
|
||||
g_chdir (pwd.c_str());
|
||||
if (res != CURLE_OK) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <atomic>
|
||||
#include <string>
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "pbd/ccurl.h"
|
||||
|
||||
#include "pbd/libpbd_visibility.h"
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class LIBPBD_API Downloader {
|
|||
std::string destdir;
|
||||
std::string file_path;
|
||||
FILE* file;
|
||||
CURL* curl;
|
||||
CCurl _ccurl;
|
||||
bool _cancel;
|
||||
std::atomic<uint64_t> _download_size; /* read-only from requestor thread */
|
||||
std::atomic<uint64_t> _downloaded; /* read-only from requestor thread */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue