/*
- 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
*/
#include <string>
-#include <iostream>
-#include <fstream>
#include <cstring>
#ifdef PLATFORM_WINDOWS
#include <curl/curl.h>
+#include "pbd/gstdio_compat.h"
#include <glibmm/miscutils.h>
#include "pbd/compose.h"
#include "ardour/rc_configuration.h"
#include "pingback.h"
+#include "utils.h"
using std::string;
using namespace ARDOUR;
curl_global_init (CURL_GLOBAL_NOTHING);
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;
}
if (_query_registry("Hardware\\Description\\System\\CentralProcessor\\0", "Identifier", val)) {
+ // remove "Family X Model YY Stepping Z" tail
+ size_t cut = val.find (" Family ");
+ if (string::npos != cut) {
+ val = val.substr (0, cut);
+ }
char* query = curl_easy_escape (c, val.c_str(), strlen (val.c_str()));
url += "m=";
url += query;
return_str = "";
if (curl_easy_perform (c) == 0) {
- long http_status;
+ long http_status;
curl_easy_getinfo (c, CURLINFO_RESPONSE_CODE, &http_status);
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
-
- std::ofstream annc_file (cm->announce_path.c_str());
-
- if (annc_file) {
- annc_file << return_str;
+
+ FILE* fout = g_fopen (cm->announce_path.c_str(), "wb");
+
+ if (fout) {
+ fwrite (return_str.c_str(), sizeof(char), return_str.length (), fout);
+ fclose (fout);
}
}
} else {
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;