]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-tp-contact-list.c
Merge branch 'people-nearby-fake-group-613558'
[empathy.git] / libempathy / empathy-tp-contact-list.c
index fd2cfaa3869a050246d39ee37f95edc775c6f9a6..95ec3bea2109631ee34d9ef2d22b599996792b68 100644 (file)
@@ -43,7 +43,6 @@
 typedef struct {
        EmpathyTpContactFactory *factory;
        TpConnection   *connection;
-       const gchar    *protocol_group;
 
        TpChannel      *publish;
        TpChannel      *subscribe;
@@ -54,6 +53,8 @@ typedef struct {
        GHashTable     *add_to_group; /* group name -> GArray of handles */
 
        EmpathyContactListFlags flags;
+
+       TpProxySignalConnection *new_channels_sig;
 } EmpathyTpContactListPriv;
 
 typedef enum {
@@ -697,6 +698,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 +738,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 +831,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. */
@@ -842,7 +859,6 @@ static void
 tp_contact_list_constructed (GObject *list)
 {
        EmpathyTpContactListPriv *priv = GET_PRIV (list);
-       gchar                    *protocol_name = NULL;
 
        priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
 
@@ -884,15 +900,6 @@ tp_contact_list_constructed (GObject *list)
                                                  tp_contact_list_new_channel_cb,
                                                  NULL, NULL,
                                                  list, NULL);
-
-       /* Check for protocols that does not support contact groups. We can
-        * put all contacts into a special group in that case.
-        * FIXME: Default group should be an information in the profile */
-       tp_connection_parse_object_path (priv->connection, &protocol_name, NULL);
-       if (!tp_strdiff (protocol_name, "local-xmpp")) {
-               priv->protocol_group = _("People nearby");
-       }
-       g_free (protocol_name);
 }
 
 static void
@@ -1094,10 +1101,6 @@ tp_contact_list_get_all_groups (EmpathyContactList *list)
                l->data = g_strdup (l->data);
        }
 
-       if (priv->protocol_group) {
-               ret = g_list_prepend (ret, g_strdup (priv->protocol_group));
-       }
-
        return ret;
 }
 
@@ -1123,10 +1126,6 @@ tp_contact_list_get_groups (EmpathyContactList *list,
                }
        }
 
-       if (priv->protocol_group) {
-               ret = g_list_prepend (ret, g_strdup (priv->protocol_group));
-       }
-
        return ret;
 }