[vinagre] Revert "Fixes the libsecret 'user' argument passing"



commit 58a0855c42bae2c3affcd0eaa5804e486f789944
Author: David King <amigadave amigadave com>
Date:   Tue Jul 23 15:25:01 2013 +0100

    Revert "Fixes the libsecret 'user' argument passing"
    
    This reverts commit f87204345c641b63b51d5713d37d94d5eb45e694.

 plugins/vnc/vinagre-vnc-tab.c |    6 +++-
 vinagre/vinagre-tab.c         |   63 +++++++++++++----------------------------
 2 files changed, 25 insertions(+), 44 deletions(-)
---
diff --git a/plugins/vnc/vinagre-vnc-tab.c b/plugins/vnc/vinagre-vnc-tab.c
index 73a13b8..7cae9f2 100644
--- a/plugins/vnc/vinagre-vnc-tab.c
+++ b/plugins/vnc/vinagre-vnc-tab.c
@@ -492,7 +492,11 @@ vnc_authentication_cb (VncDisplay *vnc, GValueArray *credList, VinagreVncTab *vn
 
   if (need_password || need_username)
     {
-      vinagre_tab_find_credentials_in_keyring (tab, &username, &password);
+      /* libsecret does not support NULL attributes, bug 685041. */
+      if (vinagre_connection_get_username (conn) != NULL)
+        {
+          vinagre_tab_find_credentials_in_keyring (tab, &username, &password);
+        }
 
       if ( (need_username && !username) || (need_password && !password) )
        {
diff --git a/vinagre/vinagre-tab.c b/vinagre/vinagre-tab.c
index c0816b8..2f06e0d 100644
--- a/vinagre/vinagre-tab.c
+++ b/vinagre/vinagre-tab.c
@@ -742,38 +742,17 @@ vinagre_tab_get_from_connection (VinagreConnection *conn)
   return (res != NULL) ? VINAGRE_TAB (res) : NULL;
 }
 
-static GHashTable *
-create_secret_hash (VinagreTab *tab)
-{
-  GHashTable *table;
-
-  table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
-
-  if (vinagre_connection_get_username (tab->priv->conn))
-    g_hash_table_insert (table, "user",
-                         g_strdup (vinagre_connection_get_username (tab->priv->conn)));
-  g_hash_table_insert (table, "server",
-                       g_strdup (vinagre_connection_get_host (tab->priv->conn)));
-  g_hash_table_insert (table, "protocol",
-                       g_strdup (vinagre_connection_get_protocol (tab->priv->conn)));
-  g_hash_table_insert (table, "port",
-                       g_strdup_printf ("%d", vinagre_connection_get_port (tab->priv->conn)));
-
-  return table;
-}
-
 gboolean
 vinagre_tab_find_credentials_in_keyring (VinagreTab *tab, gchar **username, gchar **password)
 {
-  GHashTable *table = create_secret_hash (tab);
-
   *username = NULL;
 
-  *password = secret_password_lookupv_sync (SECRET_SCHEMA_COMPAT_NETWORK,
-                                            table,
-                                            NULL,
-                                            NULL);
-  g_hash_table_destroy (table);
+  *password = secret_password_lookup_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL, NULL,
+                                           "user", vinagre_connection_get_username (tab->priv->conn),
+                                           "server", vinagre_connection_get_host (tab->priv->conn),
+                                           "protocol", vinagre_connection_get_protocol (tab->priv->conn),
+                                           "port", vinagre_connection_get_port (tab->priv->conn),
+                                           NULL);
 
   if (*password == NULL)
     return FALSE;
@@ -792,22 +771,20 @@ vinagre_tab_save_credentials_in_keyring (VinagreTab *tab)
 {
   GError *error = NULL;
   gchar *label;
-  GHashTable *table;
 
   if (!tab->priv->save_credentials)
     return;
 
-  table = create_secret_hash (tab);
   label = g_strdup_printf (_("Remote desktop password: %s"), vinagre_connection_get_host (tab->priv->conn));
-  secret_password_storev_sync (SECRET_SCHEMA_COMPAT_NETWORK,
-                               table,
-                               NULL,
-                               label,
-                               vinagre_connection_get_password (tab->priv->conn),
-                               NULL,
-                               &error);
+  secret_password_store_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL,
+                              label, vinagre_connection_get_password (tab->priv->conn),
+                              NULL, &error,
+                              "user", vinagre_connection_get_username (tab->priv->conn),
+                              "server", vinagre_connection_get_host (tab->priv->conn),
+                              "protocol", vinagre_connection_get_protocol (tab->priv->conn),
+                              "port", vinagre_connection_get_port (tab->priv->conn),
+                              NULL);
   g_free (label);
-  g_hash_table_destroy (table);
 
   if (error == NULL) {
     tab->priv->saved_credentials = TRUE;
@@ -826,12 +803,12 @@ void vinagre_tab_remove_credentials_from_keyring (VinagreTab *tab)
 {
   if (tab->priv->saved_credentials)
     {
-      GHashTable *table = create_secret_hash (tab);
-      secret_password_clearv_sync (SECRET_SCHEMA_COMPAT_NETWORK,
-                                   table,
-                                   NULL,
-                                   NULL);
-      g_hash_table_destroy (table);
+      secret_password_clear_sync (SECRET_SCHEMA_COMPAT_NETWORK, NULL, NULL,
+                                  "user", vinagre_connection_get_username (tab->priv->conn),
+                                  "server", vinagre_connection_get_host (tab->priv->conn),
+                                  "protocol", vinagre_connection_get_protocol (tab->priv->conn),
+                                  "port", vinagre_connection_get_port (tab->priv->conn),
+                                  NULL);
       tab->priv->saved_credentials = FALSE;
     }
 


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