[Telepathy-commits] [telepathy-gabble/master] generate MUC presence messages using the real connection-wide presence

Robert McQueen robert.mcqueen at collabora.co.uk
Tue Aug 19 10:54:02 PDT 2008


With a pedantic interpretation, this is arguable a spec violation because it
exposes your presence to handles who are not on your "publish" list. However, I
think that given other protocols (essentially, anything but XMPP) exist where
joining a chat will always expose your presence, I don't think it's reasonable
for clients or users to rely on this additional exposure not happening anyway.
Consider the absurdity of expecting that you can be invisible even when you've
joined a group chat. If someone wants the XMPP-specific semantics badly, we can
add a RoomPresence interface or somesuch, and they can set a property in order
to publish a per-room presence.

20080727032658-418b8-171a0e74e3910f331a49d333491376e1e73ec9f2.gz
---
 src/muc-channel.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/muc-channel.c b/src/muc-channel.c
index 77e3f9f..05fbe1f 100644
--- a/src/muc-channel.c
+++ b/src/muc-channel.c
@@ -41,6 +41,7 @@
 #include "debug.h"
 #include "disco.h"
 #include "error.h"
+#include "presence.h"
 #include "namespaces.h"
 #include "util.h"
 
@@ -683,8 +684,20 @@ create_presence_message (GabbleMucChannel *self,
   LmMessage *msg;
   LmMessageNode *node;
 
-  msg = lm_message_new_with_sub_type (priv->self_jid->str,
-      LM_MESSAGE_TYPE_PRESENCE, sub_type);
+  /* only take the connection-wide presence if the MUC protocol doesn't rely on
+   * a particular subtype (eg, leaving the room requires type='unavailable') */
+  if (sub_type == LM_MESSAGE_SUB_TYPE_NOT_SET)
+    {
+      /* note that this message doesn't contain capabilities, but that's OK as
+       * most IQ-based protocols won't work in a MUC anyway */
+      msg = gabble_presence_as_message (priv->conn->self_presence,
+          priv->self_jid->str);
+    }
+  else
+    {
+      msg = lm_message_new_with_sub_type (priv->self_jid->str,
+          LM_MESSAGE_TYPE_PRESENCE, sub_type);
+    }
 
   node = lm_message_node_add_child (msg->node, "x", NULL);
   lm_message_node_set_attribute (node, "xmlns", NS_MUC);
-- 
1.5.6.3




More information about the Telepathy-commits mailing list