diff options
-rw-r--r-- | src/command/cmd_defs.c | 6 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 15 | ||||
-rw-r--r-- | src/plugins/plugins.c | 21 | ||||
-rw-r--r-- | src/plugins/plugins.h | 1 |
4 files changed, 33 insertions, 10 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index bc8a1057..1a94605a 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1981,13 +1981,13 @@ static struct cmd_t command_defs[] = "/plugins", "/plugins unload <plugin>", "/plugins load <plugin>", - "/plugins reload <plugin>") + "/plugins reload [<plugin>]") CMD_DESC( "Manage plugins. Passing no arguments lists currently loaded plugins.") CMD_ARGS( { "load <plugin>", "Load a plugin." }, - { "reload <plugin>", "Reload a plugin." }, - { "unload <plugin>", "Unload a plugin." }) + { "unload <plugin>", "Unload a plugin." }, + { "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins" }) CMD_EXAMPLES( "/plugin load browser.py", "/plugin unload say.py", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index f5646a51..fcce7028 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -6053,14 +6053,15 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args) return TRUE; } else if (g_strcmp0(args[0], "reload") == 0) { if (args[1] == NULL) { - cons_bad_cmd_usage(command); - return TRUE; - } - gboolean res = plugins_reload(args[1]); - if (res) { - cons_show("Reloaded plugin: %s", args[1]); + plugins_reload_all(); + cons_show("Reloaded all plugins"); } else { - cons_show("Failed to reload plugin: %s", args[1]); + gboolean res = plugins_reload(args[1]); + if (res) { + cons_show("Reloaded plugin: %s", args[1]); + } else { + cons_show("Failed to reload plugin: %s", args[1]); + } } return TRUE; diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index 46fa482f..ef3fc5c2 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -187,6 +187,27 @@ plugins_unload(const char *const name) return TRUE; } +void +plugins_reload_all(void) +{ + GList *plugin_names = g_hash_table_get_keys(plugins); + GList *plugin_names_dup = NULL; + GList *curr = plugin_names; + while (curr) { + plugin_names_dup = g_list_append(plugin_names_dup, strdup(curr->data)); + curr = g_list_next(curr); + } + g_list_free(plugin_names); + + curr = plugin_names_dup; + while (curr) { + plugins_reload(curr->data); + curr = g_list_next(curr); + } + + g_list_free_full(plugin_names_dup, free); +} + gboolean plugins_reload(const char *const name) { diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h index 45be1fc6..78bae9e6 100644 --- a/src/plugins/plugins.h +++ b/src/plugins/plugins.h @@ -108,6 +108,7 @@ void plugins_shutdown(void); gboolean plugins_load(const char *const name); gboolean plugins_unload(const char *const name); gboolean plugins_reload(const char *const name); +void plugins_reload_all(void); void plugins_on_start(void); void plugins_on_shutdown(void); |