mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Add plugins on_unload hook
This commit is contained in:
parent
71178b3696
commit
99598e7d57
@ -81,6 +81,7 @@ c_plugin_create(const char *const filename)
|
|||||||
plugin->init_func = c_init_hook;
|
plugin->init_func = c_init_hook;
|
||||||
plugin->on_start_func = c_on_start_hook;
|
plugin->on_start_func = c_on_start_hook;
|
||||||
plugin->on_shutdown_func = c_on_shutdown_hook;
|
plugin->on_shutdown_func = c_on_shutdown_hook;
|
||||||
|
plugin->on_unload_func = c_on_unload_hook;
|
||||||
plugin->on_connect_func = c_on_connect_hook;
|
plugin->on_connect_func = c_on_connect_hook;
|
||||||
plugin->on_disconnect_func = c_on_disconnect_hook;
|
plugin->on_disconnect_func = c_on_disconnect_hook;
|
||||||
plugin->pre_chat_message_display = c_pre_chat_message_display_hook;
|
plugin->pre_chat_message_display = c_pre_chat_message_display_hook;
|
||||||
@ -161,6 +162,20 @@ c_on_shutdown_hook(ProfPlugin *plugin)
|
|||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
c_on_unload_hook(ProfPlugin *plugin)
|
||||||
|
{
|
||||||
|
void *f = NULL;
|
||||||
|
void (*func)(void);
|
||||||
|
assert(plugin && plugin->module);
|
||||||
|
|
||||||
|
if (NULL == (f = dlsym(plugin->module, "prof_on_unload")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
func = (void (*)(void))f;
|
||||||
|
func();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
|
c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,7 @@ void c_init_hook(ProfPlugin *plugin, const char *const version, const char *cons
|
|||||||
const char *const fulljid);
|
const char *const fulljid);
|
||||||
void c_on_start_hook(ProfPlugin *plugin);
|
void c_on_start_hook(ProfPlugin *plugin);
|
||||||
void c_on_shutdown_hook(ProfPlugin *plugin);
|
void c_on_shutdown_hook(ProfPlugin *plugin);
|
||||||
|
void c_on_unload_hook(ProfPlugin *plugin);
|
||||||
void c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
void c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
||||||
void c_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
void c_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
||||||
|
|
||||||
|
@ -168,6 +168,11 @@ plugins_load(const char *const name)
|
|||||||
gboolean
|
gboolean
|
||||||
plugins_unload(const char *const name)
|
plugins_unload(const char *const name)
|
||||||
{
|
{
|
||||||
|
ProfPlugin *plugin = g_hash_table_lookup(plugins, name);
|
||||||
|
if (plugin) {
|
||||||
|
plugin->on_unload_func(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
prefs_remove_plugin(name);
|
prefs_remove_plugin(name);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -51,6 +51,7 @@ typedef struct prof_plugin_t {
|
|||||||
|
|
||||||
void (*on_start_func)(struct prof_plugin_t* plugin);
|
void (*on_start_func)(struct prof_plugin_t* plugin);
|
||||||
void (*on_shutdown_func)(struct prof_plugin_t* plugin);
|
void (*on_shutdown_func)(struct prof_plugin_t* plugin);
|
||||||
|
void (*on_unload_func)(struct prof_plugin_t* plugin);
|
||||||
|
|
||||||
void (*on_connect_func)(struct prof_plugin_t* plugin, const char *const account_name, const char *const fulljid);
|
void (*on_connect_func)(struct prof_plugin_t* plugin, const char *const account_name, const char *const fulljid);
|
||||||
void (*on_disconnect_func)(struct prof_plugin_t* plugin, const char *const account_name,
|
void (*on_disconnect_func)(struct prof_plugin_t* plugin, const char *const account_name,
|
||||||
|
@ -91,6 +91,7 @@ python_plugin_create(const char *const filename)
|
|||||||
plugin->init_func = python_init_hook;
|
plugin->init_func = python_init_hook;
|
||||||
plugin->on_start_func = python_on_start_hook;
|
plugin->on_start_func = python_on_start_hook;
|
||||||
plugin->on_shutdown_func = python_on_shutdown_hook;
|
plugin->on_shutdown_func = python_on_shutdown_hook;
|
||||||
|
plugin->on_unload_func = python_on_unload_hook;
|
||||||
plugin->on_connect_func = python_on_connect_hook;
|
plugin->on_connect_func = python_on_connect_hook;
|
||||||
plugin->on_disconnect_func = python_on_disconnect_hook;
|
plugin->on_disconnect_func = python_on_disconnect_hook;
|
||||||
plugin->pre_chat_message_display = python_pre_chat_message_display_hook;
|
plugin->pre_chat_message_display = python_pre_chat_message_display_hook;
|
||||||
@ -186,6 +187,25 @@ python_on_shutdown_hook(ProfPlugin *plugin)
|
|||||||
allow_python_threads();
|
allow_python_threads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
python_on_unload_hook(ProfPlugin *plugin)
|
||||||
|
{
|
||||||
|
disable_python_threads();
|
||||||
|
PyObject *p_function;
|
||||||
|
|
||||||
|
PyObject *p_module = plugin->module;
|
||||||
|
if (PyObject_HasAttrString(p_module, "prof_on_unload")) {
|
||||||
|
p_function = PyObject_GetAttrString(p_module, "prof_on_unload");
|
||||||
|
python_check_error();
|
||||||
|
if (p_function && PyCallable_Check(p_function)) {
|
||||||
|
PyObject_CallObject(p_function, NULL);
|
||||||
|
python_check_error();
|
||||||
|
Py_XDECREF(p_function);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allow_python_threads();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
|
python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,7 @@ void python_init_hook(ProfPlugin *plugin, const char *const version, const char
|
|||||||
const char *const account_name, const char *const fulljid);
|
const char *const account_name, const char *const fulljid);
|
||||||
void python_on_start_hook(ProfPlugin *plugin);
|
void python_on_start_hook(ProfPlugin *plugin);
|
||||||
void python_on_shutdown_hook(ProfPlugin *plugin);
|
void python_on_shutdown_hook(ProfPlugin *plugin);
|
||||||
|
void python_on_unload_hook(ProfPlugin *plugin);
|
||||||
void python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
void python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
||||||
void python_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
void python_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user