diff options
Diffstat (limited to 'src/plugins/irc/irc-config.c')
-rw-r--r-- | src/plugins/irc/irc-config.c | 296 |
1 files changed, 170 insertions, 126 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 891571829..81c4742ab 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -103,6 +103,7 @@ struct t_config_option *irc_config_look_smart_filter_join_unmask; struct t_config_option *irc_config_look_smart_filter_mode; struct t_config_option *irc_config_look_smart_filter_nick; struct t_config_option *irc_config_look_smart_filter_quit; +struct t_config_option *irc_config_look_temporary_servers; struct t_config_option *irc_config_look_topic_strip_colors; /* IRC config, color section */ @@ -242,9 +243,11 @@ irc_config_set_nick_colors () } irc_config_nick_colors = - weechat_string_split (weechat_config_string (weechat_config_get ("weechat.color.chat_nick_colors")), - ",", 0, 0, - &irc_config_num_nick_colors); + weechat_string_split ( + weechat_config_string ( + weechat_config_get ("weechat.color.chat_nick_colors")), + ",", 0, 0, + &irc_config_num_nick_colors); } /* @@ -337,17 +340,19 @@ irc_config_change_look_display_join_message (void *data, 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); + 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); + 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++) @@ -519,16 +524,18 @@ irc_config_change_look_highlight_tags_restrict (void *data, { if (ptr_server->buffer) { - weechat_buffer_set (ptr_server->buffer, "highlight_tags_restrict", - weechat_config_string (irc_config_look_highlight_tags_restrict)); + weechat_buffer_set ( + ptr_server->buffer, "highlight_tags_restrict", + weechat_config_string (irc_config_look_highlight_tags_restrict)); } for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { if (ptr_channel->buffer) { - weechat_buffer_set (ptr_channel->buffer, "highlight_tags_restrict", - weechat_config_string (irc_config_look_highlight_tags_restrict)); + weechat_buffer_set ( + ptr_channel->buffer, "highlight_tags_restrict", + weechat_config_string (irc_config_look_highlight_tags_restrict)); } } } @@ -551,17 +558,19 @@ irc_config_change_look_nick_color_force (void *data, if (!irc_config_hashtable_nick_color_force) { - irc_config_hashtable_nick_color_force = 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, + NULL, + NULL); } else weechat_hashtable_remove_all (irc_config_hashtable_nick_color_force); - items = weechat_string_split (weechat_config_string (irc_config_look_nick_color_force), - ";", 0, 0, &num_items); + items = weechat_string_split ( + weechat_config_string (irc_config_look_nick_color_force), + ";", 0, 0, &num_items); if (items) { for (i = 0; i < num_items; i++) @@ -637,9 +646,9 @@ irc_config_change_look_nicks_hide_password (void *data, nicks_hide_password = weechat_config_string (irc_config_look_nicks_hide_password); if (nicks_hide_password && nicks_hide_password[0]) { - irc_config_nicks_hide_password = weechat_string_split (nicks_hide_password, - ",", 0, 0, - &irc_config_num_nicks_hide_password); + irc_config_nicks_hide_password = weechat_string_split ( + nicks_hide_password, ",", 0, 0, + &irc_config_num_nicks_hide_password); } } @@ -651,11 +660,23 @@ void irc_config_change_look_topic_strip_colors (void *data, struct t_config_option *option) { + struct t_irc_server *ptr_server; + struct t_irc_channel *ptr_channel; + /* make C compiler happy */ (void) data; (void) option; - weechat_bar_item_update ("buffer_title"); + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + for (ptr_channel = ptr_server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if (ptr_channel->buffer) + irc_channel_set_buffer_title (ptr_channel); + } + } } /* @@ -751,17 +772,19 @@ irc_config_change_color_mirc_remap (void *data, struct t_config_option *option) if (!irc_config_hashtable_color_mirc_remap) { - irc_config_hashtable_color_mirc_remap = weechat_hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + irc_config_hashtable_color_mirc_remap = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); } else weechat_hashtable_remove_all (irc_config_hashtable_color_mirc_remap); - items = weechat_string_split (weechat_config_string (irc_config_color_mirc_remap), - ";", 0, 0, &num_items); + items = weechat_string_split ( + weechat_config_string (irc_config_color_mirc_remap), + ";", 0, 0, &num_items); if (items) { for (i = 0; i < num_items; i++) @@ -796,17 +819,19 @@ irc_config_change_color_nick_prefixes (void *data, if (!irc_config_hashtable_nick_prefixes) { - irc_config_hashtable_nick_prefixes = weechat_hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + irc_config_hashtable_nick_prefixes = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); } else weechat_hashtable_remove_all (irc_config_hashtable_nick_prefixes); - items = weechat_string_split (weechat_config_string (irc_config_color_nick_prefixes), - ";", 0, 0, &num_items); + items = weechat_string_split ( + weechat_config_string (irc_config_color_nick_prefixes), + ";", 0, 0, &num_items); if (items) { for (i = 0; i < num_items; i++) @@ -1056,7 +1081,8 @@ irc_config_server_check_value_cb (void *data, { while (weechat_infolist_next (infolist)) { - proxy_name = weechat_infolist_string (infolist, "name"); + proxy_name = weechat_infolist_string (infolist, + "name"); if (proxy_name && (strcmp (value, proxy_name) == 0)) { proxy_found = 1; @@ -1067,12 +1093,11 @@ irc_config_server_check_value_cb (void *data, } if (!proxy_found) { - weechat_printf (NULL, - _("%s%s: warning: proxy \"%s\" does not " - "exist (you can create it with command " - "/proxy)"), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - value); + weechat_printf ( + NULL, + _("%s%s: warning: proxy \"%s\" does not exist " + "(you can create it with command /proxy)"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, value); } } break; @@ -1080,18 +1105,19 @@ irc_config_server_check_value_cb (void *data, pos_error = irc_config_check_gnutls_priorities (value); if (pos_error) { - weechat_printf (NULL, - _("%s%s: invalid priorities string, error " - "at this position in string: \"%s\""), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - pos_error); + weechat_printf ( + NULL, + _("%s%s: invalid priorities string, error at this " + "position in string: \"%s\""), + weechat_prefix ("error"), IRC_PLUGIN_NAME, pos_error); return 0; } break; case IRC_SERVER_OPTION_SSL_FINGERPRINT: if (value && value[0] && (strlen (value) != 40)) { - fingerprints = weechat_string_split (value, ",", 0, 0, NULL); + fingerprints = weechat_string_split (value, ",", 0, 0, + NULL); if (fingerprints) { rc = 1; @@ -1106,12 +1132,11 @@ irc_config_server_check_value_cb (void *data, weechat_string_free_split (fingerprints); if (!rc) { - weechat_printf (NULL, - _("%s%s: fingerprint must have " - "exactly 40 hexadecimal " - "digits"), - weechat_prefix ("error"), - IRC_PLUGIN_NAME); + weechat_printf ( + NULL, + _("%s%s: fingerprint must have exactly 40 " + "hexadecimal digits"), + weechat_prefix ("error"), IRC_PLUGIN_NAME); return 0; } } @@ -1144,14 +1169,16 @@ irc_config_server_change_cb (void *data, struct t_config_option *option) switch (index_option) { case IRC_SERVER_OPTION_ADDRESSES: - irc_server_set_addresses (ptr_server, - IRC_SERVER_OPTION_STRING(ptr_server, - IRC_SERVER_OPTION_ADDRESSES)); + irc_server_set_addresses ( + ptr_server, + IRC_SERVER_OPTION_STRING(ptr_server, + IRC_SERVER_OPTION_ADDRESSES)); break; case IRC_SERVER_OPTION_NICKS: - irc_server_set_nicks (ptr_server, - IRC_SERVER_OPTION_STRING(ptr_server, - IRC_SERVER_OPTION_NICKS)); + irc_server_set_nicks ( + ptr_server, + IRC_SERVER_OPTION_STRING(ptr_server, + IRC_SERVER_OPTION_NICKS)); break; case IRC_SERVER_OPTION_AWAY_CHECK: case IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS: @@ -1234,12 +1261,13 @@ irc_config_reload (void *data, struct t_config_file *config_file) { if (ptr_server->is_connected) { - weechat_printf (NULL, - _("%s%s: warning: server \"%s\" not found " - "in configuration file, not deleted in " - "memory because it's currently used"), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - ptr_server->name); + weechat_printf ( + NULL, + _("%s%s: warning: server \"%s\" not found in " + "configuration file, not deleted in memory because it's " + "currently used"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + ptr_server->name); } else irc_server_free (ptr_server); @@ -1295,7 +1323,8 @@ irc_config_msgbuffer_create_option (void *data, "weechat|server|current|private", 0, 0, value, value, 0, NULL, NULL, NULL, NULL, NULL, NULL); rc = (ptr_option) ? - WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; + WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : + WEECHAT_CONFIG_OPTION_SET_ERROR; } else rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE; @@ -1304,10 +1333,10 @@ irc_config_msgbuffer_create_option (void *data, if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR) { - weechat_printf (NULL, - _("%s%s: error creating \"%s\" => \"%s\""), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - option_name, value); + weechat_printf ( + NULL, + _("%s%s: error creating \"%s\" => \"%s\""), + weechat_prefix ("error"), IRC_PLUGIN_NAME, option_name, value); } return rc; @@ -1374,7 +1403,8 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file, NULL, 0, 0, default_value, value, 0, NULL, NULL, NULL, NULL, NULL, NULL); rc = (ptr_option) ? - WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; + WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : + WEECHAT_CONFIG_OPTION_SET_ERROR; } else rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE; @@ -1383,10 +1413,10 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file, if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR) { - weechat_printf (NULL, - _("%s%s: error creating CTCP \"%s\" => \"%s\""), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - option_name, value); + weechat_printf ( + NULL, + _("%s%s: error creating CTCP \"%s\" => \"%s\""), + weechat_prefix ("error"), IRC_PLUGIN_NAME, option_name, value); } return rc; @@ -1540,7 +1570,8 @@ irc_config_server_new_option (struct t_config_file *config_file, new_option = weechat_config_new_option ( config_file, section, option_name, "string", - N_("list of hostname/port or IP/port for server (separated by comma)"), + N_("list of hostname/port or IP/port for server (separated by " + "comma)"), NULL, 0, 0, default_value, value, null_value_allowed, @@ -1552,8 +1583,8 @@ irc_config_server_new_option (struct t_config_file *config_file, new_option = weechat_config_new_option ( config_file, section, option_name, "string", - N_("name of proxy used for this server (optional, proxy must be " - "defined with command /proxy)"), + N_("name of proxy used for this server (optional, proxy must " + "be defined with command /proxy)"), NULL, 0, 0, default_value, value, null_value_allowed, @@ -1619,7 +1650,8 @@ irc_config_server_new_option (struct t_config_file *config_file, new_option = weechat_config_new_option ( config_file, section, option_name, "integer", - N_("size of the key used during the Diffie-Hellman Key Exchange"), + N_("size of the key used during the Diffie-Hellman Key " + "Exchange"), NULL, 0, INT_MAX, default_value, value, null_value_allowed, @@ -1676,8 +1708,8 @@ irc_config_server_new_option (struct t_config_file *config_file, /* TRANSLATORS: please keep words "client capabilities" between brackets if translation is different (see fr.po) */ N_("comma-separated list of client capabilities to enable for " "server if they are available; capabilities supported by " - "WeeChat are: away-notify, multi-prefix, server-time, " - "userhost-in-names, (example: " + "WeeChat are: away-notify, extended-join, multi-prefix, " + "server-time, userhost-in-names (example: " "\"away-notify,multi-prefix\")"), NULL, 0, 0, default_value, value, @@ -1768,7 +1800,8 @@ irc_config_server_new_option (struct t_config_file *config_file, new_option = weechat_config_new_option ( config_file, section, option_name, "integer", - N_("delay (in seconds) before trying again to reconnect to server"), + N_("delay (in seconds) before trying again to reconnect to " + "server"), NULL, 1, 65535, default_value, value, null_value_allowed, @@ -2077,21 +2110,21 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file, { for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++) { - weechat_config_option_set (ptr_server->options[i], - NULL, 1); + weechat_config_option_set ( + ptr_server->options[i], NULL, 1); } ptr_server->reloaded_from_config = 1; } - rc = weechat_config_option_set (ptr_server->options[index_option], - value, 1); + rc = weechat_config_option_set ( + ptr_server->options[index_option], value, 1); } else { - weechat_printf (NULL, - _("%s%s: error creating server " - "\"%s\""), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - server_name); + weechat_printf ( + NULL, + _("%s%s: error creating server \"%s\""), + weechat_prefix ("error"), IRC_PLUGIN_NAME, + server_name); } } free (server_name); @@ -2101,10 +2134,10 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file, if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR) { - weechat_printf (NULL, - _("%s%s: error creating server option \"%s\""), - weechat_prefix ("error"), IRC_PLUGIN_NAME, - option_name); + weechat_printf ( + NULL, + _("%s%s: error creating server option \"%s\""), + weechat_prefix ("error"), IRC_PLUGIN_NAME, option_name); } return rc; @@ -2235,26 +2268,30 @@ irc_config_init () { struct t_config_section *ptr_section; - 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, - NULL, - NULL); - irc_config_hashtable_nick_prefixes = weechat_hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - 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_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, + NULL, + NULL); + irc_config_hashtable_nick_prefixes = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + 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); @@ -2519,9 +2556,9 @@ irc_config_init () irc_config_look_nick_color_hash = weechat_config_new_option ( irc_config_file, ptr_section, "nick_color_hash", "integer", - N_("hash algorithm used to find the color for a nick: djb2 = variant of " - "djb2 (position of letters matters: anagrams of a nick have different " - "color), sum = sum of letters"), + N_("hash algorithm used to find the color for a nick: djb2 = variant " + "of djb2 (position of letters matters: anagrams of a nick have " + "different color), sum = sum of letters"), "djb2|sum", 0, 0, "sum", NULL, 0, NULL, NULL, &irc_config_change_look_nick_colors, NULL, NULL, NULL); irc_config_look_nick_color_stop_chars = weechat_config_new_option ( @@ -2555,7 +2592,7 @@ irc_config_init () N_("display a space if nick mode is enabled but nick has no mode (not " "op, voice, ...)"), NULL, 0, 0, "off", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + &irc_config_change_bar_item_input_prompt, NULL, NULL, NULL); irc_config_look_notice_as_pv = weechat_config_new_option ( irc_config_file, ptr_section, "notice_as_pv", "integer", @@ -2678,6 +2715,12 @@ irc_config_init () /* TRANSLATORS: please do not translate "part" and "quit" */ N_("enable smart filter for \"part\" and \"quit\" messages"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_temporary_servers = weechat_config_new_option ( + irc_config_file, ptr_section, + "temporary_servers", "boolean", + N_("enable creation of temporary servers with command " + "/connect"), + NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_topic_strip_colors = weechat_config_new_option ( irc_config_file, ptr_section, "topic_strip_colors", "boolean", @@ -2986,8 +3029,9 @@ irc_config_init () } irc_config_section_server = ptr_section; - irc_config_hook_config_nick_colors = weechat_hook_config ("weechat.color.chat_nick_colors", - &irc_config_change_nick_colors_cb, NULL); + irc_config_hook_config_nick_colors = weechat_hook_config ( + "weechat.color.chat_nick_colors", + &irc_config_change_nick_colors_cb, NULL); return 1; } |