changeset 29825:885ceb384678

propagate from branch 'im.pidgin.pidgin' (head f23de15cf5cab74ad9b1c2ce72676be0e80e7f23) to branch 'im.pidgin.cpw.malu.ft_thumbnails' (head f7a917c6041411a0428726f88f9200290adde6de)
author Marcus Lundblad <ml@update.uu.se>
date Sun, 21 Mar 2010 19:44:45 +0000
parents fce17268c9ec (diff) 6671b5e92c28 (current diff)
children d6af24bcf107
files libpurple/protocols/jabber/data.c libpurple/protocols/jabber/data.h libpurple/protocols/jabber/message.c libpurple/protocols/jabber/namespaces.h libpurple/protocols/jabber/si.c
diffstat 31 files changed, 622 insertions(+), 619 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 18 22:12:08 2010 +0000
+++ b/ChangeLog	Sun Mar 21 19:44:45 2010 +0000
@@ -22,6 +22,7 @@
 	  in the distant past.  (Greg McNew)
 	* Added a menu set mood globally for all mood-supporting accounts
 	  (currently XMPP and ICQ).
+	* Use standard (but small) GTK+ buttons instead of custom "X" symbol.
 
 	Bonjour:
 	* Added support for IPv6. (Thanks to T_X for testing)
@@ -47,6 +48,8 @@
 	* Direct messages to a specific resource only upon receipt of a message
 	  with content (as opposed to a typing notification, etc).  (Thanks to
 	  rjoly for testing)
+	* When sending data using in-band-bytestreams, interpret the block-size
+	  attribute as the size of the BASE64-encoded representation of the data.
 
 	Yahoo:
 	* Attempt to better handle transparent proxies interfering with HTTP-based
--- a/ChangeLog.win32	Thu Mar 18 22:12:08 2010 +0000
+++ b/ChangeLog.win32	Sun Mar 21 19:44:45 2010 +0000
@@ -1,14 +1,15 @@
 version 2.7.0 (??/??/????):
 	* Updated GTK+ to 2.16.6
 	* Private GTK+ Runtime now used (GTK+ Installer no longer supported)
-	* Minimum required GTK+ version increased to 2.14.0
+	* Minimum required GTK+ version increased to 2.14.7
 	* Win9x no longer supported.
 	* Crash Report files (pidgin.RPT) are now generated in the ~/.purple
 	  directory instead of the installation directory.
 	* NSS SSL Library upgraded to 3.12.5 (thanks to Berke Viktor)
 	* GtkSpell upgraded to 2.0.16, changing the spellchecking backend to
-	  enchant.  This means that myspell, hunspell (OpenOffice) and existing
-	  aspell dictionaries can be used.
+	  enchant.  This means that myspell and hunspell (OpenOffice)
+	  dictionaries can be used (previous versions' aspell dictionaries
+	  will not work).
 
 version 2.6.6 (02/18/2010):
 	* Installer translations for: Norwegian nynorsk
--- a/Makefile.mingw	Thu Mar 18 22:12:08 2010 +0000
+++ b/Makefile.mingw	Sun Mar 21 19:44:45 2010 +0000
@@ -47,13 +47,15 @@
 	k5sprt32.dll \
 	krb5_32.dll \
 	libenchant.dll \
+	libenchant_ispell.dll \
+	libenchant_myspell.dll \
 	libgtkspell-0.dll \
 	libmeanwhile-1.dll \
 	libnspr4.dll \
 	libplc4.dll \
 	libplds4.dll \
 	libsasl.dll \
-	libxml2.dll \
+	libxml2-2.dll \
 	nss3.dll \
 	nssckbi.dll \
 	nssutil3.dll \
@@ -94,7 +96,7 @@
 	cp $(GTKSPELL_TOP)/bin/libgtkspell-0.dll $(PIDGIN_INSTALL_DIR)/spellcheck
 	cp $(ENCHANT_TOP)/bin/libenchant.dll $(PIDGIN_INSTALL_DIR)/spellcheck
 	cp -R $(ENCHANT_TOP)/lib $(PIDGIN_INSTALL_DIR)/spellcheck
-	cp $(WIN32_DEV_TOP)/pidgin-inst-deps-20100223/exchndl.dll $(PIDGIN_INSTALL_DIR)
+	cp $(WIN32_DEV_TOP)/pidgin-inst-deps-20100315/exchndl.dll $(PIDGIN_INSTALL_DIR)
 
 pidgin/win32/nsis/gtk-runtime-$(GTK_BUNDLE_VERSION).zip:
 	pidgin/win32/nsis/generate_gtk_zip.sh `pwd`
@@ -150,7 +152,7 @@
 installers: installer installer_offline debug_symbols_zip installer_zip
 
 Doxyfile.mingw: Doxyfile.in
-	sed -e "s/@PACKAGE@/pidgin/" -e "s/@VERSION@/$(PIDGIN_VERSION)/" -e "s/@top_srcdir@/$(PIDGIN_TREE_TOP)/g" -e "s/@enable_dot@/NO/" Doxyfile.in > Doxyfile.mingw
+	sed -e "s/@PACKAGE@/pidgin/" -e "s/@VERSION@/$(PIDGIN_VERSION)/" -e "s/@top_srcdir@/$(PIDGIN_TREE_TOP)/g" -e "s/@enable_dot@/NO/" $< > $@
 
 docs: Doxyfile.mingw
 	@echo "Running doxygen..."
--- a/libpurple/protocols/jabber/caps.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/caps.c	Sun Mar 21 19:44:45 2010 +0000
@@ -845,19 +845,18 @@
 	return fields;
 }
 
