[gnote] Fix WebDAV settings clear



commit 2223469be4f3f96937157b5dc368df8541316243
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Sun Aug 12 17:25:37 2012 +0300

    Fix WebDAV settings clear
    
    Fix issue with removing stored password.

 .../webdavsyncservice/webdavsyncserviceaddin.cpp   |    7 ++++++-
 src/gnome_keyring/ring.cpp                         |   14 +++++++++++++-
 src/gnome_keyring/ring.hpp                         |    1 +
 3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/addins/webdavsyncservice/webdavsyncserviceaddin.cpp b/src/addins/webdavsyncservice/webdavsyncserviceaddin.cpp
index e5107bb..0b3447d 100644
--- a/src/addins/webdavsyncservice/webdavsyncserviceaddin.cpp
+++ b/src/addins/webdavsyncservice/webdavsyncserviceaddin.cpp
@@ -273,7 +273,12 @@ void WebDavSyncServiceAddin::save_config_settings(const std::string & url, const
     settings->set_string(Preferences::SYNC_FUSE_WDFS_USERNAME, username);
     settings->set_string(Preferences::SYNC_FUSE_WDFS_URL, url);
 
-    Ring::create_password(Ring::default_keyring(), KEYRING_ITEM_NAME, s_request_attributes, password);
+    if(password != "") {
+      Ring::create_password(Ring::default_keyring(), KEYRING_ITEM_NAME, s_request_attributes, password);
+    }
+    else {
+      Ring::clear_password(s_request_attributes);
+    }
   }
   catch(KeyringException & ke) {
     DBG_OUT("Saving configuration to the GNOME keyring failed with the following message: %s", ke.what());
diff --git a/src/gnome_keyring/ring.cpp b/src/gnome_keyring/ring.cpp
index 63538c6..2a0ab5d 100644
--- a/src/gnome_keyring/ring.cpp
+++ b/src/gnome_keyring/ring.cpp
@@ -39,7 +39,6 @@ SecretSchema Ring::s_schema = {
 
 std::string Ring::find_password(const std::map<std::string, std::string> & atts)
 {
-  GList *list = NULL;
   GHashTable *attributes = keyring_attributes(atts);
   GError *error = NULL;
   gchar *result = secret_password_lookupv_sync(&s_schema, attributes, NULL, &error);
@@ -79,6 +78,19 @@ void Ring::create_password(const std::string & keyring, const std::string & disp
   }
 }
 
+void Ring::clear_password(const std::map<std::string, std::string> & attributes)
+{
+  GHashTable *atts = keyring_attributes(attributes);
+  GError *error = NULL;
+  secret_password_clearv_sync(&s_schema, atts, NULL, &error);
+  g_hash_table_unref(atts);
+  if(error) {
+    KeyringException e(error->message);
+    g_error_free(error);
+    throw e;
+  }
+}
+
 GHashTable *Ring::keyring_attributes(const std::map<std::string, std::string> & atts)
 {
   GHashTable *result = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
diff --git a/src/gnome_keyring/ring.hpp b/src/gnome_keyring/ring.hpp
index 2caf5f4..4995200 100644
--- a/src/gnome_keyring/ring.hpp
+++ b/src/gnome_keyring/ring.hpp
@@ -39,6 +39,7 @@ public:
   static void create_password(const std::string & keyring, const std::string & displayName,
                               const std::map<std::string, std::string> & attributes,
                               const std::string & secret);
+  static void clear_password(const std::map<std::string, std::string> & attributes);
 private:
   static GHashTable *keyring_attributes(const std::map<std::string, std::string> & atts);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]