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 <tp-account-widgets/tpaw-utils.h>
28 #include "empathy-utils.h"
30 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
31 #include "empathy-debug.h"
33 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIndividualManager)
35 /* We just expose the $TOP_INDIVIDUALS_LEN more popular individuals as that's
36 * what the view actually care about. We just want to notify it when this list
37 * changes, not when the position of every single individual is updated. */
38 #define TOP_INDIVIDUALS_LEN 5
40 /* The constant INDIVIDUALS_COUNT_COMPRESS_FACTOR represents the number of
41 * interactions needed to be considered as 1 interaction */
42 #define INTERACTION_COUNT_COMPRESS_FACTOR 50
44 /* The constant DAY_IN_SECONDS represents the seconds in a day */
45 #define DAY_IN_SECONDS 86400
47 /* This class only stores and refs Individuals who contain an EmpathyContact.
49 * This class merely forwards along signals from the aggregator and individuals
50 * and wraps aggregator functions for other client code. */
53 FolksIndividualAggregator *aggregator;
54 GHashTable *individuals; /* Individual.id -> Individual */
55 gboolean contacts_loaded;
57 /* reffed FolksIndividual sorted by popularity (most popular first) */
58 GSequence *individuals_pop;
59 /* The TOP_INDIVIDUALS_LEN first FolksIndividual (borrowed) from
61 GList *top_individuals;
62 guint global_interaction_counter;
63 } EmpathyIndividualManagerPriv;
67 PROP_TOP_INDIVIDUALS = 1,
80 static guint signals[LAST_SIGNAL] = { 0 };
82 G_DEFINE_TYPE (EmpathyIndividualManager, empathy_individual_manager,
85 static EmpathyIndividualManager *manager_singleton = NULL;
88 individual_manager_get_property (GObject *object,
93 EmpathyIndividualManager *self = EMPATHY_INDIVIDUAL_MANAGER (object);
94 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
98 case PROP_TOP_INDIVIDUALS:
99 g_value_set_pointer (value, priv->top_individuals);
101 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
107 individual_group_changed_cb (FolksIndividual *individual,
110 EmpathyIndividualManager *self)
112 g_signal_emit (self, signals[GROUPS_CHANGED], 0, individual, group,
117 individual_notify_is_favourite_cb (FolksIndividual *individual,
119 EmpathyIndividualManager *self)
121 gboolean is_favourite = folks_favourite_details_get_is_favourite (
122 FOLKS_FAVOURITE_DETAILS (individual));
123 g_signal_emit (self, signals[FAVOURITES_CHANGED], 0, individual,
128 /* Contacts that have been interacted with within the last 30 days and have
129 * have an interaction count > INTERACTION_COUNT_COMPRESS_FACTOR have a
130 * popularity value of the count/INTERACTION_COUNT_COMPRESS_FACTOR */
132 compute_popularity (FolksIndividual *individual)
134 FolksInteractionDetails *details = FOLKS_INTERACTION_DETAILS (individual);
136 guint current_timestamp, count;
139 last = folks_interaction_details_get_last_im_interaction_datetime (details);
143 /* Convert g_get_real_time () fro microseconds to seconds */
144 current_timestamp = g_get_real_time () / 1000000;
145 timediff = current_timestamp - g_date_time_to_unix (last);
147 if (timediff / DAY_IN_SECONDS > 30)
150 count = folks_interaction_details_get_im_interaction_count (details);
151 count = count / INTERACTION_COUNT_COMPRESS_FACTOR;
159 check_top_individuals (EmpathyIndividualManager *self)
161 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
163 GList *l, *new_list = NULL;
164 gboolean modified = FALSE;
167 iter = g_sequence_get_begin_iter (priv->individuals_pop);
168 l = priv->top_individuals;
170 /* Check if the TOP_INDIVIDUALS_LEN first individuals in individuals_pop are
171 * still the same as the ones in top_individuals */
172 for (i = 0; i < TOP_INDIVIDUALS_LEN && !g_sequence_iter_is_end (iter); i++)
174 FolksIndividual *individual = g_sequence_get (iter);
177 /* Don't include individual having 0 as pop */
178 pop = compute_popularity (individual);
186 /* Old list is shorter than the new one */
191 modified = (individual != l->data);
197 new_list = g_list_prepend (new_list, individual);
199 iter = g_sequence_iter_next (iter);
202 g_list_free (priv->top_individuals);
203 priv->top_individuals = g_list_reverse (new_list);
207 DEBUG ("Top individuals changed:");
209 for (l = priv->top_individuals; l != NULL; l = g_list_next (l))
211 FolksIndividual *individual = l->data;
214 folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)),
215 compute_popularity (individual));
218 g_object_notify (G_OBJECT (self), "top-individuals");
223 compare_individual_by_pop (gconstpointer a,
229 pop_a = compute_popularity (FOLKS_INDIVIDUAL (a));
230 pop_b = compute_popularity (FOLKS_INDIVIDUAL (b));
232 return pop_b - pop_a;
236 individual_notify_im_interaction_count (FolksIndividual *individual,
238 EmpathyIndividualManager *self)
240 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
242 /* We don't use g_sequence_sort_changed() because we'll first have to find
243 * the iter of @individual using g_sequence_lookup() but the lookup function
244 * won't work as it assumes that the sequence is sorted which is no longer
245 * the case at this point as @individual's popularity just changed. */
246 g_sequence_sort (priv->individuals_pop, compare_individual_by_pop, NULL);
248 /* Only check for top individuals after 10 interaction events happen */
249 if (priv->global_interaction_counter % 10 == 0)
250 check_top_individuals (self);
251 priv->global_interaction_counter++;
255 add_individual (EmpathyIndividualManager *self, FolksIndividual *individual)
257 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
259 g_hash_table_insert (priv->individuals,
260 g_strdup (folks_individual_get_id (individual)),
261 g_object_ref (individual));
263 g_sequence_insert_sorted (priv->individuals_pop, g_object_ref (individual),
264 compare_individual_by_pop, NULL);
265 check_top_individuals (self);
267 g_signal_connect (individual, "group-changed",
268 G_CALLBACK (individual_group_changed_cb), self);
269 g_signal_connect (individual, "notify::is-favourite",
270 G_CALLBACK (individual_notify_is_favourite_cb), self);
271 g_signal_connect (individual, "notify::im-interaction-count",
272 G_CALLBACK (individual_notify_im_interaction_count), self);
276 remove_individual (EmpathyIndividualManager *self, FolksIndividual *individual)
278 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
281 iter = g_sequence_lookup (priv->individuals_pop, individual,
282 compare_individual_by_pop, NULL);
285 /* priv->top_individuals borrows its reference from
286 * priv->individuals_pop so we take a reference on the individual while
287 * removing it to make sure it stays alive while calling
288 * check_top_individuals(). */
289 g_object_ref (individual);
290 g_sequence_remove (iter);
291 check_top_individuals (self);
292 g_object_unref (individual);
295 g_signal_handlers_disconnect_by_func (individual,
296 individual_group_changed_cb, self);
297 g_signal_handlers_disconnect_by_func (individual,
298 individual_notify_is_favourite_cb, self);
299 g_signal_handlers_disconnect_by_func (individual,
300 individual_notify_im_interaction_count, self);
302 g_hash_table_remove (priv->individuals, folks_individual_get_id (individual));
305 /* This is emitted for *all* individuals in the individual aggregator (not
306 * just the ones we keep a reference to), to allow for the case where a new
307 * individual doesn't contain an EmpathyContact, but later has a persona added
310 individual_notify_personas_cb (FolksIndividual *individual,
312 EmpathyIndividualManager *self)
314 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
316 const gchar *id = folks_individual_get_id (individual);
317 gboolean has_contact = empathy_folks_individual_contains_contact (individual);
318 gboolean had_contact = (g_hash_table_lookup (priv->individuals,
319 id) != NULL) ? TRUE : FALSE;
321 if (had_contact == TRUE && has_contact == FALSE)
323 GList *removed = NULL;
325 /* The Individual has lost its EmpathyContact */
326 removed = g_list_prepend (removed, individual);
327 g_signal_emit (self, signals[MEMBERS_CHANGED], 0, NULL, NULL, removed,
328 TP_CHANNEL_GROUP_CHANGE_REASON_NONE /* FIXME */);
329 g_list_free (removed);
331 remove_individual (self, individual);
333 else if (had_contact == FALSE && has_contact == TRUE)
337 /* The Individual has gained its first EmpathyContact */
338 add_individual (self, individual);
340 added = g_list_prepend (added, individual);
341 g_signal_emit (self, signals[MEMBERS_CHANGED], 0, NULL, added, NULL,
342 TP_CHANNEL_GROUP_CHANGE_REASON_NONE /* FIXME */);
348 aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator,
349 GeeMultiMap *changes,
350 EmpathyIndividualManager *self)
352 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
355 GeeCollection *added;
356 GList *added_set = NULL, *added_filtered = NULL, *removed_list = NULL;
358 /* We're not interested in the relationships between the added and removed
359 * individuals, so just extract collections of them. Note that the added
360 * collection may contain duplicates, while the removed set won't. */
361 removed = gee_multi_map_get_keys (changes);
362 added = gee_multi_map_get_values (changes);
364 /* Handle the removals first, as one of the added Individuals might have the
365 * same ID as one of the removed Individuals (due to linking). */
366 iter = gee_iterable_iterator (GEE_ITERABLE (removed));
367 while (gee_iterator_next (iter))
369 FolksIndividual *ind = gee_iterator_get (iter);
374 g_signal_handlers_disconnect_by_func (ind,
375 individual_notify_personas_cb, self);
377 if (g_hash_table_lookup (priv->individuals,
378 folks_individual_get_id (ind)) != NULL)
380 remove_individual (self, ind);
381 removed_list = g_list_prepend (removed_list, ind);
384 g_clear_object (&ind);
386 g_clear_object (&iter);
388 /* Filter the individuals for ones which contain EmpathyContacts */
389 iter = gee_iterable_iterator (GEE_ITERABLE (added));
390 while (gee_iterator_next (iter))
392 FolksIndividual *ind = gee_iterator_get (iter);
394 /* Make sure we handle each added individual only once. */
395 if (ind == NULL || g_list_find (added_set, ind) != NULL)
397 added_set = g_list_prepend (added_set, ind);
399 g_signal_connect (ind, "notify::personas",
400 G_CALLBACK (individual_notify_personas_cb), self);
402 if (empathy_folks_individual_contains_contact (ind) == TRUE)
404 add_individual (self, ind);
405 added_filtered = g_list_prepend (added_filtered, ind);
408 g_clear_object (&ind);
410 g_clear_object (&iter);
412 g_list_free (added_set);
414 g_object_unref (added);
415 g_object_unref (removed);
417 /* Bail if we have no individuals left */
418 if (added_filtered == NULL && removed == NULL)
421 added_filtered = g_list_reverse (added_filtered);
423 g_signal_emit (self, signals[MEMBERS_CHANGED], 0, NULL,
424 added_filtered, removed_list,
425 TP_CHANNEL_GROUP_CHANGE_REASON_NONE,
428 g_list_free (added_filtered);
429 g_list_free (removed_list);
433 individual_manager_dispose (GObject *object)
435 EmpathyIndividualManagerPriv *priv = GET_PRIV (object);
437 g_hash_table_unref (priv->individuals);
439 tp_clear_object (&priv->aggregator);
441 G_OBJECT_CLASS (empathy_individual_manager_parent_class)->dispose (object);
445 individual_manager_finalize (GObject *object)
447 EmpathyIndividualManagerPriv *priv = GET_PRIV (object);
449 g_sequence_free (priv->individuals_pop);
451 G_OBJECT_CLASS (empathy_individual_manager_parent_class)->finalize (object);
455 individual_manager_constructor (GType type,
457 GObjectConstructParam *props)
461 if (manager_singleton)
463 retval = g_object_ref (manager_singleton);
468 G_OBJECT_CLASS (empathy_individual_manager_parent_class)->
469 constructor (type, n_props, props);
471 manager_singleton = EMPATHY_INDIVIDUAL_MANAGER (retval);
472 g_object_add_weak_pointer (retval, (gpointer) & manager_singleton);
479 * empathy_individual_manager_initialized:
481 * Reports whether or not the singleton has already been created.
483 * There can be instances where you want to access the #EmpathyIndividualManager
484 * only if it has been set up for this process.
486 * Returns: %TRUE if the #EmpathyIndividualManager singleton has previously
490 empathy_individual_manager_initialized (void)
492 return (manager_singleton != NULL);
496 empathy_individual_manager_class_init (EmpathyIndividualManagerClass *klass)
498 GObjectClass *object_class = G_OBJECT_CLASS (klass);
501 object_class->get_property = individual_manager_get_property;
502 object_class->dispose = individual_manager_dispose;
503 object_class->finalize = individual_manager_finalize;
504 object_class->constructor = individual_manager_constructor;
506 spec = g_param_spec_pointer ("top-individuals", "top individuals",
508 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
509 g_object_class_install_property (object_class, PROP_TOP_INDIVIDUALS, spec);
511 signals[GROUPS_CHANGED] =
512 g_signal_new ("groups-changed",
513 G_TYPE_FROM_CLASS (klass),
517 g_cclosure_marshal_generic,
518 G_TYPE_NONE, 3, FOLKS_TYPE_INDIVIDUAL, G_TYPE_STRING, G_TYPE_BOOLEAN);
520 signals[FAVOURITES_CHANGED] =
521 g_signal_new ("favourites-changed",
522 G_TYPE_FROM_CLASS (klass),
526 g_cclosure_marshal_generic,
527 G_TYPE_NONE, 2, FOLKS_TYPE_INDIVIDUAL, G_TYPE_BOOLEAN);
529 signals[MEMBERS_CHANGED] =
530 g_signal_new ("members-changed",
531 G_TYPE_FROM_CLASS (klass),
535 g_cclosure_marshal_generic,
537 4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_UINT);
539 signals[CONTACTS_LOADED] =
540 g_signal_new ("contacts-loaded",
541 G_TYPE_FROM_CLASS (klass),
545 g_cclosure_marshal_generic,
549 g_type_class_add_private (object_class,
550 sizeof (EmpathyIndividualManagerPriv));
554 aggregator_is_quiescent_notify_cb (FolksIndividualAggregator *aggregator,
556 EmpathyIndividualManager *self)
558 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
559 gboolean is_quiescent;
561 if (priv->contacts_loaded)
564 g_object_get (aggregator, "is-quiescent", &is_quiescent, NULL);
569 priv->contacts_loaded = TRUE;
571 g_signal_emit (self, signals[CONTACTS_LOADED], 0);
575 empathy_individual_manager_init (EmpathyIndividualManager *self)
577 EmpathyIndividualManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
578 EMPATHY_TYPE_INDIVIDUAL_MANAGER, EmpathyIndividualManagerPriv);
581 priv->individuals = g_hash_table_new_full (g_str_hash, g_str_equal,
582 g_free, g_object_unref);
584 priv->individuals_pop = g_sequence_new (g_object_unref);
586 priv->aggregator = folks_individual_aggregator_new ();
587 tp_g_signal_connect_object (priv->aggregator, "individuals-changed-detailed",
588 G_CALLBACK (aggregator_individuals_changed_cb), self, 0);
589 tp_g_signal_connect_object (priv->aggregator, "notify::is-quiescent",
590 G_CALLBACK (aggregator_is_quiescent_notify_cb), self, 0);
591 folks_individual_aggregator_prepare (priv->aggregator, NULL, NULL);
594 EmpathyIndividualManager *
595 empathy_individual_manager_dup_singleton (void)
597 return g_object_new (EMPATHY_TYPE_INDIVIDUAL_MANAGER, NULL);
601 empathy_individual_manager_get_members (EmpathyIndividualManager *self)
603 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
605 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self), NULL);
607 return g_hash_table_get_values (priv->individuals);
611 empathy_individual_manager_lookup_member (EmpathyIndividualManager *self,
614 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
616 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self), NULL);
618 return g_hash_table_lookup (priv->individuals, id);
622 aggregator_add_persona_from_details_cb (GObject *source,
623 GAsyncResult *result,
626 FolksIndividualAggregator *aggregator = FOLKS_INDIVIDUAL_AGGREGATOR (source);
627 EmpathyContact *contact = EMPATHY_CONTACT (user_data);
628 FolksPersona *persona;
629 GError *error = NULL;
631 persona = folks_individual_aggregator_add_persona_from_details_finish (
632 aggregator, result, &error);
635 g_warning ("failed to add individual from contact: %s", error->message);
636 g_clear_error (&error);
639 /* The persona can be NULL even if there wasn't an error, if the persona was
640 * already in the contact list */
643 /* Set the contact's persona */
644 empathy_contact_set_persona (contact, persona);
645 g_object_unref (persona);
648 g_object_unref (contact);
652 empathy_individual_manager_add_from_contact (EmpathyIndividualManager *self,
653 EmpathyContact *contact)
655 EmpathyIndividualManagerPriv *priv;
656 FolksBackendStore *backend_store;
657 FolksBackend *backend;
658 FolksPersonaStore *persona_store;
660 GeeMap *persona_stores;
662 const gchar *store_id;
664 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self));
665 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
667 priv = GET_PRIV (self);
669 /* We need to ref the contact since otherwise its linked TpHandle will be
671 g_object_ref (contact);
673 DEBUG ("adding individual from contact %s (%s)",
674 empathy_contact_get_id (contact), empathy_contact_get_alias (contact));
676 account = empathy_contact_get_account (contact);
677 store_id = tp_proxy_get_object_path (TP_PROXY (account));
679 /* Get the persona store to use */
680 backend_store = folks_backend_store_dup ();
682 folks_backend_store_dup_backend_by_name (backend_store, "telepathy");
686 g_warning ("Failed to add individual from contact: couldn't get "
687 "'telepathy' backend");
691 persona_stores = folks_backend_get_persona_stores (backend);
692 persona_store = gee_map_get (persona_stores, store_id);
694 if (persona_store == NULL)
696 g_warning ("Failed to add individual from contact: couldn't get persona "
697 "store '%s'", store_id);
701 details = tp_asv_new (
702 "contact", G_TYPE_STRING, empathy_contact_get_id (contact),
705 folks_individual_aggregator_add_persona_from_details (
706 priv->aggregator, NULL, persona_store, details,
707 aggregator_add_persona_from_details_cb, contact);
709 g_hash_table_unref (details);
710 g_object_unref (persona_store);
713 tp_clear_object (&backend);
714 tp_clear_object (&backend_store);
718 aggregator_remove_individual_cb (GObject *source,
719 GAsyncResult *result,
722 FolksIndividualAggregator *aggregator = FOLKS_INDIVIDUAL_AGGREGATOR (source);
723 GError *error = NULL;
725 folks_individual_aggregator_remove_individual_finish (
726 aggregator, result, &error);
729 g_warning ("failed to remove individual: %s", error->message);
730 g_clear_error (&error);
735 * Removes the inner contact from the server (and thus the Individual). Not
736 * meant for de-shelling inner personas from an Individual.
739 empathy_individual_manager_remove (EmpathyIndividualManager *self,
740 FolksIndividual *individual,
741 const gchar *message)
743 EmpathyIndividualManagerPriv *priv;
745 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self));
746 g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual));
748 priv = GET_PRIV (self);
750 DEBUG ("removing individual %s (%s)",
751 folks_individual_get_id (individual),
752 folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));
754 folks_individual_aggregator_remove_individual (priv->aggregator, individual,
755 aggregator_remove_individual_cb, self);
758 /* FIXME: The parameter @self is not required and the method can be placed in
759 * utilities. I left it as it is to stay coherent with empathy-2.34 */
761 * empathy_individual_manager_supports_blocking
762 * @self: the #EmpathyIndividualManager
763 * @individual: an individual to check
765 * Indicates whether any personas of an @individual can be blocked.
767 * Returns: %TRUE if any persona supports contact blocking
770 empathy_individual_manager_supports_blocking (EmpathyIndividualManager *self,
771 FolksIndividual *individual)
775 gboolean retval = FALSE;
777 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self), FALSE);
779 personas = folks_individual_get_personas (individual);
780 iter = gee_iterable_iterator (GEE_ITERABLE (personas));
781 while (!retval && gee_iterator_next (iter))
783 TpfPersona *persona = gee_iterator_get (iter);
786 if (TPF_IS_PERSONA (persona))
788 TpContact *tp_contact;
790 tp_contact = tpf_persona_get_contact (persona);
791 if (tp_contact != NULL)
793 conn = tp_contact_get_connection (tp_contact);
795 if (tp_proxy_has_interface_by_id (conn,
796 TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING))
800 g_clear_object (&persona);
802 g_clear_object (&iter);
808 empathy_individual_manager_set_blocked (EmpathyIndividualManager *self,
809 FolksIndividual *individual,
816 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self));
818 personas = folks_individual_get_personas (individual);
819 iter = gee_iterable_iterator (GEE_ITERABLE (personas));
820 while (gee_iterator_next (iter))
822 TpfPersona *persona = gee_iterator_get (iter);
824 if (TPF_IS_PERSONA (persona))
826 TpContact *tp_contact;
829 tp_contact = tpf_persona_get_contact (persona);
830 if (tp_contact == NULL)
833 conn = tp_contact_get_connection (tp_contact);
835 if (!tp_proxy_has_interface_by_id (conn,
836 TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING))
840 tp_contact_block_async (tp_contact, abusive, NULL, NULL);
842 tp_contact_unblock_async (tp_contact, NULL, NULL);
844 g_clear_object (&persona);
846 g_clear_object (&iter);
850 groups_change_group_cb (GObject *source,
851 GAsyncResult *result,
854 FolksGroupDetails *group_details = FOLKS_GROUP_DETAILS (source);
855 GError *error = NULL;
857 folks_group_details_change_group_finish (group_details, result, &error);
860 g_warning ("failed to change group: %s", error->message);
861 g_clear_error (&error);
866 remove_group_cb (const gchar *id,
867 FolksIndividual *individual,
870 folks_group_details_change_group (FOLKS_GROUP_DETAILS (individual), group,
871 FALSE, groups_change_group_cb, NULL);
875 empathy_individual_manager_remove_group (EmpathyIndividualManager *manager,
878 EmpathyIndividualManagerPriv *priv;
880 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager));
881 g_return_if_fail (group != NULL);
883 priv = GET_PRIV (manager);
885 DEBUG ("removing group %s", group);
887 /* Remove every individual from the group */
888 g_hash_table_foreach (priv->individuals, (GHFunc) remove_group_cb,
893 empathy_individual_manager_get_contacts_loaded (EmpathyIndividualManager *self)
895 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
897 return priv->contacts_loaded;
901 empathy_individual_manager_get_top_individuals (EmpathyIndividualManager *self)
903 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
905 return priv->top_individuals;
909 unprepare_cb (GObject *source,
910 GAsyncResult *result,
913 GError *error = NULL;
914 GSimpleAsyncResult *my_result = user_data;
916 folks_individual_aggregator_unprepare_finish (
917 FOLKS_INDIVIDUAL_AGGREGATOR (source), result, &error);
921 DEBUG ("Failed to unprepare the aggregator: %s", error->message);
922 g_simple_async_result_take_error (my_result, error);
925 g_simple_async_result_complete (my_result);
926 g_object_unref (my_result);
930 empathy_individual_manager_unprepare_async (
931 EmpathyIndividualManager *self,
932 GAsyncReadyCallback callback,
935 EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
936 GSimpleAsyncResult *result;
938 result = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
939 empathy_individual_manager_unprepare_async);
941 folks_individual_aggregator_unprepare (priv->aggregator, unprepare_cb,
946 empathy_individual_manager_unprepare_finish (
947 EmpathyIndividualManager *self,
948 GAsyncResult *result,
951 tpaw_implement_finish_void (self,
952 empathy_individual_manager_unprepare_async)