summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/plugin-api.c20
-rw-r--r--src/plugins/plugin-api.h2
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c39
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c35
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c35
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c37
-rw-r--r--src/plugins/scripts/script-api.c27
-rw-r--r--src/plugins/scripts/script-api.h3
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c38
-rw-r--r--src/plugins/weechat-plugin.h4
11 files changed, 241 insertions, 0 deletions
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index a9028e356..c7c867b46 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -125,6 +125,26 @@ plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
}
/*
+ * plugin_api_config_is_set_plugin: return 1 if plugin option is set, otherwise 0
+ */
+
+int
+plugin_api_config_is_set_plugin (struct t_weechat_plugin *plugin,
+ const char *option_name)
+{
+ struct t_config_option *ptr_option;
+
+ if (!plugin || !option_name)
+ return 0;
+
+ ptr_option = plugin_config_search (plugin->name, option_name);
+ if (ptr_option)
+ return 1;
+
+ return 0;
+}
+
+/*
* plugin_api_config_set_plugin: set value of a plugin config option
*/
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index df1ba31dd..42e2a185f 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -31,6 +31,8 @@ extern const char *plugin_api_ngettext (const char *single, const char *plural,
extern struct t_config_option *plugin_api_config_get (const char *option_name);
extern const char *plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
const char *option_name);
+extern int plugin_api_config_is_set_plugin (struct t_weechat_plugin *plugin,
+ const char *option_name);
extern int plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
const char *option_name,
const char *value);
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 623e802cc..3f5f443e0 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -485,6 +485,7 @@ plugin_load (const char *filename)
new_plugin->config_free = &config_file_free;
new_plugin->config_get = &plugin_api_config_get;
new_plugin->config_get_plugin = &plugin_api_config_get_plugin;
+ new_plugin->config_is_set_plugin = &plugin_api_config_is_set_plugin;
new_plugin->config_set_plugin = &plugin_api_config_set_plugin;
new_plugin->config_unset_plugin = &plugin_api_config_unset_plugin;
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index a19eb6b34..5f3852128 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -2692,6 +2692,44 @@ weechat_lua_api_config_get_plugin (lua_State *L)
}
/*
+ * weechat_lua_api_config_is_set_plugin: check if a plugin option is set
+ */
+
+static int
+weechat_lua_api_config_is_set_plugin (lua_State *L)
+{
+ const char *option;
+ int n, rc;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ LUA_RETURN_INT(0);
+ }
+
+ option = NULL;
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 1)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ LUA_RETURN_INT(0);
+ }
+
+ option = lua_tostring (lua_current_interpreter, -1);
+
+ rc = script_api_config_is_set_plugin (weechat_lua_plugin,
+ lua_current_script,
+ option);
+
+ LUA_RETURN_INT(rc);
+}
+
+/*
* weechat_lua_api_config_set_plugin: set value of a plugin option
*/
@@ -7047,6 +7085,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "config_free", &weechat_lua_api_config_free },
{ "config_get", &weechat_lua_api_config_get },
{ "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_unset_plugin", &weechat_lua_api_config_unset_plugin },
{ "prefix", &weechat_lua_api_prefix },
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index 419f8b45b..f3fe2fe37 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -2258,6 +2258,40 @@ static XS (XS_weechat_api_config_get_plugin)
}
/*
+ * weechat::config_is_set_plugin: check if a plugin option is set
+ */
+
+static XS (XS_weechat_api_config_is_set_plugin)
+{
+ char *option;
+ int rc;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ PERL_RETURN_INT(0);
+ }
+
+ if (items < 1)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ PERL_RETURN_INT(0);
+ }
+
+ option = SvPV (ST (0), PL_na);
+
+ rc = script_api_config_is_set_plugin (weechat_perl_plugin,
+ perl_current_script,
+ option);
+
+ PERL_RETURN_INT(rc);
+}
+
+/*
* weechat::config_set_plugin: set value of a plugin option
*/
@@ -5646,6 +5680,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::config_free", XS_weechat_api_config_free, "weechat");
newXS ("weechat::config_get", XS_weechat_api_config_get, "weechat");
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_unset_plugin", XS_weechat_api_config_unset_plugin, "weechat");
newXS ("weechat::prefix", XS_weechat_api_prefix, "weechat");
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index 6cf94d2e3..0c58130b1 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -2387,6 +2387,40 @@ weechat_python_api_config_get_plugin (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_config_is_set_plugin: check if a plugin option is set
+ */
+
+static PyObject *
+weechat_python_api_config_is_set_plugin (PyObject *self, PyObject *args)
+{
+ char *option;
+ int rc;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ PYTHON_RETURN_INT(0);
+ }
+
+ option = NULL;
+
+ if (!PyArg_ParseTuple (args, "s", &option))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
+ }
+
+ rc = script_api_config_is_set_plugin (weechat_python_plugin,
+ python_current_script,
+ option);
+
+ PYTHON_RETURN_INT(rc);
+}
+
+/*
* weechat_python_api_config_set_plugin: set value of a plugin option
*/
@@ -5924,6 +5958,7 @@ PyMethodDef weechat_python_funcs[] =
{ "config_free", &weechat_python_api_config_free, METH_VARARGS, "" },
{ "config_get", &weechat_python_api_config_get, METH_VARARGS, "" },
{ "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_unset_plugin", &weechat_python_api_config_unset_plugin, METH_VARARGS, "" },
{ "prefix", &weechat_python_api_prefix, METH_VARARGS, "" },
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index 082b918bb..266f45497 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -2761,6 +2761,42 @@ weechat_ruby_api_config_get_plugin (VALUE class, VALUE option)
}
/*
+ * weechat_ruby_api_config_is_set_plugin: check if a plugin option is set
+ */
+
+static VALUE
+weechat_ruby_api_config_is_set_plugin (VALUE class, VALUE option)
+{
+ char *c_option;
+ int rc;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ RUBY_RETURN_INT(0);
+ }
+
+ if (NIL_P (option))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ RUBY_RETURN_INT(0);
+ }
+
+ Check_Type (option, T_STRING);
+
+ c_option = STR2CSTR (option);
+
+ rc = script_api_config_is_set_plugin (weechat_ruby_plugin,
+ ruby_current_script,
+ c_option);
+
+ RUBY_RETURN_INT(rc);
+}
+
+/*
* weechat_ruby_api_config_set_plugin: set value of a plugin option
*/
@@ -6837,6 +6873,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "config_free", &weechat_ruby_api_config_free, 1);
rb_define_module_function (ruby_mWeechat, "config_get", &weechat_ruby_api_config_get, 1);
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_unset_plugin", &weechat_ruby_api_config_unset_plugin, 1);
rb_define_module_function (ruby_mWeechat, "prefix", &weechat_ruby_api_prefix, 1);
diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c
index 38bbec75c..2eee67105 100644
--- a/src/plugins/scripts/script-api.c
+++ b/src/plugins/scripts/script-api.c
@@ -1536,6 +1536,33 @@ script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
}
/*
+ * script_api_config_is_set_plugin: check if a script option is set
+ */
+
+int
+script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *option)
+{
+ char *option_fullname;
+ int return_code;
+
+ option_fullname = malloc ((strlen (script->name) +
+ strlen (option) + 2));
+ if (!option_fullname)
+ return 0;
+
+ strcpy (option_fullname, script->name);
+ strcat (option_fullname, ".");
+ strcat (option_fullname, option);
+
+ return_code = weechat_config_is_set_plugin (option_fullname);
+ free (option_fullname);
+
+ return return_code;
+}
+
+/*
* script_api_config_set_plugin: set value of a script config option
* format in file is "plugin.script.option"
*/
diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h
index bfedeab4a..8d4622c56 100644
--- a/src/plugins/scripts/script-api.h
+++ b/src/plugins/scripts/script-api.h
@@ -286,6 +286,9 @@ extern void script_api_command (struct t_weechat_plugin *weechat_plugin,
extern const char *script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option);
+extern int script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *option);
extern int script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option, const char *value);
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index 9fc2e964b..afc4a388d 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -2584,6 +2584,42 @@ weechat_tcl_api_config_get_plugin (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_config_is_set_plugin: check if a plugin option is set
+ */
+
+static int
+weechat_tcl_api_config_is_set_plugin (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ char *option;
+ int i, rc;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ TCL_RETURN_INT(0);
+ }
+
+ if (objc < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
+ TCL_RETURN_INT(0);
+ }
+
+ option = Tcl_GetStringFromObj (objv[1], &i);
+
+ rc = script_api_config_is_set_plugin (weechat_tcl_plugin,
+ tcl_current_script,
+ option);
+
+ TCL_RETURN_INT(rc);
+}
+
+/*
* weechat_tcl_api_config_set_plugin: set value of a plugin option
*/
@@ -6434,6 +6470,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_config_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::config_get_plugin",
weechat_tcl_api_config_get_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::config_is_set_plugin",
+ 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_unset_plugin",
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 110d2fc8d..628de70b8 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -334,6 +334,8 @@ struct t_weechat_plugin
struct t_config_option *(*config_get) (const char *option_name);
const char *(*config_get_plugin) (struct t_weechat_plugin *plugin,
const char *option_name);
+ int (*config_is_set_plugin) (struct t_weechat_plugin *plugin,
+ const char *option_name);
int (*config_set_plugin) (struct t_weechat_plugin *plugin,
const char *option_name, const char *value);
int (*config_unset_plugin) (struct t_weechat_plugin *plugin,
@@ -908,6 +910,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->config_get(__option)
#define weechat_config_get_plugin(__option) \
weechat_plugin->config_get_plugin(weechat_plugin, __option)
+#define weechat_config_is_set_plugin(__option) \
+ weechat_plugin->config_is_set_plugin(weechat_plugin, __option)
#define weechat_config_set_plugin(__option, __value) \
weechat_plugin->config_set_plugin(weechat_plugin, __option, \
__value)