aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-tp-chat.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-11 21:26:33 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-13 23:59:22 +0800
commitfe838cf55249bf53c3f42098feb55edd5318bf34 (patch)
tree65ce41a2dff690a71f2964015ede40f6014dad56 /libempathy/empathy-tp-chat.c
parenta6a3c811cbd2bdd64f6d49702bf1ad2f2fdf027c (diff)
downloadgsoc2013-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}
Diffstat (limited to 'libempathy/empathy-tp-chat.c')
-rw-r--r--libempathy/empathy-tp-chat.c54
1 files changed, 54 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;
+}