changeset 11500:9fc7d0153332

[gaim-migrate @ 13745] Remove the stupid prpl option I added with the aliasing code. This fixes the remaining bug I'm aware of. It should be correct, but let me know if I've broken something (which would mostly likely be with Jabber). committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 11 Sep 2005 02:58:03 +0000
parents 6f9fc83ee25c
children 9563b768e8e2
files plugins/ChangeLog.API src/conversation.c src/gtkconv.c src/protocols/irc/irc.c src/protocols/silc/ops.c src/prpl.h
diffstat 6 files changed, 49 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Sat Sep 10 21:52:51 2005 +0000
+++ b/plugins/ChangeLog.API	Sun Sep 11 02:58:03 2005 +0000
@@ -100,8 +100,6 @@
 	* Added:   CHAT_USERS_ALIAS_COLUMN, CHAT_USERS_COLOR_COLUMN,
 	           CHAT_USERS_BUDDY_COLUMN to the list of columns for the chat
 	           user list
-	* Added:   OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS, see the prpl.h
-	           documentation if you're writing a prpl
 
 	Signals:
 	* Changed: "received-im-msg" and "received-chat-msg" to match, both
--- a/src/conversation.c	Sat Sep 10 21:52:51 2005 +0000
+++ b/src/conversation.c	Sun Sep 11 02:58:03 2005 +0000
@@ -1899,16 +1899,10 @@
 
 	if (!(flags & GAIM_MESSAGE_WHISPER)) {
 		char *str;
-		const char *nick;
 
 		str = g_strdup(gaim_normalize(account, who));
 
-		if (prpl_info->options & OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS)
-			nick = account->gc->display_name;
-		else
-			nick = account->username;
-
-		if (!g_utf8_collate(str, gaim_normalize(account, nick))) {
+		if (!strcmp(str, gaim_normalize(account, chat->nick))) {
 			flags |= GAIM_MESSAGE_SEND;
 		} else {
 			flags |= GAIM_MESSAGE_RECV;
@@ -1983,30 +1977,20 @@
 		GaimConvChatBuddyFlags flags = GPOINTER_TO_INT(fl->data);
 		const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL);
 
-		if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
-			char *tmp;
-
-			if (prpl_info->options & OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS)
-				tmp = g_strdup(gaim_normalize(conv->account, gc->display_name));
+		if (!strcmp(chat->nick, gaim_normalize(conv->account, user))) {
+			const char *alias2 = gaim_account_get_alias(conv->account);
+			if (alias2 != NULL)
+				alias = alias2;
 			else
-				tmp = g_strdup(gaim_normalize(conv->account, conv->account->username));
-
-			if (!strcmp(tmp, gaim_normalize(conv->account, user))) {
-				const char *alias2 = gaim_account_get_alias(conv->account);
-				if (alias2 != NULL)
-					alias = alias2;
-				else
-				{
-					const char *display_name = gaim_connection_get_display_name(gc);
-					if (display_name != NULL)
-						alias = display_name;
-				}
-			} else {
-				GaimBuddy *buddy;
-				if ((buddy = gaim_find_buddy(gc->account, user)) != NULL)
-					alias = gaim_buddy_get_contact_alias(buddy);
+			{
+				const char *display_name = gaim_connection_get_display_name(gc);
+				if (display_name != NULL)
+					alias = display_name;
 			}
-			g_free(tmp);
+		} else if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+			GaimBuddy *buddy;
+			if ((buddy = gaim_find_buddy(gc->account, user)) != NULL)
+				alias = gaim_buddy_get_contact_alias(buddy);
 		}
 
 		quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(),
@@ -2076,9 +2060,23 @@
 	gaim_conv_chat_set_users(chat,
 		g_list_prepend(gaim_conv_chat_get_users(chat), cb));
 
-	if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
+	if (!strcmp(chat->nick, gaim_normalize(conv->account, old_user))) {
+		const char *alias;
+
+		/* Note this for later. */
+		is_me = TRUE;
+
+		alias = gaim_account_get_alias(conv->account);
+		if (alias != NULL)
+			new_alias = alias;
+		else
+		{
+			const char *display_name = gaim_connection_get_display_name(gc);
+			if (display_name != NULL)
+				alias = display_name;
+		}
+	} else if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
 		GaimBuddy *buddy;
-
 		if ((buddy = gaim_find_buddy(gc->account, new_user)) != NULL)
 			new_alias = gaim_buddy_get_contact_alias(buddy);
 	}
@@ -2101,16 +2099,13 @@
 	else if (gaim_conv_chat_is_user_ignored(chat, new_user))
 		gaim_conv_chat_unignore(chat, new_user);
 
-	/* This should use gaim_normalize on the two values and strcmp them. */
-	if(!g_utf8_collate(old_user, chat->nick)) {
+	if (is_me)
 		gaim_conv_chat_set_nick(chat, new_user);
-		is_me = TRUE;
-	}
 
 	if (gaim_prefs_get_bool("/core/conversations/chat/show_nick_change") &&
 	    !gaim_conv_chat_is_user_ignored(chat, new_user)) {
 
-		if(is_me) {
+		if (is_me) {
 			g_snprintf(tmp, sizeof(tmp),
 					_("You are now known as %s"), new_user);
 		} else {
@@ -2347,7 +2342,7 @@
 	ops = gaim_conversation_get_ui_ops(conv);
 
 	if (ops != NULL && ops->chat_update_user != NULL)
-			ops->chat_update_user(conv, user);
+		ops->chat_update_user(conv, user);
 
 	gaim_signal_emit(gaim_conversations_get_handle(),
 					 "chat-buddy-flags", conv, user, oldflags, flags);
@@ -2374,7 +2369,7 @@
 
 	if(chat->nick)
 		g_free(chat->nick);
-	chat->nick = g_strdup(nick);
+	chat->nick = g_strdup(gaim_normalize(chat->conv->account, nick));
 }
 
 const char *gaim_conv_chat_get_nick(GaimConvChat *chat) {
--- a/src/gtkconv.c	Sat Sep 10 21:52:51 2005 +0000
+++ b/src/gtkconv.c	Sun Sep 11 02:58:03 2005 +0000
@@ -117,7 +117,7 @@
 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first);
 static GList *generate_invite_user_names(GaimConnection *gc);
 static void add_chat_buddy_common(GaimConversation *conv, const char *name,
-								  const char *alias);
+								  const char *alias, const char *old_name);
 static gboolean tab_complete(GaimConversation *conv);
 static void update_typing_icon(GaimGtkConversation *gtkconv);
 static gboolean update_send_as_selection(GaimConvWindow *win);
@@ -1470,7 +1470,7 @@
 	else
 		gaim_conv_chat_ignore(chat, name);
 
-	add_chat_buddy_common(conv, name, alias);
+	add_chat_buddy_common(conv, name, alias, NULL);
 	g_free(name);
 	g_free(alias);
 }
@@ -1554,6 +1554,7 @@
 				 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc)
 {
 	static GtkWidget *menu = NULL;
+	GaimConvChat *chat = GAIM_CONV_CHAT(conv);
 	gboolean is_me = FALSE;
 	GtkWidget *button;
 
@@ -1564,18 +1565,8 @@
 	if (menu)
 		gtk_widget_destroy(menu);
 
-	if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
-		char *tmp;
-
-		if (prpl_info->options & OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS)
-			tmp = g_strdup(gaim_normalize(conv->account, gc->display_name));
-		else
-			tmp = g_strdup(gaim_normalize(conv->account, conv->account->username));
-
-		if (!strcmp(tmp, gaim_normalize(conv->account, who)))
-			is_me = TRUE;
-		g_free(tmp);
-	}
+	if (!strcmp(chat->nick, gaim_normalize(conv->account, who)))
+		is_me = TRUE;
 
 	menu = gtk_menu_new();
 
