Slightly hacky fix for AFL/PFL button misbehaviour
[ardour.git] / gtk2_ardour / sfdb_freesound_mootcher.h
index 4c4d66ce2d745108a45041ee05ea1ee76abe3ab4..b76150e1061a7950768ec07ecfd92f05442a4378 100644 (file)
@@ -1,6 +1,7 @@
 /*sfdb_freesound_mootcher.h****************************************************************************\r
 \r
        Adapted for Ardour by Ben Loftis, March 2008\r
+       Updated to new Freesound API by Colin Fletcher, November 2011\r
 \r
        Mootcher Online Access to thefreesoundproject website\r
        http://freesound.iua.upf.edu/\r
 #include <string>\r
 #include <sstream>\r
 #include <vector>\r
+#include <gtkmm/progressbar.h>\r
 //#include <ctime>\r
 \r
 #include "curl/curl.h"\r
 \r
-\r
-// mootcher version\r
-#define ___VERSION___ 1.3\r
-\r
 //--- struct to store XML file\r
 struct MemoryStruct {\r
        char *memory;\r
        size_t size;\r
 };\r
 \r
-//--- for download process viewing\r
-struct dlprocess {\r
-       double dltotalMoo;\r
-       double dlnowMoo;\r
+enum sortMethod {\r
+       sort_none,              // no sort\r
+       sort_duration_desc,     // Sort by the duration of the sounds, longest sounds first.\r
+       sort_duration_asc,      // Same as above, but shortest sounds first.\r
+       sort_created_desc,      // Sort by the date of when the sound was added. newest sounds first.\r
+       sort_created_asc,       // Same as above, but oldest sounds first.\r
+       sort_downloads_desc,    // Sort by the number of downloads, most downloaded sounds first.\r
+       sort_downloads_asc,     // Same as above, but least downloaded sounds first.\r
+       sort_rating_desc,       // Sort by the average rating given to the sounds, highest rated first.\r
+       sort_rating_asc         // Same as above, but lowest rated sounds first.\r
 };\r
 \r
+\r
 class Mootcher\r
 {\r
 public:\r
        Mootcher(const char *saveLocation);\r
        ~Mootcher();\r
 \r
-       int                     doLogin(std::string login, std::string password);\r
-       std::string     getFile(std::string ID);\r
-       std::string     searchText(std::string word);\r
-\r
-\r
-       struct dlprocess bar;\r
+       std::string     getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, Gtk::ProgressBar *progress_bar);\r
+       std::string     searchText(std::string query, int page, std::string filter, enum sortMethod sort);\r
 \r
 private:\r
 \r
        const char*     changeWorkingDir(const char *saveLocation);\r
 \r
-       std::string     getXmlFile(std::string ID, int &length);\r
-       void            GetXml(std::string ID, struct MemoryStruct &xml_page);\r
-       std::string     changeExtension(std::string filename);\r
-\r
-       void            toLog(std::string input);\r
-\r
+       std::string     doRequest(std::string uri, std::string params);\r
        void            setcUrlOptions();\r
 \r
-    static size_t              WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);\r
-       static int                      progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);\r
+       static size_t   WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);\r
+       static int      progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);\r
+       std::string     sortMethodString(enum sortMethod sort);\r
+       std::string     getSoundResourceFile(std::string ID);\r
 \r
        CURL *curl;\r
        char errorBuffer[CURL_ERROR_SIZE];      // storage for cUrl error message\r
 \r
-       int connection;         // is 0 if no connection\r
-       char message[128];      // storage for messages that are send to the logfile\r
-\r
        std::string basePath;\r
        std::string xmlLocation;\r
 };\r
+\r