X-Git-Url: https://code.delx.au/pymsnt/blobdiff_plain/877b5516f611af10ac21f2bc314cfea275940629..5921d694e4dd3f8471745fa99e68cada51fa7182:/src/legacy/glue.py diff --git a/src/legacy/glue.py b/src/legacy/glue.py index c72cb74..b6947f3 100644 --- a/src/legacy/glue.py +++ b/src/legacy/glue.py @@ -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 @@ -18,7 +18,7 @@ import lang url = "http://msn-transport.jabberstudio.org" -version = "0.11-dev" # The transport version +version = "0.11.1" # The transport version mangle = True # XDB '@' -> '%' mangling id = "msn" # The transport identifier @@ -36,6 +36,7 @@ defaultAvatar = avatar.AvatarCache().setAvatar(defaultAvatarData) def reloadConfig(): msn.MSNConnection.GETALLAVATARS = config.getAllAvatars + msn.setDebug(config._debugLevel >= 4) def isGroupJID(jid): """ Returns True if the JID passed is a valid groupchat JID (for MSN, does not contain '%') """ @@ -108,10 +109,10 @@ def msn2jid(msnid, withResource): else: if msnid.startswith("tel:+"): msnid = msnid.replace("tel:+", "") + "%tel" - jid = msnid.replace('@', '%') + "@" + config.jid + (withResource and "/msn" or "") + jid = msnid.replace('@', '%') + "@" + config.jid msn2jid_cache[msnid] = jid jid2msn_cache[jid] = msnid - return jid + return msn2jid(msnid, withResource) # Marks this as the function to be used in jabber:iq:gateway (Service ID Translation) def translateAccount(msnid): @@ -378,8 +379,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): @@ -550,10 +552,8 @@ class LegacyList: def __init__(self, session): self.jabberID = session.jabberID self.session = session - self.subscriptionBuffer = [] def removeMe(self): - self.subscriptionBuffer = None self.session = None def addContact(self, jid): @@ -563,7 +563,7 @@ class LegacyList: # Handle adding a contact that has previously been removed msnContact = self.session.legacycon.getContacts().getContact(userHandle) - if msnContact.lists & msn.REVERSE_LIST: + if msnContact and msnContact.lists & msn.REVERSE_LIST: self.session.legacycon.contactAddedMe(userHandle) self.authContact(jid) self.session.contactList.getContact(jid).contactGrantsAuth()