]> code.delx.au - pymsnt/blobdiff - src/misciq.py
Fixed bug with version number.
[pymsnt] / src / misciq.py
index 64cbe90bc150754eae1e54cff76b2efe21935146..f66dc63e9ada36c2e4d2c4d1561fd88b33af3d1a 100644 (file)
@@ -3,9 +3,9 @@
 
 import utils
 from twisted.internet import reactor, task, protocol, error
-from tlib.xmlw import Element, jid
+from twisted.words.xish.domish import Element
+from twisted.words.protocols.jabber.jid import internJID
 from debug import LogEvent, INFO, WARN, ERROR
-import svninfo
 import jabw
 import legacy
 import disco
@@ -30,7 +30,7 @@ class ConnectUsers:
                ID = el.getAttribute("id")
                ulang = utils.getLang(el)
 
-               if config.admins.count(jid.intern(to).userhost()) == 0:
+               if config.admins.count(internJID(to).userhost()) == 0:
                        self.pytrans.discovery.sendIqError(to=to, fro=config.jid, ID=ID, xmlns=disco.COMMANDS, etype="cancel", condition="not-authorized")
                        return
 
@@ -131,7 +131,7 @@ class AdHocCommands:
        def incomingIq(self, el):
                itype = el.getAttribute("type")
                fro = el.getAttribute("from")
-               froj = jid.intern(fro)
+               froj = internJID(fro)
                to = el.getAttribute("to")
                ID = el.getAttribute("id")
 
@@ -219,9 +219,9 @@ class VCardFactory:
        def incomingIq(self, el):
                itype = el.getAttribute("type")
                fro = el.getAttribute("from")
-               froj = jid.intern(fro)
+               froj = internJID(fro)
                to = el.getAttribute("to")
-               toj = jid.intern(to)
+               toj = internJID(to)
                ID = el.getAttribute("id")
                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")
@@ -280,9 +280,9 @@ class IqAvatarFactory:
        def incomingIq(self, el):
                itype = el.getAttribute("type")
                fro = el.getAttribute("from")
-               froj = jid.intern(fro)
+               froj = internJID(fro)
                to = el.getAttribute("to")
-               toj = jid.intern(to)
+               toj = internJID(to)
                ID = el.getAttribute("id")
 
                if(itype != "get" and itype != "error"):
@@ -432,10 +432,7 @@ class VersionTeller:
                self.pytrans = pytrans
                self.pytrans.discovery.addFeature(disco.IQVERSION, self.incomingIq, config.jid)
                self.pytrans.discovery.addFeature(disco.IQVERSION, self.incomingIq, "USER")
-               try:
-                       self.version = "%s - SVN r%s" % (legacy.version, svninfo.getSVNVersion())
-               except:
-                       self.version = legacy.version
+               self.version = legacy.version
                self.os = "Python" + ".".join([str(x) for x in sys.version_info[0:3]]) + " - " + sys.platform
        
        def incomingIq(self, el):
@@ -489,8 +486,8 @@ class FileTransferOOBSend:
                else:
                        return errOut()
 
-               froj = jid.intern(el.getAttribute("from"))
-               toj = jid.intern(el.getAttribute("to"))
+               froj = internJID(el.getAttribute("from"))
+               toj = internJID(el.getAttribute("to"))
                session = self.pytrans.sessions.get(froj.userhost(), None)
                if not session:
                        return errOut()
@@ -548,8 +545,8 @@ class Socks5FileTransfer:
                def errOut():
                        self.pytrans.discovery.sendIqError(to=el.getAttribute("from"), fro=el.getAttribute("to"), ID=ID, xmlns=disco.SI, etype="cancel", condition="bad-request")
 
-               toj = jid.intern(el.getAttribute("to"))
-               froj = jid.intern(el.getAttribute("from"))
+               toj = internJID(el.getAttribute("to"))
+               froj = internJID(el.getAttribute("from"))
                session = self.pytrans.sessions.get(froj.userhost(), None)
                if not session:
                        return errOut()
@@ -620,8 +617,8 @@ class Socks5FileTransfer:
                if el.getAttribute("type") != "set":
                        return errOut()
 
-               toj = jid.intern(el.getAttribute("to"))
-               froj = jid.intern(el.getAttribute("from"))
+               toj = internJID(el.getAttribute("to"))
+               froj = internJID(el.getAttribute("from"))
 
                query = el.query
                if not (query and query.getAttribute("mode", "tcp") == "tcp"):
@@ -660,6 +657,10 @@ class Socks5FileTransfer:
                                except error.NotConnectingError:
                                        pass
 
+                       if factory.streamHostTimeout:
+                               factory.streamHostTimeout.cancel()
+                               factory.streamHostTimeout = None
+
                        iq = Element((None, "iq"))
                        iq["type"] = "result"
                        iq["from"] = toj.full()
@@ -673,12 +674,15 @@ class Socks5FileTransfer:
 
 
                # Try the streamhosts
+               LogEvent(INFO)
                factory = protocol.ClientFactory()
                factory.protocol = ft.JEP65ConnectionSend
                factory.consumer = consumer
                factory.hash = utils.socks5Hash(sid, froj.full(), toj.full())
                factory.madeConnection = gotStreamhost
                factory.connectors = []
+               factory.streamHostTimeout = reactor.callLater(120, consumer.error)
+
                for streamhost in streamhosts:
                        factory.connectors.append(reactor.connectTCP(streamhost[1], streamhost[2], factory))