summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/cfgfiles.c2
-rw-r--r--src/common/dbus/example-gdbus.py32
-rw-r--r--src/common/dbus/example.py6
-rw-r--r--src/common/fe.h5
-rw-r--r--src/common/hexchat.h3
-rw-r--r--src/common/inbound.c72
-rw-r--r--src/common/modes.c4
-rw-r--r--src/common/outbound.c42
-rw-r--r--src/common/proto-irc.c33
-rw-r--r--src/common/server.c25
-rw-r--r--src/common/servlist.c18
-rw-r--r--src/common/ssl.c6
-rw-r--r--src/common/text.c83
-rw-r--r--src/common/text.h6
-rw-r--r--src/common/textevents.in2
-rw-r--r--src/common/url.c4
-rw-r--r--src/fe-gtk/ascii.c2
-rw-r--r--src/fe-gtk/banlist.c591
-rw-r--r--src/fe-gtk/banlist.h59
-rw-r--r--src/fe-gtk/chanview-tree.c23
-rw-r--r--src/fe-gtk/dccgui.c2
-rw-r--r--src/fe-gtk/fe-gtk.c8
-rw-r--r--src/fe-gtk/fe-gtk.h6
-rw-r--r--src/fe-gtk/gtkutil.c15
-rw-r--r--src/fe-gtk/gtkutil.h1
-rw-r--r--src/fe-gtk/ignoregui.c21
-rw-r--r--src/fe-gtk/maingui.c4
-rw-r--r--src/fe-gtk/notifygui.c1
-rw-r--r--src/fe-gtk/plugingui.c1
-rw-r--r--src/fe-gtk/rawlog.c11
-rw-r--r--src/fe-gtk/search.c11
-rw-r--r--src/fe-gtk/servlistgui.c1
-rw-r--r--src/fe-gtk/setup.c13
-rw-r--r--src/fe-gtk/urlgrab.c1
-rw-r--r--src/fe-gtk/xtext.c9
-rw-r--r--src/fe-text/fe-text.c25
-rw-r--r--src/htm/Main.cs2
37 files changed, 807 insertions, 343 deletions
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index 243371b0..cca2267a 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -450,7 +450,6 @@ const struct prefs vars[] =
 	{"gui_tab_icons", P_OFFINT (hex_gui_tab_icons), TYPE_BOOL},
 	{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
 	{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
-	{"gui_tab_notices", P_OFFINT (hex_gui_tab_notices), TYPE_BOOL},
 	{"gui_tab_pos", P_OFFINT (hex_gui_tab_pos), TYPE_INT},
 	{"gui_tab_server", P_OFFINT (hex_gui_tab_server), TYPE_BOOL},
 	{"gui_tab_small", P_OFFINT (hex_gui_tab_small), TYPE_INT},
@@ -524,6 +523,7 @@ const struct prefs vars[] =
 	{"irc_nick3", P_OFFSET (hex_irc_nick3), TYPE_STR},
 	{"irc_nick_hilight", P_OFFSET (hex_irc_nick_hilight), TYPE_STR},
 	{"irc_no_hilight", P_OFFSET (hex_irc_no_hilight), TYPE_STR},
+	{"irc_notice_pos", P_OFFINT (hex_irc_notice_pos), TYPE_INT},
 	{"irc_part_reason", P_OFFSET (hex_irc_part_reason), TYPE_STR},
 	{"irc_quit_reason", P_OFFSET (hex_irc_quit_reason), TYPE_STR},
 	{"irc_raw_modes", P_OFFINT (hex_irc_raw_modes), TYPE_BOOL},
diff --git a/src/common/dbus/example-gdbus.py b/src/common/dbus/example-gdbus.py
new file mode 100644
index 00000000..3c25771b
--- /dev/null
+++ b/src/common/dbus/example-gdbus.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+
+from gi.repository import Gio
+
+bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
+connection = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None,
+  						'org.hexchat.service', '/org/hexchat/Remote', 'org.hexchat.connection', None)
+path = connection.Connect('(ssss)', 
+					'example.py',
+					'Python example', 
+					'Example of a D-Bus client written in python', 
+					'1.0')		
+hexchat = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None,
+								'org.hexchat.service', path, 'org.hexchat.plugin', None)
+         
+# Note the type before every arguement, this must be done.
+# Type requirements are listed in our docs and characters are listed in the dbus docs.
+# s = string, u = uint, i = int, etc.
+
+channels = hexchat.ListGet ('(s)', "channels")
+while hexchat.ListNext ('(u)', channels):
+	name = hexchat.ListStr ('(us)', channels, "channel")
+	print("------- " + name + " -------")
+	hexchat.SetContext ('(u)', hexchat.ListInt ('(us)', channels, "context"))
+	hexchat.EmitPrint ('(sas)', "Channel Message", ["John", "Hi there", "@"])
+	users = hexchat.ListGet ('(s)', "users")
+	while hexchat.ListNext ('(u)', users):
+		print("Nick: " + hexchat.ListStr ('(us)', users, "nick"))
+	hexchat.ListFree ('(u)', users)
+hexchat.ListFree ('(u)', channels)
+
+print(hexchat.Strip ('(sii)', "\00312Blue\003 \002Bold!\002", -1, 1|2))
diff --git a/src/common/dbus/example.py b/src/common/dbus/example.py
index 49855784..f326e98a 100644
--- a/src/common/dbus/example.py
+++ b/src/common/dbus/example.py
@@ -15,14 +15,14 @@ hexchat = dbus.Interface(proxy, 'org.hexchat.plugin')
 channels = hexchat.ListGet ("channels")
 while hexchat.ListNext (channels):
 	name = hexchat.ListStr (channels, "channel")
-	print "------- " + name + " -------"
+	print("------- " + name + " -------")
 	hexchat.SetContext (hexchat.ListInt (channels, "context"))
 	hexchat.EmitPrint ("Channel Message", ["John", "Hi there", "@"])
 	users = hexchat.ListGet ("users")
 	while hexchat.ListNext (users):
-		print "Nick: " + hexchat.ListStr (users, "nick")
+		print("Nick: " + hexchat.ListStr (users, "nick"))
 	hexchat.ListFree (users)
 hexchat.ListFree (channels)
 
-print hexchat.Strip ("\00312Blue\003 \002Bold!\002", -1, 1|2)
+print(hexchat.Strip ("\00312Blue\003 \002Bold!\002", -1, 1|2))
 
diff --git a/src/common/fe.h b/src/common/fe.h
index 4903ef0e..337c4b47 100644
--- a/src/common/fe.h
+++ b/src/common/fe.h
@@ -59,9 +59,8 @@ int fe_is_chanwindow (struct server *serv);
 void fe_add_chan_list (struct server *serv, char *chan, char *users,
 							  char *topic);
 void fe_chan_list_end (struct server *serv);
-int fe_is_banwindow (struct session *sess);
-void fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int is_exemption);
-void fe_ban_list_end (struct session *sess, int is_exemption);
+gboolean fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rplcode);
+gboolean fe_ban_list_end (struct session *sess, int rplcode);
 void fe_notify_update (char *name);
 void fe_notify_ask (char *name, char *networks);
 void fe_text_clear (struct session *sess, int lines);
diff --git a/src/common/hexchat.h b/src/common/hexchat.h
index fad61938..e234c976 100644
--- a/src/common/hexchat.h
+++ b/src/common/hexchat.h
@@ -146,7 +146,6 @@ struct hexchatprefs
 	unsigned int hex_gui_tab_dialogs;
 	unsigned int hex_gui_tab_dots;
 	unsigned int hex_gui_tab_icons;
-	unsigned int hex_gui_tab_notices;
 	unsigned int hex_gui_tab_server;
 	unsigned int hex_gui_tab_sort;
 	unsigned int hex_gui_tab_utils;
@@ -277,6 +276,7 @@ struct hexchatprefs
 	int hex_input_balloon_time;
 	int hex_irc_ban_type;
 	int hex_irc_join_delay;
+	int hex_irc_notice_pos;
 	int hex_net_ping_timeout;
 	int hex_net_proxy_port;
 	int hex_net_proxy_type;				/* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */
@@ -576,6 +576,7 @@ typedef struct server
 	unsigned int have_idmsg:1;		/* freenode's IDENTIFY-MSG */
 	unsigned int have_sasl:1;		/* SASL capability */
 	unsigned int have_except:1;	/* ban exemptions +e */
+	unsigned int have_invite:1;	/* invite exemptions +I */
 	unsigned int using_cp1255:1;	/* encoding is CP1255/WINDOWS-1255? */
 	unsigned int using_irc:1;		/* encoding is "IRC" (CP1252/UTF-8 hybrid)? */
 	unsigned int use_who:1;			/* whether to use WHO command to get dcc_ip */
diff --git a/src/common/inbound.c b/src/common/inbound.c
index 54e5bff0..dae919b8 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -155,6 +155,7 @@ void
 inbound_privmsg (server *serv, char *from, char *ip, char *text, int id)
 {
 	session *sess;
+	struct User *user;
 	char idtext[64];
 
 	sess = find_dialog (serv, from);
@@ -197,6 +198,10 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id)
 		EMIT_SIGNAL (XP_TE_PRIVMSG, sess, from, text, idtext, NULL, 0);
 		return;
 	}
+	
+	user = userlist_find (sess, from);
+	if (user)
+		user->lasttalk = time (0);
 
 	if (sess->type == SESS_DIALOG)
 		EMIT_SIGNAL (XP_TE_DPRIVMSG, sess, from, text, idtext, NULL, 0);
@@ -867,7 +872,27 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id)
 	if (!sess)
 	{
 		ptr = 0;
-		if (prefs.hex_gui_tab_notices)
+		if (prefs.hex_irc_notice_pos == 0)
+		{
+											/* paranoia check */
+			if (msg[0] == '[' && (!serv->have_idmsg || id))
+			{
+				/* guess where chanserv meant to post this -sigh- */
+				if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick))
+				{
+					char *dest = strdup (msg + 1);
+					char *end = strchr (dest, ']');
+					if (end)
+					{
+						*end = 0;
+						sess = find_channel (serv, dest);
+					}
+					free (dest);
+				}
+			}
+			if (!sess)
+				sess = find_session_from_nick (nick, serv);
+		} else if (prefs.hex_irc_notice_pos == 1)
 		{
 			int stype = server_notice ? SESS_SNOTICES : SESS_NOTICES;
 			sess = find_session_from_type (stype, serv);
@@ -888,25 +913,9 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id)
 				msg += 14;
 		} else
 		{
-											/* paranoia check */
-			if (msg[0] == '[' && (!serv->have_idmsg || id))
-			{
-				/* guess where chanserv meant to post this -sigh- */
-				if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick))
-				{
-					char *dest = strdup (msg + 1);
-					char *end = strchr (dest, ']');
-					if (end)
-					{
-						*end = 0;
-						sess = find_channel (serv, dest);
-					}
-					free (dest);
-				}
-			}
-			if (!sess)
-				sess = find_session_from_nick (nick, serv);
+			sess = serv->front_session;
 		}
