diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-04-24 18:59:22 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-04-24 18:59:22 +0200 |
commit | 93038846139cbadfb22f9a3a0da8fed2ee55e057 (patch) | |
tree | 36b9b3217a742436d147b50fdbcb3a7687c1e115 | |
parent | e3d2728571be0b56dc67253137366d96e3e7282a (diff) | |
download | weechat-93038846139cbadfb22f9a3a0da8fed2ee55e057.zip |
Add filter with third argument of infolist_get for some infolists (bars, bar items, buffers, filters, plugins, irc_server, alias, script list)
-rw-r--r-- | src/gui/gui-bar.c | 4 | ||||
-rw-r--r-- | src/gui/gui-filter.c | 2 | ||||
-rw-r--r-- | src/plugins/alias/alias-info.c | 12 | ||||
-rw-r--r-- | src/plugins/irc/irc-info.c | 12 | ||||
-rw-r--r-- | src/plugins/plugin-api.c | 63 | ||||
-rw-r--r-- | src/plugins/plugin.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua.c | 4 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 4 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 4 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.c | 4 | ||||
-rw-r--r-- | src/plugins/scripts/script.c | 17 | ||||
-rw-r--r-- | src/plugins/scripts/script.h | 3 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl.c | 4 |
13 files changed, 90 insertions, 45 deletions
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 77a7db154..594127f38 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -2303,7 +2303,9 @@ gui_bar_add_to_infolist (struct t_infolist *infolist, ptr_item = infolist_new_item (infolist); if (!ptr_item) return 0; - + + if (!infolist_new_var_string (ptr_item, "name", bar->name)) + return 0; if (!infolist_new_var_integer (ptr_item, "hidden", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_HIDDEN]))) return 0; if (!infolist_new_var_integer (ptr_item, "priority", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY]))) diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c index 83e641471..5e823e3b0 100644 --- a/src/gui/gui-filter.c +++ b/src/gui/gui-filter.c @@ -505,6 +505,8 @@ gui_filter_add_to_infolist (struct t_infolist *infolist, if (!infolist_new_var_integer (ptr_item, "enabled", filter->enabled)) return 0; + if (!infolist_new_var_string (ptr_item, "name", filter->name)) + return 0; if (!infolist_new_var_string (ptr_item, "plugin_name", filter->plugin_name)) return 0; if (!infolist_new_var_string (ptr_item, "buffer_name", filter->buffer_name)) diff --git a/src/plugins/alias/alias-info.c b/src/plugins/alias/alias-info.c index e7033df3e..956322506 100644 --- a/src/plugins/alias/alias-info.c +++ b/src/plugins/alias/alias-info.c @@ -63,14 +63,18 @@ alias_info_get_infolist_cb (void *data, const char *infolist_name, } else { - /* build list with all aliases */ + /* build list with all aliases matching arguments */ for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias) { - if (!alias_add_to_infolist (ptr_infolist, ptr_alias)) + if (!arguments || !arguments[0] + || weechat_string_match (ptr_alias->name, arguments, 0)) { - weechat_infolist_free (ptr_infolist); - return NULL; + if (!alias_add_to_infolist (ptr_infolist, ptr_alias)) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index c5894a101..8fa1a35c8 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -210,14 +210,18 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name, } else { - /* build list with all servers */ + /* build list with all servers matching arguments */ for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { - if (!irc_server_add_to_infolist (ptr_infolist, ptr_server)) + if (!arguments || !arguments[0] + || weechat_string_match (ptr_server->name, arguments, 0)) { - weechat_infolist_free (ptr_infolist); - return NULL; + if (!irc_server_add_to_infolist (ptr_infolist, ptr_server)) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index f0f310e73..fb4483b26 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -317,6 +317,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, struct t_gui_window *ptr_window; struct t_gui_hotlist *ptr_hotlist; struct t_weechat_plugin *ptr_plugin; + char buffer_full_name[1024]; /* make C compiler happy */ (void) data; @@ -345,13 +346,17 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, } else { - /* build list with all bars */ + /* build list with all bars matching arguments */ for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) { - if (!gui_bar_add_to_infolist (ptr_infolist, ptr_bar)) + if (!arguments || !arguments[0] + || string_match (ptr_bar->name, arguments, 0)) { - infolist_free (ptr_infolist); - return NULL; + if (!gui_bar_add_to_infolist (ptr_infolist, ptr_bar)) + { + infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; @@ -379,14 +384,18 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, } else { - /* build list with all bar items */ + /* build list with all bar items matching arguments */ for (ptr_bar_item = gui_bar_items; ptr_bar_item; ptr_bar_item = ptr_bar_item->next_item) { - if (!gui_bar_item_add_to_infolist (ptr_infolist, ptr_bar_item)) + if (!arguments || !arguments[0] + || string_match (ptr_bar_item->name, arguments, 0)) { - infolist_free (ptr_infolist); - return NULL; + if (!gui_bar_item_add_to_infolist (ptr_infolist, ptr_bar_item)) + { + infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; @@ -465,14 +474,22 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, } else { - /* build list with all buffers */ + /* build list with all buffers matching arguments */ for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) { - if (!gui_buffer_add_to_infolist (ptr_infolist, ptr_buffer)) + snprintf (buffer_full_name, sizeof (buffer_full_name), + "%s.%s", + plugin_get_name (ptr_buffer->plugin), + ptr_buffer->name); + if (!arguments || !arguments[0] + || string_match (buffer_full_name, arguments, 0)) { - infolist_free (ptr_infolist); - return NULL; + if (!gui_buffer_add_to_infolist (ptr_infolist, ptr_buffer)) + { + infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; @@ -514,10 +531,14 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, for (ptr_filter = gui_filters; ptr_filter; ptr_filter = ptr_filter->next_filter) { - if (!gui_filter_add_to_infolist (ptr_infolist, ptr_filter)) + if (!arguments || !arguments[0] + || string_match (ptr_filter->name, arguments, 0)) { - infolist_free (ptr_infolist); - return NULL; + if (!gui_filter_add_to_infolist (ptr_infolist, ptr_filter)) + { + infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; @@ -604,14 +625,18 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, } else { - /* build list with all plugins */ + /* build list with all plugins matching arguments */ for (ptr_plugin = weechat_plugins; ptr_plugin; ptr_plugin = ptr_plugin->next_plugin) { - if (!plugin_add_to_infolist (ptr_infolist, ptr_plugin)) + if (!arguments || !arguments[0] + || string_match (ptr_plugin->name, arguments, 0)) { - infolist_free (ptr_infolist); - return NULL; + if (!plugin_add_to_infolist (ptr_infolist, ptr_plugin)) + { + infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 96407749f..ec7f4f12b 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -1007,6 +1007,8 @@ plugin_add_to_infolist (struct t_infolist *infolist, return 0; if (!infolist_new_var_pointer (ptr_item, "handle", plugin->handle)) return 0; + if (!infolist_new_var_string (ptr_item, "name", plugin->name)) + return 0; if (!infolist_new_var_string (ptr_item, "description", plugin->description)) return 0; if (!infolist_new_var_string (ptr_item, "author", plugin->author)) diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index d87ad2417..71a76b62e 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -473,7 +473,6 @@ weechat_lua_infolist_cb (void *data, const char *infolist_name, { /* make C compiler happy */ (void) data; - (void) arguments; if (!infolist_name || !infolist_name[0]) return NULL; @@ -481,7 +480,8 @@ weechat_lua_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "lua_script") == 0) { return script_infolist_list_scripts (weechat_lua_plugin, - lua_scripts, pointer); + lua_scripts, pointer, + arguments); } return NULL; diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index c49f445cd..ac968f930 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -619,7 +619,6 @@ weechat_perl_infolist_cb (void *data, const char *infolist_name, { /* make C compiler happy */ (void) data; - (void) arguments; if (!infolist_name || !infolist_name[0]) return NULL; @@ -627,7 +626,8 @@ weechat_perl_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "perl_script") == 0) { return script_infolist_list_scripts (weechat_perl_plugin, - perl_scripts, pointer); + perl_scripts, pointer, + arguments); } return NULL; diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 4f9087897..67c7b9834 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -704,7 +704,6 @@ weechat_python_infolist_cb (void *data, const char *infolist_name, { /* make C compiler happy */ (void) data; - (void) arguments; if (!infolist_name || !infolist_name[0]) return NULL; @@ -712,7 +711,8 @@ weechat_python_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "python_script") == 0) { return script_infolist_list_scripts (weechat_python_plugin, - python_scripts, pointer); + python_scripts, pointer, + arguments); } return NULL; diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 144700497..f4b10c8ba 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -672,7 +672,6 @@ weechat_ruby_infolist_cb (void *data, const char *infolist_name, { /* make C compiler happy */ (void) data; - (void) arguments; if (!infolist_name || !infolist_name[0]) return NULL; @@ -680,7 +679,8 @@ weechat_ruby_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "ruby_script") == 0) { return script_infolist_list_scripts (weechat_ruby_plugin, - ruby_scripts, pointer); + ruby_scripts, pointer, + arguments); } return NULL; diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index 42de1e057..2ebb4862b 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -1161,7 +1161,8 @@ script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, struct t_infolist * script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *scripts, - void *pointer) + void *pointer, + const char *arguments) { struct t_infolist *ptr_infolist; struct t_plugin_script *ptr_script; @@ -1185,15 +1186,19 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, } else { - /* build list with all scripts */ + /* build list with all scripts matching arguments */ for (ptr_script = scripts; ptr_script; ptr_script = ptr_script->next_script) { - if (!script_add_to_infolist (weechat_plugin, - ptr_infolist, ptr_script)) + if (!arguments || !arguments[0] + || weechat_string_match (ptr_script->name, arguments, 0)) { - weechat_infolist_free (ptr_infolist); - return NULL; + if (!script_add_to_infolist (weechat_plugin, + ptr_infolist, ptr_script)) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } } } return ptr_infolist; diff --git a/src/plugins/scripts/script.h b/src/plugins/scripts/script.h index 715b9cc48..1b0f094fd 100644 --- a/src/plugins/scripts/script.h +++ b/src/plugins/scripts/script.h @@ -137,7 +137,8 @@ extern int script_add_to_infolist (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script); extern struct t_infolist *script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *scripts, - void *pointer); + void *pointer, + const char *arguments); extern void script_print_log (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *scripts); diff --git a/src/plugins/scripts/tcl/weechat-tcl.c b/src/plugins/scripts/tcl/weechat-tcl.c index 79a85cef1..3a77e418b 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.c +++ b/src/plugins/scripts/tcl/weechat-tcl.c @@ -414,7 +414,6 @@ weechat_tcl_infolist_cb (void *data, const char *infolist_name, { /* make C compiler happy */ (void) data; - (void) arguments; if (!infolist_name || !infolist_name[0]) return NULL; @@ -422,7 +421,8 @@ weechat_tcl_infolist_cb (void *data, const char *infolist_name, if (weechat_strcasecmp (infolist_name, "tcl_script") == 0) { return script_infolist_list_scripts (weechat_tcl_plugin, - tcl_scripts, pointer); + tcl_scripts, pointer, + arguments); } return NULL; |