diff libpurple/protocols/irc/irc.c @ 26237:eb21f65728c0

propagate from branch 'im.pidgin.pidgin' (head bc80dc424bc7a7e274901f9124173538e5b43f41) to branch 'im.pidgin.soc.2008.yahoo' (head 42700e96e9188523e8d99406abde695abf97caf5)
author Sulabh Mahajan <sulabh@soc.pidgin.im>
date Wed, 12 Nov 2008 10:18:49 +0000
parents c204239bef48
children 125cac3e24ee 32ad012ef6ac bcad7dc4b453 6ecfc6b9667c
line wrap: on
line diff
--- a/libpurple/protocols/irc/irc.c	Wed Nov 12 10:17:38 2008 +0000
+++ b/libpurple/protocols/irc/irc.c	Wed Nov 12 10:18:49 2008 +0000
@@ -62,8 +62,6 @@
 
 PurplePlugin *_irc_plugin = NULL;
 
-static const char *status_chars = "@+%&";
-
 static void irc_view_motd(PurplePluginAction *action)
 {
 	PurpleConnection *gc = (PurpleConnection *) action->context;
@@ -360,11 +358,11 @@
 
 static gboolean do_login(PurpleConnection *gc) {
 	char *buf, *tmp = NULL;
-	char hostname[256];
+	char *hostname, *server;
+	const char *hosttmp;
 	const char *username, *realname;
 	struct irc_conn *irc = gc->proto_data;
 	const char *pass = purple_connection_get_password(gc);
-	int ret;
 
 	if (pass && *pass) {
 		buf = irc_format(irc, "vv", "PASS", pass);
@@ -375,13 +373,6 @@
 		g_free(buf);
 	}
 
-
-	ret = gethostname(hostname, sizeof(hostname));
-	hostname[sizeof(hostname) - 1] = '\0';
-	if (ret < 0 || hostname[0] == '\0') {
-		purple_debug_warning("irc", "gethostname() failed -- is your hostname set?");
-		strcpy(hostname, "localhost");
-	}
 	realname = purple_account_get_string(irc->account, "realname", "");
 	username = purple_account_get_string(irc->account, "username", "");
 
@@ -396,9 +387,29 @@
 		}
 	}
 
-	buf = irc_format(irc, "vvvv:", "USER", tmp ? tmp : username, hostname, irc->server,
-			      strlen(realname) ? realname : IRC_DEFAULT_ALIAS);
+	hosttmp = purple_get_host_name();
+	if (*hosttmp == ':') {
+		/* This is either an IPv6 address, or something which
+		 * doesn't belong here.  Either way, we need to escape
+		 * it. */
+		hostname = g_strdup_printf("0%s", hosttmp);
+	} else {
+		/* Ugly, I know. */
+		hostname = g_strdup(hosttmp);
+	}
+
+	if (*irc->server == ':') {
+		/* Same as hostname, above. */
+		server = g_strdup_printf("0%s", irc->server);
+	} else {
+		server = g_strdup(irc->server);
+	}
+
+	buf = irc_format(irc, "vvvv:", "USER", tmp ? tmp : username, hostname, server,
+	                 strlen(realname) ? realname : IRC_DEFAULT_ALIAS);
 	g_free(tmp);
+	g_free(hostname);
+	g_free(server);
 	if (irc_send(irc, buf) < 0) {
 		g_free(buf);
 		return FALSE;
@@ -505,10 +516,7 @@
 	char *plain;
 	const char *args[2];
 
-	if (strchr(status_chars, *who) != NULL)
-		args[0] = who + 1;
-	else
-		args[0] = who;
+	args[0] = irc_nick_skip_mode(irc, who);
 
 	purple_markup_html_to_xhtml(what, NULL, &plain);
 	args[1] = plain;
@@ -976,6 +984,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);