mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 16:53:14 +02:00
irc: add option irc.look.display_pv_warning_address (closes #892)
If the address of remote nick changes in a private buffer, a warning is displayed.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user