From c3d85a89753aa62973d6fb4a77b4f5f7d4263820 Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Sun, 25 Oct 2009 13:21:07 -0300
Subject: [PATCH 5/7] 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  |    6 +++++-
 msnlib.py |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

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:
-- 
1.6.2.2.646.gb214


