ShowActiveData *data;
DEBUG ("Contact:'%s' now active, and %s be removed",
- folks_aliasable_get_alias (FOLKS_ALIASABLE (persona)),
+ folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (persona)),
remove_ ? "WILL" : "WILL NOT");
data = g_slice_new0 (ShowActiveData);
gboolean active,
gboolean set_changed)
{
- EmpathyPersonaStorePriv *priv;
GtkTreePath *path;
GtkTreeIter iter;
- priv = GET_PRIV (self);
-
path = find_persona (self, persona);
if (path == NULL)
return;
persona_active_cb (ShowActiveData *data)
{
const gchar *alias =
- folks_aliasable_get_alias (FOLKS_ALIASABLE (data->persona));
+ folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (data->persona));
if (data->remove)
{
EmpathyPersonaStore *self)
{
DEBUG ("Contact:'%s' updated, checking roster is in sync...",
- folks_aliasable_get_alias (FOLKS_ALIASABLE (persona)));
+ folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (persona)));
update_persona (self, persona);
}
GtkTreeIter iter;
GtkTreePath *path;
FolksPersonaStore *store;
+ TpContact *tp_contact;
EmpathyContact *contact;
const gchar *alias;
priv = GET_PRIV (self);
- alias = folks_aliasable_get_alias (FOLKS_ALIASABLE (persona));
+ alias = folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (persona));
if (EMP_STR_EMPTY (alias))
return;
- contact = empathy_contact_dup_from_tp_contact (tpf_persona_get_contact (
- TPF_PERSONA (persona)));
+ tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+ if (tp_contact == NULL)
+ return;
+
+ contact = empathy_contact_dup_from_tp_contact (tp_contact);
store = folks_persona_get_store (persona);
gtk_list_store_insert_with_values (GTK_LIST_STORE (self), &iter, 0,
FolksPersona *persona)
{
EmpathyPersonaStorePriv *priv = GET_PRIV (self);
+ TpContact *tp_contact;
EmpathyContact *contact;
const gchar *protocol_name = NULL;
gchar *icon_name = NULL;
GdkPixbuf *pixbuf_status = NULL;
const gchar *status_icon_name = NULL;
- contact = empathy_contact_dup_from_tp_contact (tpf_persona_get_contact (
- TPF_PERSONA (persona)));
+ tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+ if (tp_contact == NULL)
+ return NULL;
+
+ contact = empathy_contact_dup_from_tp_contact (tp_contact);
status_icon_name = empathy_icon_name_for_contact (contact);
if (status_icon_name == NULL)
const gchar *alias;
path = find_persona (self, persona);
- alias = folks_aliasable_get_alias (FOLKS_ALIASABLE (persona));
+ alias = folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (persona));
if (path == NULL)
{
else
{
FolksPersonaStore *store;
+ TpContact *tp_contact;
EmpathyContact *contact;
GtkTreeIter iter;
- GdkPixbuf *pixbuf_avatar;
+ GdkPixbuf *pixbuf_avatar = NULL;
GdkPixbuf *pixbuf_status;
gboolean now_online = FALSE;
gboolean was_online = TRUE;
gtk_tree_path_free (path);
/* Get online state now. */
- now_online = folks_presence_is_online (FOLKS_PRESENCE (persona));
+ now_online = folks_presence_details_is_online (
+ FOLKS_PRESENCE_DETAILS (persona));
/* Get online state before. */
gtk_tree_model_get (GTK_TREE_MODEL (self), &iter,
}
/* We still need to use EmpathyContact for the capabilities stuff */
- contact = empathy_contact_dup_from_tp_contact (tpf_persona_get_contact (
- TPF_PERSONA (persona)));
- store = folks_persona_get_store (persona);
-
- pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
- 32, 32);
- pixbuf_status = get_persona_status_icon (self, persona);
-
- gtk_list_store_set (GTK_LIST_STORE (self), &iter,
- EMPATHY_PERSONA_STORE_COL_ICON_STATUS, pixbuf_status,
- EMPATHY_PERSONA_STORE_COL_PIXBUF_AVATAR, pixbuf_avatar,
- EMPATHY_PERSONA_STORE_COL_PIXBUF_AVATAR_VISIBLE, priv->show_avatars,
- EMPATHY_PERSONA_STORE_COL_NAME, alias,
- EMPATHY_PERSONA_STORE_COL_ACCOUNT_NAME,
- folks_persona_store_get_display_name (store),
- EMPATHY_PERSONA_STORE_COL_DISPLAY_ID,
- folks_persona_get_display_id (persona),
- EMPATHY_PERSONA_STORE_COL_PRESENCE_TYPE,
- folks_presence_get_presence_type (FOLKS_PRESENCE (persona)),
- EMPATHY_PERSONA_STORE_COL_STATUS,
- folks_presence_get_presence_message (FOLKS_PRESENCE (persona)),
- EMPATHY_PERSONA_STORE_COL_IS_ONLINE, now_online,
- EMPATHY_PERSONA_STORE_COL_CAN_AUDIO_CALL,
- empathy_contact_get_capabilities (contact) &
- EMPATHY_CAPABILITIES_AUDIO,
- EMPATHY_PERSONA_STORE_COL_CAN_VIDEO_CALL,
- empathy_contact_get_capabilities (contact) &
- EMPATHY_CAPABILITIES_VIDEO,
- -1);
-
- g_object_unref (contact);
+ tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+ if (tp_contact != NULL)
+ {
+ contact = empathy_contact_dup_from_tp_contact (tp_contact);
+ store = folks_persona_get_store (persona);
+
+ pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (contact,
+ 32, 32);
+ pixbuf_status = get_persona_status_icon (self, persona);
+
+ gtk_list_store_set (GTK_LIST_STORE (self), &iter,
+ EMPATHY_PERSONA_STORE_COL_ICON_STATUS, pixbuf_status,
+ EMPATHY_PERSONA_STORE_COL_PIXBUF_AVATAR, pixbuf_avatar,
+ EMPATHY_PERSONA_STORE_COL_PIXBUF_AVATAR_VISIBLE,
+ priv->show_avatars,
+ EMPATHY_PERSONA_STORE_COL_NAME, alias,
+ EMPATHY_PERSONA_STORE_COL_ACCOUNT_NAME,
+ folks_persona_store_get_display_name (store),
+ EMPATHY_PERSONA_STORE_COL_DISPLAY_ID,
+ folks_persona_get_display_id (persona),
+ EMPATHY_PERSONA_STORE_COL_PRESENCE_TYPE,
+ folks_presence_details_get_presence_type (
+ FOLKS_PRESENCE_DETAILS (persona)),
+ EMPATHY_PERSONA_STORE_COL_STATUS,
+ folks_presence_details_get_presence_message (
+ FOLKS_PRESENCE_DETAILS (persona)),
+ EMPATHY_PERSONA_STORE_COL_IS_ONLINE, now_online,
+ EMPATHY_PERSONA_STORE_COL_CAN_AUDIO_CALL,
+ empathy_contact_get_capabilities (contact) &
+ EMPATHY_CAPABILITIES_AUDIO,
+ EMPATHY_PERSONA_STORE_COL_CAN_VIDEO_CALL,
+ empathy_contact_get_capabilities (contact) &
+ EMPATHY_CAPABILITIES_VIDEO,
+ -1);
+
+ g_object_unref (contact);
+ }
if (pixbuf_avatar)
g_object_unref (pixbuf_avatar);
static void
individual_personas_changed_cb (GObject *object,
- GList *added,
- GList *removed,
+ GeeSet *added,
+ GeeSet *removed,
EmpathyPersonaStore *self)
{
- GList *l;
+ GeeIterator *iter;
/* One of the personas' row references might hold the last reference to the
* PersonaStore, so we need to keep a reference ourselves so we don't get
g_object_ref (self);
/* Remove the old personas. */
- for (l = removed; l != NULL; l = l->next)
- remove_persona_and_disconnect (self, FOLKS_PERSONA (l->data));
+ iter = gee_iterable_iterator (GEE_ITERABLE (removed));
+ while (gee_iterator_next (iter))
+ {
+ FolksPersona *persona = gee_iterator_get (iter);
+ remove_persona_and_disconnect (self, persona);
+ g_clear_object (&persona);
+ }
+ g_clear_object (&iter);
/* Add each of the new personas to the tree model */
- for (l = added; l != NULL; l = l->next)
- add_persona_and_connect (self, FOLKS_PERSONA (l->data));
+ iter = gee_iterable_iterator (GEE_ITERABLE (added));
+ while (gee_iterator_next (iter))
+ {
+ FolksPersona *persona = gee_iterator_get (iter);
+ add_persona_and_connect (self, persona);
+ g_clear_object (&persona);
+ }
+ g_clear_object (&iter);
g_object_unref (self);
}
{
EmpathyContact *contact;
TpAccount *account_a, *account_b;
+ TpContact *tp_contact_a, *tp_contact_b;
gint ret_val;
g_return_val_if_fail (persona_a != NULL || persona_b != NULL, 0);
/* alias */
ret_val = g_utf8_collate (
- folks_aliasable_get_alias (FOLKS_ALIASABLE (persona_a)),
- folks_aliasable_get_alias (FOLKS_ALIASABLE (persona_b)));
+ folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (persona_a)),
+ folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (persona_b)));
if (ret_val != 0)
goto out;
if (ret_val != 0)
goto out;
- contact = empathy_contact_dup_from_tp_contact (tpf_persona_get_contact (
- TPF_PERSONA (persona_a)));
+ tp_contact_a = tpf_persona_get_contact (TPF_PERSONA (persona_a));
+ tp_contact_b = tpf_persona_get_contact (TPF_PERSONA (persona_b));
+
+ /* handle the case that one or more of these personas are from the cache */
+ if (tp_contact_a == NULL || tp_contact_b == NULL)
+ {
+ ret_val = (tp_contact_a != NULL ? 1 : -1);
+ goto out;
+ }
+
+ contact = empathy_contact_dup_from_tp_contact (tp_contact_a);
account_a = empathy_contact_get_account (contact);
g_object_unref (contact);
- contact = empathy_contact_dup_from_tp_contact (tpf_persona_get_contact (
- TPF_PERSONA (persona_b)));
+ contact = empathy_contact_dup_from_tp_contact (tp_contact_b);
account_b = empathy_contact_get_account (contact);
g_object_unref (contact);
/* protocol */
ret_val = strcmp (tp_account_get_protocol (account_a),
- tp_account_get_protocol (account_a));
+ tp_account_get_protocol (account_b));
if (ret_val != 0)
goto out;
/* account ID */
ret_val = strcmp (tp_proxy_get_object_path (account_a),
- tp_proxy_get_object_path (account_a));
+ tp_proxy_get_object_path (account_b));
out:
return ret_val;
* the presences.
*/
ret_val = -tp_connection_presence_type_cmp_availability (
- folks_presence_get_presence_type (FOLKS_PRESENCE (persona_a)),
- folks_presence_get_presence_type (FOLKS_PRESENCE (persona_b)));
+ folks_presence_details_get_presence_type (
+ FOLKS_PRESENCE_DETAILS (persona_a)),
+ folks_presence_details_get_presence_type (
+ FOLKS_PRESENCE_DETAILS (persona_b)));
if (ret_val == 0) {
/* Fallback: compare by name et al. */
{
EmpathyPersonaStorePriv *priv = GET_PRIV (object);
- g_hash_table_destroy (priv->status_icons);
- g_hash_table_destroy (priv->personas);
+ g_hash_table_unref (priv->status_icons);
+ g_hash_table_unref (priv->personas);
G_OBJECT_CLASS (empathy_persona_store_parent_class)->finalize (object);
}
/* Remove the old individual */
if (priv->individual != NULL)
{
- GList *personas, *l;
+ GeeSet *personas;
+ GeeIterator *iter;
g_signal_handlers_disconnect_by_func (priv->individual,
(GCallback) individual_personas_changed_cb, self);
/* Disconnect from and remove all personas belonging to this individual */
personas = folks_individual_get_personas (priv->individual);
- for (l = personas; l != NULL; l = l->next)
- remove_persona_and_disconnect (self, FOLKS_PERSONA (l->data));
+ iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+ while (gee_iterator_next (iter))
+ {
+ FolksPersona *persona = gee_iterator_get (iter);
+ remove_persona_and_disconnect (self, persona);
+ g_clear_object (&persona);
+ }
+ g_clear_object (&iter);
g_object_unref (priv->individual);
}
/* Add the new individual */
if (individual != NULL)
{
- GList *personas, *l;
+ GeeSet *personas;
+ GeeIterator *iter;
g_object_ref (individual);
(GCallback) individual_personas_changed_cb, self);
/* Add pre-existing Personas */
+
personas = folks_individual_get_personas (individual);
- for (l = personas; l != NULL; l = l->next)
- add_persona_and_connect (self, FOLKS_PERSONA (l->data));
+ iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+ while (gee_iterator_next (iter))
+ {
+ FolksPersona *persona = gee_iterator_get (iter);
+ add_persona_and_connect (self, persona);
+ g_clear_object (&persona);
+ }
+ g_clear_object (&iter);
}
g_object_notify (G_OBJECT (self), "individual");