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)
155 gtk_tree_model_get (model, iter,
156 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &str,
157 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group, -1);
159 if (is_group && !tp_strdiff (str, fg->name))
171 individual_store_get_group (EmpathyIndividualStore *self,
173 GtkTreeIter *iter_group_to_set,
174 GtkTreeIter *iter_separator_to_set,
176 gboolean is_fake_group)
178 EmpathyIndividualStorePriv *priv;
180 GtkTreeIter iter_group;
181 GtkTreeIter iter_separator;
184 priv = GET_PRIV (self);
186 memset (&fg, 0, sizeof (fg));
190 model = GTK_TREE_MODEL (self);
191 gtk_tree_model_foreach (model,
192 (GtkTreeModelForeachFunc) individual_store_get_group_foreach, &fg);
201 gtk_tree_store_insert_with_values (GTK_TREE_STORE (self), &iter_group,
203 EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, NULL,
204 EMPATHY_INDIVIDUAL_STORE_COL_NAME, name,
205 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, TRUE,
206 EMPATHY_INDIVIDUAL_STORE_COL_IS_ACTIVE, FALSE,
207 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
208 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, is_fake_group,
211 if (iter_group_to_set)
213 *iter_group_to_set = iter_group;
216 gtk_tree_store_insert_with_values (GTK_TREE_STORE (self), &iter_separator,
218 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, TRUE,
221 if (iter_separator_to_set)
223 *iter_separator_to_set = iter_separator;
233 if (iter_group_to_set)
235 *iter_group_to_set = fg.iter;
238 iter_separator = fg.iter;
240 if (gtk_tree_model_iter_next (model, &iter_separator))
242 gboolean is_separator;
244 gtk_tree_model_get (model, &iter_separator,
245 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator, -1);
247 if (is_separator && iter_separator_to_set)
249 *iter_separator_to_set = iter_separator;
256 individual_store_find_contact_foreach (GtkTreeModel *model,
261 FolksIndividual *individual;
263 gtk_tree_model_get (model, iter,
264 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
266 if (individual == fc->individual)
269 fc->iters = g_list_append (fc->iters, gtk_tree_iter_copy (iter));
272 tp_clear_object (&individual);
278 individual_store_find_contact (EmpathyIndividualStore *self,
279 FolksIndividual *individual)
281 EmpathyIndividualStorePriv *priv;
286 priv = GET_PRIV (self);
288 memset (&fc, 0, sizeof (fc));
290 fc.individual = individual;
292 model = GTK_TREE_MODEL (self);
293 gtk_tree_model_foreach (model,
294 (GtkTreeModelForeachFunc) individual_store_find_contact_foreach, &fc);
305 individual_store_remove_individual (EmpathyIndividualStore *self,
306 FolksIndividual *individual)
308 EmpathyIndividualStorePriv *priv;
312 priv = GET_PRIV (self);
314 iters = individual_store_find_contact (self, individual);
321 model = GTK_TREE_MODEL (self);
323 for (l = iters; l; l = l->next)
327 /* NOTE: it is only <= 2 here because we have
328 * separators after the group name, otherwise it
331 if (gtk_tree_model_iter_parent (model, &parent, l->data) &&
332 gtk_tree_model_iter_n_children (model, &parent) <= 2)
334 gtk_tree_store_remove (GTK_TREE_STORE (self), &parent);
338 gtk_tree_store_remove (GTK_TREE_STORE (self), l->data);
342 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
347 individual_store_add_individual (EmpathyIndividualStore *self,
348 FolksIndividual *individual)
350 EmpathyIndividualStorePriv *priv;
352 GHashTable *group_set = NULL;
353 GList *groups = NULL, *l;
354 EmpathyIndividualManager *manager;
355 EmpathyContact *contact;
356 TpConnection *connection;
357 EmpathyIndividualManagerFlags flags = 0;
359 priv = GET_PRIV (self);
361 if (EMP_STR_EMPTY (folks_individual_get_alias (individual)) ||
362 (!priv->show_offline && !folks_individual_is_online (individual)))
367 if (priv->show_groups)
369 group_set = folks_individual_get_groups (individual);
370 groups = g_hash_table_get_keys (group_set);
373 manager = empathy_individual_manager_dup_singleton ();
374 contact = empathy_contact_from_folks_individual (individual);
375 connection = empathy_contact_get_connection (contact);
376 flags = empathy_individual_manager_get_flags_for_connection (manager,
381 GtkTreeIter iter_group, *parent;
383 parent = &iter_group;
385 /* TODO: implement */
386 DEBUG ("forcing the People Nearby group even when 'show "
387 "groups' is off is unimplemented");
389 if (!priv->show_groups)
395 individual_store_get_group (self,
396 EMPATHY_INDIVIDUAL_STORE_UNGROUPED,
397 &iter_group, NULL, NULL, TRUE);
400 add_individual_to_store (GTK_TREE_STORE (self), &iter, parent,
404 /* Else add to each group. */
405 for (l = groups; l; l = l->next)
407 GtkTreeIter iter_group;
409 individual_store_get_group (self, l->data, &iter_group, NULL, NULL,
412 add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
415 g_list_free (groups);
416 if (group_set != NULL)
417 g_hash_table_unref (group_set);
419 if (priv->show_groups &&
420 folks_favourite_get_is_favourite (FOLKS_FAVOURITE (individual)))
422 /* Add contact to the fake 'Favorites' group */
423 GtkTreeIter iter_group;
425 individual_store_get_group (self, EMPATHY_INDIVIDUAL_STORE_FAVORITE,
426 &iter_group, NULL, NULL, TRUE);
428 add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
432 individual_store_contact_update (self, individual);
436 individual_store_contact_set_active (EmpathyIndividualStore *self,
437 FolksIndividual *individual,
439 gboolean set_changed)
441 EmpathyIndividualStorePriv *priv;
445 priv = GET_PRIV (self);
446 model = GTK_TREE_MODEL (self);
448 iters = individual_store_find_contact (self, individual);
449 for (l = iters; l; l = l->next)
453 gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
454 EMPATHY_INDIVIDUAL_STORE_COL_IS_ACTIVE, active,
457 DEBUG ("Set item %s", active ? "active" : "inactive");
461 path = gtk_tree_model_get_path (model, l->data);
462 gtk_tree_model_row_changed (model, path, l->data);
463 gtk_tree_path_free (path);
467 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
472 static ShowActiveData *
473 individual_store_contact_active_new (EmpathyIndividualStore *self,
474 FolksIndividual *individual,
477 ShowActiveData *data;
479 DEBUG ("Individual'%s' now active, and %s be removed",
480 folks_individual_get_alias (individual), remove_ ? "WILL" : "WILL NOT");
482 data = g_slice_new0 (ShowActiveData);
484 data->self = g_object_ref (self);
485 data->individual = g_object_ref (individual);
486 data->remove = remove_;
492 individual_store_contact_active_free (ShowActiveData *data)
494 g_object_unref (data->individual);
495 g_object_unref (data->self);
497 g_slice_free (ShowActiveData, data);
501 individual_store_contact_active_cb (ShowActiveData *data)
503 EmpathyIndividualStorePriv *priv;
505 priv = GET_PRIV (data->self);
508 !priv->show_offline && !folks_individual_is_online (data->individual))
510 DEBUG ("Individual'%s' active timeout, removing item",
511 folks_individual_get_alias (data->individual));
512 individual_store_remove_individual (data->self, data->individual);
515 DEBUG ("Individual'%s' no longer active",
516 folks_individual_get_alias (data->individual));
518 individual_store_contact_set_active (data->self,
519 data->individual, FALSE, TRUE);
521 individual_store_contact_active_free (data);
527 individual_avatar_pixbuf_received_cb (GObject *object,
528 GAsyncResult *result,
531 FolksIndividual *individual = FOLKS_INDIVIDUAL (object);
532 EmpathyIndividualStore *self = user_data;
533 GError *error = NULL;
536 pixbuf = empathy_pixbuf_avatar_from_individual_scaled_finish (individual,
541 DEBUG ("failed to retrieve pixbuf for individual %s: %s",
542 folks_individual_get_alias (individual),
544 g_clear_error (&error);
550 iters = individual_store_find_contact (self, individual);
551 for (l = iters; l; l = l->next)
553 gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
554 EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR, pixbuf,
561 individual_store_contact_update (EmpathyIndividualStore *self,
562 FolksIndividual *individual)
564 EmpathyIndividualStorePriv *priv;
565 ShowActiveData *data;
569 gboolean should_be_in_list;
570 gboolean was_online = TRUE;
571 gboolean now_online = FALSE;
572 gboolean set_model = FALSE;
573 gboolean do_remove = FALSE;
574 gboolean do_set_active = FALSE;
575 gboolean do_set_refresh = FALSE;
576 gboolean show_avatar = FALSE;
577 GdkPixbuf *pixbuf_status;
579 priv = GET_PRIV (self);
581 model = GTK_TREE_MODEL (self);
583 iters = individual_store_find_contact (self, individual);
593 /* Get online state now. */
594 now_online = folks_individual_is_online (individual);
596 if (priv->show_offline || now_online)
598 should_be_in_list = TRUE;
602 should_be_in_list = FALSE;
605 if (!in_list && !should_be_in_list)
608 DEBUG ("Individual:'%s' in list:NO, should be:NO",
609 folks_individual_get_alias (individual));
611 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
615 else if (in_list && !should_be_in_list)
617 DEBUG ("Individual:'%s' in list:YES, should be:NO",
618 folks_individual_get_alias (individual));
620 if (priv->show_active)
623 do_set_active = TRUE;
624 do_set_refresh = TRUE;
627 DEBUG ("Remove item (after timeout)");
631 DEBUG ("Remove item (now)!");
632 individual_store_remove_individual (self, individual);
635 else if (!in_list && should_be_in_list)
637 DEBUG ("Individual'%s' in list:NO, should be:YES",
638 folks_individual_get_alias (individual));
640 individual_store_add_individual (self, individual);
642 if (priv->show_active)
644 do_set_active = TRUE;
646 DEBUG ("Set active (individual added)");
651 DEBUG ("Individual'%s' in list:YES, should be:YES",
652 folks_individual_get_alias (individual));
654 /* Get online state before. */
655 if (iters && g_list_length (iters) > 0)
657 gtk_tree_model_get (model, iters->data,
658 EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, &was_online, -1);
661 /* Is this really an update or an online/offline. */
662 if (priv->show_active)
664 if (was_online != now_online)
666 do_set_active = TRUE;
667 do_set_refresh = TRUE;
669 DEBUG ("Set active (individual updated %s)",
670 was_online ? "online -> offline" : "offline -> online");
674 /* Was TRUE for presence updates. */
675 /* do_set_active = FALSE; */
676 do_set_refresh = TRUE;
678 DEBUG ("Set active (individual updated)");
685 if (priv->show_avatars && !priv->is_compact)
690 empathy_pixbuf_avatar_from_individual_scaled_async (individual,
691 individual_avatar_pixbuf_received_cb, 32, 32, self);
694 empathy_individual_store_get_individual_status_icon (self, individual);
696 for (l = iters; l && set_model; l = l->next)
698 gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
699 EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf_status,
700 EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
701 EMPATHY_INDIVIDUAL_STORE_COL_NAME,
702 folks_individual_get_alias (individual),
703 EMPATHY_INDIVIDUAL_STORE_COL_PRESENCE_TYPE,
704 folks_individual_get_presence_type (individual),
705 EMPATHY_INDIVIDUAL_STORE_COL_STATUS,
706 folks_individual_get_presence_message (individual),
707 EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL,
708 folks_individual_get_capabilities (individual) &
709 FOLKS_CAPABILITIES_FLAGS_AUDIO,
710 EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL,
711 folks_individual_get_capabilities (individual) &
712 FOLKS_CAPABILITIES_FLAGS_VIDEO,
713 EMPATHY_INDIVIDUAL_STORE_COL_COMPACT, priv->is_compact,
714 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, FALSE,
715 EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, now_online,
716 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
720 if (priv->show_active && do_set_active)
722 individual_store_contact_set_active (self, individual, do_set_active,
728 individual_store_contact_active_new (self, individual,
730 g_timeout_add_seconds (ACTIVE_USER_SHOW_TIME,
731 (GSourceFunc) individual_store_contact_active_cb, data);
735 /* FIXME: when someone goes online then offline quickly, the
736 * first timeout sets the user to be inactive and the second
737 * timeout removes the user from the contact list, really we
738 * should remove the first timeout.
740 g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
745 individual_store_contact_updated_cb (FolksIndividual *individual,
747 EmpathyIndividualStore *self)
749 DEBUG ("Individual'%s' updated, checking roster is in sync...",
750 folks_individual_get_alias (individual));
752 individual_store_contact_update (self, individual);
756 individual_store_add_individual_and_connect (EmpathyIndividualStore *self,
757 FolksIndividual *individual)
759 g_signal_connect (individual, "notify::avatar",
760 G_CALLBACK (individual_store_contact_updated_cb), self);
761 g_signal_connect (individual, "notify::presence-type",
762 G_CALLBACK (individual_store_contact_updated_cb), self);
763 g_signal_connect (individual, "notify::presence-message",
764 G_CALLBACK (individual_store_contact_updated_cb), self);
765 g_signal_connect (individual, "notify::alias",
766 G_CALLBACK (individual_store_contact_updated_cb), self);
767 g_signal_connect (individual, "notify::capabilities",
768 G_CALLBACK (individual_store_contact_updated_cb), self);
770 individual_store_add_individual (self, individual);
774 individual_store_remove_individual_and_disconnect (
775 EmpathyIndividualStore *self,
776 FolksIndividual *individual)
778 g_signal_handlers_disconnect_by_func (individual,
779 G_CALLBACK (individual_store_contact_updated_cb), self);
781 individual_store_remove_individual (self, individual);
785 individual_store_members_changed_cb (EmpathyIndividualManager *manager,
790 EmpathyIndividualStore *self)
794 for (l = added; l; l = l->next)
796 DEBUG ("Individual %s %s", folks_individual_get_id (l->data), "added");
798 individual_store_add_individual_and_connect (self, l->data);
800 for (l = removed; l; l = l->next)
802 DEBUG ("Individual %s %s",
803 folks_individual_get_id (l->data), "removed");
805 individual_store_remove_individual_and_disconnect (self, l->data);
810 individual_store_favourites_changed_cb (EmpathyIndividualManager *manager,
811 FolksIndividual *individual,
812 gboolean is_favourite,
813 EmpathyIndividualStore *self)
815 EmpathyIndividualStorePriv *priv;
817 priv = GET_PRIV (self);
819 DEBUG ("Individual %s is %s a favourite",
820 folks_individual_get_id (individual),
821 is_favourite ? "now" : "no longer");
823 individual_store_remove_individual (self, individual);
824 individual_store_add_individual (self, individual);
828 individual_store_groups_changed_cb (EmpathyIndividualManager *manager,
829 FolksIndividual *individual,
832 EmpathyIndividualStore *self)
834 EmpathyIndividualStorePriv *priv;
835 gboolean show_active;
837 priv = GET_PRIV (self);
839 DEBUG ("Updating groups for individual %s",
840 folks_individual_get_id (individual));
842 /* We do this to make sure the groups are correct, if not, we
843 * would have to check the groups already set up for each
844 * contact and then see what has been updated.
846 show_active = priv->show_active;
847 priv->show_active = FALSE;
848 individual_store_remove_individual (self, individual);
849 individual_store_add_individual (self, individual);
850 priv->show_active = show_active;
854 individual_store_manager_setup (gpointer user_data)
856 EmpathyIndividualStore *self = user_data;
857 EmpathyIndividualStorePriv *priv = GET_PRIV (self);
860 /* Signal connection. */
862 /* TODO: implement */
863 DEBUG ("handling individual renames unimplemented");
865 g_signal_connect (priv->manager,
867 G_CALLBACK (individual_store_members_changed_cb), self);
869 g_signal_connect (priv->manager,
870 "favourites-changed",
871 G_CALLBACK (individual_store_favourites_changed_cb), self);
873 g_signal_connect (priv->manager,
875 G_CALLBACK (individual_store_groups_changed_cb), self);
877 /* Add contacts already created. */
878 individuals = empathy_individual_manager_get_members (priv->manager);
879 if (individuals != NULL && FOLKS_IS_INDIVIDUAL (individuals->data))
881 individual_store_members_changed_cb (priv->manager, "initial add",
882 individuals, NULL, 0, self);
883 g_list_free (individuals);
886 priv->setup_idle_id = 0;
891 individual_store_set_individual_manager (EmpathyIndividualStore *self,
892 EmpathyIndividualManager *manager)
894 EmpathyIndividualStorePriv *priv = GET_PRIV (self);
896 priv->manager = g_object_ref (manager);
898 /* Let a chance to have all properties set before populating */
899 priv->setup_idle_id = g_idle_add (individual_store_manager_setup, self);
903 individual_store_member_renamed_cb (EmpathyIndividualManager *manager,
904 FolksIndividual *old_individual,
905 FolksIndividual *new_individual,
908 EmpathyIndividualStore *self)
910 EmpathyIndividualStorePriv *priv;
912 priv = GET_PRIV (self);
914 DEBUG ("Individual %s renamed to %s",
915 folks_individual_get_id (old_individual),
916 folks_individual_get_id (new_individual));
918 /* add the new contact */
919 individual_store_add_individual_and_connect (self, new_individual);
921 /* remove old contact */
922 individual_store_remove_individual_and_disconnect (self, old_individual);
926 individual_store_dispose (GObject *object)
928 EmpathyIndividualStorePriv *priv = GET_PRIV (object);
931 if (priv->dispose_has_run)
933 priv->dispose_has_run = TRUE;
935 contacts = empathy_individual_manager_get_members (priv->manager);
936 for (l = contacts; l; l = l->next)
938 g_signal_handlers_disconnect_by_func (l->data,
939 G_CALLBACK (individual_store_contact_updated_cb), object);
941 g_list_free (contacts);
943 g_signal_handlers_disconnect_by_func (priv->manager,
944 G_CALLBACK (individual_store_member_renamed_cb), object);
945 g_signal_handlers_disconnect_by_func (priv->manager,
946 G_CALLBACK (individual_store_members_changed_cb), object);
947 g_signal_handlers_disconnect_by_func (priv->manager,
948 G_CALLBACK (individual_store_favourites_changed_cb), object);
949 g_signal_handlers_disconnect_by_func (priv->manager,
950 G_CALLBACK (individual_store_groups_changed_cb), object);
951 g_object_unref (priv->manager);
953 if (priv->inhibit_active)
955 g_source_remove (priv->inhibit_active);
958 if (priv->setup_idle_id != 0)
960 g_source_remove (priv->setup_idle_id);
963 g_hash_table_destroy (priv->status_icons);
964 G_OBJECT_CLASS (empathy_individual_store_parent_class)->dispose (object);
968 individual_store_get_property (GObject *object,
973 EmpathyIndividualStorePriv *priv;
975 priv = GET_PRIV (object);
979 case PROP_INDIVIDUAL_MANAGER:
980 g_value_set_object (value, priv->manager);
982 case PROP_SHOW_OFFLINE:
983 g_value_set_boolean (value, priv->show_offline);
985 case PROP_SHOW_AVATARS:
986 g_value_set_boolean (value, priv->show_avatars);
988 case PROP_SHOW_PROTOCOLS:
989 g_value_set_boolean (value, priv->show_protocols);
991 case PROP_SHOW_GROUPS:
992 g_value_set_boolean (value, priv->show_groups);
994 case PROP_IS_COMPACT:
995 g_value_set_boolean (value, priv->is_compact);
997 case PROP_SORT_CRITERIUM:
998 g_value_set_enum (value, priv->sort_criterium);
1001 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
1007 individual_store_set_property (GObject *object,
1009 const GValue *value,
1012 EmpathyIndividualStorePriv *priv;
1014 priv = GET_PRIV (object);
1018 case PROP_INDIVIDUAL_MANAGER:
1019 individual_store_set_individual_manager (EMPATHY_INDIVIDUAL_STORE
1020 (object), g_value_get_object (value));
1022 case PROP_SHOW_OFFLINE:
1023 empathy_individual_store_set_show_offline (EMPATHY_INDIVIDUAL_STORE
1024 (object), g_value_get_boolean (value));
1026 case PROP_SHOW_AVATARS:
1027 empathy_individual_store_set_show_avatars (EMPATHY_INDIVIDUAL_STORE
1028 (object), g_value_get_boolean (value));
1030 case PROP_SHOW_PROTOCOLS:
1031 empathy_individual_store_set_show_protocols (EMPATHY_INDIVIDUAL_STORE
1032 (object), g_value_get_boolean (value));
1034 case PROP_SHOW_GROUPS:
1035 empathy_individual_store_set_show_groups (EMPATHY_INDIVIDUAL_STORE
1036 (object), g_value_get_boolean (value));
1038 case PROP_IS_COMPACT:
1039 empathy_individual_store_set_is_compact (EMPATHY_INDIVIDUAL_STORE
1040 (object), g_value_get_boolean (value));
1042 case PROP_SORT_CRITERIUM:
1043 empathy_individual_store_set_sort_criterium (EMPATHY_INDIVIDUAL_STORE
1044 (object), g_value_get_enum (value));
1047 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
1053 empathy_individual_store_class_init (EmpathyIndividualStoreClass *klass)
1055 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1057 object_class->dispose = individual_store_dispose;
1058 object_class->get_property = individual_store_get_property;
1059 object_class->set_property = individual_store_set_property;
1061 g_object_class_install_property (object_class,
1062 PROP_INDIVIDUAL_MANAGER,
1063 g_param_spec_object ("individual-manager",
1064 "The individual manager",
1065 "The individual manager",
1066 EMPATHY_TYPE_INDIVIDUAL_MANAGER,
1067 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
1068 g_object_class_install_property (object_class,
1070 g_param_spec_boolean ("show-offline",
1072 "Whether contact list should display "
1073 "offline contacts", FALSE, G_PARAM_READWRITE));
1074 g_object_class_install_property (object_class,
1076 g_param_spec_boolean ("show-avatars",
1078 "Whether contact list should display "
1079 "avatars for contacts", TRUE, G_PARAM_READWRITE));
1080 g_object_class_install_property (object_class,
1081 PROP_SHOW_PROTOCOLS,
1082 g_param_spec_boolean ("show-protocols",
1084 "Whether contact list should display "
1085 "protocols for contacts", FALSE, G_PARAM_READWRITE));
1086 g_object_class_install_property (object_class,
1088 g_param_spec_boolean ("show-groups",
1090 "Whether contact list should display "
1091 "contact groups", TRUE, G_PARAM_READWRITE));
1092 g_object_class_install_property (object_class,
1094 g_param_spec_boolean ("is-compact",
1096 "Whether the contact list is in compact mode or not",
1097 FALSE, G_PARAM_READWRITE));
1099 g_object_class_install_property (object_class,
1100 PROP_SORT_CRITERIUM,
1101 g_param_spec_enum ("sort-criterium",
1103 "The sort criterium to use for sorting the contact list",
1104 EMPATHY_TYPE_INDIVIDUAL_STORE_SORT,
1105 EMPATHY_INDIVIDUAL_STORE_SORT_NAME, G_PARAM_READWRITE));
1107 g_type_class_add_private (object_class,
1108 sizeof (EmpathyIndividualStorePriv));
1112 get_position (const char **strv,
1117 for (i = 0; strv[i] != NULL; i++)
1119 if (!tp_strdiff (strv[i], str))
1127 compare_separator_and_groups (gboolean is_separator_a,
1128 gboolean is_separator_b,
1129 const gchar *name_a,
1130 const gchar *name_b,
1131 FolksIndividual *individual_a,
1132 FolksIndividual *individual_b,
1133 gboolean fake_group_a,
1134 gboolean fake_group_b)
1136 /* these two lists are the sorted list of fake groups to include at the
1137 * top and bottom of the roster */
1138 const char *top_groups[] = {
1139 EMPATHY_INDIVIDUAL_STORE_FAVORITE,
1143 const char *bottom_groups[] = {
1144 EMPATHY_INDIVIDUAL_STORE_UNGROUPED,
1148 if (is_separator_a || is_separator_b)
1150 /* We have at least one separator */
1155 else if (is_separator_b)
1161 /* One group and one contact */
1162 if (!individual_a && individual_b)
1166 else if (individual_a && !individual_b)
1170 else if (!individual_a && !individual_b)
1172 gboolean a_in_top, b_in_top, a_in_bottom, b_in_bottom;
1174 a_in_top = fake_group_a && tp_strv_contains (top_groups, name_a);
1175 b_in_top = fake_group_b && tp_strv_contains (top_groups, name_b);
1176 a_in_bottom = fake_group_a && tp_strv_contains (bottom_groups, name_a);
1177 b_in_bottom = fake_group_b && tp_strv_contains (bottom_groups, name_b);
1179 if (a_in_top && b_in_top)
1181 /* compare positions */
1182 return CLAMP (get_position (top_groups, name_a) -
1183 get_position (top_groups, name_b), -1, 1);
1185 else if (a_in_bottom && b_in_bottom)
1187 /* compare positions */
1188 return CLAMP (get_position (bottom_groups, name_a) -
1189 get_position (bottom_groups, name_b), -1, 1);
1191 else if (a_in_top || b_in_bottom)
1195 else if (b_in_top || a_in_bottom)
1201 return g_utf8_collate (name_a, name_b);
1205 /* Two contacts, ordering depends of the sorting policy */
1210 individual_store_contact_sort (FolksIndividual *individual_a,
1211 FolksIndividual *individual_b)
1215 g_return_val_if_fail (individual_a != NULL || individual_b != NULL, 0);
1218 ret_val = g_utf8_collate (folks_individual_get_alias (individual_a),
1219 folks_individual_get_alias (individual_b));
1225 ret_val = g_utf8_collate (folks_individual_get_id (individual_a),
1226 folks_individual_get_id (individual_b));
1236 individual_store_state_sort_func (GtkTreeModel *model,
1237 GtkTreeIter *iter_a,
1238 GtkTreeIter *iter_b,
1242 FolksIndividual *individual_a, *individual_b;
1243 gchar *name_a, *name_b;
1244 gboolean is_separator_a, is_separator_b;
1245 gboolean fake_group_a, fake_group_b;
1246 FolksPresenceType folks_presence_type_a, folks_presence_type_b;
1247 TpConnectionPresenceType tp_presence_a, tp_presence_b;
1249 gtk_tree_model_get (model, iter_a,
1250 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_a,
1251 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_a,
1252 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_a,
1253 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_a, -1);
1254 gtk_tree_model_get (model, iter_b,
1255 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_b,
1256 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_b,
1257 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_b,
1258 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_b, -1);
1260 if (individual_a == NULL || individual_b == NULL)
1262 ret_val = compare_separator_and_groups (is_separator_a, is_separator_b,
1263 name_a, name_b, individual_a, individual_b, fake_group_a,
1268 /* If we managed to get this far, we can start looking at
1271 folks_presence_type_a = folks_individual_get_presence_type (individual_a);
1272 folks_presence_type_b = folks_individual_get_presence_type (individual_b);
1273 tp_presence_a = empathy_folks_presence_type_to_tp (folks_presence_type_a);
1274 tp_presence_b = empathy_folks_presence_type_to_tp (folks_presence_type_b);
1276 ret_val = -tp_connection_presence_type_cmp_availability (tp_presence_a,
1281 /* Fallback: compare by name et al. */
1282 ret_val = individual_store_contact_sort (individual_a, individual_b);
1288 tp_clear_object (&individual_a);
1289 tp_clear_object (&individual_b);
1295 individual_store_name_sort_func (GtkTreeModel *model,
1296 GtkTreeIter *iter_a,
1297 GtkTreeIter *iter_b,
1300 gchar *name_a, *name_b;
1301 FolksIndividual *individual_a, *individual_b;
1302 gboolean is_separator_a = FALSE, is_separator_b = FALSE;
1304 gboolean fake_group_a, fake_group_b;
1306 gtk_tree_model_get (model, iter_a,
1307 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_a,
1308 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_a,
1309 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_a,
1310 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_a, -1);
1311 gtk_tree_model_get (model, iter_b,
1312 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name_b,
1313 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual_b,
1314 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator_b,
1315 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake_group_b, -1);
1317 if (individual_a == NULL || individual_b == NULL)
1318 ret_val = compare_separator_and_groups (is_separator_a, is_separator_b,
1319 name_a, name_b, individual_a, individual_b, fake_group_a, fake_group_b);
1321 ret_val = individual_store_contact_sort (individual_a, individual_b);
1323 tp_clear_object (&individual_a);
1324 tp_clear_object (&individual_b);
1330 individual_store_setup (EmpathyIndividualStore *self)
1332 EmpathyIndividualStorePriv *priv;
1334 GDK_TYPE_PIXBUF, /* Status pixbuf */
1335 GDK_TYPE_PIXBUF, /* Avatar pixbuf */
1336 G_TYPE_BOOLEAN, /* Avatar pixbuf visible */
1337 G_TYPE_STRING, /* Name */
1338 G_TYPE_UINT, /* Presence type */
1339 G_TYPE_STRING, /* Status string */
1340 G_TYPE_BOOLEAN, /* Compact view */
1341 FOLKS_TYPE_INDIVIDUAL, /* Individual type */
1342 G_TYPE_BOOLEAN, /* Is group */
1343 G_TYPE_BOOLEAN, /* Is active */
1344 G_TYPE_BOOLEAN, /* Is online */
1345 G_TYPE_BOOLEAN, /* Is separator */
1346 G_TYPE_BOOLEAN, /* Can make audio calls */
1347 G_TYPE_BOOLEAN, /* Can make video calls */
1348 EMPATHY_TYPE_INDIVIDUAL_MANAGER_FLAGS, /* Flags */
1349 G_TYPE_BOOLEAN, /* Is a fake group */
1352 priv = GET_PRIV (self);
1354 gtk_tree_store_set_column_types (GTK_TREE_STORE (self),
1355 EMPATHY_INDIVIDUAL_STORE_COL_COUNT, types);
1357 /* Set up sorting */
1358 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (self),
1359 EMPATHY_INDIVIDUAL_STORE_COL_NAME,
1360 individual_store_name_sort_func, self, NULL);
1361 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (self),
1362 EMPATHY_INDIVIDUAL_STORE_COL_STATUS,
1363 individual_store_state_sort_func, self, NULL);
1365 priv->sort_criterium = EMPATHY_INDIVIDUAL_STORE_SORT_NAME;
1366 empathy_individual_store_set_sort_criterium (self, priv->sort_criterium);
1370 individual_store_inibit_active_cb (EmpathyIndividualStore *self)
1372 EmpathyIndividualStorePriv *priv;
1374 priv = GET_PRIV (self);
1376 priv->show_active = TRUE;
1377 priv->inhibit_active = 0;
1383 empathy_individual_store_init (EmpathyIndividualStore *self)
1385 EmpathyIndividualStorePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
1386 EMPATHY_TYPE_INDIVIDUAL_STORE, EmpathyIndividualStorePriv);
1389 priv->show_avatars = TRUE;
1390 priv->show_groups = TRUE;
1391 priv->show_protocols = FALSE;
1392 priv->inhibit_active =
1393 g_timeout_add_seconds (ACTIVE_USER_WAIT_TO_ENABLE_TIME,
1394 (GSourceFunc) individual_store_inibit_active_cb, self);
1395 priv->status_icons =
1396 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
1397 individual_store_setup (self);
1400 EmpathyIndividualStore *
1401 empathy_individual_store_new (EmpathyIndividualManager *manager)
1403 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager), NULL);
1405 return g_object_new (EMPATHY_TYPE_INDIVIDUAL_STORE,
1406 "individual-manager", manager, NULL);
1409 EmpathyIndividualManager *
1410 empathy_individual_store_get_manager (EmpathyIndividualStore *self)
1412 EmpathyIndividualStorePriv *priv;
1414 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), FALSE);
1416 priv = GET_PRIV (self);
1418 return priv->manager;
1422 empathy_individual_store_get_show_offline (EmpathyIndividualStore *self)
1424 EmpathyIndividualStorePriv *priv;
1426 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), FALSE);
1428 priv = GET_PRIV (self);
1430 return priv->show_offline;
1434 empathy_individual_store_set_show_offline (EmpathyIndividualStore *self,
1435 gboolean show_offline)
1437 EmpathyIndividualStorePriv *priv;
1438 GList *contacts, *l;
1439 gboolean show_active;
1441 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1443 priv = GET_PRIV (self);
1445 priv->show_offline = show_offline;
1446 show_active = priv->show_active;
1448 /* Disable temporarily. */
1449 priv->show_active = FALSE;
1451 contacts = empathy_individual_manager_get_members (priv->manager);
1452 for (l = contacts; l; l = l->next)
1454 individual_store_contact_update (self, l->data);
1456 g_list_free (contacts);
1458 /* Restore to original setting. */
1459 priv->show_active = show_active;
1461 g_object_notify (G_OBJECT (self), "show-offline");
1465 empathy_individual_store_get_show_avatars (EmpathyIndividualStore *self)
1467 EmpathyIndividualStorePriv *priv;
1469 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1471 priv = GET_PRIV (self);
1473 return priv->show_avatars;
1477 individual_store_update_list_mode_foreach (GtkTreeModel *model,
1480 EmpathyIndividualStore *self)
1482 EmpathyIndividualStorePriv *priv;
1483 gboolean show_avatar = FALSE;
1484 FolksIndividual *individual;
1485 GdkPixbuf *pixbuf_status;
1487 priv = GET_PRIV (self);
1489 if (priv->show_avatars && !priv->is_compact)
1494 gtk_tree_model_get (model, iter,
1495 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
1497 if (individual == NULL)
1501 /* get icon from hash_table */
1503 empathy_individual_store_get_individual_status_icon (self, individual);
1505 gtk_tree_store_set (GTK_TREE_STORE (self), iter,
1506 EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf_status,
1507 EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
1508 EMPATHY_INDIVIDUAL_STORE_COL_COMPACT, priv->is_compact, -1);
1510 g_object_unref (individual);
1516 empathy_individual_store_set_show_avatars (EmpathyIndividualStore *self,
1517 gboolean show_avatars)
1519 EmpathyIndividualStorePriv *priv;
1520 GtkTreeModel *model;
1522 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1524 priv = GET_PRIV (self);
1526 priv->show_avatars = show_avatars;
1528 model = GTK_TREE_MODEL (self);
1530 gtk_tree_model_foreach (model,
1531 (GtkTreeModelForeachFunc)
1532 individual_store_update_list_mode_foreach, self);
1534 g_object_notify (G_OBJECT (self), "show-avatars");
1538 empathy_individual_store_get_show_protocols (EmpathyIndividualStore *self)
1540 EmpathyIndividualStorePriv *priv;
1542 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1544 priv = GET_PRIV (self);
1546 return priv->show_protocols;
1550 empathy_individual_store_set_show_protocols (EmpathyIndividualStore *self,
1551 gboolean show_protocols)
1553 EmpathyIndividualStorePriv *priv;
1554 GtkTreeModel *model;
1556 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1558 priv = GET_PRIV (self);
1560 priv->show_protocols = show_protocols;
1562 model = GTK_TREE_MODEL (self);
1564 gtk_tree_model_foreach (model,
1565 (GtkTreeModelForeachFunc)
1566 individual_store_update_list_mode_foreach, self);
1568 g_object_notify (G_OBJECT (self), "show-protocols");
1572 empathy_individual_store_get_show_groups (EmpathyIndividualStore *self)
1574 EmpathyIndividualStorePriv *priv;
1576 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1578 priv = GET_PRIV (self);
1580 return priv->show_groups;
1584 empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
1585 gboolean show_groups)
1587 EmpathyIndividualStorePriv *priv;
1589 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1591 priv = GET_PRIV (self);
1593 if (priv->show_groups == show_groups)
1598 priv->show_groups = show_groups;
1600 if (priv->setup_idle_id == 0)
1602 /* Remove all contacts and add them back, not optimized but
1603 * that's the easy way :)
1605 * This is only done if there's not a pending setup idle
1606 * callback, otherwise it will race and the contacts will get
1610 gtk_tree_store_clear (GTK_TREE_STORE (self));
1611 contacts = empathy_individual_manager_get_members (priv->manager);
1613 individual_store_members_changed_cb (priv->manager,
1614 "re-adding members: toggled group visibility",
1615 contacts, NULL, 0, self);
1616 g_list_free (contacts);
1619 g_object_notify (G_OBJECT (self), "show-groups");
1623 empathy_individual_store_get_is_compact (EmpathyIndividualStore *self)
1625 EmpathyIndividualStorePriv *priv;
1627 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), TRUE);
1629 priv = GET_PRIV (self);
1631 return priv->is_compact;
1635 empathy_individual_store_set_is_compact (EmpathyIndividualStore *self,
1636 gboolean is_compact)
1638 EmpathyIndividualStorePriv *priv;
1639 GtkTreeModel *model;
1641 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1643 priv = GET_PRIV (self);
1645 priv->is_compact = is_compact;
1647 model = GTK_TREE_MODEL (self);
1649 gtk_tree_model_foreach (model,
1650 (GtkTreeModelForeachFunc)
1651 individual_store_update_list_mode_foreach, self);
1653 g_object_notify (G_OBJECT (self), "is-compact");
1656 EmpathyIndividualStoreSort
1657 empathy_individual_store_get_sort_criterium (EmpathyIndividualStore *self)
1659 EmpathyIndividualStorePriv *priv;
1661 g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), 0);
1663 priv = GET_PRIV (self);
1665 return priv->sort_criterium;
1669 empathy_individual_store_set_sort_criterium (EmpathyIndividualStore *self,
1670 EmpathyIndividualStoreSort sort_criterium)
1672 EmpathyIndividualStorePriv *priv;
1674 g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
1676 priv = GET_PRIV (self);
1678 priv->sort_criterium = sort_criterium;
1680 switch (sort_criterium)
1682 case EMPATHY_INDIVIDUAL_STORE_SORT_STATE:
1683 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self),
1684 EMPATHY_INDIVIDUAL_STORE_COL_STATUS, GTK_SORT_ASCENDING);
1687 case EMPATHY_INDIVIDUAL_STORE_SORT_NAME:
1688 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self),
1689 EMPATHY_INDIVIDUAL_STORE_COL_NAME, GTK_SORT_ASCENDING);
1693 g_object_notify (G_OBJECT (self), "sort-criterium");
1697 empathy_individual_store_row_separator_func (GtkTreeModel *model,
1701 gboolean is_separator = FALSE;
1703 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), FALSE);
1705 gtk_tree_model_get (model, iter,
1706 EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, &is_separator, -1);
1708 return is_separator;
1712 empathy_individual_store_get_parent_group (GtkTreeModel *model,
1714 gboolean *path_is_group,
1715 gboolean *is_fake_group)
1717 GtkTreeIter parent_iter, iter;
1722 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
1726 *path_is_group = FALSE;
1729 if (!gtk_tree_model_get_iter (model, &iter, path))
1734 gtk_tree_model_get (model, &iter,
1735 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group,
1736 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name, -1);
1743 if (!gtk_tree_model_iter_parent (model, &parent_iter, &iter))
1750 gtk_tree_model_get (model, &iter,
1751 EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group,
1752 EMPATHY_INDIVIDUAL_STORE_COL_NAME, &name,
1753 EMPATHY_INDIVIDUAL_STORE_COL_IS_FAKE_GROUP, &fake, -1);
1763 *path_is_group = TRUE;
1766 if (is_fake_group != NULL)
1767 *is_fake_group = fake;
1773 individual_store_get_individual_status_icon_with_icon_name (
1774 EmpathyIndividualStore *self,
1775 FolksIndividual *individual,
1776 const gchar *status_icon_name)
1778 GdkPixbuf *pixbuf_status = NULL;
1779 EmpathyIndividualStorePriv *priv;
1780 const gchar *protocol_name = NULL;
1781 gchar *icon_name = NULL;
1782 GList *personas, *l;
1783 guint contact_count;
1784 EmpathyContact *contact = NULL;
1785 gboolean show_protocols_here;
1787 priv = GET_PRIV (self);
1789 personas = folks_individual_get_personas (individual);
1790 for (l = personas, contact_count = 0; l; l = l->next)
1792 if (TPF_IS_PERSONA (l->data))
1795 if (contact_count > 1)
1799 show_protocols_here = priv->show_protocols && (contact_count == 1);
1800 if (show_protocols_here)
1802 contact = empathy_contact_from_folks_individual (individual);
1803 protocol_name = empathy_protocol_name_for_contact (contact);
1804 icon_name = g_strdup_printf ("%s-%s", status_icon_name, protocol_name);
1808 icon_name = g_strdup_printf ("%s", status_icon_name);
1810 if (pixbuf_status == NULL)
1813 empathy_pixbuf_contact_status_icon_with_icon_name (contact,
1814 status_icon_name, priv->show_protocols);
1815 if (pixbuf_status != NULL)
1817 g_hash_table_insert (priv->status_icons,
1818 g_strdup (icon_name), pixbuf_status);
1823 return pixbuf_status;
1827 empathy_individual_store_get_individual_status_icon (
1828 EmpathyIndividualStore *self,
1829 FolksIndividual *individual)
1831 GdkPixbuf *pixbuf_status = NULL;
1832 const gchar *status_icon_name = NULL;
1834 status_icon_name = empathy_icon_name_for_individual (individual);
1835 if (status_icon_name == NULL)
1839 individual_store_get_individual_status_icon_with_icon_name (self,
1840 individual, status_icon_name);
1842 return pixbuf_status;