git » msnlib » commit c3d85a8

Support the NOT message (notice notification)

author Alberto Bertogli
2009-10-25 16:21:07 UTC
committer Alberto Bertogli
2009-10-25 16:33:50 UTC
parent 007576b8dc4a2a40771225e0ee2e9c4adf63974d

Support the NOT message (notice notification)

The NOT message is sent by the server to give us a notice. It is usually
associated with MSN Calendar and MSN Alerts, according to
http://www.hypothetic.org/docs/msn/notification/miscellaneous.php.

Without this patch, the communication with the server gets stucked waiting
for us to read the payload.

Thanks to Yevgen Goncharuk (jen140) for helping to find this problem and
testing the patch.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

msncb.py +5 -1
msnlib.py +5 -1

diff --git a/msncb.py b/msncb.py
index f4620b5..b8b8f8e 100644
--- a/msncb.py
+++ b/msncb.py
@@ -48,6 +48,7 @@ class cb:
 		self.unk = cb_unk	# unknown
 		self.err = cb_err	# server error
 		self.msg = cb_msg	# get a message
+		self.notice = cb_notice	# notice notification
 		self.chl = cb_chl	# challenge
 		self.qry = cb_ign	# query response
 		self.iln = cb_iln	# status notification
@@ -488,11 +489,14 @@ def cb_msg(md, type, tid, params, sbd):
 	"Get a message"
 	debug('MESSAGE\n+++ Header: %s\n%s\n\n' % (str(tid), str(params)))
 
-
 def cb_ack(md, type, tid, params, sbd):
 	"Get a message acknowledge"
 	debug('ACK: tid:%s' % tid)
 
+def cb_notice(md, type, tid, params, sbd):
+	"Get a notice"
+	debug('NOTICE\n+++ %s\n\n' % str(params))
+
 
 def cb_nak(md, type, tid, params, sbd):
 	"Get a message negative acknowledge"
diff --git a/msnlib.py b/msnlib.py
index 377f851..7deef67 100644
--- a/msnlib.py
+++ b/msnlib.py
@@ -664,13 +664,17 @@ class msnd:
 		elif type == 'NAK': self.cb.nak(self, type, tid, params, nd)
 		elif type == 'BYE': self.cb.bye(self, type, tid, params, nd)
 
-
 		elif type == 'MSG':
 			params = tid + ' ' + params
 			mlen = int(r[2].split()[-1])
 			msg = self._recvmsg(mlen, nd.fd)
 			self.cb.msg(self, type, params, msg, nd)
 
+		elif type == 'NOT':
+			mlen = int(tid)
+			msg = self._recvmsg(mlen, nd.fd)
+			self.cb.notice(self, type, "", msg, nd)
+
 		else:
 			# catch server errors - always numeric type
 			try: