]> git.0d.be Git - empathy.git/commitdiff
disconnect NewChannels signal once we got all the list channels we care about
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 24 Mar 2010 10:49:18 +0000 (11:49 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 30 Mar 2010 10:09:44 +0000 (12:09 +0200)
libempathy/empathy-tp-contact-list.c

index fd2cfaa3869a050246d39ee37f95edc775c6f9a6..9288baa4c2c3773f32c09112e82b084cc67f3334 100644 (file)
@@ -54,6 +54,8 @@ typedef struct {
        GHashTable     *add_to_group; /* group name -> GArray of handles */
 
        EmpathyContactListFlags flags;
+
+       TpProxySignalConnection *new_channels_sig;
 } EmpathyTpContactListPriv;
 
 typedef enum {
@@ -697,6 +699,15 @@ tp_contact_list_finalize (GObject *object)
        G_OBJECT_CLASS (empathy_tp_contact_list_parent_class)->finalize (object);
 }
 
+static gboolean
+received_all_list_channels (EmpathyTpContactList *self)
+{
+       EmpathyTpContactListPriv *priv = GET_PRIV (self);
+
+       return (priv->stored != NULL && priv->publish != NULL &&
+               priv->subscribe != NULL);
+}
+
 static void
 got_list_channel (EmpathyTpContactList *list,
                  TpChannel *channel)
@@ -728,6 +739,12 @@ got_list_channel (EmpathyTpContactList *list,
                                  G_CALLBACK (tp_contact_list_subscribe_group_members_changed_cb),
                                  list);
        }
+
+       if (received_all_list_channels (list) && priv->new_channels_sig != NULL) {
+               /* We don't need to watch NewChannels anymore */
+               tp_proxy_signal_connection_disconnect (priv->new_channels_sig);
+               priv->new_channels_sig = NULL;
+       }
 }
 
 static void
@@ -815,7 +832,8 @@ conn_ready_cb (TpConnection *connection,
        /* Watch the NewChannels signal so if ensuring list channels fails (for
         * example because the server is slow and the D-Bus call timeouts before CM
         * fetches the roster), we have a chance to get them later. */
-       tp_cli_connection_interface_requests_connect_to_new_channels (
+       priv->new_channels_sig =
+         tp_cli_connection_interface_requests_connect_to_new_channels (
                priv->connection, new_channels_cb, NULL, NULL, G_OBJECT (list), NULL);
 
        /* Request the 'stored' list. */