@@ -3443,7 +3434,7 @@
 }
 
 static void
-add_chat_buddy_common(GaimConversation *conv, const char *name, const char *alias)
+add_chat_buddy_common(GaimConversation *conv, const char *name, const char *alias, const char *old_name)
 {
 	GaimGtkConversation *gtkconv;
 	GaimGtkChatPane *gtkchat;
@@ -3473,18 +3464,8 @@
 	flags = gaim_conv_chat_user_get_flags(chat, name);
 	pixbuf = get_chat_buddy_status_icon(chat, name, flags);
 
-	if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
-		char *tmp;
-		
-		if (prpl_info->options & OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS)
-			tmp = g_strdup(gaim_normalize(conv->account, gc->display_name));
-		else
-			tmp = g_strdup(gaim_normalize(conv->account, conv->account->username));
-		
-		if (!strcmp(tmp, gaim_normalize(conv->account, name)))
-			is_me = TRUE;
-		g_free(tmp);
-	}
+	if (!strcmp(chat->nick, gaim_normalize(conv->account, old_name != NULL ? old_name : name)))
+		is_me = TRUE;
 
 	is_buddy = (gaim_find_buddy(conv->account, name) != NULL);
 
@@ -3970,6 +3951,7 @@
 update_chat_alias(GaimBuddy *buddy, GaimConversation *conv, GaimConnection *gc, GaimPluginProtocolInfo *prpl_info)
 {
 	GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
+	GaimConvChat *chat = GAIM_CONV_CHAT(conv);
 	GtkTreeModel *model;
 	char *normalized_name;
 	GtkTreeIter iter;
@@ -3993,15 +3975,9 @@
 
 		if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) {
 			const char *alias = name;
-			char *tmp;
 			GaimBuddy *buddy2;
 
-			if (prpl_info->options & OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS)
-				tmp = g_strdup(gaim_normalize(conv->account, gc->display_name));
-			else
-				tmp = g_strdup(gaim_normalize(conv->account, conv->account->username));
-
-			if (strcmp(tmp, gaim_normalize(conv->account, name))) {
+			if (strcmp(chat->nick, gaim_normalize(conv->account, name))) {
 				/* This user is not me, so look into updating the alias. */
 
 				if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL)
@@ -4012,7 +3988,6 @@
 								   CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias),
 								   -1);
 			}
