static GList * contact_manager_get_groups (EmpathyContactList *manager, EmpathyContact *contact) { EmpathyContactManagerPriv *priv = GET_PRIV (manager); EmpathyContactList *list; TpConnection *connection; g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL); connection = empathy_contact_get_connection (contact); list = g_hash_table_lookup (priv->lists, connection); if (list) { return empathy_contact_list_get_groups (list, contact); } return NULL; }
static void contact_widget_groups_populate_data (EmpathyContactWidget *information) { GtkTreeView *view; GtkListStore *store; GtkTreeIter iter; GList *my_groups, *l; GList *all_groups; view = GTK_TREE_VIEW (information->treeview_groups); store = GTK_LIST_STORE (gtk_tree_view_get_model (view)); gtk_list_store_clear (store); all_groups = empathy_contact_list_get_all_groups ( EMPATHY_CONTACT_LIST (information->manager)); my_groups = empathy_contact_list_get_groups ( EMPATHY_CONTACT_LIST (information->manager), information->contact); for (l = all_groups; l; l = l->next) { const gchar *group_str; gboolean enabled; group_str = l->data; enabled = g_list_find_custom (my_groups, group_str, (GCompareFunc) strcmp) != NULL; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_NAME, group_str, COL_EDITABLE, TRUE, COL_ENABLED, enabled, -1); } g_list_foreach (all_groups, (GFunc) g_free, NULL); g_list_foreach (my_groups, (GFunc) g_free, NULL); g_list_free (all_groups); g_list_free (my_groups); }
static void contact_list_store_add_contact (EmpathyContactListStore *store, EmpathyContact *contact) { EmpathyContactListStorePriv *priv; GtkTreeIter iter; GList *groups = NULL, *l; priv = GET_PRIV (store); if (EMP_STR_EMPTY (empathy_contact_get_name (contact)) || (!priv->show_offline && !empathy_contact_is_online (contact))) { return; } if (priv->show_groups) { groups = empathy_contact_list_get_groups (priv->list, contact); } /* If no groups just add it at the top level. */ if (!groups) { gtk_tree_store_append (GTK_TREE_STORE (store), &iter, NULL); gtk_tree_store_set (GTK_TREE_STORE (store), &iter, EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact), EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact, EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_AUDIO, EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_VIDEO, -1); } /* Else add to each group. */ for (l = groups; l; l = l->next) { GtkTreeIter iter_group; contact_list_store_get_group (store, l->data, &iter_group, NULL, NULL); gtk_tree_store_insert_after (GTK_TREE_STORE (store), &iter, &iter_group, NULL); gtk_tree_store_set (GTK_TREE_STORE (store), &iter, EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact), EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact, EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_AUDIO, EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_VIDEO, -1); g_free (l->data); } g_list_free (groups); contact_list_store_contact_update (store, contact); }
static void contact_list_store_add_contact (EmpathyContactListStore *store, EmpathyContact *contact) { EmpathyContactListStorePriv *priv; GtkTreeIter iter; GList *groups = NULL, *l; TpConnection *connection; EmpathyContactListFlags flags = 0; priv = GET_PRIV (store); if (EMP_STR_EMPTY (empathy_contact_get_name (contact)) || (!priv->show_offline && !empathy_contact_is_online (contact))) { return; } if (priv->show_groups) { groups = empathy_contact_list_get_groups (priv->list, contact); } connection = empathy_contact_get_connection (contact); if (EMPATHY_IS_CONTACT_MANAGER (priv->list)) { flags = empathy_contact_manager_get_flags_for_connection ( EMPATHY_CONTACT_MANAGER (priv->list), connection); } /* If no groups just add it at the top level. */ if (!groups) { GtkTreeModel *model = GTK_TREE_MODEL (store); if (gtk_tree_model_get_iter_first (model, &iter)) do { EmpathyContact *c; gtk_tree_model_get (model, &iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &c, -1); if (c == contact) { g_object_unref (c); return; } if (c != NULL) g_object_unref (c); } while (gtk_tree_model_iter_next (model, &iter)); gtk_tree_store_append (GTK_TREE_STORE (store), &iter, NULL); gtk_tree_store_set (GTK_TREE_STORE (store), &iter, EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact), EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact, EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_AUDIO, EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_VIDEO, EMPATHY_CONTACT_LIST_STORE_COL_FLAGS, flags, -1); } /* Else add to each group. */ for (l = groups; l; l = l->next) { GtkTreeIter iter_group; contact_list_store_get_group (store, l->data, &iter_group, NULL, NULL); gtk_tree_store_insert_after (GTK_TREE_STORE (store), &iter, &iter_group, NULL); gtk_tree_store_set (GTK_TREE_STORE (store), &iter, EMPATHY_CONTACT_LIST_STORE_COL_NAME, empathy_contact_get_name (contact), EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, contact, EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_IS_SEPARATOR, FALSE, EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_AUDIO, EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL, empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_VIDEO, EMPATHY_CONTACT_LIST_STORE_COL_FLAGS, flags, -1); g_free (l->data); } g_list_free (groups); contact_list_store_contact_update (store, contact); }