summaryrefslogtreecommitdiff
path: root/gtk2_ardour/sfdb_freesound_mootcher.h
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2013-03-15 19:59:19 +0000
committerColin Fletcher <colin.m.fletcher@googlemail.com>2013-03-17 12:33:59 +0000
commit2233e91086c01eeaf4d023db4e305944bc4565e6 (patch)
tree34f7a9254a946d853eb8844a79276d801915d1cf /gtk2_ardour/sfdb_freesound_mootcher.h
parent8cbb9727e959a744057de387a293aecdce09a62c (diff)
Freesound fixes for #5853, and a few other small improvements
Add a 'More' button to load the next page of results without clearing the already-found list. Don't allow cancellation of searches, and don't update progress bar around searches, since we only get one page at a time now. Show number of pages of results remaining to download in the tooltip of the 'More' button. Use a new Mootcher object for each request, to avoid bad things happening when clicking in the Freesound search results list while a search or file download is already in progress. Make the 'Stop' button insensitive except when it will actually stop the download of a sound file. Only retrieve one page worth of data per search, rather than looping to get all pages. Don't show an error in the log window if the user cancelled download. Request 100 items per page, rather than the default 30. Fix DOS line endings.
Diffstat (limited to 'gtk2_ardour/sfdb_freesound_mootcher.h')
-rw-r--r--gtk2_ardour/sfdb_freesound_mootcher.h154
1 files changed, 77 insertions, 77 deletions
diff --git a/gtk2_ardour/sfdb_freesound_mootcher.h b/gtk2_ardour/sfdb_freesound_mootcher.h
index 40b67b9069..7e39ba4ae4 100644
--- a/gtk2_ardour/sfdb_freesound_mootcher.h
+++ b/gtk2_ardour/sfdb_freesound_mootcher.h
@@ -17,80 +17,80 @@
*/
-/*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/
-
- 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>
-#include <gtkmm/progressbar.h>
-//#include <ctime>
-
-#include "sfdb_ui.h"
-
-#include "curl/curl.h"
-
-//--- struct to store XML file
-struct MemoryStruct {
- char *memory;
- size_t size;
-};
-
-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();
- ~Mootcher();
-
- std::string getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, SoundFileBrowser *caller);
- std::string searchText(std::string query, int page, std::string filter, enum sortMethod sort);
-
-private:
-
- void changeWorkingDir(const char *saveLocation);
- void ensureWorkingDir();
-
- 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);
- std::string sortMethodString(enum sortMethod sort);
- std::string getSoundResourceFile(std::string ID);
-
- CURL *curl;
- char errorBuffer[CURL_ERROR_SIZE]; // storage for cUrl error message
-
- std::string basePath;
- std::string xmlLocation;
-};
-
+/*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/
+
+ 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>
+#include <gtkmm/progressbar.h>
+//#include <ctime>
+
+#include "sfdb_ui.h"
+
+#include "curl/curl.h"
+
+//--- struct to store XML file
+struct MemoryStruct {
+ char *memory;
+ size_t size;
+};
+
+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();
+ ~Mootcher();
+
+ std::string getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, SoundFileBrowser *caller);
+ std::string searchText(std::string query, int page, std::string filter, enum sortMethod sort);
+
+private:
+
+ void changeWorkingDir(const char *saveLocation);
+ void ensureWorkingDir();
+
+ 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);
+ std::string sortMethodString(enum sortMethod sort);
+ std::string getSoundResourceFile(std::string ID);
+
+ CURL *curl;
+ char errorBuffer[CURL_ERROR_SIZE]; // storage for cUrl error message
+
+ std::string basePath;
+ std::string xmlLocation;
+};
+