if (group != NULL)
{
- FolksPersona *persona = empathy_contact_get_persona (
- information->contact);
-
- if (persona != NULL && FOLKS_IS_GROUPS (persona))
- folks_groups_change_group (FOLKS_GROUPS (persona), group, !was_enabled);
-
+ empathy_contact_change_group (information->contact, group, !was_enabled);
g_free (group);
}
}
GtkTreeView *view;
GtkListStore *store;
GtkTreeIter iter;
- FolksPersona *persona;
const gchar *group;
view = GTK_TREE_VIEW (information->treeview_groups);
COL_ENABLED, TRUE,
-1);
- persona = empathy_contact_get_persona (information->contact);
-
- if (persona != NULL && FOLKS_IS_GROUPS (persona))
- folks_groups_change_group (FOLKS_GROUPS (persona), group, TRUE);
+ empathy_contact_change_group (information->contact, group, TRUE);
}
static void
* more fields by searching the address using geoclue.
*/
GHashTable *location;
+ GHashTable *groups;
} EmpathyContactPriv;
static void contact_finalize (GObject *object);
contact->priv = priv;
priv->location = NULL;
+ priv->groups = NULL;
}
static void
DEBUG ("finalize: %p", object);
+ if (priv->groups != NULL)
+ g_hash_table_destroy (priv->groups);
g_free (priv->alias);
g_free (priv->id);
g_free (priv->presence_message);
g_object_unref (contact);
}
+void
+empathy_contact_change_group (EmpathyContact *contact, const gchar *group,
+ gboolean is_member)
+{
+ EmpathyContactPriv *priv;
+ FolksPersona *persona;
+
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+ g_return_if_fail (group != NULL);
+
+ priv = GET_PRIV (contact);
+
+ /* Normally pass through the changes to the persona */
+ persona = empathy_contact_get_persona (contact);
+ if (persona != NULL)
+ {
+ if (FOLKS_IS_GROUPS (persona))
+ folks_groups_change_group (FOLKS_GROUPS (persona), group, is_member);
+ return;
+ }
+
+ /* If the persona doesn't exist yet, we have to cache the changes until it
+ * does */
+ if (priv->groups == NULL)
+ {
+ priv->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
+ NULL);
+ }
+
+ g_hash_table_insert (priv->groups, g_strdup (group),
+ GUINT_TO_POINTER (is_member));
+}
+
EmpathyAvatar *
empathy_contact_get_avatar (EmpathyContact *contact)
{
* empathy_contact_set_alias() before we had a persona; this happens when
* adding a contact. */
empathy_contact_set_alias (contact, priv->alias);
+
+ /* Set the persona's groups */
+ if (priv->groups != NULL)
+ {
+ if (FOLKS_IS_GROUPS (persona))
+ folks_groups_set_groups (FOLKS_GROUPS (persona), priv->groups);
+
+ g_hash_table_destroy (priv->groups);
+ priv->groups = NULL;
+ }
}
TpConnection *
void empathy_contact_set_id (EmpathyContact *contact, const gchar *id);
const gchar * empathy_contact_get_alias (EmpathyContact *contact);
void empathy_contact_set_alias (EmpathyContact *contact, const gchar *alias);
+void empathy_contact_change_group (EmpathyContact *contact, const gchar *group,
+ gboolean is_member);
EmpathyAvatar * empathy_contact_get_avatar (EmpathyContact *contact);
void empathy_contact_set_avatar (EmpathyContact *contact,
EmpathyAvatar *avatar);