-			g_free(tmp);
 			g_free(name);
 			break;
 		}
@@ -4023,7 +3998,6 @@
 	} while (f != 0);
 
 	g_free(normalized_name);
-
 }
 
 static void
@@ -5487,7 +5461,7 @@
 	l = users;
 	ll = aliases;
 	while (l != NULL && ll != NULL) {
-		add_chat_buddy_common(conv, (const char *)l->data, (const char *)ll->data);
+		add_chat_buddy_common(conv, (const char *)l->data, (const char *)ll->data, NULL);
 		l = l->next;
 		ll = ll->next;
 	}
@@ -5534,7 +5508,7 @@
 
 	g_return_if_fail(new_alias != NULL);
 
-	add_chat_buddy_common(conv, new_name, new_alias);
+	add_chat_buddy_common(conv, new_name, new_alias, old_name);
 }
 
 static void
@@ -5669,7 +5643,7 @@
 		gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1);
 
 		if (!gaim_utf8_strcasecmp(user, val)) {
-			gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &alias, -1);
+			gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1);
 			gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
 			g_free(val);
 			break;
@@ -5685,7 +5659,7 @@
 
 	g_return_if_fail(alias != NULL);
 
-	add_chat_buddy_common(conv, user, alias);
+	add_chat_buddy_common(conv, user, alias, NULL);
 	g_free(alias);
 }
 
--- a/src/protocols/irc/irc.c	Sat Sep 10 21:52:51 2005 +0000
+++ b/src/protocols/irc/irc.c	Sun Sep 11 02:58:03 2005 +0000
@@ -751,7 +751,7 @@
 
 static GaimPluginProtocolInfo prpl_info =
 {
-	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL | OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS,
+	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
 	NO_BUDDY_ICONS,		/* icon_spec */
--- a/src/protocols/silc/ops.c	Sat Sep 10 21:52:51 2005 +0000
+++ b/src/protocols/silc/ops.c	Sun Sep 11 02:58:03 2005 +0000
@@ -1214,7 +1214,7 @@
 				if (!convo)
 					continue;
 				oldnick = gaim_conv_chat_get_nick(GAIM_CONV_CHAT(convo));
-				if (strcmp(oldnick, local_entry->nickname)) {
+				if (strcmp(oldnick, gaim_normalize(gaim_conversation_get_account(convo), local_entry->nickname))) {
 					gaim_conv_chat_rename_user(GAIM_CONV_CHAT(convo),
 							oldnick, local_entry->nickname);
 					gaim_conv_chat_set_nick(GAIM_CONV_CHAT(convo), local_entry->nickname);
--- a/src/prpl.h	Sat Sep 10 21:52:51 2005 +0000
+++ b/src/prpl.h	Sun Sep 11 02:58:03 2005 +0000
@@ -163,14 +163,6 @@
 	 */
 	OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
 
-	/**
-	 * Chats use the display name for "my" nickname.
-	 *
-	 * IRC uses the user's current nickname in the chat list, not the
-	 * username that's been setup for the account.
-	 */
-	OPT_PROTO_USE_DISPLAY_NAME_FOR_ME_IN_CHATS = 0x00000400
-
 } GaimProtocolOptions;
 
 /**