[Telepathy-commits] [telepathy-gabble/master] add members to activity views

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:16 PDT 2008


20080606124724-7fe3f-243aa8ca19b9c6624d713f12a0dcd59d8dca0ee3.gz
---
 src/conn-olpc.c                            |   18 ++++++++++++++++++
 tests/twisted/olpc/olpc-activity-search.py |   19 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index a9c5c09..fd0045a 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -3461,6 +3461,8 @@ activity_query_result_cb (GabbleConnection *conn,
       GHashTable *properties;
       TpHandle handle;
       ActivityInfo *info;
+      GArray *buddies;
+      GPtrArray *buddies_properties;
 
       jid = lm_message_node_get_attribute (activity, "room");
 
@@ -3496,6 +3498,22 @@ activity_query_result_cb (GabbleConnection *conn,
         }
 
       activity_info_set_properties (info, properties);
+
+      buddies = g_array_new (FALSE, FALSE, sizeof (TpHandle));
+      buddies_properties = g_ptr_array_new ();
+
+      if (!populate_buddies_from_nodes (conn, activity, buddies,
+            buddies_properties))
+        {
+          g_array_free (buddies, TRUE);
+          g_ptr_array_free (buddies_properties, TRUE);
+          continue;
+        }
+
+      gabble_olpc_view_add_buddies (view, buddies, buddies_properties);
+
+      g_array_free (buddies, TRUE);
+      g_ptr_array_free (buddies_properties, TRUE);
     }
 
   /* TODO: remove activities when needed and unref ActivityInfo */
diff --git a/tests/twisted/olpc/olpc-activity-search.py b/tests/twisted/olpc/olpc-activity-search.py
index 8f57615..5dea226 100644
--- a/tests/twisted/olpc/olpc-activity-search.py
+++ b/tests/twisted/olpc/olpc-activity-search.py
@@ -57,6 +57,7 @@ def test(q, bus, conn, stream):
     stream.send(reply)
 
     activity_prop_iface = dbus.Interface(conn, 'org.laptop.Telepathy.ActivityProperties')
+    buddy_prop_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo')
     gadget_iface = dbus.Interface(conn, 'org.laptop.Telepathy.Gadget')
 
     sync_stream(q, stream)
@@ -87,6 +88,13 @@ def test(q, bus, conn, stream):
     property['type'] = 'str'
     property['name'] = 'color'
     property.addContent('#005FE4,#00A0FF')
+    buddy = activity.addElement((None, 'buddy'))
+    buddy['jid'] = 'lucien at localhost'
+    properties = buddy.addElement((NS_OLPC_BUDDY_PROPS, "properties"))
+    property = properties.addElement((None, "property"))
+    property['type'] = 'str'
+    property['name'] = 'color'
+    property.addContent('#AABBCC,#CCBBAA')
     stream.send(reply)
 
     view_path = return_event.value[0]
@@ -98,6 +106,11 @@ def test(q, bus, conn, stream):
     assert conn.InspectHandles(2, [handle])[0] == 'room1 at conference.localhost'
     assert props == {'color': '#005FE4,#00A0FF'}
 
+    # participants are added to view
+    event = q.expect('dbus-signal', signal='BuddiesChanged')
+    members_handles, removed = event.args
+    assert conn.InspectHandles(1, members_handles) == ['lucien at localhost']
+
     event = q.expect('dbus-signal', signal='ActivitiesChanged')
     added, removed = event.args
     assert removed == []
@@ -106,10 +119,14 @@ def test(q, bus, conn, stream):
     act = view0_iface.GetActivities()
     assert sorted(act) == sorted(added)
 
-    # we can now get these properties
+    # we can now get activity properties
     props = activity_prop_iface.GetProperties(handle)
     assert props == {'color': '#005FE4,#00A0FF'}
 
+    # and we can get participant's properties too
+    props = buddy_prop_iface.GetProperties(members_handles[0])
+    assert props == {'color': '#AABBCC,#CCBBAA'}
+
     # 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