]> git.0d.be Git - empathy.git/commitdiff
groups-widget: use empathy_connection_aggregator_get_all_groups()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 29 Nov 2011 13:02:40 +0000 (14:02 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 29 Nov 2011 13:24:17 +0000 (14:24 +0100)
We have to prepare the contact groups feature and ensure that the singleton is
still alive. The 'empathy' process is the only one allowing user to change
contact groups so we just have to do it there.

https://bugzilla.gnome.org/show_bug.cgi?id=665121

libempathy-gtk/empathy-groups-widget.c
src/empathy.c

index fa092b6d643dbaea91462b7970b088b49e9a376b..efb58fa99dc55d84c4b1bf8461e83d70a947be2f 100644 (file)
@@ -32,7 +32,7 @@
 #include <folks/folks.h>
 
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-connection-aggregator.h>
 
 #include "empathy-groups-widget.h"
 #include "empathy-ui-utils.h"
@@ -150,7 +150,7 @@ static void
 populate_data (EmpathyGroupsWidget *self)
 {
   EmpathyGroupsWidgetPriv *priv = GET_PRIV (self);
-  EmpathyContactManager *manager;
+  EmpathyConnectionAggregator *aggregator;
   GtkTreeIter iter;
   GeeSet *member_groups;
   GList *all_groups, *l;
@@ -158,12 +158,12 @@ populate_data (EmpathyGroupsWidget *self)
   /* Remove the old groups */
   gtk_list_store_clear (priv->group_store);
 
-  /* FIXME: We have to get the whole group list from EmpathyContactManager, as
-   * libfolks hasn't grown API to get the whole group list yet. (bgo#627398) */
-  manager = empathy_contact_manager_dup_singleton ();
-  all_groups = empathy_contact_list_get_all_groups (
-      EMPATHY_CONTACT_LIST (manager));
-  g_object_unref (manager);
+  /* FIXME: We have to get the whole group list from
+   * EmpathyConnectionAggregator, as libfolks hasn't grown API to get the whole
+   * group list yet. (bgo#627398) */
+  aggregator = empathy_connection_aggregator_dup_singleton ();
+  all_groups = empathy_connection_aggregator_get_all_groups (aggregator);
+  g_object_unref (aggregator);
 
   /* Get the list of groups that this #FolksGroupDetails is currently in */
   member_groups = folks_group_details_get_groups (priv->group_details);
index b73bf1b038c47fb5e9d3e5204e4ca0ed04c788eb..57f5c8418329724224143a9ef36578e51dff88df 100644 (file)
@@ -48,6 +48,8 @@
 
 #include <telepathy-logger/log-manager.h>
 
+#include <libempathy/empathy-client-factory.h>
+#include <libempathy/empathy-connection-aggregator.h>
 #include <libempathy/empathy-presence-manager.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-chatroom-manager.h>
@@ -122,6 +124,7 @@ struct _EmpathyApp
   EmpathyConnectivity *connectivity;
   GSettings *gsettings;
   EmpathyNotificationsApprover *notifications_approver;
+  EmpathyConnectionAggregator *conn_aggregator;
 #ifdef HAVE_GEOCLUE
   EmpathyLocationManager *location_manager;
 #endif
@@ -167,6 +170,7 @@ empathy_app_dispose (GObject *object)
   tp_clear_object (&self->ft_factory);
   tp_clear_object (&self->gsettings);
   tp_clear_object (&self->notifications_approver);
+  tp_clear_object (&self->conn_aggregator);
 
   if (dispose != NULL)
     dispose (object);
@@ -808,11 +812,31 @@ empathy_app_constructed (GObject *object)
   self->location_manager = empathy_location_manager_dup_singleton ();
 #endif
 
+  self->conn_aggregator = empathy_connection_aggregator_dup_singleton ();
+
   self->activated = FALSE;
   self->ft_factory = NULL;
   self->window = NULL;
 }
 
+static void
+add_empathy_features (void)
+{
+  /* Add 'empathy' specific feature before doing any preparation */
+  EmpathyClientFactory *factory;
+
+  factory = empathy_client_factory_dup ();
+
+  tp_simple_client_factory_add_connection_features_varargs (
+      TP_SIMPLE_CLIENT_FACTORY (factory),
+      /* empathy_connection_aggregator_get_all_groups(), used by
+       * EmpathyGroupsWidget relies on it */
+      TP_CONNECTION_FEATURE_CONTACT_GROUPS,
+      NULL);
+
+  g_object_unref (factory);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -832,6 +856,8 @@ main (int argc, char *argv[])
   gtk_init (&argc, &argv);
   empathy_gtk_init ();
 
+  add_empathy_features ();
+
   app = g_object_new (EMPATHY_TYPE_APP,
       "application-id", EMPATHY_DBUS_NAME,
       "flags", G_APPLICATION_HANDLES_COMMAND_LINE,