mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Plugin unload remove cmd_acs and close window
This commit is contained in:
parent
82458c9d96
commit
1926ceea3d
@ -787,6 +787,14 @@ cmd_ac_remove(const char *const value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_ac_remove_help(const char *const value)
|
||||||
|
{
|
||||||
|
if (help_ac) {
|
||||||
|
autocomplete_remove(help_ac, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_ac_exists(char *cmd)
|
cmd_ac_exists(char *cmd)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,7 @@ void cmd_ac_add_alias(ProfAlias *alias);
|
|||||||
void cmd_ac_add_alias_value(char *value);
|
void cmd_ac_add_alias_value(char *value);
|
||||||
|
|
||||||
void cmd_ac_remove(const char *const value);
|
void cmd_ac_remove(const char *const value);
|
||||||
|
void cmd_ac_remove_help(const char *const value);
|
||||||
void cmd_ac_remove_alias_value(char *value);
|
void cmd_ac_remove_alias_value(char *value);
|
||||||
|
|
||||||
gboolean cmd_ac_exists(char *cmd);
|
gboolean cmd_ac_exists(char *cmd);
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "plugins/plugins.h"
|
#include "plugins/plugins.h"
|
||||||
#include "tools/autocomplete.h"
|
#include "tools/autocomplete.h"
|
||||||
#include "tools/parser.h"
|
#include "tools/parser.h"
|
||||||
|
#include "window_list.h"
|
||||||
|
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
@ -141,9 +142,31 @@ callbacks_init(void)
|
|||||||
void
|
void
|
||||||
callbacks_remove(const char *const plugin_name)
|
callbacks_remove(const char *const plugin_name)
|
||||||
{
|
{
|
||||||
// TODO remove from cmd_ac and cmd_ac_help
|
GHashTable *command_hash = g_hash_table_lookup(p_commands, plugin_name);
|
||||||
|
if (command_hash) {
|
||||||
|
GList *commands = g_hash_table_get_keys(command_hash);
|
||||||
|
GList *curr = commands;
|
||||||
|
while (curr) {
|
||||||
|
char *command = curr->data;
|
||||||
|
cmd_ac_remove(command);
|
||||||
|
cmd_ac_remove_help(&command[1]);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(commands);
|
||||||
|
}
|
||||||
|
|
||||||
g_hash_table_remove(p_commands, plugin_name);
|
g_hash_table_remove(p_commands, plugin_name);
|
||||||
g_hash_table_remove(p_timed_functions, plugin_name);
|
g_hash_table_remove(p_timed_functions, plugin_name);
|
||||||
|
|
||||||
|
GHashTable *tag_to_win_cb_hash = g_hash_table_lookup(p_window_callbacks, plugin_name);
|
||||||
|
GList *tags = g_hash_table_get_keys(tag_to_win_cb_hash);
|
||||||
|
GList *curr = tags;
|
||||||
|
while (curr) {
|
||||||
|
wins_close_plugin(curr->data);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(tags);
|
||||||
|
|
||||||
g_hash_table_remove(p_window_callbacks, plugin_name);
|
g_hash_table_remove(p_window_callbacks, plugin_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,10 +171,19 @@ plugins_unload(const char *const name)
|
|||||||
ProfPlugin *plugin = g_hash_table_lookup(plugins, name);
|
ProfPlugin *plugin = g_hash_table_lookup(plugins, name);
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
plugin->on_unload_func(plugin);
|
plugin->on_unload_func(plugin);
|
||||||
|
#ifdef HAVE_PYTHON
|
||||||
|
if (plugin->lang == LANG_PYTHON) {
|
||||||
|
python_plugin_destroy(plugin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_C
|
||||||
|
if (plugin->lang == LANG_C) {
|
||||||
|
c_plugin_destroy(plugin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
prefs_remove_plugin(name);
|
||||||
|
g_hash_table_remove(plugins, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs_remove_plugin(name);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +249,9 @@ void
|
|||||||
plugins_win_process_line(char *win, const char * const line)
|
plugins_win_process_line(char *win, const char * const line)
|
||||||
{
|
{
|
||||||
PluginWindowCallback *window = callbacks_get_window_handler(win);
|
PluginWindowCallback *window = callbacks_get_window_handler(win);
|
||||||
window->callback_exec(window, win, line);
|
if (window) {
|
||||||
|
window->callback_exec(window, win, line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -391,7 +391,6 @@ _shutdown(void)
|
|||||||
plugins_on_shutdown();
|
plugins_on_shutdown();
|
||||||
muc_close();
|
muc_close();
|
||||||
caps_close();
|
caps_close();
|
||||||
ui_close();
|
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
otr_shutdown();
|
otr_shutdown();
|
||||||
#endif
|
#endif
|
||||||
@ -402,10 +401,11 @@ _shutdown(void)
|
|||||||
theme_close();
|
theme_close();
|
||||||
accounts_close();
|
accounts_close();
|
||||||
tlscerts_close();
|
tlscerts_close();
|
||||||
cmd_uninit();
|
|
||||||
log_stderr_close();
|
log_stderr_close();
|
||||||
log_close();
|
log_close();
|
||||||
plugins_shutdown();
|
plugins_shutdown();
|
||||||
|
cmd_uninit();
|
||||||
|
ui_close();
|
||||||
prefs_close();
|
prefs_close();
|
||||||
if (saved_status) {
|
if (saved_status) {
|
||||||
free(saved_status);
|
free(saved_status);
|
||||||
|
@ -226,6 +226,29 @@ wins_get_plugin(const char *const tag)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wins_close_plugin(const char *const tag)
|
||||||
|
{
|
||||||
|
GList *values = g_hash_table_get_values(windows);
|
||||||
|
GList *curr = values;
|
||||||
|
|
||||||
|
while (curr) {
|
||||||
|
ProfWin *window = curr->data;
|
||||||
|
if (window->type == WIN_PLUGIN) {
|
||||||
|
ProfPluginWin *pluginwin = (ProfPluginWin*)window;
|
||||||
|
if (g_strcmp0(pluginwin->tag, tag) == 0) {
|
||||||
|
int num = wins_get_num(window);
|
||||||
|
wins_close_by_num(num);
|
||||||
|
g_list_free(values);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free(values);
|
||||||
|
}
|
||||||
|
|
||||||
GList*
|
GList*
|
||||||
wins_get_private_chats(const char *const roomjid)
|
wins_get_private_chats(const char *const roomjid)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,8 @@ ProfPrivateWin* wins_get_private(const char *const fulljid);
|
|||||||
ProfPluginWin* wins_get_plugin(const char *const tag);
|
ProfPluginWin* wins_get_plugin(const char *const tag);
|
||||||
ProfXMLWin* wins_get_xmlconsole(void);
|
ProfXMLWin* wins_get_xmlconsole(void);
|
||||||
|
|
||||||
|
void wins_close_plugin(const char *const tag);
|
||||||
|
|
||||||
ProfWin* wins_get_current(void);
|
ProfWin* wins_get_current(void);
|
||||||
|
|
||||||
void wins_set_current_by_num(int i);
|
void wins_set_current_by_num(int i);
|
||||||
|
Loading…
Reference in New Issue
Block a user