]> git.0d.be Git - empathy.git/commitdiff
tp-chat: update the 'password-needed' property when password flags changes
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 11 Nov 2009 15:15:39 +0000 (15:15 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 13 Nov 2009 15:59:22 +0000 (15:59 +0000)
libempathy/empathy-tp-chat.c

index c0c6eb66ec1ca62829ca8ade9e92ec191037c958..9a235b70e9632f758cf903eb34df72acf324dafd 100644 (file)
@@ -1046,6 +1046,28 @@ tp_chat_got_self_contact_cb (EmpathyTpContactFactory *factory,
        tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
 }
 
+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,
@@ -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 {