diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-06-17 16:01:09 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-06-17 16:01:09 +0200 |
commit | af87798455e9d82773094a3c274ecb991af41ed9 (patch) | |
tree | 32de00c475b9f127003d6e663d6e8f98f13ad3ad /src/core | |
parent | 860842240b2c3f673a2265716359cb6605048386 (diff) | |
download | weechat-af87798455e9d82773094a3c274ecb991af41ed9.zip |
New plugin "notify", new option for debug messages in plugins
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 99 | ||||
-rw-r--r-- | src/core/wee-config-file.c | 57 | ||||
-rw-r--r-- | src/core/wee-config.c | 32 | ||||
-rw-r--r-- | src/core/wee-config.h | 5 |
4 files changed, 81 insertions, 112 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 81b27125d..def88fda2 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -437,87 +437,20 @@ command_buffer (void *data, struct t_gui_buffer *buffer, /* display/change buffer notify */ if (string_strcasecmp (argv[1], "notify") == 0) { - if (argc < 3) - { - /* display notify level for all buffers */ - gui_chat_printf (NULL, ""); - gui_chat_printf (NULL, _("Notify levels:")); - for (ptr_buffer = gui_buffers; ptr_buffer; - ptr_buffer = ptr_buffer->next_buffer) - { - gui_chat_printf (NULL, - " %d.%s: %d", - ptr_buffer->number, - ptr_buffer->name, - ptr_buffer->notify_level); - } - gui_chat_printf (NULL, ""); - } - else + /* display notify level for all buffers */ + gui_chat_printf (NULL, ""); + gui_chat_printf (NULL, _("Notify levels:")); + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) { - /* set notify level for buffer */ - error = NULL; - number = strtol (argv[2], &error, 10); - if (error && !error[0]) - { - if ((number < GUI_BUFFER_NOTIFY_LEVEL_MIN) - || (number > GUI_BUFFER_NOTIFY_LEVEL_MAX)) - { - /* invalid highlight level */ - gui_chat_printf (NULL, - _("%sError: incorrect notify level " - "(must be between %d and %d)"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - GUI_BUFFER_NOTIFY_LEVEL_MIN, - GUI_BUFFER_NOTIFY_LEVEL_MAX); - return WEECHAT_RC_ERROR; - } - gui_chat_printf (NULL, - _("New notify level for %s%s%s: " - "%d %s"), - GUI_COLOR(GUI_COLOR_CHAT_BUFFER), - buffer->name, - GUI_COLOR(GUI_COLOR_CHAT), - number, - GUI_COLOR(GUI_COLOR_CHAT)); - switch (number) - { - case GUI_HOTLIST_LOW: - gui_chat_printf (NULL, - _("(hotlist: never)")); - break; - case GUI_HOTLIST_MESSAGE: - gui_chat_printf (NULL, - _("(hotlist: highlights)")); - break; - case GUI_HOTLIST_PRIVATE: - gui_chat_printf (NULL, - _("(hotlist: highlights + " - "messages)")); - break; - case GUI_HOTLIST_HIGHLIGHT: - gui_chat_printf (NULL, - _("(hotlist: highlights + " - "messages + join/part " - "(all))")); - break; - default: - gui_chat_printf (NULL, ""); - break; - } - } - else - { - /* invalid number */ - gui_chat_printf (NULL, - _("%sError: incorrect notify level (must " - "be between %d and %d)"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - GUI_BUFFER_NOTIFY_LEVEL_MIN, - GUI_BUFFER_NOTIFY_LEVEL_MAX); - return WEECHAT_RC_ERROR; - } + gui_chat_printf (NULL, + " %d.%s: %d (%s)", + ptr_buffer->number, + ptr_buffer->name, + ptr_buffer->notify, + gui_buffer_notify_string[ptr_buffer->notify]); } + gui_chat_printf (NULL, ""); return WEECHAT_RC_OK; } @@ -2645,10 +2578,7 @@ command_init () "example -1)\n" " close: close buffer\n" " list: list buffers (no parameter implies this list)\n" - " notify: set notify level for buffer (0=never, " - "1=highlight, 2=1+msg, 3=2+join/part)\n" - " (when executed on server buffer, this sets " - "default notify level for whole server)\n" + " notify: display notify levels for all open buffers\n" " scroll: scroll in history (may be relative, and may " "end by a letter: s=sec, m=min, h=hour, d=day, M=month, " "y=year); if there is only letter, then scroll to " @@ -2661,9 +2591,8 @@ command_init () " clear all buffers: /buffer clear -all\n" " move buffer: /buffer move 5\n" " close buffer: /buffer close this is part msg\n" - " set notify: /buffer notify 2\n" " scroll 1 day up: /buffer scroll 1d == /buffer " - " scroll -1d == /buffer scroll -24h\n" + "scroll -1d == /buffer scroll -24h\n" " scroll to beginning\n" " of this day: /buffer scroll d\n" " scroll 15 min down: /buffer scroll +15m\n" diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 2c7cd8dfa..ae8680e8c 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -485,6 +485,31 @@ config_file_new_option (struct t_config_file *config_file, } /* + * config_file_option_full_name: build full name for an option + */ + +char * +config_file_option_full_name (struct t_config_option *option) +{ + int length_option; + char *option_full_name; + + length_option = strlen (option->config_file->name) + 1 + + strlen (option->section->name) + 1 + strlen (option->name) + 1; + option_full_name = malloc (length_option); + if (option_full_name) + { + snprintf (option_full_name, length_option, + "%s.%s.%s", + option->config_file->name, + option->section->name, + option->name); + } + + return option_full_name; +} + +/* * config_file_search_option: search an option in a config or section */ @@ -748,7 +773,7 @@ config_file_string_to_boolean (const char *text) int config_file_option_reset (struct t_config_option *option, int run_callback) { - int rc, length_option; + int rc; char value[256], *option_full_name; if (!option) @@ -830,16 +855,9 @@ config_file_option_reset (struct t_config_option *option, int run_callback) { if (option->config_file && option->section) { - length_option = strlen (option->config_file->name) + 1 + - strlen (option->section->name) + 1 + strlen (option->name) + 1; - option_full_name = malloc (length_option); + option_full_name = config_file_option_full_name (option); if (option_full_name) { - snprintf (option_full_name, length_option, - "%s.%s.%s", - option->config_file->name, - option->section->name, - option->name); hook_config_exec (option_full_name, value); free (option_full_name); } @@ -862,7 +880,7 @@ int config_file_option_set (struct t_config_option *option, const char *value, int run_callback) { - int value_int, i, rc, length_option, new_value_ok; + int value_int, i, rc, new_value_ok; long number; char *error, *option_full_name; @@ -1079,16 +1097,9 @@ config_file_option_set (struct t_config_option *option, const char *value, { if (option->config_file && option->section) { - length_option = strlen (option->config_file->name) + 1 + - strlen (option->section->name) + 1 + strlen (option->name) + 1; - option_full_name = malloc (length_option); + option_full_name = config_file_option_full_name (option); if (option_full_name) { - snprintf (option_full_name, length_option, - "%s.%s.%s", - option->config_file->name, - option->section->name, - option->name); hook_config_exec (option_full_name, value); free (option_full_name); } @@ -1111,6 +1122,7 @@ int config_file_option_unset (struct t_config_option *option) { int rc; + char *option_full_name; rc = WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET; @@ -1123,8 +1135,17 @@ config_file_option_unset (struct t_config_option *option) (option->callback_delete_data, option); } + + option_full_name = config_file_option_full_name (option); + config_file_option_free (option); rc = WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED; + + if (option_full_name) + { + hook_config_exec (option_full_name, NULL); + free (option_full_name); + } } else { diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 827ce7705..afbd74278 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -68,6 +68,7 @@ struct t_config_option *config_startup_weechat_slogan; /* config, look & feel section */ +struct t_config_option *config_look_buffer_notify_default; struct t_config_option *config_look_buffer_time_format; struct t_config_option *config_look_color_nicks_number; struct t_config_option *config_look_color_real_white; @@ -184,9 +185,10 @@ struct t_config_option *config_proxy_password; /* config, plugin section */ -struct t_config_option *config_plugin_path; struct t_config_option *config_plugin_autoload; +struct t_config_option *config_plugin_debug; struct t_config_option *config_plugin_extension; +struct t_config_option *config_plugin_path; struct t_config_option *config_plugin_save_config_on_unload; /* hooks */ @@ -779,7 +781,15 @@ config_weechat_init () config_file_free (weechat_config_file); return 0; } - + + config_look_buffer_notify_default = config_file_new_option ( + weechat_config_file, ptr_section, + "buffer_notify_default", "integer", + N_("default notify level for buffers (used to tell WeeChat if buffer " + "must be displayed in hotlist or not, according to importance " + "of message)"), + "none|highlight|message|all", 0, 0, "all", + NULL, NULL, NULL, NULL, NULL, NULL); config_look_buffer_time_format = config_file_new_option ( weechat_config_file, ptr_section, "buffer_time_format", "string", @@ -1533,12 +1543,6 @@ config_weechat_init () return 0; } - config_plugin_path = config_file_new_option ( - weechat_config_file, ptr_section, - "path", "string", - N_("path for searching plugins ('%h' will be replaced by " - "WeeChat home, ~/.weechat by default)"), - NULL, 0, 0, "%h/plugins", NULL, NULL, NULL, NULL, NULL, NULL); config_plugin_autoload = config_file_new_option ( weechat_config_file, ptr_section, "autoload", "string", @@ -1547,6 +1551,12 @@ config_weechat_init () "be partial, for example \"perl\" is ok for " "\"perl.so\")"), NULL, 0, 0, "*", NULL, NULL, NULL, NULL, NULL, NULL); + config_plugin_debug = config_file_new_option ( + weechat_config_file, ptr_section, + "debug", "boolean", + N_("enable debug messages by default in all plugins (option disabled " + "by default, which is highly recommended)"), + NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL); config_plugin_extension = config_file_new_option ( weechat_config_file, ptr_section, "extension", "string", @@ -1559,6 +1569,12 @@ config_weechat_init () ".so", #endif NULL, NULL, NULL, NULL, NULL, NULL); + config_plugin_path = config_file_new_option ( + weechat_config_file, ptr_section, + "path", "string", + N_("path for searching plugins ('%h' will be replaced by " + "WeeChat home, ~/.weechat by default)"), + NULL, 0, 0, "%h/plugins", NULL, NULL, NULL, NULL, NULL, NULL); config_plugin_save_config_on_unload = config_file_new_option ( weechat_config_file, ptr_section, "save_config_on_unload", "boolean", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index a78d4c76c..09d712b51 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -54,6 +54,7 @@ extern struct t_config_option *config_startup_display_logo; extern struct t_config_option *config_startup_display_version; extern struct t_config_option *config_startup_weechat_slogan; +extern struct t_config_option *config_look_buffer_notify_default; extern struct t_config_option *config_look_buffer_time_format; extern struct t_config_option *config_look_color_nicks_number; extern struct t_config_option *config_look_color_real_white; @@ -162,11 +163,13 @@ extern struct t_config_option *config_proxy_port; extern struct t_config_option *config_proxy_username; extern struct t_config_option *config_proxy_password; -extern struct t_config_option *config_plugin_path; extern struct t_config_option *config_plugin_autoload; +extern struct t_config_option *config_plugin_debug; extern struct t_config_option *config_plugin_extension; +extern struct t_config_option *config_plugin_path; extern struct t_config_option *config_plugin_save_config_on_unload; + extern int config_weechat_init (); extern int config_weechat_read (); extern int config_weechat_reload (); |