[empathy] tp-chat: update the 'password-needed' property when password flags changes



commit 279e787b1634fdd3269cb28f0562b9bcca79e496
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Nov 11 15:15:39 2009 +0000

    tp-chat: update the 'password-needed' property when password flags changes

 libempathy/empathy-tp-chat.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index c0c6eb6..9a235b7 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -1047,6 +1047,28 @@ tp_chat_got_self_contact_cb (EmpathyTpContactFactory *factory,
 }
 
 static void
+password_flags_changed_cb (TpChannel *channel,
+    guint added,
+    guint removed,
+    gpointer user_data,
+    GObject *weak_object)
+{
+	EmpathyTpChat *self = EMPATHY_TP_CHAT (weak_object);
+	EmpathyTpChatPriv *priv = GET_PRIV (self);
+	gboolean was_needed, needed;
+
+	was_needed = empathy_tp_chat_password_needed (self);
+
+	priv->password_flags |= added;
+	priv->password_flags ^= removed;
+
+	needed = empathy_tp_chat_password_needed (self);
+
+	if (was_needed != needed)
+		g_object_notify (G_OBJECT (self), "password-needed");
+}
+
+static void
 got_password_flags_cb (TpChannel *proxy,
 			     guint password_flags,
 			     const GError *error,
@@ -1136,6 +1158,11 @@ tp_chat_constructor (GType                  type,
 	if (tp_proxy_has_interface_by_id (priv->channel,
 					  TP_IFACE_QUARK_CHANNEL_INTERFACE_PASSWORD)) {
 		priv->got_password_flags = FALSE;
+
+		tp_cli_channel_interface_password_connect_to_password_flags_changed (
+									       priv->channel, password_flags_changed_cb, chat, NULL,
+									       G_OBJECT (chat), NULL);
+
 		tp_cli_channel_interface_password_call_get_password_flags (priv->channel,
 									       -1, got_password_flags_cb, chat, NULL, chat);
 	} else {



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