-static GString*
-jabber_caps_verification_append(GString *verification, const gchar *str)
+static void 
+append_escaped_string(PurpleCipherContext *context, const gchar *str)
 {
 	char *tmp = g_markup_escape_text(str, -1);
-	verification = g_string_append(verification, tmp);
+	purple_cipher_context_append(context, (const guchar *)tmp, strlen(tmp));
 	g_free(tmp);
-	return g_string_append_c(verification, '<');
+	purple_cipher_context_append(context, (const guchar *)"<", 1);
 }
 
 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash)
 {
 	GList *node;
-	GString *verification;
 	PurpleCipherContext *context;
 	guint8 checksum[20];
 	gsize checksum_size = 20;
@@ -871,24 +870,26 @@
 	info->features = g_list_sort(info->features, (GCompareFunc)strcmp);
 	info->forms = g_list_sort(info->forms, jabber_xdata_compare);
 
-	verification = g_string_new("");
-
-	/* concat identities to the verification string */
+	/* Add identities to the hash data */
 	for (node = info->identities; node; node = node->next) {
 		JabberIdentity *id = (JabberIdentity*)node->data;
 		char *category = g_markup_escape_text(id->category, -1);
 		char *type = g_markup_escape_text(id->type, -1);
 		char *lang = NULL;
 		char *name = NULL;
+		char *tmp;
 
 		if (id->lang)
 			lang = g_markup_escape_text(id->lang, -1);
 		if (id->name)
 			name = g_markup_escape_text(id->name, -1);
 
-		g_string_append_printf(verification, "%s/%s/%s/%s<", category,
-		        type, lang ? lang : "", name ? name : "");
+		tmp = g_strconcat(category, "/", type, "/", lang ? lang : "",
+		                  "/", name ? name : "", "<", NULL);
 
+		purple_cipher_context_append(context, (const guchar *)tmp, strlen(tmp));
+
+		g_free(tmp);
 		g_free(category);
 		g_free(type);
 		g_free(lang);
@@ -897,7 +898,7 @@
 
 	/* concat features to the verification string */
 	for (node = info->features; node; node = node->next) {
-		verification = jabber_caps_verification_append(verification, node->data);
+		append_escaped_string(context, node->data);
 	}
 
 	/* concat x-data forms to the verification string */
@@ -907,19 +908,19 @@
 		GList *fields = jabber_caps_xdata_get_fields(data);
 
 		/* append FORM_TYPE's field value to the verification string */
-		verification = jabber_caps_verification_append(verification, formtype);
+		append_escaped_string(context, formtype);
 		g_free(formtype);
 
 		while (fields) {
 			GList *value;
 			JabberDataFormField *field = (JabberDataFormField*)fields->data;
 
-			if (strcmp(field->var, "FORM_TYPE")) {
+			if (!g_str_equal(field->var, "FORM_TYPE")) {
 				/* Append the "var" attribute */
-				verification = jabber_caps_verification_append(verification, field->var);
+				append_escaped_string(context, field->var);
 				/* Append <value/> elements' cdata */
-				for(value = field->values; value; value = value->next) {
-					verification = jabber_caps_verification_append(verification, value->data);
+				for (value = field->values; value; value = value->next) {
+					append_escaped_string(context, value->data);
 					g_free(value->data);
 				}
 			}
@@ -932,12 +933,9 @@
 	}
 
 	/* generate hash */
-	purple_cipher_context_append(context, (guchar*)verification->str, verification->len);
-
-	success = purple_cipher_context_digest(context, verification->len,
+	success = purple_cipher_context_digest(context, checksum_size,
 	                                       checksum, &checksum_size);
 
-	g_string_free(verification, TRUE);
 	purple_cipher_context_destroy(context);
 
 	return (success ? purple_base64_encode(checksum, checksum_size) : NULL);
--- a/libpurple/protocols/jabber/data.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/data.c	Sun Mar 21 19:44:45 2010 +0000
@@ -172,7 +172,7 @@
 	return img;
 }
 
-xmlnode *
+static xmlnode *
 jabber_data_get_xml_request(const gchar *cid)
 {
 	xmlnode *tag = xmlnode_new("data");
@@ -183,6 +183,70 @@
 	return tag;
 }
 
+
+typedef struct {
+	gpointer userdata;
+	gchar *alt;
+	gboolean ephemeral;
+	JabberDataRequestCallback *cb;
+} JabberDataRequestData;
+
+static void
+jabber_data_request_cb(JabberStream *js, const char *from,
+	JabberIqType type, const char *id, xmlnode *packet, gpointer data)
+{
+	JabberDataRequestData *request_data = (JabberDataRequestData *) data;
+	gpointer userdata = request_data->userdata;
+	gchar *alt = request_data->alt;
+	gboolean ephemeral = request_data->ephemeral;
+	JabberDataRequestCallback *cb = request_data->cb;
+	
+	xmlnode *data_element = xmlnode_get_child(packet, "data");
+	xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found");
+
+	/* did we get a data element as result? */
+	if (data_element && type == JABBER_IQ_RESULT) {
+		JabberData *data = jabber_data_create_from_xml(data_element);
+
+		if (data) {
+			if (ephemeral) {
+				jabber_data_associate_remote(data);
+			}
+			/* TODO: validate hash */
+			cb(data, alt, userdata);
+		}
+	} else if (item_not_found) {
+		purple_debug_info("jabber",
+			"Responder didn't recognize requested data\n");
+		cb(NULL, alt, userdata);
+	} else {
+		purple_debug_error("jabber", "Unknown response to data request\n");
+		cb(NULL, alt, userdata);
+	}
+
+	g_free(request_data);
+}
+
+void
+jabber_data_request(JabberStream *js, const gchar *cid, const gchar *who, 
+    gchar *alt, gboolean ephemeral, JabberDataRequestCallback cb,
+    gpointer userdata)
+{
+	JabberIq *request = jabber_iq_new(js, JABBER_IQ_GET);
+	xmlnode *data_request = jabber_data_get_xml_request(cid);
+	JabberDataRequestData *data = g_new0(JabberDataRequestData, 1);
+
+	data->userdata = userdata;
+	data->alt = alt;
+	data->ephemeral = ephemeral;
+	data->cb = cb;
+	
+	xmlnode_set_attrib(request->node, "to", who);
+	jabber_iq_set_callback(request, jabber_data_request_cb, data);
+	xmlnode_insert_child(request->node, data_request);
+	jabber_iq_send(request);
+}
+
 const JabberData *
 jabber_data_find_local_by_alt(const gchar *alt)
 {
--- a/libpurple/protocols/jabber/data.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/data.h	Sun Mar 21 19:44:45 2010 +0000
@@ -28,6 +28,7 @@
 
 #define JABBER_DATA_MAX_SIZE 8192
 
+
 typedef struct {
 	char *cid;
 	char *type;
@@ -36,6 +37,10 @@
 	gboolean ephemeral;
 } JabberData;
 
+typedef void (JabberDataRequestCallback)(JabberData *data, gchar *alt,
+    gpointer userdata);
+
+
 /* creates a JabberData instance from raw data */
 JabberData *jabber_data_create_from_data(gconstpointer data, gsize size,
 	const char *type, gboolean ephemeral, JabberStream *js);
@@ -60,9 +65,9 @@
 /* returns an XHTML-IM "img" tag given a data instance */
 xmlnode *jabber_data_get_xhtml_im(const JabberData *data, const gchar *alt);
 
-/* returns a data request element (to be included in an iq stanza) for requesting
-  data */
-xmlnode *jabber_data_get_xml_request(const gchar *cid);
+void jabber_data_request(JabberStream *js, const gchar *cid, const gchar *who, 
+    gchar *alt, gboolean ephemeral, JabberDataRequestCallback cb,
+    gpointer userdata);
 
 /* lookup functions */
 const JabberData *jabber_data_find_local_by_alt(const gchar *alt);
--- a/libpurple/protocols/jabber/ibb.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/ibb.c	Sun Mar 21 19:44:45 2010 +0000
@@ -157,6 +157,12 @@
 	}
 }
 
+gsize
+jabber_ibb_session_get_max_data_size(const JabberIBBSession *sess)
+{
+	return (gsize) floor((sess->block_size - 2) * (float) 3 / 4);
+}
+
 gpointer
 jabber_ibb_session_get_user_data(JabberIBBSession *sess)
 {
@@ -321,7 +327,7 @@
 	if (state != JABBER_IBB_SESSION_OPENED) {
 		purple_debug_error("jabber",
 			"trying to send data on a non-open IBB session\n");
-	} else if (size > jabber_ibb_session_get_block_size(sess)) {
+	} else if (size > jabber_ibb_session_get_max_data_size(sess)) {
 		purple_debug_error("jabber",
 			"trying to send a too large packet in the IBB session\n");
 	} else {
@@ -416,6 +422,10 @@
 						purple_debug_info("jabber",
 							"got %" G_GSIZE_FORMAT " bytes of data on IBB stream\n",
 							size);
+						/* we accept other clients to send up to block-size
+						 of _unencoded_ data, since there's been some confusions
+						 regarding the interpretation of this attribute
+						 (including previous versions of libpurple) */
 						if (size > jabber_ibb_session_get_block_size(sess)) {
 							purple_debug_error("jabber",
 								"IBB: received a too large packet\n");
--- a/libpurple/protocols/jabber/ibb.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/ibb.h	Sun Mar 21 19:44:45 2010 +0000
@@ -107,6 +107,10 @@
 gsize jabber_ibb_session_get_block_size(const JabberIBBSession *sess);
 void jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size);
 
+/* get maximum size data block to send (in bytes) 
+ (before encoded to BASE64) */ 
+gsize jabber_ibb_session_get_max_data_size(const JabberIBBSession *sess);
+
 gpointer jabber_ibb_session_get_user_data(JabberIBBSession *sess);
 
 /* handle incoming packet */
--- a/libpurple/protocols/jabber/jabber.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sun Mar 21 19:44:45 2010 +0000
@@ -86,6 +86,11 @@
 {
 	char *open_stream;
 
+	if (js->stream_id) {
+		g_free(js->stream_id);
+		js->stream_id = NULL;
+	}
+
 	open_stream = g_strdup_printf("<stream:stream to='%s' "
 				          "xmlns='" NS_XMPP_CLIENT "' "
 						  "xmlns:stream='" NS_XMPP_STREAMS "' "
@@ -261,6 +266,7 @@
 
 void jabber_process_packet(JabberStream *js, xmlnode **packet)
 {
+	const char *name;
 	const char *xmlns;
 
 	purple_signal_emit(purple_connection_get_prpl(js->gc), "jabber-receiving-xmlnode", js->gc, packet);
@@ -269,6 +275,7 @@
 	if(NULL == *packet)
 		return;
 
+	name = (*packet)->name;
 	xmlns = xmlnode_get_namespace(*packet);
 
 	if(!strcmp((*packet)->name, "iq")) {
@@ -277,30 +284,30 @@
 		jabber_presence_parse(js, *packet);
 	} else if(!strcmp((*packet)->name, "message")) {
 		jabber_message_parse(js, *packet);
-	} else if(!strcmp((*packet)->name, "stream:features")) {
-		jabber_stream_features_parse(js, *packet);
-	} else if (!strcmp((*packet)->name, "features") && xmlns &&
-		   !strcmp(xmlns, NS_XMPP_STREAMS)) {
-		jabber_stream_features_parse(js, *packet);
-	} else if(!strcmp((*packet)->name, "stream:error") ||
-			 (!strcmp((*packet)->name, "error") && xmlns &&
-				!strcmp(xmlns, NS_XMPP_STREAMS)))
-	{
-		jabber_stream_handle_error(js, *packet);
-	} else if(!strcmp((*packet)->name, "challenge")) {
-		if(js->state == JABBER_STREAM_AUTHENTICATING)
-			jabber_auth_handle_challenge(js, *packet);
-	} else if(!strcmp((*packet)->name, "success")) {
-		if(js->state == JABBER_STREAM_AUTHENTICATING)
-			jabber_auth_handle_success(js, *packet);
-	} else if(!strcmp((*packet)->name, "failure")) {
-		if(js->state == JABBER_STREAM_AUTHENTICATING)
-			jabber_auth_handle_failure(js, *packet);
-	} else if(!strcmp((*packet)->name, "proceed")) {
-		if (js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION && !js->gsc)
-			tls_init(js);
-		else
-			purple_debug_warning("jabber", "Ignoring spurious <proceed/>\n");
+	} else if (purple_strequal(xmlns, NS_XMPP_STREAMS)) {
+		if (g_str_equal(name, "features"))
+			jabber_stream_features_parse(js, *packet);
+		else if (g_str_equal(name, "error"))
+			jabber_stream_handle_error(js, *packet);
+	} else if (purple_strequal(xmlns, NS_XMPP_SASL)) {
+		if (js->state != JABBER_STREAM_AUTHENTICATING)
+			purple_debug_warning("jabber", "Ignoring spurious SASL stanza %s\n", name);
+		else {
+			if (g_str_equal(name, "challenge"))
+				jabber_auth_handle_challenge(js, *packet);
+			else if (g_str_equal(name, "success"))
+				jabber_auth_handle_success(js, *packet);
+			else if (g_str_equal(name, "failure"))
+				jabber_auth_handle_failure(js, *packet);
+		}
+	} else if (purple_strequal(xmlns, NS_XMPP_TLS)) {
+		if (js->state != JABBER_STREAM_INITIALIZING_ENCRYPTION || js->gsc)
+			purple_debug_warning("jabber", "Ignoring spurious %s\n", name);
+		else {
+			if (g_str_equal(name, "proceed"))
+				tls_init(js);
+			/* TODO: Handle <failure/>, I guess? */
+		}
 	} else {
 		purple_debug_warning("jabber", "Unknown packet: %s\n", (*packet)->name);
 	}
--- a/libpurple/protocols/jabber/jabber.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Sun Mar 21 19:44:45 2010 +0000
@@ -112,6 +112,13 @@
 
 	JabberSaslMech *auth_mech;
 	gpointer auth_mech_data;
+	
+	/**
+	 * The header from the opening <stream/> tag.  This being NULL is treated
+	 * as a special condition in the parsing code (signifying the next
+	 * stanza started is an opening stream tag), and its being missing on
+	 * the stream header is treated as a fatal error.
+	 */
 	char *stream_id;
 	JabberStreamState state;
 
--- a/libpurple/protocols/jabber/message.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/message.c	Sun Mar 21 19:44:45 2010 +0000
@@ -479,65 +479,22 @@
 	}
 }
 
-/* used in the function below to supply a conversation and shortcut for a
- smiley */
-typedef struct {
-	PurpleConversation *conv;
-	gchar *alt;
-} JabberDataRef;
-
 static void
-jabber_message_get_data_cb(JabberStream *js, const char *from,
-                           JabberIqType type, const char *id,
-                           xmlnode *packet, gpointer data)
+jabber_message_request_data_cb(JabberData *data, gchar *alt,
+    gpointer userdata)
 {
-	JabberDataRef *ref = (JabberDataRef *) data;
-	PurpleConversation *conv = ref->conv;
-	const gchar *alt = ref->alt;
-	xmlnode *data_element = xmlnode_get_child(packet, "data");
-	xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found");
-
-	/* did we get a data element as result? */
-	if (data_element && type == JABBER_IQ_RESULT) {
-		JabberData *data = jabber_data_create_from_xml(data_element);
+	PurpleConversation *conv = (PurpleConversation *) userdata;
 
-		if (data) {
-			jabber_data_associate_remote(data);
-			purple_conv_custom_smiley_write(conv, alt,
-											jabber_data_get_data(data),
-											jabber_data_get_size(data));
-			purple_conv_custom_smiley_close(conv, alt);
-		}
-
-	} else if (item_not_found) {
-		purple_debug_info("jabber",
-			"Responder didn't recognize requested data\n");
-	} else {
-		purple_debug_error("jabber", "Unknown response to data request\n");
+	if (data) {
+		purple_conv_custom_smiley_write(conv, alt,
+										jabber_data_get_data(data),
+										jabber_data_get_size(data));
+		purple_conv_custom_smiley_close(conv, alt);
 	}
-	g_free(ref->alt);
-	g_free(ref);
-}
 
-static void
-jabber_message_send_data_request(JabberStream *js, PurpleConversation *conv,
-								 const gchar *cid, const gchar *who,
-								 const gchar *alt)
-{
-	JabberIq *request = jabber_iq_new(js, JABBER_IQ_GET);
-	JabberDataRef *ref = g_new0(JabberDataRef, 1);
-	xmlnode *data_request = jabber_data_get_xml_request(cid);
-
-	xmlnode_set_attrib(request->node, "to", who);
-	ref->conv = conv;
-	ref->alt = g_strdup(alt);
-	jabber_iq_set_callback(request, jabber_message_get_data_cb, ref);
-	xmlnode_insert_child(request->node, data_request);
-
-	jabber_iq_send(request);
+	g_free(alt);
 }
 
-
 void jabber_message_parse(JabberStream *js, xmlnode *packet)
 {
 	JabberMessage *jm;
@@ -693,7 +650,7 @@
 				for (; conv && smiley_refs ; smiley_refs = g_list_delete_link(smiley_refs, smiley_refs)) {
 					JabberSmileyRef *ref = (JabberSmileyRef *) smiley_refs->data;
 					const gchar *cid = ref->cid;
-					const gchar *alt = ref->alt;
+					gchar *alt = g_strdup(ref->alt);
 
 					purple_debug_info("jabber",
 						"about to add custom smiley %s to the conv\n", alt);
@@ -713,8 +670,8 @@
 							/* we need to request the smiley (data) */
 							purple_debug_info("jabber",
 								"data is unknown, need to request it\n");
-							jabber_message_send_data_request(js, conv, cid, from,
-								alt);
+							jabber_data_request(js, cid, from, alt, FALSE,
+							    jabber_message_request_data_cb, conv);
 						}
 					}
 					g_free(ref->cid);
--- a/libpurple/protocols/jabber/namespaces.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/namespaces.h	Sun Mar 21 19:44:45 2010 +0000
@@ -30,6 +30,7 @@
 #define NS_XMPP_SESSION "urn:ietf:params:xml:ns:xmpp-session"
 #define NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas"
 #define NS_XMPP_STREAMS "http://etherx.jabber.org/streams"
+#define NS_XMPP_TLS "urn:ietf:params:xml:ns:xmpp-tls"
 
 /* XEP-0012 Last Activity (and XEP-0256 Last Activity in Presence) */
 #define NS_LAST_ACTIVITY "jabber:iq:last"
--- a/libpurple/protocols/jabber/parser.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/parser.c	Sun Mar 21 19:44:45 2010 +0000
@@ -43,10 +43,25 @@
 
 	if(!element_name) {
 		return;
-	} else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) {
+	} else if (js->stream_id == NULL) {
+		/* Sanity checking! */
+		if (0 != xmlStrcmp(element_name, (xmlChar *) "stream") ||
+				0 != xmlStrcmp(namespace, (xmlChar *) NS_XMPP_STREAMS)) {
+			/* We were expecting a <stream:stream/> opening stanza, but
+			 * didn't get it. Bad!
+			 */
+			purple_debug_error("jabber", "Expecting stream header, got %s with "
+			                   "xmlns %s\n", element_name, namespace);
+			purple_connection_error_reason(js->gc,
+					PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
+					_("XMPP stream header missing"));
+			return;
+		}
+
 		js->protocol_version.major = 0;
 		js->protocol_version.minor = 9;
-		for(i=0; i < nb_attributes * 5; i += 5) {
+
+		for (i = 0; i < nb_attributes * 5; i += 5) {
 			int attrib_len = attributes[i+4] - attributes[i+3];
 			char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len);
 
@@ -56,11 +71,14 @@
 				js->protocol_version.major = atoi(attrib);
 				js->protocol_version.minor = dot ? atoi(dot + 1) : 0;
 
-				if (js->protocol_version.major > 1)
+				if (js->protocol_version.major > 1) {
 					/* TODO: Send <unsupported-version/> error */
 					purple_connection_error_reason(js->gc,
 							PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
 							_("XMPP Version Mismatch"));
+					g_free(attrib);
+					return;
+				}
 
 				if (js->protocol_version.major == 0 && js->protocol_version.minor != 9) {
 					purple_debug_warning("jabber", "Treating version %s as 0.9 for backward "
@@ -74,6 +92,11 @@
 				g_free(attrib);
 			}
 		}
+
+		if (js->stream_id == NULL)
+			purple_connection_error_reason(js->gc,
+					PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
+					_("XMPP stream missing ID"));
 	} else {
 
 		if(js->current)
--- a/libpurple/protocols/jabber/presence.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/presence.c	Sun Mar 21 19:44:45 2010 +0000
@@ -538,7 +538,7 @@
 	g_free(userdata);
 }
 
-gboolean
+static gboolean
 handle_presence_chat(JabberStream *js, JabberPresence *presence, xmlnode *packet)
 {
 	static int i = 1;
@@ -670,7 +670,7 @@
 		if (chat->muc) {
 			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110)))
 				is_our_resource = TRUE;
-			
+
 			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(301))) {
 				/* XXX: We got banned.  YAY! (No GIR, that's bad) */
 			}
@@ -744,15 +744,15 @@
 
 				g_free(reason);
 			}
-			
+
 			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(321))) {
 				/* XXX: removed due to an affiliation change */
 			}
-			
+
 			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(322))) {
 				/* XXX: removed because room is now members-only */
 			}
-			
+
 			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(332))) {
 				/* XXX: removed due to system shutdown */
 			}
@@ -792,7 +792,7 @@
 	return TRUE;
 }
 
