]> git.0d.be Git - empathy.git/commitdiff
find_items_cb: always use the first password found
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 28 Feb 2011 13:50:43 +0000 (14:50 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 28 Feb 2011 13:53:56 +0000 (14:53 +0100)
libempathy/empathy-keyring.c

index f8422c1518bb2c2024293e5727644cb73832dbd8..425ae1ed60b9ac5291cf306a4f52e36da9c88ac0 100644 (file)
@@ -55,6 +55,7 @@ find_items_cb (GnomeKeyringResult result,
     gpointer user_data)
 {
   GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
+  GnomeKeyringFound *found;
 
   if (result != GNOME_KEYRING_RESULT_OK)
     {
@@ -63,17 +64,25 @@ find_items_cb (GnomeKeyringResult result,
           gnome_keyring_result_to_message (result));
       g_simple_async_result_set_from_error (simple, error);
       g_clear_error (&error);
+      goto out;
     }
 
-  if (g_list_length (list) == 1)
+  if (list == NULL)
     {
-      GnomeKeyringFound *found = list->data;
+      g_simple_async_result_set_error (simple, TP_ERROR,
+          TP_ERROR_DOES_NOT_EXIST, "Password not found");
+      goto out;
+    }
 
-      DEBUG ("Got secret");
+  /* Get the first password returned. Ideally we should use the latest
+   * modified or something but we don't have this information from
+   * gnome-keyring atm. */
+  found = list->data;
+  DEBUG ("Got secret");
 
-      g_simple_async_result_set_op_res_gpointer (simple, found->secret, NULL);
-    }
+  g_simple_async_result_set_op_res_gpointer (simple, found->secret, NULL);
 
+out:
   g_simple_async_result_complete (simple);
   g_object_unref (simple);
 }