2008-04-11 10:06:50 -04:00
|
|
|
/*sfdb_freesound_mootcher.h****************************************************************************
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
Adapted for Ardour by Ben Loftis, March 2008
|
2011-11-14 17:04:14 -05:00
|
|
|
Updated to new Freesound API by Colin Fletcher, November 2011
|
2008-04-11 10:06:50 -04:00
|
|
|
|
|
|
|
Mootcher Online Access to thefreesoundproject website
|
|
|
|
http://freesound.iua.upf.edu/
|
|
|
|
|
|
|
|
GPL 2005 Jorn Lemon
|
|
|
|
mail for questions/remarks: mootcher@twistedlemon.nl
|
|
|
|
or go to the freesound website forum
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <vector>
|
2011-11-14 17:04:14 -05:00
|
|
|
#include <gtkmm/progressbar.h>
|
2008-04-11 10:06:50 -04:00
|
|
|
//#include <ctime>
|
|
|
|
|
2012-01-18 13:43:43 -05:00
|
|
|
#include "sfdb_ui.h"
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
#include "curl/curl.h"
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
//--- struct to store XML file
|
2008-04-11 10:06:50 -04:00
|
|
|
struct MemoryStruct {
|
|
|
|
char *memory;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
2011-11-14 17:04:14 -05:00
|
|
|
enum sortMethod {
|
|
|
|
sort_none, // no sort
|
|
|
|
sort_duration_desc, // Sort by the duration of the sounds, longest sounds first.
|
|
|
|
sort_duration_asc, // Same as above, but shortest sounds first.
|
|
|
|
sort_created_desc, // Sort by the date of when the sound was added. newest sounds first.
|
|
|
|
sort_created_asc, // Same as above, but oldest sounds first.
|
|
|
|
sort_downloads_desc, // Sort by the number of downloads, most downloaded sounds first.
|
|
|
|
sort_downloads_asc, // Same as above, but least downloaded sounds first.
|
|
|
|
sort_rating_desc, // Sort by the average rating given to the sounds, highest rated first.
|
|
|
|
sort_rating_asc // Same as above, but lowest rated sounds first.
|
2008-04-11 10:06:50 -04:00
|
|
|
};
|
|
|
|
|
2011-11-14 17:04:14 -05:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
class Mootcher
|
|
|
|
{
|
|
|
|
public:
|
2012-03-09 17:02:48 -05:00
|
|
|
Mootcher();
|
2008-04-11 10:06:50 -04:00
|
|
|
~Mootcher();
|
|
|
|
|
2012-01-18 13:43:43 -05:00
|
|
|
std::string getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, SoundFileBrowser *caller);
|
2011-11-14 17:04:14 -05:00
|
|
|
std::string searchText(std::string query, int page, std::string filter, enum sortMethod sort);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
private:
|
|
|
|
|
2011-12-27 09:36:14 -05:00
|
|
|
void changeWorkingDir(const char *saveLocation);
|
|
|
|
void ensureWorkingDir();
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2011-11-14 17:04:14 -05:00
|
|
|
std::string doRequest(std::string uri, std::string params);
|
2008-04-11 10:06:50 -04:00
|
|
|
void setcUrlOptions();
|
|
|
|
|
2011-11-14 17:04:14 -05:00
|
|
|
static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
|
|
|
|
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
|
|
|
std::string sortMethodString(enum sortMethod sort);
|
|
|
|
std::string getSoundResourceFile(std::string ID);
|
2008-04-11 10:06:50 -04:00
|
|
|
|
|
|
|
CURL *curl;
|
|
|
|
char errorBuffer[CURL_ERROR_SIZE]; // storage for cUrl error message
|
|
|
|
|
|
|
|
std::string basePath;
|
|
|
|
std::string xmlLocation;
|
|
|
|
};
|
2011-11-14 17:04:14 -05:00
|
|
|
|