 .gitignore     |    2 +
 README         |   14 +++---
 msn            |   31 ++++++++++----
 msncb.py       |   11 ++++-
 msnlib.py      |    7 +--
 msnsetup       |    2 +-
 setup.py       |    4 +-
 utils/clean    |    5 --
 utils/exporter |  127 --------------------------------------------------------
 utils/vicl     |   19 --------
 10 files changed, 45 insertions(+), 177 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..52e4e61
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.pyc
+*.pyo
diff --git a/README b/README
index 5ef35b6..1c79b57 100644
--- a/README
+++ b/README
@@ -10,26 +10,26 @@ Please read the 'INSTALL' file to see how to install and use both the client
 and the library.
 
 The client is really simple, uses a text-mode interface with commands similar
-to 'micq' (http://micq.ukeer.de/), which is a great ICQ client. 
+to 'micq' (http://micq.ukeer.de/), which is a great ICQ client.
 
 If you're looking for a good messaging system, forget about messenger and try
 Jabber (http://www.jabber.org), it's the only one which is run in the open
 based on public standards, it's safe, fast, has a lot of features and it's
-quite scalable. 
+quite scalable.
 
-But if you're stucked with messenger for whatever reason (your friends,
+But if you're stuck with messenger for whatever reason (your friends,
 family, the dog, all use it =), I hope you find this useful.
 
 
 The basic idea for the library is a main class which represents a connection
-with the server and holds all the relevant information, it has only the a few
+with the server and holds all the relevant information, it has only a few
 methods to login, change some info and status, and send messages; all the rest
-is driven by an asyncronous callback scheme registered at runtime which can be
+is driven by an asynchronous callback scheme registered at runtime which can be
 changed on the fly.
 
-If you're intrested, read the code to find out more; most of the documentation
+If you're interested, read the code to find out more; most of the documentation
 is there either as command or as python documentation strings. You might also
-want to check out the doc directory; specially if you use a non-unix platform,
+want to check out the doc directory; specially if you use a non-UNIX platform,
 take a look at the 'portability' file.
 
 
diff --git a/install b/install
old mode 100644
new mode 100755
diff --git a/msn b/msn
old mode 100644
new mode 100755
index 1e236bf..1c1e363
--- a/msn
+++ b/msn
@@ -39,11 +39,13 @@ status [mode]	Shows the current status, or changes it to "mode", which can
 q		Quits the program
 w		Prints your entire contact list
 ww		Prints your entire contact list, including email addresses
+wn		Prints your entire contact list, including real nicks
+wr		Prints your reverse contact list
 wd		Prints the differences between your forward and reverse lists
 e		Prints your online contacts
 ee		Prints your online contacts, including email addresses
 eg		Prints your online contacts with the groups
-wr		Prints your reverse contact list
+en		Prints your online contacts, including real nicks
 h		Shows your incoming message history
 add e [n] [g] 	Adds the user "e" with the nick "n" to the group "g"
 del nick	Deletes the user with nick "nick"
@@ -62,7 +64,7 @@ close nick	Closes the switchboard connection with "nick"
 config		Shows the configuration
 info [nick]	Shows the user information and pending messages (if any),
 		or our personal info
-nick newnick	Changes your nick to "newnick"
+nick [newnick]	Changes your nick to "newnick" or shows own nick
 privacy p a	Sets whether accept messages from people not on your list (p)
 		and require authorization (a)
 m nick text	Sends a message to "nick" with the "text"
@@ -118,9 +120,9 @@ c = color_classes['default']()
 
 # command list for tab-completion purposes
 command_list = [ 'a', 'add', 'block', 'close', 'color', 'config', 'del', 'e',
-	'ee', 'eg', 'g', 'gadd', 'gdel', 'green', 'h', 'help', 'info',
+	'ee', 'eg', 'en', 'g', 'gadd', 'gdel', 'green', 'h', 'help', 'info',
 	'invite', 'lignore', 'luignore', 'm', 'nick', 'privacy', 'q', 'r',
-	'ren', 'status', 'unblock', 'w', 'wd', 'wr', 'ww' ]
+	'ren', 'status', 'unblock', 'w', 'wn', 'wd', 'wr', 'ww' ]
 
 
 #
@@ -160,7 +162,8 @@ def pexc(line):
 	safe_write('\n')
 	safe_flush()
 
-def print_list(md, only_online = 0, userlist = None, include_emails = 0):
+def print_list(md, only_online = 0, userlist = None, include_emails = 0,
+		include_realnicks = 0):
 	"Prints the user list"
 	if not userlist:
 		userlist = md.users
@@ -177,6 +180,8 @@ def print_list(md, only_online = 0, userlist = None, include_emails = 0):
 		printl('%7.7s :: %s' % (status, u.nick), bold = hl)
 		if include_emails:
 			printl(' (%s)' % (email), bold = hl)
+		if include_realnicks:
+			printl(' (%s)' % (u.realnick), bold = hl)
 		if 'B' in u.lists:
 			printl(' [!]')
 		if email not in md.reverse.keys():
@@ -957,6 +962,9 @@ def parse_cmd(cmd):
 	elif cmd == 'ww':		# list, include emails
 		print_grouped_list(m, include_emails = 1)
 
+	elif cmd == 'wn':		# list, include real nicks
+		print_list(m, include_realnicks = 1)
+
 	elif cmd == 'wr':		# reverse list
 		print_list(m, userlist = m.reverse, include_emails = 1)
 
@@ -972,6 +980,9 @@ def parse_cmd(cmd):
 	elif cmd == 'ee':
 		print_grouped_list(m, only_online = 1, include_emails = 1)
 
+	elif cmd == 'en':
+		print_list(m, only_online = 1, include_realnicks = 1)
+
 	elif cmd == 'g':		# list groups
 		print_group_list(m)
 
@@ -1179,8 +1190,9 @@ def parse_cmd(cmd):
 			return 'No current chat with user %s' % dst
 		m.invite(email, dst_sbd)
 
-	elif cmd == 'nick':		# change our nick
-		if len(params) < 1: return 'Error parsing command'
+	elif cmd == 'nick':		# show or change our nick
+		if len(params) < 1:
+			return "Your current nick is: %s" % m.nick
 		nick = params
 		m.change_nick(nick)
 
@@ -1451,6 +1463,9 @@ def cb_msg(md, type, tid, params, sbd):
 	elif headers.has_key('Content-Type') and headers['Content-Type'] == 'text/x-clientcaps':
 		# ignore the x-clientcaps messages generated from gaim
 		pass
+	elif headers.has_key('Content-Type') and headers['Content-Type'] == 'text/x-keepalive':
+		# ignore kopete's keepalive messages
+		pass
 	else:
 		# messages
 		m.users[email].priv['typing'] = 0
@@ -1621,7 +1636,7 @@ m.cb.reg = cb_reg
 #
 # now the real thing
 #
-printl('* MSN Client (3.5) *\n', c.yellow, 1)
+printl('* MSN Client (3.6) *\n', c.yellow, 1)
 
 # first, the configuration
 printl('Loading config... ', c.green, 1)
diff --git a/msncb.py b/msncb.py
index 0839e9b..f4620b5 100644
--- a/msncb.py
+++ b/msncb.py
@@ -2,10 +2,15 @@
 
 import string
 import urllib
-import md5
-
 import socket
 
+# md5 is deprecated in favour of hashlib since python 2.5; hashlib was
+# introduced in python 2.5
+try:
+	from hashlib import md5
+except:
+	from md5 import md5
+
 import msnlib
 
 """
@@ -141,7 +146,7 @@ def cb_chl(md, type, tid, params):
 	"Handles the challenges"
 	if type != 'CHL': raise 'CallbackMess', (md, type, params)
 	hash = params + 'VT6PX?UQTM4WM%YR' # magic from www.hypothetic.org
-	hash = md5.md5(hash).hexdigest()
+	hash = md5(hash).hexdigest()
 	md._send('QRY', 'PROD0038W!61ZTF9 32')
 	md.fd.send(hash)
 
diff --git a/msnlib.py b/msnlib.py
index 238a062..ca40614 100644
--- a/msnlib.py
+++ b/msnlib.py
@@ -1,11 +1,8 @@
 
 
 import sys
-import time
 import string
 import socket
-import select
-import md5
 import urllib
 
 """
@@ -14,7 +11,7 @@ by Alberto Bertogli (albertogli@telpin.com.ar)
 """
 
 # constants
-VERSION = 0x0305
+VERSION = 0x0306
 LOGIN_HOST = 'messenger.hotmail.com'
 LOGIN_PORT = 1863
 
@@ -543,7 +540,7 @@ class msnd:
 		ahead += ',sign-in=' + urllib.quote(self.email)
 		ahead += ',pwd=' + urllib.quote(self.pwd)
 		ahead += ',lc=1033,id=507,tw=40,fs=1,'
-		ahead += 'ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1062764229,'
+		ahead += 'ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=0,'
 		ahead += 'kpp=1,kv=5,ver=2.1.0173.1,tpf=' + hash
 		headers = { 'Authorization': ahead }
 
diff --git a/msnsetup b/msnsetup
old mode 100644
new mode 100755
index d722e70..a41b67d
--- a/msnsetup
+++ b/msnsetup
@@ -12,7 +12,7 @@ function intro() {
 
 function get_email() {
 	echo "* Email"
-	echo "This is the email address you use with your msn account, usually (but not necesarily) a hotmail.com account."
+	echo "This is the email address you use with your msn account, usually (but not necessarily) a hotmail.com account."
 	while [ -z "$EMAIL" ]; do
 		read -p "Please insert your email address: " EMAIL
 		echo
diff --git a/setup.py b/setup.py
index 47b8c0c..a5b91f0 100644
--- a/setup.py
+++ b/setup.py
@@ -2,11 +2,11 @@
 from distutils.core import setup
 
 setup(name="msnlib",
-	version="3.5",
+	version="3.6",
 	description="MSN Messenger Library and Client",
 	author="Alberto Bertogli",
 	author_email="albertogli@telpin.com.ar",
 	url="http://users.auriga.wearlab.de/~alb/msnlib",
 	py_modules=['msnlib', 'msncb'],
 )
-									 
+
diff --git a/utils/clean b/utils/clean
deleted file mode 100644
index 168a843..0000000
--- a/utils/clean
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-rm -vrf *.pyc *.pyo *~
-rm -vrf build
-
diff --git a/utils/exporter b/utils/exporter
deleted file mode 100644
index 17b3762..0000000
--- a/utils/exporter
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import os
-from xml.sax import saxutils
-from xml.sax import make_parser
-from xml.sax.handler import feature_namespaces
-
-
-class Patch:
-	"Represents a single patch/record"
-	def __init__(self):
-		self.hash = ''
-		self.author = ''
-		self.date = ''
-		self.local_date = ''
-		self.name = ''
-		self.comment = ''
-
-	def tostr(self):
-		s = "%s\n\tAuthor: %s\n\tDate: %s\n\tHash: %s\n" % \
-			(self.name, self.author, self.date, self.hash)
-		return s
-
-	def export(self, order, path):
-		# '/'s are not allowed in filenames
-		name = self.name.replace('/', '-')
-
-		# avoid 'name..patch'
-		if name[-1] == '.':
-			name = name[:-1]
-
-		file = "%s/%.2d - %s.patch" % (path, order, name)
-		cmd = 'darcs diff -u --match "hash %s" > "%s"' % \
-				(self.hash, file)
-		if os.system(cmd):
-			print "Command failed: '%s'" % cmd
-
-
-class BuildPatchList(saxutils.DefaultHandler):
-	def __init__(self):
-		self.db = {}
-		self.list = []
-		self.cur_hash = ''
-		self.cur_elem = None
-		self.cur_val = ''
-
-	def startElement(self, name, attrs):
-		if name == 'patch':
-			p = Patch()
-			p.author = attrs.get('author', None)
-			p.date = attrs.get('date', None)
-			p.local_date = attrs.get('local_date', None)
-			p.hash = attrs.get('hash')
-			self.db[p.hash] = p
-			self.current = p.hash
-			self.list.append(p.hash)
-		elif name == 'name':
-			self.db[self.current].name = ''
-			self.cur_elem = 'name'
-		elif name == 'comment':
-			self.db[self.current].comment = ''
-			self.cur_elem = 'name'
-		else:
-			self.cur_elem = None
-
-	def characters(self, s):
-		if not self.cur_elem:
-			return
-		self.cur_val += s
-
-	def endElement(self, name):
-		if name == 'name':
-			self.db[self.current].name = self.cur_val
-		elif name == 'comment':
-			self.db[self.current].current = self.cur_val
-
-		self.cur_elem = None
-		self.cur_val = ''
-
-
-# main
-
-if len(sys.argv) < 3:
-	print "Use: exporter [xmlfile|-] [list|export destdir]"
-	print
-	print "Examples:"
-	print " # darcs changes --xml-output | exporter - export /tmp"
-	print " # darcs changes --xml-output | exporter - list"
-	sys.exit(1)
-
-if sys.argv[1] == '-':
-	file = sys.stdin
-else:
-	file = sys.argv[1]
-
-parser = make_parser()
-parser.setFeature(feature_namespaces, 0)
-
-handler = BuildPatchList()
-parser.setContentHandler(handler)
-parser.parse(file)
-
-# reverse the list so the oldest is the first, and the newest is the last
-handler.list.reverse()
-
-# we now have two main structures: handler.db is the hash table of Patches,
-# indexed by their hash, and handler.list is the ordered list of hashes.
-
-if sys.argv[2] == 'list':
-	c = 1
-	for h in handler.list:
-		print "%.2d:" % c, handler.db[h].tostr()
-		c += 1
-elif sys.argv[2] == 'export':
-	if len(sys.argv) < 4:
-		print "Destination directory missing"
-		sys.exit(1)
-	c = 1
-	for h in handler.list:
-		p = handler.db[h]
-		print "%.2d: %s" % (c, p.name)
-		p.export(c, sys.argv[3])
-		c += 1
-else:
-	print "Unknown parameter"
-
diff --git a/utils/hmerge b/utils/hmerge
old mode 100644
new mode 100755
diff --git a/utils/msnbot b/utils/msnbot
old mode 100644
new mode 100755
diff --git a/utils/msncd b/utils/msncd
old mode 100644
new mode 100755
diff --git a/utils/msntk b/utils/msntk
old mode 100644
new mode 100755
diff --git a/utils/vicl b/utils/vicl
deleted file mode 100644
index 2a87f61..0000000
--- a/utils/vicl
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-# yeah i work as root =)
-DIR=/root/devel/msn/msnlib/cur
-
-cd $DIR
-cd doc
-cp Changelog Changelog~
-
-DATE=`date '+%d %h %y %H.%M.%S'`
-echo "$DATE - Alberto <albertogli@telpin.com.ar>"  > Changelog
-echo " * " >> Changelog
-echo >> Changelog
-
-cat Changelog~ >> Changelog
-
-vi Changelog
-
-rm Changelog~

