]> code.delx.au - pymsnt/blobdiff - src/legacy/glue.py
Fixed another exception.
[pymsnt] / src / legacy / glue.py
index 0ba47b42685d96747e78353f707c0309b00e5061..c00be73b341226805a33fa4659c545b5973e24f3 100644 (file)
@@ -3,7 +3,7 @@
 
 import os.path
 import utils
-from twisted.internet import task
+from twisted.internet import task, error
 from tlib.xmlw import Element
 from tlib import msn
 from debug import LogEvent, INFO, WARN, ERROR
@@ -378,8 +378,9 @@ class LegacyConnection(msn.MSNConnection):
        
        def connectionLost(self, reason):
                LogEvent(INFO, self.jabberID)
-               text = lang.get(self.session.lang).msnDisconnected % reason
-               self.session.sendMessage(to=self.jabberID, fro=config.jid, body=text)
+               if reason.type != error.ConnectionDone:
+                       text = lang.get(self.session.lang).msnDisconnected % reason
+                       self.session.sendMessage(to=self.jabberID, fro=config.jid, body=text)
                self.session.removeMe() # Tear down the session
 
        def multipleLogin(self):
@@ -560,6 +561,12 @@ class LegacyList:
                LogEvent(INFO, self.jabberID)
                userHandle = jid2msn(jid)
                self.session.legacycon.addContact(msn.FORWARD_LIST, userHandle)
+
+               # Handle adding a contact that has previously been removed
+               msnContact = self.session.legacycon.getContacts().getContact(userHandle)
+               if msnContact and msnContact.lists & msn.REVERSE_LIST:
+                       self.session.legacycon.contactAddedMe(userHandle)
+               self.authContact(jid)
                self.session.contactList.getContact(jid).contactGrantsAuth()
        
        def removeContact(self, jid):
@@ -570,12 +577,12 @@ class LegacyList:
        
        def authContact(self, jid):
                LogEvent(INFO, self.jabberID)
-               jid = jid2msn(jid)
-               d = self.session.legacycon.remContact(msn.PENDING_LIST, jid)
+               userHandle = jid2msn(jid)
+               d = self.session.legacycon.remContact(msn.PENDING_LIST, userHandle)
                if d:
-                       self.session.legacycon.addContact(msn.REVERSE_LIST, jid)
-               self.session.legacycon.remContact(msn.BLOCK_LIST, jid)
-               self.session.legacycon.addContact(msn.ALLOW_LIST, jid)
+                       self.session.legacycon.addContact(msn.REVERSE_LIST, userHandle)
+               self.session.legacycon.remContact(msn.BLOCK_LIST, userHandle)
+               self.session.legacycon.addContact(msn.ALLOW_LIST, userHandle)
        
        def deauthContact(self, jid):
                LogEvent(INFO, self.jabberID)