mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
added the possibility to uninstall a plugin
This commit is contained in:
parent
e4ddced420
commit
cd86f5bc28
@ -2084,6 +2084,7 @@ static struct cmd_t command_defs[] =
|
||||
CMD_SUBFUNCS(
|
||||
{ "sourcepath", cmd_plugins_sourcepath },
|
||||
{ "install", cmd_plugins_install },
|
||||
{ "uninstall", cmd_plugins_uninstall },
|
||||
{ "load", cmd_plugins_load },
|
||||
{ "unload", cmd_plugins_unload },
|
||||
{ "reload", cmd_plugins_reload },
|
||||
@ -2095,6 +2096,7 @@ static struct cmd_t command_defs[] =
|
||||
"/plugins sourcepath set <path>",
|
||||
"/plugins sourcepath clear",
|
||||
"/plugins install [<path>]",
|
||||
"/plugins uninstall [<plugin>]",
|
||||
"/plugins unload [<plugin>]",
|
||||
"/plugins load [<plugin>]",
|
||||
"/plugins reload [<plugin>]",
|
||||
@ -2105,6 +2107,7 @@ static struct cmd_t command_defs[] =
|
||||
{ "sourcepath set <path>", "Set the default path to install plugins from, will be used if no arg is passed to /plugins install." },
|
||||
{ "sourcepath clear", "Clear the default plugins source path." },
|
||||
{ "install [<path>]", "Install a plugin, or all plugins found in a directory (recursive). Passing no argument will use the sourcepath if one is set." },
|
||||
{ "uninstall [<plugin>]", "Uninstall a plugin." },
|
||||
{ "load [<plugin>]", "Load a plugin that already exists in the plugin directory, passing no argument loads all found plugins." },
|
||||
{ "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." },
|
||||
@ -2113,6 +2116,7 @@ static struct cmd_t command_defs[] =
|
||||
"/plugins sourcepath set /home/meee/projects/profanity-plugins",
|
||||
"/plugins install",
|
||||
"/plugins install /home/steveharris/Downloads/metal.py",
|
||||
"/plugins uninstall browser.py",
|
||||
"/plugins load browser.py",
|
||||
"/plugins unload say.py",
|
||||
"/plugins reload wikipedia.py")
|
||||
|
@ -6663,6 +6663,23 @@ cmd_plugins_install(ProfWin *window, const char *const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_plugins_uninstall(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
if (args[1] == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean res = plugins_uninstall(args[1]);
|
||||
if (res) {
|
||||
cons_show("Uninstalled plugin: %s", args[1]);
|
||||
} else {
|
||||
cons_show("Failed to uninstall plugin: %s", args[1]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_plugins_load(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
|
@ -162,6 +162,7 @@ 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_sourcepath(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_install(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_uninstall(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);
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "config.h"
|
||||
@ -168,6 +169,20 @@ plugins_install_all(const char *const path)
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
plugins_uninstall(const char *const plugin_name)
|
||||
{
|
||||
plugins_unload(plugin_name);
|
||||
char *plugins_dir = files_get_data_path(DIR_PLUGINS);
|
||||
GString *target_path = g_string_new(plugins_dir);
|
||||
free(plugins_dir);
|
||||
g_string_append(target_path, "/");
|
||||
g_string_append(target_path, plugin_name);
|
||||
GFile *file = g_file_new_for_path(target_path->str);
|
||||
GError *error = NULL;
|
||||
return g_file_delete(file, NULL, &error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
plugins_install(const char *const plugin_name, const char *const filename, GString *error_message)
|
||||
{
|
||||
|
@ -115,6 +115,8 @@ void plugins_shutdown(void);
|
||||
void plugins_free_install_result(PluginsInstallResult *result);
|
||||
|
||||
gboolean plugins_install(const char *const plugin_name, const char *const filename, GString * error_message);
|
||||
gboolean plugins_uninstall(const char *const plugin_name);
|
||||
gboolean plugins_update(const char *const plugin_name, const char *const filename, GString * error_message);
|
||||
PluginsInstallResult* plugins_install_all(const char *const path);
|
||||
gboolean plugins_load(const char *const name);
|
||||
GSList* plugins_load_all(void);
|
||||
|
Loading…
Reference in New Issue
Block a user