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.
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):
- """ 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):
- """ 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] = {}
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)
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")
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:
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()