diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2010-08-18 19:04:54 +0200 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2010-08-18 19:04:54 +0200 |
commit | 557b5ea02725ca97c68c57c8724ed70495c43ceb (patch) | |
tree | 010ed9a36f3922a4ffc2b57c2a1939a7192626b4 /src/conn-olpc.c | |
parent | 78a857f6db363b3c23561623e46ddaf80ccb2ba3 (diff) | |
download | telepathy-gabble-557b5ea02725ca97c68c57c8724ed70495c43ceb.tar.gz |
SetActivities needs to merge new activities within the existing ones
instead of creating new ones because they may be already referenced by
muc channels.
Diffstat (limited to 'src/conn-olpc.c')
-rw-r--r-- | src/conn-olpc.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/conn-olpc.c b/src/conn-olpc.c index 707fa7eea..68180d6b6 100644 --- a/src/conn-olpc.c +++ b/src/conn-olpc.c @@ -1205,6 +1205,8 @@ olpc_buddy_info_set_activities (GabbleSvcOLPCBuddyInfo *iface, GValue pair = {0,}; gchar *id; guint channel; + const gchar *room = NULL; + GabbleOlpcActivity *activity; GError *error = NULL; g_value_init (&pair, GABBLE_STRUCT_TYPE_ACTIVITY); @@ -1214,8 +1216,9 @@ olpc_buddy_info_set_activities (GabbleSvcOLPCBuddyInfo *iface, 1, &channel, G_MAXUINT); - if (!add_activity (conn, id, channel, &error)) + if (!tp_handle_is_valid (room_repo, channel, &error)) { + DEBUG ("Invalid room handle"); dbus_g_method_return_error (context, error); /* We have to unref information previously @@ -1232,6 +1235,49 @@ olpc_buddy_info_set_activities (GabbleSvcOLPCBuddyInfo *iface, return; } + room = tp_handle_inspect (room_repo, channel); + + activity = g_hash_table_lookup (conn->olpc_activities_info, + GUINT_TO_POINTER (channel)); + + if (activity == NULL) + { + activity = add_activity_info (conn, channel); + } + else + { + if (tp_handle_set_is_member (activities_set, channel)) + { + error = g_error_new (TP_ERRORS, + TP_ERROR_INVALID_ARGUMENT, + "Can't set twice the same activity: %s", room); + + DEBUG ("activity already added: %s", room); + dbus_g_method_return_error (context, error); + + /* We have to unref information previously + * refed in this loop */ + tp_handle_set_foreach (activities_set, + decrement_contacts_activities_set_foreach, conn); + + /* set_activities failed so we don't unref old activities + * of the local user */ + + tp_handle_set_destroy (activities_set); + g_error_free (error); + g_free (activity); + g_free (id); + return; + } + + g_object_ref (activity); + + DEBUG ("ref: %s (%d) refcount: %d\n", + gabble_olpc_activity_get_room (activity), + activity->room, G_OBJECT (activity)->ref_count); + } + + g_object_set (activity, "id", id, NULL); g_free (id); tp_handle_set_add (activities_set, channel); |