diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-11-11 21:26:33 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-11-13 23:59:22 +0800 |
commit | fe838cf55249bf53c3f42098feb55edd5318bf34 (patch) | |
tree | 65ce41a2dff690a71f2964015ede40f6014dad56 | |
parent | a6a3c811cbd2bdd64f6d49702bf1ad2f2fdf027c (diff) | |
download | gsoc2013-empathy-fe838cf55249bf53c3f42098feb55edd5318bf34.tar gsoc2013-empathy-fe838cf55249bf53c3f42098feb55edd5318bf34.tar.gz gsoc2013-empathy-fe838cf55249bf53c3f42098feb55edd5318bf34.tar.bz2 gsoc2013-empathy-fe838cf55249bf53c3f42098feb55edd5318bf34.tar.lz gsoc2013-empathy-fe838cf55249bf53c3f42098feb55edd5318bf34.tar.xz gsoc2013-empathy-fe838cf55249bf53c3f42098feb55edd5318bf34.tar.zst gsoc2013-empathy-fe838cf55249bf53c3f42098feb55edd5318bf34.zip |
add empathy_tp_chat_provide_password_{async,finish}
-rw-r--r-- | libempathy/empathy-tp-chat.c | 54 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 9 |
2 files changed, 63 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index aea125469..92faa65fe 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -1521,3 +1521,57 @@ empathy_tp_chat_password_needed (EmpathyTpChat *self) return priv->password_flags & TP_CHANNEL_PASSWORD_FLAG_PROVIDE; } + +static void +provide_password_cb (TpChannel *channel, + gboolean correct, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + GSimpleAsyncResult *result = user_data; + + if (error != NULL) { + g_simple_async_result_set_from_error (result, error); + } + else if (!correct) { + /* The current D-Bus API is a bit weird so re-use the + * AuthenticationFailed error */ + g_simple_async_result_set_error (result, TP_ERRORS, + TP_ERROR_AUTHENTICATION_FAILED, "Wrong password"); + } + + g_simple_async_result_complete (result); + g_object_unref (result); +} + +void +empathy_tp_chat_provide_password_async (EmpathyTpChat *self, + const gchar *password, + GAsyncReadyCallback callback, + gpointer user_data) +{ + EmpathyTpChatPriv *priv = GET_PRIV (self); + GSimpleAsyncResult *result; + + result = g_simple_async_result_new (G_OBJECT (self), + callback, user_data, empathy_tp_chat_provide_password_finish); + + tp_cli_channel_interface_password_call_provide_password (priv->channel, -1, + password, provide_password_cb, result, NULL, G_OBJECT (self)); +} + +gboolean +empathy_tp_chat_provide_password_finish (EmpathyTpChat *self, + GAsyncResult *result, + GError **error) +{ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), + error)) + return FALSE; + + g_return_val_if_fail (g_simple_async_result_is_valid (result, + G_OBJECT (self), empathy_tp_chat_provide_password_finish), FALSE); + + return TRUE; +} diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index 4dec0cd28..013a926bf 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -88,6 +88,15 @@ void empathy_tp_chat_acknowledge_messages (EmpathyTpChat *chat, gboolean empathy_tp_chat_password_needed (EmpathyTpChat *chat); +void empathy_tp_chat_provide_password_async (EmpathyTpChat *chat, + const gchar *password, + GAsyncReadyCallback callback, + gpointer user_data); + +gboolean empathy_tp_chat_provide_password_finish (EmpathyTpChat *chat, + GAsyncResult *result, + GError **error); + G_END_DECLS #endif /* __EMPATHY_TP_CHAT_H__ */ |