[empathy: 3/10] keyring: add get_room_password_{async, finish} functions



commit 0bc660b874d8c04e22f7601dc5a3de428253d9c3
Author: Jonny Lamb <jonnylamb gnome org>
Date:   Fri Jan 28 16:29:12 2011 +0000

    keyring: add get_room_password_{async,finish} functions
    
    Signed-off-by: Jonny Lamb <jonnylamb gnome org>

 libempathy/empathy-keyring.c |   55 ++++++++++++++++++++++++++++++++++++++++++
 libempathy/empathy-keyring.h |    7 +++++
 2 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-keyring.c b/libempathy/empathy-keyring.c
index 7205a83..75387b9 100644
--- a/libempathy/empathy-keyring.c
+++ b/libempathy/empathy-keyring.c
@@ -101,6 +101,40 @@ empathy_keyring_get_account_password_async (TpAccount *account,
   gnome_keyring_attribute_list_free (match);
 }
 
+void
+empathy_keyring_get_room_password_async (TpAccount *account,
+    const gchar *id,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  GSimpleAsyncResult *simple;
+  GnomeKeyringAttributeList *match;
+  const gchar *account_id;
+
+  g_return_if_fail (TP_IS_ACCOUNT (account));
+  g_return_if_fail (id != NULL);
+  g_return_if_fail (callback != NULL);
+
+  simple = g_simple_async_result_new (G_OBJECT (account), callback,
+      user_data, empathy_keyring_get_room_password_async);
+
+  account_id = tp_proxy_get_object_path (account) +
+    strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
+
+  DEBUG ("Trying to get password for room '%s' on account '%s'",
+      id, account_id);
+
+  match = gnome_keyring_attribute_list_new ();
+  gnome_keyring_attribute_list_append_string (match, "account-id",
+      account_id);
+  gnome_keyring_attribute_list_append_string (match, "room-id", id);
+
+  gnome_keyring_find_items (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+      match, find_items_cb, simple, NULL);
+
+  gnome_keyring_attribute_list_free (match);
+}
+
 const gchar *
 empathy_keyring_get_account_password_finish (TpAccount *account,
     GAsyncResult *result,
@@ -122,6 +156,27 @@ empathy_keyring_get_account_password_finish (TpAccount *account,
   return g_simple_async_result_get_op_res_gpointer (simple);
 }
 
+const gchar *
+empathy_keyring_get_room_password_finish (TpAccount *account,
+    GAsyncResult *result,
+    GError **error)
+{
+  GSimpleAsyncResult *simple;
+
+  g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
+  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
+
+  simple = G_SIMPLE_ASYNC_RESULT (result);
+
+  if (g_simple_async_result_propagate_error (simple, error))
+    return NULL;
+
+  g_return_val_if_fail (g_simple_async_result_is_valid (result,
+          G_OBJECT (account), empathy_keyring_get_account_password_async), NULL);
+
+  return g_simple_async_result_get_op_res_gpointer (simple);
+}
+
 /* set */
 
 static void
diff --git a/libempathy/empathy-keyring.h b/libempathy/empathy-keyring.h
index 76cb4fb..58a7adc 100644
--- a/libempathy/empathy-keyring.h
+++ b/libempathy/empathy-keyring.h
@@ -33,6 +33,13 @@ void empathy_keyring_get_account_password_async (TpAccount *account,
 const gchar * empathy_keyring_get_account_password_finish (TpAccount *account,
     GAsyncResult *result, GError **error);
 
+void empathy_keyring_get_room_password_async (TpAccount *account,
+    const gchar *id,
+    GAsyncReadyCallback callback, gpointer user_data);
+
+const gchar * empathy_keyring_get_room_password_finish (TpAccount *account,
+    GAsyncResult *result, GError **error);
+
 void empathy_keyring_set_account_password_async (TpAccount *account,
     const gchar *password, GAsyncReadyCallback callback,
     gpointer user_data);



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