diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-08-06 19:00:59 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-08-06 19:00:59 +0000 |
commit | 3f0f409e0648e230b84e294429dc0603502996ae (patch) | |
tree | 7fc16355d7772f6f4b7e010678f5abd32b5a2724 /libs | |
parent | e2965cd138b31e27dc027bb674585ae93ffdc055 (diff) |
functions related to blocking mothership callbacks
git-svn-id: svn://localhost/ardour2/branches/3.0@7554 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/callback.h | 5 | ||||
-rw-r--r-- | libs/ardour/callback.cc | 36 |
2 files changed, 36 insertions, 5 deletions
diff --git a/libs/ardour/ardour/callback.h b/libs/ardour/ardour/callback.h index fe190dbd5e..3f5ec83bec 100644 --- a/libs/ardour/ardour/callback.h +++ b/libs/ardour/ardour/callback.h @@ -3,6 +3,9 @@ #include <string> -void call_the_mothership (const std::string&); +void call_the_mothership (const std::string& version); +void block_mothership (); +void unblock_mothership (); +bool mothership_blocked (); #endif /* __libardour_callback_h__ */ diff --git a/libs/ardour/callback.cc b/libs/ardour/callback.cc index e0c02e64d4..3a66836748 100644 --- a/libs/ardour/callback.cc +++ b/libs/ardour/callback.cc @@ -1,6 +1,11 @@ #include <iostream> #include <string> #include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <cstdlib> #include <sys/utsname.h> #include <curl/curl.h> @@ -17,6 +22,7 @@ using namespace std; #define PING_URL "http://ardour.org/pingback/versioncheck" +#define OFF_THE_HOOK ".offthehook" static size_t curl_write_data (char *bufptr, size_t size, size_t nitems, void *ptr) @@ -41,7 +47,31 @@ curl_write_data (char *bufptr, size_t size, size_t nitems, void *ptr) static string watermark () { - return ""; + return string(); +} + +void +block_mothership () +{ + string hangup = Glib::build_filename (ARDOUR::user_config_directory().to_string(), OFF_THE_HOOK); + int fd; + if ((fd = ::open (hangup.c_str(), O_RDWR|O_CREAT, 0600)) >= 0) { + close (fd); + } +} + +void +unblock_mothership () +{ + string hangup = Glib::build_filename (ARDOUR::user_config_directory().to_string(), OFF_THE_HOOK); + ::unlink (hangup.c_str()); +} + +bool +mothership_blocked () +{ + string hangup = Glib::build_filename (ARDOUR::user_config_directory().to_string(), OFF_THE_HOOK); + return Glib::file_test (hangup, Glib::FILE_TEST_EXISTS); } void @@ -50,9 +80,7 @@ call_the_mothership (const string& version) /* check if the user says never to do this */ - string hangup = Glib::build_filename (ARDOUR::user_config_directory().to_string(), ".offthehook"); - - if (Glib::file_test (hangup, Glib::FILE_TEST_EXISTS)) { + if (mothership_blocked()) { return; } |