MSN_CVR_STR = "0x040c winnt 5.1 i386 MSNMSGR 7.0.0777 msmsgs"
MSN_AVATAR_GUID = "{A4268EEC-FEC5-49E5-95C3-F126696BDBF6}"
MSN_MSNFTP_GUID = "{5D3E02AB-6190-11D3-BBBB-00C04F795683}"
+MSN_MAXINT = 2**31 - 1
# auth constants
LOGIN_SUCCESS = 1
e = parseText(s, True)
if not e:
return # Parse failed
- self.creator = e.getAttribute("Creator")
- self.size = int(e.getAttribute("Size"))
- self.type = int(e.getAttribute("Type"))
- self.location = e.getAttribute("Location")
- self.friendly = e.getAttribute("Friendly")
- self.sha1d = e.getAttribute("SHA1D")
- self.text = s
+ try:
+ self.creator = e.getAttribute("Creator")
+ self.size = int(e.getAttribute("Size"))
+ self.type = int(e.getAttribute("Type"))
+ self.location = e.getAttribute("Location")
+ self.friendly = e.getAttribute("Friendly")
+ self.sha1d = e.getAttribute("SHA1D")
+ self.text = s
+ except TypeError:
+ self.setNull()
+ except ValueError:
+ self.setNull()
class MSNContact:
msnContact.status = params[1]
msnContact.screenName = unquote(params[3])
if len(params) > 4: msnContact.caps = int(params[4])
- if len(params) > 5:
+ if len(params) > 5 and params[5] != "0":
self.handleAvatarHelper(msnContact, params[5])
else:
self.handleAvatarGoneHelper(msnContact)
msnContact.status = params[0]
msnContact.screenName = unquote(params[2])
if len(params) > 3: msnContact.caps = int(params[3])
- if len(params) > 4:
+ if len(params) > 4 and params[4] != "0":
self.handleAvatarHelper(msnContact, params[4])
else:
self.handleAvatarGoneHelper(msnContact)
if baseID:
self.baseID = baseID
else:
- self.baseID = random.randint(1000, sys.maxint)
+ self.baseID = random.randint(1000, MSN_MAXINT)
self.pos = -1
def get(self):
def __init__(self, remoteUser, switchboard, sessionID, sessionGuid):
self.dataFlag = 0
if not sessionID:
- sessionID = random.randint(1000, sys.maxint)
+ sessionID = random.randint(1000, MSN_MAXINT)
if not sessionGuid:
sessionGuid = random_guid()
self.remoteUser = remoteUser
binaryFields[1] = self.seqID.next()
binaryFields[3] = len(msgStr)
binaryFields[4] = binaryFields[3]
- binaryFields[6] = random.randint(1000, sys.maxint)
+ binaryFields[6] = random.randint(1000, MSN_MAXINT)
self.sendP2PMessage(binaryFields, msgStr)
def sendP2PMessage(self, binaryFields, msgStr):
binaryFields[1] = self.seqID.next()
binaryFields[3] = 4
binaryFields[4] = 4
- binaryFields[6] = random.randint(1000, sys.maxint)
+ binaryFields[6] = random.randint(1000, MSN_MAXINT)
binaryFields[9] = 1
self.sendP2PMessage(binaryFields, chr(0) * 4)
binaryFields[3] = self.filesize
binaryFields[4] = len(chunk)
binaryFields[5] = self.dataFlag
- binaryFields[6] = random.randint(1000, sys.maxint)
+ binaryFields[6] = random.randint(1000, MSN_MAXINT)
binaryFields[9] = 1
self.offset += len(chunk)
self.sendP2PMessage(binaryFields, chunk)