-gboolean
+static gboolean
 handle_presence_contact(JabberStream *js, JabberPresence *presence)
 {
 	JabberBuddyResource *jbr;
@@ -996,7 +996,7 @@
 		JabberPresenceHandler *pih;
 		if (child->type != XMLNODE_TYPE_TAG)
 			continue;
-	
+
 		key = g_strdup_printf("%s %s", child->name, xmlnode_get_namespace(child));
 		pih = g_hash_table_lookup(presence_handlers, key);
 		g_free(key);
@@ -1052,11 +1052,15 @@
 	}
 
 out:
+	while (presence.chat_info.codes)
+		presence.chat_info.codes =
+			g_slist_delete_link(presence.chat_info.codes,
+			                    presence.chat_info.codes);
+
+	g_free(presence.status);
+	g_free(presence.vcard_avatar_hash);
 	g_free(presence.nickname);
-	g_free(presence.status);
 	jabber_id_free(presence.jid_from);
-	g_free(presence.nickname);
-	g_free(presence.vcard_avatar_hash);
 }
 
 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type)
--- a/libpurple/protocols/jabber/si.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/jabber/si.c	Sun Mar 21 19:44:45 2010 +0000
@@ -1076,6 +1076,9 @@
 				jabber_si_xfer_ibb_error_cb);
 
 			jsx->ibb_session = sess;
+			/* we handle up to block-size bytes of decoded data, to handle
+			 clients interpreting the block-size attribute as that
+			 (see also remark in ibb.c) */
 			jsx->ibb_buffer =
 				purple_circ_buffer_new(jabber_ibb_session_get_block_size(sess));
 
@@ -1104,8 +1107,8 @@
 {
 	JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
 	JabberIBBSession *sess = jsx->ibb_session;
-	gsize packet_size = len < jabber_ibb_session_get_block_size(sess) ?
-		len : jabber_ibb_session_get_block_size(sess);
+	gsize packet_size = len < jabber_ibb_session_get_max_data_size(sess) ?
+		len : jabber_ibb_session_get_max_data_size(sess);
 
 	jabber_ibb_session_send_data(sess, buffer, packet_size);
 
@@ -1171,7 +1174,7 @@
 		purple_xfer_set_write_fnc(xfer, jabber_si_xfer_ibb_write);
 
 		jsx->ibb_buffer =
-			purple_circ_buffer_new(jabber_ibb_session_get_block_size(jsx->ibb_session));
+			purple_circ_buffer_new(jabber_ibb_session_get_max_data_size(jsx->ibb_session));
 
 		/* open the IBB session */
 		jabber_ibb_session_open(jsx->ibb_session);
--- a/libpurple/protocols/oscar/family_locate.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/oscar/family_locate.c	Sun Mar 21 19:44:45 2010 +0000
@@ -577,10 +577,10 @@
 	return NULL;
 }
 
-guint32
+guint64
 aim_locate_getcaps(OscarData *od, ByteStream *bs, int len)
 {
-	guint32 flags = 0;
+	guint64 flags = 0;
 	int offset;
 
 	for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x10) {
@@ -637,10 +637,10 @@
 	return result;
 }
 
-guint32
+guint64
 aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len)
 {
-	guint32 flags = 0;
+	guint64 flags = 0;
 	int offset;
 
 	for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x02) {
@@ -667,7 +667,7 @@
 }
 
 int
-byte_stream_putcaps(ByteStream *bs, guint32 caps)
+byte_stream_putcaps(ByteStream *bs, guint64 caps)
 {
 	int i;
 
@@ -1400,7 +1400,7 @@
  * Subtype 0x0004 - Set your client's capabilities.
  */
 int
-aim_locate_setcaps(OscarData *od, guint32 caps)
+aim_locate_setcaps(OscarData *od, guint64 caps)
 {
 	FlapConnection *conn;
 	PurpleAccount *account = purple_connection_get_account(od->gc);
--- a/libpurple/protocols/oscar/msgcookie.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/oscar/msgcookie.c	Sun Mar 21 19:44:45 2010 +0000
@@ -179,7 +179,7 @@
 }
 
 /* XXX I hate switch */
-int aim_msgcookie_gettype(int type)
+int aim_msgcookie_gettype(guint64 type)
 {
 	/* XXX: hokey-assed. needs fixed. */
 	switch(type) {
--- a/libpurple/protocols/oscar/oscar.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun Mar 21 19:44:45 2010 +0000
@@ -71,9 +71,18 @@
 
 #define OSCAR_CONNECT_STEPS 6
 
-static OscarCapability purple_caps = (OSCAR_CAPABILITY_CHAT | OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM |
-									  OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_UNICODE | OSCAR_CAPABILITY_INTEROPERATE |
-									  OSCAR_CAPABILITY_SHORTCAPS | OSCAR_CAPABILITY_TYPING |  OSCAR_CAPABILITY_ICQSERVERRELAY | OSCAR_CAPABILITY_NEWCAPS | OSCAR_CAPABILITY_XTRAZ);
+static guint64 purple_caps =
+	OSCAR_CAPABILITY_CHAT
+		| OSCAR_CAPABILITY_BUDDYICON
+		| OSCAR_CAPABILITY_DIRECTIM
+		| OSCAR_CAPABILITY_SENDFILE
+		| OSCAR_CAPABILITY_UNICODE
+		| OSCAR_CAPABILITY_INTEROPERATE
+		| OSCAR_CAPABILITY_SHORTCAPS
+		| OSCAR_CAPABILITY_TYPING
+		| OSCAR_CAPABILITY_ICQSERVERRELAY
+		| OSCAR_CAPABILITY_NEWCAPS
+		| OSCAR_CAPABILITY_XTRAZ;
 
 static guint8 features_aim[] = {0x01, 0x01, 0x01, 0x02};
 static guint8 features_icq[] = {0x01, 0x06};
@@ -471,7 +480,7 @@
 		charsetstr1 = "UTF-8";
 		charsetstr2 = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
 	}
-	
+
 	purple_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%" G_GSIZE_FORMAT ", choice1=%s, choice2=%s, choice3=%s\n",
 					  charset, charsubset, datalen, charsetstr1, charsetstr2, (charsetstr3 ? charsetstr3 : ""));
 
@@ -673,7 +682,7 @@
 	return g_string_free(cpy, FALSE);
 }
 
-static gchar *oscar_caps_to_string(OscarCapability caps)
+static gchar *oscar_caps_to_string(guint64 caps)
 {
 	GString *str;
 	const gchar *tmp;
@@ -2594,7 +2603,6 @@
 	PurpleAccount *account;
 	PurpleMessageFlags flags = 0;
 	char *message = NULL;
-	char *rtfmsg = NULL;
 
 	g_return_val_if_fail(od != NULL, 0);
 	g_return_val_if_fail(od->gc != NULL, 0);
@@ -2606,8 +2614,9 @@
 	if (args == NULL)
 		return 0;
 
-	purple_debug_misc("oscar", "Incoming rendezvous message of type %u, "
-			"user %s, status %hu\n", args->type, userinfo->bn, args->status);
+	purple_debug_misc("oscar", "Incoming rendezvous message of type %"
+			G_GUINT64_FORMAT ", user %s, status %hu\n",
+			args->type, userinfo->bn, args->status);
 
 	if (args->msg != NULL)
 	{
@@ -2624,20 +2633,6 @@
 		}
 	}
 
-	if (args->info.rtfmsg.rtfmsg != NULL)
-	{
-		if (args->encoding != NULL)
-		{
-			char *encoding = NULL;
-			encoding = oscar_encoding_extract(args->encoding);
-			rtfmsg = oscar_encoding_to_utf8(account, encoding, args->info.rtfmsg.rtfmsg,
-			                                 strlen(args->info.rtfmsg.rtfmsg));
-			g_free(encoding);
-		} else {
-			if (g_utf8_validate(args->info.rtfmsg.rtfmsg, strlen(args->info.rtfmsg.rtfmsg), NULL))
-				rtfmsg = g_strdup(args->info.rtfmsg.rtfmsg);
-		}
-	}
 	if (args->type & OSCAR_CAPABILITY_CHAT)
 	{
 		char *encoding, *utf8name, *tmp;
@@ -2725,30 +2720,35 @@
 	{
 		purple_debug_info("oscar", "Got an ICQ Server Relay message of "
 				"type %d\n", args->info.rtfmsg.msgtype);
-		purple_debug_info("oscar", "Sending X-Status Reply\n");
-
-		if(args->info.rtfmsg.msgtype == 26)
-			icq_relay_xstatus(od, userinfo->bn, args->cookie);
-		
-		if(args->info.rtfmsg.msgtype == 1)
+
+		if (args->info.rtfmsg.msgtype == 1)
 		{
-			if(rtfmsg)
+			if (args->info.rtfmsg.rtfmsg != NULL)
 			{
-				serv_got_im(gc, userinfo->bn, rtfmsg, flags,
-				            time(NULL));
+				char *rtfmsg = NULL;
+				if (args->encoding != NULL) {
+					char *encoding = oscar_encoding_extract(args->encoding);
+					rtfmsg = oscar_encoding_to_utf8(account, encoding,
+							args->info.rtfmsg.rtfmsg, strlen(args->info.rtfmsg.rtfmsg));
+					g_free(encoding);
+				} else {
+					if (g_utf8_validate(args->info.rtfmsg.rtfmsg, strlen(args->info.rtfmsg.rtfmsg), NULL))
+						rtfmsg = g_strdup(args->info.rtfmsg.rtfmsg);
+				}
+				if (rtfmsg) {
+					serv_got_im(gc, userinfo->bn, rtfmsg, flags, time(NULL));
+					g_free(rtfmsg);
+				}
 			}
-			else
-			{
-				serv_got_im(gc, userinfo->bn,
-				            args->info.rtfmsg.rtfmsg, flags,
-				            time(NULL));
-			}
-		}
+		} else if (args->info.rtfmsg.msgtype == 26)
+			purple_debug_info("oscar", "Sending X-Status Reply\n");
+			icq_relay_xstatus(od, userinfo->bn, args->cookie);
+
 	}
 	else
 	{
-		purple_debug_error("oscar", "Unknown request class %hu\n",
-				args->type);
+		purple_debug_error("oscar", "Unknown request class %"
+				G_GUINT64_FORMAT "\n", args->type);
 	}
 
 	g_free(message);
@@ -3331,9 +3331,9 @@
 			/* Split at (carriage return/newline)'s, then rejoin later with BRs between. */
 			statusmsg = oscar_icqstatus(state);
 			splitmsg = g_strsplit(msg, "\r\n", 0);
-			
+
 			user_info = purple_notify_user_info_new();
-				
+
 			purple_notify_user_info_add_pair(user_info, _("UIN"), who);
 			purple_notify_user_info_add_pair(user_info, _("Status"), statusmsg);
 			purple_notify_user_info_add_section_break(user_info);
@@ -4758,8 +4758,8 @@
 		img = purple_buddy_icons_find_account_icon(account);
 		if (img) {
 			gconstpointer data = purple_imgstore_get_data(img);
-			args.iconlen   = purple_imgstore_get_size(img);
-			args.iconsum   = aimutil_iconsum(data, args.iconlen);
+			args.iconlen = purple_imgstore_get_size(img);
+			args.iconsum = aimutil_iconsum(data, args.iconlen);
 			args.iconstamp = purple_buddy_icons_get_account_icon_timestamp(account);
 
 			if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) {
@@ -5368,7 +5368,7 @@
 	{ /* If not in server list then prune from local list */
 		GSList *cur, *next;
 		GSList *buddies = purple_find_buddies(account, NULL);
-		
+
 		/* Buddies */
 		cur = NULL;
 
@@ -5807,28 +5807,34 @@
 	return 1;
 }
 
-static int purple_ssi_authrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
+static int purple_ssi_authrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
+{
 	PurpleConnection *gc = od->gc;
 	va_list ap;
-	char *bn;
-	char *msg;
+	const char *bn;
+	const char *msg;
 	PurpleAccount *account = purple_connection_get_account(gc);
-	gchar *reason = NULL;
 	struct name_data *data;
 	PurpleBuddy *buddy;
 
 	va_start(ap, fr);
-	bn = va_arg(ap, char *);
-	msg = va_arg(ap, char *);
+	bn = va_arg(ap, const char *);
+	msg = va_arg(ap, const char *);
 	va_end(ap);
 
 	purple_debug_info("oscar",
-			   "ssi: received authorization request from %s\n", bn);
+			"ssi: received authorization request from %s\n", bn);
 
 	buddy = purple_find_buddy(account, bn);
 
-	if (msg != NULL)
-		reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_LATIN_1, 0x0000, msg, strlen(msg));
+	if (!msg) {
+		purple_debug_warning("oscar", "Received auth request from %s with "
+				"empty message\n", bn);
+	} else if (!g_utf8_validate(msg, -1, NULL)) {
+		purple_debug_warning("oscar", "Received auth request from %s with "
+				"invalid UTF-8 message\n", bn);
+		msg = NULL;
+	}
 
 	data = g_new(struct name_data, 1);
 	data->gc = gc;
@@ -5837,9 +5843,8 @@
 
 	purple_account_request_authorization(account, bn, NULL,
 			(buddy ? purple_buddy_get_alias_only(buddy) : NULL),
-			reason, buddy != NULL, purple_auth_grant,
+			msg, buddy != NULL, purple_auth_grant,
 			purple_auth_dontgrant_msgprompt, data);
-	g_free(reason);
 
 	return 1;
 }
@@ -6389,7 +6394,7 @@
 				purple_value_new(PURPLE_TYPE_STRING), NULL);
 
 	status_types = g_list_prepend(status_types, type);
-	
+
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
 									 OSCAR_STATUS_ID_EVIL,
 									 _("Evil"), TRUE, is_icq, FALSE,
