]> code.delx.au - pymsnt/commitdiff
Conference rooms now show up as such in service discovery.
authorJames Bunton <jamesbunton@fastmail.fm>
Sun, 29 Jul 2007 06:25:30 +0000 (16:25 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Sun, 29 Jul 2007 06:25:30 +0000 (16:25 +1000)
src/disco.py
src/main.py

index 4fd2221f840a0fd799042967aaf54fbf6360b182..6abebf40864674ac6d91e2bbc639380b32ddbbb5 100644 (file)
@@ -64,6 +64,18 @@ class ServerDiscovery:
                
                self.addFeature(DISCO, None, config.jid)
                self.addFeature(DISCO, None, "USER")
                
                self.addFeature(DISCO, None, config.jid)
                self.addFeature(DISCO, None, "USER")
+               self.addFeature(DISCO, None, "ROOM")
+       
+       def _makeSearchJID(self, jid):
+               if jid.find('@') > 0:
+                       if jid.find('%') > 0:
+                               return "USER"
+                       else:
+                               return "ROOM"
+               elif config.compjid and to == config.compjid:
+                       return config.jid
+               else:
+                       return jid
        
        def sendIq(self, el, timeout=15):
                """ Used for sending IQ packets.
        
        def sendIq(self, el, timeout=15):
                """ Used for sending IQ packets.
@@ -86,21 +98,21 @@ class ServerDiscovery:
                return d
        
        def addIdentity(self, category, ctype, name, jid):
                return d
        
        def addIdentity(self, category, ctype, name, jid):
-               """ Adds an identity to this JID's discovery profile. If jid == "USER" then MSN users will get this identity. """
+               """ Adds an identity to this JID's discovery profile. If jid == "USER" then MSN users will get this identity, jid == "ROOM" is for groupchat rooms. """
                LogEvent(INFO)
                if not self.identities.has_key(jid):
                        self.identities[jid] = []
                self.identities[jid].append((category, ctype, name))
        
        def addFeature(self, var, handler, jid):
                LogEvent(INFO)
                if not self.identities.has_key(jid):
                        self.identities[jid] = []
                self.identities[jid].append((category, ctype, name))
        
        def addFeature(self, var, handler, jid):
-               """ Adds a feature to this JID's discovery profile. If jid == "USER" then MSN users will get this feature. """
+               """ Adds a feature to this JID's discovery profile. If jid == "USER" then MSN users will get this feature, jid == "ROOM" is for groupchat rooms. """
                LogEvent(INFO)
                if not self.features.has_key(jid):
                        self.features[jid] = []
                self.features[jid].append((var, handler))
 
        def addNode(self, node, handler, name, jid, rootnode):
                LogEvent(INFO)
                if not self.features.has_key(jid):
                        self.features[jid] = []
                self.features[jid].append((var, handler))
 
        def addNode(self, node, handler, name, jid, rootnode):
-               """ Adds a node to this JID's discovery profile. If jid == "USER" then MSN users will get this node. """
+               """ Adds a node to this JID's discovery profile. If jid == "USER" then MSN users will get this node, jid == "ROOM" is for groupchat rooms. """
                LogEvent(INFO)
                if not self.nodes.has_key(jid):
                        self.nodes[jid] = {}
                LogEvent(INFO)
                if not self.nodes.has_key(jid):
                        self.nodes[jid] = {}
@@ -149,13 +161,7 @@ class ServerDiscovery:
                                self.sendDiscoItemsResponse(to=fro, ID=ID, ulang=ulang, jid=to)
                                return
 
                                self.sendDiscoItemsResponse(to=fro, ID=ID, ulang=ulang, jid=to)
                                return
 
-                       if to.find('@') > 0:
-                               searchjid = "USER"
-                       elif config.compjid and to == config.compjid:
-                               searchjid = config.jid
-                       else:
-                               searchjid = to
-                       for (feature, handler) in self.features.get(searchjid, []):
+                       for (feature, handler) in self.features.get(self._makeSearchJID(to), []):
                                if feature == xmlns and handler:
                                        LogEvent(INFO, "Handler found")
                                        handler(el)
                                if feature == xmlns and handler:
                                        LogEvent(INFO, "Handler found")
                                        handler(el)
@@ -177,9 +183,8 @@ class ServerDiscovery:
                query = iq.addElement("query")
                query.attributes["xmlns"] = DISCO_INFO
                
                query = iq.addElement("query")
                query.attributes["xmlns"] = DISCO_INFO
                
-               searchjid = jid
-               if jid.find('@') > 0: searchjid = "USER"
-               if config.compjid and jid == config.compjid: searchjid = config.jid
+               searchjid = self._makeSearchJID(jid)
+
                # Add any identities
                for (category, ctype, name) in self.identities.get(searchjid, []):
                        identity = query.addElement("identity")
                # Add any identities
                for (category, ctype, name) in self.identities.get(searchjid, []):
                        identity = query.addElement("identity")
@@ -206,9 +211,7 @@ class ServerDiscovery:
                query = iq.addElement("query")
                query.attributes["xmlns"] = DISCO_ITEMS
 
                query = iq.addElement("query")
                query.attributes["xmlns"] = DISCO_ITEMS
 
-               searchjid = jid
-               if jid.find('@') > 0: searchjid = "USER"
-               if config.compjid and jid == config.compjid: searchjid = config.jid
+               searchjid = self._makeSearchJID(jid)
                for node in self.nodes.get(searchjid, []):
                        handler, name, rootnode = self.nodes[jid][node]
                        if rootnode:
                for node in self.nodes.get(searchjid, []):
                        handler, name, rootnode = self.nodes[jid][node]
                        if rootnode:
index 6b1587a0562a46791ecc2aac36fadce900b18776..a85a4ee818acd5bc23cd514dab6b7f1043ef625b 100644 (file)
@@ -127,6 +127,7 @@ class PyTransport(component.Service):
                self.discovery.addFeature(disco.XCONFERENCE, None, config.jid) # So that clients know you can create groupchat rooms on the server
                self.discovery.addFeature("jabber:iq:conference", None, config.jid) # We don't actually support this, but Psi has a bug where it looks for this instead of the above
                self.discovery.addIdentity("client", "pc", "MSN Messenger", "USER")
                self.discovery.addFeature(disco.XCONFERENCE, None, config.jid) # So that clients know you can create groupchat rooms on the server
                self.discovery.addFeature("jabber:iq:conference", None, config.jid) # We don't actually support this, but Psi has a bug where it looks for this instead of the above
                self.discovery.addIdentity("client", "pc", "MSN Messenger", "USER")
+               self.discovery.addIdentity("conference", "text", "MSN Groupchat", "ROOM")
                
                self.xdb = xdb.XDB(config.jid, legacy.mangle)
                self.avatarCache = avatar.AvatarCache()
                
                self.xdb = xdb.XDB(config.jid, legacy.mangle)
                self.avatarCache = avatar.AvatarCache()