1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2005-2007 Imendio AB
4 * Copyright (C) 2007-2010 Collabora Ltd.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301 USA
21 * Authors: Mikael Hallendal <micke@imendio.com>
22 * Martyn Russell <martyn@imendio.com>
23 * Xavier Claessens <xclaesse@gmail.com>
24 * Travis Reitter <travis.reitter@collabora.co.uk>
32 #include <glib/gi18n-lib.h>
35 #include <folks/folks.h>
36 #include <folks/folks-telepathy.h>
37 #include <telepathy-glib/util.h>
39 #include <libempathy/empathy-utils.h>
40 #include <libempathy/empathy-enum-types.h>
41 #include <libempathy/empathy-individual-manager.h>
43 #include "empathy-individual-store.h"
44 #include "empathy-ui-utils.h"
45 #include "empathy-gtk-enum-types.h"
47 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
48 #include <libempathy/empathy-debug.h>
50 /* Active users are those which have recently changed state
51 * (e.g. online, offline or from normal to a busy state).
54 /* Time in seconds user is shown as active */
55 #define ACTIVE_USER_SHOW_TIME 7
57 /* Time in seconds after connecting which we wait before active users are enabled */
58 #define ACTIVE_USER_WAIT_TO_ENABLE_TIME 5
60 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIndividualStore)
63 EmpathyIndividualManager *manager;
64 gboolean show_offline;
65 gboolean show_avatars;
68 gboolean show_protocols;
70 EmpathyIndividualStoreSort sort_criterium;
73 gboolean dispose_has_run;
74 GHashTable *status_icons;
75 } EmpathyIndividualStorePriv;
86 FolksIndividual *individual;
93 EmpathyIndividualStore *self;
94 FolksIndividual *individual;
101 PROP_INDIVIDUAL_MANAGER,
110 /* prototypes to break cycles */
111 static void individual_store_contact_update (EmpathyIndividualStore *self,
112 FolksIndividual *individual);
114 G_DEFINE_TYPE (EmpathyIndividualStore, empathy_individual_store,
115 GTK_TYPE_TREE_STORE);
118 add_individual_to_store (GtkTreeStore *self,
121 FolksIndividual *individual,
122 EmpathyIndividualManagerFlags flags)
124 gtk_tree_store_insert_with_values (self, iter, parent, 0,
125 EMPATHY_INDIVIDUAL_STORE_COL_NAME,
126 folks_individual_get_alias (individual),
127 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, individual,
128 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, FALSE,
129 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
130 EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL,
131 folks_individual_get_capabilities (individual) &
132 FOLKS_CAPABILITIES_FLAGS_AUDIO,
133 EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL,
134 folks_individual_get_capabilities (individual) &
135 FOLKS_CAPABILITIES_FLAGS_VIDEO,
136 EMPATHY_INDIVIDUAL_STORE_COL_FLAGS, flags,
141 individual_store_get_group_foreach (GtkTreeModel *model,
149 /* Groups are only at the top level. */
150 if (gtk_tree_path_get_depth (path) != 1)
153 gtk_tree_model_get (model, iter,
154 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &str,
155 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group, -1);
157 if (is_group && !tp_strdiff (str, fg->name))
169 individual_store_get_group (EmpathyIndividualStore *self,
171 GtkTreeIter *iter_group_to_set,
172 GtkTreeIter *iter_separator_to_set,
174 gboolean is_fake_group)
176 EmpathyIndividualStorePriv *priv;
178 GtkTreeIter iter_group;
179 GtkTreeIter iter_separator;
182 priv = GET_PRIV (self);
184 memset (&fg, 0, sizeof (fg));
188 model = GTK_TREE_MODEL (self);
189 gtk_tree_model_foreach (model,
190 (GtkTreeModelForeachFunc) individual_store_get_group_foreach, &fg);
197 gtk_tree_store_insert_with_values (GTK_TREE_STORE (self), &iter_group,
199 EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, NULL,
200 EMPATHY_INDIVIDUAL_STORE_COL_NAME, name,
201 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, TRUE,
202 EMPATHY_INDIVIDUAL_STORE_COL_IS_ACTIVE, FALSE,
203 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
204 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, is_fake_group,
207 if (iter_group_to_set)
208 *iter_group_to_set = iter_group;
210 gtk_tree_store_insert_with_values (GTK_TREE_STORE (self), &iter_separator,
212 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, TRUE,
215 if (iter_separator_to_set)
216 *iter_separator_to_set = iter_separator;
223 if (iter_group_to_set)
224 *iter_group_to_set = fg.iter;
226 iter_separator = fg.iter;
228 if (gtk_tree_model_iter_next (model, &iter_separator))
230 gboolean is_separator;
232 gtk_tree_model_get (model, &iter_separator,
233 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator, -1);
235 if (is_separator && iter_separator_to_set)
236 *iter_separator_to_set = iter_separator;
242 individual_store_find_contact_foreach (GtkTreeModel *model,
247 FolksIndividual *individual;
249 gtk_tree_model_get (model, iter,
250 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
252 if (individual == fc->individual)
255 fc->iters = g_list_append (fc->iters, gtk_tree_iter_copy (iter));
258 tp_clear_object (&individual);
264 individual_store_find_contact (EmpathyIndividualStore *self,
265 FolksIndividual *individual)
267 EmpathyIndividualStorePriv *priv;
272 priv = GET_PRIV (self);
274 memset (&fc, 0, sizeof (fc));
276 fc.individual = individual;
278 model = GTK_TREE_MODEL (self);
279 gtk_tree_model_foreach (model,
280 (GtkTreeModelForeachFunc) individual_store_find_contact_foreach, &fc);
289 individual_store_remove_individual (EmpathyIndividualStore *self,
290 FolksIndividual *individual)
292 EmpathyIndividualStorePriv *priv;
296 priv = GET_PRIV (self);
298 iters = individual_store_find_contact (self, individual);
303 model = GTK_TREE_MODEL (self);
305 for (l = iters; l; l = l->next)
309 /* NOTE: it is only <= 2 here because we have
310 * separators after the group name, otherwise it
313 if (gtk_tree_model_iter_parent (model, &parent, l->data) &&
314 gtk_tree_model_iter_n_children (model, &parent) <= 2)
316 gtk_tree_store_remove (GTK_TREE_STORE (self), &parent);
320 gtk_tree_store_remove (GTK_TREE_STORE (self), l->data);
324 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
329 individual_store_add_individual (EmpathyIndividualStore *self,
330 FolksIndividual *individual)
332 EmpathyIndividualStorePriv *priv;
334 GHashTable *group_set = NULL;
335 GList *groups = NULL, *l;
336 EmpathyIndividualManager *manager;
337 EmpathyContact *contact;
338 TpConnection *connection;
339 EmpathyIndividualManagerFlags flags = 0;
341 priv = GET_PRIV (self);
343 if (EMP_STR_EMPTY (folks_individual_get_alias (individual)) ||
344 (!priv->show_offline && !folks_individual_is_online (individual)))
347 if (priv->show_groups)
349 group_set = folks_individual_get_groups (individual);
350 groups = g_hash_table_get_keys (group_set);
353 manager = empathy_individual_manager_dup_singleton ();
354 contact = empathy_contact_dup_from_folks_individual (individual);
355 connection = empathy_contact_get_connection (contact);
356 flags = empathy_individual_manager_get_flags_for_connection (manager,
361 GtkTreeIter iter_group, *parent;
363 parent = &iter_group;
365 /* TODO: implement */
366 DEBUG ("forcing the People Nearby group even when 'show "
367 "groups' is off is unimplemented");
369 if (!priv->show_groups)
373 individual_store_get_group (self,
374 EMPATHY_INDIVIDUAL_STORE_UNGROUPED,
375 &iter_group, NULL, NULL, TRUE);
378 add_individual_to_store (GTK_TREE_STORE (self), &iter, parent,
382 /* Else add to each group. */
383 for (l = groups; l; l = l->next)
385 GtkTreeIter iter_group;
387 individual_store_get_group (self, l->data, &iter_group, NULL, NULL,
390 add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
393 g_list_free (groups);
394 if (group_set != NULL)
395 g_hash_table_unref (group_set);
397 if (priv->show_groups &&
398 folks_favourite_get_is_favourite (FOLKS_FAVOURITE (individual)))
400 /* Add contact to the fake 'Favorites' group */
401 GtkTreeIter iter_group;
403 individual_store_get_group (self, EMPATHY_INDIVIDUAL_STORE_FAVORITE,
404 &iter_group, NULL, NULL, TRUE);
406 add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
410 individual_store_contact_update (self, individual);
412 tp_clear_object (&contact);
416 individual_store_contact_set_active (EmpathyIndividualStore *self,
417 FolksIndividual *individual,
419 gboolean set_changed)
421 EmpathyIndividualStorePriv *priv;
425 priv = GET_PRIV (self);
426 model = GTK_TREE_MODEL (self);
428 iters = individual_store_find_contact (self, individual);
429 for (l = iters; l; l = l->next)
433 gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
434 EMPATHY_INDIVIDUAL_STORE_COL_IS_ACTIVE, active,
437 DEBUG ("Set item %s", active ? "active" : "inactive");
441 path = gtk_tree_model_get_path (model, l->data);
442 gtk_tree_model_row_changed (model, path, l->data);
443 gtk_tree_path_free (path);
447 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
452 static ShowActiveData *
453 individual_store_contact_active_new (EmpathyIndividualStore *self,
454 FolksIndividual *individual,
457 ShowActiveData *data;
459 DEBUG ("Individual'%s' now active, and %s be removed",
460 folks_individual_get_alias (individual), remove_ ? "WILL" : "WILL NOT");
462 data = g_slice_new0 (ShowActiveData);
464 data->self = g_object_ref (self);
465 data->individual = g_object_ref (individual);
466 data->remove = remove_;
472 individual_store_contact_active_free (ShowActiveData *data)
474 g_object_unref (data->individual);
475 g_object_unref (data->self);
477 g_slice_free (ShowActiveData, data);
481 individual_store_contact_active_cb (ShowActiveData *data)
483 EmpathyIndividualStorePriv *priv;
485 priv = GET_PRIV (data->self);
488 !priv->show_offline && !folks_individual_is_online (data->individual))
490 DEBUG ("Individual'%s' active timeout, removing item",
491 folks_individual_get_alias (data->individual));
492 individual_store_remove_individual (data->self, data->individual);
495 DEBUG ("Individual'%s' no longer active",
496 folks_individual_get_alias (data->individual));
498 individual_store_contact_set_active (data->self,
499 data->individual, FALSE, TRUE);
501 individual_store_contact_active_free (data);
507 individual_avatar_pixbuf_received_cb (GObject *object,
508 GAsyncResult *result,
511 FolksIndividual *individual = FOLKS_INDIVIDUAL (object);
512 EmpathyIndividualStore *self = user_data;
513 GError *error = NULL;
516 pixbuf = empathy_pixbuf_avatar_from_individual_scaled_finish (individual,
521 DEBUG ("failed to retrieve pixbuf for individual %s: %s",
522 folks_individual_get_alias (individual),
524 g_clear_error (&error);
530 iters = individual_store_find_contact (self, individual);
531 for (l = iters; l; l = l->next)
533 gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
534 EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR, pixbuf,
541 individual_store_contact_update (EmpathyIndividualStore *self,
542 FolksIndividual *individual)
544 EmpathyIndividualStorePriv *priv;
545 ShowActiveData *data;
549 gboolean should_be_in_list;
550 gboolean was_online = TRUE;
551 gboolean now_online = FALSE;
552 gboolean set_model = FALSE;
553 gboolean do_remove = FALSE;
554 gboolean do_set_active = FALSE;
555 gboolean do_set_refresh = FALSE;
556 gboolean show_avatar = FALSE;
557 GdkPixbuf *pixbuf_status;
559 priv = GET_PRIV (self);
561 model = GTK_TREE_MODEL (self);
563 iters = individual_store_find_contact (self, individual);
573 /* Get online state now. */
574 now_online = folks_individual_is_online (individual);
576 if (priv->show_offline || now_online)
578 should_be_in_list = TRUE;
582 should_be_in_list = FALSE;
585 if (!in_list && !should_be_in_list)
588 DEBUG ("Individual:'%s' in list:NO, should be:NO",
589 folks_individual_get_alias (individual));
591 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
595 else if (in_list && !should_be_in_list)
597 DEBUG ("Individual:'%s' in list:YES, should be:NO",
598 folks_individual_get_alias (individual));
600 if (priv->show_active)
603 do_set_active = TRUE;
604 do_set_refresh = TRUE;
607 DEBUG ("Remove item (after timeout)");
611 DEBUG ("Remove item (now)!");
612 individual_store_remove_individual (self, individual);
615 else if (!in_list && should_be_in_list)
617 DEBUG ("Individual'%s' in list:NO, should be:YES",
618 folks_individual_get_alias (individual));
620 individual_store_add_individual (self, individual);
622 if (priv->show_active)
624 do_set_active = TRUE;
626 DEBUG ("Set active (individual added)");
631 DEBUG ("Individual'%s' in list:YES, should be:YES",
632 folks_individual_get_alias (individual));
634 /* Get online state before. */
635 if (iters && g_list_length (iters) > 0)
637 gtk_tree_model_get (model, iters->data,
638 EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, &was_online, -1);
641 /* Is this really an update or an online/offline. */
642 if (priv->show_active)
644 if (was_online != now_online)
646 do_set_active = TRUE;
647 do_set_refresh = TRUE;
649 DEBUG ("Set active (individual updated %s)",
650 was_online ? "online -> offline" : "offline -> online");
654 /* Was TRUE for presence updates. */
655 /* do_set_active = FALSE; */
656 do_set_refresh = TRUE;
658 DEBUG ("Set active (individual updated)");
665 if (priv->show_avatars && !priv->is_compact)
670 empathy_pixbuf_avatar_from_individual_scaled_async (individual,
671 individual_avatar_pixbuf_received_cb, 32, 32, self);
674 empathy_individual_store_get_individual_status_icon (self, individual);
676 for (l = iters; l && set_model; l = l->next)
678 gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
679 EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf_status,
680 EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
681 EMPATHY_INDIVIDUAL_STORE_COL_NAME,
682 folks_individual_get_alias (individual),
683 EMPATHY_INDIVIDUAL_STORE_COL_PRESENCE_TYPE,
684 folks_individual_get_presence_type (individual),
685 EMPATHY_INDIVIDUAL_STORE_COL_STATUS,
686 folks_individual_get_presence_message (individual),
687 EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL,
688 folks_individual_get_capabilities (individual) &
689 FOLKS_CAPABILITIES_FLAGS_AUDIO,
690 EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL,
691 folks_individual_get_capabilities (individual) &
692 FOLKS_CAPABILITIES_FLAGS_VIDEO,
693 EMPATHY_INDIVIDUAL_STORE_COL_COMPACT, priv->is_compact,
694 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, FALSE,
695 EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, now_online,
696 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
700 if (priv->show_active && do_set_active)
702 individual_store_contact_set_active (self, individual, do_set_active,
708 individual_store_contact_active_new (self, individual,
710 g_timeout_add_seconds (ACTIVE_USER_SHOW_TIME,
711 (GSourceFunc) individual_store_contact_active_cb, data);
715 /* FIXME: when someone goes online then offline quickly, the
716 * first timeout sets the user to be inactive and the second
717 * timeout removes the user from the contact list, really we
718 * should remove the first timeout.
720 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
725 individual_store_contact_updated_cb (FolksIndividual *individual,
727 EmpathyIndividualStore *self)
729 DEBUG ("Individual'%s' updated, checking roster is in sync...",
730 folks_individual_get_alias (individual));
732 individual_store_contact_update (self, individual);
736 individual_store_add_individual_and_connect (EmpathyIndividualStore *self,
737 FolksIndividual *individual)
739 g_signal_connect (individual, "notify::avatar",
740 G_CALLBACK (individual_store_contact_updated_cb), self);
741 g_signal_connect (individual, "notify::presence-type",
742 G_CALLBACK (individual_store_contact_updated_cb), self);
743 g_signal_connect (individual, "notify::presence-message",
744 G_CALLBACK (individual_store_contact_updated_cb), self);
745 g_signal_connect (individual, "notify::alias",
746 G_CALLBACK (individual_store_contact_updated_cb), self);
747 g_signal_connect (individual, "notify::capabilities",
748 G_CALLBACK (individual_store_contact_updated_cb), self);
750 individual_store_add_individual (self, individual);
754 individual_store_remove_individual_and_disconnect (
755 EmpathyIndividualStore *self,
756 FolksIndividual *individual)
758 g_signal_handlers_disconnect_by_func (individual,
759 G_CALLBACK (individual_store_contact_updated_cb), self);
761 individual_store_remove_individual (self, individual);
765 individual_store_members_changed_cb (EmpathyIndividualManager *manager,
770 EmpathyIndividualStore *self)
774 for (l = added; l; l = l->next)
776 DEBUG ("Individual %s %s", folks_individual_get_id (l->data), "added");
778 individual_store_add_individual_and_connect (self, l->data);
780 for (l = removed; l; l = l->next)
782 DEBUG ("Individual %s %s",
783 folks_individual_get_id (l->data), "removed");
785 individual_store_remove_individual_and_disconnect (self, l->data);
790 individual_store_favourites_changed_cb (EmpathyIndividualManager *manager,
791 FolksIndividual *individual,
792 gboolean is_favourite,
793 EmpathyIndividualStore *self)
795 EmpathyIndividualStorePriv *priv;
797 priv = GET_PRIV (self);
799 DEBUG ("Individual %s is %s a favourite",
800 folks_individual_get_id (individual),
801 is_favourite ? "now" : "no longer");
803 individual_store_remove_individual (self, individual);
804 individual_store_add_individual (self, individual);
808 individual_store_groups_changed_cb (EmpathyIndividualManager *manager,
809 FolksIndividual *individual,
812 EmpathyIndividualStore *self)
814 EmpathyIndividualStorePriv *priv;
815 gboolean show_active;
817 priv = GET_PRIV (self);
819 DEBUG ("Updating groups for individual %s",
820 folks_individual_get_id (individual));
822 /* We do this to make sure the groups are correct, if not, we
823 * would have to check the groups already set up for each
824 * contact and then see what has been updated.
826 show_active = priv->show_active;
827 priv->show_active = FALSE;
828 individual_store_remove_individual (self, individual);
829 individual_store_add_individual (self, individual);
830 priv->show_active = show_active;
834 individual_store_manager_setup (gpointer user_data)
836 EmpathyIndividualStore *self = user_data;
837 EmpathyIndividualStorePriv *priv = GET_PRIV (self);
840 /* Signal connection. */
842 /* TODO: implement */
843 DEBUG ("handling individual renames unimplemented");
845 g_signal_connect (priv->manager,
847 G_CALLBACK (individual_store_members_changed_cb), self);
849 g_signal_connect (priv->manager,
850 "favourites-changed",
851 G_CALLBACK (individual_store_favourites_changed_cb), self);
853 g_signal_connect (priv->manager,
855 G_CALLBACK (individual_store_groups_changed_cb), self);
857 /* Add contacts already created. */
858 individuals = empathy_individual_manager_get_members (priv->manager);
859 if (individuals != NULL && FOLKS_IS_INDIVIDUAL (individuals->data))
861 individual_store_members_changed_cb (priv->manager, "initial add",
862 individuals, NULL, 0, self);
863 g_list_free (individuals);
866 priv->setup_idle_id = 0;
871 individual_store_set_individual_manager (EmpathyIndividualStore *self,
872 EmpathyIndividualManager *manager)
874 EmpathyIndividualStorePriv *priv = GET_PRIV (self);
876 priv->manager = g_object_ref (manager);
878 /* Let a chance to have all properties set before populating */
879 priv->setup_idle_id = g_idle_add (individual_store_manager_setup, self);
883 individual_store_member_renamed_cb (EmpathyIndividualManager *manager,
884 FolksIndividual *old_individual,
885 FolksIndividual *new_individual,
888 EmpathyIndividualStore *self)
890 EmpathyIndividualStorePriv *priv;
892 priv = GET_PRIV (self);
894 DEBUG ("Individual %s renamed to %s",
895 folks_individual_get_id (old_individual),
896 folks_individual_get_id (new_individual));
898 /* add the new contact */
899 individual_store_add_individual_and_connect (self, new_individual);
901 /* remove old contact */
902 individual_store_remove_individual_and_disconnect (self, old_individual);
906 individual_store_dispose (GObject *object)
908 EmpathyIndividualStorePriv *priv = GET_PRIV (object);
911 if (priv->dispose_has_run)
913 priv->dispose_has_run = TRUE;
915 contacts = empathy_individual_manager_get_members (priv->manager);
916 for (l = contacts; l; l = l->next)
918 g_signal_handlers_disconnect_by_func (l->data,
919 G_CALLBACK (individual_store_contact_updated_cb), object);
921 g_list_free (contacts);
923 g_signal_handlers_disconnect_by_func (priv->manager,
924 G_CALLBACK (individual_store_member_renamed_cb), object);
925 g_signal_handlers_disconnect_by_func (priv->manager,
926 G_CALLBACK (individual_store_members_changed_cb), object);
927 g_signal_handlers_disconnect_by_func (priv->manager,
928 G_CALLBACK (individual_store_favourites_changed_cb), object);
929 g_signal_handlers_disconnect_by_func (priv->manager,
930 G_CALLBACK (individual_store_groups_changed_cb), object);
931 g_object_unref (priv->manager);
933 if (priv->inhibit_active)
935 g_source_remove (priv->inhibit_active);
938 if (priv->setup_idle_id != 0)
940 g_source_remove (priv->setup_idle_id);
943 g_hash_table_destroy (priv->status_icons);
944 G_OBJECT_CLASS (empathy_individual_store_parent_class)->dispose (object);
948 individual_store_get_property (GObject *object,
953 EmpathyIndividualStorePriv *priv;
955 priv = GET_PRIV (object);
959 case PROP_INDIVIDUAL_MANAGER:
960 g_value_set_object (value, priv->manager);
962 case PROP_SHOW_OFFLINE:
963 g_value_set_boolean (value, priv->show_offline);
965 case PROP_SHOW_AVATARS:
966 g_value_set_boolean (value, priv->show_avatars);
968 case PROP_SHOW_PROTOCOLS:
969 g_value_set_boolean (value, priv->show_protocols);
971 case PROP_SHOW_GROUPS:
972 g_value_set_boolean (value, priv->show_groups);
974 case PROP_IS_COMPACT:
975 g_value_set_boolean (value, priv->is_compact);
977 case PROP_SORT_CRITERIUM:
978 g_value_set_enum (value, priv->sort_criterium);
981 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
987 individual_store_set_property (GObject *object,
992 EmpathyIndividualStorePriv *priv;
994 priv = GET_PRIV (object);
998 case PROP_INDIVIDUAL_MANAGER:
999 individual_store_set_individual_manager (EMPATHY_INDIVIDUAL_STORE
1000 (object), g_value_get_object (value));
1002 case PROP_SHOW_OFFLINE:
1003 empathy_individual_store_set_show_offline (EMPATHY_INDIVIDUAL_STORE
1004 (object), g_value_get_boolean (value));
1006 case PROP_SHOW_AVATARS:
1007 empathy_individual_store_set_show_avatars (EMPATHY_INDIVIDUAL_STORE
1008 (object), g_value_get_boolean (value));
1010 case PROP_SHOW_PROTOCOLS:
1011 empathy_individual_store_set_show_protocols (EMPATHY_INDIVIDUAL_STORE
1012 (object), g_value_get_boolean (value));
1014 case PROP_SHOW_GROUPS:
1015 empathy_individual_store_set_show_groups (EMPATHY_INDIVIDUAL_STORE
1016 (object), g_value_get_boolean (value));
1018 case PROP_IS_COMPACT:
1019 empathy_individual_store_set_is_compact (EMPATHY_INDIVIDUAL_STORE
1020 (object), g_value_get_boolean (value));
1022 case PROP_SORT_CRITERIUM:
1023 empathy_individual_store_set_sort_criterium (EMPATHY_INDIVIDUAL_STORE
1024 (object), g_value_get_enum (value));
1027 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
1033 empathy_individual_store_class_init (EmpathyIndividualStoreClass *klass)
1035 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1037 object_class->dispose = individual_store_dispose;
1038 object_class->get_property = individual_store_get_property;
1039 object_class->set_property = individual_store_set_property;
1041 g_object_class_install_property (object_class,
1042 PROP_INDIVIDUAL_MANAGER,
1043 g_param_spec_object ("individual-manager",
1044 "The individual manager",
1045 "The individual manager",
1046 EMPATHY_TYPE_INDIVIDUAL_MANAGER,
1047 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
1048 g_object_class_install_property (object_class,
1050 g_param_spec_boolean ("show-offline",
1052 "Whether contact list should display "
1053 "offline contacts", FALSE, G_PARAM_READWRITE));
1054 g_object_class_install_property (object_class,
1056 g_param_spec_boolean ("show-avatars",
1058 "Whether contact list should display "
1059 "avatars for contacts", TRUE, G_PARAM_READWRITE));
1060 g_object_class_install_property (object_class,
1061 PROP_SHOW_PROTOCOLS,
1062 g_param_spec_boolean ("show-protocols",
1064 "Whether contact list should display "
1065 "protocols for contacts", FALSE, G_PARAM_READWRITE));
1066 g_object_class_install_property (object_class,
1068 g_param_spec_boolean ("show-groups",
1070 "Whether contact list should display "
1071 "contact groups", TRUE, G_PARAM_READWRITE));
1072 g_object_class_install_property (object_class,
1074 g_param_spec_boolean ("is-compact",
1076 "Whether the contact list is in compact mode or not",
1077 FALSE, G_PARAM_READWRITE));
1079 g_object_class_install_property (object_class,
1080 PROP_SORT_CRITERIUM,
1081 g_param_spec_enum ("sort-criterium",
1083 "The sort criterium to use for sorting the contact list",
1084 EMPATHY_TYPE_INDIVIDUAL_STORE_SORT,
1085 EMPATHY_INDIVIDUAL_STORE_SORT_NAME, G_PARAM_READWRITE));
1087 g_type_class_add_private (object_class,
1088 sizeof (EmpathyIndividualStorePriv));
1092 get_position (const char **strv,
1097 for (i = 0; strv[i] != NULL; i++)
1099 if (!tp_strdiff (strv[i], str))
1107 compare_separator_and_groups (gboolean is_separator_a,
1108 gboolean is_separator_b,
1109 const gchar *name_a,
1110 const gchar *name_b,
1111 FolksIndividual *individual_a,
1112 FolksIndividual *individual_b,
1113 gboolean fake_group_a,
1114 gboolean fake_group_b)
1116 /* these two lists are the sorted list of fake groups to include at the
1117 * top and bottom of the roster */
1118 const char *top_groups[] = {
1119 EMPATHY_INDIVIDUAL_STORE_FAVORITE,
1123 const char *bottom_groups[] = {
1124 EMPATHY_INDIVIDUAL_STORE_UNGROUPED,
1128 if (is_separator_a || is_separator_b)
1130 /* We have at least one separator */
1135 else if (is_separator_b)
1141 /* One group and one contact */
1142 if (!individual_a && individual_b)
1146 else if (individual_a && !individual_b)
1150 else if (!individual_a && !individual_b)
1152 gboolean a_in_top, b_in_top, a_in_bottom, b_in_bottom;
1154 a_in_top = fake_group_a && tp_strv_contains (top_groups, name_a);
1155 b_in_top = fake_group_b && tp_strv_contains (top_groups, name_b);
1156 a_in_bottom = fake_group_a && tp_strv_contains (bottom_groups, name_a);
1157 b_in_bottom = fake_group_b && tp_strv_contains (bottom_groups, name_b);
1159 if (a_in_top && b_in_top)
1161 /* compare positions */
1162 return CLAMP (get_position (top_groups, name_a) -
1163 get_position (top_groups, name_b), -1, 1);
1165 else if (a_in_bottom && b_in_bottom)
1167 /* compare positions */
1168 return CLAMP (get_position (bottom_groups, name_a) -
1169 get_position (bottom_groups, name_b), -1, 1);
1171 else if (a_in_top || b_in_bottom)
1175 else if (b_in_top || a_in_bottom)
1181 return g_utf8_collate (name_a, name_b);
1185 /* Two contacts, ordering depends of the sorting policy */
1190 individual_store_contact_sort (FolksIndividual *individual_a,
1191 FolksIndividual *individual_b)
1195 g_return_val_if_fail (individual_a != NULL || individual_b != NULL, 0);
1198 ret_val = g_utf8_collate (folks_individual_get_alias (individual_a),
1199 folks_individual_get_alias (individual_b));
1205 ret_val = g_utf8_collate (folks_individual_get_id (individual_a),
1206 folks_individual_get_id (individual_b));
1216 individual_store_state_sort_func (GtkTreeModel *model,
1217 GtkTreeIter *iter_a,
1218 GtkTreeIter *iter_b,
1222 FolksIndividual *individual_a, *individual_b;
1223 gchar *name_a, *name_b;
1224 gboolean is_separator_a, is_separator_b;
1225 gboolean fake_group_a, fake_group_b;
1226 FolksPresenceType folks_presence_type_a, folks_presence_type_b;
1227 TpConnectionPresenceType tp_presence_a, tp_presence_b;
1229 gtk_tree_model_get (model, iter_a,
1230 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_a,
1231 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_a,
1232 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_a,
1233 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_a, -1);
1234 gtk_tree_model_get (model, iter_b,
1235 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_b,
1236 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_b,
1237 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_b,
1238 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_b, -1);
1240 if (individual_a == NULL || individual_b == NULL)
1242 ret_val = compare_separator_and_groups (is_separator_a, is_separator_b,
1243 name_a, name_b, individual_a, individual_b, fake_group_a,
1248 /* If we managed to get this far, we can start looking at
1251 folks_presence_type_a = folks_individual_get_presence_type (individual_a);
1252 folks_presence_type_b = folks_individual_get_presence_type (individual_b);
1253 tp_presence_a = empathy_folks_presence_type_to_tp (folks_presence_type_a);
1254 tp_presence_b = empathy_folks_presence_type_to_tp (folks_presence_type_b);
1256 ret_val = -tp_connection_presence_type_cmp_availability (tp_presence_a,
1261 /* Fallback: compare by name et al. */
1262 ret_val = individual_store_contact_sort (individual_a, individual_b);
1268 tp_clear_object (&individual_a);
1269 tp_clear_object (&individual_b);
1275 individual_store_name_sort_func (GtkTreeModel *model,
1276 GtkTreeIter *iter_a,
1277 GtkTreeIter *iter_b,
1280 gchar *name_a, *name_b;
1281 FolksIndividual *individual_a, *individual_b;
1282 gboolean is_separator_a = FALSE, is_separator_b = FALSE;
1284 gboolean fake_group_a, fake_group_b;
1286 gtk_tree_model_get (model, iter_a,
1287 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_a,
1288 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_a,
1289 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_a,
1290 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_a, -1);
1291 gtk_tree_model_get (model, iter_b,
1292 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_b,
1293 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_b,
1294 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_b,
1295 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_b, -1);
1297 if (individual_a == NULL || individual_b == NULL)
1298 ret_val = compare_separator_and_groups (is_separator_a, is_separator_b,
1299 name_a, name_b, individual_a, individual_b, fake_group_a, fake_group_b);
1301 ret_val = individual_store_contact_sort (individual_a, individual_b);
1303 tp_clear_object (&individual_a);
1304 tp_clear_object (&individual_b);
1310 individual_store_setup (EmpathyIndividualStore *self)
1312 EmpathyIndividualStorePriv *priv;
1314 GDK_TYPE_PIXBUF, /* Status pixbuf */
1315 GDK_TYPE_PIXBUF, /* Avatar pixbuf */
1316 G_TYPE_BOOLEAN, /* Avatar pixbuf visible */
1317 G_TYPE_STRING, /* Name */
1318 G_TYPE_UINT, /* Presence type */
1319 G_TYPE_STRING, /* Status string */
1320 G_TYPE_BOOLEAN, /* Compact view */
1321 FOLKS_TYPE_INDIVIDUAL, /* Individual type */
1322 G_TYPE_BOOLEAN, /* Is group */
1323 G_TYPE_BOOLEAN, /* Is active */
1324 G_TYPE_BOOLEAN, /* Is online */
1325 G_TYPE_BOOLEAN, /* Is separator */
1326 G_TYPE_BOOLEAN, /* Can make audio calls */
1327 G_TYPE_BOOLEAN, /* Can make video calls */
1328 EMPATHY_TYPE_INDIVIDUAL_MANAGER_FLAGS, /* Flags */
1329 G_TYPE_BOOLEAN, /* Is a fake group */
1332 priv = GET_PRIV (self);
1334 gtk_tree_store_set_column_types (GTK_TREE_STORE (self),
1335 EMPATHY_INDIVIDUAL_STORE_COL_COUNT, types);
1337 /* Set up sorting */
1338 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (self),
1339 EMPATHY_INDIVIDUAL_STORE_COL_NAME,
1340 individual_store_name_sort_func, self, NULL);
1341 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (self),
1342 EMPATHY_INDIVIDUAL_STORE_COL_STATUS,
1343 individual_store_state_sort_func, self, NULL);
1345 priv->sort_criterium = EMPATHY_INDIVIDUAL_STORE_SORT_NAME;
1346 empathy_individual_store_set_sort_criterium (self, priv->sort_criterium);
1350 individual_store_inibit_active_cb (EmpathyIndividualStore *self)
1352 EmpathyIndividualStorePriv *priv;
1354 priv = GET_PRIV (self);
1356 priv->show_active = TRUE;
1357 priv->inhibit_active = 0;
1363 empathy_individual_store_init (EmpathyIndividualStore *self)
1365 EmpathyIndividualStorePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
1366 EMPATHY_TYPE_INDIVIDUAL_STORE, EmpathyIndividualStorePriv);
1369 priv->show_avatars = TRUE;
1370 priv->show_groups = TRUE;
1371 priv->show_protocols = FALSE;
1372 priv->inhibit_active =
1373 g_timeout_add_seconds (ACTIVE_USER_WAIT_TO_ENABLE_TIME,
1374 (GSourceFunc) individual_store_inibit_active_cb, self);
1375 priv->status_icons =
1376 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
1377 individual_store_setup (self);
1380 EmpathyIndividualStore *
1381 empathy_individual_store_new (EmpathyIndividualManager *manager)
1383 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager), NULL);
1385 return g_object_new (EMPATHY_TYPE_INDIVIDUAL_STORE,
1386 "individual-manager", manager, NULL);
1389 EmpathyIndividualManager *
1390 empathy_individual_store_get_manager (EmpathyIndividualStore *self)
1392 EmpathyIndividualStorePriv *priv;
1394 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), FALSE);
1396 priv = GET_PRIV (self);
1398 return priv->manager;
1402 empathy_individual_store_get_show_offline (EmpathyIndividualStore *self)
1404 EmpathyIndividualStorePriv *priv;
1406 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), FALSE);
1408 priv = GET_PRIV (self);
1410 return priv->show_offline;
1414 empathy_individual_store_set_show_offline (EmpathyIndividualStore *self,
1415 gboolean show_offline)
1417 EmpathyIndividualStorePriv *priv;
1418 GList *contacts, *l;
1419 gboolean show_active;
1421 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1423 priv = GET_PRIV (self);
1425 priv->show_offline = show_offline;
1426 show_active = priv->show_active;
1428 /* Disable temporarily. */
1429 priv->show_active = FALSE;
1431 contacts = empathy_individual_manager_get_members (priv->manager);
1432 for (l = contacts; l; l = l->next)
1434 individual_store_contact_update (self, l->data);
1436 g_list_free (contacts);
1438 /* Restore to original setting. */
1439 priv->show_active = show_active;
1441 g_object_notify (G_OBJECT (self), "show-offline");
1445 empathy_individual_store_get_show_avatars (EmpathyIndividualStore *self)
1447 EmpathyIndividualStorePriv *priv;
1449 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1451 priv = GET_PRIV (self);
1453 return priv->show_avatars;
1457 individual_store_update_list_mode_foreach (GtkTreeModel *model,
1460 EmpathyIndividualStore *self)
1462 EmpathyIndividualStorePriv *priv;
1463 gboolean show_avatar = FALSE;
1464 FolksIndividual *individual;
1465 GdkPixbuf *pixbuf_status;
1467 priv = GET_PRIV (self);
1469 if (priv->show_avatars && !priv->is_compact)
1474 gtk_tree_model_get (model, iter,
1475 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
1477 if (individual == NULL)
1481 /* get icon from hash_table */
1483 empathy_individual_store_get_individual_status_icon (self, individual);
1485 gtk_tree_store_set (GTK_TREE_STORE (self), iter,
1486 EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf_status,
1487 EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
1488 EMPATHY_INDIVIDUAL_STORE_COL_COMPACT, priv->is_compact, -1);
1490 g_object_unref (individual);
1496 empathy_individual_store_set_show_avatars (EmpathyIndividualStore *self,
1497 gboolean show_avatars)
1499 EmpathyIndividualStorePriv *priv;
1500 GtkTreeModel *model;
1502 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1504 priv = GET_PRIV (self);
1506 priv->show_avatars = show_avatars;
1508 model = GTK_TREE_MODEL (self);
1510 gtk_tree_model_foreach (model,
1511 (GtkTreeModelForeachFunc)
1512 individual_store_update_list_mode_foreach, self);
1514 g_object_notify (G_OBJECT (self), "show-avatars");
1518 empathy_individual_store_get_show_protocols (EmpathyIndividualStore *self)
1520 EmpathyIndividualStorePriv *priv;
1522 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1524 priv = GET_PRIV (self);
1526 return priv->show_protocols;
1530 empathy_individual_store_set_show_protocols (EmpathyIndividualStore *self,
1531 gboolean show_protocols)
1533 EmpathyIndividualStorePriv *priv;
1534 GtkTreeModel *model;
1536 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1538 priv = GET_PRIV (self);
1540 priv->show_protocols = show_protocols;
1542 model = GTK_TREE_MODEL (self);
1544 gtk_tree_model_foreach (model,
1545 (GtkTreeModelForeachFunc)
1546 individual_store_update_list_mode_foreach, self);
1548 g_object_notify (G_OBJECT (self), "show-protocols");
1552 empathy_individual_store_get_show_groups (EmpathyIndividualStore *self)
1554 EmpathyIndividualStorePriv *priv;
1556 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1558 priv = GET_PRIV (self);
1560 return priv->show_groups;
1564 empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
1565 gboolean show_groups)
1567 EmpathyIndividualStorePriv *priv;
1569 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1571 priv = GET_PRIV (self);
1573 if (priv->show_groups == show_groups)
1578 priv->show_groups = show_groups;
1580 if (priv->setup_idle_id == 0)
1582 /* Remove all contacts and add them back, not optimized but
1583 * that's the easy way :)
1585 * This is only done if there's not a pending setup idle
1586 * callback, otherwise it will race and the contacts will get
1590 gtk_tree_store_clear (GTK_TREE_STORE (self));
1591 contacts = empathy_individual_manager_get_members (priv->manager);
1593 individual_store_members_changed_cb (priv->manager,
1594 "re-adding members: toggled group visibility",
1595 contacts, NULL, 0, self);
1596 g_list_free (contacts);
1599 g_object_notify (G_OBJECT (self), "show-groups");
1603 empathy_individual_store_get_is_compact (EmpathyIndividualStore *self)
1605 EmpathyIndividualStorePriv *priv;
1607 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1609 priv = GET_PRIV (self);
1611 return priv->is_compact;
1615 empathy_individual_store_set_is_compact (EmpathyIndividualStore *self,
1616 gboolean is_compact)
1618 EmpathyIndividualStorePriv *priv;
1619 GtkTreeModel *model;
1621 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1623 priv = GET_PRIV (self);
1625 priv->is_compact = is_compact;
1627 model = GTK_TREE_MODEL (self);
1629 gtk_tree_model_foreach (model,
1630 (GtkTreeModelForeachFunc)
1631 individual_store_update_list_mode_foreach, self);
1633 g_object_notify (G_OBJECT (self), "is-compact");
1636 EmpathyIndividualStoreSort
1637 empathy_individual_store_get_sort_criterium (EmpathyIndividualStore *self)
1639 EmpathyIndividualStorePriv *priv;
1641 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), 0);
1643 priv = GET_PRIV (self);
1645 return priv->sort_criterium;
1649 empathy_individual_store_set_sort_criterium (EmpathyIndividualStore *self,
1650 EmpathyIndividualStoreSort sort_criterium)
1652 EmpathyIndividualStorePriv *priv;
1654 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1656 priv = GET_PRIV (self);
1658 priv->sort_criterium = sort_criterium;
1660 switch (sort_criterium)
1662 case EMPATHY_INDIVIDUAL_STORE_SORT_STATE:
1663 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self),
1664 EMPATHY_INDIVIDUAL_STORE_COL_STATUS, GTK_SORT_ASCENDING);
1667 case EMPATHY_INDIVIDUAL_STORE_SORT_NAME:
1668 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self),
1669 EMPATHY_INDIVIDUAL_STORE_COL_NAME, GTK_SORT_ASCENDING);
1673 g_object_notify (G_OBJECT (self), "sort-criterium");
1677 empathy_individual_store_row_separator_func (GtkTreeModel *model,
1681 gboolean is_separator = FALSE;
1683 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), FALSE);
1685 gtk_tree_model_get (model, iter,
1686 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator, -1);
1688 return is_separator;
1692 empathy_individual_store_get_parent_group (GtkTreeModel *model,
1694 gboolean *path_is_group,
1695 gboolean *is_fake_group)
1697 GtkTreeIter parent_iter, iter;
1702 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
1706 *path_is_group = FALSE;
1709 if (!gtk_tree_model_get_iter (model, &iter, path))
1714 gtk_tree_model_get (model, &iter,
1715 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group,
1716 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name, -1);
1723 if (!gtk_tree_model_iter_parent (model, &parent_iter, &iter))
1730 gtk_tree_model_get (model, &iter,
1731 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group,
1732 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name,
1733 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake, -1);
1743 *path_is_group = TRUE;
1746 if (is_fake_group != NULL)
1747 *is_fake_group = fake;
1753 individual_store_get_individual_status_icon_with_icon_name (
1754 EmpathyIndividualStore *self,
1755 FolksIndividual *individual,
1756 const gchar *status_icon_name)
1758 GdkPixbuf *pixbuf_status = NULL;
1759 EmpathyIndividualStorePriv *priv;
1760 const gchar *protocol_name = NULL;
1761 gchar *icon_name = NULL;
1762 GList *personas, *l;
1763 guint contact_count;
1764 EmpathyContact *contact = NULL;
1765 gboolean show_protocols_here;
1767 priv = GET_PRIV (self);
1769 personas = folks_individual_get_personas (individual);
1770 for (l = personas, contact_count = 0; l; l = l->next)
1772 if (TPF_IS_PERSONA (l->data))
1775 if (contact_count > 1)
1779 show_protocols_here = priv->show_protocols && (contact_count == 1);
1780 if (show_protocols_here)
1782 contact = empathy_contact_dup_from_folks_individual (individual);
1783 protocol_name = empathy_protocol_name_for_contact (contact);
1784 icon_name = g_strdup_printf ("%s-%s", status_icon_name, protocol_name);
1788 icon_name = g_strdup_printf ("%s", status_icon_name);
1790 if (pixbuf_status == NULL)
1793 empathy_pixbuf_contact_status_icon_with_icon_name (contact,
1794 status_icon_name, priv->show_protocols);
1795 if (pixbuf_status != NULL)
1797 g_hash_table_insert (priv->status_icons,
1798 g_strdup (icon_name), pixbuf_status);
1803 tp_clear_object (&contact);
1805 return pixbuf_status;
1809 empathy_individual_store_get_individual_status_icon (
1810 EmpathyIndividualStore *self,
1811 FolksIndividual *individual)
1813 GdkPixbuf *pixbuf_status = NULL;
1814 const gchar *status_icon_name = NULL;
1816 status_icon_name = empathy_icon_name_for_individual (individual);
1817 if (status_icon_name == NULL)
1821 individual_store_get_individual_status_icon_with_icon_name (self,
1822 individual, status_icon_name);
1824 return pixbuf_status;