+
 		if (!sess)
 		{
 			if (server_notice)	
@@ -1030,6 +1039,7 @@ check_autojoin_channels (server *serv)
 
 		free (serv->autojoin);
 		serv->autojoin = NULL;
+		i++;
 	}
 
 	/* this is really only for re-connects when you
@@ -1053,8 +1063,17 @@ check_autojoin_channels (server *serv)
 				if (po)
 					*po = 0;
 
-				channels = g_slist_append (channels, g_strdup (sess->waitchannel));
-				keys = g_slist_append (keys, g_strdup (sess->channelkey));
+				/* There can be no gap between keys, list keyed chans first. */
+				if (sess->channelkey[0] != 0)
+				{
+					channels = g_slist_prepend (channels, g_strdup (sess->waitchannel));
+					keys = g_slist_prepend (keys, g_strdup (sess->channelkey));
+				}
+				else
+				{
+					channels = g_slist_append (channels, g_strdup (sess->waitchannel));
+					keys = g_slist_append (keys, g_strdup (sess->channelkey));
+				}
 				i++;
 			}
 		}
@@ -1258,12 +1277,14 @@ inbound_user_info (session *sess, char *chan, char *user, char *host,
 }
 
 int
-inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, char *banner, int is_exemption)
+inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, char *banner, int rplcode)
 {
 	char *time_str = ctime (&stamp);
 	server *serv = sess->server;
+	char *nl;
 
-	time_str[19] = 0;	/* get rid of the \n */
+	if ((nl = strchr (time_str, '\n')))
+		*nl = 0;
 	if (stamp == 0)
 		time_str = "";
 
@@ -1274,18 +1295,17 @@ inbound_banlist (session *sess, time_t stamp, char *chan, char *mask, char *bann
 		goto nowindow;
 	}
 
-   if (!fe_is_banwindow (sess))
+	if (!fe_add_ban_list (sess, mask, banner, time_str, rplcode))
 	{
 nowindow:
 		/* let proto-irc.c do the 'goto def' for exemptions */
-		if (is_exemption)
+		if (rplcode != 367)	/* RPL_EXCEPTLIST */
 			return FALSE;
 
 		EMIT_SIGNAL (XP_TE_BANLIST, sess, chan, mask, banner, time_str, 0);
 		return TRUE;
 	}
 
-	fe_add_ban_list (sess, mask, banner, time_str, is_exemption);
 	return TRUE;
 }
 
diff --git a/src/common/modes.c b/src/common/modes.c
index 6caa46b9..7326b6fe 100644
--- a/src/common/modes.c
+++ b/src/common/modes.c
@@ -824,6 +824,10 @@ inbound_005 (server * serv, char *word[])
 #ifndef WIN32
 			serv->have_except = TRUE;
 #endif
+		} else if (strcmp (word[w], "INVEX") == 0)
+		{
+			/* supports mode letter +I, default channel invite */
+			serv->have_invite = TRUE;
 		} else if (strncmp (word[w], "ELIST=", 6) == 0)
 		{
 			/* supports LIST >< min/max user counts? */
diff --git a/src/common/outbound.c b/src/common/outbound.c
index c146c2ac..c543997a 100644
--- a/src/common/outbound.c
+++ b/src/common/outbound.c
@@ -2272,7 +2272,7 @@ cmd_ignore (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 		return TRUE;
 	}
 	if (!*word[3])
-		return FALSE;
+		word[3] = "ALL";
 
 	i = 3;
 	while (1)
@@ -2873,7 +2873,7 @@ open_query (server *serv, char *nick, gboolean focus_existing)
 
 	sess = find_dialog (serv, nick);
 	if (!sess)
-		new_ircwindow (serv, nick, SESS_DIALOG, 1);
+		new_ircwindow (serv, nick, SESS_DIALOG, focus_existing);
 	else if (focus_existing)
 		fe_ctrl_gui (sess, 2, 0);	/* bring-to-front */
 }
@@ -3066,7 +3066,7 @@ cmd_splay (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 }
 
 static int
-parse_irc_url (char *url, char *server_name[], char *port[], char *channel[], int *use_ssl)
+parse_irc_url (char *url, char *server_name[], char *port[], char *channel[], char *key[], int *use_ssl)
 {
 	char *co;
 #ifdef USE_OPENSSL
@@ -3104,6 +3104,15 @@ urlserv:
 				*channel = co;
 			
 		}
+		/* check for key - mirc style */
+		co = strchr (co + 1, '?');
+		if (co)
+		{
+			*co = 0;
+			co++;
+			*key = co;
+		}
+			
 		return TRUE;
 	}
 	return FALSE;
@@ -3117,6 +3126,7 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 	char *port = NULL;
 	char *pass = NULL;
 	char *channel = NULL;
+	char *key = NULL;
 	int use_ssl = FALSE;
 	int is_url = TRUE;
 	server *serv = sess->server;
@@ -3130,7 +3140,7 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 	}
 #endif
 
-	if (!parse_irc_url (word[2 + offset], &server_name, &port, &channel, &use_ssl))
+	if (!parse_irc_url (word[2 + offset], &server_name, &port, &channel, &key, &use_ssl))
 	{
 		is_url = FALSE;
 		server_name = word[2 + offset];
@@ -3156,6 +3166,8 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 	{
 		sess->willjoinchannel[0] = '#';
 		safe_strcpy ((sess->willjoinchannel + 1), channel, (CHANLEN - 1));
+		if (key)
+			safe_strcpy (sess->channelkey, key, 64);
 	}
 
 	/* support +7000 style ports like mIRC */
@@ -3277,6 +3289,12 @@ cmd_unignore (struct session *sess, char *tbuf, char *word[],
 	char *arg = word[3];
 	if (*mask)
 	{
+		if (strchr (mask, '?') == NULL && strchr (mask, '*') == NULL)
+		{
+			mask = tbuf;
+			snprintf (tbuf, TBUFSIZE, "%s!*@*", word[2]);
+		}
+		
 		if (ignore_del (mask, NULL))
 		{
 			if (g_ascii_strcasecmp (arg, "QUIET"))
@@ -3356,15 +3374,18 @@ find_server_from_net (void *net)
 }
 
 static void
-url_join_only (server *serv, char *tbuf, char *channel)
+url_join_only (server *serv, char *tbuf, char *channel, char *key)
 {
-	/* already connected, JOIN only. FIXME: support keys? */
+	/* already connected, JOIN only. */
 	if (channel == NULL)
 		return;
 	tbuf[0] = '#';
 	/* tbuf is 4kb */
 	safe_strcpy ((tbuf + 1), channel, 256);
-	serv->p_join (serv, tbuf, "");
+	if (key)
+		serv->p_join (serv, tbuf, key);
+	else
+		serv->p_join (serv, tbuf, "");
 }
 
 static int
@@ -3375,12 +3396,13 @@ cmd_url (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 		char *server_name = NULL;
 		char *port = NULL;
 		char *channel = NULL;
+		char *key = NULL;
 		char *url = g_strdup (word[2]);
 		int use_ssl = FALSE;
 		void *net;
 		server *serv;
 
-		if (parse_irc_url (url, &server_name, &port, &channel, &use_ssl))
+		if (parse_irc_url (url, &server_name, &port, &channel, &key, &use_ssl))
 		{
 			/* maybe we're already connected to this net */
 
@@ -3396,7 +3418,7 @@ cmd_url (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 				serv = find_server_from_net (net);
 				if (serv)
 				{
-					url_join_only (serv, tbuf, channel);
+					url_join_only (serv, tbuf, channel, key);
 					g_free (url);
 					return TRUE;
 				}
@@ -3407,7 +3429,7 @@ cmd_url (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 				serv = find_server_from_hostname (server_name);
 				if (serv)
 				{
-					url_join_only (serv, tbuf, channel);
+					url_join_only (serv, tbuf, channel, key);
 					g_free (url);
 					return TRUE;
 				}
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c
index 18015607..13147016 100644
--- a/src/common/proto-irc.c
+++ b/src/common/proto-irc.c
@@ -778,8 +778,18 @@ process_numeric (session * sess, int n,
 		}
 		break;
 
+	case 346:	/* +I-list entry */
+		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 346))
+			goto def;
+		break;
+
+	case 347:	/* end of invite list */
+		if (!fe_ban_list_end (sess, 347))
+			goto def;
+		break;
+
 	case 348:	/* +e-list entry */
-		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], TRUE))
+		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 348))
 			goto def;
 		break;
 
@@ -790,9 +800,8 @@ process_numeric (session * sess, int n,
 			sess = serv->front_session;
 			goto def;
 		}
-		if (!fe_is_banwindow (sess))
+		if (!fe_ban_list_end (sess, 349))
 			goto def;
-		fe_ban_list_end (sess, TRUE);
 		break;
 
 	case 353:						  /* NAMES */
@@ -806,7 +815,8 @@ process_numeric (session * sess, int n,
 		break;
 
 	case 367: /* banlist entry */
-		inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], FALSE);
+		if (!inbound_banlist (sess, atol (word[7]), word[4], word[5], word[6], 367))
+			goto def;
 		break;
 
 	case 368:
@@ -816,9 +826,8 @@ process_numeric (session * sess, int n,
 			sess = serv->front_session;
 			goto def;
 		}
-		if (!fe_is_banwindow (sess))
+		if (!fe_ban_list_end (sess, 368))
 			goto def;
-		fe_ban_list_end (sess, FALSE);
 		break;
 
 	case 369:	/* WHOWAS end */
