MAXMESSAGESIZE = 1400
SWITCHBOARDTIMEOUT = 30.0*60.0
GETALLAVATARS = False
+ BINDADDRESS = "0.0.0.0"
def __init__(self, username, password, ident):
""" Connects to the MSN servers.
d = Deferred()
dispatchFactory.d = d
d.addCallbacks(self._gotNotificationReferral, self.connectionFailed)
- self.connectors.append(reactor.connectTCP("messenger.hotmail.com", 1863, dispatchFactory))
+ self.connectors.append(reactor.connectTCP("messenger.hotmail.com", 1863, dispatchFactory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
LogEvent(INFO, self.ident)
def _gotNotificationReferral(self, (host, port)):
self.notificationFactory.password = self.password
self.notificationFactory.msncon = self
self.notificationFactory.protocol = NotificationClient
- self.connectors.append(reactor.connectTCP(host, port, self.notificationFactory))
+ self.connectors.append(reactor.connectTCP(host, port, self.notificationFactory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
LogEvent(INFO, self.ident)
def _sendSavedEvents(self):
sb = self.switchboardSessions.get(userHandle)
if sb: return sb.sendTypingNotification()
- def changeAvatar(self, imageData):
+ def changeAvatar(self, imageDataFunc):
"""
Changes the user's avatar.
- @param imageData: the new PNG avatar image data.
+ @param imageDataFunc: a function which returns the new PNG avatar image data.
"""
if self.notificationClient:
LogEvent(INFO, self.ident)
- self.notificationClient.changeAvatar(imageData, push=True)
+ self.notificationClient.changeAvatar(imageDataFunc, push=True)
# Save the avatar for reuse on disconnection
- self.savedEvents.avatarImageData = imageData
+ self.savedEvents.avatarImageDataFunc = imageDataFunc
def changeStatus(self, statusCode, screenName, personal):
"""
self.screenName = ""
self.statusCode = ""
self.personal = ""
- self.avatarImageData = ""
+ self.avatarImageDataFunc = None
self.addContacts = []
self.remContacts = []
def send(self, msncon):
- if self.avatarImageData:
- msncon.notificationClient.changeAvatar(self.avatarImageData, push=False)
+ if self.avatarImageDataFunc:
+ msncon.notificationClient.changeAvatar(self.avatarImageDataFunc, push=False)
if self.screenName or self.statusCode or self.personal:
msncon.changeStatus(self.statusCode, self.screenName, self.personal)
for listType, userHandle in self.addContacts:
self.reply = 0
factory = ClientFactory()
factory.buildProtocol = lambda addr: self
- reactor.connectTCP(host, port, factory)
+ self.msncon.connectors.append(reactor.connectTCP(host, port, factory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
def sbRequestFailed(ignored=None):
LogEvent(INFO, self.ident)
del self.msncon.switchboardSessions[self.remoteUser]
self.reply = 1
factory = ClientFactory()
factory.buildProtocol = lambda addr: self
- reactor.connectTCP(host, port, factory)
+ self.msncon.connectors.append(reactor.connectTCP(host, port, factory, bindAddress=(MSNConnection.BINDADDRESS, 0)))
def flushBuffer(self):
for message, noerror in self.messageBuffer[:]:
def userJoined(self, userHandle, screenName=''):
LogEvent(INFO, self.ident)
- if not self.reply:
+ if not self.reply and not self.ready:
self._ready()
if userHandle != self.remoteUser:
# Another user has joined, so we now have three participants.