]> code.delx.au - pymsnt/blobdiff - src/session.py
Fixed bug with 64bit archictectures.
[pymsnt] / src / session.py
index 847309dfee628f49b5940d3559b073210a8b3f09..be2955025cbd5e31956ee1ce492a5aedc025342e 100644 (file)
@@ -1,7 +1,7 @@
-# Copyright 2004-2005 James Bunton <james@delx.cjb.net>
+# Copyright 2004-2006 James Bunton <james@delx.cjb.net>
 # Licensed for distribution under the GPL version 2, check COPYING for details
 
-from tlib.xmlw import jid
+from twisted.words.protocols.jabber.jid import internJID
 
 import utils
 import legacy
@@ -120,9 +120,9 @@ class Session(jabw.JabberConnection):
                        avatarSet = False
                        name = ""
                        for e in vCard.elements():
-                               if e.name == "NICKNAME":
+                               if e.name == "NICKNAME" and e.__str__():
                                        name = e.__str__()
-                               if not name and e.name == "FN":
+                               if not name and e.name == "FN" and e.__str__():
                                        # Give priority to nickname
                                        name = e.__str__()
                                if e.name == "PHOTO":
@@ -133,7 +133,7 @@ class Session(jabw.JabberConnection):
                                        self.legacycon.updateAvatar(self.avatar)
                                        avatarSet = True
                        if name:
-                               self.updateNickname(e.__str__())
+                               self.updateNickname(name)
                        if not avatarSet:
                                self.legacycon.updateAvatar() # Default avatar
 
@@ -150,7 +150,7 @@ class Session(jabw.JabberConnection):
        def updateNickname(self, nickname):
                self.nickname = nickname
                if not self.nickname:
-                       j = jid.intern(self.jabberID)
+                       j = internJID(self.jabberID)
                        self.nickname = j.user
                self.setStatus(self.show, self.status)
        
@@ -329,11 +329,14 @@ class Session(jabw.JabberConnection):
                del self.resourceList[resource]
                self.legacycon.resourceOffline(resource)
        
-       def subscriptionReceived(self, to, subtype):
+       def subscriptionReceived(self, fro, to, subtype):
                """ Sends the subscription request to the legacy services handler """
                if to.find('@') > 0:
-                       LogEvent(INFO, self.jabberID, "Passing subscription to legacy service.")
-                       self.contactList.jabberSubscriptionReceived(to, subtype)
+                       if self.ready:
+                               LogEvent(INFO, self.jabberID, "Passing subscription to legacy service.")
+                               self.contactList.jabberSubscriptionReceived(to, subtype)
+                       else:
+                               self.sendPresence(fro, to, ptype="error")
                else:
                        if subtype == "subscribe":
                                self.sendPresence(to=self.jabberID, fro=config.jid, ptype="subscribed")