- /* Add new presence */
- priv->presences = g_list_insert_sorted (priv->presences,
- g_object_ref (presence),
- gossip_presence_sort_func);
-
- g_object_notify (G_OBJECT (contact), "presences");
-}
-
-void
-gossip_contact_remove_presence (GossipContact *contact,
- GossipPresence *presence)
-{
- GossipContactPriv *priv;
- GossipPresence *this_presence;
- GList *l;
-
- g_return_if_fail (GOSSIP_IS_CONTACT (contact));
- g_return_if_fail (GOSSIP_IS_PRESENCE (presence));
-
- priv = GET_PRIV (contact);
-
- for (l = priv->presences; l; l = l->next) {
- this_presence = l->data;
-
- if (gossip_presence_resource_equal (this_presence, presence)) {
- gint ref_count;
-
- ref_count = G_OBJECT (presence)->ref_count;
-
- /* Remove old presence for this resource, we
- * would use g_list_remove_all() here but we
- * want to make sure we unref for each
- * instance we find it in the list.
- */
- priv->presences = g_list_remove (priv->presences, this_presence);
- g_object_unref (this_presence);
-
- if (!priv->presences || ref_count <= 1) {
- break;
- }
-
- /* Reset list to beginnging to make sure we
- * didn't miss any duplicates.
- */
- l = priv->presences;
- }