1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 09:13:14 +02:00

irc: add option irc.look.display_join_message (task #10895)

This commit is contained in:
Sebastien Helleu
2013-03-24 13:02:26 +01:00
parent e03310cb0d
commit a08603c24c
34 changed files with 541 additions and 207 deletions
+66 -5
View File
@@ -73,6 +73,7 @@ struct t_config_option *irc_config_look_display_ctcp_unknown;
struct t_config_option *irc_config_look_display_host_join;
struct t_config_option *irc_config_look_display_host_join_local;
struct t_config_option *irc_config_look_display_host_quit;
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;
@@ -141,6 +142,7 @@ struct t_config_option *irc_config_server_default[IRC_SERVER_NUM_OPTIONS];
struct t_hook *irc_config_hook_config_nick_colors = NULL;
char **irc_config_nick_colors = NULL;
int irc_config_num_nick_colors = 0;
struct t_hashtable *irc_config_hashtable_display_join_message = NULL;
struct t_hashtable *irc_config_hashtable_nick_color_force = NULL;
struct t_hashtable *irc_config_hashtable_nick_prefixes = NULL;
struct t_hashtable *irc_config_hashtable_color_mirc_remap = NULL;
@@ -274,6 +276,45 @@ irc_config_change_look_color_nicks_in_nicklist (void *data,
irc_nick_nicklist_set_color_all ();
}
/*
* Callback for changes on option "irc.look.display_join_message".
*/
void
irc_config_change_look_display_join_message (void *data,
struct t_config_option *option)
{
char **items;
int num_items, i;
/* make C compiler happy */
(void) data;
(void) option;
if (!irc_config_hashtable_display_join_message)
{
irc_config_hashtable_display_join_message = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
}
else
weechat_hashtable_remove_all (irc_config_hashtable_display_join_message);
items = weechat_string_split (weechat_config_string (irc_config_look_display_join_message),
",", 0, 0, &num_items);
if (items)
{
for (i = 0; i < num_items; i++)
{
weechat_hashtable_set (irc_config_hashtable_display_join_message,
items[i], "1");
}
weechat_string_free_split (items);
}
}
/*
* Callback for changes on option "irc.look.server_buffer".
*/
@@ -2052,11 +2093,11 @@ irc_config_init ()
{
struct t_config_section *ptr_section;
irc_config_hashtable_color_mirc_remap = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
irc_config_hashtable_display_join_message = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
irc_config_hashtable_nick_color_force = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -2067,6 +2108,11 @@ irc_config_init ()
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
irc_config_hashtable_color_mirc_remap = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
irc_config_file = weechat_config_new (IRC_CONFIG_NAME,
&irc_config_reload, NULL);
@@ -2257,6 +2303,14 @@ irc_config_init ()
N_("display host in part/quit messages"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
irc_config_look_display_join_message = weechat_config_new_option (
irc_config_file, ptr_section,
"display_join_message", "string",
N_("comma-separated list of messages to display after joining a channel: "
"329 = channel creation date, 332 = topic, 333 = nick/date for topic, "
"366 = names on channel"),
NULL, 0, 0, "329,332,333,366", NULL, 0, NULL, NULL,
&irc_config_change_look_display_join_message, NULL, NULL, NULL);
irc_config_look_display_old_topic = weechat_config_new_option (
irc_config_file, ptr_section,
"display_old_topic", "boolean",
@@ -2754,6 +2808,7 @@ irc_config_read ()
if (rc == WEECHAT_CONFIG_READ_OK)
{
irc_notify_new_for_all_servers ();
irc_config_change_look_display_join_message (NULL, NULL);
irc_config_change_look_nick_color_force (NULL, NULL);
irc_config_change_look_nicks_hide_password (NULL, NULL);
irc_config_change_color_nick_prefixes (NULL, NULL);
@@ -2804,6 +2859,12 @@ irc_config_free ()
irc_config_num_nicks_hide_password = 0;
}
if (irc_config_hashtable_display_join_message)
{
weechat_hashtable_free (irc_config_hashtable_display_join_message);
irc_config_hashtable_display_join_message = NULL;
}
if (irc_config_hashtable_nick_color_force)
{
weechat_hashtable_free (irc_config_hashtable_nick_color_force);