//------------------------------------------------------------------------
size_t Mootcher::WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
//------------------------------------------------------------------------
size_t Mootcher::WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
- register int realsize = (int)(size * nmemb);
- struct MemoryStruct *mem = (struct MemoryStruct *)data;
+ int realsize = (int)(size * nmemb);
+ struct SfdbMemoryStruct *mem = (struct SfdbMemoryStruct *)data;
case sort_duration_asc: return "duration_asc";
case sort_created_desc: return "created_desc";
case sort_created_asc: return "created_asc";
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";
case sort_downloads_asc: return "downloads_asc";
case sort_rating_desc: return "rating_desc";
case sort_rating_asc: return "rating_asc";
}
}
//------------------------------------------------------------------------
void Mootcher::setcUrlOptions()
{
}
}
//------------------------------------------------------------------------
void Mootcher::setcUrlOptions()
{
// 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);
// 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);
// Allow connections to time out (without using signals)
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 30);
res = curl_easy_perform (curl);
fclose (theFile);
curl_easy_setopt (curl, CURLOPT_NOPROGRESS, 1); // turn off the progress bar
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) {
error << string_compose (_("curl error %1 (%2)"), res, curl_easy_strerror(res)) << endmsg;
}
if (res != CURLE_OK) {
/* it's not an error if the user pressed the stop button */
if (res != CURLE_ABORTED_BY_CALLBACK) {
error << string_compose (_("curl error %1 (%2)"), res, curl_easy_strerror(res)) << endmsg;
}
} else {
rename ( (audioFileName+".part").c_str(), audioFileName.c_str() );
// now download the tags &c.
} else {
rename ( (audioFileName+".part").c_str(), audioFileName.c_str() );
// now download the tags &c.
sfb->refresh_display(ID, audioFileName);
delete this; // this should be OK to do as long as Progress and Finished signals are always received in the order in which they are emitted
}
static void *
sfb->refresh_display(ID, audioFileName);
delete this; // this should be OK to do as long as Progress and Finished signals are always received in the order in which they are emitted
}
static void *
// check to see if audio file already exists
FILE *testFile = g_fopen(audioFileName.c_str(), "r");
// check to see if audio file already exists
FILE *testFile = g_fopen(audioFileName.c_str(), "r");
fseek (testFile , 0 , SEEK_END);
if (ftell (testFile) > 256) {
fclose (testFile);
return true;
}
fseek (testFile , 0 , SEEK_END);
if (ftell (testFile) > 256) {
fclose (testFile);
return true;
}
Mootcher::progress_callback(void *caller, double dltotal, double dlnow, double /*ultotal*/, double /*ulnow*/)
{
// It may seem curious to pass a pointer to an instance of an object to a static
Mootcher::progress_callback(void *caller, double dltotal, double dlnow, double /*ultotal*/, double /*ulnow*/)
{
// It may seem curious to pass a pointer to an instance of an object to a static
// and we want access to some private members of Mootcher.
Mootcher *thisMootcher = (Mootcher *) caller;
// and we want access to some private members of Mootcher.
Mootcher *thisMootcher = (Mootcher *) caller;