summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/CMakeLists.txt4
-rw-r--r--src/plugins/Makefile.am8
-rw-r--r--src/plugins/charset/charset.c4
-rw-r--r--src/plugins/demo/demo.c2
-rw-r--r--src/plugins/irc/irc-debug.c1
-rw-r--r--src/plugins/notify/CMakeLists.txt22
-rw-r--r--src/plugins/notify/Makefile.am25
-rw-r--r--src/plugins/notify/notify.c540
-rw-r--r--src/plugins/plugin-api.c2
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c40
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c33
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c34
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c38
-rw-r--r--src/plugins/weechat-plugin.h3
-rw-r--r--src/plugins/xfer/xfer.c2
16 files changed, 755 insertions, 4 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 59c1a0e13..9c0e475e0 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -64,6 +64,10 @@ IF(NOT DISABLE_LOGGER)
ADD_SUBDIRECTORY( logger )
ENDIF(NOT DISABLE_LOGGER)
+IF(NOT DISABLE_NOTIFY)
+ ADD_SUBDIRECTORY( notify )
+ENDIF(NOT DISABLE_NOTIFY)
+
IF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
ADD_SUBDIRECTORY( scripts )
ENDIF(NOT DISABLE_SCRIPTS AND NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 7cd2c55e7..2203d6de5 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -60,6 +60,10 @@ if PLUGIN_LOGGER
logger_dir = logger
endif
+if PLUGIN_NOTIFY
+notify_dir = notify
+endif
+
if PLUGIN_PERL
script_dir = scripts
endif
@@ -85,5 +89,5 @@ xfer_dir = xfer
endif
SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(debug_dir) \
- $(demo_dir) $(fifo_dir) $(irc_dir) $(logger_dir) $(script_dir) \
- $(trigger_dir) $(xfer_dir)
+ $(demo_dir) $(fifo_dir) $(irc_dir) $(logger_dir) $(notify_dir) \
+ $(script_dir) $(trigger_dir) $(xfer_dir)
diff --git a/src/plugins/charset/charset.c b/src/plugins/charset/charset.c
index 49d5e0c14..0f4cc5134 100644
--- a/src/plugins/charset/charset.c
+++ b/src/plugins/charset/charset.c
@@ -99,7 +99,7 @@ charset_config_reload (void *data, struct t_config_file *config_file)
}
/*
- * charset_config_set_option: set a charset
+ * charset_config_create_option: set a charset
*/
int
@@ -523,6 +523,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_plugin = plugin;
+ charset_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
+
/* get terminal & internal charsets */
charset_terminal = weechat_info_get ("charset_terminal");
charset_internal = weechat_info_get ("charset_internal");
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index b0977f0da..50deeae5e 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -411,6 +411,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_plugin = plugin;
+ demo_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
+
weechat_hook_command ("demo_printf",
_("print some messages on current ubffer"),
_("[text]"),
diff --git a/src/plugins/irc/irc-debug.c b/src/plugins/irc/irc-debug.c
index 4f16ce8f3..2bc8e721f 100644
--- a/src/plugins/irc/irc-debug.c
+++ b/src/plugins/irc/irc-debug.c
@@ -156,6 +156,7 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal,
void
irc_debug_init ()
{
+ irc_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
weechat_hook_signal ("debug", &irc_debug_signal_debug_cb, NULL);
weechat_hook_signal ("debug_dump", &irc_debug_signal_debug_dump_cb, NULL);
}
diff --git a/src/plugins/notify/CMakeLists.txt b/src/plugins/notify/CMakeLists.txt
new file mode 100644
index 000000000..063b7ef24
--- /dev/null
+++ b/src/plugins/notify/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+ADD_LIBRARY(notify MODULE notify.c)
+SET_TARGET_PROPERTIES(notify PROPERTIES PREFIX "")
+
+TARGET_LINK_LIBRARIES(notify)
+
+INSTALL(TARGETS notify LIBRARY DESTINATION lib/${PROJECT_NAME}/plugins)
diff --git a/src/plugins/notify/Makefile.am b/src/plugins/notify/Makefile.am
new file mode 100644
index 000000000..be71095dc
--- /dev/null
+++ b/src/plugins/notify/Makefile.am
@@ -0,0 +1,25 @@
+# Copyright (c) 2003-2008 FlashCode <flashcode@flashtux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(NOTIFY_CFLAGS)
+
+libdir = ${weechat_libdir}/plugins
+
+lib_LTLIBRARIES = notify.la
+
+notify_la_SOURCES = notify.c
+notify_la_LDFLAGS = -module
+notify_la_LIBADD = $(NOTIFY_LFLAGS)
diff --git a/src/plugins/notify/notify.c b/src/plugins/notify/notify.c
new file mode 100644
index 000000000..d001cf419
--- /dev/null
+++ b/src/plugins/notify/notify.c
@@ -0,0 +1,540 @@
+/*
+ * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* notify.c: Notify plugin for WeeChat: set/save buffer notify levels */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iconv.h>
+
+#include "../weechat-plugin.h"
+
+
+WEECHAT_PLUGIN_NAME("notify");
+WEECHAT_PLUGIN_DESCRIPTION("Notify plugin for WeeChat (set/save buffer notify levels)");
+WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
+WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
+WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
+WEECHAT_PLUGIN_LICENSE("GPL3");
+
+#define NOTIFY_CONFIG_NAME "notify"
+
+struct t_weechat_plugin *weechat_notify_plugin = NULL;
+#define weechat_plugin weechat_notify_plugin
+
+struct t_config_file *notify_config_file = NULL;
+struct t_config_section *notify_config_section_buffer = NULL;
+
+#define NOTIFY_NUM_LEVELS 4
+
+char *notify_string[NOTIFY_NUM_LEVELS] =
+{ "none", "highlight", "message", "all" };
+
+int notify_debug = 0;
+
+
+/*
+ * notify_search: search a notify level by name
+ */
+
+int
+notify_search (const char *notify_name)
+{
+ int i;
+
+ for (i = 0; i < NOTIFY_NUM_LEVELS; i++)
+ {
+ if (weechat_strcasecmp (notify_name, notify_string[i]) == 0)
+ return i;
+ }
+
+ /* notify level not found */
+ return -1;
+}
+
+/*
+ * notify_build_option_name: build option name for a buffer
+ */
+
+char *
+notify_build_option_name (struct t_gui_buffer *buffer)
+{
+ char *option_name, *plugin_name, *category, *name;
+ int length;
+
+ plugin_name = weechat_buffer_get_string (buffer, "plugin");
+ category = weechat_buffer_get_string (buffer, "category");
+ name = weechat_buffer_get_string (buffer, "name");
+
+ length = ((plugin_name) ? strlen (plugin_name) : 0) + 1 +
+ strlen (category) + 1 + strlen (name) + 1;
+ option_name = malloc (length);
+ if (!option_name)
+ return NULL;
+
+ snprintf (option_name, length, "%s%s%s.%s",
+ (plugin_name) ? plugin_name : "",
+ (plugin_name) ? "." : "",
+ category,
+ name);
+
+ return option_name;
+}
+
+/*
+ * notify_debug_cb: callback for "debug" signal
+ */
+
+int
+notify_debug_cb (void *data, const char *signal, const char *type_data,
+ void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+
+ if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
+ {
+ if (weechat_strcasecmp ((char *)signal_data, "notify") == 0)
+ {
+ notify_debug ^= 1;
+ if (notify_debug)
+ weechat_printf (NULL, _("%s: debug enabled"), "notify");
+ else
+ weechat_printf (NULL, _("%s: debug disabled"), "notify");
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * notify_get: read a notify level in config file
+ * we first try with all arguments, then remove one by one
+ * to find notify level (from specific to general notify)
+ */
+
+int
+notify_get (const char *name)
+{
+ char *option_name, *ptr_end;
+ struct t_config_option *ptr_option;
+
+ option_name = strdup (name);
+ if (option_name)
+ {
+ ptr_end = option_name + strlen (option_name);
+ while (ptr_end >= option_name)
+ {
+ ptr_option = weechat_config_search_option (notify_config_file,
+ notify_config_section_buffer,
+ option_name);
+ if (ptr_option)
+ {
+ free (option_name);
+ return weechat_config_integer (ptr_option);
+ }
+ ptr_end--;
+ while ((ptr_end >= option_name) && (ptr_end[0] != '.'))
+ {
+ ptr_end--;
+ }
+ if ((ptr_end >= option_name) && (ptr_end[0] == '.'))
+ ptr_end[0] = '\0';
+ }
+ ptr_option = weechat_config_search_option (notify_config_file,
+ notify_config_section_buffer,
+ option_name);
+
+ free (option_name);
+
+ if (ptr_option)
+ return weechat_config_integer (ptr_option);
+ }
+
+ /* notify level not found */
+ return -1;
+}
+
+/*
+ * notify_set_buffer: set notify for a buffer
+ */
+
+void
+notify_set_buffer (struct t_gui_buffer *buffer)
+{
+ char *option_name, notify_str[16];
+ int notify;
+
+ option_name = notify_build_option_name (buffer);
+ if (option_name)
+ {
+ notify = notify_get (option_name);
+ if (notify_debug)
+ {
+ weechat_printf (NULL,
+ _("notify: debug: set notify for buffer %s to "
+ "%d (%s)"),
+ option_name, notify,
+ (notify < 0) ? "reset" : notify_string[notify]);
+ }
+ /* set notify for buffer */
+ snprintf (notify_str, sizeof (notify_str), "%d", notify);
+ weechat_buffer_set (buffer, "notify", notify_str);
+ free (option_name);
+ }
+}
+
+/*
+ * notify_set_buffer_all: set notify for all open buffers
+ */
+
+void
+notify_set_buffer_all ()
+{
+ struct t_plugin_infolist *ptr_infolist;
+
+ ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
+ if (ptr_infolist)
+ {
+ while (weechat_infolist_next (ptr_infolist))
+ {
+ notify_set_buffer (weechat_infolist_pointer (ptr_infolist,
+ "pointer"));
+ }
+ weechat_infolist_free (ptr_infolist);
+ }
+}
+
+/*
+ * notify_config_cb: callback for config hook
+ */
+
+int
+notify_config_cb (void *data, const char *option, const char *value)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) option;
+ (void) value;
+
+ notify_set_buffer_all ();
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * notify_config_reaload: reload notify configuration file
+ */
+
+int
+notify_config_reload (void *data, struct t_config_file *config_file)
+{
+ /* make C compiler happy */
+ (void) data;
+
+ /* free all notify levels */
+ weechat_config_section_free_options (notify_config_section_buffer);
+
+ return weechat_config_reload (config_file);
+}
+
+/*
+ * notify_config_create_option: set a notify level
+ */
+
+int
+notify_config_create_option (void *data, struct t_config_file *config_file,
+ struct t_config_section *section,
+ const char *option_name, const char *value)
+{
+ struct t_config_option *ptr_option;
+ int rc;
+
+ /* make C compiler happy */
+ (void) data;
+
+ rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
+
+ if (option_name)
+ {
+ ptr_option = weechat_config_search_option (config_file, section,
+ option_name);
+ if (ptr_option)
+ {
+ if (value && value[0])
+ rc = weechat_config_option_set (ptr_option, value, 1);
+ else
+ {
+ weechat_config_option_free (ptr_option);
+ rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
+ }
+ }
+ else
+ {
+ if (value && value[0])
+ {
+ ptr_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer", NULL,
+ "none|highlight|message|all",
+ 0, 0, value, NULL, NULL, NULL, NULL, NULL, NULL);
+ rc = (ptr_option) ?
+ WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
+ }
+ else
+ rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
+ }
+ }
+
+ if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
+ {
+ weechat_printf (NULL,
+ _("%s%s: unable to set notify level \"%s\" => \"%s\""),
+ weechat_prefix ("error"), "notify",
+ option_name, value);
+ }
+
+ return rc;
+}
+
+/*
+ * notify_config_init: init notify configuration file
+ * return: 1 if ok, 0 if error
+ */
+
+int
+notify_config_init ()
+{
+ struct t_config_section *ptr_section;
+
+ notify_config_file = weechat_config_new (NOTIFY_CONFIG_NAME,
+ &notify_config_reload, NULL);
+ if (!notify_config_file)
+ return 0;
+
+ ptr_section = weechat_config_new_section (notify_config_file, "buffer",
+ 1, 1,
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ &notify_config_create_option, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (notify_config_file);
+ return 0;
+ }
+
+ notify_config_section_buffer = ptr_section;
+
+ return 1;
+}
+
+/*
+ * notify_config_read: read notify configuration file
+ */
+
+int
+notify_config_read ()
+{
+ return weechat_config_read (notify_config_file);
+}
+
+/*
+ * notify_config_write: write notify configuration file
+ */
+
+int
+notify_config_write ()
+{
+ return weechat_config_write (notify_config_file);
+}
+
+/*
+ * notify_buffer_open_signal_cb: callback for "buffer_open" signal
+ */
+
+int
+notify_buffer_open_signal_cb (void *data, const char *signal,
+ const char *type_data, void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+ (void) type_data;
+
+ notify_set_buffer (signal_data);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * notify_set: set a notify level for a buffer
+ */
+
+void
+notify_set (struct t_gui_buffer *buffer, const char *name, int value)
+{
+ char notify_str[16];
+
+ /* create/update option */
+ if (notify_config_create_option (NULL,
+ notify_config_file,
+ notify_config_section_buffer,
+ name,
+ (value < 0) ?
+ NULL : notify_string[value]) > 0)
+ {
+ /* set notify for buffer */
+ snprintf (notify_str, sizeof (notify_str), "%d", value);
+ weechat_buffer_set (buffer, "notify", notify_str);
+
+ /* display message */
+ if (value >= 0)
+ weechat_printf (NULL, _("Notify level: %s => %s"),
+ name, notify_string[value]);
+ else
+ weechat_printf (NULL, _("Notify level: %s: removed"), name);
+ }
+}
+
+/*
+ * notify_command_cb: callback for /notify command
+ */
+
+int
+notify_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
+{
+ int notify_level;
+ char *option_name;
+
+ /* make C compiler happy */
+ (void) data;
+
+ /* check arguments */
+ if (argc < 2)
+ {
+ weechat_printf (NULL,
+ _("%s%s: missing parameters"),
+ weechat_prefix ("error"), "notify");
+ return WEECHAT_RC_ERROR;
+ }
+
+ /* check if notify level exists */
+ if (weechat_strcasecmp (argv[1], "reset") == 0)
+ notify_level = -1;
+ else
+ {
+ notify_level = notify_search (argv_eol[1]);
+ if (notify_level < 0)
+ {
+ weechat_printf (NULL,
+ _("%s%s: unknown notify level \"%s\""),
+ weechat_prefix ("error"), "notify",
+ argv_eol[1]);
+ return WEECHAT_RC_ERROR;
+ }
+ }
+
+ /* set buffer notify level */
+ option_name = notify_build_option_name (buffer);
+
+ if (option_name)
+ {
+ notify_set (buffer, option_name, notify_level);
+ free (option_name);
+ }
+ else
+ return WEECHAT_RC_ERROR;
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_plugin_init: init notify plugin
+ */
+
+int
+weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
+{
+ /* make C compiler happy */
+ (void) argc;
+ (void) argv;
+
+ weechat_plugin = plugin;
+
+ notify_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
+
+ if (!notify_config_init ())
+ {
+ weechat_printf (NULL,
+ _("%s%s: error creating configuration file"),
+ weechat_prefix("error"), "notify");
+ return WEECHAT_RC_ERROR;
+ }
+ notify_config_read ();
+
+ /* /notify command */
+ weechat_hook_command ("notify",
+ _("change notify level for current buffer"),
+ _("[reset | none | highlight | message | all]"),
+ _(" reset: reset notify level to default value\n"
+ " none: buffer will never be in hotlist\n"
+ "highlight: buffer will be in hotlist for "
+ "highlights only\n"
+ " message: buffer will be in hotlist for "
+ "highlights and user messages only\n"
+ " all: buffer will be in hotlist for "
+ "any text printed"),
+ "reset|none|highlight|message|all",
+ &notify_command_cb, NULL);
+
+ /* callback when a buffer is open */
+ weechat_hook_signal ("buffer_open", &notify_buffer_open_signal_cb, NULL);
+
+ /* callback when a config option is changed */
+ weechat_hook_config ("notify.buffer.*", &notify_config_cb, NULL);
+
+ /* callback for debug */
+ weechat_hook_signal ("debug", &notify_debug_cb, NULL);
+
+ /* set notify for open buffers */
+ notify_set_buffer_all ();
+
+ return WEECHAT_RC_OK;
+}
+
+/*
+ * weechat_plugin_end: end notify plugin
+ */
+
+int
+weechat_plugin_end (struct t_weechat_plugin *plugin)
+{
+ /* make C compiler happy */
+ (void) plugin;
+
+ notify_config_write ();
+
+ weechat_config_free (notify_config_file);
+
+ return WEECHAT_RC_OK;
+}
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index ca0c8d576..db7b10dcc 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -498,7 +498,7 @@ plugin_api_infolist_get_add_buffer (struct t_plugin_infolist *infolist,
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "type", buffer->type))
return 0;
- if (!plugin_infolist_new_var_integer (ptr_item, "notify_level", buffer->notify_level))
+ if (!plugin_infolist_new_var_integer (ptr_item, "notify", buffer->notify))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed))
return 0;
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 9626a3624..676907ff6 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -389,6 +389,7 @@ plugin_load (const char *filename)
new_plugin->buffer_search = &gui_buffer_search_by_category_name;
new_plugin->buffer_clear = &gui_buffer_clear;
new_plugin->buffer_close = &gui_buffer_close;
+ new_plugin->buffer_get_integer = &gui_buffer_get_integer;
new_plugin->buffer_get_string = &gui_buffer_get_string;
new_plugin->buffer_get_pointer = &gui_buffer_get_pointer;
new_plugin->buffer_set = &gui_buffer_set;
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index add53f967..92c8b2e31 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -3366,6 +3366,45 @@ weechat_lua_api_buffer_close (lua_State *L)
}
/*
+ * weechat_lua_api_buffer_get_integer: get a buffer property as integer
+ */
+
+static int
+weechat_lua_api_buffer_get_integer (lua_State *L)
+{
+ const char *buffer, *property;
+ int n, value;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer");
+ LUA_RETURN_INT(-1);
+ }
+
+ buffer = NULL;
+ property = NULL;
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer");
+ LUA_RETURN_INT(-1);
+ }
+
+ buffer = lua_tostring (lua_current_interpreter, -2);
+ property = lua_tostring (lua_current_interpreter, -1);
+
+ value = weechat_buffer_get_integer (script_str2ptr (buffer),
+ property);
+
+ LUA_RETURN_INT(value);
+}
+
+/*
* weechat_lua_api_buffer_get_string: get a buffer property as string
*/
@@ -4968,6 +5007,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "buffer_search", &weechat_lua_api_buffer_search },
{ "buffer_clear", &weechat_lua_api_buffer_clear },
{ "buffer_close", &weechat_lua_api_buffer_close },
+ { "buffer_get_integer", &weechat_lua_api_buffer_get_integer },
{ "buffer_get_string", &weechat_lua_api_buffer_get_string },
{ "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer },
{ "buffer_set", &weechat_lua_api_buffer_set },
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index 35e2091f1..586f0fbbd 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -2811,6 +2811,38 @@ static XS (XS_weechat_buffer_close)
}
/*
+ * weechat::buffer_get_integer: get a buffer property as integer
+ */
+
+static XS (XS_weechat_buffer_get_integer)
+{
+ char *buffer, *property;
+ int value;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer");
+ PERL_RETURN_INT(-1);
+ }
+
+ if (items < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer");
+ PERL_RETURN_INT(-1);
+ }
+
+ buffer = SvPV (ST (0), PL_na);
+ property = SvPV (ST (1), PL_na);
+ value = weechat_buffer_get_integer (script_str2ptr (buffer), property);
+
+ PERL_RETURN_INT(value);
+}
+
+/*
* weechat::buffer_get_string: get a buffer property as string
*/
@@ -3898,6 +3930,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::buffer_search", XS_weechat_buffer_search, "weechat");
newXS ("weechat::buffer_clear", XS_weechat_buffer_clear, "weechat");
newXS ("weechat::buffer_close", XS_weechat_buffer_close, "weechat");
+ newXS ("weechat::buffer_get_integer", XS_weechat_buffer_get_integer, "weechat");
newXS ("weechat::buffer_get_string", XS_weechat_buffer_get_string, "weechat");
newXS ("weechat::buffer_get_pointer", XS_weechat_buffer_get_pointer, "weechat");
newXS ("weechat::buffer_set", XS_weechat_buffer_set, "weechat");
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index f6467e6c3..605c8d219 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -2987,6 +2987,39 @@ weechat_python_api_buffer_close (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_buffer_get_integer get a buffer property as integer
+ */
+
+static PyObject *
+weechat_python_api_buffer_get_integer (PyObject *self, PyObject *args)
+{
+ char *buffer, *property;
+ int value;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer");
+ PYTHON_RETURN_INT(-1);
+ }
+
+ buffer = NULL;
+ property = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &buffer, &property))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer");
+ PYTHON_RETURN_INT(-1);
+ }
+
+ value = weechat_buffer_get_integer (script_str2ptr (buffer), property);
+
+ PYTHON_RETURN_INT(value);
+}
+
+/*
* weechat_python_api_buffer_get_string: get a buffer property as string
*/
@@ -4144,6 +4177,7 @@ PyMethodDef weechat_python_funcs[] =
{ "buffer_search", &weechat_python_api_buffer_search, METH_VARARGS, "" },
{ "buffer_clear", &weechat_python_api_buffer_clear, METH_VARARGS, "" },
{ "buffer_close", &weechat_python_api_buffer_close, METH_VARARGS, "" },
+ { "buffer_get_integer", &weechat_python_api_buffer_get_integer, METH_VARARGS, "" },
{ "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" },
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
{ "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" },
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index 4e58d8e7b..b0f91fcd6 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -3428,6 +3428,43 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer,
}
/*
+ * weechat_ruby_api_buffer_get_integer: get a buffer property as integer
+ */
+
+static VALUE
+weechat_ruby_api_buffer_get_integer (VALUE class, VALUE buffer, VALUE property)
+{
+ char *c_buffer, *c_property;
+ int value;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_integer");
+ RUBY_RETURN_INT(-1);
+ }
+
+ if (NIL_P (buffer) || NIL_P (property))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_integer");
+ RUBY_RETURN_INT(-1);
+ }
+
+ Check_Type (buffer, T_STRING);
+ Check_Type (property, T_STRING);
+
+ c_buffer = STR2CSTR (buffer);
+ c_property = STR2CSTR (property);
+
+ value = weechat_buffer_get_integer (script_str2ptr (c_buffer),
+ c_property);
+
+ RUBY_RETURN_INT(value);
+}
+
+/*
* weechat_ruby_api_buffer_get_string: get a buffer property as string
*/
@@ -4771,6 +4808,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "buffer_search", &weechat_ruby_api_buffer_search, 2);
rb_define_module_function (ruby_mWeechat, "buffer_clear", &weechat_ruby_api_buffer_clear, 1);
rb_define_module_function (ruby_mWeechat, "buffer_close", &weechat_ruby_api_buffer_close, 1);
+ rb_define_module_function (ruby_mWeechat, "buffer_get_integer", &weechat_ruby_api_buffer_get_integer, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_string", &weechat_ruby_api_buffer_get_string, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2);
rb_define_module_function (ruby_mWeechat, "buffer_set", &weechat_ruby_api_buffer_set, 3);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index b60f62751..7188e1ff0 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -381,6 +381,7 @@ struct t_weechat_plugin
struct t_gui_buffer *(*buffer_search) (const char *category, const char *name);
void (*buffer_clear) (struct t_gui_buffer *buffer);
void (*buffer_close) (struct t_gui_buffer *buffer, int switch_to_another);
+ int (*buffer_get_integer) (struct t_gui_buffer *buffer, const char *property);
char *(*buffer_get_string) (struct t_gui_buffer *buffer, const char *property);
void *(*buffer_get_pointer) (struct t_gui_buffer *buffer, const char *property);
void (*buffer_set) (struct t_gui_buffer *buffer, const char *property,
@@ -807,6 +808,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->buffer_clear(__buffer)
#define weechat_buffer_close(__buffer, __switch_to_another) \
weechat_plugin->buffer_close(__buffer, __switch_to_another)
+#define weechat_buffer_get_integer(__buffer, __property) \
+ weechat_plugin->buffer_get_integer(__buffer, __property)
#define weechat_buffer_get_string(__buffer, __property) \
weechat_plugin->buffer_get_string(__buffer, __property)
#define weechat_buffer_get_pointer(__buffer, __property) \
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index c0c8951d6..52a11a2c9 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -1204,6 +1204,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
(void) argv;
weechat_plugin = plugin;
+
+ xfer_debug = weechat_config_boolean (weechat_config_get ("weechat.plugin.debug"));
if (!xfer_config_init ())
return WEECHAT_RC_ERROR;