@@ -881,6 +890,18 @@ process_numeric (session * sess, int n,
 		notify_set_online (serv, word[4]);
 		break;
 
+	case 728:	/* +q-list entry */
+		/* NOTE:  FREENODE returns these results inconsistent with e.g. +b */
+		/* Who else has imlemented MODE_QUIET, I wonder? */
+		if (!inbound_banlist (sess, atol (word[8]), word[4], word[6], word[7], 728))
+			goto def;
+		break;
+
+	case 729:	/* end of quiet list */
+		if (!fe_ban_list_end (sess, 729))
+			goto def;
+		break;
+
 	case 903:	/* successful SASL auth */
 	case 904:	/* aborted SASL auth */
 	case 905:	/* failed SASL auth */
diff --git a/src/common/server.c b/src/common/server.c
index 6ddaa18d..8ad1d6ca 100644
--- a/src/common/server.c
+++ b/src/common/server.c
@@ -313,13 +313,6 @@ server_inline (server *serv, char *line, int len)
 {
 	char *utf_line_allocated = NULL;
 
-#ifdef WIN32
-#if 0
-	char *cleaned_line;
-	int cleaned_len;
-#endif
-#endif
-
 	/* Checks whether we're set to use UTF-8 charset */
 	if (serv->using_irc ||				/* 1. using CP1252/UTF-8 Hybrid */
 		(serv->encoding == NULL && prefs.utf8_locale) || /* OR 2. using system default->UTF-8 */
@@ -406,28 +399,11 @@ server_inline (server *serv, char *line, int len)
 		}
 	}
 
-#ifdef WIN32
-#if 0
-	cleaned_line = text_replace_non_bmp (line, len, &cleaned_len);
-	if (cleaned_line != NULL ) {
-		line = cleaned_line;
-		len = cleaned_len;
-	}
-#endif
-	text_replace_non_bmp2 (line);
-#endif
-
 	fe_add_rawlog (serv, line, len, FALSE);
 
 	/* let proto-irc.c handle it */
 	serv->p_inline (serv, line, len);
 
-#ifdef WIN32
-#if 0
-	g_free (cleaned_line);
-#endif
-#endif
-
 	if (utf_line_allocated != NULL) /* only if a special copy was allocated */
 		g_free (utf_line_allocated);
 }
@@ -1914,6 +1890,7 @@ server_set_defaults (server *serv)
 	serv->have_idmsg = FALSE;
 	serv->have_sasl = FALSE;
 	serv->have_except = FALSE;
+	serv->have_invite = FALSE;
 }
 
 char *
diff --git a/src/common/servlist.c b/src/common/servlist.c
index f4208f61..96fa4557 100644
--- a/src/common/servlist.c
+++ b/src/common/servlist.c
@@ -1047,7 +1047,19 @@ servlist_load (void)
 	char *tmp;
 	ircnet *net = NULL;
 
-	fp = hexchat_fopen_file ("servlist_.conf", "r", 0);
+	/* simple migration we will keep for a short while */
+	char *oldfile = g_build_filename (get_xdir (), "servlist_.conf", NULL);
+	char *newfile = g_build_filename (get_xdir (), "servlist.conf", NULL);
+
+	if (g_file_test (oldfile, G_FILE_TEST_EXISTS) && !g_file_test (newfile, G_FILE_TEST_EXISTS))
+	{
+		g_rename (oldfile, newfile);
+	}
+
+	g_free (oldfile);
+	g_free (newfile);
+
+	fp = hexchat_fopen_file ("servlist.conf", "r", 0);
 	if (!fp)
 		return FALSE;
 
@@ -1178,12 +1190,12 @@ servlist_save (void)
 #ifndef WIN32
 	int first = FALSE;
 
-	buf = g_strdup_printf ("%s/servlist_.conf", get_xdir ());
+	buf = g_strdup_printf ("%s/servlist.conf", get_xdir ());
 	if (g_access (buf, F_OK) != 0)
 		first = TRUE;
 #endif
 
-	fp = hexchat_fopen_file ("servlist_.conf", "w", 0);
+	fp = hexchat_fopen_file ("servlist.conf", "w", 0);
 	if (!fp)
 	{
 #ifndef WIN32
diff --git a/src/common/ssl.c b/src/common/ssl.c
index 75a81250..742da619 100644
--- a/src/common/ssl.c
+++ b/src/common/ssl.c
@@ -31,7 +31,7 @@
 #include "ssl.h"				  /* struct cert_info */
 
 #ifndef HAVE_SNPRINTF
-#include <glib.h>

+#include <glib.h>
 #include <glib/gprintf.h>
 #define snprintf g_snprintf
 #endif
@@ -77,7 +77,7 @@ _SSL_context_init (void (*info_cb_func), int server)
 
 	SSLeay_add_ssl_algorithms ();
 	SSL_load_error_strings ();
-	ctx = SSL_CTX_new (server ? SSLv3_server_method() : SSLv3_client_method ());
+	ctx = SSL_CTX_new (server ? SSLv23_server_method() : SSLv23_client_method ());
 
 	SSL_CTX_set_session_cache_mode (ctx, SSL_SESS_CACHE_BOTH);
 	SSL_CTX_set_timeout (ctx, 300);
@@ -288,7 +288,7 @@ _SSL_socket (SSL_CTX *ctx, int sd)
 		__SSL_critical_error ("SSL_new");
 
 	SSL_set_fd (ssl, sd);
-	if (ctx->method == SSLv3_client_method())
+	if (ctx->method == SSLv23_client_method())
 		SSL_set_connect_state (ssl);
 	else
 	        SSL_set_accept_state(ssl);
diff --git a/src/common/text.c b/src/common/text.c
index fdf08b90..8196cc03 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -307,21 +307,9 @@ scrollback_load (session *sess)
 					{
 						text = strip_color (text + 1, -1, STRIP_COLOR);
 					}
-#ifdef WIN32
-#if 0
-					cleaned_text = text_replace_non_bmp (text, -1, &cleaned_len);
-					if (cleaned_text != NULL)
-					{
-						if (prefs.hex_text_stripcolor_replay)
-						{
-							g_free (text);
-						}
-						text = cleaned_text;
-					}
-#endif
-					text_replace_non_bmp2 (text);
-#endif
+
 					fe_print_text (sess, text, stamp);
+
 					if (prefs.hex_text_stripcolor_replay)
 					{
 						g_free (text);
@@ -833,71 +821,6 @@ iso_8859_1_to_utf8 (unsigned char *text, int len, gsize *bytes_written)
 	return res;
 }
 
-#ifdef WIN32
-/* replace characters outside of the Basic Multilingual Plane with
- * replacement characters (0xFFFD) */
-#if 0
-char *
-text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length)
-{
-	gunichar *ucs4_text;
-	gunichar suspect;
-	gchar *utf8_text;
-	glong ucs4_length;
-	glong index;
-
-	ucs4_text = g_utf8_to_ucs4_fast (utf8_input, input_length, &ucs4_length);
-
-	/* replace anything not in the Basic Multilingual Plane
-	 * (code points above 0xFFFF) with the replacement
-	 * character */
-	for (index = 0; index < ucs4_length; index++)
-	{
-		suspect = ucs4_text[index];
-		if ((suspect >= 0x1D173 && suspect <= 0x1D17A)
-			|| (suspect >= 0xE0001 && suspect <= 0xE007F))
-		{
-			ucs4_text[index] = 0xFFFD; /* replacement character */
-		}
-	}
-
-	utf8_text = g_ucs4_to_utf8 (
-		ucs4_text,
-		ucs4_length,
-		NULL,
-		output_length,
-		NULL
-	);
-	g_free (ucs4_text);
-
-	return utf8_text;
-}
-#endif
-
-void
-text_replace_non_bmp2 (char *utf8_input)
-{
-	char *tmp = utf8_input, *next;
-	gunichar suspect;
-
-	while (tmp != NULL && *tmp)
-	{
-		next = g_utf8_next_char(tmp);
-		suspect = g_utf8_get_char_validated(tmp, next - tmp);
-		if ((suspect >= 0x1D173 && suspect <= 0x1D17A) || (suspect >= 0xE0001 && suspect <= 0xE007F))
-		{
-			/* 0xFFFD - replacement character */
-			*tmp = 0xEF;
-			*(++tmp) = 0xBF;
-			*(++tmp) = 0xBD;
-			*(++tmp) = 0x1A;	/* ASCII Sub to fill the 4th non-BMP byte */
-		}
-
-		tmp = next;
-	}
-}
-#endif
-
 char *
 text_validate (char **text, int *len)
 {
@@ -1857,6 +1780,8 @@ format_event (session *sess, int index, char **args, char *o, int sizeofo, unsig
 				printf ("arg[%d] is NULL in print event\n", a + 1);
 			} else
 			{
+				if (strlen (ar) > sizeofo - oi - 4)
+					ar[sizeofo - oi - 4] = 0;	/* Avoid buffer overflow */
 				if (stripcolor_args & ARG_FLAG(a + 1)) len = strip_color2 (ar, -1, &o[oi], STRIP_ALL);
 				else len = strip_hidden_attribute (ar, &o[oi]);
 				oi += len;
diff --git a/src/common/text.h b/src/common/text.h
index e018c769..103e294d 100644
--- a/src/common/text.h
+++ b/src/common/text.h
@@ -29,12 +29,6 @@ void pevent_make_pntevts (void);
 int text_color_of (char *name);
 void text_emit (int index, session *sess, char *a, char *b, char *c, char *d);
 int text_emit_by_name (char *name, session *sess, char *a, char *b, char *c, char *d);
-#ifdef WIN32
-#if 0
-char *text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length);
-#endif
-void text_replace_non_bmp2 (char *utf8_input);
-#endif
 char *text_validate (char **text, int *len);
 int get_stamp_str (char *fmt, time_t tim, char **ret);
 void format_event (session *sess, int index, char **args, char *o, int sizeofo, unsigned int stripcolor_args);
diff --git a/src/common/textevents.in b/src/common/textevents.in
index 69d42526..ff1fd9c9 100644
--- a/src/common/textevents.in
+++ b/src/common/textevents.in
@@ -187,7 +187,7 @@ pevt_chansetlimit_help
 Channel UnBan
 XP_TE_CHANUNBAN
 pevt_chanunban_help
-%C22*%O$t%C26$1%O removes ban on %C24$2%O
+%C22*%O$t%C26$1%O removes ban on %C18$2%O
 2
 
 Channel Voice
diff --git a/src/common/url.c b/src/common/url.c
index 6bd7d9ff..2007b600 100644
--- a/src/common/url.c
+++ b/src/common/url.c
@@ -515,8 +515,8 @@ re_channel (void)
 
 /*	PATH description --- */
 #ifdef WIN32
-/* Windows path can be C: D: etc */
-#define PATH "^([a-z]:).*"
+/* Windows path can be .\ ..\ or C: D: etc */
+#define PATH "^(\\.{1,2}\\\\|[a-z]:).*"
 #else
 /* Linux path can be / or ./ or ../ etc */
 #define PATH "^(/|\\./|\\.\\./).*"
diff --git a/src/fe-gtk/ascii.c b/src/fe-gtk/ascii.c
index 06621cd7..ab6ac0ee 100644
--- a/src/fe-gtk/ascii.c
+++ b/src/fe-gtk/ascii.c
@@ -90,7 +90,6 @@ static const unsigned char table[]=
 0xd1,0x89,0xd1,0x8a,0xd1,0x8b,0xd1,0x8c,0xd1,0x8d,0xd1,0x8e,0xd1,0x8f,0
 };
 
