+ userHandle = jid2msn(jid)
+ d = self.session.legacycon.remContact(msn.PENDING_LIST, userHandle)
+ if d:
+ 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)
+ jid = jid2msn(jid)
+ self.session.legacycon.remContact(msn.ALLOW_LIST, jid)
+ self.session.legacycon.remContact(msn.PENDING_LIST, jid)
+ self.session.legacycon.addContact(msn.BLOCK_LIST, jid)
+
+
+
+ def syncJabberLegacyLists(self):
+ """ Synchronises the MSN contact list on server with the Jabber contact list """
+
+ global defaultAvatar
+
+ # We have to make an MSNContactList from the XDB data, then compare it with the one the server sent
+ # Any subscription changes must be sent to the client, as well as changed in the XDB
+ LogEvent(INFO, self.jabberID, "Start.")
+ result = self.session.pytrans.xdb.request(self.jabberID, disco.IQROSTER)
+ oldContactList = msn.MSNContactList()
+ if result:
+ for item in result.elements():
+ user = item.getAttribute("jid")
+ sub = item.getAttribute("subscription")
+ lists = item.getAttribute("lists")
+ if not lists:
+ lists = jabsub2msnlist(sub) # Backwards compatible
+ lists = int(lists)
+ contact = msn.MSNContact(userHandle=user, screenName="", lists=lists)
+ oldContactList.addContact(contact)
+
+ newXDB = Element((None, "query"))
+ newXDB.attributes["xmlns"] = disco.IQROSTER
+
+ contactList = self.session.legacycon.getContacts()
+
+
+ # Convienence functions
+ def addedToList(num):
+ return (not (oldLists & num) and (lists & num))
+ def removedFromList(num):
+ return ((oldLists & num) and not (lists & num))
+
+ for contact in contactList.contacts.values():
+ # Compare with the XDB <item/> entry
+ oldContact = oldContactList.getContact(contact.userHandle)
+ if oldContact == None:
+ oldLists = 0
+ else:
+ oldLists = oldContact.lists
+ lists = contact.lists
+
+ # Create the Jabber representation of the
+ # contact base on the old list data and then
+ # sync it with current
+ jabContact = self.session.contactList.createContact(msn2jid(contact.userHandle, False), msnlist2jabsub(oldLists))
+ jabContact.updateAvatar(defaultAvatar, push=False)