summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-color.c8
-rw-r--r--src/plugins/irc/irc-protocol.c19
-rw-r--r--src/plugins/irc/irc-server.c10
3 files changed, 25 insertions, 12 deletions
diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c
index 044e78081..e2b10e0e8 100644
--- a/src/plugins/irc/irc-color.c
+++ b/src/plugins/irc/irc-color.c
@@ -60,7 +60,6 @@ char *irc_color_to_weechat[IRC_NUM_COLORS] =
char *
irc_color_decode (const char *string, int keep_colors)
{
- char *string_without_weechat_colors;
unsigned char *out, *ptr_string;
int out_length, length, out_pos;
char str_fg[3], str_bg[3], str_color[128];
@@ -76,9 +75,7 @@ irc_color_decode (const char *string, int keep_colors)
italic = 0;
underline = 0;
- string_without_weechat_colors = weechat_string_remove_color (string, "?");
- ptr_string = (string_without_weechat_colors) ?
- (unsigned char *)string_without_weechat_colors : (unsigned char *)string;
+ ptr_string = (unsigned char *)string;
out[0] = '\0';
while (ptr_string && ptr_string[0])
{
@@ -196,9 +193,6 @@ irc_color_decode (const char *string, int keep_colors)
}
}
- if (string_without_weechat_colors)
- free (string_without_weechat_colors);
-
return (char *)out;
}
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index dbca108fd..7fa8cb446 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -3311,7 +3311,7 @@ int
irc_protocol_cmd_332 (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
- char *pos_topic;
+ char *pos_topic, *topic_no_color, *topic_color;
struct t_irc_channel *ptr_channel;
struct t_gui_buffer *ptr_buffer;
@@ -3327,12 +3327,19 @@ irc_protocol_cmd_332 (struct t_irc_server *server, const char *command,
if (ptr_channel && ptr_channel->nicks)
{
- irc_channel_set_topic (ptr_channel, pos_topic);
+ topic_no_color = (weechat_config_boolean (irc_config_network_colors_receive)) ?
+ NULL : irc_color_decode (pos_topic, 0);
+ irc_channel_set_topic (ptr_channel,
+ (topic_no_color) ? topic_no_color : pos_topic);
+ if (topic_no_color)
+ free (topic_no_color);
ptr_buffer = ptr_channel->buffer;
}
else
ptr_buffer = server->buffer;
-
+
+ topic_color = irc_color_decode (pos_topic,
+ (weechat_config_boolean (irc_config_network_colors_receive)) ? 1 : 0);
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sTopic for %s%s%s is \"%s%s\""),
@@ -3341,8 +3348,10 @@ irc_protocol_cmd_332 (struct t_irc_server *server, const char *command,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
- pos_topic,
+ (topic_color) ? topic_color : pos_topic,
IRC_COLOR_CHAT);
+ if (topic_color)
+ free (topic_color);
return WEECHAT_RC_OK;
}
@@ -4387,7 +4396,7 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line,
{ "329", /* channel creation date */ 1, &irc_protocol_cmd_329 },
{ "330", /* is logged in as */ 1, &irc_protocol_cmd_330 },
{ "331", /* no topic for channel */ 1, &irc_protocol_cmd_331 },
- { "332", /* topic of channel */ 1, &irc_protocol_cmd_332 },
+ { "332", /* topic of channel */ 0, &irc_protocol_cmd_332 },
{ "333", /* infos about topic (nick and date changed) */ 1, &irc_protocol_cmd_333 },
{ "338", /* whois (host) */ 1, &irc_protocol_cmd_338 },
{ "341", /* inviting */ 1, &irc_protocol_cmd_341 },
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index b7746b1d0..ff8692347 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -1287,6 +1287,7 @@ void
irc_server_msgq_add_msg (struct t_irc_server *server, const char *msg)
{
struct t_irc_message *message;
+ char *data_without_weechat_colors;
if (!server->unterminated_message && !msg[0])
return;
@@ -1322,6 +1323,15 @@ irc_server_msgq_add_msg (struct t_irc_server *server, const char *msg)
}
else
message->data = strdup (msg);
+
+ /* replace WeeChat internal color codes by "?" */
+ data_without_weechat_colors = weechat_string_remove_color (message->data, "?");
+ if (data_without_weechat_colors)
+ {
+ free (message->data);
+ message->data = data_without_weechat_colors;
+ }
+
message->next_message = NULL;
if (irc_msgq_last_msg)