summaryrefslogtreecommitdiff
path: root/gtk2_ardour/sfdb_freesound_mootcher.h
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-11-14 22:04:14 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-11-14 22:04:14 +0000
commit1d984b7985ad6f717fe7de206a6189fbf019b9eb (patch)
treedb0df9ec5aa3d6a651e4a374831307d7752e9bf9 /gtk2_ardour/sfdb_freesound_mootcher.h
parent8171a144e05d7e1a52023bd08717f025d54fe016 (diff)
the return of basic FreeSound mootcher functionality, c/o colinf. lots of bugs and workflow issues to still resolve, but good to play with. remember that ardour can't play mp3's
git-svn-id: svn://localhost/ardour2/branches/3.0@10596 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/sfdb_freesound_mootcher.h')
-rw-r--r--gtk2_ardour/sfdb_freesound_mootcher.h46
1 files changed, 21 insertions, 25 deletions
diff --git a/gtk2_ardour/sfdb_freesound_mootcher.h b/gtk2_ardour/sfdb_freesound_mootcher.h
index 4c4d66ce2d..b76150e106 100644
--- a/gtk2_ardour/sfdb_freesound_mootcher.h
+++ b/gtk2_ardour/sfdb_freesound_mootcher.h
@@ -1,6 +1,7 @@
/*sfdb_freesound_mootcher.h****************************************************************************
Adapted for Ardour by Ben Loftis, March 2008
+ Updated to new Freesound API by Colin Fletcher, November 2011
Mootcher Online Access to thefreesoundproject website
http://freesound.iua.upf.edu/
@@ -19,60 +20,55 @@
#include <string>
#include <sstream>
#include <vector>
+#include <gtkmm/progressbar.h>
//#include <ctime>
#include "curl/curl.h"
-
-// mootcher version
-#define ___VERSION___ 1.3
-
//--- struct to store XML file
struct MemoryStruct {
char *memory;
size_t size;
};
-//--- for download process viewing
-struct dlprocess {
- double dltotalMoo;
- double dlnowMoo;
+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.
};
+
class Mootcher
{
public:
Mootcher(const char *saveLocation);
~Mootcher();
- int doLogin(std::string login, std::string password);
- std::string getFile(std::string ID);
- std::string searchText(std::string word);
-
-
- struct dlprocess bar;
+ std::string getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, Gtk::ProgressBar *progress_bar);
+ std::string searchText(std::string query, int page, std::string filter, enum sortMethod sort);
private:
const char* changeWorkingDir(const char *saveLocation);
- std::string getXmlFile(std::string ID, int &length);
- void GetXml(std::string ID, struct MemoryStruct &xml_page);
- std::string changeExtension(std::string filename);
-
- void toLog(std::string input);
-
+ std::string doRequest(std::string uri, std::string params);
void setcUrlOptions();
- 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);
+ 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);
CURL *curl;
char errorBuffer[CURL_ERROR_SIZE]; // storage for cUrl error message
- int connection; // is 0 if no connection
- char message[128]; // storage for messages that are send to the logfile
-
std::string basePath;
std::string xmlLocation;
};
+