-
 static gboolean
 ascii_enter (GtkWidget * wid, GdkEventCrossing *event, GtkWidget *label)
 {
@@ -133,6 +132,7 @@ ascii_open (void)
 	win = mg_create_generic_tab ("charmap", _("Character Chart"), TRUE, TRUE,
 										  NULL, NULL, 0, 0, &vbox, NULL);
 	gtk_container_set_border_width (GTK_CONTAINER (win), 5);
+	gtkutil_destroy_on_esc (win);
 
 	label = gtk_label_new (NULL);
 
diff --git a/src/fe-gtk/banlist.c b/src/fe-gtk/banlist.c
index a783ea07..995af8a2 100644
--- a/src/fe-gtk/banlist.c
+++ b/src/fe-gtk/banlist.c
@@ -36,6 +36,7 @@
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtktreeview.h>
 #include <gtk/gtktreeselection.h>
+#include <glib.h>
 
 #include "../common/hexchat.h"
 #include "../common/fe.h"
@@ -46,9 +47,56 @@
 #include "maingui.h"
 #include "banlist.h"
 
+/*
+ * These supports_* routines set capable, readable, writable bits */
+static void supports_bans (banlist_info *, int);
+static void supports_exempt (banlist_info *, int);
+static void supports_invite (banlist_info *, int);
+static void supports_quiet (banlist_info *, int);
+
+static mode_info modes[MODE_CT] = {
+	{
+		N_("Bans"),
+		N_("Ban"),
+		'b',
+		RPL_BANLIST,
+		RPL_ENDOFBANLIST,
+		1<<MODE_BAN,
+		supports_bans
+	}
+	,{
+		N_("Exempts"),
+		N_("Exempt"),
+		'e',
+		RPL_EXCEPTLIST,
+		RPL_ENDOFEXCEPTLIST,
+		1<<MODE_EXEMPT,
+		supports_exempt
+	}
+	,{
+		N_("Invites"),
+		N_("Invite"),
+		'I',
+		RPL_INVITELIST,
+		RPL_ENDOFINVITELIST,
+		1<<MODE_INVITE,
+		supports_invite
+	}
+	,{
+		N_("Quiets"),
+		N_("Quiet"),
+		'q',
+		RPL_QUIETLIST,
+		RPL_ENDOFQUIETLIST,
+		1<<MODE_QUIET,
+		supports_quiet
+	}
+};
+
 /* model for the banlist tree */
 enum
 {
+	TYPE_COLUMN,
 	MASK_COLUMN,
 	FROM_COLUMN,
 	DATE_COLUMN,
@@ -58,7 +106,7 @@ enum
 static GtkTreeView *
 get_view (struct session *sess)
 {
-	return GTK_TREE_VIEW (sess->res->banlist_treeview);
+	return GTK_TREE_VIEW (sess->res->banlist->treeview);
 }
 
 static GtkListStore *
@@ -67,91 +115,280 @@ get_store (struct session *sess)
 	return GTK_LIST_STORE (gtk_tree_view_get_model (get_view (sess)));
 }
 
-static gboolean
-supports_exempt (server *serv)
+static void
+supports_bans (banlist_info *banl, int i)
+{
+	int bit = 1<<i;
+
+	banl->capable |= bit;
+	banl->readable |= bit;
+	banl->writeable |= bit;
+	return;
+}
+
+static void
+supports_exempt (banlist_info *banl, int i)
 {
+	server *serv = banl->sess->server;
 	char *cm = serv->chanmodes;
+	int bit = 1<<i;
 
 	if (serv->have_except)
-		return TRUE;
+		goto yes;
 
 	if (!cm)
-		return FALSE;
+		return;
 
 	while (*cm)
 	{
 		if (*cm == ',')
 			break;
 		if (*cm == 'e')
-			return TRUE;
+			goto yes;
 		cm++;
 	}
+	return;
 
-	return FALSE;
+yes:
+	banl->capable |= bit;
+	banl->writeable |= bit;
 }
 
-void
-fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int is_exempt)
+static void
+supports_invite (banlist_info *banl, int i)
+{
+	server *serv = banl->sess->server;
+	char *cm = serv->chanmodes;
+	int bit = 1<<i;
+
+	if (serv->have_invite)
+		goto yes;
+
+	if (!cm)
+		return;
+
+	while (*cm)
+	{
+		if (*cm == ',')
+			break;
+		if (*cm == 'I')
+			goto yes;
+		cm++;
+	}
+	return;
+
+yes:
+	banl->capable |= bit;
+	banl->writeable |= bit;
+}
+
+static void
+supports_quiet (banlist_info *banl, int i)
 {
+	server *serv = banl->sess->server;
+	char *cm = serv->chanmodes;
+	int bit = 1<<i;
+
+	if (!cm)
+		return;
+
+	while (*cm)
+	{
+		if (*cm == ',')
+			break;
+		if (*cm == modes[i].letter)
+			goto yes;
+		cm++;
+	}
+	return;
+
+yes:
+	banl->capable |= bit;
+	banl->readable |= bit;
+	banl->writeable |= bit;
+}
+
+/* fe_add_ban_list() and fe_ban_list_end() return TRUE if consumed, FALSE otherwise */
+gboolean
+fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rplcode)
+{
+	banlist_info *banl = sess->res->banlist;
+	int i;
 	GtkListStore *store;
 	GtkTreeIter iter;
-	char buf[512];
 
-	store = get_store (sess);
-	gtk_list_store_append (store, &iter);
+	if (!banl)
+		return FALSE;
 
-	if (is_exempt)
+	for (i = 0; i < MODE_CT; i++)
+		if (modes[i].code == rplcode)
+			break;
+	if (i == MODE_CT)
 	{
-		snprintf (buf, sizeof (buf), "(EX) %s", mask);
-		gtk_list_store_set (store, &iter, 0, buf, 1, who, 2, when, -1);
-	} else
+		/* printf ("Unexpected value in fe_add_ban_list:  %d\n", rplcode); */
+		return FALSE;
+	}
+	if (banl->pending & 1<<i)
 	{
-		gtk_list_store_set (store, &iter, 0, mask, 1, who, 2, when, -1);
+		store = get_store (sess);
+		gtk_list_store_append (store, &iter);
+
+		gtk_list_store_set (store, &iter, TYPE_COLUMN, _(modes[i].type), MASK_COLUMN, mask,
+						FROM_COLUMN, who, DATE_COLUMN, when, -1);
+
+		banl->line_ct++;
+		return TRUE;
 	}
+	else return FALSE;
 }
 
-void
-fe_ban_list_end (struct session *sess, int is_exemption)
+/* Sensitize checkboxes and buttons as appropriate for the moment  */
+static void
+banlist_sensitize (banlist_info *banl)
+{
+	int checkable, i;
+
+	/* CHECKBOXES -- */
+	checkable = banl->sess->me->op? banl->writeable: banl->readable;
+	for (i = 0; i < MODE_CT; i++)
+	{
+		if (banl->checkboxes[i] == NULL)
+			continue;
+		if ((checkable & 1<<i) == 0)
+		/* Checkbox is not checkable.  Grey it and uncheck it. */
+		{
+			gtk_widget_set_sensitive (banl->checkboxes[i], FALSE);
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (banl->checkboxes[i]), FALSE);
+		}
+		else
+		/* Checkbox is checkable.  Be sure it's sensitive. */
+		{
+			gtk_widget_set_sensitive (banl->checkboxes[i], TRUE);
+		}
+	}
+
+	/* BUTTONS --- */
+	if (banl->sess->me->op == 0 || banl->line_ct == 0)
+	{
+		/* If user is not op or list is empty, buttons should be all greyed */
+		gtk_widget_set_sensitive (banl->but_clear, FALSE);
+		gtk_widget_set_sensitive (banl->but_crop, FALSE);
+		gtk_widget_set_sensitive (banl->but_remove, FALSE);
+	}
+	else
+	{
+		/* If no lines are selected, only the CLEAR button should be sensitive */
+		if (banl->select_ct == 0)
+		{
+			gtk_widget_set_sensitive (banl->but_clear, TRUE);
+			gtk_widget_set_sensitive (banl->but_crop, FALSE);
+			gtk_widget_set_sensitive (banl->but_remove, FALSE);
+		}
+		/* If any lines are selected, only the REMOVE and CROP buttons should be sensitive */
+		else
+		{
+			gtk_widget_set_sensitive (banl->but_clear, FALSE);
+			gtk_widget_set_sensitive (banl->but_crop, TRUE);
+			gtk_widget_set_sensitive (banl->but_remove, TRUE);
+		}
+	}
+
+	/* Set "Refresh" sensitvity */
+	gtk_widget_set_sensitive (banl->but_refresh, banl->pending? FALSE: banl->checked? TRUE: FALSE);
+}
+/* fe_ban_list_end() returns TRUE if consumed, FALSE otherwise */
+gboolean
+fe_ban_list_end (struct session *sess, int rplcode)
+{
+	banlist_info *banl = sess->res->banlist;
+	int i;
+
+	if (!banl)
+		return FALSE;
+
+	for (i = 0; i < MODE_CT; i++)
+		if (modes[i].endcode == rplcode)
+			break;
+	if (i == MODE_CT)
+	{
+		/* printf ("Unexpected rplcode value in fe_ban_list_end:  %d\n", rplcode); */
+		return FALSE;
+	}
+	if (banl->pending & modes[i].bit)
+	{
+		banl->pending &= ~modes[i].bit;
+		if (!banl->pending)
+		{
+			gtk_widget_set_sensitive (banl->but_refresh, TRUE);
+			banlist_sensitize (banl);
+		}
+		return TRUE;
+	}
+	else return FALSE;
+}
+
+static void
+banlist_select_changed (GtkWidget *item, banlist_info *banl)
 {
-	gtk_widget_set_sensitive (sess->res->banlist_butRefresh, TRUE);
+	GList *list;
+
+	if (banl->line_ct == 0)
+		banl->select_ct = 0;
+	else
+	{
+		list = gtk_tree_selection_get_selected_rows (GTK_TREE_SELECTION (item), NULL);
+		banl->select_ct = list? 1: 0;
+		g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
+		g_list_free (list);
+	}
+	banlist_sensitize (banl);
 }
 
 /**
  *  * Performs the actual refresh operations.
  *  */
 static void
