diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 46 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.h | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 8 |
5 files changed, 67 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index deee971b5..a67358cbe 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -569,11 +569,57 @@ irc_channel_set_buffer_title (struct t_irc_channel *channel) void irc_channel_set_topic (struct t_irc_channel *channel, const char *topic) { + int display_warning; + + /* + * display a warning in the private buffer if the address of remote + * nick has changed (that means you may talk to someone else!) + */ + display_warning = ( + (channel->type == IRC_CHANNEL_TYPE_PRIVATE) + && weechat_config_boolean (irc_config_look_display_pv_warning_address) + && channel->topic && channel->topic[0] + && topic && topic[0] + && (strcmp (channel->topic, topic) != 0)); + if (channel->topic) free (channel->topic); channel->topic = (topic) ? strdup (topic) : NULL; irc_channel_set_buffer_title (channel); + + if (display_warning) + { + weechat_printf_date_tags ( + channel->buffer, + 0, + "no_log,warning_nick_address", + _("%sWarning: the address of remote nick has changed"), + weechat_prefix ("error")); + } +} + +/* + * Sets topic of all private buffers with a nick. + */ + +void +irc_channel_set_topic_private_buffers (struct t_irc_server *server, + struct t_irc_nick *nick, + const char *nickname, + const char *topic) +{ + struct t_irc_channel *ptr_channel; + + for (ptr_channel = server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) + && (irc_server_strcasecmp (server, ptr_channel->name, (nick) ? nick->name : nickname) == 0)) + { + irc_channel_set_topic (ptr_channel, topic); + } + } } /* diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h index 0e75ccbed..78dea65cd 100644 --- a/src/plugins/irc/irc-channel.h +++ b/src/plugins/irc/irc-channel.h @@ -103,6 +103,10 @@ extern void irc_channel_add_nicklist_groups (struct t_irc_server *server, extern void irc_channel_set_buffer_title (struct t_irc_channel *channel); extern void irc_channel_set_topic (struct t_irc_channel *channel, const char *topic); +extern void irc_channel_set_topic_private_buffers (struct t_irc_server *server, + struct t_irc_nick *nick, + const char *nickname, + const char *topic); extern void irc_channel_set_modes (struct t_irc_channel *channel, const char *modes); extern void irc_channel_free (struct t_irc_server *server, diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 6943f0a5e..dd18a268c 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -70,6 +70,7 @@ struct t_config_option *irc_config_look_display_join_message; struct t_config_option *irc_config_look_display_old_topic; struct t_config_option *irc_config_look_display_pv_away_once; struct t_config_option *irc_config_look_display_pv_back; +struct t_config_option *irc_config_look_display_pv_warning_address; struct t_config_option *irc_config_look_highlight_channel; struct t_config_option *irc_config_look_highlight_pv; struct t_config_option *irc_config_look_highlight_server; @@ -2825,6 +2826,13 @@ irc_config_init () "server)"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_display_pv_warning_address = weechat_config_new_option ( + irc_config_file, ptr_section, + "display_pv_warning_address", "boolean", + N_("display a warning in private buffer if the address of remote nick " + "has changed"), + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_highlight_channel = weechat_config_new_option ( irc_config_file, ptr_section, "highlight_channel", "string", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index ad2099aaf..d8712e362 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -110,6 +110,7 @@ extern struct t_config_option *irc_config_look_display_join_message; extern struct t_config_option *irc_config_look_display_old_topic; extern struct t_config_option *irc_config_look_display_pv_away_once; extern struct t_config_option *irc_config_look_display_pv_back; +extern struct t_config_option *irc_config_look_display_pv_warning_address; extern struct t_config_option *irc_config_look_highlight_channel; extern struct t_config_option *irc_config_look_highlight_pv; extern struct t_config_option *irc_config_look_highlight_server; diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index a5566c4cc..cf741c873 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1244,7 +1244,11 @@ IRC_PROTOCOL_CALLBACK(join) /* display message in private if private has flag "has_quit_server" */ if (!local_join) + { irc_channel_display_nick_back_in_pv (server, ptr_nick, nick); + irc_channel_set_topic_private_buffers (server, ptr_nick, nick, + address); + } } if (local_join) @@ -1717,7 +1721,11 @@ IRC_PROTOCOL_CALLBACK(nick) } if (!local_nick) + { irc_channel_display_nick_back_in_pv (server, ptr_nick_found, new_nick); + irc_channel_set_topic_private_buffers (server, ptr_nick_found, + new_nick, address); + } return WEECHAT_RC_OK; } |