changeset 26709:fcd7d4c24230

Notify the user if an IRC /nick command fails, rather than trying fallbacks. This code should not come into play on initial connect, but only on /nick commands issued by the user. If it does, we'll have to try again. Fixes #5181
author Ethan Blanton <elb@pidgin.im>
date Sat, 18 Apr 2009 03:08:12 +0000
parents e5ebf3abd9f8
children f3a6f9976d9c
files ChangeLog libpurple/protocols/irc/msgs.c
diffstat 2 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Apr 18 02:52:46 2009 +0000
+++ b/ChangeLog	Sat Apr 18 03:08:12 2009 +0000
@@ -26,6 +26,9 @@
 	IRC:
 	* Correctly handle WHOIS for users who are joined to a large number of
 	  channels.
+	* Notify the user if a /nick command fails, rather than trying
+	  fallback nicks.
+	
 
 	Pidgin:
 	* Added -f command line option to tell Pidgin to ignore NetworkManager
--- a/libpurple/protocols/irc/msgs.c	Sat Apr 18 02:52:46 2009 +0000
+++ b/libpurple/protocols/irc/msgs.c	Sat Apr 18 03:08:12 2009 +0000
@@ -1004,10 +1004,23 @@
 void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	char *newnick, *buf, *end;
+	PurpleConnection *gc = purple_account_get_connection(irc->account);
 
 	if (!args || !args[1])
 		return;
 
+	if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTED) {
+		/* We only want to do the following dance if the connection
+		   has not been successfully completed.  If it has, just
+		   notify the user that their /nick command didn't go. */
+		buf = g_strdup_printf(_("The nickname \"%s\" is already being used."),
+				      irc->reqnick);
+		purple_notify_error(gc, _("Nickname in use"),
+				    _("Nickname in use"), buf);
+		g_free(buf);
+		g_free(irc->reqnick);
+	}
+
 	if (strlen(args[1]) < strlen(irc->reqnick) || irc->nickused)
 		newnick = g_strdup(args[1]);
 	else