[Pkg-owncloud-commits] [qtkeychain] 02/16: Detect GNOME keychain daemons presence using official API

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Sep 3 22:15:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository qtkeychain.

commit 97d50f65d9362c1fc0cc03b1b3d6aafe5d14241b
Author: Daniel Molkentin <daniel at molkentin.de>
Date:   Tue Apr 1 10:11:25 2014 +0200

    Detect GNOME keychain daemons presence using official API
    
    The previous approach was hacky and broke often, as
    variables kept changing again and again.
---
 gnomekeyring.cpp  | 15 +++++++++------
 gnomekeyring_p.h  |  6 +++++-
 keychain_unix.cpp |  2 +-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/gnomekeyring.cpp b/gnomekeyring.cpp
index 4191df9..9cef00f 100644
--- a/gnomekeyring.cpp
+++ b/gnomekeyring.cpp
@@ -2,21 +2,23 @@
 
 const char* GnomeKeyring::GNOME_KEYRING_DEFAULT = NULL;
 
-bool GnomeKeyring::isSupported()
+bool GnomeKeyring::isAvailable()
 {
     const GnomeKeyring& keyring = instance();
     return keyring.isLoaded() &&
            keyring.NETWORK_PASSWORD &&
+           keyring.is_available &&
            keyring.find_password &&
            keyring.store_password &&
-           keyring.delete_password;
+           keyring.delete_password &&
+           keyring.is_available();
 }
 
 GnomeKeyring::gpointer GnomeKeyring::store_network_password( const gchar* keyring, const gchar* display_name,
                                                const gchar* user, const gchar* server, const gchar* password,
                                                OperationDoneCallback callback, gpointer data, GDestroyNotify destroy_data )
 {
-    if ( !isSupported() )
+    if ( !isAvailable() )
         return 0;
     return instance().store_password( instance().NETWORK_PASSWORD,
                                       keyring, display_name, password, callback, data, destroy_data,
@@ -26,7 +28,7 @@ GnomeKeyring::gpointer GnomeKeyring::store_network_password( const gchar* keyrin
 GnomeKeyring::gpointer GnomeKeyring::find_network_password( const gchar* user, const gchar* server,
                                               OperationGetStringCallback callback, gpointer data, GDestroyNotify destroy_data )
 {
-    if ( !isSupported() )
+    if ( !isAvailable() )
         return 0;
     return instance().find_password( instance().NETWORK_PASSWORD,
                                      callback, data, destroy_data,
@@ -39,7 +41,7 @@ GnomeKeyring::gpointer GnomeKeyring::delete_network_password( const gchar* user,
                                                        gpointer data,
                                                        GDestroyNotify destroy_data )
 {
-    if ( !isSupported() )
+    if ( !isAvailable() )
         return 0;
     return instance().delete_password( instance().NETWORK_PASSWORD,
                                        callback, data, destroy_data,
@@ -57,7 +59,8 @@ GnomeKeyring::GnomeKeyring()
     };
 
     NETWORK_PASSWORD = &schema;
-    find_password =	reinterpret_cast<find_password_fn*>( resolve( "gnome_keyring_find_password" ) );
+    is_available = reinterpret_cast<is_available_fn*>( resolve( "gnome_keyring_is_available" ) );
+    find_password = reinterpret_cast<find_password_fn*>( resolve( "gnome_keyring_find_password" ) );
     store_password = reinterpret_cast<store_password_fn*>( resolve( "gnome_keyring_store_password" ) );
     delete_password = reinterpret_cast<delete_password_fn*>( resolve( "gnome_keyring_delete_password" ) );
 }
diff --git a/gnomekeyring_p.h b/gnomekeyring_p.h
index abe049e..6d150ba 100644
--- a/gnomekeyring_p.h
+++ b/gnomekeyring_p.h
@@ -34,6 +34,7 @@ public:
 
     typedef char gchar;
     typedef void* gpointer;
+    typedef bool gboolean;
     typedef struct {
         ItemType item_type;
         struct {
@@ -48,7 +49,7 @@ public:
 
     static const char* GNOME_KEYRING_DEFAULT;
 
-    static bool isSupported();
+    static bool isAvailable();
 
     static gpointer store_network_password( const gchar* keyring, const gchar* display_name,
                                             const gchar* user, const gchar* server, const gchar* password,
@@ -65,6 +66,7 @@ private:
     static GnomeKeyring& instance();
 
     const PasswordSchema* NETWORK_PASSWORD;
+    typedef gboolean ( is_available_fn )( void );
     typedef gpointer ( store_password_fn )( const PasswordSchema* schema, const gchar* keyring,
                                             const gchar* display_name, const gchar* password,
                                             OperationDoneCallback callback, gpointer data, GDestroyNotify destroy_data,
@@ -75,6 +77,8 @@ private:
     typedef gpointer ( delete_password_fn )( const PasswordSchema* schema,
                                              OperationDoneCallback callback, gpointer data, GDestroyNotify destroy_data,
                                              ... );
+
+    is_available_fn* is_available;
     find_password_fn* find_password;
     store_password_fn* store_password;
     delete_password_fn* delete_password;
diff --git a/keychain_unix.cpp b/keychain_unix.cpp
index 6bd1f25..87f3656 100644
--- a/keychain_unix.cpp
+++ b/keychain_unix.cpp
@@ -32,7 +32,7 @@ enum KeyringBackend {
 
 static KeyringBackend detectKeyringBackend()
 {
-    if ( !( qgetenv( "GNOME_KEYRING_CONTROL" ).isNull() && qgetenv("GNOME_KEYRING_SOCKET").isNull() ) && GnomeKeyring::isSupported() )
+    if ( GnomeKeyring::isAvailable() )
         return Backend_GnomeKeyring;
     else
         return Backend_Kwallet;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/qtkeychain.git



More information about the Pkg-owncloud-commits mailing list