-banlist_do_refresh (struct session *sess)
+banlist_do_refresh (banlist_info *banl)
 {
+	session *sess = banl->sess;
 	char tbuf[256];
+	int i;
+	char *tbufp;
+
+	banlist_sensitize (banl);
+
 	if (sess->server->connected)
 	{
 		GtkListStore *store;
 
-		gtk_widget_set_sensitive (sess->res->banlist_butRefresh, FALSE);
-
-		snprintf (tbuf, sizeof tbuf, DISPLAY_NAME": Ban List (%s, %s)",
+		g_snprintf (tbuf, sizeof tbuf, DISPLAY_NAME": Ban List (%s, %s)",
 						sess->channel, sess->server->servername);
-		mg_set_title (sess->res->banlist_window, tbuf);
+		mg_set_title (banl->window, tbuf);
 
 		store = get_store (sess);
 		gtk_list_store_clear (store);
-
-		handle_command (sess, "ban", FALSE);
-
-		if (supports_exempt (sess->server))
+		banl->line_ct = 0;
+		banl->pending = banl->checked;
+		if (banl->pending)
 		{
-			snprintf (tbuf, sizeof (tbuf), "quote mode %s +e", sess->channel);
+			tbufp = tbuf + g_snprintf (tbuf, sizeof tbuf, "quote mode %s +", sess->channel);
+			for (i = 0; i < MODE_CT; i++)
+				if (banl->pending & 1<<i)
+				{
+					*tbufp++ = modes[i].letter;
+				}
+			*tbufp = 0;
 			handle_command (sess, tbuf, FALSE);
 		}
-
-	} else
+	}
+	else
 	{
 		fe_message (_("Not connected."), FE_MSG_ERROR);
 	}
 }
 
 static void
-banlist_refresh (GtkWidget * wid, struct session *sess)
+banlist_refresh (GtkWidget * wid, banlist_info *banl)
 {
 	/* JG NOTE: Didn't see actual use of wid here, so just forwarding
 	   *          * this to chanlist_do_refresh because I use it without any widget
@@ -159,123 +396,106 @@ banlist_refresh (GtkWidget * wid, struct session *sess)
 	   *          * or apply for the first time if the list has not yet been
 	   *          * received.
 	   *          */
-	banlist_do_refresh (sess);
+	banlist_do_refresh (banl);
 }
 
 static int
-banlist_unban_inner (gpointer none, struct session *sess, int do_exempts)
+banlist_unban_inner (gpointer none, banlist_info *banl, int mode_num)
 {
+	session *sess = banl->sess;
 	GtkTreeModel *model;
 	GtkTreeSelection *sel;
 	GtkTreeIter iter;
 	char tbuf[2048];
-	char **masks, *tmp, *space;
+	char **masks, *mask, *type;
 	int num_sel, i;
 
+
 	/* grab the list of selected items */
 	model = GTK_TREE_MODEL (get_store (sess));
 	sel = gtk_tree_view_get_selection (get_view (sess));
-	num_sel = 0;
-	if (gtk_tree_model_get_iter_first (model, &iter))
-	{
-		do
-		{
-			if (gtk_tree_selection_iter_is_selected (sel, &iter))
-				num_sel++;
-		}
-		while (gtk_tree_model_iter_next (model, &iter));
-	}
 
-	if (num_sel < 1)
+	if (!gtk_tree_model_get_iter_first (model, &iter))
 		return 0;
 
-	/* create an array of all the masks */
-	masks = calloc (1, num_sel * sizeof (char *));
-
-	i = 0;
-	gtk_tree_model_get_iter_first (model, &iter);
+	masks = g_malloc (sizeof (char *) * banl->line_ct);
+	num_sel = 0;
 	do
 	{
 		if (gtk_tree_selection_iter_is_selected (sel, &iter))
 		{
-			gtk_tree_model_get (model, &iter, MASK_COLUMN, &masks[i], -1);
-			space = strchr (masks[i], ' ');
+			/* Get the mask part of this selected line */
+			gtk_tree_model_get (model, &iter, TYPE_COLUMN, &type, MASK_COLUMN, &mask, -1);
 
-			if (do_exempts)
-			{
-				if (space)
-				{
-					/* remove the "(EX) " */
-					tmp = masks[i];
-					masks[i] = g_strdup (space + 1);
-					g_free (tmp);
-					i++;
-				}
-			} else
-			{
-				if (!space)
-					i++;
-			}
+			/* If it's the wrong type of mask, just continue */
+			if (strcmp (_(modes[mode_num].type), type) != 0)
+				continue;
+
+			/* Otherwise add it to our array of mask pointers */
+			masks[num_sel++] = g_strdup (mask);
+			g_free (mask);
+			g_free (type);
 		}
 	}
 	while (gtk_tree_model_iter_next (model, &iter));
 
 	/* and send to server */
-	if (do_exempts)
-		send_channel_modes (sess, tbuf, masks, 0, i, '-', 'e', 0);
-	else
-		send_channel_modes (sess, tbuf, masks, 0, i, '-', 'b', 0);
+	if (num_sel)
+		send_channel_modes (sess, tbuf, masks, 0, num_sel, '-', modes[mode_num].letter, 0);
 
-	/* now free everything, and refresh banlist */	
+	/* now free everything */
 	for (i=0; i < num_sel; i++)
 		g_free (masks[i]);
-	free (masks);
+	g_free (masks);
 
 	return num_sel;
 }
 
 static void
-banlist_unban (GtkWidget * wid, struct session *sess)
+banlist_unban (GtkWidget * wid, banlist_info *banl)
 {
-	int num = 0;
+	int i, num = 0;
 
-	num += banlist_unban_inner (wid, sess, FALSE);
-	num += banlist_unban_inner (wid, sess, TRUE);
+	for (i = 0; i < MODE_CT; i++)
+		num += banlist_unban_inner (wid, banl, i);
 
+	/* This really should not occur with the redesign */
 	if (num < 1)
 	{
 		fe_message (_("You must select some bans."), FE_MSG_ERROR);
 		return;
 	}
 
-	banlist_do_refresh (sess);
+	banlist_do_refresh (banl);
 }
 
 static void
-banlist_clear_cb (GtkDialog *dialog, gint response, gpointer sess)
+banlist_clear_cb (GtkDialog *dialog, gint response, gpointer data)
 {
+	banlist_info *banl = data;
 	GtkTreeSelection *sel;
 
 	gtk_widget_destroy (GTK_WIDGET (dialog));
 
 	if (response == GTK_RESPONSE_OK)
 	{
-		sel = gtk_tree_view_get_selection (get_view (sess));
+		sel = gtk_tree_view_get_selection (get_view (banl->sess));
 		gtk_tree_selection_select_all (sel);
-		banlist_unban (NULL, sess);
+		banlist_unban (NULL, banl);
 	}
 }
 
 static void
-banlist_clear (GtkWidget * wid, struct session *sess)
+banlist_clear (GtkWidget * wid, banlist_info *banl)
 {
 	GtkWidget *dialog;
 
 	dialog = gtk_message_dialog_new (NULL, 0,
 								GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
-					_("Are you sure you want to remove all bans in %s?"), sess->channel);
+					_("Are you sure you want to remove all listed items in %s?"), banl->sess->channel);
+
 	g_signal_connect (G_OBJECT (dialog), "response",
-							G_CALLBACK (banlist_clear_cb), sess);
+							G_CALLBACK (banlist_clear_cb), banl);
 	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
 	gtk_widget_show (dialog);
 }
@@ -298,8 +518,9 @@ banlist_add_selected_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *it
 }
 
 static void
-banlist_crop (GtkWidget * wid, struct session *sess)
+banlist_crop (GtkWidget * wid, banlist_info *banl)
 {
+	session *sess = banl->sess;
 	GtkTreeSelection *select;
 	GSList *list = NULL, *node;
 	int num_sel;
@@ -318,44 +539,147 @@ banlist_crop (GtkWidget * wid, struct session *sess)
 
 		for (node = list; node; node = node->next)
 			gtk_tree_selection_unselect_iter (select, node->data);
-		
+
 		g_slist_foreach (list, (GFunc)g_free, NULL);
 		g_slist_free (list);
 
-		banlist_unban (NULL, sess);
+		banlist_unban (NULL, banl);
 	} else
 		fe_message (_("You must select some bans."), FE_MSG_ERROR);
 }
 
+static void
+banlist_toggle (GtkWidget *item, gpointer data)
+{
+	banlist_info *banl = data;
+	int i, bit = 0;
+
+	for (i = 0; i < MODE_CT; i++)
+		if (banl->checkboxes[i] == item)
+		{
+			bit = 1<<i;
+			break;
+		}
+
+	if (bit)		/* Should be gassert() */
+	{
+		banl->checked &= ~bit;
+		banl->checked |= (GTK_TOGGLE_BUTTON (item)->active)? bit: 0;
+		banlist_do_refresh (banl);
+	}
+}
+
+/* NOTICE:  The official strptime() is not available on all platforms so
+ * I've implemented a special version here.  The official version is
+ * vastly more general than this:  it uses locales for weekday and month
+ * names and its second arg is a format character-string.  This special
+ * version depends on the format returned by ctime(3) whose manpage
+ * says it returns:
+ *     "a null-terminated string of the form "Wed Jun 30 21:49:08 1993\n"
+ *
+ * If the real strpftime() comes available, use this format string:
+ *		#define DATE_FORMAT "%a %b %d %T %Y"
+ */
+static void
+strptime (char *ti, struct tm *tm)
+{
+	/* Expect something like "Sat Mar 16 21:24:27 2013" */
+	static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+								  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
+	int M = -1, d = -1, h = -1, m = -1, s = -1, y = -1;
+
+	if (*ti == 0)
+	{
+		memset (tm, 0, sizeof *tm);
+		return;
+	}
+	/* No need to supply tm->tm_wday; mktime() doesn't read it */
+	ti += 4;
+	while ((mon[++M]))
+		if (strncmp (ti, mon[M], 3) == 0)
+			break;
+	ti += 4;
+
+	d = strtol (ti, &ti, 10);
+	h = strtol (++ti, &ti, 10);
+	m = strtol (++ti, &ti, 10);
+	s = strtol (++ti, &ti, 10);
+	y = strtol (++ti, NULL, 10) - 1900;
+
+	tm->tm_sec = s;
+	tm->tm_min = m;
+	tm->tm_hour = h;
+	tm->tm_mday = d;
+	tm->tm_mon = M;
+	tm->tm_year = y;
+}
+
+gint
+banlist_date_sort (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
+{
+	struct tm tm1, tm2;
+	time_t t1, t2;
+	char *time1, *time2;
+
+	gtk_tree_model_get(model, a, 2, &time1, -1);
+	gtk_tree_model_get(model, b, 2, &time2, -1);
+	strptime (time1, &tm1);
+	strptime (time2, &tm2);
+	t1 = mktime (&tm1);
+	t2 = mktime (&tm2);
+
+	if (t1 < t2) return 1;
+	if (t1 == t2) return 0;
+	return -1;
+}
+
 static GtkWidget *
-banlist_treeview_new (GtkWidget *box)
+banlist_treeview_new (GtkWidget *box, banlist_info *banl)
 {
 	GtkListStore *store;
 	GtkWidget *view;
 	GtkTreeSelection *select;
 	GtkTreeViewColumn *col;
+	GtkTreeSortable *sortable;
 
 	store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
-	                            G_TYPE_STRING);
+	                            G_TYPE_STRING, G_TYPE_STRING);
 	g_return_val_if_fail (store != NULL, NULL);
