fix cURL/SSL
[ardour.git] / gtk2_ardour / pingback.cc
index 10c798e104c341659c0f339cbd12df8fb952f2fb..feae1ff77accc12bcb61036c4782946482bc94a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Paul Davis 
+    Copyright (C) 2012 Paul Davis
     Inspired by code from Ben Loftis @ Harrison Consoles
 
     This program is free software; you can redistribute it and/or modify
@@ -19,8 +19,6 @@
 */
 
 #include <string>
-#include <iostream>
-#include <fstream>
 #include <cstring>
 
 #ifdef PLATFORM_WINDOWS
@@ -32,7 +30,7 @@
 
 #include <curl/curl.h>
 
-#include <glib/gstdio.h>
+#include "pbd/gstdio_compat.h"
 #include <glibmm/miscutils.h>
 
 #include "pbd/compose.h"
@@ -42,6 +40,7 @@
 #include "ardour/rc_configuration.h"
 
 #include "pingback.h"
+#include "utils.h"
 
 using std::string;
 using namespace ARDOUR;
@@ -110,13 +109,13 @@ _pingback (void *arg)
        string return_str;
        //initialize curl
 
-       curl_global_init (CURL_GLOBAL_NOTHING);
+       curl_global_init (CURL_GLOBAL_DEFAULT);
        c = curl_easy_init ();
-       
-       curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, curl_write_data); 
-       curl_easy_setopt (c, CURLOPT_WRITEDATA, &return_str); 
+
+       curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, curl_write_data);
+       curl_easy_setopt (c, CURLOPT_WRITEDATA, &return_str);
        char errbuf[CURL_ERROR_SIZE];
-       curl_easy_setopt (c, CURLOPT_ERRORBUFFER, errbuf); 
+       curl_easy_setopt (c, CURLOPT_ERRORBUFFER, errbuf);
 
        string url;
 
@@ -206,7 +205,7 @@ _pingback (void *arg)
        return_str = "";
 
        if (curl_easy_perform (c) == 0) {
-               long http_status; 
+               long http_status;
 
                curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &http_status);
 
@@ -219,21 +218,14 @@ _pingback (void *arg)
                        std::cerr << "Announcement string is too long (probably behind a proxy)." << std::endl;
                } else {
                        std::cerr << "Announcement is: " << return_str << std::endl;
-                       
+
                        //write announcements to local file, even if the
                        //announcement is empty
 
                        FILE* fout = g_fopen (cm->announce_path.c_str(), "wb");
 
                        if (fout) {
-                               {
-                                       std::ofstream annc_file (fout);
-
-                                       if (annc_file) {
-                                               annc_file << return_str;
-                                       }
-                               }
-
+                               fwrite (return_str.c_str(), sizeof(char), return_str.length (), fout);
                                fclose (fout);
                        }
                }
@@ -248,8 +240,15 @@ _pingback (void *arg)
 
 namespace ARDOUR {
 
-void pingback (const string& version, const string& announce_path) 
+void pingback (const string& version, const string& announce_path)
 {
+       if (ARDOUR_UI_UTILS::running_from_source_tree ()) {
+               /* we don't ping under these conditions, because the user is
+                  probably just paul or robin :)
+               */
+               return;
+       }
+
        ping_call* cm = new ping_call (version, announce_path);
        pthread_t thread;