fix curl error checks
authorBen Loftis <ben@glw.com>
Wed, 26 Mar 2008 15:52:13 +0000 (15:52 +0000)
committerBen Loftis <ben@glw.com>
Wed, 26 Mar 2008 15:52:13 +0000 (15:52 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3188 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/sfdb_freesound_mootcher.cc
gtk2_ardour/sfdb_ui.cc

index c9e04c14d571867cd30566e55b1ec724dd1b6c8d..484df19941e73105f9a2b70d433dc9a1ef8e3c56 100644 (file)
@@ -159,6 +159,8 @@ int                 Mootcher::doLogin(std::string login, std::string password)
                setcUrlOptions();\r
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); \r
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&xml_page);\r
+               // save the sessoin id that is given back by the server in a cookie\r
+               curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookiejar.txt");\r
                // use POST for login variables\r
                curl_easy_setopt(curl, CURLOPT_POST, TRUE);\r
                curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postMessage.c_str());\r
@@ -169,11 +171,14 @@ int                       Mootcher::doLogin(std::string login, std::string password)
                curl_easy_setopt(curl, CURLOPT_URL, login_url.c_str() );\r
 \r
                // perform online request\r
+               connection = 1;\r
                CURLcode res = curl_easy_perform(curl);\r
-               // if something goes wrong 'connection' is set to '0'\r
-               if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
-               else connection = 0;\r
-\r
+               if( res != 0 ) {\r
+                       toLog("curl login error\n");\r
+                       toLog(curl_easy_strerror(res));\r
+                       connection = 0;\r
+               }\r
+               \r
                if (connection == 1){\r
                        std::string check_page = xml_page.memory;\r
                        int test = (int)check_page.find("login");   //logged\r
@@ -238,12 +243,16 @@ std::string       Mootcher::searchText(std::string word)
                        curl_easy_setopt(curl, CURLOPT_URL, search_url.c_str());\r
 \r
                        // perform the online search \r
-                       CURLcode res = curl_easy_perform(curl);\r
-                       if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
-                       else connection = 0;\r
+                       connection = 1;\r
+                       CURLcode res = curl_easy_perform(curl);\r
+                       if( res != 0 ) {\r
+                               toLog("curl login error\n");\r
+                               toLog(curl_easy_strerror(res));\r
+                               connection = 0;\r
+                       }\r
                        \r
                        result = xml_page.memory;\r
-//printf("%s/n", result.c_str());\r
+                       toLog( result.c_str() );\r
 \r
                        // free the memory\r
                        if(xml_page.memory){\r
@@ -302,9 +311,13 @@ void               Mootcher::GetXml(std::string ID, struct MemoryStruct &xml_page)
                curl_easy_setopt(curl, CURLOPT_URL, getxml_url.c_str() );\r
                \r
                // get it!\r
+               connection = 1;\r
                CURLcode res = curl_easy_perform(curl);\r
-               if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
-               else connection = 0;\r
+               if( res != 0 ) {\r
+                       toLog("curl login error\n");\r
+                       toLog(curl_easy_strerror(res));\r
+                       connection = 0;\r
+               }\r
        }\r
 }\r
 //------------------------------------------------------------------------\r
@@ -459,9 +472,14 @@ std::string        Mootcher::getFile(std::string ID)
                                curl_easy_setopt(curl, CURLOPT_URL, audioURL.c_str() );\r
                                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, audioFileWrite);\r
                                curl_easy_setopt(curl, CURLOPT_WRITEDATA, theFile);\r
+\r
+                               connection = 1;\r
                                CURLcode res = curl_easy_perform(curl);\r
-                               if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
-                               else connection = 0;\r
+                               if( res != 0 ) {\r
+                                       toLog("curl login error\n");\r
+                                       toLog(curl_easy_strerror(res));\r
+                                       connection = 0;\r
+                               }\r
 \r
                                fclose(theFile);\r
                        }\r
index 7b8babca585ab386739f30cd196181ca315d31b0..4daab8029d893c8bf5da646beed4d382acfda2bc 100644 (file)
@@ -734,7 +734,7 @@ SoundFileBrowser::freesound_search_clicked ()
                return;
        
        if ( searching ) {
-               freesound_search_btn.set_label(_("Canceling.."));
+               freesound_search_btn.set_label(_("Cancelling.."));
                canceling = true;
        } else {
                searching = true;