From 1c1ef05451cf3e2abd960faa45b53e0cc2d32c5c Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 12 Mar 2012 19:26:26 +0100 Subject: irc: use computed nick color in many messages instead of option weechat.color.chat_nick --- src/plugins/irc/irc-protocol.c | 153 +++++++++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 58 deletions(-) (limited to 'src/plugins/irc/irc-protocol.c') diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index bb63b5882..f24e6c558 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -500,7 +500,7 @@ IRC_PROTOCOL_CALLBACK(invite) IRC_COLOR_CHAT_CHANNEL, (argv[3][0] == ':') ? argv[3] + 1 : argv[3], IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, nick), nick, IRC_COLOR_RESET); } @@ -586,7 +586,7 @@ IRC_PROTOCOL_CALLBACK(join) nick), _("%s%s%s%s%s%s%s%s%s%s has joined %s%s%s"), weechat_prefix ("join"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_CHAT_DELIMITERS, (display_host) ? " (" : "", @@ -643,10 +643,10 @@ IRC_PROTOCOL_CALLBACK(kick) irc_protocol_tags (command, NULL, NULL), _("%s%s%s%s has kicked %s%s%s %s(%s%s%s)"), weechat_prefix ("quit"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (ptr_nick_kicked, argv[3]), + irc_nick_color_for_server_message (server, ptr_nick_kicked, argv[3]), argv[3], IRC_COLOR_MESSAGE_QUIT, IRC_COLOR_CHAT_DELIMITERS, @@ -662,10 +662,10 @@ IRC_PROTOCOL_CALLBACK(kick) irc_protocol_tags (command, NULL, NULL), _("%s%s%s%s has kicked %s%s%s"), weechat_prefix ("quit"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (ptr_nick_kicked, argv[3]), + irc_nick_color_for_server_message (server, ptr_nick_kicked, argv[3]), argv[3], IRC_COLOR_MESSAGE_QUIT); } @@ -744,7 +744,7 @@ IRC_PROTOCOL_CALLBACK(kill) _("%s%sYou were killed by %s%s%s %s(%s%s%s)"), weechat_prefix ("quit"), IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_MESSAGE_QUIT, IRC_COLOR_CHAT_DELIMITERS, @@ -761,7 +761,7 @@ IRC_PROTOCOL_CALLBACK(kill) _("%s%sYou were killed by %s%s%s"), weechat_prefix ("quit"), IRC_COLOR_MESSAGE_QUIT, - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_MESSAGE_QUIT); } @@ -862,7 +862,7 @@ IRC_PROTOCOL_CALLBACK(mode) pos_modes, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick); } else @@ -878,7 +878,7 @@ IRC_PROTOCOL_CALLBACK(mode) pos_modes, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, nick), nick); irc_mode_user_set (server, pos_modes, 0); } @@ -990,7 +990,7 @@ IRC_PROTOCOL_CALLBACK(nick) old_color : IRC_COLOR_CHAT_NICK, nick, IRC_COLOR_RESET, - irc_nick_color_for_server_message (ptr_nick, new_nick), + irc_nick_color_for_message (server, ptr_nick, new_nick), new_nick, IRC_COLOR_RESET); } @@ -1094,7 +1094,7 @@ IRC_PROTOCOL_CALLBACK(notice) _("Notice"), (notice_op) ? "Op" : ((notice_voice) ? "Voice" : ""), IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_message (server, ptr_nick, nick), (nick && nick[0]) ? nick : "?", IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -1144,7 +1144,8 @@ IRC_PROTOCOL_CALLBACK(notice) nick), "%s%s%s%s: %s", weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_message (server, NULL, + nick), nick, IRC_COLOR_RESET, pos_args); @@ -1175,7 +1176,9 @@ IRC_PROTOCOL_CALLBACK(notice) /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ _("Notice"), IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_message (server, + NULL, + pos_target), pos_target, IRC_COLOR_RESET, pos_args); @@ -1190,7 +1193,9 @@ IRC_PROTOCOL_CALLBACK(notice) nick), "%s%s%s %s(%s%s%s)%s: %s", weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_message (server, + NULL, + nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -1209,7 +1214,9 @@ IRC_PROTOCOL_CALLBACK(notice) nick), "%s%s%s%s: %s", weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_message (server, + NULL, + nick), nick, IRC_COLOR_RESET, pos_args); @@ -1295,7 +1302,7 @@ IRC_PROTOCOL_CALLBACK(part) _("%s%s%s%s%s%s%s%s%s%s has left %s%s%s " "%s(%s%s%s)"), weechat_prefix ("quit"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_CHAT_DELIMITERS, (display_host) ? " (" : "", @@ -1328,7 +1335,7 @@ IRC_PROTOCOL_CALLBACK(part) _("%s%s%s%s%s%s%s%s%s%s has left " "%s%s%s"), weechat_prefix ("quit"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_CHAT_DELIMITERS, (display_host) ? " (" : "", @@ -1635,7 +1642,7 @@ IRC_PROTOCOL_CALLBACK(quit) "%s(%s%s%s)"), weechat_prefix ("quit"), (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ? - irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_CHAT_DELIMITERS, (display_host) ? " (" : "", @@ -1665,7 +1672,7 @@ IRC_PROTOCOL_CALLBACK(quit) _("%s%s%s%s%s%s%s%s%s%s has quit"), weechat_prefix ("quit"), (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ? - irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_CHAT_DELIMITERS, (display_host) ? " (" : "", @@ -1799,7 +1806,7 @@ IRC_PROTOCOL_CALLBACK(topic) _("%s%s%s%s has changed topic for %s%s%s " "from \"%s%s%s\" to \"%s%s%s\""), weechat_prefix ("network"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, @@ -1823,7 +1830,7 @@ IRC_PROTOCOL_CALLBACK(topic) _("%s%s%s%s has changed topic for %s%s%s " "to \"%s%s%s\""), weechat_prefix ("network"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, @@ -1850,7 +1857,7 @@ IRC_PROTOCOL_CALLBACK(topic) _("%s%s%s%s has unset topic for %s%s%s " "(old topic: \"%s%s%s\")"), weechat_prefix ("network"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, @@ -1870,7 +1877,7 @@ IRC_PROTOCOL_CALLBACK(topic) irc_protocol_tags (command, NULL, NULL), _("%s%s%s%s has unset topic for %s%s%s"), weechat_prefix ("network"), - irc_nick_color_for_server_message (ptr_nick, nick), + irc_nick_color_for_server_message (server, ptr_nick, nick), nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, @@ -1907,7 +1914,7 @@ IRC_PROTOCOL_CALLBACK(wallops) irc_protocol_tags (command, NULL, nick), _("%sWallops from %s%s %s(%s%s%s)%s: %s"), weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_message (server, NULL, nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -2134,7 +2141,8 @@ IRC_PROTOCOL_CALLBACK(221) irc_protocol_tags (command, "irc_numeric", NULL), _("%sUser mode for %s%s%s is %s[%s%s%s]"), weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[2]), argv[2], IRC_COLOR_RESET, IRC_COLOR_CHAT_DELIMITERS, @@ -2187,7 +2195,9 @@ IRC_PROTOCOL_CALLBACK(301) _("%s%s[%s%s%s]%s is away: %s"), weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, + NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -2312,7 +2322,8 @@ IRC_PROTOCOL_CALLBACK(whois_nick_msg) "%s%s[%s%s%s] %s%s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -2341,7 +2352,8 @@ IRC_PROTOCOL_CALLBACK(whowas_nick_msg) "%s%s[%s%s%s] %s%s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -2370,7 +2382,8 @@ IRC_PROTOCOL_CALLBACK(311) "%s%s[%s%s%s] (%s%s@%s%s)%s: %s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -2403,7 +2416,8 @@ IRC_PROTOCOL_CALLBACK(312) "%s%s[%s%s%s] %s%s %s(%s%s%s)", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -2436,7 +2450,8 @@ IRC_PROTOCOL_CALLBACK(314) _("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"), weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -2525,7 +2540,8 @@ IRC_PROTOCOL_CALLBACK(317) "%s%s, signon at: %s%s"), weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -2557,7 +2573,8 @@ IRC_PROTOCOL_CALLBACK(317) "signon at: %s%s"), weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -2752,7 +2769,8 @@ IRC_PROTOCOL_CALLBACK(327) "%s%s[%s%s%s] %s%s %s %s(%s%s%s)", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -2770,7 +2788,8 @@ IRC_PROTOCOL_CALLBACK(327) "%s%s[%s%s%s] %s%s %s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -2895,12 +2914,14 @@ IRC_PROTOCOL_CALLBACK(330_343) "%s%s[%s%s%s] %s%s %s%s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[4]), argv[4]); } else @@ -2915,7 +2936,8 @@ IRC_PROTOCOL_CALLBACK(330_343) "%s%s[%s%s%s] %s%s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -3064,7 +3086,7 @@ IRC_PROTOCOL_CALLBACK(333) /* TRANSLATORS: "%s" after "on" is a date */ _("%sTopic set by %s%s%s%s%s%s%s%s%s on %s"), weechat_prefix ("network"), - irc_nick_color_for_server_message (ptr_nick, topic_nick), + irc_nick_color_for_server_message (server, ptr_nick, topic_nick), topic_nick, IRC_COLOR_CHAT_DELIMITERS, (topic_address && topic_address[0]) ? " (" : "", @@ -3101,7 +3123,7 @@ IRC_PROTOCOL_CALLBACK(333) IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_RESET, - irc_nick_color_for_server_message (ptr_nick, topic_nick), + irc_nick_color_for_server_message (server, ptr_nick, topic_nick), topic_nick, IRC_COLOR_CHAT_DELIMITERS, (topic_address && topic_address[0]) ? " (" : "", @@ -3151,7 +3173,8 @@ IRC_PROTOCOL_CALLBACK(338) "%s%s[%s%s%s]%s %s %s%s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, @@ -3180,10 +3203,12 @@ IRC_PROTOCOL_CALLBACK(341) irc_protocol_tags (command, "irc_numeric", NULL), _("%s%s%s%s has invited %s%s%s to %s%s%s"), weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[2]), argv[2], IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[3]), argv[3], IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, @@ -3257,17 +3282,20 @@ IRC_PROTOCOL_CALLBACK(346) struct t_irc_channel *ptr_channel; struct t_gui_buffer *ptr_buffer; time_t datetime; + const char *invite_nick, *invite_address; /* * 346 message looks like: * :server 346 mynick #channel invitemask nick!user@host 1205590879 */ - IRC_PROTOCOL_MIN_ARGS(5); + IRC_PROTOCOL_MIN_ARGS(6); ptr_channel = irc_channel_search (server, argv[3]); ptr_buffer = (ptr_channel && ptr_channel->nicks) ? ptr_channel->buffer : server->buffer; + invite_nick = irc_message_get_nick_from_host (argv[5]); + invite_address = irc_message_get_address_from_host (argv[5]); if (argc >= 7) { datetime = (time_t)(atol (argv[6])); @@ -3286,11 +3314,12 @@ IRC_PROTOCOL_CALLBACK(346) IRC_COLOR_CHAT_HOST, argv[4], IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, - irc_message_get_nick_from_host (argv[5]), + irc_nick_color_for_server_message (server, NULL, + invite_nick), + invite_nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, - irc_message_get_address_from_host (argv[5]), + invite_address, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, weechat_util_get_time_string (&datetime)); @@ -3311,11 +3340,12 @@ IRC_PROTOCOL_CALLBACK(346) IRC_COLOR_CHAT_HOST, argv[4], IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, - irc_message_get_nick_from_host (argv[5]), + irc_nick_color_for_server_message (server, NULL, + invite_nick), + invite_nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, - irc_message_get_address_from_host (argv[5]), + invite_address, IRC_COLOR_CHAT_DELIMITERS); } @@ -3371,6 +3401,7 @@ IRC_PROTOCOL_CALLBACK(348) struct t_irc_channel *ptr_channel; struct t_gui_buffer *ptr_buffer; time_t datetime; + const char *exception_nick, *exception_address; /* * 348 message looks like: @@ -3385,6 +3416,8 @@ IRC_PROTOCOL_CALLBACK(348) ptr_channel->buffer : server->buffer; if (argc >= 7) { + exception_nick = irc_message_get_nick_from_host (argv[5]); + exception_address = irc_message_get_address_from_host (argv[5]); datetime = (time_t)(atol (argv[6])); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, command, "exceptionlist", @@ -3402,11 +3435,12 @@ IRC_PROTOCOL_CALLBACK(348) IRC_COLOR_CHAT_HOST, argv[4], IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, - irc_message_get_nick_from_host (argv[5]), + irc_nick_color_for_server_message (server, NULL, + exception_nick), + exception_nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, - irc_message_get_address_from_host (argv[5]), + exception_address, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, weechat_util_get_time_string (&datetime)); @@ -3576,14 +3610,15 @@ IRC_PROTOCOL_CALLBACK(352) command, "who", NULL), irc_protocol_tags (command, "irc_numeric", NULL), - "%s%s[%s%s%s] %s%s%s(%s%s@%s%s)%s " + "%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s " "%s%s%s%s(%s)", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + argv[7]), argv[7], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -3910,7 +3945,8 @@ IRC_PROTOCOL_CALLBACK(367) IRC_COLOR_CHAT_HOST, argv[4], IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + irc_message_get_nick_from_host (argv[5])), irc_message_get_nick_from_host (argv[5]), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, @@ -3935,7 +3971,8 @@ IRC_PROTOCOL_CALLBACK(367) IRC_COLOR_CHAT_HOST, argv[4], IRC_COLOR_RESET, - IRC_COLOR_CHAT_NICK, + irc_nick_color_for_server_message (server, NULL, + irc_message_get_nick_from_host (argv[5])), irc_message_get_nick_from_host (argv[5]), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, -- cgit v1.2.3