@@ -6651,23 +6656,22 @@
 		 * window. Let the user know that we canceled the Direct IM. */
 		conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name);
 		purple_conversation_write(conv, NULL, _("You closed the connection."),
-		                          PURPLE_MESSAGE_SYSTEM, time(NULL));
-	}
-}
-
-static void oscar_get_icqxstatusmsg (PurpleBlistNode *node, gpointer ignore)
+				PURPLE_MESSAGE_SYSTEM, time(NULL));
+	}
+}
+
+static void oscar_get_icqxstatusmsg(PurpleBlistNode *node, gpointer ignore)
 {
 	PurpleBuddy *buddy;
 	PurpleConnection *gc;
 	PurpleAccount *account;
-	
-	
+
 	g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
 
 	buddy = (PurpleBuddy *)node;
 	gc = purple_account_get_connection(buddy->account);
 	account = purple_connection_get_account(gc);
-	purple_debug_info("oscar",   "Manual X-Status Get From %s to %s:\n", purple_buddy_get_name(buddy), account->username);
+	purple_debug_info("oscar", "Manual X-Status Get From %s to %s:\n", purple_buddy_get_name(buddy), account->username);
 
 	icq_im_xstatus_request(gc->proto_data, purple_buddy_get_name(buddy));
 }
--- a/libpurple/protocols/oscar/oscar.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Sun Mar 21 19:44:45 2010 +0000
@@ -344,44 +344,39 @@
 	OSCAR_DISCONNECT_RETRYING /* peer connections only */
 } OscarDisconnectReason;
 
-typedef enum
-{
-	OSCAR_CAPABILITY_BUDDYICON            = 0x00000001,
-	OSCAR_CAPABILITY_TALK                 = 0x00000002,
-	OSCAR_CAPABILITY_DIRECTIM             = 0x00000004,
-	OSCAR_CAPABILITY_CHAT                 = 0x00000008,
-	OSCAR_CAPABILITY_GETFILE              = 0x00000010,
-	OSCAR_CAPABILITY_SENDFILE             = 0x00000020,
-	OSCAR_CAPABILITY_GAMES                = 0x00000040,
-	OSCAR_CAPABILITY_ADDINS               = 0x00000080,
-	OSCAR_CAPABILITY_SENDBUDDYLIST        = 0x00000100,
-	OSCAR_CAPABILITY_GAMES2               = 0x00000200,
-	OSCAR_CAPABILITY_ICQ_DIRECT           = 0x00000400,
-	OSCAR_CAPABILITY_APINFO               = 0x00000800,
-	OSCAR_CAPABILITY_ICQRTF               = 0x00001000,
-	OSCAR_CAPABILITY_EMPTY                = 0x00002000,
-	OSCAR_CAPABILITY_ICQSERVERRELAY       = 0x00004000,
-	OSCAR_CAPABILITY_UNICODEOLD           = 0x00008000,
-	OSCAR_CAPABILITY_TRILLIANCRYPT        = 0x00010000,
-	OSCAR_CAPABILITY_UNICODE              = 0x00020000,
-	OSCAR_CAPABILITY_INTEROPERATE         = 0x00040000,
-	OSCAR_CAPABILITY_SHORTCAPS            = 0x00080000,
-	OSCAR_CAPABILITY_HIPTOP               = 0x00100000,
-	OSCAR_CAPABILITY_SECUREIM             = 0x00200000,
-	OSCAR_CAPABILITY_SMS                  = 0x00400000,
-	OSCAR_CAPABILITY_VIDEO                = 0x00800000,
-	OSCAR_CAPABILITY_ICHATAV              = 0x01000000,
-	OSCAR_CAPABILITY_LIVEVIDEO            = 0x02000000,
-	OSCAR_CAPABILITY_CAMERA               = 0x04000000,
-	OSCAR_CAPABILITY_ICHAT_SCREENSHARE    = 0x08000000,
-	OSCAR_CAPABILITY_TYPING               = 0x10000000,
-	OSCAR_CAPABILITY_NEWCAPS              = 0x20000000,
-	OSCAR_CAPABILITY_XTRAZ                = 0x40000000,
-	OSCAR_CAPABILITY_GENERICUNKNOWN       = 0x80000000,
-#warning Fix OSCAR_CAPABILITY_LAST situation
-	// TODO: We're out of bits.  Rework things that depend on this or remove some capability. (Or, ensure this is a 64-bit type.)
-	OSCAR_CAPABILITY_LAST                 = 0x100000000	
-} OscarCapability;
+#define OSCAR_CAPABILITY_BUDDYICON             0x0000000000000001
+#define OSCAR_CAPABILITY_TALK                  0x0000000000000002
+#define OSCAR_CAPABILITY_DIRECTIM              0x0000000000000004
+#define OSCAR_CAPABILITY_CHAT                  0x0000000000000008
+#define OSCAR_CAPABILITY_GETFILE               0x0000000000000010
+#define OSCAR_CAPABILITY_SENDFILE              0x0000000000000020
+#define OSCAR_CAPABILITY_GAMES                 0x0000000000000040
+#define OSCAR_CAPABILITY_ADDINS                0x0000000000000080
+#define OSCAR_CAPABILITY_SENDBUDDYLIST         0x0000000000000100
+#define OSCAR_CAPABILITY_GAMES2                0x0000000000000200
+#define OSCAR_CAPABILITY_ICQ_DIRECT            0x0000000000000400
+#define OSCAR_CAPABILITY_APINFO                0x0000000000000800
+#define OSCAR_CAPABILITY_ICQRTF                0x0000000000001000
+#define OSCAR_CAPABILITY_EMPTY                 0x0000000000002000
+#define OSCAR_CAPABILITY_ICQSERVERRELAY        0x0000000000004000
+#define OSCAR_CAPABILITY_UNICODEOLD            0x0000000000008000
+#define OSCAR_CAPABILITY_TRILLIANCRYPT         0x0000000000010000
+#define OSCAR_CAPABILITY_UNICODE               0x0000000000020000
+#define OSCAR_CAPABILITY_INTEROPERATE          0x0000000000040000
+#define OSCAR_CAPABILITY_SHORTCAPS             0x0000000000080000
+#define OSCAR_CAPABILITY_HIPTOP                0x0000000000100000
+#define OSCAR_CAPABILITY_SECUREIM              0x0000000000200000
+#define OSCAR_CAPABILITY_SMS                   0x0000000000400000
+#define OSCAR_CAPABILITY_VIDEO                 0x0000000000800000
+#define OSCAR_CAPABILITY_ICHATAV               0x0000000001000000
+#define OSCAR_CAPABILITY_LIVEVIDEO             0x0000000002000000
+#define OSCAR_CAPABILITY_CAMERA                0x0000000004000000
+#define OSCAR_CAPABILITY_ICHAT_SCREENSHARE     0x0000000008000000
+#define OSCAR_CAPABILITY_TYPING                0x0000000010000000
+#define OSCAR_CAPABILITY_NEWCAPS               0x0000000020000000
+#define OSCAR_CAPABILITY_XTRAZ                 0x0000000040000000
+#define OSCAR_CAPABILITY_GENERICUNKNOWN        0x0000000080000000
+#define OSCAR_CAPABILITY_LAST                  0x0000000100000000
 
 /*
  * Byte Stream type. Sort of.
@@ -949,7 +944,7 @@
 {
 	guint16 status;
 	guchar cookie[8];
-	int type; /* One of the OSCAR_CAPABILITY_ constants */
+	guint64 type; /* One of the OSCAR_CAPABILITY_ constants */
 	const char *proxyip;
 	const char *clientip;
 	const char *verifiedip;
@@ -1077,7 +1072,7 @@
 	guint32 membersince; /* time_t */
 	guint32 onlinesince; /* time_t */
 	guint32 sessionlen;  /* in seconds */
-	guint32 capabilities;
+	guint64 capabilities;
 	struct {
 		guint32 status;
 		guint32 ipaddr;
@@ -1142,7 +1137,7 @@
 void aim_locate_dorequest(OscarData *od);
 
 /* 0x0002 */ int aim_locate_reqrights(OscarData *od);
-/* 0x0004 */ int aim_locate_setcaps(OscarData *od, guint32 caps);
+/* 0x0004 */ int aim_locate_setcaps(OscarData *od, guint64 caps);
 /* 0x0004 */ int aim_locate_setprofile(OscarData *od, const char *profile_encoding, const gchar *profile, const int profile_len, const char *awaymsg_encoding, const gchar *awaymsg, const int awaymsg_len);
 /* 0x0005 */ int aim_locate_getinfo(OscarData *od, const char *, guint16);
 /* 0x0009 */ int aim_locate_setdirinfo(OscarData *od, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, guint16 privacy);
@@ -1150,8 +1145,8 @@
 /* 0x000f */ int aim_locate_setinterests(OscarData *od, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, guint16 privacy);
 /* 0x0015 */ int aim_locate_getinfoshort(OscarData *od, const char *bn, guint32 flags);
 
-guint32 aim_locate_getcaps(OscarData *od, ByteStream *bs, int len);
-guint32 aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len);
+guint64 aim_locate_getcaps(OscarData *od, ByteStream *bs, int len);
+guint64 aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len);
 void aim_info_free(aim_userinfo_t *);
 int aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *);
 int aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info);
@@ -1487,7 +1482,7 @@
 int aim_tlvlist_add_16(GSList **list, const guint16 type, const guint16 value);
 int aim_tlvlist_add_32(GSList **list, const guint16 type, const guint32 value);
 int aim_tlvlist_add_str(GSList **list, const guint16 type, const char *value);
-int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint32 caps, const char *mood);
+int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint64 caps, const char *mood);
 int aim_tlvlist_add_userinfo(GSList **list, guint16 type, aim_userinfo_t *userinfo);
 int aim_tlvlist_add_chatroom(GSList **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
 int aim_tlvlist_add_frozentlvlist(GSList **list, guint16 type, GSList **tl);
@@ -1650,7 +1645,7 @@
 int byte_stream_putstr(ByteStream *bs, const char *str);
 int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, int len);
 int byte_stream_putuid(ByteStream *bs, OscarData *od);
-int byte_stream_putcaps(ByteStream *bs, guint32 caps);
+int byte_stream_putcaps(ByteStream *bs, guint64 caps);
 
 /**
  * Inserts a BART asset block into the given byte stream.  The flags
@@ -1710,7 +1705,7 @@
 IcbmCookie *aim_mkcookie(guint8 *, int, void *);
 IcbmCookie *aim_checkcookie(OscarData *, const unsigned char *, const int);
 int aim_freecookie(OscarData *od, IcbmCookie *cookie);
-int aim_msgcookie_gettype(int type);
+int aim_msgcookie_gettype(guint64 type);
 int aim_cookie_free(OscarData *od, IcbmCookie *cookie);
 
 int aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo);
--- a/libpurple/protocols/oscar/peer.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/oscar/peer.c	Sun Mar 21 19:44:45 2010 +0000
@@ -69,7 +69,7 @@
 #endif
 
 PeerConnection *
-peer_connection_find_by_type(OscarData *od, const char *bn, OscarCapability type)
+peer_connection_find_by_type(OscarData *od, const char *bn, guint64 type)
 {
 	GSList *cur;
 	PeerConnection *conn;
@@ -104,7 +104,7 @@
 }
 
 PeerConnection *
-peer_connection_new(OscarData *od, OscarCapability type, const char *bn)
+peer_connection_new(OscarData *od, guint64 type, const char *bn)
 {
 	PeerConnection *conn;
 	PurpleAccount *account;
@@ -897,7 +897,7 @@
  * Initiate a peer connection with someone.
  */
 void
