[Telepathy-commits] [telepathy-gabble/master] The presence-cache shouldn't handle Gadget's inspector muc presence

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Oct 24 05:23:00 PDT 2008


---
 src/muc-factory.c                   |   17 +++++++++++++++++
 tests/twisted/olpc/gadget-invite.py |    8 ++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/muc-factory.c b/src/muc-factory.c
index df8759e..84e749f 100644
--- a/src/muc-factory.c
+++ b/src/muc-factory.c
@@ -900,6 +900,7 @@ muc_factory_presence_cb (LmMessageHandler *handler,
       if (muc_chan != NULL)
         {
           TpHandle handle;
+          LmMessageNode *item_node;
 
           handle = tp_handle_ensure (contact_repo, from,
               GUINT_TO_POINTER (GABBLE_JID_ROOM_MEMBER), NULL);
@@ -910,6 +911,22 @@ muc_factory_presence_cb (LmMessageHandler *handler,
               return LM_HANDLER_RESULT_REMOVE_MESSAGE;
             }
 
+          item_node = lm_message_node_get_child (x_node, "item");
+          if (item_node != NULL)
+            {
+              const gchar *owner_jid;
+
+              owner_jid = lm_message_node_get_attribute (item_node, "jid");
+              /* We drop OLPC Gadget's inspector presence as activities
+               * doesn't have to see it as a member of the room and the
+               * presence cache should ignore it as well. */
+              if (owner_jid != NULL &&
+                  !tp_strdiff (owner_jid, priv->conn->olpc_gadget_activity))
+                {
+                  return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+                }
+            }
+
           _gabble_muc_channel_member_presence_updated (muc_chan, handle,
                                                        msg, x_node);
           tp_handle_unref (contact_repo, handle);
diff --git a/tests/twisted/olpc/gadget-invite.py b/tests/twisted/olpc/gadget-invite.py
index dc4ba9b..2f43f75 100644
--- a/tests/twisted/olpc/gadget-invite.py
+++ b/tests/twisted/olpc/gadget-invite.py
@@ -56,6 +56,7 @@ def test(q, bus, conn, stream):
 
     act_prop_iface = dbus.Interface(conn, 'org.laptop.Telepathy.ActivityProperties')
     buddy_info_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo')
+    simple_presence_iface = dbus.Interface(conn, 'org.freedesktop.Telepathy.Connection.Interface.SimplePresence')
 
     q.expect('dbus-signal', signal='GadgetDiscovered')
 
@@ -123,6 +124,13 @@ def test(q, bus, conn, stream):
     members = muc_group.GetMembers()
     assert conn.InspectHandles(1, members) == ['myroom at conference.localhost/test']
 
+    # Regression test for a nasty bug caused by the presence cache handling
+    # the inspector presence as a not muc one because the inspector is not
+    # addded to muc's members.
+    handle = conn.RequestHandles(1, ['myroom at conference.localhost'])[0]
+    presence = simple_presence_iface.GetPresences([handle])
+    assert presence[handle] == (7, 'unknown', '')
+
     conn.Disconnect()
 
     # PEP activity update
-- 
1.5.6.5




More information about the Telepathy-commits mailing list