1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007-2010 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
20 * Travis Reitter <travis.reitter@collabora.co.uk>
24 #include "empathy-individual-manager.h"
26 #include "empathy-utils.h"
28 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
29 #include "empathy-debug.h"
31 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIndividualManager)
33 /* We just expose the $TOP_INDIVIDUALS_LEN more popular individuals as that's
34 * what the view actually care about. We just want to notify it when this list
35 * changes, not when the position of every single individual is updated. */
36 #define TOP_INDIVIDUALS_LEN 5
38 /* The constant INDIVIDUALS_COUNT_COMPRESS_FACTOR represents the number of
39 * interactions needed to be considered as 1 interaction */
40 #define INTERACTION_COUNT_COMPRESS_FACTOR 50
42 /* The constant DAY_IN_SECONDS represents the seconds in a day */
43 #define DAY_IN_SECONDS 86400
45 /* This class only stores and refs Individuals who contain an EmpathyContact.
47 * This class merely forwards along signals from the aggregator and individuals
48 * and wraps aggregator functions for other client code. */
51 FolksIndividualAggregator *aggregator;
52 GHashTable *individuals; /* Individual.id -> Individual */
53 gboolean contacts_loaded;
55 /* reffed FolksIndividual sorted by popularity (most popular first) */
56 GSequence *individuals_pop;
57 /* The TOP_INDIVIDUALS_LEN first FolksIndividual (borrowed) from
59 GList *top_individuals;
60 guint global_interaction_counter;
61 } EmpathyIndividualManagerPriv;
65 PROP_TOP_INDIVIDUALS = 1,
78 static guint signals[LAST_SIGNAL] = { 0 };
80 G_DEFINE_TYPE (EmpathyIndividualManager, empathy_individual_manager,
83 static EmpathyIndividualManager *manager_singleton = NULL;
86 individual_manager_get_property (GObject *object,
91 EmpathyIndividualManager *self = EMPATHY_INDIVIDUAL_MANAGER (object);
92 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
96 case PROP_TOP_INDIVIDUALS:
97 g_value_set_pointer (value, priv->top_individuals);
99 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
105 individual_group_changed_cb (FolksIndividual *individual,
108 EmpathyIndividualManager *self)
110 g_signal_emit (self, signals[GROUPS_CHANGED], 0, individual, group,
115 individual_notify_is_favourite_cb (FolksIndividual *individual,
117 EmpathyIndividualManager *self)
119 gboolean is_favourite = folks_favourite_details_get_is_favourite (
120 FOLKS_FAVOURITE_DETAILS (individual));
121 g_signal_emit (self, signals[FAVOURITES_CHANGED], 0, individual,
126 /* Contacts that have been interacted with within the last 30 days and have
127 * have an interaction count > INTERACTION_COUNT_COMPRESS_FACTOR have a
128 * popularity value of the count/INTERACTION_COUNT_COMPRESS_FACTOR */
130 compute_popularity (FolksIndividual *individual)
132 FolksInteractionDetails *details = FOLKS_INTERACTION_DETAILS (individual);
134 guint current_timestamp, count;
137 last = folks_interaction_details_get_last_im_interaction_datetime (details);
141 /* Convert g_get_real_time () fro microseconds to seconds */
142 current_timestamp = g_get_real_time () / 1000000;
143 timediff = current_timestamp - g_date_time_to_unix (last);
145 if (timediff / DAY_IN_SECONDS > 30)
148 count = folks_interaction_details_get_im_interaction_count (details);
149 count = count / INTERACTION_COUNT_COMPRESS_FACTOR;
157 check_top_individuals (EmpathyIndividualManager *self)
159 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
161 GList *l, *new_list = NULL;
162 gboolean modified = FALSE;
165 iter = g_sequence_get_begin_iter (priv->individuals_pop);
166 l = priv->top_individuals;
168 /* Check if the TOP_INDIVIDUALS_LEN first individuals in individuals_pop are
169 * still the same as the ones in top_individuals */
170 for (i = 0; i < TOP_INDIVIDUALS_LEN && !g_sequence_iter_is_end (iter); i++)
172 FolksIndividual *individual = g_sequence_get (iter);
175 /* Don't include individual having 0 as pop */
176 pop = compute_popularity (individual);
184 /* Old list is shorter than the new one */
189 modified = (individual != l->data);
195 new_list = g_list_prepend (new_list, individual);
197 iter = g_sequence_iter_next (iter);
200 g_list_free (priv->top_individuals);
201 priv->top_individuals = g_list_reverse (new_list);
205 DEBUG ("Top individuals changed:");
207 for (l = priv->top_individuals; l != NULL; l = g_list_next (l))
209 FolksIndividual *individual = l->data;
212 folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)),
213 compute_popularity (individual));
216 g_object_notify (G_OBJECT (self), "top-individuals");
221 compare_individual_by_pop (gconstpointer a,
227 pop_a = compute_popularity (FOLKS_INDIVIDUAL (a));
228 pop_b = compute_popularity (FOLKS_INDIVIDUAL (b));
230 return pop_b - pop_a;
234 individual_notify_im_interaction_count (FolksIndividual *individual,
236 EmpathyIndividualManager *self)
238 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
240 /* We don't use g_sequence_sort_changed() because we'll first have to find
241 * the iter of @individual using g_sequence_lookup() but the lookup function
242 * won't work as it assumes that the sequence is sorted which is no longer
243 * the case at this point as @individual's popularity just changed. */
244 g_sequence_sort (priv->individuals_pop, compare_individual_by_pop, NULL);
246 /* Only check for top individuals after 10 interaction events happen */
247 if (priv->global_interaction_counter % 10 == 0)
248 check_top_individuals (self);
249 priv->global_interaction_counter++;
253 add_individual (EmpathyIndividualManager *self, FolksIndividual *individual)
255 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
257 g_hash_table_insert (priv->individuals,
258 g_strdup (folks_individual_get_id (individual)),
259 g_object_ref (individual));
261 g_sequence_insert_sorted (priv->individuals_pop, g_object_ref (individual),
262 compare_individual_by_pop, NULL);
263 check_top_individuals (self);
265 g_signal_connect (individual, "group-changed",
266 G_CALLBACK (individual_group_changed_cb), self);
267 g_signal_connect (individual, "notify::is-favourite",
268 G_CALLBACK (individual_notify_is_favourite_cb), self);
269 g_signal_connect (individual, "notify::im-interaction-count",
270 G_CALLBACK (individual_notify_im_interaction_count), self);
274 remove_individual (EmpathyIndividualManager *self, FolksIndividual *individual)
276 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
279 iter = g_sequence_lookup (priv->individuals_pop, individual,
280 compare_individual_by_pop, NULL);
283 /* priv->top_individuals borrows its reference from
284 * priv->individuals_pop so we take a reference on the individual while
285 * removing it to make sure it stays alive while calling
286 * check_top_individuals(). */
287 g_object_ref (individual);
288 g_sequence_remove (iter);
289 check_top_individuals (self);
290 g_object_unref (individual);
293 g_signal_handlers_disconnect_by_func (individual,
294 individual_group_changed_cb, self);
295 g_signal_handlers_disconnect_by_func (individual,
296 individual_notify_is_favourite_cb, self);
297 g_signal_handlers_disconnect_by_func (individual,
298 individual_notify_im_interaction_count, self);
300 g_hash_table_remove (priv->individuals, folks_individual_get_id (individual));
303 /* This is emitted for *all* individuals in the individual aggregator (not
304 * just the ones we keep a reference to), to allow for the case where a new
305 * individual doesn't contain an EmpathyContact, but later has a persona added
308 individual_notify_personas_cb (FolksIndividual *individual,
310 EmpathyIndividualManager *self)
312 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
314 const gchar *id = folks_individual_get_id (individual);
315 gboolean has_contact = empathy_folks_individual_contains_contact (individual);
316 gboolean had_contact = (g_hash_table_lookup (priv->individuals,
317 id) != NULL) ? TRUE : FALSE;
319 if (had_contact == TRUE && has_contact == FALSE)
321 GList *removed = NULL;
323 /* The Individual has lost its EmpathyContact */
324 removed = g_list_prepend (removed, individual);
325 g_signal_emit (self, signals[MEMBERS_CHANGED], 0, NULL, NULL, removed,
326 TP_CHANNEL_GROUP_CHANGE_REASON_NONE /* FIXME */);
327 g_list_free (removed);
329 remove_individual (self, individual);
331 else if (had_contact == FALSE && has_contact == TRUE)
335 /* The Individual has gained its first EmpathyContact */
336 add_individual (self, individual);
338 added = g_list_prepend (added, individual);
339 g_signal_emit (self, signals[MEMBERS_CHANGED], 0, NULL, added, NULL,
340 TP_CHANNEL_GROUP_CHANGE_REASON_NONE /* FIXME */);
346 aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator,
347 GeeMultiMap *changes,
348 EmpathyIndividualManager *self)
350 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
353 GeeCollection *added;
354 GList *added_set = NULL, *added_filtered = NULL, *removed_list = NULL;
356 /* We're not interested in the relationships between the added and removed
357 * individuals, so just extract collections of them. Note that the added
358 * collection may contain duplicates, while the removed set won't. */
359 removed = gee_multi_map_get_keys (changes);
360 added = gee_multi_map_get_values (changes);
362 /* Handle the removals first, as one of the added Individuals might have the
363 * same ID as one of the removed Individuals (due to linking). */
364 iter = gee_iterable_iterator (GEE_ITERABLE (removed));
365 while (gee_iterator_next (iter))
367 FolksIndividual *ind = gee_iterator_get (iter);
372 g_signal_handlers_disconnect_by_func (ind,
373 individual_notify_personas_cb, self);
375 if (g_hash_table_lookup (priv->individuals,
376 folks_individual_get_id (ind)) != NULL)
378 remove_individual (self, ind);
379 removed_list = g_list_prepend (removed_list, ind);
382 g_clear_object (&ind);
384 g_clear_object (&iter);
386 /* Filter the individuals for ones which contain EmpathyContacts */
387 iter = gee_iterable_iterator (GEE_ITERABLE (added));
388 while (gee_iterator_next (iter))
390 FolksIndividual *ind = gee_iterator_get (iter);
392 /* Make sure we handle each added individual only once. */
393 if (ind == NULL || g_list_find (added_set, ind) != NULL)
395 added_set = g_list_prepend (added_set, ind);
397 g_signal_connect (ind, "notify::personas",
398 G_CALLBACK (individual_notify_personas_cb), self);
400 if (empathy_folks_individual_contains_contact (ind) == TRUE)
402 add_individual (self, ind);
403 added_filtered = g_list_prepend (added_filtered, ind);
406 g_clear_object (&ind);
408 g_clear_object (&iter);
410 g_list_free (added_set);
412 g_object_unref (added);
413 g_object_unref (removed);
415 /* Bail if we have no individuals left */
416 if (added_filtered == NULL && removed == NULL)
419 added_filtered = g_list_reverse (added_filtered);
421 g_signal_emit (self, signals[MEMBERS_CHANGED], 0, NULL,
422 added_filtered, removed_list,
423 TP_CHANNEL_GROUP_CHANGE_REASON_NONE,
426 g_list_free (added_filtered);
427 g_list_free (removed_list);
431 individual_manager_dispose (GObject *object)
433 EmpathyIndividualManagerPriv *priv = GET_PRIV (object);
435 g_hash_table_unref (priv->individuals);
437 tp_clear_object (&priv->aggregator);
439 G_OBJECT_CLASS (empathy_individual_manager_parent_class)->dispose (object);
443 individual_manager_finalize (GObject *object)
445 EmpathyIndividualManagerPriv *priv = GET_PRIV (object);
447 g_sequence_free (priv->individuals_pop);
449 G_OBJECT_CLASS (empathy_individual_manager_parent_class)->finalize (object);
453 individual_manager_constructor (GType type,
455 GObjectConstructParam *props)
459 if (manager_singleton)
461 retval = g_object_ref (manager_singleton);
466 G_OBJECT_CLASS (empathy_individual_manager_parent_class)->
467 constructor (type, n_props, props);
469 manager_singleton = EMPATHY_INDIVIDUAL_MANAGER (retval);
470 g_object_add_weak_pointer (retval, (gpointer) & manager_singleton);
477 * empathy_individual_manager_initialized:
479 * Reports whether or not the singleton has already been created.
481 * There can be instances where you want to access the #EmpathyIndividualManager
482 * only if it has been set up for this process.
484 * Returns: %TRUE if the #EmpathyIndividualManager singleton has previously
488 empathy_individual_manager_initialized (void)
490 return (manager_singleton != NULL);
494 empathy_individual_manager_class_init (EmpathyIndividualManagerClass *klass)
496 GObjectClass *object_class = G_OBJECT_CLASS (klass);
499 object_class->get_property = individual_manager_get_property;
500 object_class->dispose = individual_manager_dispose;
501 object_class->finalize = individual_manager_finalize;
502 object_class->constructor = individual_manager_constructor;
504 spec = g_param_spec_pointer ("top-individuals", "top individuals",
506 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
507 g_object_class_install_property (object_class, PROP_TOP_INDIVIDUALS, spec);
509 signals[GROUPS_CHANGED] =
510 g_signal_new ("groups-changed",
511 G_TYPE_FROM_CLASS (klass),
515 g_cclosure_marshal_generic,
516 G_TYPE_NONE, 3, FOLKS_TYPE_INDIVIDUAL, G_TYPE_STRING, G_TYPE_BOOLEAN);
518 signals[FAVOURITES_CHANGED] =
519 g_signal_new ("favourites-changed",
520 G_TYPE_FROM_CLASS (klass),
524 g_cclosure_marshal_generic,
525 G_TYPE_NONE, 2, FOLKS_TYPE_INDIVIDUAL, G_TYPE_BOOLEAN);
527 signals[MEMBERS_CHANGED] =
528 g_signal_new ("members-changed",
529 G_TYPE_FROM_CLASS (klass),
533 g_cclosure_marshal_generic,
535 4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_UINT);
537 signals[CONTACTS_LOADED] =
538 g_signal_new ("contacts-loaded",
539 G_TYPE_FROM_CLASS (klass),
543 g_cclosure_marshal_generic,
547 g_type_class_add_private (object_class,
548 sizeof (EmpathyIndividualManagerPriv));
552 aggregator_is_quiescent_notify_cb (FolksIndividualAggregator *aggregator,
554 EmpathyIndividualManager *self)
556 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
557 gboolean is_quiescent;
559 if (priv->contacts_loaded)
562 g_object_get (aggregator, "is-quiescent", &is_quiescent, NULL);
567 priv->contacts_loaded = TRUE;
569 g_signal_emit (self, signals[CONTACTS_LOADED], 0);
573 empathy_individual_manager_init (EmpathyIndividualManager *self)
575 EmpathyIndividualManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
576 EMPATHY_TYPE_INDIVIDUAL_MANAGER, EmpathyIndividualManagerPriv);
579 priv->individuals = g_hash_table_new_full (g_str_hash, g_str_equal,
580 g_free, g_object_unref);
582 priv->individuals_pop = g_sequence_new (g_object_unref);
584 priv->aggregator = folks_individual_aggregator_new ();
585 tp_g_signal_connect_object (priv->aggregator, "individuals-changed-detailed",
586 G_CALLBACK (aggregator_individuals_changed_cb), self, 0);
587 tp_g_signal_connect_object (priv->aggregator, "notify::is-quiescent",
588 G_CALLBACK (aggregator_is_quiescent_notify_cb), self, 0);
589 folks_individual_aggregator_prepare (priv->aggregator, NULL, NULL);
592 EmpathyIndividualManager *
593 empathy_individual_manager_dup_singleton (void)
595 return g_object_new (EMPATHY_TYPE_INDIVIDUAL_MANAGER, NULL);
599 empathy_individual_manager_get_members (EmpathyIndividualManager *self)
601 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
603 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self), NULL);
605 return g_hash_table_get_values (priv->individuals);
609 empathy_individual_manager_lookup_member (EmpathyIndividualManager *self,
612 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
614 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self), NULL);
616 return g_hash_table_lookup (priv->individuals, id);
620 aggregator_add_persona_from_details_cb (GObject *source,
621 GAsyncResult *result,
624 FolksIndividualAggregator *aggregator = FOLKS_INDIVIDUAL_AGGREGATOR (source);
625 EmpathyContact *contact = EMPATHY_CONTACT (user_data);
626 FolksPersona *persona;
627 GError *error = NULL;
629 persona = folks_individual_aggregator_add_persona_from_details_finish (
630 aggregator, result, &error);
633 g_warning ("failed to add individual from contact: %s", error->message);
634 g_clear_error (&error);
637 /* The persona can be NULL even if there wasn't an error, if the persona was
638 * already in the contact list */
641 /* Set the contact's persona */
642 empathy_contact_set_persona (contact, persona);
643 g_object_unref (persona);
646 g_object_unref (contact);
650 empathy_individual_manager_add_from_contact (EmpathyIndividualManager *self,
651 EmpathyContact *contact)
653 EmpathyIndividualManagerPriv *priv;
654 FolksBackendStore *backend_store;
655 FolksBackend *backend;
656 FolksPersonaStore *persona_store;
658 GeeMap *persona_stores;
660 const gchar *store_id;
662 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self));
663 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
665 priv = GET_PRIV (self);
667 /* We need to ref the contact since otherwise its linked TpHandle will be
669 g_object_ref (contact);
671 DEBUG ("adding individual from contact %s (%s)",
672 empathy_contact_get_id (contact), empathy_contact_get_alias (contact));
674 account = empathy_contact_get_account (contact);
675 store_id = tp_proxy_get_object_path (TP_PROXY (account));
677 /* Get the persona store to use */
678 backend_store = folks_backend_store_dup ();
680 folks_backend_store_dup_backend_by_name (backend_store, "telepathy");
684 g_warning ("Failed to add individual from contact: couldn't get "
685 "'telepathy' backend");
689 persona_stores = folks_backend_get_persona_stores (backend);
690 persona_store = gee_map_get (persona_stores, store_id);
692 if (persona_store == NULL)
694 g_warning ("Failed to add individual from contact: couldn't get persona "
695 "store '%s'", store_id);
699 details = tp_asv_new (
700 "contact", G_TYPE_STRING, empathy_contact_get_id (contact),
703 folks_individual_aggregator_add_persona_from_details (
704 priv->aggregator, NULL, persona_store, details,
705 aggregator_add_persona_from_details_cb, contact);
707 g_hash_table_unref (details);
708 g_object_unref (persona_store);
711 tp_clear_object (&backend);
712 tp_clear_object (&backend_store);
716 aggregator_remove_individual_cb (GObject *source,
717 GAsyncResult *result,
720 FolksIndividualAggregator *aggregator = FOLKS_INDIVIDUAL_AGGREGATOR (source);
721 GError *error = NULL;
723 folks_individual_aggregator_remove_individual_finish (
724 aggregator, result, &error);
727 g_warning ("failed to remove individual: %s", error->message);
728 g_clear_error (&error);
733 * Removes the inner contact from the server (and thus the Individual). Not
734 * meant for de-shelling inner personas from an Individual.
737 empathy_individual_manager_remove (EmpathyIndividualManager *self,
738 FolksIndividual *individual,
739 const gchar *message)
741 EmpathyIndividualManagerPriv *priv;
743 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self));
744 g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual));
746 priv = GET_PRIV (self);
748 DEBUG ("removing individual %s (%s)",
749 folks_individual_get_id (individual),
750 folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));
752 folks_individual_aggregator_remove_individual (priv->aggregator, individual,
753 aggregator_remove_individual_cb, self);
756 /* FIXME: The parameter @self is not required and the method can be placed in
757 * utilities. I left it as it is to stay coherent with empathy-2.34 */
759 * empathy_individual_manager_supports_blocking
760 * @self: the #EmpathyIndividualManager
761 * @individual: an individual to check
763 * Indicates whether any personas of an @individual can be blocked.
765 * Returns: %TRUE if any persona supports contact blocking
768 empathy_individual_manager_supports_blocking (EmpathyIndividualManager *self,
769 FolksIndividual *individual)
773 gboolean retval = FALSE;
775 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self), FALSE);
777 personas = folks_individual_get_personas (individual);
778 iter = gee_iterable_iterator (GEE_ITERABLE (personas));
779 while (!retval && gee_iterator_next (iter))
781 TpfPersona *persona = gee_iterator_get (iter);
784 if (TPF_IS_PERSONA (persona))
786 TpContact *tp_contact;
788 tp_contact = tpf_persona_get_contact (persona);
789 if (tp_contact != NULL)
791 conn = tp_contact_get_connection (tp_contact);
793 if (tp_proxy_has_interface_by_id (conn,
794 TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING))
798 g_clear_object (&persona);
800 g_clear_object (&iter);
806 empathy_individual_manager_set_blocked (EmpathyIndividualManager *self,
807 FolksIndividual *individual,
814 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self));
816 personas = folks_individual_get_personas (individual);
817 iter = gee_iterable_iterator (GEE_ITERABLE (personas));
818 while (gee_iterator_next (iter))
820 TpfPersona *persona = gee_iterator_get (iter);
822 if (TPF_IS_PERSONA (persona))
824 TpContact *tp_contact;
827 tp_contact = tpf_persona_get_contact (persona);
828 if (tp_contact == NULL)
831 conn = tp_contact_get_connection (tp_contact);
833 if (!tp_proxy_has_interface_by_id (conn,
834 TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING))
838 tp_contact_block_async (tp_contact, abusive, NULL, NULL);
840 tp_contact_unblock_async (tp_contact, NULL, NULL);
842 g_clear_object (&persona);
844 g_clear_object (&iter);
848 groups_change_group_cb (GObject *source,
849 GAsyncResult *result,
852 FolksGroupDetails *group_details = FOLKS_GROUP_DETAILS (source);
853 GError *error = NULL;
855 folks_group_details_change_group_finish (group_details, result, &error);
858 g_warning ("failed to change group: %s", error->message);
859 g_clear_error (&error);
864 remove_group_cb (const gchar *id,
865 FolksIndividual *individual,
868 folks_group_details_change_group (FOLKS_GROUP_DETAILS (individual), group,
869 FALSE, groups_change_group_cb, NULL);
873 empathy_individual_manager_remove_group (EmpathyIndividualManager *manager,
876 EmpathyIndividualManagerPriv *priv;
878 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager));
879 g_return_if_fail (group != NULL);
881 priv = GET_PRIV (manager);
883 DEBUG ("removing group %s", group);
885 /* Remove every individual from the group */
886 g_hash_table_foreach (priv->individuals, (GHFunc) remove_group_cb,
891 empathy_individual_manager_get_contacts_loaded (EmpathyIndividualManager *self)
893 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
895 return priv->contacts_loaded;
899 empathy_individual_manager_get_top_individuals (EmpathyIndividualManager *self)
901 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
903 return priv->top_individuals;
907 unprepare_cb (GObject *source,
908 GAsyncResult *result,
911 GError *error = NULL;
912 GSimpleAsyncResult *my_result = user_data;
914 folks_individual_aggregator_unprepare_finish (
915 FOLKS_INDIVIDUAL_AGGREGATOR (source), result, &error);
919 DEBUG ("Failed to unprepare the aggregator: %s", error->message);
920 g_simple_async_result_take_error (my_result, error);
923 g_simple_async_result_complete (my_result);
924 g_object_unref (my_result);
928 empathy_individual_manager_unprepare_async (
929 EmpathyIndividualManager *self,
930 GAsyncReadyCallback callback,
933 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
934 GSimpleAsyncResult *result;
936 result = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
937 empathy_individual_manager_unprepare_async);
939 folks_individual_aggregator_unprepare (priv->aggregator, unprepare_cb,
944 empathy_individual_manager_unprepare_finish (
945 EmpathyIndividualManager *self,
946 GAsyncResult *result,
949 empathy_implement_finish_void (self,
950 empathy_individual_manager_unprepare_async)