self.isLeaf = True
self.files = {}
self.oobSite = server.Site(self)
- reactor.listenTCP(int(config.ftOOBPort), oobSite)
+ reactor.listenTCP(int(config.ftOOBPort), self.oobSite)
def putFile(self, file, filename):
self.files[filename] = file
from tlib.xmlw import Element
from tlib import msn
from debug import LogEvent, INFO, WARN, ERROR
+import disco
import sha
import groupchat
import ft
self.remoteNick = ""
# Init the MSN bits
- msn.MSNConnection.__init__(self, username, password)
+ msn.MSNConnection.__init__(self, username, password, self.session.jabberID)
# User typing notification stuff
self.userTyping = dict() # Indexed by contact MSN ID, stores whether the user is typing to this contact
self.userTypingSend.stop()
- msn.MSNConnection.removeMe(self)
self.legacyList.removeMe()
self.legacyList = None
self.session = None
-
- def jidRes(self, resource):
- to = self.session.jabberID
- if resource:
- to += "/" + resource
-
- return to
+ def resourceOffline(self, resource):
+ pass
+
def highestResource(self):
""" Returns highest priority resource """
return self.session.highestResource()
if self.userTyping.has_key(dest):
del self.userTyping[dest]
try:
- msn.MSNConnection.sendMessage(self, dest, resource, body, noerror)
+ msn.MSNConnection.sendMessage(self, dest, body, noerror)
self.session.pytrans.statistics.stats["MessageCount"] += 1
except:
self.failedMessage(dest, body)
self.sendTypingToContact(contact)
# Send any typing notification messages from contacts to the user
- for contact, resource in self.contactTyping.keys():
- self.contactTyping[(contact, resource)] += 1
- if self.contactTyping[(contact, resource)] >= 3:
- self.session.sendTypingNotification(self.jidRes(resource), msn2jid(contact), False)
- del self.contactTyping[(contact, resource)]
+ for contact in self.contactTyping.keys():
+ self.contactTyping[contact] += 1
+ if self.contactTyping[contact] >= 3:
+ self.session.sendTypingNotification(self.session.jabberID, msn2jid(contact), False)
+ del self.contactTyping[contact]
- def gotContactTyping(self, contact, resource):
+ def gotContactTyping(self, contact):
if not self.session: return
# Check if the contact has only just started typing
- if not self.contactTyping.has_key((contact, resource)):
- self.session.sendTypingNotification(self.jidRes(resource), msn2jid(contact), True)
+ if not self.contactTyping.has_key(contact):
+ self.session.sendTypingNotification(self.session.jabberID, msn2jid(contact), True)
# Reset the counter
- self.contactTyping[(contact, resource)] = 0
+ self.contactTyping[contact] = 0
def userTypingNotification(self, dest, resource, composing):
if not self.session: return
self.listSynced = True
#self.legacyList.flushSubscriptionBuffer()
- def gotMessage(self, remoteUser, resource, text):
+ def gotMessage(self, remoteUser, text):
if not self.session: return
source = msn2jid(remoteUser)
- self.session.sendMessage(self.jidRes(resource), fro=source, body=text, mtype="chat")
+ self.session.sendMessage(self.session.jabberID, fro=source, body=text, mtype="chat")
self.session.pytrans.statistics.stats["MessageCount"] += 1
def avatarHashChanged(self, userHandle, hash):
LogEvent(INFO, self.session.jabberID)
self.session.ready = True
- def contactStatusChanged(self, remoteUser):
+ def contactStatusChanged(self, remoteUser, statusCode, screenName):
if not (self.session and self.getContacts()): return
LogEvent(INFO, self.session.jabberID)
import utils
from twisted.internet import reactor, task
+from tlib.xmlw import Element, jid
from debug import LogEvent, INFO, WARN, ERROR
import jabw
import legacy
from msnw import MSNConnection
-import msn
+from msn import FORWARD_LIST, ALLOW_LIST, BLOCK_LIST, REVERSE_LIST, PENDING_LIST
+from msn import STATUS_ONLINE, STATUS_OFFLINE, STATUS_HIDDEN, STATUS_IDLE, STATUS_AWAY, STATUS_BUSY, STATUS_BRB, STATUS_PHONE, STATUS_LUNCH
+from msn import MSNContact, MSNContactList
return userHandle, screenName, userGuid, lists, groups
+def ljust(s, n, c):
+ """ Needed for Python 2.3 compatibility """
+ return s + (n-len(s))*c
+
def b64enc(s):
return base64.encodestring(s).replace("\n", "")
data = struct.pack("<LLQL", 638, 0x03, self.filesize, 0x01)
data = data[:-1] # Uck, weird, but it works
data += self.filename.encode("utf-16")[2:] # Strip off the utf16 BOM
- data = data.ljust(570, '\0')
+ data = ljust(data, 570, '\0')
data += struct.pack("<L", 0xFFFFFFFF)
- data = data.ljust(638, '\0')
+ data = ljust(data, 638, '\0')
return data
def parse(self, packet):
from debug import LogEvent, INFO, WARN, ERROR
from tlib.msn import msn
-# Imports from msn
-from msn import FORWARD_LIST, ALLOW_LIST, BLOCK_LIST, REVERSE_LIST, PENDING_LIST
-from msn import STATUS_ONLINE, STATUS_OFFLINE, STATUS_HIDDEN, STATUS_IDLE, STATUS_AWAY, STATUS_BUSY, STATUS_BRB, STATUS_PHONE, STATUS_LUNCH
MAXMESSAGESIZE = 1400
SWITCHBOARDTIMEOUT = 30.0*60.0
self.password = password
self.ident = ident
self.timeout = None
+ self.notificationClient = None
self.connect()
LogEvent(INFO, self.ident)
if self.notificationClient:
count = 0
- def cb():
+ def cb(ignored=None):
if count == 3:
self.ourStatusChanged(statusCode, screenName, personal)
LogEvent(INFO, self.ident)
LogEvent(INFO, self.factory.msncon.ident)
msn.NotificationClient.loggedIn(self, userHandle, verified)
self.factory.msncon._notificationClientReady(self)
+ self.factory.msncon.loggedIn()
if not verified:
self.factory.msncon.accountNotVerified()
def __init__(self, msncon, remoteUser):
SwitchboardSessionBase.__init__(self, msncon)
msn.SwitchboardClient.__init__(self)
- self.remoteUser = remoteUser
+ self.remoteUser = str(remoteUser)
self.ident = (self.msncon, self.remoteUser)
self.chattingUsers = []
self.timeout = None
def sendTypingNotification(self):
LogEvent(INFO, self.ident)
if self.ready:
- msn.SwitchboaldClient.sendTypingNotification(self)
+ msn.SwitchboardClient.sendTypingNotification(self)
CAPS = msn.MSNContact.MSNC1 | msn.MSNContact.MSNC2 | msn.MSNContact.MSNC3 | msn.MSNContact.MSNC4
def sendAvatarRequest(self):
d.callback(None)
for msnContact in msncon.getContacts().contacts.values():
- for list in [msnw.FORWARD_LIST, msnw.BLOCK_LIST, msnw.ALLOW_LIST, msnw.PENDING_LIST]:
+ for list in [msn.FORWARD_LIST, msn.BLOCK_LIST, msn.ALLOW_LIST, msn.PENDING_LIST]:
if msnContact.lists & list:
msncon.remContact(list, msnContact.userHandle).addCallback(cb)
count += 1
def doAddContacts(self, both=True):
# Adding users to each other's lists
- self.user1.addContact(msnw.FORWARD_LIST, USER2).addCallback(self.cb)
+ self.user1.addContact(msn.FORWARD_LIST, USER2).addCallback(self.cb)
self.loop("Adding user2 to user1's forward list.")
- self.user1.addContact(msnw.ALLOW_LIST, USER2).addCallback(self.cb)
+ self.user1.addContact(msn.ALLOW_LIST, USER2).addCallback(self.cb)
self.loop("Adding user2 to user1's allow list.")
if both:
- self.user2.addContact(msnw.FORWARD_LIST, USER1).addCallback(self.cb)
+ self.user2.addContact(msn.FORWARD_LIST, USER1).addCallback(self.cb)
self.loop("Adding user1 to user2's forward list.")
- self.user2.addContact(msnw.ALLOW_LIST, USER1).addCallback(self.cb)
+ self.user2.addContact(msn.ALLOW_LIST, USER1).addCallback(self.cb)
self.loop("Adding user1 to user2's allow list.")
# Check the contacts have seen each other
d = self.user1.sendFile(USER2, "myfile.txt", len(data))
d.addCallback(gotFileSend)
self.loop("Sending file.", cond="GOTMESSAGE", timeout=60*60)
-# testFileSend.skip = "True"
+ testFileSend.skip = "True"
def testFileReceive(self):
if raw_input("\n\nALERT!!!\n\nPlease connect to account %s and send a file transfer to %s.\nType ok when you are ready: " % (USER2, USER1)).lower() != "ok":
self.doPurgeContacts(both=False)
self.doAddContacts(both=False)
self.loop("Receiving file.", cond="GOTFILE", timeout=60*60)
-# testFileReceive.skip = "True"
+ testFileReceive.skip = "True"