-peer_connection_propose(OscarData *od, OscarCapability type, const char *bn)
+peer_connection_propose(OscarData *od, guint64 type, const char *bn)
 {
 	PeerConnection *conn;
 
--- a/libpurple/protocols/oscar/peer.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/oscar/peer.h	Sun Mar 21 19:44:45 2010 +0000
@@ -136,7 +136,7 @@
 struct _PeerConnection
 {
 	OscarData *od;
-	OscarCapability type;
+	guint64 type;
 	char *bn;
 	guchar magic[4];
 	guchar cookie[8];
@@ -228,11 +228,11 @@
  * @param type The type of the peer connection.  One of
  *        OSCAR_CAPABILITY_DIRECTIM or OSCAR_CAPABILITY_SENDFILE.
  */
-PeerConnection *peer_connection_new(OscarData *od, OscarCapability type, const char *bn);
+PeerConnection *peer_connection_new(OscarData *od, guint64 type, const char *bn);
 
 void peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
 void peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message);
-PeerConnection *peer_connection_find_by_type(OscarData *od, const char *bn, OscarCapability type);
+PeerConnection *peer_connection_find_by_type(OscarData *od, const char *bn, guint64 type);
 PeerConnection *peer_connection_find_by_cookie(OscarData *od, const char *bn, const guchar *cookie);
 
 void peer_connection_listen_cb(gpointer data, gint source, PurpleInputCondition cond);
@@ -241,7 +241,7 @@
 
 void peer_connection_trynext(PeerConnection *conn);
 void peer_connection_finalize_connection(PeerConnection *conn);
-void peer_connection_propose(OscarData *od, OscarCapability type, const char *bn);
+void peer_connection_propose(OscarData *od, guint64 type, const char *bn);
 void peer_connection_got_proposition(OscarData *od, const gchar *bn, const gchar *message, IcbmArgsCh2 *args);
 
 /*
--- a/libpurple/protocols/oscar/tlv.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/oscar/tlv.c	Sun Mar 21 19:44:45 2010 +0000
@@ -407,7 +407,7 @@
  * @param caps Bitfield of capability flags to send
  * @return The size of the value added.
  */
-int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint32 caps, const char *mood)
+int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint64 caps, const char *mood)
 {
 	guint8 buf[256]; /* TODO: Don't use a fixed length buffer */
 	ByteStream bs;
--- a/libpurple/protocols/yahoo/libymsg.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/libpurple/protocols/yahoo/libymsg.h	Sun Mar 21 19:44:45 2010 +0000
@@ -90,8 +90,8 @@
 #define YAHOO_CLIENT_VERSION_ID "4194239"
 #define YAHOO_CLIENT_VERSION "9.0.0.2162"
 
-#define YAHOOJP_CLIENT_VERSION_ID "4194239"
-#define YAHOOJP_CLIENT_VERSION "9.0.0.2162"
+#define YAHOOJP_CLIENT_VERSION_ID "4186047"
+#define YAHOOJP_CLIENT_VERSION "9.0.0.1727"
 
 #define YAHOO_CLIENT_USERAGENT "Mozilla/5.0"
 
--- a/pidgin/gtkblist.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/gtkblist.c	Sun Mar 21 19:44:45 2010 +0000
@@ -70,8 +70,6 @@
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 
-#define HEADLINE_CLOSE_SIZE 11
-
 typedef struct
 {
 	PurpleAccount *account;
@@ -4983,58 +4981,16 @@
 }
 
 static gboolean
-headline_hover_close(int x, int y)
-{
-	GtkWidget *w = gtkblist->headline_hbox;
-	if (x <= w->allocation.width && x >= w->allocation.width - HEADLINE_CLOSE_SIZE &&
-			y >= 0 && y <= HEADLINE_CLOSE_SIZE)
-		return TRUE;
-	return FALSE;
-}
-
-static gboolean
 headline_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, PidginBuddyList *gtkblist)
 {
 	gdk_window_set_cursor(widget->window, gtkblist->hand_cursor);
-
-	if (gtkblist->headline_close) {
-		gdk_draw_pixbuf(widget->window, NULL, gtkblist->headline_close,
-					0, 0,
-					widget->allocation.width - 2 - HEADLINE_CLOSE_SIZE, 2,
-					HEADLINE_CLOSE_SIZE, HEADLINE_CLOSE_SIZE,
-					GDK_RGB_DITHER_NONE, 0, 0);
-		gtk_paint_focus(widget->style, widget->window, GTK_STATE_PRELIGHT,
-				NULL, widget, NULL,
-				widget->allocation.width - HEADLINE_CLOSE_SIZE - 3, 1,
-				HEADLINE_CLOSE_SIZE + 2, HEADLINE_CLOSE_SIZE + 2);
-	}
-
 	return FALSE;
 }
 
-#if 0
-static gboolean
-headline_box_motion_cb(GtkWidget *widget, GdkEventMotion *event, PidginBuddyList *gtkblist)
-{
-	purple_debug_fatal("motion", "%d %d\n", (int)event->x, (int)event->y);
-	if (headline_hover_close((int)event->x, (int)event->y))
-		gtk_paint_focus(widget->style, widget->window, GTK_STATE_PRELIGHT,
-				NULL, widget, NULL,
-				widget->allocation.width - HEADLINE_CLOSE_SIZE - 3, 1,
-				HEADLINE_CLOSE_SIZE + 2, HEADLINE_CLOSE_SIZE + 2);
-	return FALSE;
-}
-#endif
-
 static gboolean
 headline_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, PidginBuddyList *gtkblist)
 {
 	gdk_window_set_cursor(widget->window, gtkblist->arrow_cursor);
-	if (gtkblist->headline_close) {
-		GdkRectangle rect = {widget->allocation.width - 3 - HEADLINE_CLOSE_SIZE, 1,
-				HEADLINE_CLOSE_SIZE + 2, HEADLINE_CLOSE_SIZE + 2};
-		gdk_window_invalidate_rect(widget->window, &rect, TRUE);
-	}
 	return FALSE;
 }
 
@@ -5057,10 +5013,17 @@
 }
 
 static gboolean
+headline_close_press_cb(GtkButton *button, PidginBuddyList *gtkblist)
+{
+	gtk_widget_hide(gtkblist->headline_hbox);
+	return FALSE;
+}
+
+static gboolean
 headline_box_press_cb(GtkWidget *widget, GdkEventButton *event, PidginBuddyList *gtkblist)
 {
 	gtk_widget_hide(gtkblist->headline_hbox);
-	if (gtkblist->headline_callback && !headline_hover_close((int)event->x, (int)event->y))
+	if (gtkblist->headline_callback)
 		g_idle_add(headline_click_callback, NULL);
 	else {
 		if (gtkblist->headline_destroy)
@@ -5812,6 +5775,7 @@
 	GtkWidget *sw;
 	GtkWidget *sep;
 	GtkWidget *label;
+	GtkWidget *close;
 	char *pretty, *tmp;
 	const char *theme_name;
 	GtkAccelGroup *accel_group;
@@ -5945,16 +5909,18 @@
 	gtkblist->hand_cursor = gdk_cursor_new (GDK_HAND2);
 	gtkblist->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
 
+	/* Close button. */
+	close = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+	close = pidgin_create_small_button(close);
+	gtk_box_pack_start(GTK_BOX(gtkblist->headline_hbox), close, FALSE, FALSE, 0);
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(close, _("Close"));
+#endif
+	g_signal_connect(close, "clicked", G_CALLBACK(headline_close_press_cb), gtkblist);
+
 	g_signal_connect(G_OBJECT(ebox), "enter-notify-event", G_CALLBACK(headline_box_enter_cb), gtkblist);
 	g_signal_connect(G_OBJECT(ebox), "leave-notify-event", G_CALLBACK(headline_box_leave_cb), gtkblist);
 	g_signal_connect(G_OBJECT(ebox), "button-press-event", G_CALLBACK(headline_box_press_cb), gtkblist);
-#if 0
-	/* I couldn't get this to work. The idea was to draw the focus-border only
-	 * when hovering over the close image. So for now, the focus-border is
-	 * always there. -- sad */
-	gtk_widget_set_events(ebox, gtk_widget_get_events(ebox) | GDK_POINTER_MOTION_HINT_MASK);
-	g_signal_connect(G_OBJECT(ebox), "motion-notify-event", G_CALLBACK(headline_box_motion_cb), gtkblist);
-#endif
 
 	/****************************** GtkTreeView **********************************/
 	sw = gtk_scrolled_window_new(NULL,NULL);
@@ -6949,7 +6915,7 @@
 	purple_signals_disconnect_by_handle(gtkblist);
 
 	if (gtkblist->headline_close)
-		g_object_unref(G_OBJECT(gtkblist->headline_close));
+		gdk_pixbuf_unref(gtkblist->headline_close);
 
 	gtk_widget_destroy(gtkblist->window);
 
--- a/pidgin/gtkblist.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/gtkblist.h	Sun Mar 21 19:44:45 2010 +0000
@@ -119,7 +119,7 @@
 	GtkWidget *headline_hbox;       /**< Hbox for headline notification */
 	GtkWidget *headline_label;	/**< Label for headline notifications */
 	GtkWidget *headline_image;      /**< Image for headline notifications */
-	GdkPixbuf *headline_close;      /**< Close image for closing the headline without triggering the callback */
+	GdkPixbuf *headline_close;      /**< @deprecated: Close image for closing the headline without triggering the callback */ 
 	GCallback headline_callback;    /**< Callback for headline notifications */
 	gpointer headline_data;         /**< User data for headline notifications */
 	GDestroyNotify headline_destroy; /**< Callback to use for destroying the headline-data */
--- a/pidgin/gtkconv.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/gtkconv.c	Sun Mar 21 19:44:45 2010 +0000
@@ -229,7 +229,7 @@
 }
 
 static gboolean
-close_conv_cb(GtkWidget *w, GdkEventButton *dontuse, PidginConversation *gtkconv)
+close_conv_cb(GtkButton *button, PidginConversation *gtkconv)
 {
 	/* We are going to destroy the conversations immediately only if the 'close immediately'
 	 * preference is selected. Otherwise, close the conversation after a reasonable timeout
@@ -1325,7 +1325,7 @@
 {
 	PidginWindow *win = data;
 
-	close_conv_cb(NULL, NULL, PIDGIN_CONVERSATION(pidgin_conv_window_get_active_conversation(win)));
+	close_conv_cb(NULL, PIDGIN_CONVERSATION(pidgin_conv_window_get_active_conversation(win)));
 }
 
 static void
@@ -4824,52 +4824,6 @@
 	return FALSE;
 }
 
-/* Close button {{{ */
-static gboolean
-close_button_left_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label)
-{
-	static GdkCursor *ptr = NULL;
-	if (ptr == NULL) {
-		ptr = gdk_cursor_new(GDK_LEFT_PTR);
-	}
-
-	gtk_label_set_markup(label, "×");
-	gdk_window_set_cursor(event->window, ptr);
-	return FALSE;
-}
-
-static gboolean
-close_button_entered_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label)
-{
-	static GdkCursor *hand = NULL;
-	if (hand == NULL) {
-		hand = gdk_cursor_new(GDK_HAND2);
-	}
-
-	gtk_label_set_markup(label, "<u>×</u>");
-	gdk_window_set_cursor(event->window, hand);
-	return FALSE;
-}
-
-static GtkWidget *
-create_close_button(void)
-{
-	GtkWidget *ebox = gtk_event_box_new();
-	GtkWidget *close_image;
-
-	gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE);
-	gtk_widget_set_events(ebox, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
-	close_image = gtk_label_new("×");
-	g_signal_connect(G_OBJECT(ebox), "enter-notify-event", G_CALLBACK(close_button_entered_cb), close_image);
-	g_signal_connect(G_OBJECT(ebox), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_image);
-	gtk_widget_show(close_image);
-	gtk_container_add(GTK_CONTAINER(ebox), close_image);
-
-	return ebox;
-}
-
-/* }}} */
-
 /* Quick Find {{{ */
 static gboolean
 pidgin_conv_end_quickfind(PidginConversation *gtkconv)
@@ -4912,11 +4866,12 @@
 pidgin_conv_setup_quickfind(PidginConversation *gtkconv, GtkWidget *container)
 {
 	GtkWidget *widget = gtk_hbox_new(FALSE, 0);
-	GtkWidget *label, *entry, *close;
+	GtkWidget *label, *entry, *close, *image;
 
 	gtk_box_pack_start(GTK_BOX(container), widget, FALSE, FALSE, 0);
 
-	close = create_close_button();
+	image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+	close = pidgin_create_small_button(image);
 	gtk_box_pack_start(GTK_BOX(widget), close, FALSE, FALSE, 0);
 	gtk_tooltips_set_tip(gtkconv->tooltips, close,
 	                     _("Close Find bar"), NULL);
@@ -8677,7 +8632,7 @@
 			return FALSE;
 
 		gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, tab_clicked);
-		close_conv_cb(NULL, NULL, gtkconv);
+		close_conv_cb(NULL, gtkconv);
 		return TRUE;
 	}
 
@@ -8945,7 +8900,7 @@
 
 		if (gconv != gtkconv)
 		{
-			close_conv_cb(NULL, NULL, gconv);
+			close_conv_cb(NULL, gconv);
 		}
 	}
 }
@@ -8957,7 +8912,7 @@
 	gtkconv = g_object_get_data(menu, "clicked_tab");
 
 	if (gtkconv)
-		close_conv_cb(NULL, NULL, gtkconv);
+		close_conv_cb(NULL, gtkconv);
 }
 
 static gboolean
@@ -9421,7 +9376,7 @@
 	if (win->gtkconvs) {
 		while (win->gtkconvs) {
 			gboolean last = (win->gtkconvs->next == NULL);
-			close_conv_cb(NULL, NULL, win->gtkconvs->data);
+			close_conv_cb(NULL, win->gtkconvs->data);
 			if (last)
 				break;
 		}
@@ -9495,6 +9450,7 @@
 	GtkWidget *tab_cont = gtkconv->tab_cont;
 	PurpleConversationType conv_type;
 	const gchar *tmp_lab;
+	GtkWidget *close_image;
 
 	conv_type = purple_conversation_get_type(conv);
 
@@ -9506,12 +9462,12 @@
 
 
 	/* Close button. */
-	gtkconv->close = create_close_button();
+	close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+	gtkconv->close = pidgin_create_small_button(close_image);
 	gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close,
 	                     _("Close conversation"), NULL);
 
-	g_signal_connect(G_OBJECT(gtkconv->close), "button-press-event",
-			 G_CALLBACK(close_conv_cb), gtkconv);
+	g_signal_connect(gtkconv->close, "clicked", G_CALLBACK (close_conv_cb), gtkconv);
 
 	/* Status icon. */
 	gtkconv->icon = gtk_image_new();
--- a/pidgin/gtkutils.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/gtkutils.c	Sun Mar 21 19:44:45 2010 +0000
@@ -153,6 +153,27 @@
 }
 
 GtkWidget *
