diff options
-rw-r--r-- | src/command/cmd_funcs.c | 22 | ||||
-rw-r--r-- | src/plugins/plugins.c | 26 | ||||
-rw-r--r-- | src/plugins/plugins.h | 3 |
3 files changed, 45 insertions, 6 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 6f238612..7f854249 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -6264,9 +6264,21 @@ gboolean cmd_plugins_load(ProfWin *window, const char *const command, gchar **args) { if (args[1] == NULL) { - cons_bad_cmd_usage(command); + GSList *loaded = plugins_load_all(); + if (loaded) { + cons_show("Loaded plugins:"); + GSList *curr = loaded; + while (curr) { + cons_show(" %s", curr->data); + curr = g_slist_next(curr); + } + g_slist_free_full(loaded, g_free); + } else { + cons_show("No plugins loaded."); + } return TRUE; } + gboolean res = plugins_load(args[1]); if (res) { cons_show("Loaded plugin: %s", args[1]); @@ -6281,8 +6293,12 @@ gboolean cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args) { if (args[1] == NULL) { - plugins_unload_all(); - cons_show("Unloaded all plugins"); + gboolean res = plugins_unload_all(); + if (res) { + cons_show("Unloaded all plugins."); + } else { + cons_show("No plugins unloaded."); + } return TRUE; } diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index c9e37c15..4896fedb 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -153,6 +153,23 @@ plugins_install(const char *const plugin_name, const char *const filename) return result; } +GSList* +plugins_load_all(void) +{ + GSList *plugins = plugins_unloaded_list(); + GSList *loaded = NULL; + GSList *curr = plugins; + while (curr) { + if (plugins_load(curr->data)) { + loaded = g_slist_append(loaded, strdup(curr->data)); + } + curr = g_slist_next(curr); + } + g_slist_free_full(plugins, g_free); + + return loaded; +} + gboolean plugins_load(const char *const name) { @@ -190,9 +207,10 @@ plugins_load(const char *const name) } } -void +gboolean plugins_unload_all(void) { + gboolean result = FALSE; GList *plugin_names = g_hash_table_get_keys(plugins); GList *plugin_names_dup = NULL; GList *curr = plugin_names; @@ -204,11 +222,15 @@ plugins_unload_all(void) curr = plugin_names_dup; while (curr) { - plugins_unload(curr->data); + if (plugins_unload(curr->data)) { + result = TRUE; + } curr = g_list_next(curr); } g_list_free_full(plugin_names_dup, free); + + return result; } gboolean diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h index 8762556e..502af806 100644 --- a/src/plugins/plugins.h +++ b/src/plugins/plugins.h @@ -109,8 +109,9 @@ void plugins_shutdown(void); gboolean plugins_install(const char *const plugin_name, const char *const filename); gboolean plugins_load(const char *const name); +GSList* plugins_load_all(void); gboolean plugins_unload(const char *const name); -void plugins_unload_all(void); +gboolean plugins_unload_all(void); gboolean plugins_reload(const char *const name); void plugins_reload_all(void); |