]> code.delx.au - pymsnt/blobdiff - src/misciq.py
Added auto-reconnect.
[pymsnt] / src / misciq.py
index a565755251c1b3bc86e33d5b0ad5b7ed86f582f1..66f87b95903d9849424b1f9f2fa5db3d99eb2dce 100644 (file)
@@ -138,7 +138,7 @@ class AdHocCommands:
 
                node = None
                for child in el.elements():
-                       xmlns = child.defaultUri
+                       xmlns = child.uri
                        node = child.getAttribute("node")
 
                        handled = False
@@ -220,8 +220,9 @@ class VCardFactory:
                fro = el.getAttribute("from")
                froj = jid.intern(fro)
                to = el.getAttribute("to")
+               toj = jid.intern(to)
                ID = el.getAttribute("id")
-               if(itype != "get" and itype != "error"):
+               if itype != "get" and itype != "error":
                        self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="cancel", condition="feature-not-implemented")
                        return
 
@@ -229,17 +230,17 @@ class VCardFactory:
 
                toGateway = not (to.find('@') > 0)
 
-               if(not toGateway):
-                       if(not self.pytrans.sessions.has_key(froj.userhost())):
+               if not toGateway:
+                       if not self.pytrans.sessions.has_key(froj.userhost()):
                                self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="auth", condition="not-authorized")
                                return
                        s = self.pytrans.sessions[froj.userhost()]
-                       if(not s.ready):
+                       if not s.ready:
                                self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="auth", condition="not-authorized")
                                return
                
-                       c = s.contactList.findContact(to)
-                       if(not c):
+                       c = s.contactList.findContact(toj.userhost())
+                       if not c:
                                self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="cancel", condition="recipient-unavailable")
                                return
 
@@ -252,18 +253,18 @@ class VCardFactory:
                iq.attributes["type"] = "result"
                vCard = iq.addElement("vCard")
                vCard.attributes["xmlns"] = "vcard-temp"
-               if(toGateway):
+               if toGateway:
                        FN = vCard.addElement("FN")
-                       FN.addContent(legacy.name)
+                       FN.addContent(config.discoName)
                        DESC = vCard.addElement("DESC")
-                       DESC.addContent(legacy.name)
+                       DESC.addContent(config.discoName)
                        URL = vCard.addElement("URL")
                        URL.addContent(legacy.url)
                else:
-                       if(c.nickname):
+                       if c.nickname:
                                NICKNAME = vCard.addElement("NICKNAME")
                                NICKNAME.addContent(c.nickname)
-                       if(c.avatar):
+                       if c.avatar:
                                PHOTO = c.avatar.makePhotoElement()
                                vCard.addChild(PHOTO)
 
@@ -280,6 +281,7 @@ class IqAvatarFactory:
                fro = el.getAttribute("from")
                froj = jid.intern(fro)
                to = el.getAttribute("to")
+               toj = jid.intern(to)
                ID = el.getAttribute("id")
 
                if(itype != "get" and itype != "error"):
@@ -296,7 +298,7 @@ class IqAvatarFactory:
                        self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns=disco.IQAVATAR, etype="auth", condition="not-authorized")
                        return
 
-               c = s.contactList.findContact(to)
+               c = s.contactList.findContact(toj.userhost())
                if(not c):
                        self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns=disco.IQAVATAR, etype="cancel", condition="recipient-unavailable")
                        return
@@ -447,7 +449,7 @@ class VersionTeller:
                query = iq.addElement("query")
                query.attributes["xmlns"] = disco.IQVERSION
                name = query.addElement("name")
-               name.addContent(legacy.name)
+               name.addContent(config.discoName)
                version = query.addElement("version")
                version.addContent(legacy.version)
                os = query.addElement("os")
@@ -550,7 +552,7 @@ class Socks5FileTransfer:
                if not (si and si.getAttribute("profile") == disco.FT):
                        return errOut()
                file = si.file
-               if not (file and file.defaultUri == disco.FT):
+               if not (file and file.uri == disco.FT):
                        return errOut()
                try:
                        sid = si["id"]
@@ -563,10 +565,10 @@ class Socks5FileTransfer:
 
                # Check that we can use socks5 bytestreams
                feature = si.feature
-               if not (feature and feature.defaultUri == disco.FEATURE_NEG):
+               if not (feature and feature.uri == disco.FEATURE_NEG):
                        return errOut()
                x = feature.x
-               if not (x and x.defaultUri == disco.XDATA):
+               if not (x and x.uri == disco.XDATA):
                        return errOut()
                field = x.field
                if not (field and field.getAttribute("var") == "stream-method"):
@@ -616,7 +618,7 @@ class Socks5FileTransfer:
                froj = jid.intern(el.getAttribute("from"))
 
                query = el.query
-               if not (query and query.getAttribute("mode") == "tcp"):
+               if not (query and query.getAttribute("mode", "tcp") == "tcp"):
                        return errOut()
                sid = query.getAttribute("sid")
                consumer = self.sessions.pop((froj.full(), sid), None)