+pidgin_create_small_button(GtkWidget *image)
+{
+	GtkWidget *button;
+
+	button = gtk_button_new();
+	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+
+	/* don't allow focus on the close button */
+	gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
+
+	/* set style to make it as small as possible */
+	gtk_widget_set_name(button, "pidgin-small-close-button");
+
+	gtk_widget_show(image);
+
+	gtk_container_add(GTK_CONTAINER(button), image);
+
+	return button;
+}
+
+GtkWidget *
 pidgin_create_dialog(const char *title, guint border_width, const char *role, gboolean resizable)
 {
 	GtkWindow *wnd = NULL;
@@ -3448,6 +3469,16 @@
 	if (purple_running_gnome())
 		register_gnome_url_handlers();
 
+	/* Used to make small buttons */
+	gtk_rc_parse_string("style \"pidgin-small-close-button\"\n"
+	                    "{\n"
+	                    "GtkWidget::focus-padding = 0\n"
+	                    "GtkWidget::focus-line-width = 0\n"
+	                    "xthickness = 0\n"
+	                    "ythickness = 0\n"
+	                    "}\n"
+	                    "widget \"*.pidgin-small-close-button\" style \"pidgin-small-close-button\"");
+
 #ifdef _WIN32
 	winpidgin_register_win32_url_handlers();
 #endif
--- a/pidgin/gtkutils.h	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/gtkutils.h	Sun Mar 21 19:44:45 2010 +0000
@@ -109,6 +109,16 @@
 GtkWidget *pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret);
 
 /**
+ * Creates a small button
+ *
+ * @param  image   A button image.
+ *
+ * @return   A GtkButton created from the image.
+ * @since 2.7.0
+ */
+GtkWidget *pidgin_create_small_button(GtkWidget *image);
+
+/**
  * Creates a new window
  *
  * @param title        The window title, or @c NULL
--- a/pidgin/plugins/xmppconsole.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/plugins/xmppconsole.c	Sun Mar 21 19:44:45 2010 +0000
@@ -845,7 +845,7 @@
 	                                              /**  summary        */
 	N_("Send and receive raw XMPP stanzas."),
 	                                              /**  description    */
-	N_("This plugin is useful for debbuging XMPP servers or clients."),
+	N_("This plugin is useful for debugging XMPP servers or clients."),
 	"Sean Egan <seanegan@gmail.com>",             /**< author         */
 	PURPLE_WEBSITE,                               /**< homepage       */
 
--- a/pidgin/win32/winpidgin.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/win32/winpidgin.c	Sun Mar 21 19:44:45 2010 +0000
@@ -26,13 +26,10 @@
  */
 
 /* This is for ATTACH_PARENT_PROCESS */
-#define UNICODE
-#define _UNICODE
 #ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x501
 #endif
 #include <windows.h>
-#include <tchar.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
@@ -53,70 +50,70 @@
 static LPFNPIDGINMAIN pidgin_main = NULL;
 static LPFNSETDLLDIRECTORY MySetDllDirectory = NULL;
 
