summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-02-01 13:31:42 -0500
committerTingPing <tingping@tingping.se>2014-02-01 13:31:42 -0500
commit0cb025ff06bff2a080e9aafbef74468721fe4cdf (patch)
treeda6a5bf635520e1bac25fad8310e167fa1677fdc /src/fe-gtk
parent604337ccc7b2ec1b6fc22885b5ef02f7bb5b2f9a (diff)
Prevent users from having the same alternate nicks
For some reason users do this and then complain when they cannot connect
when nick is in use. There are other ways for them to break it but at
least it shouldn't be on accident.
Diffstat (limited to 'src/fe-gtk')
-rw-r--r--src/fe-gtk/servlistgui.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/fe-gtk/servlistgui.c b/src/fe-gtk/servlistgui.c
index 7a9ee8a1..2244e556 100644
--- a/src/fe-gtk/servlistgui.c
+++ b/src/fe-gtk/servlistgui.c
@@ -944,6 +944,7 @@ static int
 servlist_savegui (void)
 {
 	char *sp;
+	char *nick1, *nick2;
 
 	/* check for blank username, ircd will not allow this */
 	if (gtk_entry_get_text (GTK_ENTRY (entry_guser))[0] == 0)
@@ -952,8 +953,15 @@ servlist_savegui (void)
 	/* if (gtk_entry_get_text (GTK_ENTRY (entry_greal))[0] == 0)
 		return 1; */
 
-	strcpy (prefs.hex_irc_nick1, gtk_entry_get_text (GTK_ENTRY (entry_nick1)));
-	strcpy (prefs.hex_irc_nick2, gtk_entry_get_text (GTK_ENTRY (entry_nick2)));
+	nick1 = gtk_entry_get_text (GTK_ENTRY (entry_nick1));
+	nick2 = gtk_entry_get_text (GTK_ENTRY (entry_nick2));
+
+	/* ensure unique nicknames */
+	if (!rfc_casecmp (nick1, nick2))
+		return 2;
+
+	strcpy (prefs.hex_irc_nick1, nick1);
+	strcpy (prefs.hex_irc_nick2, nick2);
 	strcpy (prefs.hex_irc_nick3, gtk_entry_get_text (GTK_ENTRY (entry_nick3)));
 	strcpy (prefs.hex_irc_user_name, gtk_entry_get_text (GTK_ENTRY (entry_guser)));
 	sp = strchr (prefs.hex_irc_user_name, ' ');
@@ -1104,12 +1112,20 @@ servlist_toggle_global_user (gboolean sensitive)
 static void
 servlist_connect_cb (GtkWidget *button, gpointer userdata)
 {
+	int servlist_err;
+
 	if (!selected_net)
 		return;
 
-	if (servlist_savegui () != 0)
+	servlist_err = servlist_savegui ();
+	if (servlist_err == 1)
+	{
+		fe_message (_("User name cannot be left blank."), FE_MSG_ERROR);
+		return;
+	}
+	else if (servlist_err == 2)
 	{
-		fe_message (_("User name and Real name cannot be left blank."), FE_MSG_ERROR);
+		fe_message (_("You must have a unique nickname for Second Choice."), FE_MSG_ERROR);
 		return;
 	}