[Telepathy-commits] [telepathy-gabble/master] store ActivityInfo for activities in views
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:12 PDT 2008
20080526093432-7fe3f-2655c0fe857f72fda82e36043ee7bea5f44f4685.gz
---
src/conn-olpc.c | 19 ++++++++++++++++++-
tests/twisted/olpc/olpc-activity-search.py | 4 ++++
2 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index d10d2b4..69186a9 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -3159,6 +3159,9 @@ conn_olpc_activity_properties_init (GabbleConnection *conn)
/* Active activities views
*
* view id guint => GabbleOlpcActivityView
+ *
+ * Each activity in the view represents a reference
+ * to an ActivityInfo
*/
conn->olpc_activity_views = g_hash_table_new_full (g_direct_hash,
g_direct_equal, NULL, (GDestroyNotify) g_object_unref);
@@ -3421,6 +3424,7 @@ activity_query_result_cb (GabbleConnection *conn,
LmMessageNode *properties_node;
GHashTable *properties;
TpHandle handle;
+ ActivityInfo *info;
jid = lm_message_node_get_attribute (activity, "room");
@@ -3443,10 +3447,23 @@ activity_query_result_cb (GabbleConnection *conn,
gabble_svc_olpc_activity_properties_emit_activity_properties_changed (
conn, handle, properties);
- g_hash_table_destroy (properties);
+ /* ref the activity while it is in the view */
+ info = g_hash_table_lookup (conn->olpc_activities_info,
+ GUINT_TO_POINTER (handle));
+ if (info == NULL)
+ {
+ info = add_activity_info (conn, handle);
+ }
+ else
+ {
+ info->refcount++;
+ }
+
+ activity_info_set_properties (info, properties);
}
/* TODO: remove activities when needed */
+ /* TODO: unref ActivityInfo when removing */
gabble_olpc_activity_view_add_activities (view, activities);
tp_handle_set_destroy (activities);
diff --git a/tests/twisted/olpc/olpc-activity-search.py b/tests/twisted/olpc/olpc-activity-search.py
index a91aca9..fbc64f2 100644
--- a/tests/twisted/olpc/olpc-activity-search.py
+++ b/tests/twisted/olpc/olpc-activity-search.py
@@ -98,6 +98,10 @@ def test(q, bus, conn, stream):
assert conn.InspectHandles(2, [handle])[0] == 'room1 at conference.localhost'
assert props == {'color': '#005FE4,#00A0FF'}
+ # we can now get these properties
+ props = activity_prop_iface.GetProperties(handle)
+ assert props == {'color': '#005FE4,#00A0FF'}
+
# activity search by properties
props = {'color': '#AABBCC,#001122'}
call_async(q, gadget_iface, 'SearchActivitiesByProperties', props)
--
1.5.6.5
More information about the Telepathy-commits
mailing list