[Telepathy-commits] [telepathy-gabble/master] emit the BuddyInfo.PropertiesChanged signal after buddies have been added to the view so client are already aware of them

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


20080611153517-7fe3f-d28d0436e2cd2e0b4c16985349f3b2d4e3bbabf4.gz
---
 src/conn-olpc.c                         |   23 +++++++++++++++--------
 tests/twisted/olpc/olpc-buddy-search.py |   10 +++++-----
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index 5905ead..99a2e19 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -2985,11 +2985,6 @@ populate_buddies_from_nodes (GabbleConnection *conn,
           "property");
 
       g_ptr_array_add (buddies_properties, properties);
-
-      /* FIXME: is it sane to fire this signal as the client doesn't know
-       * this buddy yet? */
-      gabble_svc_olpc_buddy_info_emit_properties_changed (conn, handle,
-          properties);
     }
 
   return TRUE;
@@ -3020,10 +3015,22 @@ add_buddies_to_view_from_node (GabbleConnection *conn,
   gabble_olpc_view_add_buddies (view, buddies, buddies_properties);
 
   for (i = 0; i < buddies->len; i++)
-    tp_handle_unref (contact_repo, g_array_index (buddies, TpHandle, i));
-  g_array_free (buddies, TRUE);
+    {
+      TpHandle handle;
+      GHashTable *properties;
+
+      handle = g_array_index (buddies, TpHandle, i);
+      properties = g_ptr_array_index (buddies_properties, i);
 
-  g_ptr_array_foreach (buddies_properties, (GFunc) g_hash_table_unref, NULL);
+      gabble_svc_olpc_buddy_info_emit_properties_changed (conn, handle,
+          properties);
+
+      /* Free the ressource allocated in populate_buddies_from_nodes */
+      tp_handle_unref (contact_repo, handle);
+      g_hash_table_unref (properties);
+    }
+
+  g_array_free (buddies, TRUE);
   g_ptr_array_free (buddies_properties, TRUE);
 
   return TRUE;
diff --git a/tests/twisted/olpc/olpc-buddy-search.py b/tests/twisted/olpc/olpc-buddy-search.py
index 1f7f42d..928a48e 100644
--- a/tests/twisted/olpc/olpc-buddy-search.py
+++ b/tests/twisted/olpc/olpc-buddy-search.py
@@ -193,11 +193,6 @@ def test(q, bus, conn, stream):
     view1 = bus.get_object(conn.bus_name, view_path)
     view1_iface = dbus.Interface(view1, 'org.laptop.Telepathy.View')
 
-    event = q.expect('dbus-signal', signal='PropertiesChanged')
-    handle, props = event.args
-    assert conn.InspectHandles(1, [handle])[0] == 'charles at localhost'
-    assert props == {'color': '#AABBCC,#001122'}
-
     event = q.expect('dbus-signal', signal='BuddiesChanged')
     added, removed = event.args
     assert removed == []
@@ -205,6 +200,11 @@ def test(q, bus, conn, stream):
     handle = added[0]
     assert conn.InspectHandles(1, [handle])[0] == 'charles at localhost'
 
+    event = q.expect('dbus-signal', signal='PropertiesChanged')
+    handle, props = event.args
+    assert conn.InspectHandles(1, [handle])[0] == 'charles at localhost'
+    assert props == {'color': '#AABBCC,#001122'}
+
     # add a buddy to view 0
     message = domish.Element((None, 'message'))
     message['from'] = 'gadget.localhost'
-- 
1.5.6.5




More information about the Telepathy-commits mailing list