]> code.delx.au - pymsnt/blobdiff - src/jabw.py
OOB file sending works.
[pymsnt] / src / jabw.py
index 0d0a1f51604e886ed0fee0b75bf1290b0b7aacea..ec2904fe608143e891716aaefa8eb63cb6361546 100644 (file)
@@ -2,12 +2,7 @@
 # Licensed for distribution under the GPL version 2, check COPYING for details
 
 import utils
-if(utils.checkTwisted()):
-       from twisted.xish.domish import Element
-       from twisted.words.protocols.jabber import jid
-else:
-       from tlib.domish import Element
-       from tlib.jabber import jid
+from tlib.xmlw import Element, jid
 from debug import LogEvent, INFO, WARN, ERROR
 import disco
 
@@ -38,9 +33,8 @@ def sendMessage(pytrans, to, fro, body, mtype=None, delay=None):
 def sendPresence(pytrans, to, fro, show=None, status=None, priority=None, ptype=None, avatarHash=None, nickname=None, payload=[]):
        # Strip the resource off any presence subscribes (as per XMPP RFC 3921 Section 5.1.6)
        # Makes eJabberd behave :)
-       if(ptype == "subscribe"):
-               (user,host,res) = jid.parse(to)
-               to = "%s@%s" % (user, host)
+       if ptype == "subscribe":
+               to = jid.intern(to).userhost()
        
        el = Element((None, "presence"))
        el.attributes["to"] = to
@@ -188,8 +182,8 @@ class JabberConnection:
                fro = el.getAttribute("from")
                to = el.getAttribute("to")
                try:
-                       froj = jid.JID(fro)
-                       toj = jid.JID(to)
+                       froj = jid.intern(fro)
+                       toj = jid.intern(to)
                except Exception, e:
                        LogEvent(WARN, self.jabberID)
                        return
@@ -250,9 +244,9 @@ class JabberConnection:
                """ Handles incoming presence packets """
                #LogEvent(INFO, self.jabberID)
                fro = el.getAttribute("from")
-               froj = jid.JID(fro)
+               froj = jid.intern(fro)
                to = el.getAttribute("to")
-               toj = jid.JID(to)
+               toj = jid.intern(to)
                
                # Grab the contents of the <presence/> packet
                ptype = el.getAttribute("type")