1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 13:26:38 +02:00

api: add new function config_set_desc_plugin (task #10925)

This commit is contained in:
Sebastien Helleu
2011-04-26 17:47:49 +02:00
parent 51f836feb8
commit 3fd2af8184
27 changed files with 601 additions and 17 deletions
+39
View File
@@ -2911,6 +2911,44 @@ weechat_lua_api_config_set_plugin (lua_State *L)
LUA_RETURN_INT(rc);
}
/*
* weechat_lua_api_config_set_desc_plugin: set description of a plugin option
*/
static int
weechat_lua_api_config_set_desc_plugin (lua_State *L)
{
const char *option, *description;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script || !lua_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
LUA_RETURN_ERROR;
}
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
LUA_RETURN_ERROR;
}
option = lua_tostring (lua_current_interpreter, -2);
description = lua_tostring (lua_current_interpreter, -1);
script_api_config_set_desc_plugin (weechat_lua_plugin,
lua_current_script,
option,
description);
LUA_RETURN_OK;
}
/*
* weechat_lua_api_config_unset_plugin: unset plugin option
*/
@@ -7800,6 +7838,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "config_get_plugin", &weechat_lua_api_config_get_plugin },
{ "config_is_set_plugin", &weechat_lua_api_config_is_set_plugin },
{ "config_set_plugin", &weechat_lua_api_config_set_plugin },
{ "config_set_desc_plugin", &weechat_lua_api_config_set_desc_plugin },
{ "config_unset_plugin", &weechat_lua_api_config_unset_plugin },
{ "prefix", &weechat_lua_api_prefix },
{ "color", &weechat_lua_api_color },
@@ -2610,6 +2610,41 @@ XS (XS_weechat_api_config_set_plugin)
PERL_RETURN_INT(rc);
}
/*
* weechat::config_set_desc_plugin: set description of a plugin option
*/
XS (XS_weechat_api_config_set_desc_plugin)
{
char *option, *description;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script || !perl_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PERL_RETURN_ERROR;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PERL_RETURN_ERROR;
}
option = SvPV (ST (0), PL_na);
description = SvPV (ST (1), PL_na);
script_api_config_set_desc_plugin (weechat_perl_plugin,
perl_current_script,
option,
description);
PERL_RETURN_OK;
}
/*
* weechat::config_unset_plugin: unset a plugin option
*/
@@ -6729,6 +6764,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::config_get_plugin", XS_weechat_api_config_get_plugin, "weechat");
newXS ("weechat::config_is_set_plugin", XS_weechat_api_config_is_set_plugin, "weechat");
newXS ("weechat::config_set_plugin", XS_weechat_api_config_set_plugin, "weechat");
newXS ("weechat::config_set_desc_plugin", XS_weechat_api_config_set_desc_plugin, "weechat");
newXS ("weechat::config_unset_plugin", XS_weechat_api_config_unset_plugin, "weechat");
newXS ("weechat::prefix", XS_weechat_api_prefix, "weechat");
newXS ("weechat::color", XS_weechat_api_color, "weechat");
@@ -2759,6 +2759,41 @@ weechat_python_api_config_set_plugin (PyObject *self, PyObject *args)
PYTHON_RETURN_INT(rc);
}
/*
* weechat_python_api_config_set_desc_plugin: set description of a plugin option
*/
static PyObject *
weechat_python_api_config_set_desc_plugin (PyObject *self, PyObject *args)
{
char *option, *description;
/* make C compiler happy */
(void) self;
if (!python_current_script || !python_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PYTHON_RETURN_ERROR;
}
option = NULL;
description = NULL;
if (!PyArg_ParseTuple (args, "ss", &option, &description))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
PYTHON_RETURN_ERROR;
}
script_api_config_set_desc_plugin (weechat_python_plugin,
python_current_script,
option,
description);
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_config_unset_plugin: unset plugin option
*/
@@ -7066,6 +7101,7 @@ PyMethodDef weechat_python_funcs[] =
{ "config_get_plugin", &weechat_python_api_config_get_plugin, METH_VARARGS, "" },
{ "config_is_set_plugin", &weechat_python_api_config_is_set_plugin, METH_VARARGS, "" },
{ "config_set_plugin", &weechat_python_api_config_set_plugin, METH_VARARGS, "" },
{ "config_set_desc_plugin", &weechat_python_api_config_set_desc_plugin, METH_VARARGS, "" },
{ "config_unset_plugin", &weechat_python_api_config_unset_plugin, METH_VARARGS, "" },
{ "prefix", &weechat_python_api_prefix, METH_VARARGS, "" },
{ "color", &weechat_python_api_color, METH_VARARGS, "" },
@@ -2992,6 +2992,45 @@ weechat_ruby_api_config_set_plugin (VALUE class, VALUE option, VALUE value)
RUBY_RETURN_INT(rc);
}
/*
* weechat_ruby_api_config_set_desc_plugin: set description of a plugin option
*/
static VALUE
weechat_ruby_api_config_set_desc_plugin (VALUE class, VALUE option,
VALUE description)
{
char *c_option, *c_description;
/* make C compiler happy */
(void) class;
if (!ruby_current_script || !ruby_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
RUBY_RETURN_ERROR;
}
if (NIL_P (option) || NIL_P (description))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
RUBY_RETURN_ERROR;
}
Check_Type (option, T_STRING);
Check_Type (description, T_STRING);
c_option = StringValuePtr (option);
c_description = StringValuePtr (description);
script_api_config_set_desc_plugin (weechat_ruby_plugin,
ruby_current_script,
c_option,
c_description);
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_config_unset_plugin: unset plugin option
*/
@@ -7737,6 +7776,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "config_get_plugin", &weechat_ruby_api_config_get_plugin, 1);
rb_define_module_function (ruby_mWeechat, "config_is_set_plugin", &weechat_ruby_api_config_is_set_plugin, 1);
rb_define_module_function (ruby_mWeechat, "config_set_plugin", &weechat_ruby_api_config_set_plugin, 2);
rb_define_module_function (ruby_mWeechat, "config_set_desc_plugin", &weechat_ruby_api_config_set_desc_plugin, 2);
rb_define_module_function (ruby_mWeechat, "config_unset_plugin", &weechat_ruby_api_config_unset_plugin, 1);
rb_define_module_function (ruby_mWeechat, "prefix", &weechat_ruby_api_prefix, 1);
rb_define_module_function (ruby_mWeechat, "color", &weechat_ruby_api_color, 1);
+25
View File
@@ -1680,6 +1680,31 @@ script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
return return_code;
}
/*
* script_api_config_set_plugin: set value of a script config option
* format in file is "plugin.script.option"
*/
void
script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option, const char *description)
{
char *option_fullname;
option_fullname = malloc ((strlen (script->name) +
strlen (option) + 2));
if (!option_fullname)
return;
strcpy (option_fullname, script->name);
strcat (option_fullname, ".");
strcat (option_fullname, option);
weechat_config_set_desc_plugin (option_fullname, description);
free (option_fullname);
}
/*
* script_api_config_unset_plugin: unset script config option
* format in file is "plugin.script.option"
+4
View File
@@ -317,6 +317,10 @@ extern int script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plu
extern int script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option, const char *value);
extern void script_api_config_set_desc_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option,
const char *description);
extern int script_api_config_unset_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option);
+40
View File
@@ -2984,6 +2984,44 @@ weechat_tcl_api_config_set_plugin (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_INT(rc);
}
/*
* weechat_tcl_api_config_set_desc_plugin: set description of a plugin option
*/
static int
weechat_tcl_api_config_set_desc_plugin (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *option, *description;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script || !tcl_current_script->name)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
TCL_RETURN_ERROR;
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_set_desc_plugin");
TCL_RETURN_ERROR;
}
option = Tcl_GetStringFromObj (objv[1], &i);
description = Tcl_GetStringFromObj (objv[2], &i);
script_api_config_set_desc_plugin (weechat_tcl_plugin,
tcl_current_script,
option,
description);
TCL_RETURN_OK;
}
/*
* weechat_tcl_api_config_set_plugin: unset plugin option
*/
@@ -7639,6 +7677,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_config_is_set_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::config_set_plugin",
weechat_tcl_api_config_set_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::config_set_desc_plugin",
weechat_tcl_api_config_set_desc_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::config_unset_plugin",
weechat_tcl_api_config_unset_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::prefix",