mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow unloading all plugins
This commit is contained in:
parent
b768c8b5c5
commit
a9fab9ed2d
@ -2047,13 +2047,18 @@ static struct cmd_t command_defs[] =
|
|||||||
|
|
||||||
{ "/plugins",
|
{ "/plugins",
|
||||||
parse_args, 0, 2, NULL,
|
parse_args, 0, 2, NULL,
|
||||||
CMD_NOSUBFUNCS
|
CMD_SUBFUNCS(
|
||||||
|
{ "install", cmd_plugins_install },
|
||||||
|
{ "load", cmd_plugins_load },
|
||||||
|
{ "unload", cmd_plugins_unload },
|
||||||
|
{ "reload", cmd_plugins_reload },
|
||||||
|
{ "python_version", cmd_plugins_python_version })
|
||||||
CMD_MAINFUNC(cmd_plugins)
|
CMD_MAINFUNC(cmd_plugins)
|
||||||
CMD_NOTAGS
|
CMD_NOTAGS
|
||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
"/plugins",
|
"/plugins",
|
||||||
"/plugins install <path>",
|
"/plugins install <path>",
|
||||||
"/plugins unload <plugin>",
|
"/plugins unload [<plugin>]",
|
||||||
"/plugins load <plugin>",
|
"/plugins load <plugin>",
|
||||||
"/plugins reload [<plugin>]",
|
"/plugins reload [<plugin>]",
|
||||||
"/plugins python_version")
|
"/plugins python_version")
|
||||||
@ -2062,7 +2067,7 @@ static struct cmd_t command_defs[] =
|
|||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "install <file>", "Install file to plugins directory, and load or reload the plugin." },
|
{ "install <file>", "Install file to plugins directory, and load or reload the plugin." },
|
||||||
{ "load <plugin>", "Load a plugin that already exists in the plugin directory." },
|
{ "load <plugin>", "Load a plugin that already exists in the plugin directory." },
|
||||||
{ "unload <plugin>", "Unload a loaded plugin." },
|
{ "unload [<plugin>]", "Unload a loaded plugin, passing no argument will unload all plugins." },
|
||||||
{ "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins." },
|
{ "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins." },
|
||||||
{ "python_version", "Show the Python interpreter version." })
|
{ "python_version", "Show the Python interpreter version." })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
|
@ -6212,9 +6212,8 @@ cmd_xa(ProfWin *window, const char *const command, gchar **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
cmd_plugins_install(ProfWin *window, const char *const command, gchar **args)
|
||||||
{
|
{
|
||||||
if (g_strcmp0(args[0], "install") == 0) {
|
|
||||||
char *filename = args[1];
|
char *filename = args[1];
|
||||||
if (filename == NULL) {
|
if (filename == NULL) {
|
||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
@ -6259,7 +6258,11 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
|||||||
|
|
||||||
free(filename);
|
free(filename);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[0], "load") == 0) {
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_plugins_load(ProfWin *window, const char *const command, gchar **args)
|
||||||
|
{
|
||||||
if (args[1] == NULL) {
|
if (args[1] == NULL) {
|
||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -6272,11 +6275,17 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[0], "unload") == 0) {
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args)
|
||||||
|
{
|
||||||
if (args[1] == NULL) {
|
if (args[1] == NULL) {
|
||||||
cons_bad_cmd_usage(command);
|
plugins_unload_all();
|
||||||
|
cons_show("Unloaded all plugins");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean res = plugins_unload(args[1]);
|
gboolean res = plugins_unload(args[1]);
|
||||||
if (res) {
|
if (res) {
|
||||||
cons_show("Unloaded plugin: %s", args[1]);
|
cons_show("Unloaded plugin: %s", args[1]);
|
||||||
@ -6285,21 +6294,30 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[0], "reload") == 0) {
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args)
|
||||||
|
{
|
||||||
if (args[1] == NULL) {
|
if (args[1] == NULL) {
|
||||||
plugins_reload_all();
|
plugins_reload_all();
|
||||||
cons_show("Reloaded all plugins");
|
cons_show("Reloaded all plugins");
|
||||||
} else {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean res = plugins_reload(args[1]);
|
gboolean res = plugins_reload(args[1]);
|
||||||
if (res) {
|
if (res) {
|
||||||
cons_show("Reloaded plugin: %s", args[1]);
|
cons_show("Reloaded plugin: %s", args[1]);
|
||||||
} else {
|
} else {
|
||||||
cons_show("Failed to reload plugin: %s", args[1]);
|
cons_show("Failed to reload plugin: %s", args[1]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[0], "python_version") == 0) {
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args)
|
||||||
|
{
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
const char *version = python_get_version();
|
const char *version = python_get_version();
|
||||||
cons_show("Python version:");
|
cons_show("Python version:");
|
||||||
@ -6308,8 +6326,11 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
|||||||
cons_show("This build does not support pytyon plugins.");
|
cons_show("This build does not support pytyon plugins.");
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
gboolean
|
||||||
|
cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
||||||
|
{
|
||||||
GList *plugins = plugins_loaded_list();
|
GList *plugins = plugins_loaded_list();
|
||||||
if (plugins == NULL) {
|
if (plugins == NULL) {
|
||||||
cons_show("No plugins installed.");
|
cons_show("No plugins installed.");
|
||||||
@ -6326,7 +6347,6 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_pgp(ProfWin *window, const char *const command, gchar **args)
|
cmd_pgp(ProfWin *window, const char *const command, gchar **args)
|
||||||
|
@ -158,7 +158,14 @@ gboolean cmd_script(ProfWin *window, const char *const command, gchar **args);
|
|||||||
gboolean cmd_export(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_export(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_console(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_console(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
|
||||||
gboolean cmd_plugins(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_plugins(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
gboolean cmd_plugins_install(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
gboolean cmd_plugins_load(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
gboolean cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
gboolean cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
gboolean cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
|
||||||
gboolean cmd_blocked(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_blocked(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
|
||||||
gboolean cmd_account(ProfWin *window, const char *const command, gchar **args);
|
gboolean cmd_account(ProfWin *window, const char *const command, gchar **args);
|
||||||
|
@ -190,6 +190,27 @@ plugins_load(const char *const name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
plugins_unload_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_unload(curr->data);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free_full(plugin_names_dup, free);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
plugins_unload(const char *const name)
|
plugins_unload(const char *const name)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +110,7 @@ void plugins_shutdown(void);
|
|||||||
gboolean plugins_install(const char *const plugin_name, const char *const filename);
|
gboolean plugins_install(const char *const plugin_name, const char *const filename);
|
||||||
gboolean plugins_load(const char *const name);
|
gboolean plugins_load(const char *const name);
|
||||||
gboolean plugins_unload(const char *const name);
|
gboolean plugins_unload(const char *const name);
|
||||||
|
void plugins_unload_all(void);
|
||||||
gboolean plugins_reload(const char *const name);
|
gboolean plugins_reload(const char *const name);
|
||||||
void plugins_reload_all(void);
|
void plugins_reload_all(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user