mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
Add description for info and infolist hooks
This commit is contained in:
@@ -45,7 +45,7 @@ struct t_config_file *config_files = NULL;
|
||||
struct t_config_file *last_config_file = NULL;
|
||||
|
||||
char *config_option_type_string[CONFIG_NUM_OPTION_TYPES] =
|
||||
{ "boolean", "integer", "string", "color" };
|
||||
{ N_("boolean"), N_("integer"), N_("string"), N_("color") };
|
||||
char *config_boolean_true[] = { "on", "yes", "y", "true", "t", "1", NULL };
|
||||
char *config_boolean_false[] = { "off", "no", "n", "false", "f", "0", NULL };
|
||||
|
||||
@@ -2182,16 +2182,16 @@ config_file_add_to_infolist (struct t_infolist *infolist,
|
||||
}
|
||||
if (!infolist_new_var_string (ptr_item,
|
||||
"description",
|
||||
(ptr_option->description
|
||||
&& ptr_option->description[0]) ?
|
||||
_(ptr_option->description) : ""))
|
||||
ptr_option->description))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_string (ptr_item,
|
||||
"description_en",
|
||||
ptr_option->description))
|
||||
"description_nls",
|
||||
(ptr_option->description
|
||||
&& ptr_option->description[0]) ?
|
||||
_(ptr_option->description) : ""))
|
||||
{
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
|
||||
+28
-6
@@ -1331,6 +1331,7 @@ hook_modifier_exec (struct t_weechat_plugin *plugin, const char *modifier,
|
||||
|
||||
struct t_hook *
|
||||
hook_info (struct t_weechat_plugin *plugin, const char *info_name,
|
||||
const char *description,
|
||||
t_hook_callback_info *callback, void *callback_data)
|
||||
{
|
||||
struct t_hook *new_hook;
|
||||
@@ -1354,6 +1355,8 @@ hook_info (struct t_weechat_plugin *plugin, const char *info_name,
|
||||
new_hook->hook_data = new_hook_info;
|
||||
new_hook_info->callback = callback;
|
||||
new_hook_info->info_name = strdup (info_name);
|
||||
new_hook_info->description = (description) ?
|
||||
strdup (description) : strdup ("");
|
||||
|
||||
hook_add_to_list (new_hook);
|
||||
|
||||
@@ -1413,6 +1416,7 @@ hook_info_get (struct t_weechat_plugin *plugin, const char *info_name,
|
||||
|
||||
struct t_hook *
|
||||
hook_infolist (struct t_weechat_plugin *plugin, const char *infolist_name,
|
||||
const char *description,
|
||||
t_hook_callback_infolist *callback, void *callback_data)
|
||||
{
|
||||
struct t_hook *new_hook;
|
||||
@@ -1436,6 +1440,8 @@ hook_infolist (struct t_weechat_plugin *plugin, const char *infolist_name,
|
||||
new_hook->hook_data = new_hook_infolist;
|
||||
new_hook_infolist->callback = callback;
|
||||
new_hook_infolist->infolist_name = strdup (infolist_name);
|
||||
new_hook_infolist->description = (description) ?
|
||||
strdup (description) : strdup ("");
|
||||
|
||||
hook_add_to_list (new_hook);
|
||||
|
||||
@@ -1706,26 +1712,26 @@ hook_add_to_infolist_type (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "level", HOOK_COMMAND(ptr_hook, level)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_en",
|
||||
if (!infolist_new_var_string (ptr_item, "description",
|
||||
HOOK_COMMAND(ptr_hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description",
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_COMMAND(ptr_hook, description)
|
||||
&& HOOK_COMMAND(ptr_hook, description)[0]) ?
|
||||
_(HOOK_COMMAND(ptr_hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_en",
|
||||
if (!infolist_new_var_string (ptr_item, "args",
|
||||
HOOK_COMMAND(ptr_hook, args)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args",
|
||||
if (!infolist_new_var_string (ptr_item, "args_nls",
|
||||
(HOOK_COMMAND(ptr_hook, args)
|
||||
&& HOOK_COMMAND(ptr_hook, args)[0]) ?
|
||||
_(HOOK_COMMAND(ptr_hook, args)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_en",
|
||||
if (!infolist_new_var_string (ptr_item, "args_description",
|
||||
HOOK_COMMAND(ptr_hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description",
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_COMMAND(ptr_hook, args_description)
|
||||
&& HOOK_COMMAND(ptr_hook, args_description)[0]) ?
|
||||
_(HOOK_COMMAND(ptr_hook, args_description)) : ""))
|
||||
@@ -1854,6 +1860,13 @@ hook_add_to_infolist_type (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO(ptr_hook, info_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO(ptr_hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFO(ptr_hook, description)
|
||||
&& HOOK_INFO(ptr_hook, description)[0]) ?
|
||||
_(HOOK_INFO(ptr_hook, description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_INFOLIST:
|
||||
@@ -1863,6 +1876,13 @@ hook_add_to_infolist_type (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "infolist_name", HOOK_INFOLIST(ptr_hook, infolist_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFOLIST(ptr_hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFOLIST(ptr_hook, description)
|
||||
&& HOOK_INFOLIST(ptr_hook, description)[0]) ?
|
||||
_(HOOK_INFOLIST(ptr_hook, description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case HOOK_NUM_TYPES:
|
||||
@@ -2043,6 +2063,7 @@ hook_print_log ()
|
||||
log_printf (" info data:");
|
||||
log_printf (" callback . . . . . . : 0x%x", HOOK_INFO(ptr_hook, callback));
|
||||
log_printf (" info_name. . . . . . : '%s'", HOOK_INFO(ptr_hook, info_name));
|
||||
log_printf (" description. . . . . : '%s'", HOOK_INFO(ptr_hook, description));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_INFOLIST:
|
||||
@@ -2051,6 +2072,7 @@ hook_print_log ()
|
||||
log_printf (" infolist data:");
|
||||
log_printf (" callback . . . . . . : 0x%x", HOOK_INFOLIST(ptr_hook, callback));
|
||||
log_printf (" infolist_name. . . . : '%s'", HOOK_INFOLIST(ptr_hook, infolist_name));
|
||||
log_printf (" description. . . . . : '%s'", HOOK_INFOLIST(ptr_hook, description));
|
||||
}
|
||||
break;
|
||||
case HOOK_NUM_TYPES:
|
||||
|
||||
@@ -202,6 +202,7 @@ struct t_hook_info
|
||||
{
|
||||
t_hook_callback_info *callback; /* info callback */
|
||||
char *info_name; /* name of info returned */
|
||||
char *description; /* description */
|
||||
};
|
||||
|
||||
typedef struct t_infolist *(t_hook_callback_infolist)(void *data,
|
||||
@@ -213,6 +214,7 @@ struct t_hook_infolist
|
||||
{
|
||||
t_hook_callback_infolist *callback; /* infolist callback */
|
||||
char *infolist_name; /* name of infolist returned */
|
||||
char *description; /* description */
|
||||
};
|
||||
|
||||
/* hook variables */
|
||||
@@ -297,6 +299,7 @@ extern char *hook_modifier_exec (struct t_weechat_plugin *plugin,
|
||||
const char *string);
|
||||
extern struct t_hook *hook_info (struct t_weechat_plugin *plugin,
|
||||
const char *info_name,
|
||||
const char *description,
|
||||
t_hook_callback_info *callback,
|
||||
void *callback_data);
|
||||
extern char *hook_info_get (struct t_weechat_plugin *plugin,
|
||||
@@ -304,6 +307,7 @@ extern char *hook_info_get (struct t_weechat_plugin *plugin,
|
||||
const char *arguments);
|
||||
extern struct t_hook *hook_infolist (struct t_weechat_plugin *plugin,
|
||||
const char *infolist_name,
|
||||
const char *description,
|
||||
t_hook_callback_infolist *callback,
|
||||
void *callback_data);
|
||||
extern struct t_infolist *hook_infolist_get (struct t_weechat_plugin *plugin,
|
||||
|
||||
@@ -89,5 +89,6 @@ void
|
||||
alias_info_init ()
|
||||
{
|
||||
/* alias infolist hooks */
|
||||
weechat_hook_infolist ("alias", &alias_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("alias", N_("list of alias"),
|
||||
&alias_info_get_infolist_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -53,5 +53,6 @@ void
|
||||
fifo_info_init ()
|
||||
{
|
||||
/* fifo info hooks */
|
||||
weechat_hook_info ("fifo_filename", &fifo_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("fifo_filename", N_("fifo filename"),
|
||||
&fifo_info_get_info_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -326,12 +326,18 @@ void
|
||||
irc_info_init ()
|
||||
{
|
||||
/* irc info hooks */
|
||||
weechat_hook_info ("irc_is_channel", &irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_nick_from_host", &irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_buffer", &irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_is_channel", N_("1 if string is an IRC channel"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_nick_from_host", N_("get nick from IRC host"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
|
||||
/* irc infolist hooks */
|
||||
weechat_hook_infolist ("irc_server", &irc_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("irc_channel", &irc_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("irc_nick", &irc_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("irc_server", N_("list of IRC servers"),
|
||||
&irc_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("irc_channel", N_("list of channels for an IRC server"),
|
||||
&irc_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("irc_nick", N_("list of nicks for an IRC channel"),
|
||||
&irc_info_get_infolist_cb, NULL);
|
||||
}
|
||||
|
||||
@@ -92,5 +92,6 @@ void
|
||||
logger_info_init ()
|
||||
{
|
||||
/* irc infolist hooks */
|
||||
weechat_hook_infolist ("logger_buffer", &logger_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("logger_buffer", N_("list of logger buffers"),
|
||||
&logger_info_get_infolist_cb, NULL);
|
||||
}
|
||||
|
||||
+36
-19
@@ -675,25 +675,42 @@ void
|
||||
plugin_api_init ()
|
||||
{
|
||||
/* WeeChat core info hooks */
|
||||
hook_info (NULL, "version", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "date", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "dir_separator", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_dir", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_libdir", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_sharedir", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_localedir", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "charset_terminal", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "charset_internal", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "inactivity", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "filters_enabled", &plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "version", N_("WeeChat version"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "date", N_("WeeChat compilation date"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "dir_separator", N_("directory separator"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_dir", N_("WeeChat directory"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_libdir", N_("WeeChat \"lib\" directory"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_sharedir", N_("WeeChat \"share\" directory"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "weechat_localedir", N_("WeeChat \"locale\" directory"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "charset_terminal", N_("terminal charset"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "charset_internal", N_("WeeChat internal charset"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "inactivity", N_("keyboard inactivity (seconds)"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
hook_info (NULL, "filters_enabled", N_("1 if filters are enabled"),
|
||||
&plugin_api_info_get_internal, NULL);
|
||||
|
||||
/* WeeChat core infolist hooks */
|
||||
hook_infolist (NULL, "buffer", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "buffer_lines", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "buffer", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "nicklist", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "window", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "hotlist", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "option", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "hook", &plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "buffer", N_("list of buffers"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "buffer_lines", N_("lines of a buffer"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "window", N_("list of windows"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "hotlist", N_("list of buffers in hotlist"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "option", N_("list of options"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "hook", N_("list of hooks"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
}
|
||||
|
||||
@@ -3105,7 +3105,7 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name,
|
||||
static int
|
||||
weechat_lua_api_hook_info (lua_State *L)
|
||||
{
|
||||
const char *info_name, *function;
|
||||
const char *info_name, *description, *function;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
@@ -3123,18 +3123,20 @@ weechat_lua_api_hook_info (lua_State *L)
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
info_name = lua_tostring (lua_current_interpreter, -2);
|
||||
info_name = lua_tostring (lua_current_interpreter, -3);
|
||||
description = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (script_api_hook_info (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
info_name,
|
||||
description,
|
||||
&weechat_lua_api_hook_info_cb,
|
||||
function));
|
||||
|
||||
@@ -3178,7 +3180,7 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
|
||||
static int
|
||||
weechat_lua_api_hook_infolist (lua_State *L)
|
||||
{
|
||||
const char *infolist_name, *function;
|
||||
const char *infolist_name, *description, *function;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
@@ -3196,18 +3198,20 @@ weechat_lua_api_hook_infolist (lua_State *L)
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
infolist_name = lua_tostring (lua_current_interpreter, -2);
|
||||
infolist_name = lua_tostring (lua_current_interpreter, -3);
|
||||
description = lua_tostring (lua_current_interpreter, -2);
|
||||
function = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (script_api_hook_infolist (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
&weechat_lua_api_hook_infolist_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -2597,7 +2597,7 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name,
|
||||
|
||||
static XS (XS_weechat_hook_info)
|
||||
{
|
||||
char *result, *info_name, *perl_fn;
|
||||
char *result, *info_name, *description, *perl_fn;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2609,17 +2609,19 @@ static XS (XS_weechat_hook_info)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
info_name = SvPV (ST (0), PL_na);
|
||||
perl_fn = SvPV (ST (1), PL_na);
|
||||
description = SvPV (ST (1), PL_na);
|
||||
perl_fn = SvPV (ST (2), PL_na);
|
||||
result = script_ptr2str (script_api_hook_info (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
info_name,
|
||||
description,
|
||||
&weechat_perl_api_hook_info_cb,
|
||||
perl_fn));
|
||||
|
||||
@@ -2662,7 +2664,7 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
|
||||
static XS (XS_weechat_hook_infolist)
|
||||
{
|
||||
char *result, *infolist_name, *perl_fn;
|
||||
char *result, *infolist_name, *description, *perl_fn;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2674,17 +2676,19 @@ static XS (XS_weechat_hook_infolist)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
infolist_name = SvPV (ST (0), PL_na);
|
||||
perl_fn = SvPV (ST (1), PL_na);
|
||||
description = SvPV (ST (1), PL_na);
|
||||
perl_fn = SvPV (ST (2), PL_na);
|
||||
result = script_ptr2str (script_api_hook_infolist (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
&weechat_perl_api_hook_infolist_cb,
|
||||
perl_fn));
|
||||
|
||||
|
||||
@@ -2754,7 +2754,7 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name,
|
||||
static PyObject *
|
||||
weechat_python_api_hook_info (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *info_name, *function, *result;
|
||||
char *info_name, *description, *function, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2767,9 +2767,10 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
info_name = NULL;
|
||||
description = NULL;
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &info_name, &function))
|
||||
if (!PyArg_ParseTuple (args, "sss", &info_name, &description, &function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -2778,6 +2779,7 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
|
||||
result = script_ptr2str(script_api_hook_info (weechat_python_plugin,
|
||||
python_current_script,
|
||||
info_name,
|
||||
description,
|
||||
&weechat_python_api_hook_info_cb,
|
||||
function));
|
||||
|
||||
@@ -2821,7 +2823,7 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
static PyObject *
|
||||
weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *infolist_name, *function, *result;
|
||||
char *infolist_name, *description, *function, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2834,9 +2836,10 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
infolist_name = NULL;
|
||||
description = NULL;
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &infolist_name, &function))
|
||||
if (!PyArg_ParseTuple (args, "sss", &infolist_name, &description, &function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -2845,6 +2848,7 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
|
||||
result = script_ptr2str(script_api_hook_infolist (weechat_python_plugin,
|
||||
python_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
&weechat_python_api_hook_infolist_cb,
|
||||
function));
|
||||
|
||||
|
||||
@@ -3162,9 +3162,10 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE function)
|
||||
weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description,
|
||||
VALUE function)
|
||||
{
|
||||
char *c_info_name, *c_function, *result;
|
||||
char *c_info_name, *c_description, *c_function, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -3177,23 +3178,27 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE function)
|
||||
}
|
||||
|
||||
c_info_name = NULL;
|
||||
c_description = NULL;
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (info_name) || NIL_P (function))
|
||||
if (NIL_P (info_name) || NIL_P (description) || NIL_P (function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_info");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (info_name, T_STRING);
|
||||
Check_Type (description, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_info_name = STR2CSTR (info_name);
|
||||
c_description = STR2CSTR (description);
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
result = script_ptr2str (script_api_hook_info (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_info_name,
|
||||
c_description,
|
||||
&weechat_ruby_api_hook_info_cb,
|
||||
c_function));
|
||||
|
||||
@@ -3235,9 +3240,10 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, VALUE function)
|
||||
weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name,
|
||||
VALUE description, VALUE function)
|
||||
{
|
||||
char *c_infolist_name, *c_function, *result;
|
||||
char *c_infolist_name, *c_description, *c_function, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -3250,23 +3256,27 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name, VALUE function
|
||||
}
|
||||
|
||||
c_infolist_name = NULL;
|
||||
c_description = NULL;
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (infolist_name) || NIL_P (function))
|
||||
if (NIL_P (infolist_name) || NIL_P (description) || NIL_P (function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_infolist");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (infolist_name, T_STRING);
|
||||
Check_Type (description, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
c_infolist_name = STR2CSTR (infolist_name);
|
||||
c_description = STR2CSTR (description);
|
||||
c_function = STR2CSTR (function);
|
||||
|
||||
result = script_ptr2str (script_api_hook_infolist (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_infolist_name,
|
||||
c_description,
|
||||
&weechat_ruby_api_hook_infolist_cb,
|
||||
c_function));
|
||||
|
||||
@@ -4964,8 +4974,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "hook_completion_list_add", &weechat_ruby_api_hook_completion_list_add, 4);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_modifier", &weechat_ruby_api_hook_modifier, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_modifier_exec", &weechat_ruby_api_hook_modifier_exec, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "unhook_all", &weechat_ruby_api_unhook_all, 0);
|
||||
rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 4);
|
||||
|
||||
@@ -884,6 +884,7 @@ struct t_hook *
|
||||
script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *info_name,
|
||||
const char *description,
|
||||
char *(*callback)(void *data,
|
||||
const char *info_name,
|
||||
const char *arguments),
|
||||
@@ -896,7 +897,8 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = weechat_hook_info (info_name, callback, new_script_callback);
|
||||
new_hook = weechat_hook_info (info_name, description,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
script_callback_free_data (new_script_callback);
|
||||
@@ -922,6 +924,7 @@ struct t_hook *
|
||||
script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *infolist_name,
|
||||
const char *description,
|
||||
struct t_infolist *(*callback)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
@@ -935,7 +938,7 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = weechat_hook_infolist (infolist_name,
|
||||
new_hook = weechat_hook_infolist (infolist_name, description,
|
||||
callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
|
||||
@@ -153,6 +153,7 @@ extern struct t_hook *script_api_hook_modifier (struct t_weechat_plugin *weechat
|
||||
extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *info_name,
|
||||
const char *description,
|
||||
char *(*callback)(void *data,
|
||||
const char *info_name,
|
||||
const char *arguments),
|
||||
@@ -160,6 +161,7 @@ extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plu
|
||||
extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *infolist_name,
|
||||
const char *description,
|
||||
struct t_infolist *(*callback)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
|
||||
@@ -370,12 +370,14 @@ struct t_weechat_plugin
|
||||
const char *string);
|
||||
struct t_hook *(*hook_info) (struct t_weechat_plugin *plugin,
|
||||
const char *info_name,
|
||||
const char *description,
|
||||
char *(*callback)(void *data,
|
||||
const char *info_name,
|
||||
const char *arguments),
|
||||
void *callback_data);
|
||||
struct t_hook *(*hook_infolist) (struct t_weechat_plugin *plugin,
|
||||
const char *infolist_name,
|
||||
const char *description,
|
||||
struct t_infolist *(*callback)(void *data,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
@@ -836,12 +838,14 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
__string) \
|
||||
weechat_plugin->hook_modifier_exec(weechat_plugin, __modifier, \
|
||||
__modifier_data, __string)
|
||||
#define weechat_hook_info(__info_name, __callback, __data) \
|
||||
#define weechat_hook_info(__info_name, __description, __callback, \
|
||||
__data) \
|
||||
weechat_plugin->hook_info(weechat_plugin, __info_name, \
|
||||
__callback, __data)
|
||||
#define weechat_hook_infolist(__infolist_name, __callback, __data) \
|
||||
__description, __callback, __data)
|
||||
#define weechat_hook_infolist(__infolist_name, __description, \
|
||||
__callback, __data) \
|
||||
weechat_plugin->hook_infolist(weechat_plugin, __infolist_name, \
|
||||
__callback, __data)
|
||||
__description, __callback, __data)
|
||||
#define weechat_unhook(__hook) \
|
||||
weechat_plugin->unhook( __hook)
|
||||
#define weechat_unhook_all() \
|
||||
|
||||
@@ -90,5 +90,6 @@ void
|
||||
xfer_info_init ()
|
||||
{
|
||||
/* xfer infolist hooks */
|
||||
weechat_hook_infolist ("xfer", &xfer_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("xfer", N_("list of xfer"),
|
||||
&xfer_info_get_infolist_cb, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user