[Telepathy-commits] [telepathy-gabble/master] roster.c: ref handles expected to be valid in later roster edit callback
Senko Rasic
senko.rasic at collabora.co.uk
Tue Jan 20 02:49:26 PST 2009
---
src/roster.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/roster.c b/src/roster.c
index e183cad..3bf52ec 100644
--- a/src/roster.c
+++ b/src/roster.c
@@ -1899,6 +1899,8 @@ roster_item_apply_edits (GabbleRoster *roster,
TpHandleRepoIface *group_repo = tp_base_connection_get_handles (
(TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_GROUP);
GabbleRosterItemEdit *edits = item->unsent_edits;
+ TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+ (TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
LmMessage *message;
DEBUG ("Applying edits to contact#%u", contact);
@@ -2016,6 +2018,7 @@ roster_item_apply_edits (GabbleRoster *roster,
}
DEBUG ("Contact#%u did change, sending message", contact);
+ tp_handle_ref (contact_repo, contact);
message = _gabble_roster_item_to_message (roster, contact, NULL,
&edited_item);
ret = _gabble_connection_send_with_reply (priv->conn,
@@ -2051,6 +2054,8 @@ roster_edited_cb (GabbleConnection *conn,
GabbleRoster *roster = GABBLE_ROSTER (roster_obj);
TpHandle contact = GPOINTER_TO_UINT (user_data);
GabbleRosterItem *item = _gabble_roster_item_get (roster, contact);
+ TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+ (TpBaseConnection *) conn, TP_HANDLE_TYPE_CONTACT);
if (item->unsent_edits)
{
@@ -2058,6 +2063,8 @@ roster_edited_cb (GabbleConnection *conn,
roster_item_apply_edits (roster, contact, item);
}
+ tp_handle_unref (contact_repo, contact);
+
return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
@@ -2141,6 +2148,7 @@ gabble_roster_handle_set_blocked (GabbleRoster *roster,
message = _gabble_roster_item_to_message (roster, handle, NULL, NULL);
item->google_type = orig_type;
+ tp_handle_ref (contact_repo, handle);
ret = _gabble_connection_send_with_reply (priv->conn,
message, roster_edited_cb, G_OBJECT (roster),
GUINT_TO_POINTER(handle), error);
@@ -2239,6 +2247,7 @@ gabble_roster_handle_set_name (GabbleRoster *roster,
lm_message_node_set_attribute (item_node, "name", name);
+ tp_handle_ref (contact_repo, handle);
ret = _gabble_connection_send_with_reply (priv->conn,
message, roster_edited_cb, G_OBJECT (roster),
GUINT_TO_POINTER(handle), error);
@@ -2288,6 +2297,7 @@ gabble_roster_handle_remove (GabbleRoster *roster,
subscription = item->subscription;
item->subscription = GABBLE_ROSTER_SUBSCRIPTION_REMOVE;
+ tp_handle_ref (contact_repo, handle);
message = _gabble_roster_item_to_message (roster, handle, NULL, NULL);
ret = _gabble_connection_send_with_reply (priv->conn,
message, roster_edited_cb, G_OBJECT (roster),
@@ -2347,6 +2357,7 @@ gabble_roster_handle_add (GabbleRoster *roster,
item->unsent_edits = item_edit_new ();
}
+ tp_handle_ref (contact_repo, handle);
message = _gabble_roster_item_to_message (roster, handle, NULL, NULL);
ret = _gabble_connection_send_with_reply (priv->conn,
message, roster_edited_cb, G_OBJECT (roster),
@@ -2408,6 +2419,7 @@ gabble_roster_handle_add_to_group (GabbleRoster *roster,
NODE_DEBUG (message->node, "Roster item as message");
tp_handle_set_remove (item->groups, group);
+ tp_handle_ref (contact_repo, handle);
ret = _gabble_connection_send_with_reply (priv->conn,
message, roster_edited_cb, G_OBJECT (roster),
GUINT_TO_POINTER(handle), error);
@@ -2475,6 +2487,7 @@ gabble_roster_handle_remove_from_group (GabbleRoster *roster,
tp_handle_set_add (item->groups, group);
tp_handle_unref (group_repo, group);
+ tp_handle_ref (contact_repo, handle);
ret = _gabble_connection_send_with_reply (priv->conn,
message, roster_edited_cb, G_OBJECT (roster),
GUINT_TO_POINTER(handle), error);
--
1.5.6.5
More information about the Telepathy-commits
mailing list