+
+	sortable = GTK_TREE_SORTABLE (store);
+	gtk_tree_sortable_set_sort_func (sortable, 2, banlist_date_sort, GINT_TO_POINTER (2), NULL);
+
 	view = gtkutil_treeview_new (box, GTK_TREE_MODEL (store), NULL,
+	                             TYPE_COLUMN, _("Type"),
 	                             MASK_COLUMN, _("Mask"),
 	                             FROM_COLUMN, _("From"),
 	                             DATE_COLUMN, _("Date"), -1);
 
 	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), MASK_COLUMN);
 	gtk_tree_view_column_set_alignment (col, 0.5);
-	gtk_tree_view_column_set_min_width (col, 300);
+	gtk_tree_view_column_set_min_width (col, 100);
 	gtk_tree_view_column_set_sort_column_id (col, MASK_COLUMN);
+	gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+	gtk_tree_view_column_set_resizable (col, TRUE);
+
+	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), TYPE_COLUMN);
+	gtk_tree_view_column_set_alignment (col, 0.5);
+	gtk_tree_view_column_set_sort_column_id (col, TYPE_COLUMN);
 
 	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), FROM_COLUMN);
 	gtk_tree_view_column_set_alignment (col, 0.5);
 	gtk_tree_view_column_set_sort_column_id (col, FROM_COLUMN);
+	gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+	gtk_tree_view_column_set_resizable (col, TRUE);
 
 	col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), DATE_COLUMN);
 	gtk_tree_view_column_set_alignment (col, 0.5);
+	gtk_tree_view_column_set_sort_column_id (col, DATE_COLUMN);
+	gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+	gtk_tree_view_column_set_resizable (col, TRUE);
 
 	select = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+	g_signal_connect (G_OBJECT (select), "changed", G_CALLBACK (banlist_select_changed), banl);
 	gtk_tree_selection_set_mode (select, GTK_SELECTION_MULTIPLE);
 
 	gtk_widget_show (view);
@@ -363,56 +687,99 @@ banlist_treeview_new (GtkWidget *box)
 }
 
 static void
-banlist_closegui (GtkWidget *wid, session *sess)
+banlist_closegui (GtkWidget *wid, banlist_info *banl)
 {
-	if (is_session (sess))
-		sess->res->banlist_window = 0;
+	session *sess = banl->sess;
+
+	if (sess->res->banlist == banl)
+	{
+		g_free (banl);
+		sess->res->banlist = NULL;
+	}
 }
 
 void
 banlist_opengui (struct session *sess)
 {
-	GtkWidget *vbox1;
-	GtkWidget *bbox;
+	banlist_info *banl;
+	int i;
+	GtkWidget *table, *vbox, *bbox;
 	char tbuf[256];
 
-	if (sess->res->banlist_window)
+	if (sess->type != SESS_CHANNEL)
 	{
-		mg_bring_tofront (sess->res->banlist_window);
+		fe_message (_("You can only open the Ban List window while in a channel tab."), FE_MSG_ERROR);
 		return;
 	}
 
-	if (sess->type != SESS_CHANNEL)
+	if (!sess->res->banlist)
 	{
-		fe_message (_("You can only open the Ban List window while in a channel tab."), FE_MSG_ERROR);
+		sess->res->banlist = g_malloc0 (sizeof (banlist_info));
+		if (!sess->res->banlist)
+		{
+			fe_message (_("Banlist initialization failed."), FE_MSG_ERROR);
+			return;
+		}
+	}
+	banl = sess->res->banlist;
+	if (banl->window)
+	{
+		mg_bring_tofront (banl->window);
 		return;
 	}
 
-	snprintf (tbuf, sizeof tbuf, _(DISPLAY_NAME": Ban List (%s)"),
+	/* New banlist for this session -- Initialize it */
+	banl->sess = sess;
+	/* For each mode set its bit in capable/readable/writeable */
+	for (i = 0; i < MODE_CT; i++)
+		modes[i].tester (banl, i);
+	/* Force on the checkmark in the "Bans" box */
+	banl->checked = 1<<MODE_BAN;
+
+	g_snprintf (tbuf, sizeof tbuf, _(DISPLAY_NAME": Ban List (%s)"),
 					sess->server->servername);
 
-	sess->res->banlist_window = mg_create_generic_tab ("BanList", tbuf, FALSE,
-					TRUE, banlist_closegui, sess, 550, 200, &vbox1, sess->server);
+	banl->window = mg_create_generic_tab ("BanList", tbuf, FALSE,
+					TRUE, banlist_closegui, banl, 550, 200, &vbox, sess->server);
+	gtkutil_destroy_on_esc (banl->window);
+
+	gtk_container_set_border_width (GTK_CONTAINER (banl->window), 3);
+	gtk_box_set_spacing (GTK_BOX (vbox), 3);
 
 	/* create banlist view */
-	sess->res->banlist_treeview = banlist_treeview_new (vbox1);
+	banl->treeview = banlist_treeview_new (vbox, banl);
+
+	table = gtk_table_new (1, 3, FALSE);
+	gtk_table_set_col_spacings (GTK_TABLE (table), 16);
+	gtk_box_pack_start (GTK_BOX (vbox), table, 0, 0, 0);
+
+	for (i = 0; i < MODE_CT; i++)
+	{
+		if (!(banl->capable & 1<<i))
+			continue;
+		banl->checkboxes[i] = gtk_check_button_new_with_label (_(modes[i].name));
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (banl->checkboxes[i]), (banl->checked & 1<<i? TRUE: FALSE));
+		g_signal_connect (G_OBJECT (banl->checkboxes[i]), "toggled",
+								G_CALLBACK (banlist_toggle), banl);
+		gtk_table_attach (GTK_TABLE (table), banl->checkboxes[i], i+1, i+2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+	}
 
 	bbox = gtk_hbutton_box_new ();
 	gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_SPREAD);
 	gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
-	gtk_box_pack_end (GTK_BOX (vbox1), bbox, 0, 0, 0);
+	gtk_box_pack_end (GTK_BOX (vbox), bbox, 0, 0, 0);
 	gtk_widget_show (bbox);
 
-	gtkutil_button (bbox, GTK_STOCK_REMOVE, 0, banlist_unban, sess,
+	banl->but_remove = gtkutil_button (bbox, GTK_STOCK_REMOVE, 0, banlist_unban, banl,
 	                _("Remove"));
-	gtkutil_button (bbox, GTK_STOCK_REMOVE, 0, banlist_crop, sess,
+	banl->but_crop = gtkutil_button (bbox, GTK_STOCK_REMOVE, 0, banlist_crop, banl,
 	                _("Crop"));
-	gtkutil_button (bbox, GTK_STOCK_CLEAR, 0, banlist_clear, sess,
+	banl->but_clear = gtkutil_button (bbox, GTK_STOCK_CLEAR, 0, banlist_clear, banl,
 	                _("Clear"));
 
-	sess->res->banlist_butRefresh = gtkutil_button (bbox, GTK_STOCK_REFRESH, 0, banlist_refresh, sess, _("Refresh"));
+	banl->but_refresh = gtkutil_button (bbox, GTK_STOCK_REFRESH, 0, banlist_refresh, banl, _("Refresh"));
 
-	banlist_do_refresh (sess);
+	banlist_do_refresh (banl);
 
-	gtk_widget_show (sess->res->banlist_window);
+	gtk_widget_show_all (banl->window);
 }
diff --git a/src/fe-gtk/banlist.h b/src/fe-gtk/banlist.h
index 7ceccd00..0fabc605 100644
--- a/src/fe-gtk/banlist.h
+++ b/src/fe-gtk/banlist.h
@@ -1 +1,60 @@
+#ifndef BANLIST_H
+#define BANLIST_H
+
+#include "../common/hexchat.h"
 void banlist_opengui (session *sess);
+
+#ifndef RPL_BANLIST
+/* Where's that darn header file, that would have all these defines ? */
+#define RPL_BANLIST 367
+#define RPL_ENDOFBANLIST 368
+#define RPL_INVITELIST 346
+#define RPL_ENDOFINVITELIST 347
+#define RPL_EXCEPTLIST 348
+#define RPL_ENDOFEXCEPTLIST 349
+#define RPL_QUIETLIST 728
+#define RPL_ENDOFQUIETLIST 729
+#endif
+
+typedef enum banlist_modes_e {
+	MODE_BAN,
+	MODE_EXEMPT,
+	MODE_INVITE,
+	MODE_QUIET,
+	MODE_CT
+} banlist_modes;
+
+typedef struct banlist_info_s banlist_info;
+
+typedef struct mode_info_s {
+	char *name;		/* Checkbox name, e.g. "Bans" */
+	char *type;		/* Type for type column, e.g. "Ban" */
+	char letter;	/* /mode-command letter, e.g. 'b' for MODE_BAN */
+	int code;		/* rfc RPL_foo code, e.g. 367 for RPL_BANLIST */
+	int endcode;	/* rfc RPL_ENDOFfoo code, e.g. 368 for RPL_ENDOFBANLIST */
+	int bit;			/* Mask bit, e.g., 1<<MODE_BAN  */
+	void (*tester)(banlist_info *, int);	/* Function returns true to set bit into checkable */
+} mode_info;
+
+typedef struct banlist_info_s {
+	session *sess;
+	int capable;	/* MODE bitmask */
+	int readable;	/* subset of capable if not op */
+	int writeable;	/* subset of capable if op */
+	int checked;	/* subset of (op? writeable: readable) */
+	int pending;	/* subset of checked */
+	int current;	/* index of currently processing mode */
+	int line_ct;	/* count of presented lines */
+	int select_ct;	/* count of selected lines */
+		/* Not really; 1 if any are selected otherwise 0 */
+	GtkWidget *window;
+	GtkWidget *treeview;
+	GtkWidget *radios[MODE_CT];
+	GtkWidget *checkboxes[MODE_CT];
+	GtkWidget *but_remove;
+	GtkWidget *but_crop;
+	GtkWidget *but_clear;
+	GtkWidget *but_refresh;
+	GtkWidget *checkbox[MODE_CT];	/* Checkbox widget for mode */
+} banlist_info;
+#endif /* BANLIST_H */
diff --git a/src/fe-gtk/chanview-tree.c b/src/fe-gtk/chanview-tree.c
index 4a4f1db2..2a0bff65 100644
--- a/src/fe-gtk/chanview-tree.c
+++ b/src/fe-gtk/chanview-tree.c
@@ -75,6 +75,8 @@ cv_tree_init (chanview *cv)
 {
 	GtkWidget *view, *win;
 	GtkCellRenderer *renderer;
+	GtkTreeViewColumn *col;
+	int wid1, wid2;
 	static const GtkTargetEntry dnd_src_target[] =
 	{
 		{"HEXCHAT_CHANVIEW", GTK_TARGET_SAME_APP, 75 }
@@ -105,8 +107,17 @@ cv_tree_init (chanview *cv)
 	{
 		gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (view), TRUE);
 	}
+	
+	/* Indented channels with no server looks silly, but we still want expanders */
+	if (!prefs.hex_gui_tab_server)
+	{
+		gtk_widget_style_get (view, "expander-size", &wid1, "horizontal-separator", &wid2, NULL);
+		gtk_tree_view_set_level_indentation (GTK_TREE_VIEW (view), -wid1 - wid2);
+	}
+
 
 	gtk_container_add (GTK_CONTAINER (win), view);
+	col = gtk_tree_view_column_new();
 
 	/* icon column */
 	if (cv->use_icons)
@@ -114,9 +125,9 @@ cv_tree_init (chanview *cv)
 		renderer = gtk_cell_renderer_pixbuf_new ();
 		if (prefs.hex_gui_compact)
 			g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
-		gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
-																	-1, NULL, renderer,
-																	"pixbuf", COL_PIXBUF, NULL);
+
+		gtk_tree_view_column_pack_start(col, renderer, FALSE);
+		gtk_tree_view_column_set_attributes (col, renderer, "pixbuf", COL_PIXBUF, NULL);
 	}
 
 	/* main column */
@@ -124,9 +135,9 @@ cv_tree_init (chanview *cv)
 	if (prefs.hex_gui_compact)
 		g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
 	gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
-	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
-																-1, NULL, renderer,
-									"text", COL_NAME, "attributes", COL_ATTR, NULL);
+	gtk_tree_view_column_pack_start(col, renderer, TRUE);
+	gtk_tree_view_column_set_attributes (col, renderer, "text", COL_NAME, "attributes", COL_ATTR, NULL);
+	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);									
 
 	g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (view))),
 							"changed", G_CALLBACK (cv_tree_sel_cb), cv);
diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c
index 6cfcd8b7..ffb95218 100644
--- a/src/fe-gtk/dccgui.c
+++ b/src/fe-gtk/dccgui.c
@@ -745,6 +745,7 @@ fe_dcc_open_recv_win (int passive)
 	dccfwin.window = mg_create_generic_tab ("Transfers", _(DISPLAY_NAME": Uploads and Downloads"),
 														 FALSE, TRUE, close_dcc_file_window, NULL,
 														 win_width, win_height, &vbox, 0);
+	gtkutil_destroy_on_esc (dccfwin.window);
 	gtk_container_set_border_width (GTK_CONTAINER (dccfwin.window), 3);
 	gtk_box_set_spacing (GTK_BOX (vbox), 3);
 
@@ -989,6 +990,7 @@ fe_dcc_open_chat_win (int passive)
 	dcccwin.window =
 			  mg_create_generic_tab ("DCCChat", _(DISPLAY_NAME": DCC Chat List"),
 						FALSE, TRUE, dcc_chat_close_cb, NULL, 550, 180, &vbox, 0);
+	gtkutil_destroy_on_esc (dcccwin.window);
 	gtk_container_set_border_width (GTK_CONTAINER (dcccwin.window), 3);
 	gtk_box_set_spacing (GTK_BOX (vbox), 3);
 
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c
index a29a6fda..7ed55cbd 100644
--- a/src/fe-gtk/fe-gtk.c
+++ b/src/fe-gtk/fe-gtk.c
@@ -604,14 +604,6 @@ fe_is_chanwindow (struct server *serv)
 	return 1;
 }
 
-int
-fe_is_banwindow (struct session *sess)
-{
-   if (!sess->res->banlist_window)
-     return 0;
-   return 1;
-}
-
 void
 fe_notify_update (char *name)
 {
diff --git a/src/fe-gtk/fe-gtk.h b/src/fe-gtk/fe-gtk.h
index 313afc4b..d15980c6 100644
--- a/src/fe-gtk/fe-gtk.h
+++ b/src/fe-gtk/fe-gtk.h
@@ -29,6 +29,7 @@
 #include <gtk/gtkwidget.h>
 #include <gtk/gtkcontainer.h>
 #include <gtk/gtksignal.h>
+#include "banlist.h"
 
 #undef gtk_signal_connect
 #define gtk_signal_connect g_signal_connect
@@ -97,10 +98,7 @@ struct server_gui
 
 typedef struct restore_gui
 {
-	/* banlist stuff */
-	GtkWidget *banlist_window;
-	GtkWidget *banlist_treeview;
-	GtkWidget *banlist_butRefresh;
+	banlist_info *banlist;
 
 	void *tab;			/* (chan *) */
 
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c
index d032cf48..3743b5e3 100644
--- a/src/fe-gtk/gtkutil.c
+++ b/src/fe-gtk/gtkutil.c
@@ -45,6 +45,7 @@
 #include <gtk/gtkcellrenderertoggle.h>
 #include <gtk/gtkversion.h>
 #include <gtk/gtkfilechooserdialog.h>
+#include <gdk/gdkkeysyms.h>
 
 #include "../common/hexchat.h"
 #include "../common/fe.h"
@@ -338,6 +339,20 @@ gtkutil_file_req (const char *title, void *callback, void *userdata, char *filte
 	gtk_widget_show (dialog);
 }
 
+static gboolean
+gtkutil_esc_destroy (GtkWidget * win, GdkEventKey * key, gpointer userdata)
+{
+	if (key->keyval == GDK_Escape)
+		gtk_widget_destroy (win);
+	return FALSE;
+}
+
+void
+gtkutil_destroy_on_esc (GtkWidget *win)
+{
+	g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (gtkutil_esc_destroy), win);
+}
+
 void
 gtkutil_destroy (GtkWidget * igad, GtkWidget * dgad)
 {
diff --git a/src/fe-gtk/gtkutil.h b/src/fe-gtk/gtkutil.h
index 65b5c079..ad0c36ba 100644
--- a/src/fe-gtk/gtkutil.h
+++ b/src/fe-gtk/gtkutil.h
@@ -12,6 +12,7 @@ typedef void (*filereqcallback) (void *, char *file);
 
 void gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions, int flags);
 void gtkutil_destroy (GtkWidget * igad, GtkWidget * dgad);
+void gtkutil_destroy_on_esc (GtkWidget *win);
 GtkWidget *gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
 				 void *userdata, char *labeltext);
 void gtkutil_label_new (char *text, GtkWidget * box);
diff --git a/src/fe-gtk/ignoregui.c b/src/fe-gtk/ignoregui.c
index dca4384b..34a06837 100644
--- a/src/fe-gtk/ignoregui.c
+++ b/src/fe-gtk/ignoregui.c
@@ -273,13 +273,15 @@ ignore_store_new (int cancel, char *mask, gpointer data)
 }
 
 static void
-ignore_clear_entry_clicked (GtkWidget * wid, gpointer unused)
+ignore_clear_cb (GtkDialog *dialog, gint response)
 {
 	GtkListStore *store = GTK_LIST_STORE (get_store ());
 	GtkTreeIter iter;
 	char *mask;
 
-	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
+	gtk_widget_destroy (GTK_WIDGET (dialog));
+
+	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter) && response == GTK_RESPONSE_OK)
 	{
 		/* remove from ignore_list */
 		do
@@ -297,6 +299,20 @@ ignore_clear_entry_clicked (GtkWidget * wid, gpointer unused)
 }
 
 static void
+ignore_clear_entry_clicked (GtkWidget * wid)
+{
+	GtkWidget *dialog;
+
+	dialog = gtk_message_dialog_new (NULL, 0,
+								GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
+					_("Are you sure you want to remove all ignores?"));
+	g_signal_connect (G_OBJECT (dialog), "response",
+							G_CALLBACK (ignore_clear_cb), NULL);
+	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+	gtk_widget_show (dialog);
+}
+
+static void
 ignore_new_entry_clicked (GtkWidget * wid, struct session *sess)
 {
 	fe_get_str (_("Enter mask to ignore:"), "nick!userid@host.com",
@@ -349,6 +365,7 @@ ignore_gui_open ()
 			  mg_create_generic_tab ("IgnoreList", _(DISPLAY_NAME": Ignore list"),
 											FALSE, TRUE, close_ignore_gui_callback,
 											NULL, 600, 256, &vbox, 0);
+	gtkutil_destroy_on_esc (ignorewin);
 
 	view = ignore_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (ignorewin), "view", view);
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c
index 41344c8f..2d02c59d 100644
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -3530,8 +3530,8 @@ fe_server_callback (server *serv)
 void
 fe_session_callback (session *sess)
 {
-	if (sess->res->banlist_window)
-		mg_close_gen (NULL, sess->res->banlist_window);
+	if (sess->res->banlist && sess->res->banlist->window)
+		mg_close_gen (NULL, sess->res->banlist->window);
 
 	if (sess->res->input_text)
 		free (sess->res->input_text);
diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c
index 0559734c..4d144258 100644
--- a/src/fe-gtk/notifygui.c
+++ b/src/fe-gtk/notifygui.c
@@ -413,6 +413,7 @@ notify_opengui (void)
 	notify_window =
 		mg_create_generic_tab ("Notify", _(DISPLAY_NAME": Friends List"), FALSE, TRUE,
 		                       notify_closegui, NULL, 400, 250, &vbox, 0);
+	gtkutil_destroy_on_esc (notify_window);
 
 	view = notify_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (notify_window), "view", view);
diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c
index 293535cc..b2cb95d7 100644
--- a/src/fe-gtk/plugingui.c
+++ b/src/fe-gtk/plugingui.c
@@ -219,6 +219,7 @@ plugingui_open (void)
 	plugin_window = mg_create_generic_tab ("Addons", _(DISPLAY_NAME": Plugins and Scripts"),
 														 FALSE, TRUE, plugingui_close, NULL,
 														 500, 250, &vbox, 0);
+	gtkutil_destroy_on_esc (plugin_window);
 
 	view = plugingui_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (plugin_window), "view", view);
diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c
index 6764034f..651ca1ec 100644
--- a/src/fe-gtk/rawlog.c
+++ b/src/fe-gtk/rawlog.c
@@ -86,7 +86,7 @@ rawlog_savebutton (GtkWidget * wid, server *serv)
 	return FALSE;
 }
 
