#include <iostream>
#include <glib.h>
-#include <pbd/gstdio_compat.h>
+#include "pbd/gstdio_compat.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
#include "ardour/audio_library.h"
#include "ardour/rc_configuration.h"
}
#endif
}
-
+
//------------------------------------------------------------------------
size_t Mootcher::WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
int realsize = (int)(size * nmemb);
- struct MemoryStruct *mem = (struct MemoryStruct *)data;
+ struct SfdbMemoryStruct *mem = (struct SfdbMemoryStruct *)data;
mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
// sort the results in the requested way.
switch (sort) {
- case sort_duration_desc: return "duration_desc";
+ case sort_duration_desc: return "duration_desc";
case sort_duration_asc: return "duration_asc";
case sort_created_desc: return "created_desc";
case sort_created_asc: return "created_asc";
case sort_downloads_asc: return "downloads_asc";
case sort_rating_desc: return "rating_desc";
case sort_rating_asc: return "rating_asc";
- default: return "";
+ default: return "";
}
}
//------------------------------------------------------------------------
void Mootcher::setcUrlOptions()
{
- // basic init for curl
- curl_global_init(CURL_GLOBAL_ALL);
// some servers don't like requests that are made without a user-agent field, so we provide one
curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
// setup curl error buffer
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
// Allow redirection
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
-
+
// Allow connections to time out (without using signals)
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 30);
std::string Mootcher::doRequest(std::string uri, std::string params)
{
std::string result;
- struct MemoryStruct xml_page;
+ struct SfdbMemoryStruct xml_page;
xml_page.memory = NULL;
xml_page.size = 0;
} else {
url += "api_key=" + api_key + "&format=xml";
}
-
+
curl_easy_setopt(curl, CURLOPT_URL, url.c_str() );
-
+
// perform online request
CURLcode res = curl_easy_perform(curl);
if( res != 0 ) {
if (xml_page.memory) {
result = xml_page.memory;
}
-
+
free (xml_page.memory);
xml_page.memory = NULL;
xml_page.size = 0;
params += "&f=" + std::string(ef);
free(ef);
}
-
+
if (sort)
params += "&s=" + sortMethodString(sort);
res = curl_easy_perform (curl);
fclose (theFile);
curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 1); // turn off the progress bar
-
+
if (res != CURLE_OK) {
/* it's not an error if the user pressed the stop button */
if (res != CURLE_ABORTED_BY_CALLBACK) {
fclose (testFile);
return true;
}
-
+
// else file was small, probably an error, delete it
fclose(testFile);
remove( audioFileName.c_str() );
if (!theFile) {
return false;
}
-
+
// create the download url
audioURL += "?api_key=" + api_key;
// and we want access to some private members of Mootcher.
Mootcher *thisMootcher = (Mootcher *) caller;
-
+
if (thisMootcher->cancel_download) {
return -1;
}