NO-OP; clean up script spacing and remove goto
[ardour.git] / gtk2_ardour / sfdb_freesound_mootcher.h
index 8956e349eb6dd5fe19ce170cfc820570d4d833e4..c9a27c7c1c39ae9de91cd0ba123af2f05957fefe 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Paul Davis 
+    Copyright (C) 2012 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 *****************************************************************************/
 
+#ifndef __gtk_ardour_sfdb_freesound_mootcher_h__
+#define __gtk_ardour_sfdb_freesound_mootcher_h__
+
 #include <string>
-#include <fstream>
-#include <iostream>
 #include <stdio.h>
 #include <cstring>
 #include <string>
@@ -47,7 +48,7 @@
 #include "curl/curl.h"
 
 //--- struct to store XML file
-struct MemoryStruct {
+struct SfdbMemoryStruct {
        char *memory;
        size_t size;
 };
@@ -65,14 +66,28 @@ 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:
 
@@ -89,7 +104,23 @@ 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;
 };
 
+#endif // __gtk_ardour_sfdb_freesound_mootcher_h__