1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00

Added event handler to plugin API

This commit is contained in:
Sebastien Helleu
2007-02-05 22:18:33 +00:00
parent 4713f94602
commit 8e436c58cd
44 changed files with 5140 additions and 2052 deletions
+157 -29
View File
@@ -200,6 +200,36 @@ weechat_lua_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_lua_event_handler: general event handler for Lua
*/
int
weechat_lua_event_handler (t_weechat_plugin *plugin,
int argc, char **argv,
char *handler_args, void *handler_pointer)
{
int *r;
int ret;
if (argc >= 1)
{
r = (int *) weechat_lua_exec (plugin, (t_plugin_script *)handler_pointer,
SCRIPT_EXEC_INT,
handler_args, argv[0], NULL, NULL);
if (r == NULL)
ret = PLUGIN_RC_KO;
else
{
ret = *r;
free (r);
}
return ret;
}
else
return PLUGIN_RC_KO;
}
/*
* weechat_lua_modifier: general modifier for Lua
*/
@@ -310,7 +340,7 @@ weechat_lua_register (lua_State *L)
*/
static int
weechat_lua_set_charset (lua_State *L)
weechat_lua_set_charset (lua_State *L)
{
const char *charset;
int n;
@@ -355,7 +385,7 @@ weechat_lua_set_charset (lua_State *L)
*/
static int
weechat_lua_print (lua_State *L)
weechat_lua_print (lua_State *L)
{
const char *message, *channel_name, *server_name;
int n;
@@ -414,7 +444,7 @@ weechat_lua_print (lua_State *L)
*/
static int
weechat_lua_print_server (lua_State *L)
weechat_lua_print_server (lua_State *L)
{
const char *message;
int n;
@@ -457,7 +487,7 @@ weechat_lua_print_server (lua_State *L)
*/
static int
weechat_lua_print_infobar (lua_State *L)
weechat_lua_print_infobar (lua_State *L)
{
const char *message;
int delay, n;
@@ -502,7 +532,7 @@ weechat_lua_print_infobar (lua_State *L)
*/
static int
weechat_lua_remove_infobar (lua_State *L)
weechat_lua_remove_infobar (lua_State *L)
{
int n, how_many;
@@ -536,7 +566,7 @@ weechat_lua_remove_infobar (lua_State *L)
*/
static int
weechat_lua_log (lua_State *L)
weechat_lua_log (lua_State *L)
{
const char *message, *channel_name, *server_name;
int n;
@@ -595,7 +625,7 @@ weechat_lua_log (lua_State *L)
*/
static int
weechat_lua_command (lua_State *L)
weechat_lua_command (lua_State *L)
{
const char *command, *channel_name, *server_name;
int n;
@@ -654,7 +684,7 @@ weechat_lua_command (lua_State *L)
*/
static int
weechat_lua_add_message_handler (lua_State *L)
weechat_lua_add_message_handler (lua_State *L)
{
const char *irc_command, *function;
int n;
@@ -706,7 +736,7 @@ weechat_lua_add_message_handler (lua_State *L)
*/
static int
weechat_lua_add_command_handler (lua_State *L)
weechat_lua_add_command_handler (lua_State *L)
{
const char *command, *function, *description, *arguments, *arguments_description;
const char *completion_template;
@@ -778,7 +808,7 @@ weechat_lua_add_command_handler (lua_State *L)
*/
static int
weechat_lua_add_timer_handler (lua_State *L)
weechat_lua_add_timer_handler (lua_State *L)
{
int interval;
const char *function;
@@ -831,7 +861,7 @@ weechat_lua_add_timer_handler (lua_State *L)
*/
static int
weechat_lua_add_keyboard_handler (lua_State *L)
weechat_lua_add_keyboard_handler (lua_State *L)
{
const char *function;
int n;
@@ -876,6 +906,58 @@ weechat_lua_add_keyboard_handler (lua_State *L)
return 1;
}
/*
* weechat_lua_add_event_handler: add handler for events
*/
static int
weechat_lua_add_event_handler (lua_State *L)
{
const char *event, *function;
int n;
/* make gcc happy */
(void) L;
if (!lua_current_script)
{
lua_plugin->print_server (lua_plugin,
"Lua error: unable to add event handler, "
"script not initialized");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
event = NULL;
function = NULL;
n = lua_gettop (lua_current_interpreter);
if (n != 2)
{
lua_plugin->print_server (lua_plugin,
"Lua error: wrong parameters for "
"\"add_event_handler\" function");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
event = lua_tostring (lua_current_interpreter, -2);
function = lua_tostring (lua_current_interpreter, -1);
if (!lua_plugin->event_handler_add (lua_plugin, (char *) event,
weechat_lua_event_handler,
(char *) function,
(void *)lua_current_script))
{
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
lua_pushnumber (lua_current_interpreter, 1);
return 1;
}
/*
* weechat_lua_remove_handler: remove a command/message handler
*/
@@ -1010,6 +1092,50 @@ weechat_lua_remove_keyboard_handler (lua_State *L)
return 1;
}
/*
* weechat_lua_remove_event_handler: remove an event handler
*/
static int
weechat_lua_remove_event_handler (lua_State *L)
{
const char *function;
int n;
/* make gcc happy */
(void) L;
if (!lua_current_script)
{
lua_plugin->print_server (lua_plugin,
"Lua error: unable to remove event handler, "
"script not initialized");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
function = NULL;
n = lua_gettop (lua_current_interpreter);
if (n != 1)
{
lua_plugin->print_server (lua_plugin,
"Lua error: wrong parameters for "
"\"remove_event_handler\" function");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
function = lua_tostring (lua_current_interpreter, -1);
weechat_script_remove_event_handler (lua_plugin, lua_current_script,
(char *) function);
lua_pushnumber (lua_current_interpreter, 1);
return 1;
}
/*
* weechat_lua_add_modifier: add a modifier
*/
@@ -1118,7 +1244,7 @@ weechat_lua_remove_modifier (lua_State *L)
*/
static int
weechat_lua_get_info (lua_State *L)
weechat_lua_get_info (lua_State *L)
{
const char *arg, *server_name;
char *info;
@@ -1172,7 +1298,7 @@ weechat_lua_get_info (lua_State *L)
*/
static int
weechat_lua_get_dcc_info (lua_State *L)
weechat_lua_get_dcc_info (lua_State *L)
{
t_plugin_dcc_info *dcc_info, *ptr_dcc;
char timebuffer1[64];
@@ -1289,7 +1415,7 @@ weechat_lua_get_dcc_info (lua_State *L)
*/
static int
weechat_lua_get_config (lua_State *L)
weechat_lua_get_config (lua_State *L)
{
const char *option;
char *return_value;
@@ -1336,7 +1462,7 @@ weechat_lua_get_config (lua_State *L)
*/
static int
weechat_lua_set_config (lua_State *L)
weechat_lua_set_config (lua_State *L)
{
const char *option, *value;
int n;
@@ -1383,7 +1509,7 @@ weechat_lua_set_config (lua_State *L)
*/
static int
weechat_lua_get_plugin_config (lua_State *L)
weechat_lua_get_plugin_config (lua_State *L)
{
const char *option;
char *return_value;
@@ -1432,7 +1558,7 @@ weechat_lua_get_plugin_config (lua_State *L)
*/
static int
weechat_lua_set_plugin_config (lua_State *L)
weechat_lua_set_plugin_config (lua_State *L)
{
const char *option, *value;
int n;
@@ -1481,7 +1607,7 @@ weechat_lua_set_plugin_config (lua_State *L)
*/
static int
weechat_lua_get_server_info (lua_State *L)
weechat_lua_get_server_info (lua_State *L)
{
t_plugin_server_info *server_info, *ptr_server;
char timebuffer[64];
@@ -1627,7 +1753,7 @@ weechat_lua_get_server_info (lua_State *L)
*/
static int
weechat_lua_get_channel_info (lua_State *L)
weechat_lua_get_channel_info (lua_State *L)
{
t_plugin_channel_info *channel_info, *ptr_channel;
const char *server;
@@ -1711,7 +1837,7 @@ weechat_lua_get_channel_info (lua_State *L)
*/
static int
weechat_lua_get_nick_info (lua_State *L)
weechat_lua_get_nick_info (lua_State *L)
{
t_plugin_nick_info *nick_info, *ptr_nick;
const char *server, *channel;
@@ -1825,7 +1951,7 @@ weechat_lua_get_irc_color (lua_State *L)
*/
static int
weechat_lua_get_window_info (lua_State *L)
weechat_lua_get_window_info (lua_State *L)
{
t_plugin_window_info *window_info, *ptr_window;
int i;
@@ -1897,7 +2023,7 @@ weechat_lua_get_window_info (lua_State *L)
*/
static int
weechat_lua_get_buffer_info (lua_State *L)
weechat_lua_get_buffer_info (lua_State *L)
{
t_plugin_buffer_info *buffer_info, *ptr_buffer;
@@ -1929,7 +2055,7 @@ weechat_lua_get_buffer_info (lua_State *L)
lua_pushstring (lua_current_interpreter, "type");
lua_pushnumber (lua_current_interpreter, ptr_buffer->type);
lua_rawset (lua_current_interpreter, -3);
lua_pushstring (lua_current_interpreter, "num_displayed");
lua_pushnumber (lua_current_interpreter, ptr_buffer->num_displayed);
lua_rawset (lua_current_interpreter, -3);
@@ -1966,7 +2092,7 @@ weechat_lua_get_buffer_info (lua_State *L)
*/
static int
weechat_lua_get_buffer_data (lua_State *L)
weechat_lua_get_buffer_data (lua_State *L)
{
t_plugin_buffer_line *buffer_data, *ptr_data;
const char *server, *channel;
@@ -2053,7 +2179,7 @@ weechat_lua_get_buffer_data (lua_State *L)
*/
static int
weechat_lua_constant_plugin_rc_ok (lua_State *L)
weechat_lua_constant_plugin_rc_ok (lua_State *L)
{
/* make gcc happy */
(void) L;
@@ -2063,7 +2189,7 @@ weechat_lua_constant_plugin_rc_ok (lua_State *L)
}
static int
weechat_lua_constant_plugin_rc_ko (lua_State *L)
weechat_lua_constant_plugin_rc_ko (lua_State *L)
{
/* make gcc happy */
(void) L;
@@ -2073,7 +2199,7 @@ weechat_lua_constant_plugin_rc_ko (lua_State *L)
}
static int
weechat_lua_constant_plugin_rc_ok_ignore_weechat (lua_State *L)
weechat_lua_constant_plugin_rc_ok_ignore_weechat (lua_State *L)
{
/* make gcc happy */
(void) L;
@@ -2083,7 +2209,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_weechat (lua_State *L)
}
static int
weechat_lua_constant_plugin_rc_ok_ignore_plugins (lua_State *L)
weechat_lua_constant_plugin_rc_ok_ignore_plugins (lua_State *L)
{
/* make gcc happy */
(void) L;
@@ -2093,7 +2219,7 @@ weechat_lua_constant_plugin_rc_ok_ignore_plugins (lua_State *L)
}
static int
weechat_lua_constant_plugin_rc_ok_ignore_all (lua_State *L)
weechat_lua_constant_plugin_rc_ok_ignore_all (lua_State *L)
{
/* make gcc happy */
(void) L;
@@ -2120,9 +2246,11 @@ const struct luaL_reg weechat_lua_funcs[] = {
{ "add_command_handler", weechat_lua_add_command_handler },
{ "add_timer_handler", weechat_lua_add_timer_handler },
{ "add_keyboard_handler", weechat_lua_add_keyboard_handler },
{ "add_event_handler", weechat_lua_add_event_handler },
{ "remove_handler", weechat_lua_remove_handler },
{ "remove_timer_handler", weechat_lua_remove_timer_handler },
{ "remove_keyboard_handler", weechat_lua_remove_keyboard_handler },
{ "remove_event_handler", weechat_lua_remove_event_handler },
{ "add_modifier", weechat_lua_add_modifier },
{ "remove_modifier", weechat_lua_remove_modifier },
{ "get_info", weechat_lua_get_info },
+106
View File
@@ -320,6 +320,35 @@ weechat_perl_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_perl_event_handler: general event handler for Perl
*/
int
weechat_perl_event_handler (t_weechat_plugin *plugin,
int argc, char **argv,
char *handler_args, void *handler_pointer)
{
int *r, ret;
if (argc >= 1)
{
r = (int *) weechat_perl_exec (plugin, (t_plugin_script *)handler_pointer,
SCRIPT_EXEC_INT,
handler_args, argv[0], NULL, NULL);
if (r == NULL)
ret = PLUGIN_RC_KO;
else
{
ret = *r;
free (r);
}
return ret;
}
else
return PLUGIN_RC_KO;
}
/*
* weechat_perl_modifier: general modifier for Perl
*/
@@ -835,6 +864,45 @@ static XS (XS_weechat_add_keyboard_handler)
XSRETURN_NO;
}
/*
* weechat::add_event_handler: add an event handler
*/
static XS (XS_weechat_add_event_handler)
{
char *event, *function;
dXSARGS;
/* make gcc happy */
(void) cv;
if (!perl_current_script)
{
perl_plugin->print_server (perl_plugin,
"Perl error: unable to add event handler, "
"script not initialized");
XSRETURN_NO;
}
if (items < 2)
{
perl_plugin->print_server (perl_plugin,
"Perl error: wrong parameters for "
"\"add_event_handler\" function");
XSRETURN_NO;
}
event = SvPV (ST (0), PL_na);
function = SvPV (ST (1), PL_na);
if (perl_plugin->event_handler_add (perl_plugin, event,
weechat_perl_event_handler, function,
(void *)perl_current_script))
XSRETURN_YES;
XSRETURN_NO;
}
/*
* weechat::remove_handler: remove a message/command handler
*/
@@ -944,6 +1012,42 @@ static XS (XS_weechat_remove_keyboard_handler)
XSRETURN_YES;
}
/*
* weechat::remove_event_handler: remove an event handler
*/
static XS (XS_weechat_remove_event_handler)
{
char *function;
dXSARGS;
/* make gcc happy */
(void) cv;
if (!perl_current_script)
{
perl_plugin->print_server (perl_plugin,
"Perl error: unable to remove event handler, "
"script not initialized");
XSRETURN_NO;
}
if (items < 1)
{
perl_plugin->print_server (perl_plugin,
"Perl error: wrong parameters for "
"\"remove_event_handler\" function");
XSRETURN_NO;
}
function = SvPV (ST (0), PL_na);
weechat_script_remove_event_handler (perl_plugin, perl_current_script,
function);
XSRETURN_YES;
}
/*
* weechat::add_modifier: add a modifier
*/
@@ -1798,9 +1902,11 @@ weechat_perl_xs_init (pTHX)
newXS ("weechat::add_command_handler", XS_weechat_add_command_handler, "weechat");
newXS ("weechat::add_timer_handler", XS_weechat_add_timer_handler, "weechat");
newXS ("weechat::add_keyboard_handler", XS_weechat_add_keyboard_handler, "weechat");
newXS ("weechat::add_event_handler", XS_weechat_add_event_handler, "weechat");
newXS ("weechat::remove_handler", XS_weechat_remove_handler, "weechat");
newXS ("weechat::remove_timer_handler", XS_weechat_remove_timer_handler, "weechat");
newXS ("weechat::remove_keyboard_handler", XS_weechat_remove_keyboard_handler, "weechat");
newXS ("weechat::remove_event_handler", XS_weechat_remove_event_handler, "weechat");
newXS ("weechat::add_modifier", XS_weechat_add_modifier, "weechat");
newXS ("weechat::remove_modifier", XS_weechat_remove_modifier, "weechat");
newXS ("weechat::get_info", XS_weechat_get_info, "weechat");
+108
View File
@@ -242,6 +242,36 @@ weechat_python_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_python_event_handler: general event handler for Python
*/
int
weechat_python_event_handler (t_weechat_plugin *plugin,
int argc, char **argv,
char *handler_args, void *handler_pointer)
{
int *r;
int ret;
if (argc >= 1)
{
r = (int *) weechat_python_exec (plugin, (t_plugin_script *)handler_pointer,
SCRIPT_EXEC_INT,
handler_args, argv[0], NULL, NULL);
if (r == NULL)
ret = PLUGIN_RC_KO;
else
{
ret = *r;
free (r);
}
return ret;
}
else
return PLUGIN_RC_KO;
}
/*
* weechat_python_modifier: general modifier for Python
*/
@@ -755,6 +785,46 @@ weechat_python_add_keyboard_handler (PyObject *self, PyObject *args)
return Py_BuildValue ("i", 0);
}
/*
* weechat_python_add_event_handler: add handler for events
*/
static PyObject *
weechat_python_add_event_handler (PyObject *self, PyObject *args)
{
char *event, *function;
/* make gcc happy */
(void) self;
if (!python_current_script)
{
python_plugin->print_server (python_plugin,
"Python error: unable to add event handler, "
"script not initialized");
return Py_BuildValue ("i", 0);
}
event = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "ss", &event, &function))
{
python_plugin->print_server (python_plugin,
"Python error: wrong parameters for "
"\"add_event_handler\" function");
return Py_BuildValue ("i", 0);
}
if (python_plugin->event_handler_add (python_plugin, event,
weechat_python_event_handler,
function,
(void *)python_current_script))
return Py_BuildValue ("i", 1);
return Py_BuildValue ("i", 0);
}
/*
* weechat_python_remove_handler: remove a handler
*/
@@ -864,6 +934,42 @@ weechat_python_remove_keyboard_handler (PyObject *self, PyObject *args)
return Py_BuildValue ("i", 1);
}
/*
* weechat_python_remove_event_handler: remove an event handler
*/
static PyObject *
weechat_python_remove_event_handler (PyObject *self, PyObject *args)
{
char *function;
/* make gcc happy */
(void) self;
if (!python_current_script)
{
python_plugin->print_server (python_plugin,
"Python error: unable to remove event handler, "
"script not initialized");
return Py_BuildValue ("i", 0);
}
function = NULL;
if (!PyArg_ParseTuple (args, "s", &function))
{
python_plugin->print_server (python_plugin,
"Python error: wrong parameters for "
"\"remove_event_handler\" function");
return Py_BuildValue ("i", 0);
}
weechat_script_remove_event_handler (python_plugin, python_current_script,
function);
return Py_BuildValue ("i", 1);
}
/*
* weechat_python_add_modifier: add a modifier
*/
@@ -1761,9 +1867,11 @@ PyMethodDef weechat_python_funcs[] = {
{ "add_command_handler", weechat_python_add_command_handler, METH_VARARGS, "" },
{ "add_timer_handler", weechat_python_add_timer_handler, METH_VARARGS, "" },
{ "add_keyboard_handler", weechat_python_add_keyboard_handler, METH_VARARGS, "" },
{ "add_event_handler", weechat_python_add_event_handler, METH_VARARGS, "" },
{ "remove_handler", weechat_python_remove_handler, METH_VARARGS, "" },
{ "remove_timer_handler", weechat_python_remove_timer_handler, METH_VARARGS, "" },
{ "remove_keyboard_handler", weechat_python_remove_keyboard_handler, METH_VARARGS, "" },
{ "remove_event_handler", weechat_python_remove_event_handler, METH_VARARGS, "" },
{ "add_modifier", weechat_python_add_modifier, METH_VARARGS, "" },
{ "remove_modifier", weechat_python_remove_modifier, METH_VARARGS, "" },
{ "get_info", weechat_python_get_info, METH_VARARGS, "" },
+118
View File
@@ -281,6 +281,36 @@ weechat_ruby_keyboard_handler (t_weechat_plugin *plugin,
return PLUGIN_RC_KO;
}
/*
* weechat_ruby_event_handler: general event handler for Ruby
*/
int
weechat_ruby_event_handler (t_weechat_plugin *plugin,
int argc, char **argv,
char *handler_args, void *handler_pointer)
{
int *r;
int ret;
if (argc >= 1)
{
r = (int *) weechat_ruby_exec (plugin, (t_plugin_script *)handler_pointer,
SCRIPT_EXEC_INT,
handler_args, argv[0], NULL, NULL);
if (r == NULL)
ret = PLUGIN_RC_KO;
else
{
ret = *r;
free (r);
}
return ret;
}
else
return PLUGIN_RC_KO;
}
/*
* weechat_ruby_modifier: general modifier for Ruby
*/
@@ -947,6 +977,52 @@ weechat_ruby_add_keyboard_handler (VALUE class, VALUE function)
return INT2FIX (0);
}
/*
* weechat_ruby_add_event_handler: add a handler for events
*/
static VALUE
weechat_ruby_add_event_handler (VALUE class, VALUE event, VALUE function)
{
char *c_event, *c_function;
/* make gcc happy */
(void) class;
if (!ruby_current_script)
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: unable to add event handler, "
"script not initialized");
return INT2FIX (0);
}
c_event = NULL;
c_function = NULL;
if (NIL_P (event) || NIL_P (function))
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: wrong parameters for "
"\"add_event_handler\" function");
return INT2FIX (0);
}
Check_Type (event, T_STRING);
Check_Type (function, T_STRING);
c_event = STR2CSTR (event);
c_function = STR2CSTR (function);
if (ruby_plugin->event_handler_add (ruby_plugin, c_event,
weechat_ruby_event_handler,
c_function,
(void *)ruby_current_script))
return INT2FIX (1);
return INT2FIX (0);
}
/*
* weechat_ruby_remove_handler: remove a handler
*/
@@ -1070,6 +1146,46 @@ weechat_ruby_remove_keyboard_handler (VALUE class, VALUE function)
return INT2FIX (1);
}
/*
* weechat_ruby_remove_event_handler: remove an event handler
*/
static VALUE
weechat_ruby_remove_event_handler (VALUE class, VALUE function)
{
char *c_function;
/* make gcc happy */
(void) class;
if (!ruby_current_script)
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: unable to remove event handler, "
"script not initialized");
return INT2FIX (0);
}
c_function = NULL;
if (NIL_P (function))
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: wrong parameters for "
"\"remove_event_handler\" function");
return INT2FIX (0);
}
Check_Type (function, T_STRING);
c_function = STR2CSTR (function);
weechat_script_remove_event_handler (ruby_plugin, ruby_current_script,
c_function);
return INT2FIX (1);
}
/*
* weechat_ruby_add_modifier: add a modifier
*/
@@ -2486,9 +2602,11 @@ weechat_plugin_init (t_weechat_plugin *plugin)
rb_define_module_function (ruby_mWeechat, "add_command_handler", weechat_ruby_add_command_handler, -1);
rb_define_module_function (ruby_mWeechat, "add_timer_handler", weechat_ruby_add_timer_handler, 2);
rb_define_module_function (ruby_mWeechat, "add_keyboard_handler", weechat_ruby_add_keyboard_handler, 1);
rb_define_module_function (ruby_mWeechat, "add_event_handler", weechat_ruby_add_event_handler, 2);
rb_define_module_function (ruby_mWeechat, "remove_handler", weechat_ruby_remove_handler, 2);
rb_define_module_function (ruby_mWeechat, "remove_timer_handler", weechat_ruby_remove_timer_handler, 1);
rb_define_module_function (ruby_mWeechat, "remove_keyboard_handler", weechat_ruby_remove_keyboard_handler, 1);
rb_define_module_function (ruby_mWeechat, "remove_event_handler", weechat_ruby_remove_event_handler, 1);
rb_define_module_function (ruby_mWeechat, "add_modifier", weechat_ruby_add_modifier, 3);
rb_define_module_function (ruby_mWeechat, "remove_modifier", weechat_ruby_remove_modifier, 3);
rb_define_module_function (ruby_mWeechat, "get_info", weechat_ruby_get_info, -1);
+28
View File
@@ -516,6 +516,34 @@ weechat_script_remove_keyboard_handler (t_weechat_plugin *plugin,
}
}
/*
* weechat_script_remove_event_handler: remove an event handler for a script
*/
void
weechat_script_remove_event_handler (t_weechat_plugin *plugin,
t_plugin_script *script,
char *function)
{
t_plugin_handler *ptr_handler, *next_handler;
/* search and remove timer handlers */
ptr_handler = plugin->handlers;
while (ptr_handler)
{
if ((ptr_handler->type == PLUGIN_HANDLER_EVENT)
&& ((t_plugin_script *)ptr_handler->handler_pointer == script)
&& (plugin->ascii_strcasecmp (plugin, ptr_handler->handler_args, function) == 0))
{
next_handler = ptr_handler->next_handler;
plugin->handler_remove (plugin, ptr_handler);
ptr_handler = next_handler;
}
else
ptr_handler = ptr_handler->next_handler;
}
}
/*
* weechat_script_remove_modifier: remove a modifier
* arg1=type, arg2=command, arg3=function
+3
View File
@@ -79,6 +79,9 @@ extern void weechat_script_remove_timer_handler (t_weechat_plugin *,
extern void weechat_script_remove_keyboard_handler (t_weechat_plugin *,
t_plugin_script *,
char *);
extern void weechat_script_remove_event_handler (t_weechat_plugin *,
t_plugin_script *,
char *);
extern void weechat_script_remove_modifier (t_weechat_plugin *,
t_plugin_script *,
char *, char *, char *);