diff options
author | Jonny Lamb <jonnylamb@gnome.org> | 2011-01-29 00:29:12 +0800 |
---|---|---|
committer | Jonny Lamb <jonnylamb@gnome.org> | 2011-01-29 00:29:12 +0800 |
commit | 0bc660b874d8c04e22f7601dc5a3de428253d9c3 (patch) | |
tree | 1bf1b0fe677fbbd15cd459f950516f99946ace54 /libempathy | |
parent | 1cbcfd3eda00fa93d081ef37c609103d84663941 (diff) | |
download | gsoc2013-empathy-0bc660b874d8c04e22f7601dc5a3de428253d9c3.tar gsoc2013-empathy-0bc660b874d8c04e22f7601dc5a3de428253d9c3.tar.gz gsoc2013-empathy-0bc660b874d8c04e22f7601dc5a3de428253d9c3.tar.bz2 gsoc2013-empathy-0bc660b874d8c04e22f7601dc5a3de428253d9c3.tar.lz gsoc2013-empathy-0bc660b874d8c04e22f7601dc5a3de428253d9c3.tar.xz gsoc2013-empathy-0bc660b874d8c04e22f7601dc5a3de428253d9c3.tar.zst gsoc2013-empathy-0bc660b874d8c04e22f7601dc5a3de428253d9c3.zip |
keyring: add get_room_password_{async,finish} functions
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-keyring.c | 55 | ||||
-rw-r--r-- | 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 7205a83fb..75387b926 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 76cb4fbeb..58a7adce7 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); |