proper 1px track separator
[ardour.git] / gtk2_ardour / sfdb_freesound_mootcher.h
index 7e39ba4ae4ad015d9a5029080e30fe9507231d00..48fb11b638fa4a311ea49cdb440df99481db83be 100644 (file)
@@ -65,18 +65,31 @@ enum sortMethod {
 };
 
 
-class Mootcher
+class Mootcher: public sigc::trackable, public PBD::ScopedConnectionList
 {
 public:
        Mootcher();
        ~Mootcher();
 
-       std::string     getAudioFile(std::string originalFileName, std::string ID, std::string audioURL, SoundFileBrowser *caller);
+       bool            checkAudioFile(std::string originalFileName, std::string ID);
+       bool            fetchAudioFile(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);
+       std::string     searchSimilar(std::string id);
+       void *          threadFunc();
+       SoundFileBrowser *sfb; 
+       std::string     audioFileName;
+       std::string     ID;
+
+       /** signal emitted when mootcher reports progress updates during download.
+        * The parameters are current and total numbers of bytes downloaded.
+        */
+       PBD::Signal2<void, double, double> Progress;
+       /** signal emitted when the mootcher has finished downloading. */
+       PBD::Signal0<void> Finished;
+
 
 private:
 
-       void            changeWorkingDir(const char *saveLocation);
        void            ensureWorkingDir();
 
        std::string     doRequest(std::string uri, std::string params);
@@ -90,6 +103,21 @@ private:
        CURL *curl;
        char errorBuffer[CURL_ERROR_SIZE];      // storage for cUrl error message
 
+       FILE* theFile;
+
+       void updateProgress(double dlnow, double dltotal);
+       void doneWithMootcher();
+
+       Gtk::HBox progress_hbox;
+       Gtk::ProgressBar progress_bar;
+       Gtk::Button cancel_download_btn;
+
+       bool cancel_download;
+       void cancelDownload() { 
+               cancel_download = true;
+               progress_hbox.hide();
+       }
+
        std::string basePath;
        std::string xmlLocation;
 };