diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-05-21 18:19:02 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-05-21 18:19:02 +0200 |
commit | 6253e3ac375b9203cf232329069cbd695a7ded5a (patch) | |
tree | b2f26302d1aa5dfab9122f8c00fe4d93bca237b8 /src/plugins/irc | |
parent | 61886d9455c1fa2d0fb428c8fc632b3d60f7fce2 (diff) | |
download | weechat-6253e3ac375b9203cf232329069cbd695a7ded5a.zip |
Add optional message in IRC private buffer when nick is back on server after a /quit
New option: "irc.look.display_pv_back" (default value is "on").
Option "irc.look.show_away_once" has been renamed to "irc.look.display_pv_away_once".
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 46 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.h | 5 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 19 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 26 | ||||
-rw-r--r-- | src/plugins/irc/irc-upgrade.c | 1 |
6 files changed, 91 insertions, 9 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index dfb6e0674..74ba350c2 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -31,6 +31,7 @@ #include "irc.h" #include "irc-channel.h" #include "irc-buffer.h" +#include "irc-color.h" #include "irc-command.h" #include "irc-config.h" #include "irc-nick.h" @@ -246,6 +247,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type, new_channel->key = NULL; new_channel->checking_away = 0; new_channel->away_message = NULL; + new_channel->has_quit_server = 0; new_channel->cycle = 0; new_channel->display_creation_date = 0; new_channel->nick_completion_reset = 0; @@ -682,6 +684,47 @@ irc_channel_autorejoin_cb (void *data, int remaining_calls) } /* + * irc_channel_display_nick_back_in_pv: display a message in pv buffer if nick + * is back and if private has flag + * "has_quit_server" + */ + +void +irc_channel_display_nick_back_in_pv (struct t_irc_server *server, + struct t_irc_nick *nick, + const char *nickname) +{ + struct t_irc_channel *ptr_channel; + + if (!server || (!nick && !nickname)) + return; + + for (ptr_channel = server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) + && ptr_channel->has_quit_server + && (strcmp (ptr_channel->name, (nick) ? nick->name : nickname) == 0)) + { + if (weechat_config_boolean (irc_config_look_display_pv_back)) + { + weechat_printf (ptr_channel->buffer, + _("%s%s%s %s(%s%s%s)%s is back on server"), + weechat_prefix ("join"), + IRC_COLOR_NICK_IN_SERVER_MESSAGE(nick), + (nick) ? nick->name : nickname, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + (nick) ? nick->host : "", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_MESSAGE_JOIN); + } + ptr_channel->has_quit_server = 0; + } + } +} + +/* * irc_channel_free: free a channel and remove it from channels list */ @@ -801,6 +844,8 @@ irc_channel_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_string (ptr_item, "away_message", channel->away_message)) return 0; + if (!weechat_infolist_new_var_integer (ptr_item, "has_quit_server", channel->has_quit_server)) + return 0; if (!weechat_infolist_new_var_integer (ptr_item, "cycle", channel->cycle)) return 0; if (!weechat_infolist_new_var_integer (ptr_item, "display_creation_date", channel->display_creation_date)) @@ -869,6 +914,7 @@ irc_channel_print_log (struct t_irc_channel *channel) weechat_log_printf (" key. . . . . . . . . . . : '%s'", channel->key); weechat_log_printf (" checking_away. . . . . . : %d", channel->checking_away); weechat_log_printf (" away_message . . . . . . : '%s'", channel->away_message); + weechat_log_printf (" has_quit_server. . . . . : %d", channel->has_quit_server); weechat_log_printf (" cycle. . . . . . . . . . : %d", channel->cycle); weechat_log_printf (" display_creation_date. . : %d", channel->display_creation_date); weechat_log_printf (" nick_completion_reset. . : %d", channel->nick_completion_reset); diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h index 38d5bb933..00d4191ec 100644 --- a/src/plugins/irc/irc-channel.h +++ b/src/plugins/irc/irc-channel.h @@ -49,6 +49,8 @@ struct t_irc_channel char *key; /* channel key (NULL if no key set) */ int checking_away; /* = 1 if checking away with WHO cmd */ char *away_message; /* to display away only once in pv */ + int has_quit_server; /* =1 if nick has quit (pv only), to */ + /* display message when he's back */ int cycle; /* currently cycling (/part + /join) */ int display_creation_date; /* 1 for displaying creation date */ int nick_completion_reset; /* 1 for resetting nick completion */ @@ -112,6 +114,9 @@ extern void irc_channel_nick_speaking_time_rename (struct t_irc_channel *channel extern void irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel); extern int irc_channel_autorejoin_cb (void *data, int remaining_calls); +extern void irc_channel_display_nick_back_in_pv (struct t_irc_server *server, + struct t_irc_nick *nick, + const char *nickname); extern int irc_channel_add_to_infolist (struct t_infolist *infolist, struct t_irc_channel *channel); extern void irc_channel_print_log (struct t_irc_channel *channel); diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 18037a3a9..1501c3f3b 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -61,6 +61,8 @@ struct t_config_option *irc_config_look_display_ctcp_blocked; struct t_config_option *irc_config_look_display_ctcp_reply; struct t_config_option *irc_config_look_display_ctcp_unknown; 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_item_channel_modes; struct t_config_option *irc_config_look_item_channel_modes_hide_key; struct t_config_option *irc_config_look_item_nick_modes; @@ -72,7 +74,6 @@ struct t_config_option *irc_config_look_msgbuffer_fallback; struct t_config_option *irc_config_look_notice_as_pv; struct t_config_option *irc_config_look_part_closes_buffer; struct t_config_option *irc_config_look_raw_messages; -struct t_config_option *irc_config_look_show_away_once; struct t_config_option *irc_config_look_smart_filter; struct t_config_option *irc_config_look_smart_filter_delay; struct t_config_option *irc_config_look_smart_filter_join; @@ -1486,6 +1487,17 @@ irc_config_init () N_("display old topic when channel topic is changed"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_display_pv_away_once = weechat_config_new_option ( + irc_config_file, ptr_section, + "display_pv_away_once", "boolean", + N_("display remote away message only once in private"), + NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_display_pv_back = weechat_config_new_option ( + irc_config_file, ptr_section, + "display_pv_back", "boolean", + N_("display a message in private when user is back (after quit on " + "server)"), + NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_item_channel_modes = weechat_config_new_option ( irc_config_file, ptr_section, "item_channel_modes", "boolean", @@ -1544,11 +1556,6 @@ irc_config_init () N_("number of IRC raw messages to save in memory when raw data buffer " "is closed (messages will be displayed when opening raw data buffer)"), NULL, 0, 65535, "256", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_show_away_once = weechat_config_new_option ( - irc_config_file, ptr_section, - "show_away_once", "boolean", - N_("show remote away message only once in private"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter = weechat_config_new_option ( irc_config_file, ptr_section, "smart_filter", "boolean", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index b73e79417..aa1cd619b 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -81,6 +81,8 @@ extern struct t_config_option *irc_config_look_display_ctcp_blocked; extern struct t_config_option *irc_config_look_display_ctcp_reply; extern struct t_config_option *irc_config_look_display_ctcp_unknown; 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_item_channel_modes; extern struct t_config_option *irc_config_look_item_channel_modes_hide_key; extern struct t_config_option *irc_config_look_item_nick_modes; @@ -92,7 +94,6 @@ extern struct t_config_option *irc_config_look_msgbuffer_fallback; extern struct t_config_option *irc_config_look_notice_as_pv; extern struct t_config_option *irc_config_look_part_closes_buffer; extern struct t_config_option *irc_config_look_raw_messages; -extern struct t_config_option *irc_config_look_show_away_once; extern struct t_config_option *irc_config_look_smart_filter; extern struct t_config_option *irc_config_look_smart_filter_delay; extern struct t_config_option *irc_config_look_smart_filter_join; diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 9de40246b..b562ffe70 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -603,6 +603,10 @@ IRC_PROTOCOL_CALLBACK(join) IRC_COLOR_CHAT_CHANNEL, pos_channel, IRC_COLOR_MESSAGE_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); } return WEECHAT_RC_OK; @@ -873,7 +877,7 @@ IRC_PROTOCOL_CALLBACK(mode) IRC_PROTOCOL_CALLBACK(nick) { struct t_irc_channel *ptr_channel; - struct t_irc_nick *ptr_nick; + struct t_irc_nick *ptr_nick, *ptr_nick_found; char *new_nick, *old_color, *buffer_name; int local_nick; @@ -889,6 +893,8 @@ IRC_PROTOCOL_CALLBACK(nick) local_nick = (strcmp (nick, server->nick) == 0) ? 1 : 0; + ptr_nick_found = NULL; + for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { @@ -918,6 +924,8 @@ IRC_PROTOCOL_CALLBACK(nick) ptr_nick = irc_nick_search (ptr_channel, nick); if (ptr_nick) { + ptr_nick_found = ptr_nick; + /* temporary disable hotlist */ weechat_buffer_set (NULL, "hotlist", "-"); @@ -971,6 +979,8 @@ IRC_PROTOCOL_CALLBACK(nick) if (local_nick) irc_server_set_nick (server, new_nick); + else + irc_channel_display_nick_back_in_pv (server, ptr_nick_found, new_nick); return WEECHAT_RC_OK; } @@ -1079,6 +1089,11 @@ IRC_PROTOCOL_CALLBACK(notice) irc_nick_as_prefix (NULL, nick, irc_nick_color_for_pv (ptr_channel, nick)), pos_args); + if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) + && ptr_channel->has_quit_server) + { + ptr_channel->has_quit_server = 0; + } } else { @@ -1451,6 +1466,9 @@ IRC_PROTOCOL_CALLBACK(privmsg) IRC_COLOR_CHAT_NICK_SELF : irc_nick_color_for_pv (ptr_channel, nick)), pos_args); + if (ptr_channel->has_quit_server) + ptr_channel->has_quit_server = 0; + weechat_hook_signal_send ("irc_pv", WEECHAT_HOOK_SIGNAL_STRING, argv_eol[0]); @@ -1503,6 +1521,10 @@ IRC_PROTOCOL_CALLBACK(quit) && (weechat_config_boolean (irc_config_look_smart_filter_quit))) ? irc_channel_nick_speaking_time_search (ptr_channel, nick, 1) : NULL; } + if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) + { + ptr_channel->has_quit_server = 1; + } if (pos_comment && pos_comment[0]) { weechat_printf_tags (ptr_channel->buffer, @@ -1933,7 +1955,7 @@ IRC_PROTOCOL_CALLBACK(301) /* look for private buffer to display message */ ptr_channel = irc_channel_search (server, argv[3]); - if (!weechat_config_boolean (irc_config_look_show_away_once) + if (!weechat_config_boolean (irc_config_look_display_pv_away_once) || !ptr_channel || !(ptr_channel->away_message) || (strcmp (ptr_channel->away_message, pos_away_msg) != 0)) diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index e61f7e1ca..35ac6c2fb 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -297,6 +297,7 @@ irc_upgrade_read_cb (void *data, str = weechat_infolist_string (infolist, "away_message"); if (str) irc_upgrade_current_channel->away_message = strdup (str); + irc_upgrade_current_channel->has_quit_server = weechat_infolist_integer (infolist, "has_quit_server"); irc_upgrade_current_channel->cycle = weechat_infolist_integer (infolist, "cycle"); irc_upgrade_current_channel->display_creation_date = weechat_infolist_integer (infolist, "display_creation_date"); irc_upgrade_current_channel->nick_completion_reset = weechat_infolist_integer (infolist, "nick_completion_reset"); |