-static void
+static gboolean
 rawlog_key_cb (GtkWidget * wid, GdkEventKey * key, gpointer userdata)
 {
 	/* Copy rawlog selection to clipboard when Ctrl+Shift+C is pressed,
@@ -99,13 +99,7 @@ rawlog_key_cb (GtkWidget * wid, GdkEventKey * key, gpointer userdata)
 	{
 		gtk_xtext_copy_selection (userdata);
 	}
-	/* close_rawlog is given to mg_create_generic_tab as
-	 * close_callback, it should take care of the rest.
-	 */
-	else if (key->keyval == GDK_Escape)
-	{
-		gtk_widget_destroy (wid);
-	}
+	return FALSE;
 }
 
 void
@@ -124,6 +118,7 @@ open_rawlog (struct server *serv)
 	serv->gui->rawlog_window =
 		mg_create_generic_tab ("RawLog", tbuf, FALSE, TRUE, close_rawlog, serv,
 							 640, 320, &vbox, serv);
+	gtkutil_destroy_on_esc (serv->gui->rawlog_window);
 
 	hbox = gtk_hbox_new (FALSE, 2);
 	gtk_container_add (GTK_CONTAINER (vbox), hbox);
diff --git a/src/fe-gtk/search.c b/src/fe-gtk/search.c
index 41a1a642..f2940e70 100644
--- a/src/fe-gtk/search.c
+++ b/src/fe-gtk/search.c
@@ -32,7 +32,6 @@
 #include <gtk/gtkvseparator.h>
 #include <gtk/gtkradiobutton.h>
 #include <gtk/gtktogglebutton.h>
-#include <gdk/gdkkeysyms.h>
 
 #include "../common/hexchat.h"
 #include "../common/fe.h"
@@ -119,14 +118,6 @@ search_entry_cb (GtkWidget * entry, session * sess)
 	search_search (sess, gtk_entry_get_text (GTK_ENTRY (entry)));
 }
 
-static gboolean 
-search_key_cb (GtkWidget * window, GdkEventKey * key, gpointer userdata)
-{
-	if (key->keyval == GDK_Escape)
-		gtk_widget_destroy (window);
-	return FALSE;
-}
-
 static void
 search_caseign_cb (GtkToggleButton * but, session * sess)
 {
@@ -238,7 +229,7 @@ search_open (session * sess)
 	add_tip (wid, "Close this box, reset highlighted search items, and stop searching new lines.");
 
 	/* Add recognition of the ESC key to close the box */
-	g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (search_key_cb), win);
+	gtkutil_destroy_on_esc (win);
 
 	/* That's all, folks */
 	searchwin = win;
diff --git a/src/fe-gtk/servlistgui.c b/src/fe-gtk/servlistgui.c
index 4aeaf00f..813a85d5 100644
--- a/src/fe-gtk/servlistgui.c
+++ b/src/fe-gtk/servlistgui.c
@@ -93,7 +93,6 @@ static GtkWidget *servlist_open_edit (GtkWidget *parent, ircnet *net);
 
 static const char *pages[]=
 {
-	"UTF-8 (Unicode)",
 	IRC_DEFAULT_CHARSET,
 	"ISO-8859-15 (Western Europe)",
 	"ISO-8859-2 (Central Europe)",
diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c
index 71162792..d7561520 100644
--- a/src/fe-gtk/setup.c
+++ b/src/fe-gtk/setup.c
@@ -322,6 +322,14 @@ static const char *const focusnewtabsmenu[] =
 	NULL
 };
 
+static const char *const noticeposmenu[] =
+{
+	N_("Automatic"),
+	N_("In an extra tab"),
+	N_("In the front tab"),
+	NULL
+};
+
 static const char *const swtype[] =
 {
 	N_("Tabs"),	/* 0 tabs */
@@ -335,13 +343,13 @@ static const setting tabs_settings[] =
 	/*{ST_HEADER,	N_("Channel Switcher"),0,0,0},*/
 	{ST_RADIO,  N_("Switcher type:"),P_OFFINTNL(hex_gui_tab_layout), 0, swtype, 0},
 	{ST_TOGGLE, N_("Open an extra tab for server messages"), P_OFFINTNL(hex_gui_tab_server), 0, 0, 0},
-	{ST_TOGGLE, N_("Open an extra tab for server notices"), P_OFFINTNL(hex_gui_tab_notices), 0, 0, 0},
 	{ST_TOGGLE, N_("Open a new tab when you receive a private message"), P_OFFINTNL(hex_gui_autoopen_dialog), 0, 0, 0},
 	{ST_TOGGLE, N_("Sort tabs in alphabetical order"), P_OFFINTNL(hex_gui_tab_sort), 0, 0, 0},
 	{ST_TOGGLE, N_("Show icons in the channel tree"), P_OFFINTNL(hex_gui_tab_icons), 0, 0, 0},
 	{ST_TOGGLE, N_("Show dotted lines in the channel tree"), P_OFFINTNL(hex_gui_tab_dots), 0, 0, 0},
 	{ST_TOGGLE, N_("Smaller text"), P_OFFINTNL(hex_gui_tab_small), 0, 0, 0},
 	{ST_MENU,	N_("Focus new tabs:"), P_OFFINTNL(hex_gui_tab_newtofront), 0, focusnewtabsmenu, 0},
+	{ST_MENU,	N_("Placement of notices:"), P_OFFINTNL(hex_irc_notice_pos), 0, noticeposmenu, 0},
 	{ST_MENU,	N_("Show channel switcher at:"), P_OFFINTNL(hex_gui_tab_pos), 0, cspos, 1},
 	{ST_NUMBER,	N_("Shorten tab labels to:"), P_OFFINTNL(hex_gui_tab_trunc), 0, (const char **)N_("letters."), 99},
 
@@ -494,6 +502,7 @@ static const setting general_settings[] =
 static const setting advanced_settings[] =
 {
 	{ST_HEADER,	N_("Advanced Settings"),0,0,0},
+	{ST_ENTRY,  N_("Real name:"), P_OFFSETNL(hex_irc_real_name), 0, 0, sizeof prefs.hex_irc_real_name},
 #ifdef WIN32
 	{ST_ENTRY,  N_("Alternative fonts:"), P_OFFSETNL(hex_text_font_alternative), "Separate multiple entries with commas without spaces before or after.", 0, sizeof prefs.hex_text_font_alternative},
 #endif
@@ -2221,7 +2230,7 @@ setup_apply (struct hexchatprefs *pr)
 	if (DIFF (hex_gui_compact))
 		noapply = TRUE;
 	if (DIFF (hex_gui_input_icon))
-		noapply = TRUE;	
+		noapply = TRUE;
 	if (DIFF (hex_gui_input_nick))
 		noapply = TRUE;
 	if (DIFF (hex_gui_lagometer))
diff --git a/src/fe-gtk/urlgrab.c b/src/fe-gtk/urlgrab.c
index b8a40a35..0e27efdc 100644
--- a/src/fe-gtk/urlgrab.c
+++ b/src/fe-gtk/urlgrab.c
@@ -198,6 +198,7 @@ url_opengui ()
 	urlgrabberwindow =
 		mg_create_generic_tab ("UrlGrabber", _(DISPLAY_NAME": URL Grabber"), FALSE,
 							 TRUE, url_closegui, NULL, 400, 256, &vbox, 0);
+	gtkutil_destroy_on_esc (urlgrabberwindow);
 	view = url_treeview_new (vbox);
 	g_object_set_data (G_OBJECT (urlgrabberwindow), "model",
 	                   gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c
index 6005e265..5b85022e 100644
--- a/src/fe-gtk/xtext.c
+++ b/src/fe-gtk/xtext.c
@@ -90,15 +90,8 @@
 #endif
 
 /* is delimiter */
-#if 0
-/* () is used by Wikipedia */
-#define is_del(c) \
-	(c == ' ' || c == '\n' || c == ')' || c == '(' || \
-	 c == '>' || c == '<' || c == ATTR_RESET || c == ATTR_BOLD || c == 0)
-#endif
 #define is_del(c) \
-	(c == ' ' || c == '\n' || c == '>' || c == '<' || \
-	 c == ATTR_RESET || c == ATTR_BOLD || c == 0)
+	(c == ' ' || c == '\n' || c == '>' || c == '<' || c == 0)
 
 #ifdef SCROLL_HACK
 /* force scrolling off */
diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c
index 90f86627..74496cff 100644
--- a/src/fe-text/fe-text.c
+++ b/src/fe-text/fe-text.c
@@ -33,6 +33,7 @@
 #include <sys/types.h>
 #include <ctype.h>
 #include <glib.h>
+#include <glib-object.h>
 #include "../common/hexchat.h"
 #include "../common/hexchatc.h"
 #include "../common/cfgfiles.h"
@@ -61,7 +62,7 @@ handle_line (GIOChannel *channel, GIOCondition cond, gpointer data)
 	GIOStatus result;
 
 	result = g_io_channel_read_line(channel, &str_return, &length, &terminator_pos, &error);
-	if (result == G_IO_STATUS_ERROR) {
+	if (result == G_IO_STATUS_ERROR || result == G_IO_STATUS_EOF) {
 		return FALSE;
 	}
 	else {
@@ -429,7 +430,14 @@ fe_input_add (int sok, int flags, void *func, void *data)
 	int tag, type = 0;
 	GIOChannel *channel;
 
+#ifdef G_OS_WIN32
+	if (flags & FIA_FD)
+		channel = g_io_channel_win32_new_fd (sok);
+	else
+		channel = g_io_channel_win32_new_socket (sok);
+#else
 	channel = g_io_channel_unix_new (sok);
+#endif
 
 	if (flags & FIA_READ)
 		type |= G_IO_IN | G_IO_HUP | G_IO_ERR;
@@ -478,6 +486,8 @@ fe_args (int argc, char *argv[])
 	context = g_option_context_new (NULL);
 	g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE);
 	g_option_context_parse (context, &argc, &argv, &error);
+	
+	g_type_init ();
 
 	if (error)
 	{
@@ -641,17 +651,12 @@ void
 fe_chan_list_end (struct server *serv)
 {
 }
-int
-fe_is_banwindow (struct session *sess)
+gboolean
+fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rplcode)
 {
-	return 0;
 }
-void
-fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int is_exemption)
-{
-}
-void
-fe_ban_list_end (struct session *sess, int is_exemption)
+gboolean
+fe_ban_list_end (struct session *sess, int rplcode)
 {
 }
 void
diff --git a/src/htm/Main.cs b/src/htm/Main.cs
index cc33e206..e3ae04cf 100644
--- a/src/htm/Main.cs
+++ b/src/htm/Main.cs
@@ -281,7 +281,7 @@ namespace thememan
 

             try

             {

-                using (Package zip = Package.Open(zipFile.FullName, FileMode.Open))

+                using (Package zip = Package.Open(zipFile.FullName, FileMode.Open, FileAccess.Read))

                 {

                     PackagePartCollection parts = zip.GetParts();