-static const TCHAR *get_win32_error_message(DWORD err) {
-	static TCHAR err_msg[512];
+static const wchar_t *get_win32_error_message(DWORD err) {
+	static wchar_t err_msg[512];
 
-	FormatMessage(
+	FormatMessageW(
 		FORMAT_MESSAGE_FROM_SYSTEM,
 		NULL, err,
 		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-		(LPTSTR) &err_msg, sizeof(err_msg) / sizeof(TCHAR), NULL);
+		(LPWSTR) &err_msg, sizeof(err_msg) / sizeof(wchar_t), NULL);
 
 	return err_msg;
 }
 
-static BOOL read_reg_string(HKEY key, TCHAR *sub_key, TCHAR *val_name, LPBYTE data, LPDWORD data_len) {
+static BOOL read_reg_string(HKEY key, wchar_t *sub_key, wchar_t *val_name, LPBYTE data, LPDWORD data_len) {
 	HKEY hkey;
 	BOOL ret = FALSE;
 	LONG retv;
 
-	if (ERROR_SUCCESS == (retv = RegOpenKeyEx(key, sub_key, 0,
+	if (ERROR_SUCCESS == (retv = RegOpenKeyExW(key, sub_key, 0,
 					KEY_QUERY_VALUE, &hkey))) {
-		if (ERROR_SUCCESS == (retv = RegQueryValueEx(hkey, val_name,
+		if (ERROR_SUCCESS == (retv = RegQueryValueExW(hkey, val_name,
 						NULL, NULL, data, data_len)))
 			ret = TRUE;
 		else {
-			const TCHAR *err_msg = get_win32_error_message(retv);
+			const wchar_t *err_msg = get_win32_error_message(retv);
 
-			_tprintf(_T("Could not read reg key '%s' subkey '%s' value: '%s'.\nMessage: (%ld) %s\n"),
-					(key == HKEY_LOCAL_MACHINE) ? _T("HKLM")
-					 : ((key == HKEY_CURRENT_USER) ? _T("HKCU") : _T("???")),
+			wprintf(L"Could not read reg key '%s' subkey '%s' value: '%s'.\nMessage: (%ld) %s\n",
+					(key == HKEY_LOCAL_MACHINE) ? L"HKLM"
+					 : ((key == HKEY_CURRENT_USER) ? L"HKCU" : L"???"),
 					sub_key, val_name, retv, err_msg);
 		}
 		RegCloseKey(hkey);
 	}
 	else {
-		TCHAR szBuf[80];
+		wchar_t szBuf[80];
 
-		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, retv, 0,
-				(LPTSTR) &szBuf, sizeof(szBuf) / sizeof(TCHAR), NULL);
-		_tprintf(_T("Could not open reg subkey: %s\nError: (%ld) %s\n"),
+		FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, retv, 0,
+				(LPWSTR) &szBuf, sizeof(szBuf) / sizeof(wchar_t), NULL);
+		wprintf(L"Could not open reg subkey: %s\nError: (%ld) %s\n",
 				sub_key, retv, szBuf);
 	}
 
 	return ret;
 }
 
-static BOOL common_dll_prep(const TCHAR *path) {
+static BOOL common_dll_prep(const wchar_t *path) {
 	HMODULE hmod;
 	HKEY hkey;
 	struct _stat stat_buf;
-	TCHAR test_path[MAX_PATH + 1];
+	wchar_t test_path[MAX_PATH + 1];
 
-	_sntprintf(test_path, sizeof(test_path) / sizeof(TCHAR),
-		_T("%s\\libgtk-win32-2.0-0.dll"), path);
-	test_path[sizeof(test_path) / sizeof(TCHAR) - 1] = _T('\0');
+	_snwprintf(test_path, sizeof(test_path) / sizeof(wchar_t),
+		L"%s\\libgtk-win32-2.0-0.dll", path);
+	test_path[sizeof(test_path) / sizeof(wchar_t) - 1] = L'\0';
 
-	if (_tstat(test_path, &stat_buf) != 0) {
+	if (_wstat(test_path, &stat_buf) != 0) {
 		printf("Unable to determine GTK+ path. \n"
 			"Assuming GTK+ is in the PATH.\n");
 		return FALSE;
 	}
 
 
-	_tprintf(_T("GTK+ path found: %s\n"), path);
+	wprintf(L"GTK+ path found: %s\n", path);
 
-	if ((hmod = GetModuleHandle(_T("kernel32.dll")))) {
+	if ((hmod = GetModuleHandleW(L"kernel32.dll"))) {
 		MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress(
 			hmod, "SetDllDirectoryW");
 		if (!MySetDllDirectory)
@@ -133,44 +130,44 @@
 	/* For the rest, we set the current directory and make sure
 	 * SafeDllSearch is set to 0 where needed. */
 	else {
-		OSVERSIONINFO osinfo;
+		OSVERSIONINFOW osinfo;
 
 		printf("Setting current directory to GTK+ dll directory\n");
-		SetCurrentDirectory(path);
+		SetCurrentDirectoryW(path);
 		/* For Windows 2000 (SP3+) / WinXP (No SP):
 		 * If SafeDllSearchMode is set to 1, Windows system directories are
 		 * searched for dlls before the current directory. Therefore we set it
 		 * to 0.
 		 */
-		osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-		GetVersionEx(&osinfo);
+		osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
+		GetVersionExW(&osinfo);
 		if ((osinfo.dwMajorVersion == 5
 				&& osinfo.dwMinorVersion == 0
-				&& _tcscmp(osinfo.szCSDVersion, _T("Service Pack 3")) >= 0)
+				&& wcscmp(osinfo.szCSDVersion, L"Service Pack 3") >= 0)
 			||
 			(osinfo.dwMajorVersion == 5
 				&& osinfo.dwMinorVersion == 1
-				&& _tcscmp(osinfo.szCSDVersion, _T("")) >= 0)
+				&& wcscmp(osinfo.szCSDVersion, L"") >= 0)
 		) {
 			DWORD regval = 1;
 			DWORD reglen = sizeof(DWORD);
 
 			printf("Using Win2k (SP3+) / WinXP (No SP)... Checking SafeDllSearch\n");
 			read_reg_string(HKEY_LOCAL_MACHINE,
-				_T("System\\CurrentControlSet\\Control\\Session Manager"),
-				_T("SafeDllSearchMode"),
+				L"System\\CurrentControlSet\\Control\\Session Manager",
+				L"SafeDllSearchMode",
 				(LPBYTE) &regval,
 				&reglen);
 
 			if (regval != 0) {
 				printf("Trying to set SafeDllSearchMode to 0\n");
 				regval = 0;
-				if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-					_T("System\\CurrentControlSet\\Control\\Session Manager"),
+				if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+					L"System\\CurrentControlSet\\Control\\Session Manager",
 					0,  KEY_SET_VALUE, &hkey
 				) == ERROR_SUCCESS) {
-					if (RegSetValueEx(hkey,
-						_T("SafeDllSearchMode"), 0,
+					if (RegSetValueExW(hkey,
+						L"SafeDllSearchMode", 0,
 						REG_DWORD, (LPBYTE) &regval,
 						sizeof(DWORD)
 					) != ERROR_SUCCESS)
@@ -188,35 +185,35 @@
 	return TRUE;
 }
 
-static BOOL dll_prep(const TCHAR *pidgin_dir) {
-	TCHAR path[MAX_PATH + 1];
-	path[0] = _T('\0');
+static BOOL dll_prep(const wchar_t *pidgin_dir) {
+	wchar_t path[MAX_PATH + 1];
+	path[0] = L'\0';
 
 	if (*pidgin_dir) {
-		_sntprintf(path, sizeof(path) / sizeof(TCHAR), _T("%s\\Gtk\\bin"), pidgin_dir);
-		path[sizeof(path) / sizeof(TCHAR)] = _T('\0');
+		_snwprintf(path, sizeof(path) / sizeof(wchar_t), L"%s\\Gtk\\bin", pidgin_dir);
+		path[sizeof(path) / sizeof(wchar_t) - 1] = L'\0';
 	}
 
 	return common_dll_prep(path);
 }
 
-static void portable_mode_dll_prep(const TCHAR *pidgin_dir) {
-	/* need to be able to fit MAX_PATH + "PIDGIN_ASPELL_DIR=\\Aspell\\bin" in path2 */
-	TCHAR path[MAX_PATH + 1];
-	TCHAR path2[MAX_PATH + 33];
-	const TCHAR *prev = NULL;
+static void portable_mode_dll_prep(const wchar_t *pidgin_dir) {
+	/* need to be able to fit MAX_PATH + "PURPLEHOME=" in path2 */
+	wchar_t path[MAX_PATH + 1];
+	wchar_t path2[MAX_PATH + 12];
+	const wchar_t *prev = NULL;
 
 	/* We assume that GTK+ is installed under \\path\to\Pidgin\..\GTK
 	 * First we find \\path\to
 	 */
 	if (*pidgin_dir)
 		/* pidgin_dir points to \\path\to\Pidgin */
-		prev = _tcsrchr(pidgin_dir, _T('\\'));
+		prev = wcsrchr(pidgin_dir, L'\\');
 
 	if (prev) {
 		int cnt = (prev - pidgin_dir);
-		_tcsncpy(path, pidgin_dir, cnt);
-		path[cnt] = _T('\0');
+		wcsncpy(path, pidgin_dir, cnt);
+		path[cnt] = L'\0';
 	} else {
 		printf("Unable to determine current executable path. \n"
 			"This will prevent the settings dir from being set.\n"
@@ -225,130 +222,126 @@
 	}
 
 	/* Set $HOME so that the GTK+ settings get stored in the right place */
-	_sntprintf(path2, sizeof(path2) / sizeof(TCHAR), _T("HOME=%s"), path);
-	_tputenv(path2);
+	_snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"HOME=%s", path);
+	_wputenv(path2);
 
 	/* Set up the settings dir base to be \\path\to
 	 * The actual settings dir will be \\path\to\.purple */
-	_sntprintf(path2, sizeof(path2) / sizeof(TCHAR), _T("PURPLEHOME=%s"), path);
-	_tprintf(_T("Setting settings dir: %s\n"), path2);
-	_tputenv(path2);
-
-	_sntprintf(path2, sizeof(path2) / sizeof(TCHAR), _T("PIDGIN_ASPELL_DIR=%s\\Aspell\\bin"), path);
-	_tprintf(_T("%s\n"), path2);
-	_tputenv(path2);
+	_snwprintf(path2, sizeof(path2) / sizeof(wchar_t), L"PURPLEHOME=%s", path);
+	wprintf(L"Setting settings dir: %s\n", path2);
+	_wputenv(path2);
 
 	if (!dll_prep(pidgin_dir)) {
 		/* set the GTK+ path to be \\path\to\GTK\bin */
-		_tcscat(path, _T("\\GTK\\bin"));
+		wcscat(path, L"\\GTK\\bin");
 		common_dll_prep(path);
 	}
 }
 
-static TCHAR* winpidgin_lcid_to_posix(LCID lcid) {
-	TCHAR *posix = NULL;
+static wchar_t* winpidgin_lcid_to_posix(LCID lcid) {
+	wchar_t *posix = NULL;
 	int lang_id = PRIMARYLANGID(lcid);
 	int sub_id = SUBLANGID(lcid);
 
 	switch (lang_id) {
-		case LANG_AFRIKAANS: posix = _T("af"); break;
-		case LANG_ARABIC: posix = _T("ar"); break;
-		case LANG_AZERI: posix = _T("az"); break;
-		case LANG_BENGALI: posix = _T("bn"); break;
-		case LANG_BULGARIAN: posix = _T("bg"); break;
-		case LANG_CATALAN: posix = _T("ca"); break;
-		case LANG_CZECH: posix = _T("cs"); break;
-		case LANG_DANISH: posix = _T("da"); break;
-		case LANG_ESTONIAN: posix = _T("et"); break;
-		case LANG_PERSIAN: posix = _T("fa"); break;
-		case LANG_GERMAN: posix = _T("de"); break;
-		case LANG_GREEK: posix = _T("el"); break;
+		case LANG_AFRIKAANS: posix = L"af"; break;
+		case LANG_ARABIC: posix = L"ar"; break;
+		case LANG_AZERI: posix = L"az"; break;
+		case LANG_BENGALI: posix = L"bn"; break;
+		case LANG_BULGARIAN: posix = L"bg"; break;
+		case LANG_CATALAN: posix = L"ca"; break;
+		case LANG_CZECH: posix = L"cs"; break;
+		case LANG_DANISH: posix = L"da"; break;
+		case LANG_ESTONIAN: posix = L"et"; break;
+		case LANG_PERSIAN: posix = L"fa"; break;
+		case LANG_GERMAN: posix = L"de"; break;
+		case LANG_GREEK: posix = L"el"; break;
 		case LANG_ENGLISH:
 			switch (sub_id) {
 				case SUBLANG_ENGLISH_UK:
-					posix = _T("en_GB"); break;
+					posix = L"en_GB"; break;
 				case SUBLANG_ENGLISH_AUS:
-					posix = _T("en_AU"); break;
+					posix = L"en_AU"; break;
 				case SUBLANG_ENGLISH_CAN:
-					posix = _T("en_CA"); break;
+					posix = L"en_CA"; break;
 				default:
-					posix = _T("en"); break;
+					posix = L"en"; break;
 			}
 			break;
-		case LANG_SPANISH: posix = _T("es"); break;
-		case LANG_BASQUE: posix = _T("eu"); break;
-		case LANG_FINNISH: posix = _T("fi"); break;
-		case LANG_FRENCH: posix = _T("fr"); break;
-		case LANG_GALICIAN: posix = _T("gl"); break;
-		case LANG_GUJARATI: posix = _T("gu"); break;
-		case LANG_HEBREW: posix = _T("he"); break;
-		case LANG_HINDI: posix = _T("hi"); break;
-		case LANG_HUNGARIAN: posix = _T("hu"); break;
+		case LANG_SPANISH: posix = L"es"; break;
+		case LANG_BASQUE: posix = L"eu"; break;
+		case LANG_FINNISH: posix = L"fi"; break;
+		case LANG_FRENCH: posix = L"fr"; break;
+		case LANG_GALICIAN: posix = L"gl"; break;
+		case LANG_GUJARATI: posix = L"gu"; break;
+		case LANG_HEBREW: posix = L"he"; break;
+		case LANG_HINDI: posix = L"hi"; break;
+		case LANG_HUNGARIAN: posix = L"hu"; break;
 		case LANG_ICELANDIC: break;
-		case LANG_INDONESIAN: posix = _T("id"); break;
-		case LANG_ITALIAN: posix = _T("it"); break;
-		case LANG_JAPANESE: posix = _T("ja"); break;
-		case LANG_GEORGIAN: posix = _T("ka"); break;
-		case LANG_KANNADA: posix = _T("kn"); break;
-		case LANG_KOREAN: posix = _T("ko"); break;
-		case LANG_LITHUANIAN: posix = _T("lt"); break;
-		case LANG_MACEDONIAN: posix = _T("mk"); break;
-		case LANG_DUTCH: posix = _T("nl"); break;
-		case LANG_NEPALI: posix = _T("ne"); break;
+		case LANG_INDONESIAN: posix = L"id"; break;
+		case LANG_ITALIAN: posix = L"it"; break;
+		case LANG_JAPANESE: posix = L"ja"; break;
+		case LANG_GEORGIAN: posix = L"ka"; break;
+		case LANG_KANNADA: posix = L"kn"; break;
+		case LANG_KOREAN: posix = L"ko"; break;
+		case LANG_LITHUANIAN: posix = L"lt"; break;
+		case LANG_MACEDONIAN: posix = L"mk"; break;
+		case LANG_DUTCH: posix = L"nl"; break;
+		case LANG_NEPALI: posix = L"ne"; break;
 		case LANG_NORWEGIAN:
 			switch (sub_id) {
 				case SUBLANG_NORWEGIAN_BOKMAL:
-					posix = _T("nb"); break;
+					posix = L"nb"; break;
 				case SUBLANG_NORWEGIAN_NYNORSK:
-					posix = _T("nn"); break;
+					posix = L"nn"; break;
 			}
 			break;
-		case LANG_PUNJABI: posix = _T("pa"); break;
-		case LANG_POLISH: posix = _T("pl"); break;
-		case LANG_PASHTO: posix = _T("ps"); break;
+		case LANG_PUNJABI: posix = L"pa"; break;
+		case LANG_POLISH: posix = L"pl"; break;
+		case LANG_PASHTO: posix = L"ps"; break;
 		case LANG_PORTUGUESE:
 			switch (sub_id) {
 				case SUBLANG_PORTUGUESE_BRAZILIAN:
-					posix = _T("pt_BR"); break;
+					posix = L"pt_BR"; break;
 				default:
-				posix = _T("pt"); break;
+				posix = L"pt"; break;
 			}
 			break;
-		case LANG_ROMANIAN: posix = _T("ro"); break;
-		case LANG_RUSSIAN: posix = _T("ru"); break;
-		case LANG_SLOVAK: posix = _T("sk"); break;
-		case LANG_SLOVENIAN: posix = _T("sl"); break;
-		case LANG_ALBANIAN: posix = _T("sq"); break;
+		case LANG_ROMANIAN: posix = L"ro"; break;
+		case LANG_RUSSIAN: posix = L"ru"; break;
+		case LANG_SLOVAK: posix = L"sk"; break;
+		case LANG_SLOVENIAN: posix = L"sl"; break;
+		case LANG_ALBANIAN: posix = L"sq"; break;
 		/* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN */
 		case LANG_SERBIAN:
 			switch (sub_id) {
 				case SUBLANG_SERBIAN_LATIN:
-					posix = _T("sr@Latn"); break;
+					posix = L"sr@Latn"; break;
 				case SUBLANG_SERBIAN_CYRILLIC:
-					posix = _T("sr"); break;
+					posix = L"sr"; break;
 				case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC:
 				case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN:
-					posix = _T("bs"); break;
+					posix = L"bs"; break;
 				case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN:
-					posix = _T("hr"); break;
+					posix = L"hr"; break;
 			}
 			break;
-		case LANG_SWEDISH: posix = _T("sv"); break;
-		case LANG_TAMIL: posix = _T("ta"); break;
-		case LANG_TELUGU: posix = _T("te"); break;
-		case LANG_THAI: posix = _T("th"); break;
-		case LANG_TURKISH: posix = _T("tr"); break;
-		case LANG_UKRAINIAN: posix = _T("uk"); break;
-		case LANG_VIETNAMESE: posix = _T("vi"); break;
-		case LANG_XHOSA: posix = _T("xh"); break;
+		case LANG_SWEDISH: posix = L"sv"; break;
+		case LANG_TAMIL: posix = L"ta"; break;
+		case LANG_TELUGU: posix = L"te"; break;
+		case LANG_THAI: posix = L"th"; break;
+		case LANG_TURKISH: posix = L"tr"; break;
+		case LANG_UKRAINIAN: posix = L"uk"; break;
+		case LANG_VIETNAMESE: posix = L"vi"; break;
+		case LANG_XHOSA: posix = L"xh"; break;
 		case LANG_CHINESE:
 			switch (sub_id) {
 				case SUBLANG_CHINESE_SIMPLIFIED:
-					posix = _T("zh_CN"); break;
+					posix = L"zh_CN"; break;
 				case SUBLANG_CHINESE_TRADITIONAL:
-					posix = _T("zh_TW"); break;
+					posix = L"zh_TW"; break;
 				default:
-					posix = _T("zh"); break;
+					posix = L"zh"; break;
 			}
 			break;
 		case LANG_URDU: break;
@@ -379,8 +372,8 @@
 	/* Deal with exceptions */
 	if (posix == NULL) {
 		switch (lcid) {
-			case 0x0455: posix = _T("my_MM"); break; /* Myanmar (Burmese) */
-			case 9999: posix = _T("ku"); break; /* Kurdish (from NSIS) */
+			case 0x0455: posix = L"my_MM"; break; /* Myanmar (Burmese) */
+			case 9999: posix = L"ku"; break; /* Kurdish (from NSIS) */
 		}
 	}
 
@@ -392,19 +385,19 @@
    - Check NSIS Installer Language reg value
    - Use default user locale
 */
-static const TCHAR *winpidgin_get_locale() {
-	const TCHAR *locale = NULL;
+static const wchar_t *winpidgin_get_locale() {
+	const wchar_t *locale = NULL;
 	LCID lcid;
-	TCHAR data[10];
-	DWORD datalen = sizeof(data) / sizeof(TCHAR);
+	wchar_t data[10];
+	DWORD datalen = sizeof(data) / sizeof(wchar_t);
 
 	/* Check if user set PIDGINLANG env var */
-	if ((locale = _tgetenv(_T("PIDGINLANG"))))
+	if ((locale = _wgetenv(L"PIDGINLANG")))
 		return locale;
 
-	if (!portable_mode && read_reg_string(HKEY_CURRENT_USER, _T("SOFTWARE\\pidgin"),
-			_T("Installer Language"), (LPBYTE) &data, &datalen)) {
-		if ((locale = winpidgin_lcid_to_posix(_ttoi(data))))
+	if (!portable_mode && read_reg_string(HKEY_CURRENT_USER, L"SOFTWARE\\pidgin",
+			L"Installer Language", (LPBYTE) &data, &datalen)) {
+		if ((locale = winpidgin_lcid_to_posix(_wtoi(data))))
 			return locale;
 	}
 
@@ -412,39 +405,39 @@
 	if ((locale = winpidgin_lcid_to_posix(lcid)))
 		return locale;
 
-	return _T("en");
+	return L"en";
 }
 
 static void winpidgin_set_locale() {
-	const TCHAR *locale;
-	TCHAR envstr[25];
+	const wchar_t *locale;
+	wchar_t envstr[25];
 
 	locale = winpidgin_get_locale();
 
-	_sntprintf(envstr, sizeof(envstr) / sizeof(TCHAR), _T("LANG=%s"), locale);
-	_tprintf(_T("Setting locale: %s\n"), envstr);
-	_tputenv(envstr);
+	_snwprintf(envstr, sizeof(envstr) / sizeof(wchar_t), L"LANG=%s", locale);
+	wprintf(L"Setting locale: %s\n", envstr);
+	_wputenv(envstr);
 }
 
 
 static void winpidgin_add_stuff_to_path() {
-	TCHAR perl_path[MAX_PATH + 1];
-	TCHAR *ppath = NULL;
-	TCHAR mit_kerberos_path[MAX_PATH + 1];
-	TCHAR *mpath = NULL;
+	wchar_t perl_path[MAX_PATH + 1];
+	wchar_t *ppath = NULL;
+	wchar_t mit_kerberos_path[MAX_PATH + 1];
+	wchar_t *mpath = NULL;
 	DWORD plen;
 
 	printf("%s", "Looking for Perl... ");
 
-	plen = sizeof(perl_path) / sizeof(TCHAR);
-	if (read_reg_string(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Perl"), _T(""),
+	plen = sizeof(perl_path) / sizeof(wchar_t);
+	if (read_reg_string(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Perl", L"",
 			    (LPBYTE) &perl_path, &plen)) {
 		/* We *could* check for perl510.dll, but it seems unnecessary. */
-		_tprintf(_T("found in '%s'.\n"), perl_path);
+		wprintf(L"found in '%s'.\n", perl_path);
 
-		if (perl_path[_tcslen(perl_path) - 1] != _T('\\'))
-			_tcscat(perl_path, _T("\\"));
-		_tcscat(perl_path, _T("bin"));
+		if (perl_path[wcslen(perl_path) - 1] != L'\\')
+			wcscat(perl_path, L"\\");
+		wcscat(perl_path, L"bin");
 
 		ppath = perl_path;
 	} else
@@ -452,47 +445,47 @@
 
 	printf("%s", "Looking for MIT Kerberos... ");
 
-	plen = sizeof(mit_kerberos_path) / sizeof(TCHAR);
-	if (read_reg_string(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\MIT\\Kerberos"), _T("InstallDir"),
+	plen = sizeof(mit_kerberos_path) / sizeof(wchar_t);
+	if (read_reg_string(HKEY_LOCAL_MACHINE, L"SOFTWARE\\MIT\\Kerberos", L"InstallDir",
 			    (LPBYTE) &mit_kerberos_path, &plen)) {
 		/* We *could* check for gssapi32.dll */
-		_tprintf(_T("found in '%s'.\n"), mit_kerberos_path);
+		wprintf(L"found in '%s'.\n", mit_kerberos_path);
 
-		if (mit_kerberos_path[_tcslen(mit_kerberos_path) - 1] != _T('\\'))
-			_tcscat(mit_kerberos_path, _T("\\"));
-		_tcscat(mit_kerberos_path, _T("bin"));
+		if (mit_kerberos_path[wcslen(mit_kerberos_path) - 1] != L'\\')
+			wcscat(mit_kerberos_path, L"\\");
+		wcscat(mit_kerberos_path, L"bin");
 
 		mpath = mit_kerberos_path;
 	} else
 		printf("%s", "not found.\n");
 
 	if (ppath != NULL || mpath != NULL) {
-		const TCHAR *path = _tgetenv(_T("PATH"));
-		BOOL add_ppath = ppath != NULL && (path == NULL || !_tcsstr(path, ppath));
-		BOOL add_mpath = mpath != NULL && (path == NULL || !_tcsstr(path, mpath));
-		TCHAR *newpath;
+		const wchar_t *path = _wgetenv(L"PATH");
+		BOOL add_ppath = ppath != NULL && (path == NULL || !wcsstr(path, ppath));
+		BOOL add_mpath = mpath != NULL && (path == NULL || !wcsstr(path, mpath));
+		wchar_t *newpath;
 		int newlen;
 
 		if (add_ppath || add_mpath) {
 			/* Enough to add "PATH=" + path + ";"  + ppath + ";" + mpath + \0 */
-			newlen = 6 + (path ? _tcslen(path) + 1 : 0);
+			newlen = 6 + (path ? wcslen(path) + 1 : 0);
 			if (add_ppath)
-				newlen += _tcslen(ppath) + 1;
+				newlen += wcslen(ppath) + 1;
 			if (add_mpath)
-				newlen += _tcslen(mpath) + 1;
-			newpath = malloc(newlen * sizeof(TCHAR));
+				newlen += wcslen(mpath) + 1;
+			newpath = malloc(newlen * sizeof(wchar_t));
 
-			_sntprintf(newpath, newlen, _T("PATH=%s%s%s%s%s%s"),
-				  path ? path : _T(""),
-				  path ? _T(";") : _T(""),
-				  add_ppath ? ppath : _T(""),
-				  add_ppath ? _T(";") : _T(""),
-				  add_mpath ? mpath : _T(""),
-				  add_mpath ? _T(";") : _T(""));
+			_snwprintf(newpath, newlen, L"PATH=%s%s%s%s%s%s",
+				  path ? path : L"",
+				  path ? L";" : L"",
+				  add_ppath ? ppath : L"",
+				  add_ppath ? L";" : L"",
+				  add_mpath ? mpath : L"",
+				  add_mpath ? L";" : L"");
 
-			_tprintf(_T("New PATH: %s\n"), newpath);
+			wprintf(L"New PATH: %s\n", newpath);
 
-			_tputenv(newpath);
+			_wputenv(newpath);
 			free(newpath);
 		}
 	}
@@ -504,7 +497,7 @@
 static BOOL winpidgin_set_running(BOOL fail_if_running) {
 	HANDLE h;
 
-	if ((h = CreateMutex(NULL, FALSE, _T("pidgin_is_running")))) {
+	if ((h = CreateMutexW(NULL, FALSE, L"pidgin_is_running"))) {
 		DWORD err = GetLastError();
 		if (err == ERROR_ALREADY_EXISTS) {
 			if (fail_if_running) {
@@ -512,14 +505,14 @@
 
 				printf("An instance of Pidgin is already running.\n");
 
-				if((msg_win = FindWindowEx(NULL, NULL, _T("WinpidginMsgWinCls"), NULL)))
+				if((msg_win = FindWindowExW(NULL, NULL, L"WinpidginMsgWinCls", NULL)))
 					if(SendMessage(msg_win, PIDGIN_WM_FOCUS_REQUEST, (WPARAM) NULL, (LPARAM) NULL))
 						return FALSE;
 
 				/* If we get here, the focus request wasn't successful */
 
-				MessageBox(NULL,
-					_T("An instance of Pidgin is already running"),
+				MessageBoxW(NULL,
+					L"An instance of Pidgin is already running",
 					NULL, MB_OK | MB_TOPMOST);
 
 				return FALSE;
@@ -555,7 +548,7 @@
 		return;
 	}
 
-	if (!(msg_win = FindWindowEx(NULL, NULL, _T("WinpidginMsgWinCls"), NULL))) {
+	if (!(msg_win = FindWindowExW(NULL, NULL, L"WinpidginMsgWinCls", NULL))) {
 		printf("Unable to find an instance of Pidgin to handle protocol message.\n");
 		return;
 	}
@@ -576,8 +569,8 @@
 	GetWindowThreadProcessId(msg_win, &pid);
 	if (!(process = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, pid))) {
 		DWORD dw = GetLastError();
-		const TCHAR *err_msg = get_win32_error_message(dw);
-		_tprintf(_T("Unable to open Pidgin process. (%u) %s\n"), (UINT) dw, err_msg);
+		const wchar_t *err_msg = get_win32_error_message(dw);
+		wprintf(L"Unable to open Pidgin process. (%u) %s\n", (UINT) dw, err_msg);
 		return;
 	}
 
@@ -591,15 +584,15 @@
 				printf("Unable to send protocol message to Pidgin instance.\n");
 		} else {
 			DWORD dw = GetLastError();
-			const TCHAR *err_msg = get_win32_error_message(dw);
-			_tprintf(_T("Unable to write to remote memory. (%u) %s\n"), (UINT) dw, err_msg);
+			const wchar_t *err_msg = get_win32_error_message(dw);
+			wprintf(L"Unable to write to remote memory. (%u) %s\n", (UINT) dw, err_msg);
 		}
 
 		VirtualFreeEx(process, remote_msg, 0, MEM_RELEASE);
 	} else {
 		DWORD dw = GetLastError();
-		const TCHAR *err_msg = get_win32_error_message(dw);
-		_tprintf(_T("Unable to allocate remote memory. (%u) %s\n"), (UINT) dw, err_msg);
+		const wchar_t *err_msg = get_win32_error_message(dw);
+		wprintf(L"Unable to allocate remote memory. (%u) %s\n", (UINT) dw, err_msg);
 	}
 
 	CloseHandle(process);
@@ -610,11 +603,11 @@
 int _stdcall
 WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance,
 		char *lpszCmdLine, int nCmdShow) {
-	TCHAR errbuf[512];
-	TCHAR pidgin_dir[MAX_PATH];
-	TCHAR exe_name[MAX_PATH];
+	wchar_t errbuf[512];
+	wchar_t pidgin_dir[MAX_PATH];
+	wchar_t exe_name[MAX_PATH];
 	HMODULE hmod;
-	TCHAR *tmp;
+	wchar_t *tmp;
 	wchar_t *wtmp;
 	int pidgin_argc;
 	char **pidgin_argv; /* This is in utf-8 */
@@ -654,7 +647,7 @@
 		 *  (_istty() doesn't work for stuff using the GUI subsystem) */
 		if (_fileno(stdout) == -1 || _fileno(stdout) == -2) {
 			LPFNATTACHCONSOLE MyAttachConsole = NULL;
-			if ((hmod = GetModuleHandle(_T("kernel32.dll")))) {
+			if ((hmod = GetModuleHandleW(L"kernel32.dll"))) {
 				MyAttachConsole =
 					(LPFNATTACHCONSOLE)
 					GetProcAddress(hmod, "AttachConsole");
@@ -676,20 +669,20 @@
 	}
 
 	/* Load exception handler if we have it */
-	if (GetModuleFileName(NULL, pidgin_dir, MAX_PATH) != 0) {
+	if (GetModuleFileNameW(NULL, pidgin_dir, MAX_PATH) != 0) {
 
 		/* primitive dirname() */
-		tmp = _tcsrchr(pidgin_dir, _T('\\'));
+		tmp = wcsrchr(pidgin_dir, L'\\');
 
 		if (tmp) {
 			HMODULE hmod;
-			tmp[0] = _T('\0');
+			tmp[0] = L'\0';
 
 			/* tmp++ will now point to the executable file name */
-			_tcscpy(exe_name, tmp + 1);
+			wcscpy(exe_name, tmp + 1);
 
-			_tcscat(pidgin_dir, _T("\\exchndl.dll"));
-			if ((hmod = LoadLibrary(pidgin_dir))) {
+			wcscat(pidgin_dir, L"\\exchndl.dll");
+			if ((hmod = LoadLibraryW(pidgin_dir))) {
 				FARPROC proc;
 				/* exchndl.dll is built without UNICODE */
 				char debug_dir[MAX_PATH];
@@ -709,8 +702,7 @@
 				proc = GetProcAddress(hmod, "SetDebugInfoDir");
 				if (proc) {
 					char *pidgin_dir_ansi = NULL;
-					tmp[0] = _T('\0');
-#ifdef _UNICODE
+					tmp[0] = L'\0';
 					i = WideCharToMultiByte(CP_ACP, 0, pidgin_dir,
 						-1, NULL, 0, NULL, NULL);
 					if (i != 0) {
@@ -722,9 +714,6 @@
 							pidgin_dir_ansi = NULL;
 						}
 					}
-#else
-					pidgin_dir_ansi = pidgin_dir;
-#endif
 					if (pidgin_dir_ansi != NULL) {
 						_snprintf(debug_dir, sizeof(debug_dir) / sizeof(char),
 							"%s\\pidgin-%s-dbgsym",
@@ -733,30 +722,28 @@
 						printf(" Setting exchndl.dll DebugInfoDir to %s\n",
 							debug_dir);
 						(proc)(debug_dir);
-#ifdef _UNICODE
 						free(pidgin_dir_ansi);
-#endif
 					}
 				}
 
 			}
 
-			tmp[0] = _T('\0');
+			tmp[0] = L'\0';
 		}
 	} else {
 		DWORD dw = GetLastError();
-		const TCHAR *err_msg = get_win32_error_message(dw);
-		_sntprintf(errbuf, 512,
-			_T("Error getting module filename.\nError: (%u) %s"),
+		const wchar_t *err_msg = get_win32_error_message(dw);
+		_snwprintf(errbuf, 512,
+			L"Error getting module filename.\nError: (%u) %s",
 			(UINT) dw, err_msg);
-		_tprintf(_T("%s\n"), errbuf);
-		MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST);
-		pidgin_dir[0] = _T('\0');
+		wprintf(L"%s\n", errbuf);
+		MessageBoxW(NULL, errbuf, NULL, MB_OK | MB_TOPMOST);
+		pidgin_dir[0] = L'\0';
 	}
 
 	/* Determine if we're running in portable mode */
 	if (wcsstr(cmdLine, L"--portable-mode")
-			|| (exe_name != NULL && _tcsstr(exe_name, _T("-portable.exe")))) {
+			|| (exe_name != NULL && wcsstr(exe_name, L"-portable.exe"))) {
 		printf("Running in PORTABLE mode.\n");
 		portable_mode = TRUE;
 	}
@@ -776,20 +763,20 @@
 			return 0;
 
 	/* Now we are ready for Pidgin .. */
-	if ((hmod = LoadLibrary(_T("pidgin.dll"))))
+	if ((hmod = LoadLibraryW(L"pidgin.dll")))
 		pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");
 
 	if (!pidgin_main) {
 		DWORD dw = GetLastError();
 		BOOL mod_not_found = (dw == ERROR_MOD_NOT_FOUND || dw == ERROR_DLL_NOT_FOUND);
-		const TCHAR *err_msg = get_win32_error_message(dw);
+		const wchar_t *err_msg = get_win32_error_message(dw);
 
-		_sntprintf(errbuf, 512, _T("Error loading pidgin.dll.\nError: (%u) %s%s%s"),
+		_snwprintf(errbuf, 512, L"Error loading pidgin.dll.\nError: (%u) %s%s%s",
 			(UINT) dw, err_msg,
-			mod_not_found ? _T("\n") : _T(""),
-			mod_not_found ? _T("This probably means that GTK+ can't be found.") : _T(""));
-		_tprintf(_T("%s\n"), errbuf);
-		MessageBox(NULL, errbuf, _T("Error"), MB_OK | MB_TOPMOST);
+			mod_not_found ? L"\n" : L"",
+			mod_not_found ? L"This probably means that GTK+ can't be found." : L"");
+		wprintf(L"%s\n", errbuf);
+		MessageBoxW(NULL, errbuf, L"Error", MB_OK | MB_TOPMOST);
 
 		return 0;
 	}
--- a/pidgin/win32/wspell.c	Thu Mar 18 22:12:08 2010 +0000
+++ b/pidgin/win32/wspell.c	Sun Mar 21 19:44:45 2010 +0000
@@ -95,41 +95,6 @@
 	SetErrorMode(old_error_mode);
 }
 
-static void lookup_aspell_path() {
-	const char *tmp;
-	gchar *aspell_path;
-
-	if ((tmp = g_getenv("PIDGIN_ASPELL_DIR")))
-		aspell_path = g_strdup(tmp);
-	else
-		aspell_path = wpurple_read_reg_string(HKEY_LOCAL_MACHINE, "Software\\Aspell", "Path");
-
-	if (aspell_path != NULL) {
-		char *tmp = g_build_filename(aspell_path, "aspell-15.dll", NULL);
-		if (g_file_test(tmp, G_FILE_TEST_EXISTS)) {
-			const char *path = g_getenv("PATH");
-			purple_debug_info("wspell", "Found Aspell in %s\n", aspell_path);
-
-			g_free(tmp);
-
-			tmp = g_strdup_printf("%s%s%s", (path ? path : ""),
-					(path ? G_SEARCHPATH_SEPARATOR_S : ""),
-					aspell_path);
-
-			g_setenv("PATH", tmp, TRUE);
-
-		} else
-			purple_debug_warning("wspell", "Couldn't find aspell-15.dll\n");
-
-		g_free(tmp);
-		g_free(aspell_path);
-	} else
-		purple_debug_warning("wspell", "Aspell installation not found (this isn't necessarily a problem)\n");
-}
-
 void winpidgin_spell_init() {
-	/* We keep doing the aspell path thing so that previously installed dictionaries still work */
-	lookup_aspell_path();
-
 	load_gtkspell();
 }