changeset 23631:b33b5e56a482

merge of '0d858a8978355a1e8b7305b64b87db51e44e9978' and '4837767868c0defe45efc50e8d0639be2ed4ad7d'
author Ethan Blanton <elb@pidgin.im>
date Fri, 01 Aug 2008 19:45:08 +0000
parents 46cc31494ff4 (current diff) aac5753e2528 (diff)
children c6033a3031bb
files libpurple/protocols/msn/slpsession.c libpurple/protocols/msn/slpsession.h
diffstat 4 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Aug 01 07:04:25 2008 +0000
+++ b/ChangeLog	Fri Aug 01 19:45:08 2008 +0000
@@ -12,6 +12,8 @@
 
 	IRC:
 	* /ctcp command (Vladislav Guberinić)
+	* Allow for auto-detection of incoming UTF-8 formatted text on
+	  accounts which are configured to use some other encoding.
 
 	MSN:
 	* Update MSN support to protocol 15 (Elliott Sales de Andrade, Jorge
--- a/libpurple/protocols/irc/irc.c	Fri Aug 01 07:04:25 2008 +0000
+++ b/libpurple/protocols/irc/irc.c	Fri Aug 01 19:45:08 2008 +0000
@@ -989,6 +989,9 @@
 	option = purple_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
+	option = purple_account_option_bool_new(_("Auto-detect incoming UTF-8"), "autodetect_utf8", IRC_DEFAULT_AUTODETECT);
+	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
+
 	option = purple_account_option_string_new(_("Username"), "username", "");
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
--- a/libpurple/protocols/irc/irc.h	Fri Aug 01 07:04:25 2008 +0000
+++ b/libpurple/protocols/irc/irc.h	Fri Aug 01 19:45:08 2008 +0000
@@ -35,6 +35,7 @@
 #define IRC_DEFAULT_SSL_PORT 994
 
 #define IRC_DEFAULT_CHARSET "UTF-8"
+#define IRC_DEFAULT_AUTODETECT FALSE
 #define IRC_DEFAULT_ALIAS "purple"
 
 #define IRC_DEFAULT_QUIT "Leaving."
--- a/libpurple/protocols/irc/parse.c	Fri Aug 01 07:04:25 2008 +0000
+++ b/libpurple/protocols/irc/parse.c	Fri Aug 01 19:45:08 2008 +0000
@@ -253,6 +253,7 @@
 	char *utf8 = NULL;
 	const gchar *charset, *enclist;
 	gchar **encodings;
+	gboolean autodetect;
 	int i;
 
 	enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET);
@@ -263,6 +264,12 @@
 		return purple_utf8_salvage(string);
 	}
 
+	autodetect = purple_account_get_bool(irc->account, "autodetect_utf8", IRC_DEFAULT_AUTODETECT);
+
+	if (autodetect && g_utf8_validate(string, -1, NULL)) {
+		return g_strdup(string);
+	}
+
 	for (i = 0; encodings[i] != NULL; i++) {
 		charset = encodings[i];
 		while (*charset == ' ')