summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/alias/alias.c247
-rw-r--r--src/plugins/alias/alias.h2
-rw-r--r--src/plugins/charset/Makefile.am2
-rw-r--r--src/plugins/charset/charset.c673
-rw-r--r--src/plugins/charset/charset.h33
-rw-r--r--src/plugins/debug/debug.c2
-rw-r--r--src/plugins/demo/demo.c18
-rw-r--r--src/plugins/fifo/fifo.c15
-rw-r--r--src/plugins/irc/irc-channel.c14
-rw-r--r--src/plugins/irc/irc-command.c709
-rw-r--r--src/plugins/irc/irc-completion.c8
-rw-r--r--src/plugins/irc/irc-config.c1165
-rw-r--r--src/plugins/irc/irc-config.h117
-rw-r--r--src/plugins/irc/irc-debug.c6
-rw-r--r--src/plugins/irc/irc-display.c32
-rw-r--r--src/plugins/irc/irc-input.c2
-rw-r--r--src/plugins/irc/irc-nick.c32
-rw-r--r--src/plugins/irc/irc-protocol.c24
-rw-r--r--src/plugins/irc/irc-server.c619
-rw-r--r--src/plugins/irc/irc-server.h12
-rw-r--r--src/plugins/irc/irc.c5
-rw-r--r--src/plugins/irc/irc.h30
-rw-r--r--src/plugins/logger/logger.c16
-rw-r--r--src/plugins/plugin-api.c86
-rw-r--r--src/plugins/plugin-config.c308
-rw-r--r--src/plugins/plugin-config.h2
-rw-r--r--src/plugins/plugin.c62
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c101
-rw-r--r--src/plugins/scripts/lua/weechat-lua.c14
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c101
-rw-r--r--src/plugins/scripts/perl/weechat-perl.c14
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c92
-rw-r--r--src/plugins/scripts/python/weechat-python.c14
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c110
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby.c14
-rw-r--r--src/plugins/scripts/script-api.c210
-rw-r--r--src/plugins/scripts/script-api.h14
-rw-r--r--src/plugins/scripts/script.c16
-rw-r--r--src/plugins/trigger/trigger.c2
-rw-r--r--src/plugins/trigger/trigger.h2
-rw-r--r--src/plugins/weechat-plugin.h132
41 files changed, 2902 insertions, 2175 deletions
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index c2295ed10..dba460a61 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include "../weechat-plugin.h"
@@ -31,12 +32,16 @@ WEECHAT_PLUGIN_DESCRIPTION("Alias plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
+
+#define ALIAS_CONFIG_NAME "alias"
struct t_weechat_plugin *weechat_alias_plugin = NULL;
#define weechat_plugin weechat_alias_plugin
struct t_config_file *alias_config_file = NULL;
+struct t_config_section *alias_config_section_cmd = NULL;
+
struct t_alias *alias_list = NULL;
struct t_alias *last_alias = NULL;
@@ -280,15 +285,34 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
}
/*
+ * alias_find_pos: find position for an alias (for sorting aliases)
+ */
+
+struct t_alias *
+alias_find_pos (char *name)
+{
+ struct t_alias *ptr_alias;
+
+ for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias)
+ {
+ if (weechat_strcasecmp (name, ptr_alias->name) < 0)
+ return ptr_alias;
+ }
+
+ /* position not found (we will add to the end of list) */
+ return NULL;
+}
+
+/*
* alias_new: create new alias and add it to alias list
*/
struct t_alias *
alias_new (char *name, char *command)
{
- struct t_alias *new_alias, *ptr_alias;
+ struct t_alias *new_alias, *ptr_alias, *pos_alias;
struct t_hook *new_hook;
-
+
if (!name || !name[0] || !command || !command[0])
return NULL;
@@ -321,14 +345,37 @@ alias_new (char *name, char *command)
new_alias->name = strdup (name);
new_alias->command = strdup (command);
new_alias->running = 0;
-
- new_alias->prev_alias = last_alias;
- new_alias->next_alias = NULL;
+
if (alias_list)
- last_alias->next_alias = new_alias;
+ {
+ pos_alias = alias_find_pos (name);
+ if (pos_alias)
+ {
+ /* insert alias into the list (before alias found) */
+ new_alias->prev_alias = pos_alias->prev_alias;
+ new_alias->next_alias = pos_alias;
+ if (pos_alias->prev_alias)
+ (pos_alias->prev_alias)->next_alias = new_alias;
+ else
+ alias_list = new_alias;
+ pos_alias->prev_alias = new_alias;
+ }
+ else
+ {
+ /* add alias to end of list */
+ new_alias->prev_alias = last_alias;
+ new_alias->next_alias = NULL;
+ last_alias->next_alias = new_alias;
+ last_alias = new_alias;
+ }
+ }
else
+ {
+ new_alias->prev_alias = NULL;
+ new_alias->next_alias = NULL;
alias_list = new_alias;
- last_alias = new_alias;
+ last_alias = new_alias;
+ }
}
return new_alias;
@@ -375,7 +422,7 @@ void
alias_free (struct t_alias *alias)
{
struct t_alias *new_alias_list;
-
+
/* remove alias from list */
if (last_alias == alias)
last_alias = alias->prev_alias;
@@ -409,84 +456,71 @@ void
alias_free_all ()
{
while (alias_list)
+ {
alias_free (alias_list);
+ }
}
/*
- * alias_config_reaload: reload alias configuration file
+ * alias_config_change_cb: callback called when alias option is modified
*/
-int
-alias_config_reload (void *data, struct t_config_file *config_file)
+void
+alias_config_change_cb (void *data, struct t_config_option *option)
{
+ struct t_alias *ptr_alias;
+
/* make C compiler happy */
(void) data;
- (void) config_file;
- alias_free_all ();
- return weechat_config_reload (alias_config_file);
+ ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
+ if (ptr_alias)
+ alias_free (ptr_alias);
+ alias_new (weechat_config_option_get_pointer (option, "name"),
+ weechat_config_option_get_pointer (option, "value"));
}
/*
- * alias_config_read_line: read an alias in configuration file
+ * alias_config_delete_cb: callback called when alias option is deleted
*/
void
-alias_config_read_line (void *data, struct t_config_file *config_file,
- char *option_name, char *value)
+alias_config_delete_cb (void *data, struct t_config_option *option)
{
+ struct t_alias *ptr_alias;
+
/* make C compiler happy */
(void) data;
- (void) config_file;
-
- if (option_name && value)
- {
- /* create new alias */
- if (!alias_new (option_name, value))
- {
- weechat_printf (NULL,
- "%s%s: error creating alias \"%s\" => \"%s\"",
- weechat_prefix ("error"), "alias",
- option_name, value);
- }
- }
+
+ ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
+ if (ptr_alias)
+ alias_free (ptr_alias);
}
/*
- * alias_config_write_section: write alias section in configuration file
- * Return: 0 = successful
- * -1 = write error
+ * alias_config_reload: reload alias configuration file
*/
-void
-alias_config_write_section (void *data, struct t_config_file *config_file,
- char *section_name)
+int
+alias_config_reload (void *data, struct t_config_file *config_file)
{
- struct t_alias *ptr_alias;
-
/* make C compiler happy */
(void) data;
+
+ weechat_config_section_free_options (alias_config_section_cmd);
+ alias_free_all ();
- weechat_config_write_line (config_file, section_name, NULL);
-
- for (ptr_alias = alias_list; ptr_alias;
- ptr_alias = ptr_alias->next_alias)
- {
- weechat_config_write_line (config_file,
- ptr_alias->name,
- "\"%s\"",
- ptr_alias->command);
- }
+ return weechat_config_reload (config_file);
}
/*
- * alias_config_write_default_aliases: write default aliases in configuration file
+ * alias_config_write_default: write default aliases in configuration file
*/
void
-alias_config_write_default_aliases (void *data,
- struct t_config_file *config_file,
- char *section_name)
+alias_config_write_default (void *data,
+ struct t_config_file *config_file,
+ char *section_name)
{
/* make C compiler happy */
(void) data;
@@ -521,6 +555,51 @@ alias_config_write_default_aliases (void *data,
}
/*
+ * alias_config_create_option: create an alias
+ */
+
+int
+alias_config_create_option (void *data, struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name, char *value)
+{
+ struct t_alias *ptr_alias;
+ int rc;
+
+ /* make C compiler happy */
+ (void) data;
+
+ rc = 0;
+
+ /* create config option */
+ weechat_config_new_option (
+ config_file, section,
+ option_name, "string", NULL,
+ NULL, 0, 0, value, NULL, NULL,
+ &alias_config_change_cb, NULL,
+ &alias_config_delete_cb, NULL);
+
+ /* create alias */
+ ptr_alias = alias_search (option_name);
+ if (ptr_alias)
+ alias_free (ptr_alias);
+ if (value && value[0])
+ rc = (alias_new (option_name, value)) ? 1 : 0;
+ else
+ rc = 1;
+
+ if (rc == 0)
+ {
+ weechat_printf (NULL,
+ "%s%s: error creating alias \"%s\" => \"%s\"",
+ weechat_prefix ("error"), "alias",
+ option_name, value);
+ }
+
+ return rc;
+}
+
+/*
* alias_config_init: init alias configuration file
* return: 1 if ok, 0 if error
*/
@@ -530,24 +609,24 @@ alias_config_init ()
{
struct t_config_section *ptr_section;
- alias_config_file = weechat_config_new (ALIAS_CONFIG_FILENAME,
+ alias_config_file = weechat_config_new (ALIAS_CONFIG_NAME,
&alias_config_reload, NULL);
if (!alias_config_file)
return 0;
- ptr_section = weechat_config_new_section (alias_config_file, "alias",
- &alias_config_read_line,
- NULL,
- &alias_config_write_section,
- NULL,
- &alias_config_write_default_aliases,
- NULL);
+ ptr_section = weechat_config_new_section (alias_config_file, "cmd",
+ NULL, NULL,
+ NULL, NULL,
+ &alias_config_write_default, NULL,
+ &alias_config_create_option, NULL);
if (!ptr_section)
{
weechat_config_free (alias_config_file);
return 0;
}
+ alias_config_section_cmd = ptr_section;
+
return 1;
}
@@ -601,9 +680,17 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
alias_name, argv_eol[2]);
return WEECHAT_RC_ERROR;
}
+
+ /* create config option */
+ weechat_config_new_option (
+ alias_config_file, alias_config_section_cmd,
+ alias_name, "string", NULL,
+ NULL, 0, 0, argv_eol[2], NULL, NULL,
+ &alias_config_change_cb, NULL,
+ &alias_config_delete_cb, NULL);
+
weechat_printf (NULL,
- _("%sAlias \"%s\" => \"%s\" created"),
- weechat_prefix ("info"),
+ _("Alias \"%s\" => \"%s\" created"),
alias_name, argv_eol[2]);
}
else
@@ -616,14 +703,13 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (NULL, _("Alias:"));
weechat_printf (NULL, " %s %s=>%s %s",
ptr_alias->name,
- weechat_color ("color_chat_delimiters"),
- weechat_color ("color_chat"),
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat"),
ptr_alias->command);
}
else
weechat_printf (NULL,
- _("%sNo alias found."),
- weechat_prefix ("info"));
+ _("No alias found"));
}
}
else
@@ -639,8 +725,8 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (NULL,
" %s %s=>%s %s",
ptr_alias->name,
- weechat_color ("color_chat_delimiters"),
- weechat_color ("color_chat"),
+ weechat_color ("chat_delimiters"),
+ weechat_color ("chat"),
ptr_alias->command);
}
}
@@ -661,6 +747,7 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
{
char *alias_name;
struct t_alias *ptr_alias;
+ struct t_config_option *ptr_option;
/* make C compiler happy */
(void) data;
@@ -677,15 +764,24 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
_("%sAlias \"%s\" not found"),
weechat_prefix ("error"),
alias_name);
- return -1;
+ return WEECHAT_RC_ERROR;
}
+
+ /* remove alias */
alias_free (ptr_alias);
+
+ /* remove option */
+ ptr_option = weechat_config_search_option (alias_config_file,
+ alias_config_section_cmd,
+ alias_name);
+ if (ptr_option)
+ weechat_config_option_free (alias_config_section_cmd, ptr_option);
+
weechat_printf (NULL,
- _("%sAlias \"%s\" removed"),
- weechat_prefix ("info"),
+ _("Alias \"%s\" removed"),
alias_name);
}
- return 0;
+ return WEECHAT_RC_OK;
}
/*
@@ -724,9 +820,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
if (!alias_config_init ())
{
weechat_printf (NULL,
- "%s%s: error creating configuration file \"%s\"",
- weechat_prefix("error"), "alias",
- ALIAS_CONFIG_FILENAME);
+ "%s%s: error creating configuration file",
+ weechat_prefix("error"), "alias");
return WEECHAT_RC_ERROR;
}
alias_config_read ();
diff --git a/src/plugins/alias/alias.h b/src/plugins/alias/alias.h
index 2cb840cb5..9aed403ad 100644
--- a/src/plugins/alias/alias.h
+++ b/src/plugins/alias/alias.h
@@ -20,8 +20,6 @@
#ifndef __WEECHAT_ALIAS_H
#define __WEECHAT_ALIAS_H 1
-#define ALIAS_CONFIG_FILENAME "alias.rc"
-
struct t_alias
{
struct t_hook *hook; /* command hook */
diff --git a/src/plugins/charset/Makefile.am b/src/plugins/charset/Makefile.am
index 0c73d8057..0f5a770bb 100644
--- a/src/plugins/charset/Makefile.am
+++ b/src/plugins/charset/Makefile.am
@@ -20,6 +20,6 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = charset.la
-charset_la_SOURCES = charset.c charset.h
+charset_la_SOURCES = charset.c
charset_la_LDFLAGS = -module
charset_la_LIBADD = $(CHARSET_LFLAGS)
diff --git a/src/plugins/charset/charset.c b/src/plugins/charset/charset.c
index 81e71d6ec..4055d994b 100644
--- a/src/plugins/charset/charset.c
+++ b/src/plugins/charset/charset.c
@@ -28,7 +28,6 @@
#include <iconv.h>
#include "../weechat-plugin.h"
-#include "charset.h"
WEECHAT_PLUGIN_NAME("charset");
@@ -36,14 +35,18 @@ WEECHAT_PLUGIN_DESCRIPTION("Charset plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
+
+#define CHARSET_CONFIG_NAME "charset"
struct t_weechat_plugin *weechat_charset_plugin = NULL;
#define weechat_plugin weechat_charset_plugin
struct t_config_file *charset_config_file = NULL;
-struct t_charset *charset_list = NULL;
-struct t_charset *last_charset = NULL;
+struct t_config_option *charset_default_decode = NULL;
+struct t_config_option *charset_default_encode = NULL;
+struct t_config_section *charset_config_section_decode = NULL;
+struct t_config_section *charset_config_section_encode = NULL;
char *charset_terminal = NULL;
char *charset_internal = NULL;
@@ -65,112 +68,19 @@ charset_debug_cb (void *data, char *signal, char *type_data, void *signal_data)
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (weechat_strcasecmp ((char *)signal_data, "charset") == 0)
+ {
charset_debug ^= 1;
+ if (charset_debug)
+ weechat_printf (NULL, _("%s: debug enabled"), "charset");
+ else
+ weechat_printf (NULL, _("%s: debug disabled"), "charset");
+ }
}
return WEECHAT_RC_OK;
}
/*
- * charset_search: search a charset
- */
-
-struct t_charset *
-charset_search (char *name)
-{
- struct t_charset *ptr_charset;
-
- for (ptr_charset = charset_list; ptr_charset;
- ptr_charset = ptr_charset->next_charset)
- {
- if (strcmp (name, ptr_charset->name) == 0)
- return ptr_charset;
- }
- return NULL;
-}
-
-/*
- * charset_new: create new charset and add it to charset list
- */
-
-struct t_charset *
-charset_new (char *name, char *charset)
-{
- struct t_charset *new_charset, *ptr_charset;
-
- if (!name || !name[0] || !charset || !charset[0])
- return NULL;
-
- ptr_charset = charset_search (name);
- if (ptr_charset)
- {
- if (ptr_charset->charset)
- free (ptr_charset->charset);
- ptr_charset->charset = strdup (charset);
- return ptr_charset;
- }
-
- new_charset = malloc (sizeof (*new_charset));
- {
- new_charset->name = strdup (name);
- new_charset->charset = strdup (charset);
-
- new_charset->prev_charset = last_charset;
- new_charset->next_charset = NULL;
- if (charset_list)
- last_charset->next_charset = new_charset;
- else
- charset_list = new_charset;
- last_charset = new_charset;
- }
-
- return new_charset;
-}
-
-/*
- * charset_free: free a charset and remove it from list
- */
-
-void
-charset_free (struct t_charset *charset)
-{
- struct t_charset *new_charset_list;
-
- /* remove charset from list */
- if (last_charset == charset)
- last_charset = charset->prev_charset;
- if (charset->prev_charset)
- {
- (charset->prev_charset)->next_charset = charset->next_charset;
- new_charset_list = charset_list;
- }
- else
- new_charset_list = charset->next_charset;
- if (charset->next_charset)
- (charset->next_charset)->prev_charset = charset->prev_charset;
-
- /* free data */
- if (charset->name)
- free (charset->name);
- if (charset->charset)
- free (charset->charset);
- free (charset);
-
- charset_list = new_charset_list;
-}
-
-/*
- * charset_free_all: free all charsets
- */
-
-void
-charset_free_all ()
-{
- while (charset_list)
- charset_free (charset_list);
-}
-
-/*
* charset_config_reaload: reload charset configuration file
*/
@@ -179,84 +89,69 @@ charset_config_reload (void *data, struct t_config_file *config_file)
{
/* make C compiler happy */
(void) data;
- (void) config_file;
- charset_free_all ();
- return weechat_config_reload (charset_config_file);
+ /* free all decode/encode charsets */
+ weechat_config_section_free_options (charset_config_section_decode);
+ weechat_config_section_free_options (charset_config_section_encode);
+
+ return weechat_config_reload (config_file);
}
/*
- * charset_config_read_line: read a charset in configuration file
+ * charset_config_set_option: set a charset
*/
-void
-charset_config_read_line (void *data, struct t_config_file *config_file,
- char *option_name, char *value)
+int
+charset_config_create_option (void *data, struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name, char *value)
{
+ struct t_config_option *ptr_option;
+ int rc;
+
/* make C compiler happy */
(void) data;
- (void) config_file;
- if (option_name && value)
+ rc = 0;
+
+ if (option_name)
{
- /* create new charset */
- if (!charset_new (option_name, value))
+ ptr_option = weechat_config_search_option (config_file, section,
+ option_name);
+ if (ptr_option)
{
- weechat_printf (NULL,
- _("%s%s: error creating charset \"%s\" => \"%s\""),
- weechat_prefix ("error"), "charset",
- option_name, value);
+ if (value && value[0])
+ rc = weechat_config_option_set (ptr_option, value, 1);
+ else
+ {
+ weechat_config_option_free (section, ptr_option);
+ rc = 1;
+ }
+ }
+ else
+ {
+ if (value && value[0])
+ {
+ ptr_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string", NULL,
+ NULL, 0, 0, value, NULL, NULL, NULL, NULL, NULL, NULL);
+ rc = (ptr_option) ? 1 : 0;
+ }
+ else
+ rc = 1;
}
}
-}
-
-/*
- * charseet_config_write_section: write charset section in configuration file
- * Return: 0 = successful
- * -1 = write error
- */
-
-void
-charset_config_write_section (void *data, struct t_config_file *config_file,
- char *section_name)
-{
- struct t_charset *ptr_charset;
- /* make C compiler happy */
- (void) data;
-
- weechat_config_write_line (config_file, section_name, NULL);
-
- for (ptr_charset = charset_list; ptr_charset;
- ptr_charset = ptr_charset->next_charset)
+ if (rc == 0)
{
- weechat_config_write_line (config_file,
- ptr_charset->name,
- "\"%s\"",
- ptr_charset->charset);
+ weechat_printf (NULL,
+ _("%s%s: error creating charset \"%s\" => \"%s\""),
+ weechat_prefix ("error"), "charset",
+ option_name, value);
}
-}
-
-/*
- * charset_config_write_default_aliases: write default charsets in configuration file
- */
-
-void
-charset_config_write_default_charsets (void *data,
- struct t_config_file *config_file,
- char *section_name)
-{
- /* make C compiler happy */
- (void) data;
- weechat_config_write_line (config_file, section_name, NULL);
-
- if (charset_terminal && charset_internal
- && (strcasecmp (charset_terminal,
- charset_internal) != 0))
- weechat_config_write_line (config_file, "decode", "%s", charset_terminal);
- else
- weechat_config_write_line (config_file, "decode", "%s", "iso-8859-1");
+ return rc;
}
/*
@@ -269,24 +164,65 @@ charset_config_init ()
{
struct t_config_section *ptr_section;
- charset_config_file = weechat_config_new (CHARSET_CONFIG_FILENAME,
+ charset_config_file = weechat_config_new (CHARSET_CONFIG_NAME,
&charset_config_reload, NULL);
if (!charset_config_file)
return 0;
- ptr_section = weechat_config_new_section (charset_config_file, "charset",
- &charset_config_read_line,
- NULL,
- &charset_config_write_section,
- NULL,
- &charset_config_write_default_charsets,
- NULL);
+ ptr_section = weechat_config_new_section (charset_config_file, "default",
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (charset_config_file);
+ return 0;
+ }
+
+ charset_default_decode = weechat_config_new_option (
+ charset_config_file, ptr_section,
+ "decode", "string",
+ N_("global decoding charset"),
+ NULL, 0, 0,
+ (charset_terminal && charset_internal
+ && (strcasecmp (charset_terminal,
+ charset_internal) != 0)) ?
+ charset_terminal : "iso-8859-1",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ charset_default_encode = weechat_config_new_option (
+ charset_config_file, ptr_section,
+ "encode", "string",
+ N_("global encoding charset"),
+ NULL, 0, 0, "",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+
+ ptr_section = weechat_config_new_section (charset_config_file, "decode",
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ &charset_config_create_option, NULL);
if (!ptr_section)
{
weechat_config_free (charset_config_file);
return 0;
}
+ charset_config_section_decode = ptr_section;
+
+ ptr_section = weechat_config_new_section (charset_config_file, "encode",
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ &charset_config_create_option, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (charset_config_file);
+ return 0;
+ }
+
+ charset_config_section_encode = ptr_section;
+
return 1;
}
@@ -332,173 +268,31 @@ charset_check (char *charset)
}
/*
- * charset_parse_irc_msg: return nick, command, channel and position
- * of arguments in IRC message
- */
-
-void
-charset_parse_irc_msg (char *message, char **nick, char **command,
- char **channel, char **pos_args)
-{
- char *pos, *pos2, *pos3, *pos4, *pos_tmp;
-
- *nick = NULL;
- *command = NULL;
- *channel = NULL;
- *pos_args = NULL;
-
- if (message[0] == ':')
- {
- pos = message + 1;
- pos_tmp = strchr (pos, ' ');
- if (pos_tmp)
- pos_tmp[0] = '\0';
- pos2 = strchr (pos, '!');
- if (pos2)
- *nick = weechat_strndup (pos, pos2 - pos);
- else
- {
- pos2 = strchr (pos, ' ');
- if (pos2)
- *nick = weechat_strndup (pos, pos2 - pos);
- }
- if (pos_tmp)
- pos_tmp[0] = ' ';
- pos = strchr (message, ' ');
- if (!pos)
- pos = message;
- }
- else
- pos = message;
-
- if (pos && pos[0])
- {
- while (pos[0] == ' ')
- pos++;
- pos2 = strchr (pos, ' ');
- if (pos2)
- {
- *command = weechat_strndup (pos, pos2 - pos);
- pos2++;
- while (pos2[0] == ' ')
- pos2++;
- *pos_args = pos2;
- if (pos2[0] != ':')
- {
- if ((pos2[0] == '#') || (pos2[0] == '&')
- || (pos2[0] == '+') || (pos2[0] == '!'))
- {
- pos3 = strchr (pos2, ' ');
- if (pos3)
- *channel = weechat_strndup (pos2, pos3 - pos2);
- else
- *channel = strdup (pos2);
- }
- else
- {
- pos3 = strchr (pos2, ' ');
- if (!*nick)
- {
- if (pos3)
- *nick = weechat_strndup (pos2, pos3 - pos2);
- else
- *nick = strdup (pos2);
- }
- if (pos3)
- {
- pos3++;
- while (pos3[0] == ' ')
- pos3++;
- if ((pos3[0] == '#') || (pos3[0] == '&')
- || (pos3[0] == '+') || (pos3[0] == '!'))
- {
- pos4 = strchr (pos3, ' ');
- if (pos4)
- *channel = weechat_strndup (pos3, pos4 - pos3);
- else
- *channel = strdup (pos3);
- }
- }
- }
- }
- }
- }
-}
-
-/*
- * charset_set: set a charset
- * return 1 if ok, 0 if error
- */
-
-int
-charset_set (char *name, char *charset)
-{
- struct t_charset *ptr_charset;
-
- if (charset && charset[0])
- {
- if (charset_new (name, charset))
- {
- weechat_printf (NULL,
- _("%sCharset \"%s\" => \"%s\""),
- weechat_prefix ("info"), name, charset);
- }
- else
- {
- weechat_printf (NULL,
- _("%s%s: error creating charset \"%s\" "
- "=> \"%s\""),
- weechat_prefix ("error"), "charset", name, charset);
- return 0;
- }
- }
- else
- {
- ptr_charset = charset_search (name);
- if (!ptr_charset)
- {
- weechat_printf (NULL,
- _("%s%s: charset \"%s\" not found"),
- weechat_prefix ("error"), "charset", name);
- return 0;
- }
- charset_free (ptr_charset);
- weechat_printf (NULL,
- _("%sCharset \"%s\" removed"),
- weechat_prefix ("info"), name);
- }
-
- return 1;
-}
-
-/*
* charset_get: read a charset in config file
- * type is "decode" or "encode"
* we first try with all arguments, then remove one by one
* to find charset (from specific to general charset)
*/
char *
-charset_get (char *type, char *name)
+charset_get (struct t_config_section *section, char *name,
+ struct t_config_option *default_charset)
{
char *option_name, *ptr_end;
- struct t_charset *ptr_charset;
- int length;
-
- length = strlen (type) + 1 + strlen (name) + 1;
- option_name = malloc (length);
+ struct t_config_option *ptr_option;
+
+ option_name = strdup (name);
if (option_name)
{
- snprintf (option_name, length, "%s.%s",
- type, name);
ptr_end = option_name + strlen (option_name);
while (ptr_end >= option_name)
{
- ptr_charset = charset_search (option_name);
- if (ptr_charset)
+ ptr_option = weechat_config_search_option (charset_config_file,
+ section,
+ option_name);
+ if (ptr_option)
{
free (option_name);
- return ptr_charset->charset;
+ return weechat_config_string (ptr_option);
}
ptr_end--;
while ((ptr_end >= option_name) && (ptr_end[0] != '.'))
@@ -508,15 +302,22 @@ charset_get (char *type, char *name)
if ((ptr_end >= option_name) && (ptr_end[0] == '.'))
ptr_end[0] = '\0';
}
- ptr_charset = charset_search (option_name);
+ ptr_option = weechat_config_search_option (charset_config_file,
+ section,
+ option_name);
free (option_name);
- if (ptr_charset)
- return ptr_charset->charset;
+ if (ptr_option)
+ return weechat_config_string (ptr_option);
}
- /* nothing found => no decode/encode for this message! */
+ /* nothing found => return default decode/encode charset (if set) */
+ if (weechat_config_string (default_charset)
+ && weechat_config_string (default_charset)[0])
+ return weechat_config_string (default_charset);
+
+ /* no default charset set */
return NULL;
}
@@ -534,7 +335,15 @@ charset_decode (void *data, char *modifier, char *modifier_data,
(void) data;
(void) modifier;
- charset = charset_get ("decode", modifier_data);
+ charset = charset_get (charset_config_section_decode, modifier_data,
+ charset_default_decode);
+ if (charset_debug)
+ {
+ weechat_printf (NULL,
+ "charset: debug: using 'decode' charset: %s "
+ "(modifier='%s', modifier_data='%s', string='%s')",
+ charset, modifier, modifier_data, string);
+ }
if (charset && charset[0])
return weechat_iconv_to_internal (charset, string);
@@ -555,7 +364,15 @@ charset_encode (void *data, char *modifier, char *modifier_data,
(void) data;
(void) modifier;
- charset = charset_get ("encode", modifier_data);
+ charset = charset_get (charset_config_section_encode, modifier_data,
+ charset_default_encode);
+ if (charset_debug)
+ {
+ weechat_printf (NULL,
+ "charset: debug: using 'encode' charset: %s "
+ "(modifier='%s', modifier_data='%s', string='%s')",
+ charset, modifier, modifier_data, string);
+ }
if (charset && charset[0])
return weechat_iconv_from_internal (charset, string);
@@ -563,6 +380,29 @@ charset_encode (void *data, char *modifier, char *modifier_data,
}
/*
+ * charset_set: set a charset
+ */
+
+void
+charset_set (struct t_config_section *section, char *type,
+ char *name, char *value)
+{
+ if (charset_config_create_option (NULL,
+ charset_config_file,
+ section,
+ name,
+ value) > 0)
+ {
+ if (value && value[0])
+ weechat_printf (NULL, _("Charset: %s, %s => %s"),
+ type, name, value);
+ else
+ weechat_printf (NULL, _("Charset: %s, %s: removed"),
+ type, name);
+ }
+}
+
+/*
* charset_command_cb: callback for /charset command
*/
@@ -570,75 +410,98 @@ int
charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
- int charset_found, length, rc;
- struct t_charset *ptr_charset;
- char *option_name, *ptr_value;
+ struct t_config_section *ptr_section;
+ int length;
+ char *ptr_charset, *option_name, *plugin_name, *category, *name;
/* make C compiler happy */
(void) data;
- (void) buffer;
- if ((argc > 2) && (strcmp (argv[2], "=") == 0))
+ if (argc < 2)
+ {
+ weechat_printf (NULL,
+ _("%s%s: missing parameters"),
+ weechat_prefix ("error"), "charset");
+ return WEECHAT_RC_ERROR;
+ }
+
+ ptr_section = NULL;
+
+ 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 WEECHAT_RC_ERROR;
+
+ snprintf (option_name, length, "%s%s%s.%s",
+ (plugin_name) ? plugin_name : "",
+ (plugin_name) ? "." : "",
+ category,
+ name);
+
+ if ((argc > 1) && (weechat_strcasecmp (argv[1], "reset") == 0))
{
- ptr_value = (argc > 3) ? argv_eol[3] : NULL;
- if ((weechat_strncasecmp (argv[1], "decode.", 7) != 0)
- && (weechat_strncasecmp (argv[1], "encode.", 7) != 0))
+ charset_set (charset_config_section_decode, "decode", option_name,
+ NULL);
+ charset_set (charset_config_section_encode, "encode", option_name,
+ NULL);
+ }
+ else
+ {
+ if (argc > 2)
{
- length = strlen (argv[1]) + strlen ("decode.") + 1;
- option_name = malloc (length);
- if (option_name)
+ if (weechat_strcasecmp (argv[1], "decode") == 0)
{
- rc = 1;
- snprintf (option_name, length, "decode.%s", argv[1]);
- if (!charset_set (option_name, ptr_value))
- rc = 0;
- snprintf (option_name, length, "encode.%s", argv[1]);
- if (!charset_set (option_name, ptr_value))
- rc = 0;
- if (!rc)
- return WEECHAT_RC_ERROR;
+ ptr_section = charset_config_section_decode;
+ ptr_charset = argv_eol[2];
+ }
+ else if (weechat_strcasecmp (argv[1], "encode") == 0)
+ {
+ ptr_section = charset_config_section_encode;
+ ptr_charset = argv_eol[2];
+ }
+ if (!ptr_section)
+ {
+ weechat_printf (NULL,
+ _("%s%s: wrong charset type (decode or encode "
+ "expected)"),
+ weechat_prefix ("error"), "charset");
+ if (option_name)
+ free (option_name);
+ return WEECHAT_RC_ERROR;
}
}
else
+ ptr_charset = argv_eol[1];
+
+ if (!charset_check (ptr_charset))
{
- if (!charset_set (argv[1], ptr_value))
- return WEECHAT_RC_ERROR;
+ weechat_printf (NULL,
+ _("%s%s: invalid charset: \"%s\""),
+ weechat_prefix ("error"), "charset", ptr_charset);
+ if (option_name)
+ free (option_name);
+ return WEECHAT_RC_ERROR;
}
- }
- else
- {
- /* list all charsets */
- if (charset_list)
+ if (ptr_section)
{
- weechat_printf (NULL, "");
- if (argc == 1)
- weechat_printf (NULL, _("List of charsets:"));
- else
- weechat_printf (NULL, _("List of charsets with \"%s\":"),
- argv_eol[1]);
- charset_found = 0;
- for (ptr_charset = charset_list; ptr_charset;
- ptr_charset = ptr_charset->next_charset)
- {
- if ((argc < 2)
- || (weechat_strcasestr (ptr_charset->name, argv_eol[1])))
- {
- charset_found = 1;
- weechat_printf (NULL,
- " %s %s=>%s %s",
- ptr_charset->name,
- weechat_color ("color_chat_delimiters"),
- weechat_color ("color_chat"),
- ptr_charset->charset);
- }
- }
- if (!charset_found)
- weechat_printf (NULL, _("No charset found"));
+ charset_set (ptr_section, argv[1], option_name, ptr_charset);
}
else
- weechat_printf (NULL, _("No charset defined"));
+ {
+ charset_set (charset_config_section_decode, "decode", option_name,
+ ptr_charset);
+ charset_set (charset_config_section_encode, "encode", option_name,
+ ptr_charset);
+ }
}
+ free (option_name);
+
return WEECHAT_RC_OK;
}
@@ -657,50 +520,36 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
/* display message */
weechat_printf (NULL,
- _("%s%s: terminal: %s, internal: %s"),
- weechat_prefix ("info"), "charset",
- charset_terminal, charset_internal);
+ _("%s: terminal: %s, internal: %s"),
+ "charset", charset_terminal, charset_internal);
if (!charset_config_init ())
{
weechat_printf (NULL,
- _("%s%s: error creating configuration file \"%s\""),
- weechat_prefix("error"), "charset",
- CHARSET_CONFIG_FILENAME);
+ _("%s%s: error creating configuration file"),
+ weechat_prefix("error"), "charset");
return WEECHAT_RC_ERROR;
}
charset_config_read ();
- /* add command handler */
+ /* /charset command */
weechat_hook_command ("charset",
- _("manage charsets"),
- _("[[type.]plugin.string [= charset]]"),
- _(" type: \"decode\" or \"encode\" (if type is "
- "omitted, then both \"decode\" and \"encode\" are "
- "set)\n"
- " plugin: plugin name\n"
- " string: string specific to plugin (for example "
- "a server name or server.channel for IRC plugin)\n"
- "charset: charset to use (if empty, then charset "
- "is removed)\n\n"
- "Examples :\n"
- "/charset decode iso-8859-15 => set global "
- "decode charset to iso-8859-15\n"
- "/charset encode iso-8859-15 => set global "
- "encode charset to iso-8859-15\n"
- "/charset decode.irc.freenode => set decode "
- "charset to iso-8859-15 for IRC server "
- "\"freenode\" (all channels)\n"
- "/charset decode.irc.freenode.#weechat => set "
- "decode charset to iso-8859-15 for IRC channel "
- "\"#weechat\" on server \"freenode\""),
- "%(charset_name) %(charset)",
+ _("change charset for current buffer"),
+ _("[[decode | encode] charset] | [reset]"),
+ _(" decode: change decoding charset\n"
+ " encode: change encoding charset\n"
+ "charset: new charset for current buffer\n"
+ " reset: reset charsets for current buffer"),
+ "decode|encode|reset",
&charset_command_cb, NULL);
- /* add messge modifiers */
+ /* modifiers hooks */
weechat_hook_modifier ("charset_decode", &charset_decode, NULL);
weechat_hook_modifier ("charset_encode", &charset_encode, NULL);
+ /* callback for debug */
+ weechat_hook_signal ("debug", &charset_debug_cb, NULL);
+
return WEECHAT_RC_OK;
}
@@ -715,7 +564,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
(void) plugin;
charset_config_write ();
- charset_free_all ();
+
weechat_config_free (charset_config_file);
return WEECHAT_RC_OK;
diff --git a/src/plugins/charset/charset.h b/src/plugins/charset/charset.h
deleted file mode 100644
index 248972587..000000000
--- a/src/plugins/charset/charset.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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/>.
- */
-
-
-#ifndef __WEECHAT_CHARSET_H
-#define __WEECHAT_CHARSET_H 1
-
-#define CHARSET_CONFIG_FILENAME "charset.rc"
-
-struct t_charset
-{
- char *name; /* charset name (identifier) */
- char *charset; /* charset value for name */
- struct t_charset *prev_charset; /* link to previous charset */
- struct t_charset *next_charset; /* link to next charset */
-};
-
-#endif /* charset.h */
diff --git a/src/plugins/debug/debug.c b/src/plugins/debug/debug.c
index 6a3a5c30e..514b11fc0 100644
--- a/src/plugins/debug/debug.c
+++ b/src/plugins/debug/debug.c
@@ -30,7 +30,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Debug plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_debug_plugin = NULL;
#define weechat_plugin weechat_debug_plugin
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c
index 36c600868..f8a4620bc 100644
--- a/src/plugins/demo/demo.c
+++ b/src/plugins/demo/demo.c
@@ -36,7 +36,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Demo plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_demo_plugin = NULL;
#define weechat_plugin weechat_demo_plugin
@@ -91,19 +91,16 @@ demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (buffer,
_("demo message without prefix"));
weechat_printf (buffer,
- _("%sdemo message with info prefix"),
- weechat_prefix ("info"));
- weechat_printf (buffer,
_("%sdemo message with error prefix"),
weechat_prefix ("error"));
weechat_printf (buffer,
_("colors: %s buffer %s nick1 %s nick2 %s nick3 "
"%s nick4"),
- weechat_color ("color_chat_buffer"),
- weechat_color ("color_chat_nick_color1"),
- weechat_color ("color_chat_nick_color2"),
- weechat_color ("color_chat_nick_color3"),
- weechat_color ("color_chat_nick_color4"));
+ weechat_color ("chat_buffer"),
+ weechat_color ("chat_nick_color1"),
+ weechat_color ("chat_nick_color2"),
+ weechat_color ("chat_nick_color3"),
+ weechat_color ("chat_nick_color4"));
}
return WEECHAT_RC_OK;
@@ -342,8 +339,7 @@ demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv_eol;
if (argc > 1)
- weechat_printf (NULL, "%sinfo \"%s\" = \"%s\"",
- weechat_prefix ("info"),
+ weechat_printf (NULL, "info \"%s\" = \"%s\"",
argv[1],
weechat_info_get (argv[1]));
else
diff --git a/src/plugins/fifo/fifo.c b/src/plugins/fifo/fifo.c
index b79692c15..5e92498ed 100644
--- a/src/plugins/fifo/fifo.c
+++ b/src/plugins/fifo/fifo.c
@@ -35,7 +35,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Fifo plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_fifo_plugin = NULL;
#define weechat_plugin weechat_fifo_plugin
@@ -94,8 +94,8 @@ fifo_create ()
O_RDONLY | O_NONBLOCK)) != -1)
{
weechat_printf (NULL,
- _("%s%s: pipe open"),
- weechat_prefix ("info"), "fifo"),
+ _("%s: pipe open"),
+ "fifo"),
rc = 1;
}
else
@@ -148,8 +148,8 @@ fifo_remove ()
}
weechat_printf (NULL,
- _("%s%s: pipe closed"),
- weechat_prefix ("info"), "fifo");
+ _("%s: pipe closed"),
+ "fifo");
}
/*
@@ -320,11 +320,10 @@ fifo_read ()
*/
int
-fifo_config_cb (void *data, char *type, char *option, char *value)
+fifo_config_cb (void *data, char *option, char *value)
{
/* make C compiler happy */
(void) data;
- (void) type;
(void) option;
if (weechat_strcasecmp (value, "on") == 0)
@@ -354,7 +353,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
fifo_fd_hook = weechat_hook_fd (fifo_fd, 1, 0, 0,
&fifo_read, NULL);
- weechat_hook_config ("plugin", "fifo.fifo", &fifo_config_cb, NULL);
+ weechat_hook_config ("plugins.var.fifo.fifo", &fifo_config_cb, NULL);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index a838786a8..f7b6614e1 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -70,15 +70,15 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
weechat_buffer_set (new_buffer, "nicklist", "1");
weechat_buffer_set (new_buffer, "nicklist_display_groups", "0");
weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_OP,
- "color_nicklist_group", 1);
+ "nicklist_group", 1);
weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_HALFOP,
- "color_nicklist_group", 1);
+ "nicklist_group", 1);
weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_VOICE,
- "color_nicklist_group", 1);
+ "nicklist_group", 1);
weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_CHANUSER,
- "color_nicklist_group", 1);
+ "nicklist_group", 1);
weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_NORMAL,
- "color_nicklist_group", 1);
+ "nicklist_group", 1);
}
/* initialize new channel */
@@ -324,8 +324,8 @@ irc_channel_check_away (struct t_irc_server *server,
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
if (force
- || (weechat_config_integer (irc_config_irc_away_check_max_nicks) == 0)
- || (channel->nicks_count <= weechat_config_integer (irc_config_irc_away_check_max_nicks)))
+ || (weechat_config_integer (irc_config_network_away_check_max_nicks) == 0)
+ || (channel->nicks_count <= weechat_config_integer (irc_config_network_away_check_max_nicks)))
{
channel->checking_away++;
irc_server_sendf (server, "WHO %s", channel->name);
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 072068883..7b14bb576 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -269,11 +269,11 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
server->is_away = 1;
server->away_time = time (NULL);
irc_server_sendf (server, "AWAY :%s", arguments);
- if (weechat_config_integer (irc_config_irc_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF)
+ if (weechat_config_integer (irc_config_look_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF)
{
string = (char *)irc_color_decode ((unsigned char *)arguments,
1, 0);
- if (weechat_config_integer (irc_config_irc_display_away) == IRC_CONFIG_DISPLAY_AWAY_LOCAL)
+ if (weechat_config_integer (irc_config_look_display_away) == IRC_CONFIG_DISPLAY_AWAY_LOCAL)
irc_display_away (server, "away",
(string) ? string : arguments);
else
@@ -302,8 +302,8 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
string = (char *)irc_color_decode ((unsigned char *)arguments,
1, 0);
weechat_printf (server->buffer,
- _("%s%s: future away on %s%s%s: %s"),
- weechat_prefix ("info"), "irc",
+ _("%s: future away on %s%s%s: %s"),
+ "irc",
IRC_COLOR_CHAT_SERVER,
server->name,
IRC_COLOR_CHAT,
@@ -331,9 +331,9 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
elapsed = (time_now >= server->away_time) ?
time_now - server->away_time : 0;
server->away_time = 0;
- if (weechat_config_integer (irc_config_irc_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF)
+ if (weechat_config_integer (irc_config_look_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF)
{
- if (weechat_config_integer (irc_config_irc_display_away) == IRC_CONFIG_DISPLAY_AWAY_LOCAL)
+ if (weechat_config_integer (irc_config_look_display_away) == IRC_CONFIG_DISPLAY_AWAY_LOCAL)
{
snprintf (buffer, sizeof (buffer),
"gone %.2ld:%.2ld:%.2ld",
@@ -360,8 +360,8 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
/* server not connected, remove away message but do not send
anything */
weechat_printf (server->buffer,
- _("%s%s: future away on %s%s%s removed"),
- weechat_prefix ("info"), "irc",
+ _("%s: future away on %s%s%s removed"),
+ "irc",
IRC_COLOR_CHAT_SERVER,
server->name,
IRC_COLOR_CHAT);
@@ -624,10 +624,10 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
if (ptr_server)
{
weechat_printf (NULL,
- _("%s%s: server %s%s%s created "
+ _("%s: server %s%s%s created "
"(temporary server, "
"NOT SAVED!)"),
- weechat_prefix ("info"), "irc",
+ "irc",
IRC_COLOR_CHAT_SERVER,
server_tmp.name,
IRC_COLOR_CHAT);
@@ -831,9 +831,9 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
}
ptr_arg = (pos_args) ? pos_args :
- (weechat_config_string (irc_config_irc_default_msg_part)
- && weechat_config_string (irc_config_irc_default_msg_part)[0]) ?
- weechat_config_string (irc_config_irc_default_msg_part) : NULL;
+ (weechat_config_string (irc_config_network_default_msg_part)
+ && weechat_config_string (irc_config_network_default_msg_part)[0]) ?
+ weechat_config_string (irc_config_network_default_msg_part) : NULL;
if (ptr_arg)
{
@@ -1064,9 +1064,9 @@ irc_command_quit_server (struct t_irc_server *server, char *arguments)
if (server->is_connected)
{
ptr_arg = (arguments) ? arguments :
- (weechat_config_string (irc_config_irc_default_msg_quit)
- && weechat_config_string (irc_config_irc_default_msg_quit)[0]) ?
- weechat_config_string (irc_config_irc_default_msg_quit) : NULL;
+ (weechat_config_string (irc_config_network_default_msg_quit)
+ && weechat_config_string (irc_config_network_default_msg_quit)[0]) ?
+ weechat_config_string (irc_config_network_default_msg_quit) : NULL;
if (ptr_arg)
{
@@ -1105,8 +1105,8 @@ irc_command_disconnect_one_server (struct t_irc_server *server)
if (server->reconnect_start > 0)
{
weechat_printf (server->buffer,
- _("%s%s: auto-reconnection is cancelled"),
- weechat_prefix ("info"), "irc");
+ _("%s: auto-reconnection is cancelled"),
+ "irc");
}
irc_command_quit_server (server, NULL);
irc_server_disconnect (server, 0);
@@ -2107,9 +2107,9 @@ irc_command_part_channel (struct t_irc_server *server, char *channel_name,
char *ptr_arg, *buf, *version;
ptr_arg = (part_message) ? part_message :
- (weechat_config_string (irc_config_irc_default_msg_part)
- && weechat_config_string (irc_config_irc_default_msg_part)[0]) ?
- weechat_config_string (irc_config_irc_default_msg_part) : NULL;
+ (weechat_config_string (irc_config_network_default_msg_part)
+ && weechat_config_string (irc_config_network_default_msg_part)[0]) ?
+ weechat_config_string (irc_config_network_default_msg_part) : NULL;
if (ptr_arg)
{
@@ -2560,328 +2560,343 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
_("No server found with \"%s\""),
server_name);
}
+
+ return WEECHAT_RC_OK;
}
- else
+
+ /* TODO: fix server command */
+ weechat_printf (NULL,
+ "%sSome server options are temporarirly disabled in "
+ "this version, you can use /set irc.server.xxxx.yyyy = zzzz "
+ "and /reload command to reload options from irc.conf",
+ weechat_prefix ("error"));
+ return WEECHAT_RC_ERROR;
+
+ if (weechat_strcasecmp (argv[1], "add") == 0)
{
- if (weechat_strcasecmp (argv[1], "add") == 0)
+ if (argc < 4)
{
- if (argc < 4)
- {
- IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server add");
- }
- if (irc_server_search (argv[2]))
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" already exists, "
- "can't create it!"),
- weechat_prefix ("error"), "irc", argv[2]);
- return WEECHAT_RC_ERROR;
- }
-
- /* init server struct */
- irc_server_init (&server_tmp);
-
- server_tmp.name = strdup (argv[2]);
- server_tmp.addresses = strdup (argv[3]);
-
- /* parse arguments */
- for (i = 4; i < argc; i++)
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server add");
+ }
+ if (irc_server_search (argv[2]))
+ {
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" already exists, "
+ "can't create it!"),
+ weechat_prefix ("error"), "irc", argv[2]);
+ return WEECHAT_RC_ERROR;
+ }
+
+ /* init server struct */
+ irc_server_init (&server_tmp);
+
+ server_tmp.name = strdup (argv[2]);
+ server_tmp.addresses = strdup (argv[3]);
+
+ /* parse arguments */
+ for (i = 4; i < argc; i++)
+ {
+ if (argv[i][0] == '-')
{
- if (argv[i][0] == '-')
+ if (weechat_strcasecmp (argv[i], "-temp") == 0)
+ server_tmp.temp_server = 1;
+ if (weechat_strcasecmp (argv[i], "-auto") == 0)
+ server_tmp.autoconnect = 1;
+ if (weechat_strcasecmp (argv[i], "-noauto") == 0)
+ server_tmp.autoconnect = 0;
+ if (weechat_strcasecmp (argv[i], "-ipv6") == 0)
+ server_tmp.ipv6 = 1;
+ if (weechat_strcasecmp (argv[i], "-ssl") == 0)
+ server_tmp.ssl = 1;
+ if (weechat_strcasecmp (argv[i], "-pwd") == 0)
{
- if (weechat_strcasecmp (argv[i], "-temp") == 0)
- server_tmp.temp_server = 1;
- if (weechat_strcasecmp (argv[i], "-auto") == 0)
- server_tmp.autoconnect = 1;
- if (weechat_strcasecmp (argv[i], "-noauto") == 0)
- server_tmp.autoconnect = 0;
- if (weechat_strcasecmp (argv[i], "-ipv6") == 0)
- server_tmp.ipv6 = 1;
- if (weechat_strcasecmp (argv[i], "-ssl") == 0)
- server_tmp.ssl = 1;
- if (weechat_strcasecmp (argv[i], "-pwd") == 0)
+ if (i == (argc - 1))
{
- if (i == (argc - 1))
- {
- weechat_printf (NULL,
- _("%s%s: missing argument for "
- "\"%s\" option"),
- weechat_prefix ("error"), "irc",
- "-pwd");
- irc_server_free_data (&server_tmp);
- return WEECHAT_RC_ERROR;
- }
- server_tmp.password = strdup (argv[++i]);
+ weechat_printf (NULL,
+ _("%s%s: missing argument for "
+ "\"%s\" option"),
+ weechat_prefix ("error"), "irc",
+ "-pwd");
+ irc_server_free_data (&server_tmp);
+ return WEECHAT_RC_ERROR;
}
- if (weechat_strcasecmp (argv[i], "-nicks") == 0)
+ server_tmp.password = strdup (argv[++i]);
+ }
+ if (weechat_strcasecmp (argv[i], "-nicks") == 0)
+ {
+ if (i == (argc - 1))
{
- if (i == (argc - 1))
- {
- weechat_printf (NULL,
- _("%s%s: missing argument for "
- "\"%s\" option"),
- weechat_prefix ("error"), "irc",
- "-nicks");
- irc_server_free_data (&server_tmp);
- return WEECHAT_RC_ERROR;
- }
- server_tmp.nicks = strdup (argv[++i]);
+ weechat_printf (NULL,
+ _("%s%s: missing argument for "
+ "\"%s\" option"),
+ weechat_prefix ("error"), "irc",
+ "-nicks");
+ irc_server_free_data (&server_tmp);
+ return WEECHAT_RC_ERROR;
}
- if (weechat_strcasecmp (argv[i], "-username") == 0)
+ server_tmp.nicks = strdup (argv[++i]);
+ }
+ if (weechat_strcasecmp (argv[i], "-username") == 0)
+ {
+ if (i == (argc - 1))
{
- if (i == (argc - 1))
- {
- weechat_printf (NULL,
- _("%s%s: missing argument for "
- "\"%s\" option"),
- weechat_prefix ("error"), "irc",
- "-username");
- irc_server_free_data (&server_tmp);
- return WEECHAT_RC_ERROR;
- }
- server_tmp.username = strdup (argv[++i]);
+ weechat_printf (NULL,
+ _("%s%s: missing argument for "
+ "\"%s\" option"),
+ weechat_prefix ("error"), "irc",
+ "-username");
+ irc_server_free_data (&server_tmp);
+ return WEECHAT_RC_ERROR;
}
- if (weechat_strcasecmp (argv[i], "-realname") == 0)
+ server_tmp.username = strdup (argv[++i]);
+ }
+ if (weechat_strcasecmp (argv[i], "-realname") == 0)
+ {
+ if (i == (argc - 1))
{
- if (i == (argc - 1))
- {
- weechat_printf (NULL,
- _("%s%s: missing argument for "
- "\"%s\" option"),
- weechat_prefix ("error"), "irc",
- "-realname");
- irc_server_free_data (&server_tmp);
- return WEECHAT_RC_ERROR;
- }
- server_tmp.realname = strdup (argv[++i]);
+ weechat_printf (NULL,
+ _("%s%s: missing argument for "
+ "\"%s\" option"),
+ weechat_prefix ("error"), "irc",
+ "-realname");
+ irc_server_free_data (&server_tmp);
+ return WEECHAT_RC_ERROR;
}
- if (weechat_strcasecmp (argv[i], "-autojoin") == 0)
+ server_tmp.realname = strdup (argv[++i]);
+ }
+ if (weechat_strcasecmp (argv[i], "-autojoin") == 0)
+ {
+ if (i == (argc - 1))
{
- if (i == (argc - 1))
- {
- weechat_printf (NULL,
- _("%s%s: missing argument for "
- "\"%s\" option"),
- weechat_prefix ("error"), "irc",
- "-autojoin");
- irc_server_free_data (&server_tmp);
- return WEECHAT_RC_ERROR;
- }
- server_tmp.autojoin = strdup (argv[++i]);
+ weechat_printf (NULL,
+ _("%s%s: missing argument for "
+ "\"%s\" option"),
+ weechat_prefix ("error"), "irc",
+ "-autojoin");
+ irc_server_free_data (&server_tmp);
+ return WEECHAT_RC_ERROR;
}
+ server_tmp.autojoin = strdup (argv[++i]);
}
}
-
- /* create new server */
- new_server = irc_server_new (server_tmp.name,
- server_tmp.autoconnect,
- server_tmp.autoreconnect,
- server_tmp.autoreconnect_delay,
- server_tmp.temp_server,
- server_tmp.addresses,
- server_tmp.ipv6,
- server_tmp.ssl,
- server_tmp.password,
- server_tmp.nicks,
- server_tmp.username,
- server_tmp.realname,
- server_tmp.hostname,
- server_tmp.command,
- 1, /* command_delay */
- server_tmp.autojoin,
- 1, /* autorejoin */
- NULL);
- if (new_server)
- {
- weechat_printf (NULL,
- _("%s%s: server %s%s%s created"),
- weechat_prefix ("info"), "irc",
- IRC_COLOR_CHAT_SERVER,
- server_tmp.name,
- IRC_COLOR_CHAT);
- }
- else
- {
- weechat_printf (NULL,
- _("%s%s: unable to create server"),
- weechat_prefix ("error"), "irc");
- irc_server_free_data (&server_tmp);
- return WEECHAT_RC_ERROR;
- }
-
- if (new_server->autoconnect)
- irc_server_connect (new_server, 0);
-
+ }
+
+ /* create new server */
+ new_server = irc_server_new (server_tmp.name,
+ server_tmp.autoconnect,
+ server_tmp.autoreconnect,
+ server_tmp.autoreconnect_delay,
+ server_tmp.temp_server,
+ server_tmp.addresses,
+ server_tmp.ipv6,
+ server_tmp.ssl,
+ server_tmp.password,
+ server_tmp.nicks,
+ server_tmp.username,
+ server_tmp.realname,
+ server_tmp.hostname,
+ server_tmp.command,
+ 1, /* command_delay */
+ server_tmp.autojoin,
+ 1, /* autorejoin */
+ NULL);
+ if (new_server)
+ {
+ weechat_printf (NULL,
+ _("%s: server %s%s%s created"),
+ "irc",
+ IRC_COLOR_CHAT_SERVER,
+ server_tmp.name,
+ IRC_COLOR_CHAT);
+ }
+ else
+ {
+ weechat_printf (NULL,
+ _("%s%s: unable to create server"),
+ weechat_prefix ("error"), "irc");
irc_server_free_data (&server_tmp);
+ return WEECHAT_RC_ERROR;
}
- else if (weechat_strcasecmp (argv[1], "copy") == 0)
+
+ if (new_server->autoconnect)
+ irc_server_connect (new_server, 0);
+
+ irc_server_free_data (&server_tmp);
+
+ return WEECHAT_RC_OK;
+ }
+
+ if (weechat_strcasecmp (argv[1], "copy") == 0)
+ {
+ if (argc < 4)
{
- if (argc < 4)
- {
- IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server copy");
- }
-
- /* look for server by name */
- server_found = irc_server_search (argv[2]);
- if (!server_found)
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" not found for "
- "\"%s\" command"),
- weechat_prefix ("error"), "irc",
- argv[2], "server copy");
- return WEECHAT_RC_ERROR;
- }
-
- /* check if target name already exists */
- if (irc_server_search (argv[3]))
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" already exists for "
- "\"%s\" command"),
- weechat_prefix ("error"), "irc",
- argv[3], "server copy");
- return WEECHAT_RC_ERROR;
- }
-
- /* duplicate server */
- new_server = irc_server_duplicate (server_found, argv[3]);
- if (new_server)
- {
- weechat_printf (NULL,
- _("%s%s: Server %s%s%s has been copied to "
- "%s%s"),
- weechat_prefix ("info"), "irc",
- IRC_COLOR_CHAT_SERVER,
- argv[2],
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_SERVER,
- argv[3]);
- //gui_window_redraw_all_buffers ();
- return WEECHAT_RC_OK;
- }
-
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server copy");
+ }
+
+ /* look for server by name */
+ server_found = irc_server_search (argv[2]);
+ if (!server_found)
+ {
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" not found for "
+ "\"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ argv[2], "server copy");
return WEECHAT_RC_ERROR;
}
- else if (weechat_strcasecmp (argv[1], "rename") == 0)
+
+ /* check if target name already exists */
+ if (irc_server_search (argv[3]))
{
- if (argc < 4)
- {
- IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
- }
-
- /* look for server by name */
- server_found = irc_server_search (argv[2]);
- if (!server_found)
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" not found for "
- "\"%s\" command"),
- weechat_prefix ("error"), "irc",
- argv[2], "server rename");
- return WEECHAT_RC_ERROR;
- }
-
- /* check if target name already exists */
- if (irc_server_search (argv[3]))
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" already exists for "
- "\"%s\" command"),
- weechat_prefix ("error"), "irc",
- argv[3], "server rename");
- return WEECHAT_RC_ERROR;
- }
-
- /* rename server */
- if (irc_server_rename (server_found, argv[3]))
- {
- weechat_printf (NULL,
- _("%s%s: server %s%s%s has been renamed to "
- "%s%s"),
- weechat_prefix ("info"), "irc",
- IRC_COLOR_CHAT_SERVER,
- argv[2],
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_SERVER,
- argv[3]);
- //gui_window_redraw_all_buffers ();
- return WEECHAT_RC_OK;
- }
-
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" already exists for "
+ "\"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ argv[3], "server copy");
return WEECHAT_RC_ERROR;
}
- else if (weechat_strcasecmp (argv[1], "keep") == 0)
+
+ /* duplicate server */
+ new_server = irc_server_duplicate (server_found, argv[3]);
+ if (new_server)
{
- if (argc < 3)
- {
- IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
- }
-
- /* look for server by name */
- server_found = irc_server_search (argv[2]);
- if (!server_found)
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" not found for "
- "\"%s\" command"),
- weechat_prefix ("error"), "irc",
- argv[2], "server keep");
- return WEECHAT_RC_ERROR;
- }
-
- /* check that it is temporary server */
- if (!server_found->temp_server)
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" is not a temporary "
- "server"),
- weechat_prefix ("error"), "irc", argv[2]);
- return WEECHAT_RC_ERROR;
- }
-
- /* remove temporary flag on server */
- server_found->temp_server = 0;
-
weechat_printf (NULL,
- _("%s%s: server %s%s%s is not temporary any "
- "more"),
- weechat_prefix ("info"), "irc",
+ _("%s: server %s%s%s has been copied to "
+ "%s%s"),
+ "irc",
IRC_COLOR_CHAT_SERVER,
argv[2],
- IRC_COLOR_CHAT);
-
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_SERVER,
+ argv[3]);
+ //gui_window_redraw_all_buffers ();
return WEECHAT_RC_OK;
}
- else if (weechat_strcasecmp (argv[1], "del") == 0)
+
+ return WEECHAT_RC_ERROR;
+ }
+
+ if (weechat_strcasecmp (argv[1], "rename") == 0)
+ {
+ if (argc < 4)
{
- if (argc < 3)
- {
- IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server del");
- }
-
- /* look for server by name */
- server_found = irc_server_search (argv[2]);
- if (!server_found)
- {
- weechat_printf (NULL,
- _("%s%s: server \"%s\" not found for "
- "\"%s\" command"),
- weechat_prefix ("error"), "irc",
- argv[2], "server del");
- return WEECHAT_RC_ERROR;
- }
- if (server_found->is_connected)
- {
- weechat_printf (NULL,
- _("%s%s: you can not delete server \"%s\" "
- "because you are connected to. "
- "Try \"/disconnect %s\" before."),
- weechat_prefix ("error"), "irc",
- argv[2], argv[2]);
- return WEECHAT_RC_ERROR;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
+ }
+
+ /* look for server by name */
+ server_found = irc_server_search (argv[2]);
+ if (!server_found)
+ {
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" not found for "
+ "\"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ argv[2], "server rename");
+ return WEECHAT_RC_ERROR;
+ }
+
+ /* check if target name already exists */
+ if (irc_server_search (argv[3]))
+ {
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" already exists for "
+ "\"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ argv[3], "server rename");
+ return WEECHAT_RC_ERROR;
+ }
+
+ /* rename server */
+ if (irc_server_rename (server_found, argv[3]))
+ {
+ weechat_printf (NULL,
+ _("%s: server %s%s%s has been renamed to "
+ "%s%s"),
+ "irc",
+ IRC_COLOR_CHAT_SERVER,
+ argv[2],
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_SERVER,
+ argv[3]);
+ //gui_window_redraw_all_buffers ();
+ return WEECHAT_RC_OK;
+ }
+
+ return WEECHAT_RC_ERROR;
+ }
+
+ if (weechat_strcasecmp (argv[1], "keep") == 0)
+ {
+ if (argc < 3)
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
+ }
+
+ /* look for server by name */
+ server_found = irc_server_search (argv[2]);
+ if (!server_found)
+ {
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" not found for "
+ "\"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ argv[2], "server keep");
+ return WEECHAT_RC_ERROR;
+ }
+
+ /* check that it is temporary server */
+ if (!server_found->temp_server)
+ {
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" is not a temporary "
+ "server"),
+ weechat_prefix ("error"), "irc", argv[2]);
+ return WEECHAT_RC_ERROR;
+ }
+
+ /* remove temporary flag on server */
+ server_found->temp_server = 0;
+
+ weechat_printf (NULL,
+ _("%s: server %s%s%s is not temporary any "
+ "more"),
+ "irc",
+ IRC_COLOR_CHAT_SERVER,
+ argv[2],
+ IRC_COLOR_CHAT);
+
+ return WEECHAT_RC_OK;
+ }
+
+ if (weechat_strcasecmp (argv[1], "del") == 0)
+ {
+ if (argc < 3)
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server del");
+ }
+
+ /* look for server by name */
+ server_found = irc_server_search (argv[2]);
+ if (!server_found)
+ {
+ weechat_printf (NULL,
+ _("%s%s: server \"%s\" not found for "
+ "\"%s\" command"),
+ weechat_prefix ("error"), "irc",
+ argv[2], "server del");
+ return WEECHAT_RC_ERROR;
+ }
+ if (server_found->is_connected)
+ {
+ weechat_printf (NULL,
+ _("%s%s: you can not delete server \"%s\" "
+ "because you are connected to. "
+ "Try \"/disconnect %s\" before."),
+ weechat_prefix ("error"), "irc",
+ argv[2], argv[2]);
+ return WEECHAT_RC_ERROR;
}
-
+
/*
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
@@ -2894,48 +2909,44 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
}
}
*/
-
- server_name = strdup (server_found->name);
-
- irc_server_free (server_found);
-
- weechat_printf (NULL,
- _("%s%s: Server %s%s%s has been deleted"),
- weechat_prefix ("info"), "irc",
- IRC_COLOR_CHAT_SERVER,
- (server_name) ? server_name : "???",
- IRC_COLOR_CHAT);
- if (server_name)
- free (server_name);
-
- //gui_window_redraw_buffer (window->buffer);
-
- return WEECHAT_RC_OK;
- }
- else if (weechat_strcasecmp (argv[1], "deloutq") == 0)
- {
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- irc_server_outqueue_free_all (ptr_server);
- }
- weechat_printf (NULL,
- _("%s%s: messages outqueue DELETED for all "
- "servers. Some messages from you or "
- "WeeChat may have been lost!"),
- weechat_prefix ("info"), "irc");
- return WEECHAT_RC_OK;
- }
- else
+
+ server_name = strdup (server_found->name);
+
+ irc_server_free (server_found);
+
+ weechat_printf (NULL,
+ _("%s: Server %s%s%s has been deleted"),
+ "irc",
+ IRC_COLOR_CHAT_SERVER,
+ (server_name) ? server_name : "???",
+ IRC_COLOR_CHAT);
+ if (server_name)
+ free (server_name);
+
+ //gui_window_redraw_buffer (window->buffer);
+
+ return WEECHAT_RC_OK;
+ }
+
+ if (weechat_strcasecmp (argv[1], "deloutq") == 0)
+ {
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
{
- weechat_printf (NULL,
- _("%s%s: unknown option for \"%s\" command"),
- weechat_prefix ("error"), "irc", "server");
- return WEECHAT_RC_ERROR;
+ irc_server_outqueue_free_all (ptr_server);
}
+ weechat_printf (NULL,
+ _("%s: messages outqueue DELETED for all "
+ "servers. Some messages from you or "
+ "WeeChat may have been lost!"),
+ "irc");
+ return WEECHAT_RC_OK;
}
-
- return WEECHAT_RC_OK;
+
+ weechat_printf (NULL,
+ _("%s%s: unknown option for \"%s\" command"),
+ weechat_prefix ("error"), "irc", "server");
+ return WEECHAT_RC_ERROR;
}
/*
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 4089c3fb5..62a85723d 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -171,7 +171,7 @@ irc_completion_channel_nicks_cb (void *data, char *completion,
}
/* add nicks speaking recently on this channel */
- if (weechat_config_boolean (irc_config_irc_nick_completion_smart))
+ if (weechat_config_boolean (irc_config_look_nick_completion_smart))
{
list_size = weechat_list_size (ptr_channel->nicks_speaking);
for (i = 0; i < list_size; i++)
@@ -320,11 +320,11 @@ irc_completion_msg_part_cb (void *data, char *completion,
(void) completion;
(void) buffer;
- if (weechat_config_string (irc_config_irc_default_msg_part)
- && weechat_config_string (irc_config_irc_default_msg_part)[0])
+ if (weechat_config_string (irc_config_network_default_msg_part)
+ && weechat_config_string (irc_config_network_default_msg_part)[0])
{
weechat_list_add (list,
- weechat_config_string (irc_config_irc_default_msg_part),
+ weechat_config_string (irc_config_network_default_msg_part),
WEECHAT_LIST_POS_SORT);
}
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 18f857e34..9062a8b60 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <pwd.h>
@@ -32,30 +33,45 @@
#include "irc-server.h"
+char *irc_config_server_option_str[IRC_CONFIG_NUM_SERVER_OPTIONS] =
+{ "autoconnect", "autoreconnect", "autoreconnect_delay", "addresses", "ipv6",
+ "ssl", "password", "nicks", "username", "realname", "hostname", "command",
+ "command_delay", "autojoin", "autorejoin", "notify_levels"
+};
+char *irc_config_server_option_default[IRC_CONFIG_NUM_SERVER_OPTIONS] =
+{ "off", "on", "30", "", "off", "off", "", "", "", "", "", "", "0", "",
+ "off", ""
+};
+
struct t_config_file *irc_config_file = NULL;
+struct t_config_section *irc_config_section_server_default = NULL;
struct t_config_section *irc_config_section_server = NULL;
-/* config, irc section */
-
-struct t_config_option *irc_config_irc_one_server_buffer;
-struct t_config_option *irc_config_irc_open_near_server;
-struct t_config_option *irc_config_irc_nick_prefix;
-struct t_config_option *irc_config_irc_nick_suffix;
-struct t_config_option *irc_config_irc_nick_completion_smart;
-struct t_config_option *irc_config_irc_display_away;
-struct t_config_option *irc_config_irc_show_away_once;
-struct t_config_option *irc_config_irc_default_msg_part;
-struct t_config_option *irc_config_irc_notice_as_pv;
-struct t_config_option *irc_config_irc_away_check;
-struct t_config_option *irc_config_irc_away_check_max_nicks;
-struct t_config_option *irc_config_irc_lag_check;
-struct t_config_option *irc_config_irc_lag_min_show;
-struct t_config_option *irc_config_irc_lag_disconnect;
-struct t_config_option *irc_config_irc_anti_flood;
-struct t_config_option *irc_config_irc_highlight;
-struct t_config_option *irc_config_irc_colors_receive;
-struct t_config_option *irc_config_irc_colors_send;
-struct t_config_option *irc_config_irc_send_unknown_commands;
+/* config, look section */
+
+struct t_config_option *irc_config_look_one_server_buffer;
+struct t_config_option *irc_config_look_open_near_server;
+struct t_config_option *irc_config_look_nick_prefix;
+struct t_config_option *irc_config_look_nick_suffix;
+struct t_config_option *irc_config_look_nick_completion_smart;
+struct t_config_option *irc_config_look_display_away;
+struct t_config_option *irc_config_look_show_away_once;
+struct t_config_option *irc_config_look_notice_as_pv;
+struct t_config_option *irc_config_look_highlight;
+
+/* config, network section */
+
+struct t_config_option *irc_config_network_default_msg_part;
+struct t_config_option *irc_config_network_default_msg_quit;
+struct t_config_option *irc_config_network_away_check;
+struct t_config_option *irc_config_network_away_check_max_nicks;
+struct t_config_option *irc_config_network_lag_check;
+struct t_config_option *irc_config_network_lag_min_show;
+struct t_config_option *irc_config_network_lag_disconnect;
+struct t_config_option *irc_config_network_anti_flood;
+struct t_config_option *irc_config_network_colors_receive;
+struct t_config_option *irc_config_network_colors_send;
+struct t_config_option *irc_config_network_send_unknown_commands;
/* config, dcc section */
@@ -74,36 +90,68 @@ struct t_config_option *irc_config_dcc_auto_resume;
/* config, log section */
-struct t_config_option *irc_config_log_auto_server;
-struct t_config_option *irc_config_log_auto_channel;
-struct t_config_option *irc_config_log_auto_private;
+struct t_config_option *irc_config_log_auto_log_server;
+struct t_config_option *irc_config_log_auto_log_channel;
+struct t_config_option *irc_config_log_auto_log_private;
struct t_config_option *irc_config_log_hide_nickserv_pwd;
/* config, server section */
-struct t_config_option *irc_config_server_name;
-struct t_config_option *irc_config_server_autoconnect;
-struct t_config_option *irc_config_server_autoreconnect;
-struct t_config_option *irc_config_server_autoreconnect_delay;
-struct t_config_option *irc_config_server_addresses;
-struct t_config_option *irc_config_server_ipv6;
-struct t_config_option *irc_config_server_ssl;
-struct t_config_option *irc_config_server_password;
-struct t_config_option *irc_config_server_nicks;
-struct t_config_option *irc_config_server_username;
-struct t_config_option *irc_config_server_realname;
-struct t_config_option *irc_config_server_hostname;
-struct t_config_option *irc_config_server_command;
-struct t_config_option *irc_config_server_command_delay;
-struct t_config_option *irc_config_server_autojoin;
-struct t_config_option *irc_config_server_autorejoin;
-struct t_config_option *irc_config_server_notify_levels;
-
-struct t_irc_server *irc_config_server = NULL;
-int irc_config_reload_flag;
+struct t_config_option *irc_config_server_default[IRC_CONFIG_NUM_SERVER_OPTIONS];
/*
+ * irc_config_search_server_option: search a server option name
+ * return index of option in array
+ * "irc_config_server_option_str", or -1 if
+ * not found
+ */
+
+int
+irc_config_search_server_option (char *option_name)
+{
+ int i;
+
+ if (!option_name)
+ return -1;
+
+ for (i = 0; i < IRC_CONFIG_NUM_SERVER_OPTIONS; i++)
+ {
+ if (weechat_strcasecmp (irc_config_server_option_str[i],
+ option_name) == 0)
+ return i;
+ }
+
+ /* server option not found */
+ return -1;
+}
+
+struct t_irc_server *
+irc_config_get_server_from_option_name (char *name)
+{
+ struct t_irc_server *ptr_server;
+ char *pos_option, *server_name;
+
+ ptr_server = NULL;
+
+ if (name)
+ {
+ pos_option = strchr (name, '.');
+ if (pos_option)
+ {
+ server_name = weechat_strndup (name, pos_option - name);
+ if (server_name)
+ {
+ ptr_server = irc_server_search (server_name);
+ free (server_name);
+ }
+ }
+ }
+
+ return ptr_server;
+}
+
+/*
* irc_config_change_one_server_buffer: called when the "one server buffer"
* setting is changed
*/
@@ -130,7 +178,7 @@ irc_config_change_away_check ()
weechat_unhook (irc_hook_timer_check_away);
irc_hook_timer_check_away = NULL;
}
- if (weechat_config_integer (irc_config_irc_away_check) == 0)
+ if (weechat_config_integer (irc_config_network_away_check) == 0)
{
/* reset away flag for all nicks/chans/servers */
//irc_server_remove_away ();
@@ -201,259 +249,598 @@ irc_config_change_notify_levels ()
}
/*
+ * irc_config_server_default_change_cb: callback called when a default server
+ * option is modified
+ */
+
+void
+irc_config_server_default_change_cb (void *data, struct t_config_option *option)
+{
+ int index_option, length;
+ char *option_full_name;
+ struct t_irc_server *ptr_server;
+ struct t_config_option *ptr_option;
+
+ index_option = irc_config_search_server_option (data);
+ if (index_option >= 0)
+ {
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ length = strlen (ptr_server->name) + 1 + strlen (data) + 1;
+ option_full_name = malloc (length);
+ if (option_full_name)
+ {
+ ptr_option = weechat_config_search_option (irc_config_file,
+ irc_config_section_server,
+ option_full_name);
+ if (!ptr_option)
+ {
+ /* option does not exist for server, so we change value
+ with default value */
+ irc_server_set_with_option (ptr_server, index_option,
+ option);
+ }
+ free (option_full_name);
+ }
+ }
+ }
+}
+
+/*
+ * irc_config_server_change_cb: callback called when a server option is modified
+ */
+
+void
+irc_config_server_change_cb (void *data, struct t_config_option *option)
+{
+ int index_option;
+ char *name;
+ struct t_irc_server *ptr_server;
+
+ index_option = irc_config_search_server_option (data);
+ if (index_option >= 0)
+ {
+ name = weechat_config_option_get_pointer (option, "name");
+ ptr_server = irc_config_get_server_from_option_name (name);
+ if (ptr_server)
+ {
+ irc_server_set_with_option (ptr_server, index_option, option);
+ }
+ }
+}
+
+/*
+ * irc_config_server_delete_cb: callback called when a server option is deleted
+ */
+
+void
+irc_config_server_delete_cb (void *data, struct t_config_option *option)
+{
+ int index_option;
+ char *name;
+ struct t_irc_server *ptr_server;
+
+ index_option = irc_config_search_server_option (data);
+ if (index_option >= 0)
+ {
+ name = weechat_config_option_get_pointer (option, "name");
+ ptr_server = irc_config_get_server_from_option_name (name);
+ if (ptr_server)
+ {
+ irc_server_set_with_option (ptr_server, index_option,
+ irc_config_server_default[index_option]);
+ }
+ }
+}
+
+/*
+ * irc_config_reload_servers_from_config: create/update servers from options
+ * read in config file
+ */
+
+void
+irc_config_reload_servers_from_config ()
+{
+ struct t_plugin_infolist *infolist;
+ struct t_irc_server *ptr_server;
+ struct t_config_option *ptr_option;
+ char *name, *full_name, *server_name, *pos_option;
+ int i, index_option;
+
+ infolist = weechat_infolist_get ("options", "irc.server.*");
+ while (weechat_infolist_next (infolist))
+ {
+ name = weechat_infolist_string (infolist, "name");
+ full_name = weechat_infolist_string (infolist, "full_name");
+ if (name && full_name)
+ {
+ pos_option = strchr (name, '.');
+ if (pos_option)
+ {
+ server_name = weechat_strndup (name, pos_option - name);
+ if (server_name)
+ {
+ pos_option++;
+ ptr_server = irc_server_search (server_name);
+ if (!ptr_server)
+ {
+ /* create server, it's first time we see it */
+ ptr_server = irc_server_alloc (server_name);
+ if (!ptr_server)
+ {
+ weechat_printf (NULL,
+ _("%s%s: error creating server "
+ "\"%s\""),
+ weechat_prefix ("error"), "irc",
+ server_name);
+ }
+ }
+ if (ptr_server)
+ {
+ index_option = irc_config_search_server_option (pos_option);
+ if (index_option >= 0)
+ {
+ if (!ptr_server->reloaded_from_config)
+ {
+ /* it's first time we see server, and we are
+ reloading config, then initialize server
+ with default values (will be overwritten
+ by config later in this function
+ */
+ for (i = 0; i < IRC_CONFIG_NUM_SERVER_OPTIONS; i++)
+ {
+ irc_server_set_with_option (ptr_server,
+ i,
+ irc_config_server_default[i]);
+ }
+ ptr_server->reloaded_from_config = 1;
+ }
+ weechat_config_search_with_string (full_name, NULL,
+ NULL, &ptr_option,
+ NULL);
+ if (ptr_option)
+ {
+ irc_server_set_with_option (ptr_server,
+ index_option,
+ ptr_option);
+ }
+ }
+ }
+ else
+ {
+ weechat_printf (NULL,
+ _("%s%s: error creating option "
+ "\"%s\" for server \"%s\" (server "
+ "not found)"),
+ weechat_prefix ("error"), "irc",
+ pos_option, server_name);
+ }
+ free (server_name);
+ }
+ }
+ }
+ }
+ weechat_infolist_free (infolist);
+}
+
+/*
* irc_config_reload: reload IRC configuration file
*/
int
irc_config_reload (void *data, struct t_config_file *config_file)
{
- struct t_irc_server *ptr_server, *next_server;
int rc;
+ struct t_irc_server *ptr_server, *next_server;
/* make C compiler happy */
(void) data;
- (void) config_file;
- irc_config_server = NULL;
- irc_config_reload_flag = 1;
+ weechat_config_section_free_options (irc_config_section_server);
+
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
ptr_server->reloaded_from_config = 0;
}
- rc = weechat_config_reload (irc_config_file);
+ rc = weechat_config_reload (config_file);
if (rc == 0)
+ irc_config_reload_servers_from_config (1);
+
+ ptr_server = irc_servers;
+ while (ptr_server)
{
+ next_server = ptr_server->next_server;
- if (irc_config_server)
- irc_server_init_with_config_options (irc_config_server,
- irc_config_section_server,
- irc_config_reload_flag);
-
- ptr_server = irc_servers;
- while (ptr_server)
+ if (!ptr_server->reloaded_from_config)
{
- next_server = ptr_server->next_server;
-
- if (!ptr_server->reloaded_from_config)
+ if (ptr_server->is_connected)
{
- if (ptr_server->is_connected)
- {
- weechat_printf (NULL,
- _("%s%s: warning: server \"%s\" not found "
- "in configuration file, not deleted in "
- "memory because it's currently used"),
- weechat_prefix ("error"), "irc",
- ptr_server->name);
- }
- else
- irc_server_free (ptr_server);
+ weechat_printf (NULL,
+ _("%s%s: warning: server \"%s\" not found "
+ "in configuration file, not deleted in "
+ "memory because it's currently used"),
+ weechat_prefix ("error"), "irc",
+ ptr_server->name);
+ /* TODO: create options for server in section (options that
+ are not default one */
+ // ...
}
-
- ptr_server = next_server;
+ else
+ irc_server_free (ptr_server);
}
+
+ ptr_server = next_server;
}
return rc;
}
/*
- * irc_config_read_server_line: read a server line in configuration file
+ * irc_config_server_write_default: write default server section in configuration file
*/
void
-irc_config_read_server_line (void *data, struct t_config_file *config_file,
- char *option_name, char *value)
+irc_config_server_write_default (void *data, struct t_config_file *config_file,
+ char *section_name)
{
- struct t_config_option *ptr_option;
- int rc;
-
/* make C compiler happy */
(void) data;
- (void) config_file;
+
+ weechat_config_write_line (config_file, section_name, NULL);
+
+ weechat_config_write_line (config_file, "freenode.addresses",
+ "%s", "\"chat.freenode.net/6667\"");
+}
- if (option_name && value)
- {
- if (irc_config_server)
- {
- ptr_option = weechat_config_search_option (irc_config_file,
- irc_config_section_server,
- option_name);
- if (ptr_option)
- {
- rc = weechat_config_option_set (ptr_option, value, 0);
- switch (rc)
- {
- case 2:
- break;
- case 1:
- break;
- case 0:
- weechat_printf (NULL,
- _("%s%s: value \"%s\" is invalid "
- "for option \"%s\""),
- weechat_prefix ("error"), "irc",
- value, option_name);
- break;
- }
- }
- else
- {
- weechat_printf (NULL,
- _("%s%s: option \"%s\" not found"),
- weechat_prefix ("error"), "irc",
- option_name);
- }
- }
- }
- else
+/*
+ * irc_config_server_new_option: create a new option for a server
+ */
+
+struct t_config_option *
+irc_config_server_new_option (struct t_config_file *config_file,
+ struct t_config_section *section,
+ int index_option,
+ char *option_name, char *value,
+ void *callback_change,
+ void *callback_change_data,
+ void *callback_delete,
+ void *callback_delete_data)
+{
+ struct t_config_option *new_option;
+
+ new_option = NULL;
+
+ switch (index_option)
{
- /* beginning of [server] section: save current server and create new
- with default values for filling with next lines in file */
- if (irc_config_server)
- {
- irc_server_init_with_config_options (irc_config_server,
- irc_config_section_server,
- irc_config_reload_flag);
- }
- irc_config_server = irc_server_alloc ();
- if (!irc_config_server)
- {
- weechat_printf (NULL,
- _("%s%s: error creating server for reading "
- "configuration file"), "irc",
- weechat_prefix ("error"));
- }
+ case IRC_CONFIG_SERVER_AUTOCONNECT:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "boolean",
+ N_("automatically connect to server when WeeChat is starting"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_AUTORECONNECT:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "boolean",
+ N_("automatically reconnect to server when disconnected"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_AUTORECONNECT_DELAY:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("delay (in seconds) before trying again to reconnect to server"),
+ NULL, 0, 65535, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_ADDRESSES:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("list of IP/port or hostname/port for server (separated by comma)"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_IPV6:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "boolean",
+ N_("use IPv6 protocol for server communication"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_SSL:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "boolean",
+ N_("use SSL for server communication"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_PASSWORD:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("password for IRC server"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_NICKS:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("nicknames to use on IRC server (separated by comma)"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_USERNAME:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("user name to use on IRC server"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_REALNAME:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("real name to use on IRC server"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_HOSTNAME:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("custom hostname/IP for server (optional, if empty local hostname "
+ "is used)"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_COMMAND:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("command(s) to run when connected to server (many commands should "
+ "be separated by ';', use '\\;' for a semicolon, special variables "
+ "$nick, $channel and $server are replaced by their value)"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_COMMAND_DELAY:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("delay (in seconds) after command was executed (example: give some "
+ "time for authentication)"),
+ NULL, 0, 3600, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_AUTOJOIN:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("comma separated list of channels to join when connected to server "
+ "(example: \"#chan1,#chan2,#chan3 key1,key2\")"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_AUTOREJOIN:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "boolean",
+ N_("automatically rejoin channels when kicked"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_SERVER_NOTIFY_LEVELS:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("comma separated list of notify levels for channels of this server "
+ "(format: #channel:1,..), a channel name '*' is reserved for "
+ "server default notify level"),
+ NULL, 0, 0, value, NULL, NULL,
+ callback_change, callback_change_data,
+ callback_delete, callback_delete_data);
+ break;
+ case IRC_CONFIG_NUM_SERVER_OPTIONS:
+ break;
}
+
+ return new_option;
}
/*
- * irc_config_write_servers: write servers in configuration file
+ * irc_config_server_create_option: create a server option
*/
-void
-irc_config_write_servers (void *data, struct t_config_file *config_file,
- char *section_name)
+int
+irc_config_server_create_option (void *data, struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name, char *value)
{
+ struct t_config_option *ptr_option;
struct t_irc_server *ptr_server;
+ int rc, index_option;
+ char *pos_option, *server_name;
/* make C compiler happy */
(void) data;
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
+ rc = 0;
+
+ if (option_name)
{
- if (!ptr_server->temp_server)
+ pos_option = strchr (option_name, '.');
+ if (pos_option)
{
- weechat_config_write_line (config_file, section_name, NULL);
- weechat_config_write_line (config_file, "server_name", "\"%s\"",
- ptr_server->name);
- weechat_config_write_line (config_file, "server_autoconnect", "%s",
- (ptr_server->autoconnect) ? "on" : "off");
- weechat_config_write_line (config_file, "server_autoreconnect", "%s",
- (ptr_server->autoreconnect) ? "on" : "off");
- weechat_config_write_line (config_file, "server_autoreconnect_delay", "%d",
- ptr_server->autoreconnect_delay);
- weechat_config_write_line (config_file, "server_addresses", "\"%s\"", ptr_server->addresses);
- weechat_config_write_line (config_file, "server_ipv6", "%s",
- (ptr_server->ipv6) ? "on" : "off");
- weechat_config_write_line (config_file, "server_ssl", "%s",
- (ptr_server->ssl) ? "on" : "off");
- weechat_config_write_line (config_file, "server_password", "\"%s\"",
- (ptr_server->password) ? ptr_server->password : "");
- weechat_config_write_line (config_file, "server_nicks", "\"%s\"",
- ptr_server->nicks);
- weechat_config_write_line (config_file, "server_username", "\"%s\"",
- ptr_server->username);
- weechat_config_write_line (config_file, "server_realname", "\"%s\"",
- ptr_server->realname);
- weechat_config_write_line (config_file, "server_hostname", "\"%s\"",
- (ptr_server->hostname) ? ptr_server->hostname : "");
- weechat_config_write_line (config_file, "server_command", "\"%s\"",
- (ptr_server->command) ? ptr_server->command : "");
- weechat_config_write_line (config_file, "server_command_delay", "%d",
- ptr_server->command_delay);
- weechat_config_write_line (config_file, "server_autojoin", "\"%s\"",
- (ptr_server->autojoin) ? ptr_server->autojoin : "");
- weechat_config_write_line (config_file, "server_autorejoin", "%s",
- (ptr_server->autorejoin) ? "on" : "off");
- weechat_config_write_line (config_file, "server_notify_levels", "\"%s\"",
- (ptr_server->notify_levels) ? ptr_server->notify_levels : "");
+ server_name = weechat_strndup (option_name,
+ pos_option - option_name);
+ pos_option++;
+ if (server_name)
+ {
+ index_option = irc_config_search_server_option (pos_option);
+ if (index_option >= 0)
+ {
+ ptr_server = irc_server_search (server_name);
+ if (!ptr_server)
+ ptr_server = irc_server_alloc (server_name);
+ if (!ptr_server)
+ {
+ weechat_printf (NULL,
+ _("%s%s: error creating server "
+ "\"%s\""),
+ weechat_prefix ("error"), "irc",
+ server_name);
+ }
+ ptr_option = weechat_config_search_option (config_file,
+ section,
+ option_name);
+ if (ptr_option)
+ {
+ rc = weechat_config_option_set (ptr_option, value, 1);
+ }
+ else
+ {
+ if (value && value[0] && (index_option >= 0))
+ {
+ ptr_option = irc_config_server_new_option (config_file,
+ section,
+ index_option,
+ option_name,
+ value,
+ &irc_config_server_change_cb,
+ irc_config_server_option_str[index_option],
+ &irc_config_server_delete_cb,
+ irc_config_server_option_str[index_option]);
+
+ if (ptr_option)
+ {
+ if (ptr_server)
+ {
+ irc_server_set_with_option (ptr_server,
+ index_option,
+ ptr_option);
+ }
+ rc = 1;
+ }
+ }
+ }
+ }
+ free (server_name);
+ }
}
}
+
+ if (rc == 0)
+ {
+ weechat_printf (NULL,
+ _("%s%s: error creating server option \"%s\""),
+ weechat_prefix ("error"), "irc",
+ option_name);
+ }
+
+ return rc;
}
/*
- * irc_config_write_server_default: write default server in configuration file
+ * irc_config_server_create_default_options: create default options for servers
*/
void
-irc_config_write_server_default (void *data, struct t_config_file *config_file,
- char *section_name)
+irc_config_server_create_default_options (struct t_config_section *section)
{
+ int i, length;
+ char *nicks, *username, *realname, *pos, *default_value;
struct passwd *my_passwd;
- char *realname, *pos;
- /* make C compiler happy */
- (void) data;
-
- weechat_config_write_line (config_file, section_name, NULL);
-
- weechat_config_write_line (config_file, "server_name", "%s", "\"freenode\"");
- weechat_config_write_line (config_file, "server_autoconnect", "%s", "off");
- weechat_config_write_line (config_file, "server_autoreconnect", "%s", "on");
- weechat_config_write_line (config_file, "server_autoreconnect_delay", "%s", "30");
- weechat_config_write_line (config_file, "server_addresses", "%s", "\"irc.freenode.net/6667\"");
- weechat_config_write_line (config_file, "server_ipv6", "%s", "off");
- weechat_config_write_line (config_file, "server_ssl", "%s", "off");
- weechat_config_write_line (config_file, "server_password", "%s", "\"\"");
+ nicks = NULL;
+ username = NULL;
+ realname = NULL;
/* Get the user's name from /etc/passwd */
if ((my_passwd = getpwuid (geteuid ())) != NULL)
{
- weechat_config_write_line (config_file,
- "server_nicks", "\"%s,%s1,%s2,%s3,%s4\"",
- my_passwd->pw_name,
- my_passwd->pw_name,
- my_passwd->pw_name,
- my_passwd->pw_name,
- my_passwd->pw_name);
- weechat_config_write_line (config_file, "server_username", "\"%s\"", my_passwd->pw_name);
+ length = (strlen (my_passwd->pw_name) + 4) * 5;
+ nicks = malloc (length);
+ if (nicks)
+ {
+ snprintf (nicks, length, "%s,%s1,%s2,%s3,%s4",
+ my_passwd->pw_name,
+ my_passwd->pw_name,
+ my_passwd->pw_name,
+ my_passwd->pw_name,
+ my_passwd->pw_name);
+ }
+ username = strdup (my_passwd->pw_name);
if ((!my_passwd->pw_gecos)
|| (my_passwd->pw_gecos[0] == '\0')
|| (my_passwd->pw_gecos[0] == ',')
|| (my_passwd->pw_gecos[0] == ' '))
- weechat_config_write_line (config_file, "server_realname", "\"%s\"", my_passwd->pw_name);
+ realname = strdup (my_passwd->pw_name);
else
{
realname = strdup (my_passwd->pw_gecos);
pos = strchr (realname, ',');
if (pos)
pos[0] = '\0';
- weechat_config_write_line (config_file, "server_realname", "\"%s\"",
- realname);
- if (pos)
- pos[0] = ',';
- free (realname);
}
}
else
{
/* default values if /etc/passwd can't be read */
- weechat_config_write_line (config_file, "server_nicks", "%s",
- "\"" IRC_SERVER_DEFAULT_NICKS "\"");
- weechat_config_write_line (config_file, "server_username", "%s", "\"weechat\"");
- weechat_config_write_line (config_file, "server_realname", "%s", "\"weechat\"");
+ nicks = strdup (IRC_SERVER_DEFAULT_NICKS);
+ username = strdup ("weechat");
+ realname = strdup ("weechat");
}
- weechat_config_write_line (config_file, "server_hostname", "%s", "\"\"");
- weechat_config_write_line (config_file, "server_command", "%s", "\"\"");
- weechat_config_write_line (config_file, "server_command_delay", "%s", "0");
- weechat_config_write_line (config_file, "server_autojoin", "%s", "\"\"");
- weechat_config_write_line (config_file, "server_autorejoin", "%s", "on");
- weechat_config_write_line (config_file, "server_notify_levels", "%s", "\"\"");
+ for (i = 0; i < IRC_CONFIG_NUM_SERVER_OPTIONS; i++)
+ {
+ default_value = NULL;
+ if (i == IRC_CONFIG_SERVER_NICKS)
+ default_value = nicks;
+ else if (i == IRC_CONFIG_SERVER_USERNAME)
+ default_value = username;
+ else if (i == IRC_CONFIG_SERVER_REALNAME)
+ default_value = realname;
+ if (!default_value)
+ default_value = irc_config_server_option_default[i];
+
+ irc_config_server_default[i] = irc_config_server_new_option (
+ irc_config_file,
+ section,
+ i,
+ irc_config_server_option_str[i],
+ default_value,
+ &irc_config_server_default_change_cb,
+ irc_config_server_option_str[i],
+ NULL,
+ NULL);
+ }
}
/*
@@ -465,131 +852,145 @@ int
irc_config_init ()
{
struct t_config_section *ptr_section;
-
- irc_config_file = weechat_config_new (IRC_CONFIG_FILENAME,
+
+ irc_config_file = weechat_config_new (IRC_CONFIG_NAME,
&irc_config_reload, NULL);
if (!irc_config_file)
return 0;
- ptr_section = weechat_config_new_section (irc_config_file, "irc",
- NULL, NULL,
- NULL, NULL,
- NULL, NULL);
+ ptr_section = weechat_config_new_section (irc_config_file, "look",
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
return 0;
}
- irc_config_irc_one_server_buffer = weechat_config_new_option (
+ irc_config_look_one_server_buffer = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_one_server_buffer", "boolean",
+ "one_server_buffer", "boolean",
N_("use same buffer for all servers"),
- NULL, 0, 0, "off", &irc_config_change_one_server_buffer, NULL);
- irc_config_irc_open_near_server = weechat_config_new_option (
+ NULL, 0, 0, "off", NULL, NULL, &irc_config_change_one_server_buffer, NULL, NULL, NULL);
+ irc_config_look_open_near_server = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_open_near_server", "boolean",
+ "open_near_server", "boolean",
N_("open new channels/privates near server"),
- NULL, 0, 0, "off", NULL, NULL);
- irc_config_irc_nick_prefix = weechat_config_new_option (
+ NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_nick_prefix = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_nick_prefix", "string",
+ "nick_prefix", "string",
N_("text to display before nick in chat window"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_irc_nick_suffix = weechat_config_new_option (
+ NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_nick_suffix = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_nick_suffix", "string",
+ "nick_suffix", "string",
N_("text to display after nick in chat window"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_irc_nick_completion_smart = weechat_config_new_option (
+ NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_nick_completion_smart = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_nick_completion_smart", "boolean",
+ "nick_completion_smart", "boolean",
N_("smart completion for nicks (completes with last speakers first)"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_irc_display_away = weechat_config_new_option (
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_display_away = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_display_away", "integer",
+ "display_away", "integer",
N_("display message when (un)marking as away"),
- "off|local|channel", 0, 0, "local", NULL, NULL);
- irc_config_irc_show_away_once = weechat_config_new_option (
+ "off|local|channel", 0, 0, "local", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_show_away_once = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_show_away_once", "boolean",
+ "show_away_once", "boolean",
N_("show remote away message only once in private"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_irc_default_msg_part = weechat_config_new_option (
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_notice_as_pv = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "notice_as_pv", "boolean",
+ N_("display notices as private messages"),
+ NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_look_highlight = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "highlight", "string",
+ N_("comma separated list of words to highlight (case insensitive "
+ "comparison, words may begin or end with \"*\" for partial match)"),
+ NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL);
+
+ ptr_section = weechat_config_new_section (irc_config_file, "network",
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (irc_config_file);
+ return 0;
+ }
+
+ irc_config_network_default_msg_part = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_default_msg_part", "string",
+ "default_msg_part", "string",
N_("default part message (leaving channel) ('%v' will be replaced by "
"WeeChat version in string)"),
- NULL, 0, 0, "WeeChat %v", NULL, NULL);
- irc_config_irc_notice_as_pv = weechat_config_new_option (
+ NULL, 0, 0, "WeeChat %v", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_default_msg_quit = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_notice_as_pv", "boolean",
- N_("display notices as private messages"),
- NULL, 0, 0, "off", NULL, NULL);
- irc_config_irc_away_check = weechat_config_new_option (
+ "default_msg_quit", "string",
+ N_("default quit message (disconnecting from server) ('%v' will be "
+ "replaced by WeeChat version in string)"),
+ NULL, 0, 0, "WeeChat %v", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_away_check = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_away_check", "integer",
+ "away_check", "integer",
N_("interval between two checks for away (in minutes, 0 = never "
"check)"),
- NULL, 0, INT_MAX, "0", &irc_config_change_away_check, NULL);
- irc_config_irc_away_check_max_nicks = weechat_config_new_option (
+ NULL, 0, INT_MAX, "0", NULL, NULL, &irc_config_change_away_check, NULL, NULL, NULL);
+ irc_config_network_away_check_max_nicks = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_away_check_max_nicks", "integer",
+ "away_check_max_nicks", "integer",
N_("do not check away nicks on channels with high number of nicks "
"(0 = unlimited)"),
- NULL, 0, INT_MAX, "0", &irc_config_change_away_check, NULL);
- irc_config_irc_lag_check = weechat_config_new_option (
+ NULL, 0, INT_MAX, "0", NULL, NULL, &irc_config_change_away_check, NULL, NULL, NULL);
+ irc_config_network_lag_check = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_lag_check", "integer",
+ "lag_check", "integer",
N_("interval between two checks for lag (in seconds, 0 = never "
"check)"),
- NULL, 0, INT_MAX, "60", NULL, NULL);
- irc_config_irc_lag_min_show = weechat_config_new_option (
+ NULL, 0, INT_MAX, "60", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_lag_min_show = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_lag_min_show", "integer",
+ "lag_min_show", "integer",
N_("minimum lag to show (in seconds)"),
- NULL, 0, INT_MAX, "1", NULL, NULL);
- irc_config_irc_lag_disconnect = weechat_config_new_option (
+ NULL, 0, INT_MAX, "1", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_lag_disconnect = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_lag_disconnect", "integer",
+ "lag_disconnect", "integer",
N_("disconnect after important lag (in minutes, 0 = never "
"disconnect)"),
- NULL, 0, INT_MAX, "5", NULL, NULL);
- irc_config_irc_anti_flood = weechat_config_new_option (
+ NULL, 0, INT_MAX, "5", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_anti_flood = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_anti_flood", "integer",
+ "anti_flood", "integer",
N_("anti-flood: # seconds between two user messages (0 = no "
"anti-flood)"),
- NULL, 0, 5, "2", NULL, NULL);
- irc_config_irc_highlight = weechat_config_new_option (
+ NULL, 0, 5, "2", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_colors_receive = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_highlight", "string",
- N_("comma separated list of words to highlight (case insensitive "
- "comparison, words may begin or end with \"*\" for partial match)"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_irc_colors_receive = weechat_config_new_option (
- irc_config_file, ptr_section,
- "irc_colors_receive", "boolean",
+ "colors_receive", "boolean",
N_("when off, colors codes are ignored in incoming messages"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_irc_colors_send = weechat_config_new_option (
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_colors_send = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_colors_send", "boolean",
+ "colors_send", "boolean",
N_("allow user to send colors with special codes (^Cb=bold, "
"^Ccxx=color, ^Ccxx,yy=color+background, ^Cu=underline, "
"^Cr=reverse)"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_irc_send_unknown_commands = weechat_config_new_option (
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
+ irc_config_network_send_unknown_commands = weechat_config_new_option (
irc_config_file, ptr_section,
- "irc_send_unknown_commands", "boolean",
+ "send_unknown_commands", "boolean",
N_("send unknown commands to IRC server"),
- NULL, 0, 0, "off", NULL, NULL);
+ NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "dcc",
- NULL, NULL,
- NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -598,109 +999,119 @@ irc_config_init ()
irc_config_dcc_auto_accept_files = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_auto_accept_files", "boolean",
+ "auto_accept_files", "boolean",
N_("automatically accept incoming dcc files (use carefully!)"),
- NULL, 0, 0, "off", NULL, NULL);
+ NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_auto_accept_chats = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_auto_accept_chats", "boolean",
+ "auto_accept_chats", "boolean",
N_("automatically accept dcc chats (use carefully!)"),
- NULL, 0, 0, "off", NULL, NULL);
+ NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_timeout = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_timeout", "integer",
+ "timeout", "integer",
N_("timeout for dcc request (in seconds)"),
- NULL, 5, INT_MAX, "300", NULL, NULL);
+ NULL, 5, INT_MAX, "300", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_blocksize = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_blocksize", "integer",
+ "blocksize", "integer",
N_("block size for dcc packets in bytes"),
NULL, IRC_DCC_MIN_BLOCKSIZE, IRC_DCC_MAX_BLOCKSIZE, "65536",
- NULL, NULL);
+ NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_fast_send = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_fast_send", "boolean",
+ "fast_send", "boolean",
N_("does not wait for ACK when sending file"),
- NULL, 0, 0, "on", NULL, NULL);
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_port_range = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_port_range", "string",
+ "port_range", "string",
N_("restricts outgoing dcc to use only ports in the given range "
"(useful for NAT) (syntax: a single port, ie. 5000 or a port "
"range, ie. 5000-5015, empty value means any port)"),
- NULL, 0, 0, "", NULL, NULL);
+ NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_own_ip = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_own_ip", "string",
+ "own_ip", "string",
N_("IP or DNS address used for outgoing dcc "
"(if empty, local interface IP is used)"),
- NULL, 0, 0, "", NULL, NULL);
+ NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_download_path = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_download_path", "string",
+ "download_path", "string",
N_("path for writing incoming files with dcc"),
- NULL, 0, 0, "%h/dcc", NULL, NULL);
+ NULL, 0, 0, "%h/dcc", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_upload_path = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_upload_path", "string",
+ "upload_path", "string",
N_("path for reading files when sending thru dcc (when no path is "
"specified)"),
- NULL, 0, 0, "~", NULL, NULL);
+ NULL, 0, 0, "~", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_convert_spaces = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_convert_spaces", "boolean",
+ "convert_spaces", "boolean",
N_("convert spaces to underscores when sending files"),
- NULL, 0, 0, "on", NULL, NULL);
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_auto_rename = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_auto_rename", "boolean",
+ "auto_rename", "boolean",
N_("rename incoming files if already exists (add '.1', '.2', ...)"),
- NULL, 0, 0, "on", NULL, NULL);
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_dcc_auto_resume = weechat_config_new_option (
irc_config_file, ptr_section,
- "dcc_auto_resume", "boolean",
+ "auto_resume", "boolean",
N_("automatically resume dcc transfer if connection with remote host "
"is loosed"),
- NULL, 0, 0, "on", NULL, NULL);
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "log",
- NULL, NULL,
- NULL, NULL,
- NULL, NULL);
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
return 0;
}
- irc_config_log_auto_server = weechat_config_new_option (
+ irc_config_log_auto_log_server = weechat_config_new_option (
irc_config_file, ptr_section,
- "log_auto_server", "boolean",
+ "auto_log_server", "boolean",
N_("automatically log server messages"),
- NULL, 0, 0, "off", &irc_config_change_log, NULL);
- irc_config_log_auto_channel = weechat_config_new_option (
+ NULL, 0, 0, "off", NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
+ irc_config_log_auto_log_channel = weechat_config_new_option (
irc_config_file, ptr_section,
- "log_auto_channel", "boolean",
+ "auto_log_channel", "boolean",
N_("automatically log channel chats"),
- NULL, 0, 0, "off", &irc_config_change_log, NULL);
- irc_config_log_auto_private = weechat_config_new_option (
+ NULL, 0, 0, "off", NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
+ irc_config_log_auto_log_private = weechat_config_new_option (
irc_config_file, ptr_section,
- "log_auto_private", "boolean",
+ "auto_log_private", "boolean",
N_("automatically log private chats"),
- NULL, 0, 0, "off", &irc_config_change_log, NULL);
+ NULL, 0, 0, "off", NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
irc_config_log_hide_nickserv_pwd = weechat_config_new_option (
irc_config_file, ptr_section,
- "log_hide_nickserv_pwd", "boolean",
+ "hide_nickserv_pwd", "boolean",
N_("hide password displayed by nickserv"),
- NULL, 0, 0, "on", &irc_config_change_log, NULL);
+ NULL, 0, 0, "on", NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
+
+ ptr_section = weechat_config_new_section (irc_config_file, "server_default",
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (irc_config_file);
+ return 0;
+ }
+
+ irc_config_section_server_default = ptr_section;
+
+ irc_config_server_create_default_options (ptr_section);
ptr_section = weechat_config_new_section (irc_config_file, "server",
- &irc_config_read_server_line,
- NULL,
- &irc_config_write_servers,
- NULL,
- &irc_config_write_server_default,
- NULL);
+ NULL, NULL,
+ NULL, NULL,
+ &irc_config_server_write_default, NULL,
+ &irc_config_server_create_option, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -709,98 +1120,6 @@ irc_config_init ()
irc_config_section_server = ptr_section;
- irc_config_server_name = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_name", "string",
- N_("name associated to IRC server (for display only)"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_autoconnect = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_autoconnect", "boolean",
- N_("automatically connect to server when WeeChat is starting"),
- NULL, 0, 0, "off", NULL, NULL);
- irc_config_server_autoreconnect = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_autoreconnect", "boolean",
- N_("automatically reconnect to server when disconnected"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_server_autoreconnect_delay = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_autoreconnect_delay", "integer",
- N_("delay (in seconds) before trying again to reconnect to server"),
- NULL, 0, 65535, "30", NULL, NULL);
- irc_config_server_addresses = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_addresses", "string",
- N_("list of IP/port or hostname/port for server (separated by comma)"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_ipv6 = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_ipv6", "boolean",
- N_("use IPv6 protocol for server communication"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_server_ssl = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_ssl", "boolean",
- N_("use SSL for server communication"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_server_password = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_password", "string",
- N_("password for IRC server"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_nicks = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_nicks", "string",
- N_("nicknames to use on IRC server (separated by comma)"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_username = weechat_config_new_option (
- irc_config_file, ptr_section, "server_username", "string",
- N_("user name to use on IRC server"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_realname = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_realname", "string",
- N_("real name to use on IRC server"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_hostname = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_hostname", "string",
- N_("custom hostname/IP for server (optional, if empty local hostname "
- "is used)"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_command = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_command", "string",
- N_("command(s) to run when connected to server (many commands should "
- "be separated by ';', use '\\;' for a semicolon, special variables "
- "$nick, $channel and $server are replaced by their value)"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_command_delay = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_command_delay", "integer",
- N_("delay (in seconds) after command was executed (example: give some "
- "time for authentication)"),
- NULL, 0, 3600, "0", NULL, NULL);
- irc_config_server_autojoin = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_autojoin", "string",
- N_("comma separated list of channels to join when connected to server "
- "(example: \"#chan1,#chan2,#chan3 key1,key2\")"),
- NULL, 0, 0, "", NULL, NULL);
- irc_config_server_autorejoin = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_autorejoin", "string",
- N_("automatically rejoin channels when kicked"),
- NULL, 0, 0, "on", NULL, NULL);
- irc_config_server_notify_levels = weechat_config_new_option (
- irc_config_file, ptr_section,
- "server_notify_levels", "string",
- N_("comma separated list of notify levels for channels of this server "
- "(format: #channel:1,..), a channel name '*' is reserved for "
- "server default notify level"),
- NULL, 0, 0, "", NULL, NULL);
-
return 1;
}
@@ -816,15 +1135,7 @@ irc_config_read ()
{
int rc;
- irc_config_server = NULL;
- irc_config_reload_flag = 0;
-
rc = weechat_config_read (irc_config_file);
-
- if (irc_config_server)
- irc_server_init_with_config_options (irc_config_server,
- irc_config_section_server,
- irc_config_reload_flag);
return rc;
}
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 8127bd6d2..7c3765513 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -20,55 +20,90 @@
#ifndef __WEECHAT_IRC_CONFIG_H
#define __WEECHAT_IRC_CONFIG_H 1
-#define IRC_CONFIG_FILENAME "irc.rc"
+#define IRC_CONFIG_NAME "irc"
#define IRC_CONFIG_DISPLAY_AWAY_OFF 0
#define IRC_CONFIG_DISPLAY_AWAY_LOCAL 1
#define IRC_CONFIG_DISPLAY_AWAY_CHANNEL 2
-struct t_config_file *irc_config;
+enum t_irc_config_server_option
+{
+ IRC_CONFIG_SERVER_AUTOCONNECT = 0,
+ IRC_CONFIG_SERVER_AUTORECONNECT,
+ IRC_CONFIG_SERVER_AUTORECONNECT_DELAY,
+ IRC_CONFIG_SERVER_ADDRESSES,
+ IRC_CONFIG_SERVER_IPV6,
+ IRC_CONFIG_SERVER_SSL,
+ IRC_CONFIG_SERVER_PASSWORD,
+ IRC_CONFIG_SERVER_NICKS,
+ IRC_CONFIG_SERVER_USERNAME,
+ IRC_CONFIG_SERVER_REALNAME,
+ IRC_CONFIG_SERVER_HOSTNAME,
+ IRC_CONFIG_SERVER_COMMAND,
+ IRC_CONFIG_SERVER_COMMAND_DELAY,
+ IRC_CONFIG_SERVER_AUTOJOIN,
+ IRC_CONFIG_SERVER_AUTOREJOIN,
+ IRC_CONFIG_SERVER_NOTIFY_LEVELS,
+ /* number of server options */
+ IRC_CONFIG_NUM_SERVER_OPTIONS,
+};
-struct t_config_option *irc_config_irc_one_server_buffer;
-struct t_config_option *irc_config_irc_open_near_server;
-struct t_config_option *irc_config_irc_nick_prefix;
-struct t_config_option *irc_config_irc_nick_suffix;
-struct t_config_option *irc_config_irc_nick_completion_smart;
-struct t_config_option *irc_config_irc_display_away;
-struct t_config_option *irc_config_irc_show_away_once;
-struct t_config_option *irc_config_irc_default_msg_part;
-struct t_config_option *irc_config_irc_default_msg_quit;
-struct t_config_option *irc_config_irc_notice_as_pv;
-struct t_config_option *irc_config_irc_away_check;
-struct t_config_option *irc_config_irc_away_check_max_nicks;
-struct t_config_option *irc_config_irc_lag_check;
-struct t_config_option *irc_config_irc_lag_min_show;
-struct t_config_option *irc_config_irc_lag_disconnect;
-struct t_config_option *irc_config_irc_anti_flood;
-struct t_config_option *irc_config_irc_highlight;
-struct t_config_option *irc_config_irc_colors_receive;
-struct t_config_option *irc_config_irc_colors_send;
-struct t_config_option *irc_config_irc_send_unknown_commands;
+#define IRC_CONFIG_SERVER_DEFAULT_AUTOCONNECT 0
+#define IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT 1
+#define IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT_DELAY 30
+#define IRC_CONFIG_SERVER_DEFAULT_IPV6 0
+#define IRC_CONFIG_SERVER_DEFAULT_SSL 0
+#define IRC_CONFIG_SERVER_DEFAULT_COMMAND_DELAY 1
+#define IRC_CONFIG_SERVER_DEFAULT_AUTOREJOIN 0
-struct t_config_option *irc_config_dcc_auto_accept_files;
-struct t_config_option *irc_config_dcc_auto_accept_chats;
-struct t_config_option *irc_config_dcc_timeout;
-struct t_config_option *irc_config_dcc_blocksize;
-struct t_config_option *irc_config_dcc_fast_send;
-struct t_config_option *irc_config_dcc_port_range;
-struct t_config_option *irc_config_dcc_own_ip;
-struct t_config_option *irc_config_dcc_download_path;
-struct t_config_option *irc_config_dcc_upload_path;
-struct t_config_option *irc_config_dcc_convert_spaces;
-struct t_config_option *irc_config_dcc_auto_rename;
-struct t_config_option *irc_config_dcc_auto_resume;
-struct t_config_option *irc_config_log_auto_server;
-struct t_config_option *irc_config_log_auto_channel;
-struct t_config_option *irc_config_log_auto_private;
-struct t_config_option *irc_config_log_hide_nickserv_pwd;
+extern char *irc_config_server_option_str[];
+extern struct t_config_file *irc_config;
-int irc_config_init ();
-int irc_config_read ();
-int irc_config_write ();
+extern struct t_config_option *irc_config_look_one_server_buffer;
+extern struct t_config_option *irc_config_look_open_near_server;
+extern struct t_config_option *irc_config_look_nick_prefix;
+extern struct t_config_option *irc_config_look_nick_suffix;
+extern struct t_config_option *irc_config_look_nick_completion_smart;
+extern struct t_config_option *irc_config_look_display_away;
+extern struct t_config_option *irc_config_look_show_away_once;
+extern struct t_config_option *irc_config_look_notice_as_pv;
+extern struct t_config_option *irc_config_look_highlight;
+
+extern struct t_config_option *irc_config_network_default_msg_part;
+extern struct t_config_option *irc_config_network_default_msg_quit;
+extern struct t_config_option *irc_config_network_away_check;
+extern struct t_config_option *irc_config_network_away_check_max_nicks;
+extern struct t_config_option *irc_config_network_lag_check;
+extern struct t_config_option *irc_config_network_lag_min_show;
+extern struct t_config_option *irc_config_network_lag_disconnect;
+extern struct t_config_option *irc_config_network_anti_flood;
+extern struct t_config_option *irc_config_network_colors_receive;
+extern struct t_config_option *irc_config_network_colors_send;
+extern struct t_config_option *irc_config_network_send_unknown_commands;
+
+extern struct t_config_option *irc_config_dcc_auto_accept_files;
+extern struct t_config_option *irc_config_dcc_auto_accept_chats;
+extern struct t_config_option *irc_config_dcc_timeout;
+extern struct t_config_option *irc_config_dcc_blocksize;
+extern struct t_config_option *irc_config_dcc_fast_send;
+extern struct t_config_option *irc_config_dcc_port_range;
+extern struct t_config_option *irc_config_dcc_own_ip;
+extern struct t_config_option *irc_config_dcc_download_path;
+extern struct t_config_option *irc_config_dcc_upload_path;
+extern struct t_config_option *irc_config_dcc_convert_spaces;
+extern struct t_config_option *irc_config_dcc_auto_rename;
+extern struct t_config_option *irc_config_dcc_auto_resume;
+
+extern struct t_config_option *irc_config_log_auto_log_server;
+extern struct t_config_option *irc_config_log_auto_log_channel;
+extern struct t_config_option *irc_config_log_auto_log_private;
+extern struct t_config_option *irc_config_log_hide_nickserv_pwd;
+
+extern struct t_config_option *irc_config_server_default[];
+
+extern int irc_config_init ();
+extern int irc_config_read ();
+extern int irc_config_write ();
#endif /* irc-config.h */
diff --git a/src/plugins/irc/irc-debug.c b/src/plugins/irc/irc-debug.c
index d947a6070..a652a4963 100644
--- a/src/plugins/irc/irc-debug.c
+++ b/src/plugins/irc/irc-debug.c
@@ -83,12 +83,12 @@ irc_debug_printf (struct t_irc_server *server, int send, int modified,
weechat_printf (irc_debug_buffer,
"%s%s%s%s%s\t%s",
- (server) ? weechat_color ("color_chat_server") : "",
+ (server) ? weechat_color ("chat_server") : "",
(server) ? server->name : "",
(server) ? " " : "",
(send) ?
- weechat_color ("color_chat_prefix_quit") :
- weechat_color ("color_chat_prefix_join"),
+ weechat_color ("chat_prefix_quit") :
+ weechat_color ("chat_prefix_join"),
(send) ?
((modified) ? IRC_DEBUG_PREFIX_SEND_MOD : IRC_DEBUG_PREFIX_SEND) :
((modified) ? IRC_DEBUG_PREFIX_RECV_MOD : IRC_DEBUG_PREFIX_RECV),
diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c
index 03c2cbfca..ee213d487 100644
--- a/src/plugins/irc/irc-display.c
+++ b/src/plugins/irc/irc-display.c
@@ -344,31 +344,31 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("connected") : _("not connected"),
IRC_COLOR_CHAT_DELIMITERS);
- weechat_printf (NULL, " server_autoconnect . . . . : %s%s",
+ weechat_printf (NULL, " autoconnect . . . . : %s%s",
(server->autoconnect) ? _("on") : _("off"),
(server->temp_server) ?
_(" (temporary server, will not be saved)") : "");
- weechat_printf (NULL, " server_autoreconnect . . . : %s",
+ weechat_printf (NULL, " autoreconnect . . . : %s",
(server->autoreconnect) ? _("on") : _("off"));
- weechat_printf (NULL, " server_autoreconnect_delay : %d %s",
+ weechat_printf (NULL, " autoreconnect_delay : %d %s",
server->autoreconnect_delay,
NG_("second", "seconds", server->autoreconnect_delay));
- weechat_printf (NULL, " server_addresses . . . . . : %s",
+ weechat_printf (NULL, " addresses . . . . . : %s",
server->addresses);
- weechat_printf (NULL, " server_ipv6 . . . . . . . : %s",
+ weechat_printf (NULL, " ipv6 . . . . . . . : %s",
(server->ipv6) ? _("on") : _("off"));
- weechat_printf (NULL, " server_ssl . . . . . . . . : %s",
+ weechat_printf (NULL, " ssl . . . . . . . . : %s",
(server->ssl) ? _("on") : _("off"));
- weechat_printf (NULL, " server_password . . . . . : %s",
+ weechat_printf (NULL, " password . . . . . : %s",
(server->password && server->password[0]) ?
_("(hidden)") : "");
- weechat_printf (NULL, " server_nicks . . . . . . . : %s",
+ weechat_printf (NULL, " nicks . . . . . . . : %s",
server->nicks);
- weechat_printf (NULL, " server_username . . . . . : %s",
+ weechat_printf (NULL, " username . . . . . : %s",
server->username);
- weechat_printf (NULL, " server_realname . . . . . : %s",
+ weechat_printf (NULL, " realname . . . . . : %s",
server->realname);
- weechat_printf (NULL, " server_hostname . . . . . : %s",
+ weechat_printf (NULL, " hostname . . . . . : %s",
(server->hostname) ? server->hostname : "");
if (server->command && server->command[0])
string = strdup (server->command);
@@ -378,21 +378,21 @@ irc_display_server (struct t_irc_server *server, int with_detail)
{
if (weechat_config_boolean (irc_config_log_hide_nickserv_pwd))
irc_display_hide_password (string, 1);
- weechat_printf (NULL, " server_command . . . . . . : %s",
+ weechat_printf (NULL, " command . . . . . . : %s",
string);
free (string);
}
else
- weechat_printf (NULL, " server_command . . . . . . : %s",
+ weechat_printf (NULL, " command . . . . . . : %s",
(server->command && server->command[0]) ?
server->command : "");
- weechat_printf (NULL, " server_command_delay . . . : %d %s",
+ weechat_printf (NULL, " command_delay . . . : %d %s",
server->command_delay,
NG_("second", "seconds", server->command_delay));
- weechat_printf (NULL, " server_autojoin . . . . . : %s",
+ weechat_printf (NULL, " autojoin . . . . . : %s",
(server->autojoin && server->autojoin[0]) ?
server->autojoin : "");
- weechat_printf (NULL, " server_notify_levels . . . : %s",
+ weechat_printf (NULL, " notify_levels . . . : %s",
(server->notify_levels && server->notify_levels[0]) ?
server->notify_levels : "");
}
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index 537de4c69..586168e7a 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -158,7 +158,7 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer, char *input_data)
if (ptr_channel)
{
data_with_colors = (char *)irc_color_encode ((unsigned char *)input_data,
- weechat_config_boolean (irc_config_irc_colors_send));
+ weechat_config_boolean (irc_config_network_colors_send));
if (ptr_channel->dcc_chat)
{
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 0ead9034d..862d97c09 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -51,7 +51,7 @@ irc_nick_find_color (struct t_irc_nick *nick)
weechat_config_integer (weechat_config_get_weechat ("look_color_nicks_number")));
snprintf (color_name, sizeof (color_name),
- "color_chat_nick_color%d", color);
+ "chat_nick_color%d", color);
return weechat_color (color_name);
}
@@ -165,7 +165,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
irc_nick_get_gui_infos (channel->buffer, ptr_nick, &prefix,
&prefix_color, &ptr_group);
snprintf (str_prefix_color, sizeof (str_prefix_color),
- "color_nicklist_prefix%d",
+ "nicklist_prefix%d",
prefix_color);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
ptr_nick->name, ptr_nick->color,
@@ -211,7 +211,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
irc_nick_get_gui_infos (channel->buffer, new_nick, &prefix, &prefix_color,
&ptr_group);
snprintf (str_prefix_color, sizeof (str_prefix_color),
- "color_nicklist_prefix%d",
+ "nicklist_prefix%d",
prefix_color);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
new_nick->name, new_nick->color,
@@ -263,7 +263,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
irc_nick_get_gui_infos (channel->buffer, nick, &prefix, &prefix_color,
&ptr_group);
snprintf (str_prefix_color, sizeof (str_prefix_color),
- "color_nicklist_prefix%d",
+ "nicklist_prefix%d",
prefix_color);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
nick->name, nick->color,
@@ -280,8 +280,8 @@ irc_nick_set (struct t_irc_channel *channel,
{
char prefix, str_prefix_color[64];
int prefix_color;
-
struct t_gui_nick_group *ptr_group;
+
/* remove nick from nicklist */
irc_nick_get_gui_infos (channel->buffer, nick, &prefix,
&prefix_color, &ptr_group);
@@ -297,7 +297,7 @@ irc_nick_set (struct t_irc_channel *channel,
irc_nick_get_gui_infos (channel->buffer, nick, &prefix,
&prefix_color, &ptr_group);
snprintf (str_prefix_color, sizeof (str_prefix_color),
- "color_nicklist_prefix%d",
+ "nicklist_prefix%d",
prefix_color);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
nick->name, nick->color,
@@ -481,20 +481,20 @@ irc_nick_as_prefix (struct t_irc_nick *nick, char *nickname, char *force_color)
static char result[256];
snprintf (result, sizeof (result), "%s%s%s%s%s%s\t",
- (weechat_config_string (irc_config_irc_nick_prefix)
- && weechat_config_string (irc_config_irc_nick_prefix)[0]) ?
+ (weechat_config_string (irc_config_look_nick_prefix)
+ && weechat_config_string (irc_config_look_nick_prefix)[0]) ?
IRC_COLOR_CHAT_DELIMITERS : "",
- (weechat_config_string (irc_config_irc_nick_prefix)
- && weechat_config_string (irc_config_irc_nick_prefix)[0]) ?
- weechat_config_string (irc_config_irc_nick_prefix) : "",
+ (weechat_config_string (irc_config_look_nick_prefix)
+ && weechat_config_string (irc_config_look_nick_prefix)[0]) ?
+ weechat_config_string (irc_config_look_nick_prefix) : "",
(force_color) ? force_color : ((nick) ? nick->color : IRC_COLOR_CHAT_NICK),
(nick) ? nick->name : nickname,
- (weechat_config_string (irc_config_irc_nick_suffix)
- && weechat_config_string (irc_config_irc_nick_suffix)[0]) ?
+ (weechat_config_string (irc_config_look_nick_suffix)
+ && weechat_config_string (irc_config_look_nick_suffix)[0]) ?
IRC_COLOR_CHAT_DELIMITERS : "",
- (weechat_config_string (irc_config_irc_nick_suffix)
- && weechat_config_string (irc_config_irc_nick_suffix)[0]) ?
- weechat_config_string (irc_config_irc_nick_suffix) : "");
+ (weechat_config_string (irc_config_look_nick_suffix)
+ && weechat_config_string (irc_config_look_nick_suffix)[0]) ?
+ weechat_config_string (irc_config_look_nick_suffix) : "");
return result;
}
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index fc8480666..85b21f7c1 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -269,14 +269,14 @@ irc_protocol_is_highlight (char *message, char *nick)
}
/* no highlight by nickname and "irc_highlight" is empty */
- if (!weechat_config_string (irc_config_irc_highlight)
- || !weechat_config_string (irc_config_irc_highlight)[0])
+ if (!weechat_config_string (irc_config_look_highlight)
+ || !weechat_config_string (irc_config_look_highlight)[0])
return 0;
/* convert both strings to lower case */
if ((msg = strdup (message)) == NULL)
return 0;
- highlight = strdup (weechat_config_string (irc_config_irc_highlight));
+ highlight = strdup (weechat_config_string (irc_config_look_highlight));
if (!highlight)
{
free (msg);
@@ -955,7 +955,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *command,
}
else
{
- if (nick && weechat_config_boolean (irc_config_irc_notice_as_pv))
+ if (nick && weechat_config_boolean (irc_config_look_notice_as_pv))
{
ptr_channel = irc_channel_search (server, nick);
if (!ptr_channel)
@@ -1251,7 +1251,7 @@ irc_protocol_cmd_pong (struct t_irc_server *server, char *command,
server->lag_check_time.tv_sec = 0;
server->lag_check_time.tv_usec = 0;
server->lag_next_check = time (NULL) +
- weechat_config_integer (irc_config_irc_lag_check);
+ weechat_config_integer (irc_config_network_lag_check);
}
return WEECHAT_RC_OK;
@@ -1380,7 +1380,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command,
if ((look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != weechat_current_buffer))
weechat_infobar_printf (look_infobar_delay_highlight,
- "color_infobar_highlight",
+ "infobar_highlight",
_("Channel %s: * %s %s"),
ptr_channel->name,
nick,
@@ -1546,7 +1546,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command,
if ((look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != weechat_current_buffer))
weechat_infobar_printf (look_infobar_delay_highlight,
- "color_infobar_highlight",
+ "infobar_highlight",
_("Channel %s: %s> %s"),
ptr_channel->name,
nick,
@@ -2184,7 +2184,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command,
if ((look_infobar_delay_highlight > 0)
&& (ptr_channel->buffer != weechat_current_buffer))
weechat_infobar_printf (look_infobar_delay_highlight,
- "color_infobar_highlight",
+ "infobar_highlight",
_("Private %s> %s"),
nick, pos_args);
highlight_displayed = 1;
@@ -2517,7 +2517,7 @@ irc_protocol_cmd_001 (struct t_irc_server *server, char *command,
/* connection to IRC server is ok! */
server->is_connected = 1;
server->lag_next_check = time (NULL) +
- weechat_config_integer (irc_config_irc_lag_check);
+ weechat_config_integer (irc_config_network_lag_check);
/* set away message if user was away (before disconnection for example) */
if (server->away_message && server->away_message[0])
@@ -2670,7 +2670,7 @@ irc_protocol_cmd_301 (struct t_irc_server *server, char *command,
/* look for private buffer to display message */
ptr_channel = irc_channel_search (server, argv[3]);
- if (!weechat_config_boolean (irc_config_irc_show_away_once)
+ if (!weechat_config_boolean (irc_config_look_show_away_once)
|| !ptr_channel
|| !(ptr_channel->away_message)
|| (strcmp (ptr_channel->away_message, pos_away_msg) != 0))
@@ -4284,9 +4284,9 @@ irc_protocol_cmd_433 (struct t_irc_server *server, char *command,
}
weechat_printf (server->buffer,
- _("%s%s: nickname \"%s\" is already in use, "
+ _("%s: nickname \"%s\" is already in use, "
"trying nickname #%d (\"%s\")"),
- weechat_prefix ("info"), "irc", server->nick,
+ "irc", server->nick,
nick_to_use + 1, server->nicks_array[nick_to_use]);
irc_server_set_nick (server, server->nicks_array[nick_to_use]);
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index f7df652b0..13dbf5a7b 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -71,30 +71,222 @@ const int gnutls_cert_type_prio[] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
/*
+ * irc_server_set_addresses: set addresses for server
+ */
+
+void
+irc_server_set_addresses (struct t_irc_server *server, char *addresses)
+{
+ int i;
+ char *pos, *error;
+ long number;
+
+ /* free data */
+ if (server->addresses)
+ {
+ free (server->addresses);
+ server->addresses = NULL;
+ }
+ server->addresses_count = 0;
+ if (server->addresses_array)
+ {
+ weechat_string_free_exploded (server->addresses_array);
+ server->addresses_array = NULL;
+ }
+ if (server->ports_array)
+ {
+ free (server->ports_array);
+ server->ports_array = NULL;
+ }
+
+ /* set new address */
+ server->addresses = strdup (addresses);
+ if (server->addresses)
+ {
+ server->addresses_array = weechat_string_explode (server->addresses,
+ ",", 0, 0,
+ &server->addresses_count);
+ server->ports_array = malloc (server->addresses_count * sizeof (server->ports_array[0]));
+ for (i = 0; i < server->addresses_count; i++)
+ {
+ pos = strchr (server->addresses_array[i], '/');
+ if (pos)
+ {
+ pos[0] = 0;
+ pos++;
+ error = NULL;
+ number = strtol (pos, &error, 10);
+ server->ports_array[i] = (error && !error[0]) ?
+ number : IRC_SERVER_DEFAULT_PORT;
+ }
+ else
+ {
+ server->ports_array[i] = IRC_SERVER_DEFAULT_PORT;
+ }
+ }
+ }
+}
+
+/*
+ * irc_server_set_nicks: set nicks for server
+ */
+
+void
+irc_server_set_nicks (struct t_irc_server *server, char *nicks)
+{
+ /* free data */
+ if (server->nicks)
+ {
+ free (server->nicks);
+ server->nicks = NULL;
+ }
+ server->nicks_count = 0;
+ if (server->nicks_array)
+ {
+ weechat_string_free_exploded (server->nicks_array);
+ server->nicks_array = NULL;
+ }
+
+ /* set new nicks */
+ server->nicks = strdup ((nicks) ? nicks : IRC_SERVER_DEFAULT_NICKS);
+ if (server->nicks)
+ {
+ server->nicks_array = weechat_string_explode (server->nicks,
+ ",", 0, 0,
+ &server->nicks_count);
+ }
+}
+
+/*
+ * irc_server_set_with_option: set a server option with a config option
+ */
+
+void
+irc_server_set_with_option (struct t_irc_server *server,
+ int index_option,
+ struct t_config_option *option)
+{
+ if (!server || !option)
+ return;
+
+ switch (index_option)
+ {
+ case IRC_CONFIG_SERVER_AUTOCONNECT:
+ server->autoconnect = weechat_config_integer (option);
+ break;
+ case IRC_CONFIG_SERVER_AUTORECONNECT:
+ server->autoreconnect = weechat_config_integer (option);
+ break;
+ case IRC_CONFIG_SERVER_AUTORECONNECT_DELAY:
+ server->autoreconnect_delay = weechat_config_integer (option);
+ break;
+ case IRC_CONFIG_SERVER_ADDRESSES:
+ irc_server_set_addresses (server, weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_IPV6:
+ server->ipv6 = weechat_config_integer (option);
+ break;
+ case IRC_CONFIG_SERVER_SSL:
+ server->ssl = weechat_config_integer (option);
+ break;
+ case IRC_CONFIG_SERVER_PASSWORD:
+ if (server->password)
+ free (server->password);
+ server->password = strdup (weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_NICKS:
+ irc_server_set_nicks (server, weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_USERNAME:
+ if (server->username)
+ free (server->username);
+ server->username = strdup (weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_REALNAME:
+ if (server->realname)
+ free (server->realname);
+ server->realname = strdup (weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_HOSTNAME:
+ if (server->hostname)
+ free (server->hostname);
+ server->hostname = strdup (weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_COMMAND:
+ if (server->command)
+ free (server->command);
+ server->command = strdup (weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_COMMAND_DELAY:
+ server->command_delay = weechat_config_integer (option);
+ break;
+ case IRC_CONFIG_SERVER_AUTOJOIN:
+ if (server->autojoin)
+ free (server->autojoin);
+ server->autojoin = strdup (weechat_config_string (option));
+ break;
+ case IRC_CONFIG_SERVER_AUTOREJOIN:
+ server->autorejoin = weechat_config_integer (option);
+ break;
+ case IRC_CONFIG_SERVER_NOTIFY_LEVELS:
+ if (server->notify_levels)
+ free (server->notify_levels);
+ server->notify_levels = strdup (weechat_config_string (option));
+ break;
+ case IRC_CONFIG_NUM_SERVER_OPTIONS:
+ break;
+ }
+}
+
+/*
+ * irc_server_set_nick: set nickname for a server
+ */
+
+void
+irc_server_set_nick (struct t_irc_server *server, char *nick)
+{
+ struct t_irc_channel *ptr_channel;
+
+ if (server->nick)
+ free (server->nick);
+ server->nick = (nick) ? strdup (nick) : NULL;
+
+ weechat_buffer_set (server->buffer, "nick", nick);
+
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ weechat_buffer_set (ptr_channel->buffer, "nick", nick);
+ }
+}
+
+/*
* irc_server_init: init server struct with default values
*/
void
irc_server_init (struct t_irc_server *server)
{
+ int i;
+
/* user choices */
server->name = NULL;
- server->autoconnect = 0;
- server->autoreconnect = 1;
- server->autoreconnect_delay = 30;
+ server->autoconnect = IRC_CONFIG_SERVER_DEFAULT_AUTOCONNECT;
+ server->autoreconnect = IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT;
+ server->autoreconnect_delay = IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT_DELAY;
server->temp_server = 0;
server->addresses = NULL;
- server->ipv6 = 0;
- server->ssl = 0;
+ server->ipv6 = IRC_CONFIG_SERVER_DEFAULT_IPV6;
+ server->ssl = IRC_CONFIG_SERVER_DEFAULT_SSL;
server->password = NULL;
server->nicks = NULL;
server->username = NULL;
server->realname = NULL;
server->hostname = NULL;
server->command = NULL;
- server->command_delay = 1;
+ server->command_delay = IRC_CONFIG_SERVER_DEFAULT_COMMAND_DELAY;
server->autojoin = NULL;
- server->autorejoin = 0;
+ server->autorejoin = IRC_CONFIG_SERVER_DEFAULT_AUTOREJOIN;
server->notify_levels = NULL;
/* internal vars */
@@ -127,7 +319,7 @@ irc_server_init (struct t_irc_server *server)
server->lag_check_time.tv_sec = 0;
server->lag_check_time.tv_usec = 0;
server->lag_next_check = time (NULL) +
- weechat_config_integer (irc_config_irc_lag_check);
+ weechat_config_integer (irc_config_network_lag_check);
server->cmd_list_regexp = NULL;
server->queue_msg = 0;
server->last_user_message = 0;
@@ -136,6 +328,50 @@ irc_server_init (struct t_irc_server *server)
server->buffer = NULL;
server->channels = NULL;
server->last_channel = NULL;
+
+ /* init with default values from config */
+ for (i = 0; i < IRC_CONFIG_NUM_SERVER_OPTIONS; i++)
+ {
+ irc_server_set_with_option (server, i,
+ irc_config_server_default[i]);
+ }
+}
+
+/*
+ * irc_server_alloc: allocate a new server and add it to the servers queue
+ */
+
+struct t_irc_server *
+irc_server_alloc (char *name)
+{
+ struct t_irc_server *new_server;
+
+ /* alloc memory for new server */
+ if ((new_server = malloc (sizeof (*new_server))) == NULL)
+ {
+ weechat_printf (NULL,
+ _("%s%s: error when allocating new server"),
+ weechat_prefix ("error"), "irc");
+ return NULL;
+ }
+
+ /* initialize new server */
+ irc_server_init (new_server);
+
+ /* set name */
+ new_server->name = strdup (name);
+
+ /* add new server to queue */
+ new_server->prev_server = last_irc_server;
+ new_server->next_server = NULL;
+ if (irc_servers)
+ last_irc_server->next_server = new_server;
+ else
+ irc_servers = new_server;
+ last_irc_server = new_server;
+
+ /* all is ok, return address of new server */
+ return new_server;
}
/*
@@ -265,119 +501,10 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
*/
/*
- * irc_server_set_addresses: set addresses for server
- */
-
-void
-irc_server_set_addresses (struct t_irc_server *server, char *addresses)
-{
- int i;
- char *pos, *error;
- long number;
-
- /* free data */
- if (server->addresses)
- {
- free (server->addresses);
- server->addresses = NULL;
- }
- server->addresses_count = 0;
- if (server->addresses_array)
- {
- weechat_string_free_exploded (server->addresses_array);
- server->addresses_array = NULL;
- }
- if (server->ports_array)
- {
- free (server->ports_array);
- server->ports_array = NULL;
- }
-
- /* set new address */
- server->addresses = strdup (addresses);
- if (server->addresses)
- {
- server->addresses_array = weechat_string_explode (server->addresses,
- ",", 0, 0,
- &server->addresses_count);
- server->ports_array = malloc (server->addresses_count * sizeof (server->ports_array[0]));
- for (i = 0; i < server->addresses_count; i++)
- {
- pos = strchr (server->addresses_array[i], '/');
- if (pos)
- {
- pos[0] = 0;
- pos++;
- error = NULL;
- number = strtol (pos, &error, 10);
- server->ports_array[i] = (error && !error[0]) ?
- number : IRC_SERVER_DEFAULT_PORT;
- }
- else
- {
- server->ports_array[i] = IRC_SERVER_DEFAULT_PORT;
- }
- }
- }
-}
-
-/*
- * irc_server_set_nicks: set nicks for server
- */
-
-void
-irc_server_set_nicks (struct t_irc_server *server, char *nicks)
-{
- /* free data */
- if (server->nicks)
- {
- free (server->nicks);
- server->nicks = NULL;
- }
- server->nicks_count = 0;
- if (server->nicks_array)
- {
- weechat_string_free_exploded (server->nicks_array);
- server->nicks_array = NULL;
- }
-
- /* set new nicks */
- server->nicks = strdup ((nicks) ? nicks : IRC_SERVER_DEFAULT_NICKS);
- if (server->nicks)
- {
- server->nicks_array = weechat_string_explode (server->nicks,
- ",", 0, 0,
- &server->nicks_count);
- }
-}
-
-/*
- * irc_server_set_nick: set nickname for a server
- */
-
-void
-irc_server_set_nick (struct t_irc_server *server, char *nick)
-{
- struct t_irc_channel *ptr_channel;
-
- if (server->nick)
- free (server->nick);
- server->nick = (nick) ? strdup (nick) : NULL;
-
- weechat_buffer_set (server->buffer, "nick", nick);
-
- for (ptr_channel = server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
- {
- weechat_buffer_set (ptr_channel->buffer, "nick", nick);
- }
-}
-
-/*
* irc_server_init_with_config_options: init a server with config options
* (called when reading config file)
*/
-
+/*
void
irc_server_init_with_config_options (struct t_irc_server *server,
struct t_config_section *section,
@@ -386,7 +513,8 @@ irc_server_init_with_config_options (struct t_irc_server *server,
struct t_config_option *ptr_option;
struct t_irc_server *ptr_server;
- ptr_option = weechat_config_search_option (NULL, section, "server_name");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_NAME);
if (!ptr_option)
{
irc_server_free (server);
@@ -411,27 +539,30 @@ irc_server_init_with_config_options (struct t_irc_server *server,
else
ptr_server = server;
- /* server internal name */
+ // server internal name
if (ptr_server->name)
free (ptr_server->name);
ptr_server->name = strdup (weechat_config_string (ptr_option));
- /* auto-connect */
- ptr_option = weechat_config_search_option (NULL, section, "server_autoconnect");
+ // auto-connect
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_AUTOCONNECT);
if (ptr_option)
ptr_server->autoconnect = weechat_config_integer (ptr_option);
- /* auto-reconnect */
- ptr_option = weechat_config_search_option (NULL, section, "server_autoreconnect");
+ // auto-reconnect
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_AUTORECONNECT);
if (ptr_option)
ptr_server->autoreconnect = weechat_config_integer (ptr_option);
- /* auto-reconnect delay */
- ptr_option = weechat_config_search_option (NULL, section, "server_autoreconnect_delay");
+ // auto-reconnect delay
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_AUTORECONNECT_DELAY);
if (ptr_option)
ptr_server->autoreconnect_delay = weechat_config_integer (ptr_option);
- /* addresses */
+ // addresses
if (ptr_server->addresses)
{
free (ptr_server->addresses);
@@ -448,31 +579,35 @@ irc_server_init_with_config_options (struct t_irc_server *server,
free (ptr_server->ports_array);
ptr_server->ports_array = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_addresses");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_ADDRESSES);
if (ptr_option)
irc_server_set_addresses (ptr_server, weechat_config_string (ptr_option));
- /* ipv6 */
- ptr_option = weechat_config_search_option (NULL, section, "server_ipv6");
+ // ipv6
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_IPV6);
if (ptr_option)
ptr_server->ipv6 = weechat_config_integer (ptr_option);
- /* SSL */
- ptr_option = weechat_config_search_option (NULL, section, "server_ssl");
+ // SSL
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_SSL);
if (ptr_option)
ptr_server->ssl = weechat_config_integer (ptr_option);
- /* password */
+ // password
if (ptr_server->password)
{
free (ptr_server->password);
ptr_server->password = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_password");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_PASSWORD);
if (ptr_option)
ptr_server->password = strdup (weechat_config_string (ptr_option));
- /* nicks */
+ // nicks
if (ptr_server->nicks)
{
free (ptr_server->nicks);
@@ -484,116 +619,92 @@ irc_server_init_with_config_options (struct t_irc_server *server,
weechat_string_free_exploded (ptr_server->nicks_array);
ptr_server->nicks_array = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_nicks");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_NICKS);
if (ptr_option)
irc_server_set_nicks (ptr_server, weechat_config_string (ptr_option));
- /* username */
+ // username
if (ptr_server->username)
{
free (ptr_server->username);
ptr_server->username = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_username");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_USERNAME);
if (ptr_option)
ptr_server->username = strdup (weechat_config_string (ptr_option));
- /* realname */
+ // realname
if (ptr_server->realname)
{
free (ptr_server->realname);
ptr_server->realname = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_realname");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_REALNAME);
if (ptr_option)
ptr_server->realname = strdup (weechat_config_string (ptr_option));
- /* hostname */
+ // hostname
if (ptr_server->hostname)
{
free (ptr_server->hostname);
ptr_server->hostname = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_hostname");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_HOSTNAME);
if (ptr_option)
ptr_server->hostname = strdup (weechat_config_string (ptr_option));
- /* command */
+ // command
if (ptr_server->command)
{
free (ptr_server->command);
ptr_server->command = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_command");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_COMMAND);
if (ptr_option)
ptr_server->command = strdup (weechat_config_string (ptr_option));
- /* command delay */
- ptr_option = weechat_config_search_option (NULL, section, "server_command_delay");
+ // command delay
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_COMMAND_DELAY);
if (ptr_option)
ptr_server->command_delay = weechat_config_integer (ptr_option);
- /* auto-join */
+ // auto-join
if (ptr_server->autojoin)
{
free (ptr_server->autojoin);
ptr_server->autojoin = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_autojoin");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_AUTOJOIN);
if (ptr_option)
ptr_server->autojoin = strdup (weechat_config_string (ptr_option));
- /* auto-rejoin */
- ptr_option = weechat_config_search_option (NULL, section, "server_autorejoin");
+ // auto-rejoin
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_AUTOREJOIN);
if (ptr_option)
ptr_server->autorejoin = weechat_config_integer (ptr_option);
- /* notify_levels */
+ // notify_levels
if (ptr_server->notify_levels)
{
free (ptr_server->notify_levels);
ptr_server->notify_levels = NULL;
}
- ptr_option = weechat_config_search_option (NULL, section, "server_notify_levels");
+ ptr_option = weechat_config_search_option (NULL, section,
+ IRC_CONFIG_SERVER_NOTIFY_LEVELS);
if (ptr_option)
ptr_server->notify_levels = strdup (weechat_config_string (ptr_option));
ptr_server->reloaded_from_config = 1;
}
-
-/*
- * irc_server_alloc: allocate a new server and add it to the servers queue
- */
-
-struct t_irc_server *
-irc_server_alloc ()
-{
- struct t_irc_server *new_server;
-
- /* alloc memory for new server */
- if ((new_server = malloc (sizeof (*new_server))) == NULL)
- {
- weechat_printf (NULL,
- _("%s%s: error when allocating new server"),
- weechat_prefix ("error"), "irc");
- return NULL;
- }
-
- /* initialize new server */
- irc_server_init (new_server);
-
- /* add new server to queue */
- new_server->prev_server = last_irc_server;
- new_server->next_server = NULL;
- if (irc_servers)
- last_irc_server->next_server = new_server;
- else
- irc_servers = new_server;
- last_irc_server = new_server;
-
- /* all is ok, return address of new server */
- return new_server;
-}
+*/
/*
* irc_server_outqueue_add: add a message in out queue
@@ -797,10 +908,10 @@ irc_server_new (char *name, int autoconnect, int autoreconnect,
(autorejoin) ? "on" : "off",
(notify_levels) ? notify_levels : "");
}
-
- if ((new_server = irc_server_alloc ()))
+
+ new_server = irc_server_alloc (name);
+ if (new_server)
{
- new_server->name = strdup (name);
new_server->autoconnect = autoconnect;
new_server->autoreconnect = autoreconnect;
new_server->autoreconnect_delay = autoreconnect_delay;
@@ -828,6 +939,7 @@ irc_server_new (char *name, int autoconnect, int autoreconnect,
}
else
return NULL;
+
return new_server;
}
@@ -876,22 +988,46 @@ irc_server_duplicate (struct t_irc_server *server, char *new_name)
int
irc_server_rename (struct t_irc_server *server, char *new_name)
{
- char *str;
+ int length;
+ char *option_name, *name, *pos_option;
+ struct t_plugin_infolist *infolist;
/* check if another server exists with this name */
if (irc_server_search (new_name))
return 0;
- /* rename server */
- str = strdup (new_name);
- if (str)
- {
- if (server->name)
- free (server->name);
- server->name = str;
- return 1;
+ /* rename options */
+ length = 32 + strlen (server->name) + 1;
+ option_name = malloc (length);
+ if (!option_name)
+ return 0;
+ snprintf (option_name, length, "irc.server.%s.*", server->name);
+ infolist = weechat_infolist_get ("options", option_name);
+ free (option_name);
+ while (weechat_infolist_next (infolist))
+ {
+ name = weechat_infolist_string (infolist, "name");
+ pos_option = strchr (name, '.');
+ if (pos_option)
+ {
+ pos_option++;
+ length = strlen (new_name) + 1 + strlen (pos_option) + 1;
+ option_name = malloc (length);
+ if (option_name)
+ {
+ snprintf (option_name, length, "%s.%s", new_name, pos_option);
+ /* TODO: complete this function */
+ free (option_name);
+ }
+ }
}
- return 0;
+ weechat_infolist_free (infolist);
+
+ /* rename server */
+ if (server->name)
+ free (server->name);
+ server->name = strdup (new_name);
+ return 1;
}
/*
@@ -955,7 +1091,7 @@ irc_server_outqueue_send (struct t_irc_server *server)
{
time_now = time (NULL);
if (time_now >= server->last_user_message +
- weechat_config_integer (irc_config_irc_anti_flood))
+ weechat_config_integer (irc_config_network_anti_flood))
{
if (server->outqueue->message_before_mod)
{
@@ -1158,7 +1294,7 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message)
server->name,
ptr_chan_nick);
}
- msg_encoded = weechat_hook_modifier_exec ("charset_decode",
+ msg_encoded = weechat_hook_modifier_exec ("charset_encode",
modifier_data,
ptr_msg);
@@ -1178,9 +1314,9 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message)
queue = 0;
if ((server->queue_msg)
&& ((server->outqueue)
- || ((weechat_config_integer (irc_config_irc_anti_flood) > 0)
+ || ((weechat_config_integer (irc_config_network_anti_flood) > 0)
&& (time_now - server->last_user_message <
- weechat_config_integer (irc_config_irc_anti_flood)))))
+ weechat_config_integer (irc_config_network_anti_flood)))))
queue = 1;
/* if queue, then only queue message and send nothing now */
@@ -1638,18 +1774,18 @@ irc_server_timer_cb (void *data)
/* lag timeout => disconnect */
if ((ptr_server->lag_check_time.tv_sec != 0)
- && (weechat_config_integer (irc_config_irc_lag_disconnect) > 0))
+ && (weechat_config_integer (irc_config_network_lag_disconnect) > 0))
{
gettimeofday (&tv, NULL);
diff = (int) weechat_timeval_diff (&(ptr_server->lag_check_time),
&tv);
- if (diff / 1000 > weechat_config_integer (irc_config_irc_lag_disconnect) * 60)
+ if (diff / 1000 > weechat_config_integer (irc_config_network_lag_disconnect) * 60)
{
weechat_printf (ptr_server->buffer,
- _("%s%s: lag is high, "
+ _("%s: lag is high, "
"disconnecting from "
"server..."),
- weechat_prefix ("info"), "irc");
+ "irc");
irc_server_disconnect (ptr_server, 1);
}
}
@@ -1670,7 +1806,7 @@ irc_server_timer_check_away (void *empty)
{
(void) empty;
- if (weechat_config_integer (irc_config_irc_away_check) > 0)
+ if (weechat_config_integer (irc_config_network_away_check) > 0)
irc_server_check_away ();
}
@@ -1757,8 +1893,8 @@ irc_server_reconnect_schedule (struct t_irc_server *server)
{
server->reconnect_start = time (NULL);
weechat_printf (server->buffer,
- _("%s%s: reconnecting to server in %d %s"),
- weechat_prefix ("info"), "irc",
+ _("%s: reconnecting to server in %d %s"),
+ "irc",
server->autoreconnect_delay,
NG_("second", "seconds",
server->autoreconnect_delay));
@@ -1778,16 +1914,21 @@ irc_server_login (struct t_irc_server *server)
irc_server_sendf (server, "PASS %s", server->password);
if (!server->nick)
- irc_server_set_nick (server, server->nicks_array[0]);
+ irc_server_set_nick (server,
+ (server->nicks_array) ?
+ server->nicks_array[0] : "weechat");
irc_server_sendf (server,
"NICK %s\n"
"USER %s %s %s :%s",
server->nick,
- server->username,
- server->username,
+ (server->username && server->username[0]) ?
+ server->username : "weechat",
+ (server->username && server->username[0]) ?
+ server->username : "weechat",
server->addresses_array[server->current_address],
- server->realname);
+ (server->realname && server->realname[0]) ?
+ server->realname : "weechat");
}
/*
@@ -1803,8 +1944,8 @@ irc_server_switch_address (struct t_irc_server *server)
{
server->current_address++;
weechat_printf (server->buffer,
- _("%s%s: switching address to %s/%d"),
- weechat_prefix ("info"), "irc",
+ _("%s: switching address to %s/%d"),
+ "irc",
server->addresses_array[server->current_address],
server->ports_array[server->current_address]);
irc_server_connect (server, 0);
@@ -2233,7 +2374,7 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
/* buffer[3] = address type */
switch (buffer[3])
{
- case 1 :
+ case 1:
/* ipv4
* server socks return server bound address and port
* address of 4 bytes and port of 2 bytes (= 6 bytes)
@@ -2253,7 +2394,7 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
if (recv (sock, buffer, addr_len + 2, 0) != (addr_len + 2))
return 1;
break;
- case 4 :
+ case 4:
/* ipv6
* server socks return server bound address and port
* address of 16 bytes and port of 2 bytes (= 18 bytes)
@@ -2462,6 +2603,26 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
char *config_proxy_type, *config_proxy_address;
int config_proxy_use, config_proxy_ipv6, config_proxy_port;
+ if (!server->addresses || !server->addresses[0])
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: addresses not defined for server \"%s\", "
+ "cannot connect"),
+ weechat_prefix ("error"), "irc",
+ server->name);
+ return 0;
+ }
+
+ if (!server->nicks || !server->nicks[0])
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: nicks not defined for server \"%s\", "
+ "cannot connect"),
+ weechat_prefix ("error"), "irc",
+ server->name);
+ return 0;
+ }
+
config_proxy_use = weechat_config_boolean (
weechat_config_get_weechat ("proxy_use"));
config_proxy_ipv6 = weechat_config_boolean (
@@ -2498,9 +2659,9 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (config_proxy_use)
{
weechat_printf (server->buffer,
- _("%s%s: connecting to server %s/%d%s%s via %s "
+ _("%s: connecting to server %s/%d%s%s via %s "
"proxy %s/%d%s..."),
- weechat_prefix ("info"), "irc",
+ "irc",
server->addresses_array[server->current_address],
server->ports_array[server->current_address],
(server->ipv6) ? " (IPv6)" : "",
@@ -2521,8 +2682,8 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
else
{
weechat_printf (server->buffer,
- _("%s%s: connecting to server %s/%d%s%s..."),
- weechat_prefix ("info"), "irc",
+ _("%s: connecting to server %s/%d%s%s..."),
+ "irc",
server->addresses_array[server->current_address],
server->ports_array[server->current_address],
(server->ipv6) ? " (IPv6)" : "",
@@ -2648,8 +2809,8 @@ void
irc_server_reconnect (struct t_irc_server *server)
{
weechat_printf (server->buffer,
- _("%s%s: reconnecting to server..."),
- weechat_prefix ("info"), "irc");
+ _("%s: reconnecting to server..."),
+ "irc");
server->reconnect_start = 0;
server->current_address = 0;
@@ -2696,8 +2857,8 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect)
ptr_channel = ptr_channel->next_channel)
{
weechat_printf (ptr_channel->buffer,
- _("%s%s: disconnected from server"),
- weechat_prefix ("info"), "irc");
+ _("%s: disconnected from server"),
+ "irc");
}
}
@@ -2705,8 +2866,8 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect)
if (server->buffer)
weechat_printf (server->buffer,
- _("%s%s: disconnected from server"),
- weechat_prefix ("info"), "irc");
+ _("%s: disconnected from server"),
+ "irc");
server->current_address = 0;
if (server->nick_modes)
@@ -2725,7 +2886,7 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect)
server->lag_check_time.tv_sec = 0;
server->lag_check_time.tv_usec = 0;
server->lag_next_check = time (NULL) +
- weechat_config_integer (irc_config_irc_lag_check);
+ weechat_config_integer (irc_config_network_lag_check);
if ((reconnect) && (server->autoreconnect))
irc_server_reconnect_schedule (server);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 7febdbc8d..cf18813ab 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -138,11 +138,19 @@ extern const int gnutls_prot_prio[];
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
+extern void irc_server_set_addresses (struct t_irc_server *server,
+ char *addresses);
+extern void irc_server_set_nicks (struct t_irc_server *server, char *nicks);
+extern void irc_server_set_with_option (struct t_irc_server *server,
+ int index_option,
+ struct t_config_option *option);
extern void irc_server_init (struct t_irc_server *server);
-extern struct t_irc_server *irc_server_alloc ();
-extern void irc_server_init_with_config_options (struct t_irc_server *server,
+extern struct t_irc_server *irc_server_alloc (char *name);
+
+/*extern void irc_server_init_with_config_options (struct t_irc_server *server,
struct t_config_section *section,
int config_reload);
+*/
extern struct t_irc_server *irc_server_new (char *name, int autoconnect,
int autoreconnect,
int autoreconnect_delay,
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index d2df7d2ab..a41d5a503 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -43,7 +43,7 @@ WEECHAT_PLUGIN_DESCRIPTION("IRC (Internet Relay Chat) plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_irc_plugin = NULL;
@@ -99,7 +99,8 @@ irc_signal_quit_cb (void *data, char *signal, char *type_data,
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- irc_command_quit_server (ptr_server, (char *)signal_data);
+ irc_command_quit_server (ptr_server,
+ (signal_data) ? (char *)signal_data : NULL);
}
}
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index a46228a6b..f00c7922f 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -47,21 +47,21 @@
ptr_server, weechat_buffer_get_string (__buffer, "name")); \
}
-#define IRC_COLOR_CHAT weechat_color("color_chat")
-#define IRC_COLOR_CHAT_CHANNEL weechat_color("color_chat_channel")
-#define IRC_COLOR_CHAT_DELIMITERS weechat_color("color_chat_delimiters")
-#define IRC_COLOR_CHAT_HIGHLIGHT weechat_color("color_chat_highlight")
-#define IRC_COLOR_CHAT_HOST weechat_color("color_chat_host")
-#define IRC_COLOR_CHAT_NICK weechat_color("color_chat_nick")
-#define IRC_COLOR_CHAT_NICK_SELF weechat_color("color_chat_nick_self")
-#define IRC_COLOR_CHAT_NICK_OTHER weechat_color("color_chat_nick_other")
-#define IRC_COLOR_CHAT_SERVER weechat_color("color_chat_server")
-#define IRC_COLOR_INFOBAR_HIGHLIGHT weechat_color("color_infobar_highlight")
-#define IRC_COLOR_NICKLIST_PREFIX1 weechat_color("color_nicklist_prefix1")
-#define IRC_COLOR_NICKLIST_PREFIX2 weechat_color("color_nicklist_prefix2")
-#define IRC_COLOR_NICKLIST_PREFIX3 weechat_color("color_nicklist_prefix3")
-#define IRC_COLOR_NICKLIST_PREFIX4 weechat_color("color_nicklist_prefix4")
-#define IRC_COLOR_NICKLIST_PREFIX5 weechat_color("color_nicklist_prefix5")
+#define IRC_COLOR_CHAT weechat_color("chat")
+#define IRC_COLOR_CHAT_CHANNEL weechat_color("chat_channel")
+#define IRC_COLOR_CHAT_DELIMITERS weechat_color("chat_delimiters")
+#define IRC_COLOR_CHAT_HIGHLIGHT weechat_color("chat_highlight")
+#define IRC_COLOR_CHAT_HOST weechat_color("chat_host")
+#define IRC_COLOR_CHAT_NICK weechat_color("chat_nick")
+#define IRC_COLOR_CHAT_NICK_SELF weechat_color("chat_nick_self")
+#define IRC_COLOR_CHAT_NICK_OTHER weechat_color("chat_nick_other")
+#define IRC_COLOR_CHAT_SERVER weechat_color("chat_server")
+#define IRC_COLOR_INFOBAR_HIGHLIGHT weechat_color("infobar_highlight")
+#define IRC_COLOR_NICKLIST_PREFIX1 weechat_color("nicklist_prefix1")
+#define IRC_COLOR_NICKLIST_PREFIX2 weechat_color("nicklist_prefix2")
+#define IRC_COLOR_NICKLIST_PREFIX3 weechat_color("nicklist_prefix3")
+#define IRC_COLOR_NICKLIST_PREFIX4 weechat_color("nicklist_prefix4")
+#define IRC_COLOR_NICKLIST_PREFIX5 weechat_color("nicklist_prefix5")
extern struct t_weechat_plugin *weechat_irc_plugin;
extern struct t_hook *irc_hook_timer_check_away;
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index c82eb9436..85b05f8c1 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -44,7 +44,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Logger plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_logger_plugin = NULL;
@@ -642,11 +642,10 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
*/
int
-logger_config_cb (void *data, char *type, char *option, char *value)
+logger_config_cb (void *data, char *option, char *value)
{
/* make C compiler happy */
(void) data;
- (void) type;
(void) option;
(void) value;
@@ -679,16 +678,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_print (NULL, NULL, NULL, 1, &logger_print_cb, NULL);
- weechat_hook_config ("plugin", "logger." LOGGER_OPTION_PATH,
- &logger_config_cb, NULL);
- weechat_hook_config ("plugin", "logger." LOGGER_OPTION_NAME_LOWER_CASE,
- &logger_config_cb, NULL);
- weechat_hook_config ("plugin", "logger." LOGGER_OPTION_TIME_FORMAT,
- &logger_config_cb, NULL);
- weechat_hook_config ("plugin", "logger." LOGGER_OPTION_INFO_LINES,
- &logger_config_cb, NULL);
- weechat_hook_config ("plugin", "logger." LOGGER_OPTION_BACKLOG,
- &logger_config_cb, NULL);
+ weechat_hook_config ("plugins.var.logger.*", &logger_config_cb, NULL);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 8b5ebb195..2e942006b 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -198,8 +198,6 @@ plugin_api_prefix (char *prefix)
if (!prefix)
return gui_chat_prefix_empty;
- if (string_strcasecmp (prefix, "info") == 0)
- return gui_chat_prefix[GUI_CHAT_PREFIX_INFO];
if (string_strcasecmp (prefix, "error") == 0)
return gui_chat_prefix[GUI_CHAT_PREFIX_ERROR];
if (string_strcasecmp (prefix, "network") == 0)
@@ -504,6 +502,77 @@ plugin_api_infolist_get_add_buffer_line (struct t_plugin_infolist *infolist,
}
/*
+ * plugin_api_infolist_get_add_options: add config options in a list
+ * return 1 if ok, 0 if error
+ */
+
+int
+plugin_api_infolist_get_add_options (struct t_plugin_infolist *infolist,
+ char *option_name)
+{
+ struct t_config_file *ptr_config;
+ struct t_config_section *ptr_section;
+ struct t_config_option *ptr_option;
+ struct t_plugin_infolist_item *ptr_item;
+ int length;
+ char *option_full_name;
+
+ if (!infolist)
+ return 0;
+
+ for (ptr_config = config_files; ptr_config;
+ ptr_config = ptr_config->next_config)
+ {
+ for (ptr_section = ptr_config->sections; ptr_section;
+ ptr_section = ptr_section->next_section)
+ {
+ for (ptr_option = ptr_section->options; ptr_option;
+ ptr_option = ptr_option->next_option)
+ {
+ length = strlen (ptr_config->name) + 1 +
+ strlen (ptr_section->name) + 1 +
+ strlen (ptr_option->name) + 1;
+ option_full_name = malloc (length);
+ if (option_full_name)
+ {
+ snprintf (option_full_name, length, "%s.%s.%s",
+ ptr_config->name,
+ ptr_section->name,
+ ptr_option->name);
+ if (!option_name || !option_name[0]
+ || string_match (option_full_name, option_name, 0))
+ {
+ ptr_item = plugin_infolist_new_item (infolist);
+ if (!ptr_item)
+ {
+ free (option_full_name);
+ return 0;
+ }
+ if (!plugin_infolist_new_var_string (ptr_item,
+ "full_name",
+ option_full_name))
+ {
+ free (option_full_name);
+ return 0;
+ }
+ if (!plugin_infolist_new_var_string (ptr_item,
+ "name",
+ ptr_option->name))
+ {
+ free (option_full_name);
+ return 0;
+ }
+ }
+ free (option_full_name);
+ }
+ }
+ }
+ }
+
+ return 1;
+}
+
+/*
* plugin_api_infolist_get: get list with infos about WeeChat structures
* WARNING: caller has to free string returned
* by this function after use, with weechat_infolist_free()
@@ -582,6 +651,19 @@ plugin_api_infolist_get (char *name, void *pointer)
return ptr_infolist;
}
}
+ else if (string_strcasecmp (name, "options") == 0)
+ {
+ ptr_infolist = plugin_infolist_new ();
+ if (ptr_infolist)
+ {
+ if (!plugin_api_infolist_get_add_options (ptr_infolist, pointer))
+ {
+ plugin_infolist_free (ptr_infolist);
+ return NULL;
+ }
+ return ptr_infolist;
+ }
+ }
/* list not found */
return NULL;
diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c
index 73a49d80c..1a6b41f1b 100644
--- a/src/plugins/plugin-config.c
+++ b/src/plugins/plugin-config.c
@@ -32,82 +32,43 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
#include "../core/wee-hook.h"
+#include "../core/wee-list.h"
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "plugin-config.h"
+#include "weechat-plugin.h"
-struct t_config_file *plugin_config = NULL;
-struct t_config_option *plugin_options = NULL;
-struct t_config_option *last_plugin_option = NULL;
+struct t_config_file *plugin_config_file = NULL;
+struct t_config_section *plugin_config_section_var = NULL;
/*
- * plugin_config_search_internal: search a plugin option (internal function)
- * This function should not be called directly.
- */
-
-struct t_config_option *
-plugin_config_search_internal (char *option_name)
-{
- struct t_config_option *ptr_option;
-
- for (ptr_option = plugin_options; ptr_option;
- ptr_option = ptr_option->next_option)
- {
- if (string_strcasecmp (ptr_option->name, option_name) == 0)
- {
- return ptr_option;
- }
- }
-
- /* plugin option not found */
- return NULL;
-}
-
-/*
* plugin_config_search: search a plugin option
*/
struct t_config_option *
plugin_config_search (char *plugin_name, char *option_name)
{
- char *internal_option;
+ int length;
+ char *option_full_name;
struct t_config_option *ptr_option;
- internal_option = malloc (strlen (plugin_name) + strlen (option_name) + 2);
- if (!internal_option)
- return NULL;
-
- strcpy (internal_option, plugin_name);
- strcat (internal_option, ".");
- strcat (internal_option, option_name);
-
- ptr_option = plugin_config_search_internal (internal_option);
-
- free (internal_option);
-
- return ptr_option;
-}
-
-/*
- * plugin_config_find_pos: find position for a plugin option (for sorting options)
- */
-
-struct t_config_option *
-plugin_config_find_pos (char *name)
-{
- struct t_config_option *ptr_option;
+ ptr_option = NULL;
- for (ptr_option = plugin_options; ptr_option;
- ptr_option = ptr_option->next_option)
+ length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
+ option_full_name = malloc (length);
+ if (option_full_name)
{
- if (string_strcasecmp (name, ptr_option->name) < 0)
- return ptr_option;
+ snprintf (option_full_name, length, "%s.%s",
+ plugin_name, option_name);
+ ptr_option = config_file_search_option (plugin_config_file,
+ plugin_config_section_var,
+ option_full_name);
+ free (option_full_name);
}
- /* position not found (we will add to the end of list) */
- return NULL;
+ return ptr_option;
}
/*
@@ -119,164 +80,55 @@ plugin_config_find_pos (char *name)
int
plugin_config_set_internal (char *option, char *value)
{
- struct t_config_option *ptr_option, *pos_option;
int rc;
-
+ struct t_config_option *ptr_option;
+
rc = 0;
- ptr_option = plugin_config_search_internal (option);
+ ptr_option = config_file_search_option (plugin_config_file,
+ plugin_config_section_var,
+ option);
if (ptr_option)
{
- if (!value || !value[0])
- {
- /* remove option from list */
- if (ptr_option->prev_option)
- (ptr_option->prev_option)->next_option =
- ptr_option->next_option;
- else
- plugin_options = ptr_option->next_option;
- if (ptr_option->next_option)
- (ptr_option->next_option)->prev_option =
- ptr_option->prev_option;
- rc = 1;
- }
- else
- {
- /* replace old value by new one */
- if (ptr_option->value)
- free (ptr_option->value);
- ptr_option->value = strdup (value);
- rc = 1;
- }
+ rc = config_file_option_set (ptr_option, value, 0);
}
else
{
- if (value && value[0])
- {
- ptr_option = malloc (sizeof (*ptr_option));
- if (ptr_option)
- {
- /* create new option */
- ptr_option->name = strdup (option);
- string_tolower (ptr_option->name);
- ptr_option->type = CONFIG_OPTION_STRING;
- ptr_option->description = NULL;
- ptr_option->string_values = NULL;
- ptr_option->min = 0;
- ptr_option->max = 0;
- ptr_option->default_value = NULL;
- ptr_option->value = strdup (value);
- ptr_option->callback_change = NULL;
-
- if (plugin_options)
- {
- pos_option = plugin_config_find_pos (ptr_option->name);
- if (pos_option)
- {
- /* insert option into the list (before option found) */
- ptr_option->prev_option = pos_option->prev_option;
- ptr_option->next_option = pos_option;
- if (pos_option->prev_option)
- pos_option->prev_option->next_option = ptr_option;
- else
- plugin_options = ptr_option;
- pos_option->prev_option = ptr_option;
- }
- else
- {
- /* add option to the end */
- ptr_option->prev_option = last_plugin_option;
- ptr_option->next_option = NULL;
- last_plugin_option->next_option = ptr_option;
- last_plugin_option = ptr_option;
- }
- }
- else
- {
- ptr_option->prev_option = NULL;
- ptr_option->next_option = NULL;
- plugin_options = ptr_option;
- last_plugin_option = ptr_option;
- }
- rc = 1;
- }
- }
- else
- rc = 0;
+ ptr_option = config_file_new_option (
+ plugin_config_file, plugin_config_section_var,
+ option, "string", NULL,
+ NULL, 0, 0, value, NULL, NULL, NULL, NULL, NULL, NULL);
+ rc = (ptr_option) ? 1 : 0;
}
- if (rc)
- hook_config_exec ("plugin", option, value);
-
return rc;
}
/*
* plugin_config_set: set value for a plugin option (create it if not found)
- * return: 1 if ok, 0 if error
+ * Return: 1 if ok, 0 if error
*/
int
plugin_config_set (char *plugin_name, char *option_name, char *value)
{
- char *internal_option;
- int return_code;
-
- internal_option = malloc (strlen (plugin_name) + strlen (option_name) + 2);
- if (!internal_option)
- return 0;
-
- strcpy (internal_option, plugin_name);
- strcat (internal_option, ".");
- strcat (internal_option, option_name);
+ int length, rc;
+ char *option_full_name;
- return_code = plugin_config_set_internal (internal_option, value);
- free (internal_option);
-
- return return_code;
-}
-
-/*
- * plugin_config_free: free a plugin option and remove it from list
- */
-
-void
-plugin_config_free (struct t_config_option *option)
-{
- struct t_config_option *new_plugin_options;
+ rc = 0;
- /* remove option from list */
- if (last_plugin_option == option)
- last_plugin_option = option->prev_option;
- if (option->prev_option)
+ length = strlen (plugin_name) + 1 + strlen (option_name) + 1;
+ option_full_name = malloc (length);
+ if (option_full_name)
{
- (option->prev_option)->next_option = option->next_option;
- new_plugin_options = plugin_options;
+ snprintf (option_full_name, length, "%s.%s",
+ plugin_name, option_name);
+ string_tolower (option_full_name);
+ rc = plugin_config_set_internal (option_full_name, value);
+ free (option_full_name);
}
- else
- new_plugin_options = option->next_option;
-
- if (option->next_option)
- (option->next_option)->prev_option = option->prev_option;
- /* free option */
- config_file_option_free_data (option);
- free (option);
-
- plugin_options = new_plugin_options;
-}
-
-/*
- * plugin_config_free_all: free all plugin options
- */
-
-void
-plugin_config_free_all ()
-{
- while (plugin_options)
- {
- plugin_config_free (plugin_options);
- }
+ return rc;
}
/*
@@ -291,64 +143,34 @@ plugin_config_reload (void *data, struct t_config_file *config_file)
{
/* make C compiler happy */
(void) data;
- (void) config_file;
/* remove all plugin options */
- plugin_config_free_all ();
+ config_file_section_free_options (plugin_config_section_var);
/* reload plugins config file */
- return config_file_reload (plugin_config);
+ return config_file_reload (config_file);
}
/*
- * plugin_config_read_option: read an option in config file
- * Return: 0 = successful
- * -1 = option not found
- * -2 = bad format/value
+ * plugin_config_create_option: set plugin option
*/
-void
-plugin_config_read_option (void *data, struct t_config_file *config_file,
- char *option_name, char *value)
-{
- char *value2;
-
- /* make C compiler happy */
- (void) data;
- (void) config_file;
-
- if (option_name && value)
- {
- value2 = string_iconv_to_internal (NULL, value);
- plugin_config_set_internal (option_name,
- (value2) ? value2 : value);
- if (value2)
- free (value2);
- }
-}
-
-/*
- * plugin_config_write_options: write plugin options in configuration file
- */
-
-void
-plugin_config_write_options (void *data, struct t_config_file *config_file,
- char *section_name)
+int
+plugin_config_create_option (void *data, struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name, char *value)
{
struct t_config_option *ptr_option;
/* make C compiler happy */
(void) data;
- config_file_write_line (config_file, section_name, NULL);
+ ptr_option = config_file_new_option (
+ config_file, section,
+ option_name, "string", NULL,
+ NULL, 0, 0, value, NULL, NULL, NULL, NULL, NULL, NULL);
- for (ptr_option = plugin_options; ptr_option;
- ptr_option = ptr_option->next_option)
- {
- config_file_write_line (config_file,
- ptr_option->name,
- "%s", ptr_option->value);
- }
+ return (ptr_option) ? 1 : 0;
}
/*
@@ -358,15 +180,19 @@ plugin_config_write_options (void *data, struct t_config_file *config_file,
void
plugin_config_init ()
{
- plugin_config = config_file_new (NULL, PLUGIN_CONFIG_FILENAME,
- &plugin_config_reload, NULL);
- if (plugin_config)
+ plugin_config_file = config_file_new (NULL, PLUGIN_CONFIG_NAME,
+ &plugin_config_reload, NULL);
+ if (plugin_config_file)
{
- config_file_new_section (plugin_config, "plugins",
- &plugin_config_read_option, NULL,
- &plugin_config_write_options, NULL,
- NULL, NULL);
+ plugin_config_section_var = config_file_new_section (
+ plugin_config_file, "var",
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ &plugin_config_create_option, NULL);
}
+ else
+ plugin_config_section_var = NULL;
}
/*
@@ -379,7 +205,7 @@ plugin_config_init ()
int
plugin_config_read ()
{
- return config_file_read (plugin_config);
+ return config_file_read (plugin_config_file);
}
/*
@@ -391,7 +217,7 @@ plugin_config_read ()
int
plugin_config_write ()
{
- return config_file_write (plugin_config);
+ return config_file_write (plugin_config_file);
}
/*
@@ -402,5 +228,5 @@ void
plugin_config_end ()
{
/* free all plugin config options */
- plugin_config_free_all ();
+ config_file_section_free_options (plugin_config_section_var);
}
diff --git a/src/plugins/plugin-config.h b/src/plugins/plugin-config.h
index 5ad2f3eeb..dac48cd95 100644
--- a/src/plugins/plugin-config.h
+++ b/src/plugins/plugin-config.h
@@ -20,7 +20,7 @@
#ifndef __WEECHAT_PLUGIN_CONFIG_H
#define __WEECHAT_PLUGIN_CONFIG_H 1
-#define PLUGIN_CONFIG_FILENAME "plugins.rc"
+#define PLUGIN_CONFIG_NAME "plugins"
extern struct t_config_file *plugin_config;
extern struct t_config_option *plugin_options;
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 07968b405..a4cc64819 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -325,7 +325,11 @@ plugin_load (char *filename)
new_plugin->config_search_section = &config_file_search_section;
new_plugin->config_new_option = &config_file_new_option;
new_plugin->config_search_option = &config_file_search_option;
+ new_plugin->config_search_section_option = &config_file_search_section_option;
+ new_plugin->config_search_with_string = &config_file_search_with_string;
+ new_plugin->config_option_reset = &config_file_option_reset;
new_plugin->config_option_set = &config_file_option_set;
+ new_plugin->config_option_get_pointer = &config_file_option_get_pointer;
new_plugin->config_string_to_boolean = &config_file_string_to_boolean;
new_plugin->config_boolean = &config_file_option_boolean;
new_plugin->config_integer = &config_file_option_integer;
@@ -335,6 +339,9 @@ plugin_load (char *filename)
new_plugin->config_write = &config_file_write;
new_plugin->config_read = &config_file_read;
new_plugin->config_reload = &config_file_reload;
+ new_plugin->config_option_free = &config_file_option_free;
+ new_plugin->config_section_free_options = &config_file_section_free_options;
+ new_plugin->config_section_free = &config_file_section_free;
new_plugin->config_free = &config_file_free;
new_plugin->config_get_weechat = &plugin_api_config_get_weechat;
new_plugin->config_get_plugin = &plugin_api_config_get_plugin;
@@ -436,8 +443,7 @@ plugin_load (char *filename)
}
gui_chat_printf (NULL,
- _("%sPlugin \"%s\" loaded"),
- gui_chat_prefix[GUI_CHAT_PREFIX_INFO],
+ _("Plugin \"%s\" loaded"),
name);
free (full_name);
@@ -458,14 +464,14 @@ plugin_auto_load_file (void *plugin, char *filename)
/* make C compiler happy */
(void) plugin;
- if (CONFIG_STRING(config_plugins_extension)
- && CONFIG_STRING(config_plugins_extension)[0])
+ if (CONFIG_STRING(config_plugin_extension)
+ && CONFIG_STRING(config_plugin_extension)[0])
{
- pos = strstr (filename, CONFIG_STRING(config_plugins_extension));
+ pos = strstr (filename, CONFIG_STRING(config_plugin_extension));
if (pos)
{
if (string_strcasecmp (pos,
- CONFIG_STRING(config_plugins_extension)) == 0)
+ CONFIG_STRING(config_plugin_extension)) == 0)
{
plugin_load (filename);
}
@@ -484,34 +490,34 @@ plugin_auto_load_file (void *plugin, char *filename)
void
plugin_auto_load ()
{
- char *ptr_home, *dir_name, *plugins_path, *plugins_path2;
+ char *ptr_home, *dir_name, *plugin_path, *plugin_path2;
char *list_plugins, *pos, *pos2;
- if (CONFIG_STRING(config_plugins_autoload)
- && CONFIG_STRING(config_plugins_autoload)[0])
+ if (CONFIG_STRING(config_plugin_autoload)
+ && CONFIG_STRING(config_plugin_autoload)[0])
{
- if (string_strcasecmp (CONFIG_STRING(config_plugins_autoload),
+ if (string_strcasecmp (CONFIG_STRING(config_plugin_autoload),
"*") == 0)
{
/* auto-load plugins in WeeChat home dir */
- if (CONFIG_STRING(config_plugins_path)
- && CONFIG_STRING(config_plugins_path)[0])
+ if (CONFIG_STRING(config_plugin_path)
+ && CONFIG_STRING(config_plugin_path)[0])
{
ptr_home = getenv ("HOME");
- plugins_path = string_replace (CONFIG_STRING(config_plugins_path),
- "~", ptr_home);
- plugins_path2 = string_replace ((plugins_path) ?
- plugins_path : CONFIG_STRING(config_plugins_path),
- "%h", weechat_home);
- util_exec_on_files ((plugins_path2) ?
- plugins_path2 : ((plugins_path) ?
- plugins_path : CONFIG_STRING(config_plugins_path)),
+ plugin_path = string_replace (CONFIG_STRING(config_plugin_path),
+ "~", ptr_home);
+ plugin_path2 = string_replace ((plugin_path) ?
+ plugin_path : CONFIG_STRING(config_plugin_path),
+ "%h", weechat_home);
+ util_exec_on_files ((plugin_path2) ?
+ plugin_path2 : ((plugin_path) ?
+ plugin_path : CONFIG_STRING(config_plugin_path)),
NULL,
&plugin_auto_load_file);
- if (plugins_path)
- free (plugins_path);
- if (plugins_path2)
- free (plugins_path2);
+ if (plugin_path)
+ free (plugin_path);
+ if (plugin_path2)
+ free (plugin_path2);
}
/* auto-load plugins in WeeChat global lib dir */
@@ -526,7 +532,7 @@ plugin_auto_load ()
}
else
{
- list_plugins = strdup (CONFIG_STRING(config_plugins_autoload));
+ list_plugins = strdup (CONFIG_STRING(config_plugin_autoload));
if (list_plugins)
{
pos = list_plugins;
@@ -635,8 +641,7 @@ plugin_unload (struct t_weechat_plugin *plugin)
plugin_remove (plugin);
gui_chat_printf (NULL,
- _("%sPlugin \"%s\" unloaded"),
- gui_chat_prefix[GUI_CHAT_PREFIX_INFO],
+ _("Plugin \"%s\" unloaded"),
(name) ? name : "???");
if (name)
free (name);
@@ -694,8 +699,7 @@ plugin_reload_name (char *name)
{
plugin_unload (ptr_plugin);
gui_chat_printf (NULL,
- _("%sPlugin \"%s\" unloaded"),
- gui_chat_prefix[GUI_CHAT_PREFIX_INFO],
+ _("Plugin \"%s\" unloaded"),
name);
plugin_load (filename);
free (filename);
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index 1e8b6770d..ad38dc5b1 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -119,10 +119,9 @@ weechat_lua_api_register (lua_State *L)
if (lua_current_script)
{
weechat_printf (NULL,
- weechat_gettext ("%s%s: registered script \"%s\", "
+ weechat_gettext ("%s: registered script \"%s\", "
"version %s (%s)"),
- weechat_prefix ("info"), "lua",
- name, version, description);
+ "lua", name, version, description);
}
else
{
@@ -934,7 +933,7 @@ weechat_lua_api_config_reload_cb (void *data,
static int
weechat_lua_api_config_new (lua_State *L)
{
- const char *filename, *function;
+ const char *name, *function;
char *result;
int n;
@@ -947,7 +946,7 @@ weechat_lua_api_config_new (lua_State *L)
LUA_RETURN_EMPTY;
}
- filename = NULL;
+ name = NULL;
function = NULL;
n = lua_gettop (lua_current_interpreter);
@@ -958,12 +957,12 @@ weechat_lua_api_config_new (lua_State *L)
LUA_RETURN_EMPTY;
}
- filename = lua_tostring (lua_current_interpreter, -2);
+ name = lua_tostring (lua_current_interpreter, -2);
function = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (script_api_config_new (weechat_lua_plugin,
lua_current_script,
- (char *)filename,
+ (char *)name,
&weechat_lua_api_config_reload_cb,
(char *)function));
@@ -1072,6 +1071,54 @@ weechat_lua_api_config_section_write_default_cb (void *data,
}
/*
+ * weechat_lua_api_config_section_create_option_cb: callback to create an option
+ */
+
+int
+weechat_lua_api_config_section_create_option_cb (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value)
+{
+ struct t_script_callback *script_callback;
+ char *lua_argv[5];
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback->function && script_callback->function[0])
+ {
+ lua_argv[0] = script_ptr2str (config_file);
+ lua_argv[1] = script_ptr2str (section);
+ lua_argv[2] = option_name;
+ lua_argv[3] = value;
+ lua_argv[4] = NULL;
+
+ rc = (int *) weechat_lua_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ lua_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (lua_argv[0])
+ free (lua_argv[0]);
+ if (lua_argv[1])
+ free (lua_argv[1]);
+
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
* weechat_lua_api_config_new_section: create a new section in configuration file
*/
@@ -1079,7 +1126,7 @@ static int
weechat_lua_api_config_new_section (lua_State *L)
{
const char *config_file, *name, *function_read, *function_write;
- const char *function_write_default;
+ const char *function_write_default, *function_create_option;
char *result;
int n;
@@ -1097,20 +1144,22 @@ weechat_lua_api_config_new_section (lua_State *L)
function_read = NULL;
function_write = NULL;
function_write_default = NULL;
+ function_create_option = NULL;
n = lua_gettop (lua_current_interpreter);
- if (n < 5)
+ if (n < 6)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
LUA_RETURN_EMPTY;
}
- config_file = lua_tostring (lua_current_interpreter, -5);
- name = lua_tostring (lua_current_interpreter, -4);
- function_read = lua_tostring (lua_current_interpreter, -3);
- function_write = lua_tostring (lua_current_interpreter, -2);
- function_write_default = lua_tostring (lua_current_interpreter, -1);
+ config_file = lua_tostring (lua_current_interpreter, -6);
+ name = lua_tostring (lua_current_interpreter, -5);
+ function_read = lua_tostring (lua_current_interpreter, -4);
+ function_write = lua_tostring (lua_current_interpreter, -3);
+ function_write_default = lua_tostring (lua_current_interpreter, -2);
+ function_create_option = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (script_api_config_new_section (weechat_lua_plugin,
lua_current_script,
@@ -1120,8 +1169,10 @@ weechat_lua_api_config_new_section (lua_State *L)
(char *)function_read,
&weechat_lua_api_config_section_write_cb,
(char *)function_write,
- &weechat_lua_api_config_section_write_cb,
- (char *)function_write_default));
+ &weechat_lua_api_config_section_write_default_cb,
+ (char *)function_write_default,
+ &weechat_lua_api_config_section_create_option_cb,
+ (char *)function_create_option));
LUA_RETURN_STRING_FREE(result);
}
@@ -2553,19 +2604,17 @@ weechat_lua_api_hook_signal_send (lua_State *L)
*/
int
-weechat_lua_api_hook_config_cb (void *data, char *type, char *option,
- char *value)
+weechat_lua_api_hook_config_cb (void *data, char *option, char *value)
{
struct t_script_callback *script_callback;
- char *lua_argv[4];
+ char *lua_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
- lua_argv[0] = type;
- lua_argv[1] = option;
- lua_argv[2] = value;
- lua_argv[3] = NULL;
+ lua_argv[0] = option;
+ lua_argv[1] = value;
+ lua_argv[2] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
@@ -2596,7 +2645,7 @@ weechat_lua_api_hook_config (lua_State *L)
/* make C compiler happy */
(void) L;
-
+
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_config");
@@ -2609,19 +2658,17 @@ weechat_lua_api_hook_config (lua_State *L)
n = lua_gettop (lua_current_interpreter);
- if (n < 3)
+ if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config");
LUA_RETURN_EMPTY;
}
- type = lua_tostring (lua_current_interpreter, -3);
option = lua_tostring (lua_current_interpreter, -2);
function = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (script_api_hook_config (weechat_lua_plugin,
lua_current_script,
- (char *)type,
(char *)option,
&weechat_lua_api_hook_config_cb,
(char *)function));
diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c
index 50458c209..f5a799840 100644
--- a/src/plugins/scripts/lua/weechat-lua.c
+++ b/src/plugins/scripts/lua/weechat-lua.c
@@ -37,7 +37,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Lua plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_lua_plugin;
@@ -142,8 +142,8 @@ weechat_lua_load (char *filename)
}
weechat_printf (NULL,
- weechat_gettext ("%s%s: loading script \"%s\""),
- weechat_prefix ("info"), "lua", filename);
+ weechat_gettext ("%s: loading script \"%s\""),
+ "lua", filename);
lua_current_script = NULL;
@@ -259,8 +259,8 @@ weechat_lua_unload (struct t_plugin_script *script)
char *lua_argv[1] = { NULL };
weechat_printf (NULL,
- weechat_gettext ("%s%s: unloading script \"%s\""),
- weechat_prefix ("info"), "lua", script->name);
+ weechat_gettext ("%s: unloading script \"%s\""),
+ "lua", script->name);
if (script->shutdown_func && script->shutdown_func[0])
{
@@ -291,8 +291,8 @@ weechat_lua_unload_name (char *name)
{
weechat_lua_unload (ptr_script);
weechat_printf (NULL,
- weechat_gettext ("%s%s: script \"%s\" unloaded"),
- weechat_prefix ("info"), "lua", name);
+ weechat_gettext ("%s: script \"%s\" unloaded"),
+ "lua", name);
}
else
{
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index b68577825..3e52ef045 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -110,10 +110,9 @@ static XS (XS_weechat_register)
if (perl_current_script)
{
weechat_printf (NULL,
- weechat_gettext ("%s%s: registered script \"%s\", "
+ weechat_gettext ("%s: registered script \"%s\", "
"version %s (%s)"),
- weechat_prefix ("info"), "perl",
- name, version, description);
+ "perl", name, version, description);
}
else
{
@@ -768,7 +767,7 @@ weechat_perl_api_config_reload_cb (void *data,
static XS (XS_weechat_config_new)
{
- char *result, *filename, *function;
+ char *result, *name, *function;
dXSARGS;
/* make C compiler happy */
@@ -786,11 +785,11 @@ static XS (XS_weechat_config_new)
PERL_RETURN_EMPTY;
}
- filename = SvPV (ST (0), PL_na);
+ name = SvPV (ST (0), PL_na);
function = SvPV (ST (1), PL_na);
result = script_ptr2str (script_api_config_new (weechat_perl_plugin,
perl_current_script,
- filename,
+ name,
&weechat_perl_api_config_reload_cb,
function));
@@ -899,12 +898,61 @@ weechat_perl_api_config_section_write_default_cb (void *data,
}
/*
+ * weechat_perl_api_config_section_create_option_cb: callback to create an option
+ */
+
+int
+weechat_perl_api_config_section_create_option_cb (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value)
+{
+ struct t_script_callback *script_callback;
+ char *perl_argv[5];
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback->function && script_callback->function[0])
+ {
+ perl_argv[0] = script_ptr2str (config_file);
+ perl_argv[1] = script_ptr2str (section);
+ perl_argv[2] = option_name;
+ perl_argv[3] = value;
+ perl_argv[4] = NULL;
+
+ rc = (int *) weechat_perl_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ perl_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (perl_argv[0])
+ free (perl_argv[0]);
+ if (perl_argv[1])
+ free (perl_argv[1]);
+
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
* weechat::config_new_section: create a new section in configuration file
*/
static XS (XS_weechat_config_new_section)
{
- char *result, *cfg_file, *name, *read_cb, *write_cb, *write_default_db;
+ char *result, *cfg_file, *name, *function_read, *function_write;
+ char *function_write_default, *function_create_option;
dXSARGS;
/* make C compiler happy */
@@ -916,7 +964,7 @@ static XS (XS_weechat_config_new_section)
PERL_RETURN_EMPTY;
}
- if (items < 5)
+ if (items < 6)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
PERL_RETURN_EMPTY;
@@ -924,19 +972,22 @@ static XS (XS_weechat_config_new_section)
cfg_file = SvPV (ST (0), PL_na);
name = SvPV (ST (1), PL_na);
- read_cb = SvPV (ST (2), PL_na);
- write_cb = SvPV (ST (3), PL_na);
- write_default_db = SvPV (ST (4), PL_na);
+ function_read = SvPV (ST (2), PL_na);
+ function_write = SvPV (ST (3), PL_na);
+ function_write_default = SvPV (ST (4), PL_na);
+ function_create_option = SvPV (ST (5), PL_na);
result = script_ptr2str (script_api_config_new_section (weechat_perl_plugin,
perl_current_script,
script_str2ptr (cfg_file),
name,
&weechat_perl_api_config_section_read_cb,
- read_cb,
+ function_read,
&weechat_perl_api_config_section_write_cb,
- write_cb,
+ function_write,
&weechat_perl_api_config_section_write_default_cb,
- write_default_db));
+ function_write_default,
+ &weechat_perl_api_config_section_create_option_cb,
+ function_create_option));
PERL_RETURN_STRING_FREE(result);
}
@@ -2117,19 +2168,17 @@ static XS (XS_weechat_hook_signal_send)
*/
int
-weechat_perl_api_hook_config_cb (void *data, char *type, char *option,
- char *value)
+weechat_perl_api_hook_config_cb (void *data, char *option, char *value)
{
struct t_script_callback *script_callback;
- char *perl_argv[4];
+ char *perl_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
- perl_argv[0] = type;
- perl_argv[1] = option;
- perl_argv[2] = value;
- perl_argv[3] = NULL;
+ perl_argv[0] = option;
+ perl_argv[1] = value;
+ perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
@@ -2153,7 +2202,7 @@ weechat_perl_api_hook_config_cb (void *data, char *type, char *option,
static XS (XS_weechat_hook_config)
{
- char *result, *type, *option, *function;
+ char *result, *option, *function;
dXSARGS;
/* make C compiler happy */
@@ -2165,18 +2214,16 @@ static XS (XS_weechat_hook_config)
PERL_RETURN_EMPTY;
}
- if (items < 3)
+ if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config");
PERL_RETURN_EMPTY;
}
- type = SvPV (ST (0), PL_na);
- option = SvPV (ST (1), PL_na);
- function = SvPV (ST (2), PL_na);
+ option = SvPV (ST (0), PL_na);
+ function = SvPV (ST (1), PL_na);
result = script_ptr2str (script_api_hook_config (weechat_perl_plugin,
perl_current_script,
- type,
option,
&weechat_perl_api_hook_config_cb,
function));
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c
index 6766f94f2..d62556baa 100644
--- a/src/plugins/scripts/perl/weechat-perl.c
+++ b/src/plugins/scripts/perl/weechat-perl.c
@@ -35,7 +35,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Perl plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_perl_plugin = NULL;
@@ -236,8 +236,8 @@ weechat_perl_load (char *filename)
}
weechat_printf (NULL,
- weechat_gettext ("%s%s: loading script \"%s\""),
- weechat_prefix ("info"), "perl", filename);
+ weechat_gettext ("%s: loading script \"%s\""),
+ "perl", filename);
perl_current_script = NULL;
@@ -381,8 +381,8 @@ weechat_perl_unload (struct t_plugin_script *script)
char *perl_argv[1] = { NULL };
weechat_printf (NULL,
- weechat_gettext ("%s%s: unloading script \"%s\""),
- weechat_prefix ("info"), "perl", script->name);
+ weechat_gettext ("%s: unloading script \"%s\""),
+ "perl", script->name);
#ifdef MULTIPLICITY
PERL_SET_CONTEXT (script->interpreter);
@@ -425,8 +425,8 @@ weechat_perl_unload_name (char *name)
{
weechat_perl_unload (ptr_script);
weechat_printf (NULL,
- weechat_gettext ("%s%s: script \"%s\" unloaded"),
- weechat_prefix ("info"), "perl", name);
+ weechat_gettext ("%s: script \"%s\" unloaded"),
+ "perl", name);
}
else
{
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index 33992d6b9..5b7cfc8f7 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -101,10 +101,9 @@ weechat_python_api_register (PyObject *self, PyObject *args)
if (python_current_script)
{
weechat_printf (NULL,
- weechat_gettext ("%s%s: registered script \"%s\", "
+ weechat_gettext ("%s: registered script \"%s\", "
"version %s (%s)"),
- weechat_prefix ("info"), "python",
- name, version, description);
+ "python", name, version, description);
}
else
{
@@ -811,7 +810,7 @@ weechat_python_api_config_reload_cb (void *data,
static PyObject *
weechat_python_api_config_new (PyObject *self, PyObject *args)
{
- char *filename, *function, *result;
+ char *name, *function, *result;
PyObject *object;
/* make C compiler happy */
@@ -823,10 +822,10 @@ weechat_python_api_config_new (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
- filename = NULL;
+ name = NULL;
function = NULL;
- if (!PyArg_ParseTuple (args, "ss", &filename, &function))
+ if (!PyArg_ParseTuple (args, "ss", &name, &function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new");
PYTHON_RETURN_EMPTY;
@@ -834,7 +833,7 @@ weechat_python_api_config_new (PyObject *self, PyObject *args)
result = script_ptr2str (script_api_config_new (weechat_python_plugin,
python_current_script,
- filename,
+ name,
&weechat_python_api_config_reload_cb,
function));
@@ -943,6 +942,54 @@ weechat_python_api_config_section_write_default_cb (void *data,
}
/*
+ * weechat_python_api_config_section_create_option_cb: callback to create an option
+ */
+
+int
+weechat_python_api_config_section_create_option_cb (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value)
+{
+ struct t_script_callback *script_callback;
+ char *python_argv[5];
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback->function && script_callback->function[0])
+ {
+ python_argv[0] = script_ptr2str (config_file);
+ python_argv[1] = script_ptr2str (section);
+ python_argv[2] = option_name;
+ python_argv[3] = value;
+ python_argv[4] = NULL;
+
+ rc = (int *) weechat_python_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ python_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (python_argv[0])
+ free (python_argv[0]);
+ if (python_argv[1])
+ free (python_argv[1]);
+
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
* weechat_python_api_config_new_section: create a new section in configuration file
*/
@@ -950,7 +997,8 @@ static PyObject *
weechat_python_api_config_new_section (PyObject *self, PyObject *args)
{
char *config_file, *name, *function_read, *function_write;
- char *function_write_default, *result;
+ char *function_write_default, *function_create_option;
+ char *result;
PyObject *object;
/* make C compiler happy */
@@ -967,9 +1015,11 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
function_read = NULL;
function_write = NULL;
function_write_default = NULL;
+ function_create_option = NULL;
- if (!PyArg_ParseTuple (args, "sssss", &config_file, &name, &function_read,
- &function_write, &function_write_default))
+ if (!PyArg_ParseTuple (args, "ssssss", &config_file, &name,
+ &function_read, &function_write,
+ &function_write_default, &function_create_option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
PYTHON_RETURN_EMPTY;
@@ -984,7 +1034,9 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
&weechat_python_api_config_section_write_cb,
function_write,
&weechat_python_api_config_section_write_default_cb,
- function_write_default));
+ function_write_default,
+ &weechat_python_api_config_section_create_option_cb,
+ function_create_option));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2255,19 +2307,17 @@ weechat_python_api_hook_signal_send (PyObject *self, PyObject *args)
*/
int
-weechat_python_api_hook_config_cb (void *data, char *type, char *option,
- char *value)
+weechat_python_api_hook_config_cb (void *data, char *option, char *value)
{
struct t_script_callback *script_callback;
- char *python_argv[4];
+ char *python_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
- python_argv[0] = type;
- python_argv[1] = option;
- python_argv[2] = value;
- python_argv[3] = NULL;
+ python_argv[0] = option;
+ python_argv[1] = value;
+ python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
@@ -2292,7 +2342,7 @@ weechat_python_api_hook_config_cb (void *data, char *type, char *option,
static PyObject *
weechat_python_api_hook_config (PyObject *self, PyObject *args)
{
- char *type, *option, *function, *result;
+ char *option, *function, *result;
PyObject *object;
/* make C compiler happy */
@@ -2304,11 +2354,10 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
- type = NULL;
option = NULL;
function = NULL;
- if (!PyArg_ParseTuple (args, "sss", &type, &option, &function))
+ if (!PyArg_ParseTuple (args, "ss", &option, &function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config");
PYTHON_RETURN_EMPTY;
@@ -2316,7 +2365,6 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args)
result = script_ptr2str(script_api_hook_config (weechat_python_plugin,
python_current_script,
- type,
option,
&weechat_python_api_hook_config_cb,
function));
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c
index b259427be..f485a6f18 100644
--- a/src/plugins/scripts/python/weechat-python.c
+++ b/src/plugins/scripts/python/weechat-python.c
@@ -33,7 +33,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Python plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_python_plugin = NULL;
@@ -261,8 +261,8 @@ weechat_python_load (char *filename)
}
weechat_printf (NULL,
- weechat_gettext ("%s%s: loading script \"%s\""),
- weechat_prefix ("info"), "python", filename);
+ weechat_gettext ("%s: loading script \"%s\""),
+ "python", filename);
python_current_script = NULL;
@@ -428,8 +428,8 @@ weechat_python_unload (struct t_plugin_script *script)
int *r;
weechat_printf (NULL,
- weechat_gettext ("%s%s: unloading script \"%s\""),
- weechat_prefix ("info"), "python", script->name);
+ weechat_gettext ("%s: unloading script \"%s\""),
+ "python", script->name);
if (script->shutdown_func && script->shutdown_func[0])
{
@@ -459,8 +459,8 @@ weechat_python_unload_name (char *name)
{
weechat_python_unload (ptr_script);
weechat_printf (NULL,
- weechat_gettext ("%s%s: script \"%s\" unloaded"),
- weechat_prefix ("info"), "python", name);
+ weechat_gettext ("%s: script \"%s\" unloaded"),
+ "python", name);
}
else
{
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index 52108c980..b6f71f7ad 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -119,10 +119,9 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author,
if (ruby_current_script)
{
weechat_printf (NULL,
- weechat_gettext ("%s%s: registered script \"%s\", "
+ weechat_gettext ("%s: registered script \"%s\", "
"version %s (%s)"),
- weechat_prefix ("info"), "ruby",
- c_name, c_version, c_description);
+ "ruby", c_name, c_version, c_description);
}
else
{
@@ -922,9 +921,9 @@ weechat_ruby_api_config_reload_cb (void *data,
*/
static VALUE
-weechat_ruby_api_config_new (VALUE class, VALUE filename, VALUE function)
+weechat_ruby_api_config_new (VALUE class, VALUE name, VALUE function)
{
- char *c_filename, *c_function, *result;
+ char *c_name, *c_function, *result;
VALUE return_value;
/* make C compiler happy */
@@ -936,24 +935,24 @@ weechat_ruby_api_config_new (VALUE class, VALUE filename, VALUE function)
RUBY_RETURN_EMPTY;
}
- c_filename = NULL;
+ c_name = NULL;
c_function = NULL;
- if (NIL_P (filename) || NIL_P (function))
+ if (NIL_P (name) || NIL_P (function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new");
RUBY_RETURN_EMPTY;
}
- Check_Type (filename, T_STRING);
+ Check_Type (name, T_STRING);
Check_Type (function, T_STRING);
- c_filename = STR2CSTR (filename);
+ c_name = STR2CSTR (name);
c_function = STR2CSTR (function);
result = script_ptr2str (script_api_config_new (weechat_ruby_plugin,
ruby_current_script,
- c_filename,
+ c_name,
&weechat_ruby_api_config_reload_cb,
c_function));
@@ -1062,6 +1061,54 @@ weechat_ruby_api_config_section_write_default_cb (void *data,
}
/*
+ * weechat_ruby_api_config_section_create_option_cb: callback to create an option
+ */
+
+int
+weechat_ruby_api_config_section_create_option_cb (void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value)
+{
+ struct t_script_callback *script_callback;
+ char *ruby_argv[5];
+ int *rc, ret;
+
+ script_callback = (struct t_script_callback *)data;
+
+ if (script_callback->function && script_callback->function[0])
+ {
+ ruby_argv[0] = script_ptr2str (config_file);
+ ruby_argv[1] = script_ptr2str (section);
+ ruby_argv[2] = option_name;
+ ruby_argv[3] = value;
+ ruby_argv[4] = NULL;
+
+ rc = (int *) weechat_ruby_exec (script_callback->script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ script_callback->function,
+ ruby_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (ruby_argv[0])
+ free (ruby_argv[0]);
+ if (ruby_argv[1])
+ free (ruby_argv[1]);
+
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
* weechat_ruby_api_config_new_section: create a new section in configuration file
*/
@@ -1069,10 +1116,12 @@ static VALUE
weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
VALUE name, VALUE function_read,
VALUE function_write,
- VALUE function_write_default)
+ VALUE function_write_default,
+ VALUE function_create_option)
{
char *c_config_file, *c_name, *c_function_read, *c_function_write;
- char *c_function_write_default, *result;
+ char *c_function_write_default, *c_function_create_option;
+ char *result;
VALUE return_value;
/* make C compiler happy */
@@ -1089,9 +1138,11 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
c_function_read = NULL;
c_function_write = NULL;
c_function_write_default = NULL;
+ c_function_create_option = NULL;
if (NIL_P (config_file) || NIL_P (name) || NIL_P (function_read)
- || NIL_P (function_write) || NIL_P (function_write_default))
+ || NIL_P (function_write) || NIL_P (function_write_default)
+ || NIL_P (function_create_option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
RUBY_RETURN_EMPTY;
@@ -1102,12 +1153,14 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
Check_Type (function_read, T_STRING);
Check_Type (function_write, T_STRING);
Check_Type (function_write_default, T_STRING);
+ Check_Type (function_create_option, T_STRING);
c_config_file = STR2CSTR (config_file);
c_name = STR2CSTR (name);
c_function_read = STR2CSTR (function_read);
c_function_write = STR2CSTR (function_write);
c_function_write_default = STR2CSTR (function_write_default);
+ c_function_create_option = STR2CSTR (function_create_option);
result = script_ptr2str (script_api_config_new_section (weechat_ruby_plugin,
ruby_current_script,
@@ -1118,7 +1171,9 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
&weechat_ruby_api_config_section_write_cb,
c_function_write,
&weechat_ruby_api_config_section_write_default_cb,
- c_function_write_default));
+ c_function_write_default,
+ &weechat_ruby_api_config_section_create_option_cb,
+ c_function_create_option));
RUBY_RETURN_STRING_FREE(result);
}
@@ -2606,19 +2661,17 @@ weechat_ruby_api_hook_signal_send (VALUE class, VALUE signal, VALUE type_data,
*/
int
-weechat_ruby_api_hook_config_cb (void *data, char *type, char *option,
- char *value)
+weechat_ruby_api_hook_config_cb (void *data, char *option, char *value)
{
struct t_script_callback *script_callback;
- char *ruby_argv[4];
+ char *ruby_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
- ruby_argv[0] = type;
- ruby_argv[1] = option;
- ruby_argv[2] = value;
- ruby_argv[3] = NULL;
+ ruby_argv[0] = option;
+ ruby_argv[1] = value;
+ ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
@@ -2641,10 +2694,9 @@ weechat_ruby_api_hook_config_cb (void *data, char *type, char *option,
*/
static VALUE
-weechat_ruby_api_hook_config (VALUE class, VALUE type, VALUE option,
- VALUE function)
+weechat_ruby_api_hook_config (VALUE class, VALUE option, VALUE function)
{
- char *c_type, *c_option, *c_function, *result;
+ char *c_option, *c_function, *result;
VALUE return_value;
/* make C compiler happy */
@@ -2656,27 +2708,23 @@ weechat_ruby_api_hook_config (VALUE class, VALUE type, VALUE option,
RUBY_RETURN_EMPTY;
}
- c_type = NULL;
c_option = NULL;
c_function = NULL;
- if (NIL_P (type) || NIL_P (option) || NIL_P (function))
+ if (NIL_P (option) || NIL_P (function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_config");
RUBY_RETURN_EMPTY;
}
- Check_Type (type, T_STRING);
Check_Type (option, T_STRING);
Check_Type (function, T_STRING);
- c_type = STR2CSTR (type);
c_option = STR2CSTR (option);
c_function = STR2CSTR (function);
result = script_ptr2str (script_api_hook_config (weechat_ruby_plugin,
ruby_current_script,
- c_type,
c_option,
&weechat_ruby_api_hook_config_cb,
c_function));
@@ -4388,7 +4436,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "list_remove_all", &weechat_ruby_api_list_remove_all, 1);
rb_define_module_function (ruby_mWeechat, "list_free", &weechat_ruby_api_list_free, 1);
rb_define_module_function (ruby_mWeechat, "config_new", &weechat_ruby_api_config_new, 2);
- rb_define_module_function (ruby_mWeechat, "config_new_section", &weechat_ruby_api_config_new_section, 5);
+ rb_define_module_function (ruby_mWeechat, "config_new_section", &weechat_ruby_api_config_new_section, 6);
rb_define_module_function (ruby_mWeechat, "config_search_section", &weechat_ruby_api_config_search_section, 2);
rb_define_module_function (ruby_mWeechat, "config_new_option", &weechat_ruby_api_config_new_option, 10);
rb_define_module_function (ruby_mWeechat, "config_search_option", &weechat_ruby_api_config_search_option, 3);
@@ -4417,7 +4465,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "hook_print", &weechat_ruby_api_hook_print, 5);
rb_define_module_function (ruby_mWeechat, "hook_signal", &weechat_ruby_api_hook_signal, 2);
rb_define_module_function (ruby_mWeechat, "hook_signal_send", &weechat_ruby_api_hook_signal_send, 3);
- rb_define_module_function (ruby_mWeechat, "hook_config", &weechat_ruby_api_hook_config, 3);
+ rb_define_module_function (ruby_mWeechat, "hook_config", &weechat_ruby_api_hook_config, 2);
rb_define_module_function (ruby_mWeechat, "hook_completion", &weechat_ruby_api_hook_completion, 2);
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);
diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c
index dc32998c6..d34e8dd16 100644
--- a/src/plugins/scripts/ruby/weechat-ruby.c
+++ b/src/plugins/scripts/ruby/weechat-ruby.c
@@ -36,7 +36,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Ruby plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
struct t_weechat_plugin *weechat_ruby_plugin = NULL;
@@ -306,8 +306,8 @@ weechat_ruby_load (char *filename)
}
weechat_printf (NULL,
- weechat_gettext ("%s%s: loading script \"%s\""),
- weechat_prefix ("info"), "ruby", filename);
+ weechat_gettext ("%s: loading script \"%s\""),
+ "ruby", filename);
ruby_current_script = NULL;
@@ -435,8 +435,8 @@ weechat_ruby_unload (struct t_plugin_script *script)
char *ruby_argv[1] = { NULL };
weechat_printf (NULL,
- weechat_gettext ("%s%s: unloading script \"%s\""),
- weechat_prefix ("info"), "ruby", script->name);
+ weechat_gettext ("%s: unloading script \"%s\""),
+ "ruby", script->name);
if (script->shutdown_func && script->shutdown_func[0])
{
@@ -468,8 +468,8 @@ weechat_ruby_unload_name (char *name)
{
weechat_ruby_unload (ptr_script);
weechat_printf (NULL,
- weechat_gettext ("%s%s: script \"%s\" unloaded"),
- weechat_prefix ("info"), "ruby", name);
+ weechat_gettext ("%s: script \"%s\" unloaded"),
+ "ruby", name);
}
else
{
diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c
index f12caa768..ea9821918 100644
--- a/src/plugins/scripts/script-api.c
+++ b/src/plugins/scripts/script-api.c
@@ -51,7 +51,7 @@ script_api_charset_set (struct t_plugin_script *script,
struct t_config_file *
script_api_config_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
- char *filename,
+ char *name,
int (*callback_reload)(void *data,
struct t_config_file *config_file),
char *function)
@@ -65,7 +65,7 @@ script_api_config_new (struct t_weechat_plugin *weechat_plugin,
if (!new_script_callback)
return NULL;
- new_config_file = weechat_config_new (filename, callback_reload,
+ new_config_file = weechat_config_new (name, callback_reload,
new_script_callback);
if (!new_config_file)
{
@@ -82,7 +82,7 @@ script_api_config_new (struct t_weechat_plugin *weechat_plugin,
}
else
{
- new_config_file = weechat_config_new (filename, NULL, NULL);
+ new_config_file = weechat_config_new (name, NULL, NULL);
}
return new_config_file;
@@ -110,19 +110,27 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
void (*callback_write_default)(void *data,
struct t_config_file *config_file,
char *section_name),
- char *function_write_default)
+ char *function_write_default,
+ int (*callback_create_option)(void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value),
+ char *function_create_option)
{
struct t_script_callback *new_script_callback1, *new_script_callback2;
- struct t_script_callback *new_script_callback3;
+ struct t_script_callback *new_script_callback3, *new_script_callback4;
struct t_config_section *new_section;
- void *callback1, *callback2, *callback3;
+ void *callback1, *callback2, *callback3, *callback4;
new_script_callback1 = NULL;
new_script_callback2 = NULL;
new_script_callback3 = NULL;
+ new_script_callback4 = NULL;
callback1 = NULL;
callback2 = NULL;
callback3 = NULL;
+ callback4 = NULL;
if (function_read && function_read[0])
{
@@ -167,6 +175,31 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
callback3 = callback_write_default;
}
+ if (function_create_option && function_create_option[0])
+ {
+ new_script_callback4 = script_callback_alloc ();
+ if (!new_script_callback4)
+ {
+ if (new_script_callback1)
+ {
+ script_callback_free_data (new_script_callback1);
+ free (new_script_callback1);
+ }
+ if (new_script_callback2)
+ {
+ script_callback_free_data (new_script_callback2);
+ free (new_script_callback2);
+ }
+ if (new_script_callback3)
+ {
+ script_callback_free_data (new_script_callback3);
+ free (new_script_callback3);
+ }
+ return NULL;
+ }
+ callback4 = callback_create_option;
+ }
+
new_section = weechat_config_new_section (config_file,
name,
callback1,
@@ -174,7 +207,9 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
callback2,
new_script_callback2,
callback3,
- new_script_callback3);
+ new_script_callback3,
+ callback4,
+ new_script_callback4);
if (!new_section)
{
if (new_script_callback1)
@@ -192,6 +227,11 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
script_callback_free_data (new_script_callback3);
free (new_script_callback3);
}
+ if (new_script_callback4)
+ {
+ script_callback_free_data (new_script_callback4);
+ free (new_script_callback4);
+ }
return NULL;
}
@@ -222,6 +262,15 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
script_callback_add (script, new_script_callback3);
}
+ if (new_script_callback4)
+ {
+ new_script_callback4->script = script;
+ new_script_callback4->function = strdup (function_create_option);
+ new_script_callback4->config_file = config_file;
+ new_script_callback4->config_section = new_section;
+ script_callback_add (script, new_script_callback4);
+ }
+
return new_section;
}
@@ -238,43 +287,126 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
char *name, char *type,
char *description, char *string_values,
int min, int max, char *default_value,
- void (*callback_change)(void *data),
- char *function)
+ void (*callback_check_value)(void *data,
+ struct t_config_option *option,
+ char *value),
+ char *function_check_value,
+ void (*callback_change)(void *data,
+ struct t_config_option *option),
+ char *function_change,
+ void (*callback_delete)(void *data,
+ struct t_config_option *option),
+ char *function_delete)
{
- struct t_script_callback *new_script_callback;
+ struct t_script_callback *new_script_callback1, *new_script_callback2;
+ struct t_script_callback *new_script_callback3;
+ void *callback1, *callback2, *callback3;
struct t_config_option *new_option;
-
- if (function && function[0])
+
+ new_script_callback1 = NULL;
+ new_script_callback2 = NULL;
+ new_script_callback3 = NULL;
+ callback1 = NULL;
+ callback2 = NULL;
+ callback3 = NULL;
+
+ if (function_check_value && function_check_value[0])
{
- new_script_callback = script_callback_alloc ();
- if (!new_script_callback)
+ new_script_callback1 = script_callback_alloc ();
+ if (!new_script_callback1)
return NULL;
-
- new_option = weechat_config_new_option (config_file, section, name, type,
- description, string_values, min,
- max, default_value,
- callback_change,
- new_script_callback);
- if (!new_option)
+ callback1 = callback_check_value;
+ }
+
+ if (function_change && function_change[0])
+ {
+ new_script_callback2 = script_callback_alloc ();
+ if (!new_script_callback2)
{
- script_callback_free_data (new_script_callback);
- free (new_script_callback);
+ if (new_script_callback1)
+ {
+ script_callback_free_data (new_script_callback1);
+ free (new_script_callback1);
+ }
return NULL;
}
-
- new_script_callback->script = script;
- new_script_callback->function = strdup (function);
- new_script_callback->config_file = config_file;
- new_script_callback->config_section = section;
- new_script_callback->config_option = new_option;
-
- script_callback_add (script, new_script_callback);
+ callback2 = callback_change;
}
- else
+
+ if (function_delete && function_delete[0])
+ {
+ new_script_callback3 = script_callback_alloc ();
+ if (!new_script_callback3)
+ {
+ if (new_script_callback1)
+ {
+ script_callback_free_data (new_script_callback1);
+ free (new_script_callback1);
+ }
+ if (new_script_callback2)
+ {
+ script_callback_free_data (new_script_callback2);
+ free (new_script_callback2);
+ }
+ return NULL;
+ }
+ callback3 = callback_delete;
+ }
+
+ new_option = weechat_config_new_option (config_file, section, name, type,
+ description, string_values, min,
+ max, default_value,
+ callback1, new_script_callback1,
+ callback2, new_script_callback2,
+ callback3, new_script_callback3);
+ if (!new_option)
{
- new_option = weechat_config_new_option (config_file, section, name, type,
- description, string_values, min,
- max, default_value, NULL, NULL);
+ if (new_script_callback1)
+ {
+ script_callback_free_data (new_script_callback1);
+ free (new_script_callback1);
+ }
+ if (new_script_callback2)
+ {
+ script_callback_free_data (new_script_callback2);
+ free (new_script_callback2);
+ }
+ if (new_script_callback3)
+ {
+ script_callback_free_data (new_script_callback3);
+ free (new_script_callback3);
+ }
+ return NULL;
+ }
+
+ if (new_script_callback1)
+ {
+ new_script_callback1->script = script;
+ new_script_callback1->function = strdup (function_check_value);
+ new_script_callback1->config_file = config_file;
+ new_script_callback1->config_section = section;
+ new_script_callback1->config_option = new_option;
+ script_callback_add (script, new_script_callback1);
+ }
+
+ if (new_script_callback2)
+ {
+ new_script_callback2->script = script;
+ new_script_callback2->function = strdup (function_check_value);
+ new_script_callback2->config_file = config_file;
+ new_script_callback2->config_section = section;
+ new_script_callback2->config_option = new_option;
+ script_callback_add (script, new_script_callback2);
+ }
+
+ if (new_script_callback3)
+ {
+ new_script_callback3->script = script;
+ new_script_callback3->function = strdup (function_check_value);
+ new_script_callback3->config_file = config_file;
+ new_script_callback3->config_section = section;
+ new_script_callback3->config_option = new_option;
+ script_callback_add (script, new_script_callback3);
}
return new_option;
@@ -638,9 +770,9 @@ script_api_hook_signal (struct t_weechat_plugin *weechat_plugin,
struct t_hook *
script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
- char *type, char *option,
- int (*callback)(void *data, char *type,
- char *option, char *value),
+ char *option,
+ int (*callback)(void *data, char *option,
+ char *value),
char *function)
{
struct t_script_callback *new_script_callback;
@@ -650,7 +782,7 @@ script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
if (!new_script_callback)
return NULL;
- new_hook = weechat_hook_config (type, option, callback, new_script_callback);
+ new_hook = weechat_hook_config (option, callback, new_script_callback);
if (!new_hook)
{
script_callback_free_data (new_script_callback);
diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h
index 98217549a..d27f23ee4 100644
--- a/src/plugins/scripts/script-api.h
+++ b/src/plugins/scripts/script-api.h
@@ -23,7 +23,7 @@ extern void script_api_charset_set (struct t_plugin_script *script,
char *charset);
extern struct t_config_file *script_api_config_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
- char *filename,
+ char *name,
int (*callback_reload)(void *data,
struct t_config_file *config_file),
char *function);
@@ -43,7 +43,13 @@ extern struct t_config_section *script_api_config_new_section (struct t_weechat_
void (*callback_write_default)(void *data,
struct t_config_file *config_file,
char *section_name),
- char *function_write_default);
+ char *function_write_default,
+ int (*callback_create_option)(void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value),
+ char *function_create_option);
extern struct t_config_option *script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_config_file *config_file,
@@ -125,8 +131,8 @@ extern struct t_hook *script_api_hook_signal (struct t_weechat_plugin *weechat_p
char *function);
extern struct t_hook *script_api_hook_config (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
- char *type, char *option,
- int (*callback)(void *data, char *type,
+ char *option,
+ int (*callback)(void *data,
char *option,
char *value),
char *function);
diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c
index 94dbf42bf..108d0d12a 100644
--- a/src/plugins/scripts/script.c
+++ b/src/plugins/scripts/script.c
@@ -63,10 +63,9 @@ script_config_read (struct t_weechat_plugin *weechat_plugin)
*/
int
-script_config_cb (void *data, char *type, char *option, char *value)
+script_config_cb (void *data, char *option, char *value)
{
/* make C compiler happy */
- (void) type;
(void) option;
(void) value;
@@ -100,14 +99,13 @@ script_init (struct t_weechat_plugin *weechat_plugin,
script_config_read (weechat_plugin);
/* add hook for config option */
- length = strlen (weechat_plugin->name) + 32;
+ length = strlen (weechat_plugin->name) + 64;
string = malloc (length);
if (string)
{
- snprintf (string, length, "%s.%s",
+ snprintf (string, length, "plugins.var.%s.%s",
weechat_plugin->name, SCRIPT_OPTION_CHECK_LICENSE);
- weechat_hook_config ("plugin", string,
- &script_config_cb, weechat_plugin);
+ weechat_hook_config (string, &script_config_cb, weechat_plugin);
free (string);
}
@@ -427,7 +425,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
&& !ptr_script_callback->config_section
&& !ptr_script_callback->config_option)
{
- if (weechat_config_boolean (weechat_config_get_weechat ("plugins_save_config_on_unload")))
+ if (weechat_config_boolean (weechat_config_get_weechat ("plugin_save_config_on_unload")))
weechat_config_write (ptr_script_callback->config_file);
weechat_config_free (ptr_script_callback->config_file);
}
@@ -509,9 +507,9 @@ script_display_list (struct t_weechat_plugin *weechat_plugin,
{
weechat_printf (NULL,
" %s%s%s v%s - %s",
- weechat_color ("color_chat_buffer"),
+ weechat_color ("chat_buffer"),
ptr_script->name,
- weechat_color ("color_chat"),
+ weechat_color ("chat"),
ptr_script->version,
ptr_script->description);
if (full)
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index 88daa3623..8f5a5974b 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -34,7 +34,7 @@ WEECHAT_PLUGIN_DESCRIPTION("Trigger plugin for WeeChat");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
-WEECHAT_PLUGIN_LICENSE("GPL");
+WEECHAT_PLUGIN_LICENSE("GPL3");
t_weechat_trigger *weechat_trigger_list = NULL;
t_weechat_trigger *weechat_trigger_last = NULL;
diff --git a/src/plugins/trigger/trigger.h b/src/plugins/trigger/trigger.h
index 23d23e5ec..580f07e86 100644
--- a/src/plugins/trigger/trigger.h
+++ b/src/plugins/trigger/trigger.h
@@ -35,7 +35,7 @@ typedef struct t_weechat_trigger
struct t_weechat_trigger *next_trigger;
} t_weechat_trigger;
-#define CONF_FILE "trigger.rc"
+#define CONF_FILE "trigger.conf"
#define CONF_SAVE 1
#define CONF_LOAD 2
#define DIR_SEP "/"
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 9a4f658b4..9228b099f 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -147,7 +147,7 @@ struct t_weechat_plugin
char *data);
struct t_weelist_item *(*list_get) (struct t_weelist *weelist,
int position);
- void (*list_set) (struct t_weelist_item *item, char *new_value);
+ void (*list_set) (struct t_weelist_item *item, char *value);
struct t_weelist_item *(*list_next) (struct t_weelist_item *item);
struct t_weelist_item *(*list_prev) (struct t_weelist_item *item);
char *(*list_string) (struct t_weelist_item *item);
@@ -159,16 +159,17 @@ struct t_weechat_plugin
/* config files */
struct t_config_file *(*config_new) (struct t_weechat_plugin *plugin,
- char *filename,
+ char *name,
int (*callback_reload)(void *data,
struct t_config_file *config_file),
void *callback_reload_data);
struct t_config_section *(*config_new_section) (struct t_config_file *config_file,
char *name,
- void (*callback_read)(void *data,
- struct t_config_file *config_file,
- char *option_name,
- char *value),
+ int (*callback_read)(void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value),
void *callback_read_data,
void (*callback_write)(void *data,
struct t_config_file *config_file,
@@ -177,7 +178,13 @@ struct t_weechat_plugin
void (*callback_write_default)(void *data,
struct t_config_file *config_file,
char *section_name),
- void *callback_write_default_data);
+ void *callback_write_default_data,
+ int (*callback_create_option)(void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ char *value),
+ void *callback_create_option_data);
struct t_config_section *(*config_search_section) (struct t_config_file *config_file,
char *section_name);
struct t_config_option *(*config_new_option) (struct t_config_file *config_file,
@@ -187,14 +194,36 @@ struct t_weechat_plugin
char *string_values,
int min, int max,
char *default_value,
- void (*callback_change)(void *data),
- void *callback_change_data);
+ int (*callback_check_value)(void *data,
+ struct t_config_option *option,
+ char *value),
+ void *callback_check_value_data,
+ void (*callback_change)(void *data,
+ struct t_config_option *option),
+ void *callback_change_data,
+ void (*callback_delete)(void *data,
+ struct t_config_option *option),
+ void *callback_delete_data);
struct t_config_option *(*config_search_option) (struct t_config_file *config_file,
struct t_config_section *section,
char *option_name);
+ void (*config_search_section_option) (struct t_config_file *config_file,
+ struct t_config_section *section,
+ char *option_name,
+ struct t_config_section **section_found,
+ struct t_config_option **option_found);
+ void (*config_search_with_string) (char *option_name,
+ struct t_config_file **config_file,
+ struct t_config_section **section,
+ struct t_config_option **option,
+ char **pos_option_name);
int (*config_string_to_boolean) (char *text);
- int (*config_option_set) (struct t_config_option *option, char *new_value,
+ int (*config_option_reset) (struct t_config_option *option,
+ int run_callback);
+ int (*config_option_set) (struct t_config_option *option, char *value,
int run_callback);
+ void *(*config_option_get_pointer) (struct t_config_option *option,
+ char *property);
int (*config_boolean) (struct t_config_option *option);
int (*config_integer) (struct t_config_option *option);
char *(*config_string) (struct t_config_option *option);
@@ -204,6 +233,11 @@ struct t_weechat_plugin
int (*config_write) (struct t_config_file *config_file);
int (*config_read) (struct t_config_file *config_file);
int (*config_reload) (struct t_config_file *config_file);
+ void (*config_option_free) (struct t_config_section *section,
+ struct t_config_option *option);
+ void (*config_section_free_options) (struct t_config_section *section);
+ void (*config_section_free) (struct t_config_file *config_file,
+ struct t_config_section *section);
void (*config_free) (struct t_config_file *config_file);
struct t_config_option *(*config_get_weechat) (char *option_name);
char *(*config_get_plugin) (struct t_weechat_plugin *plugin,
@@ -263,9 +297,9 @@ struct t_weechat_plugin
void (*hook_signal_send) (char *signal, char *type_data,
void *signal_data);
struct t_hook *(*hook_config) (struct t_weechat_plugin *plugin,
- char *type, char *option,
- int (*callback)(void *data, char *type,
- char *option, char *value),
+ char *option,
+ int (*callback)(void *data, char *option,
+ char *value),
void *callback_data);
struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin,
char *completion,
@@ -486,8 +520,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->list_casesearch(__list, __string)
#define weechat_list_get(__list, __index) \
weechat_plugin->list_get(__list, __index)
-#define weechat_list_set(__item, __new_value) \
- weechat_plugin->list_set(__item, __new_value)
+#define weechat_list_set(__item, __value) \
+ weechat_plugin->list_set(__item, __value)
#define weechat_list_next(__item) \
weechat_plugin->list_next(__item)
#define weechat_list_prev(__item) \
@@ -504,37 +538,65 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->list_free(__list)
/* config files */
-#define weechat_config_new(__filename, __callback_reload, \
+#define weechat_config_new(__name, __callback_reload, \
__callback_reload_data) \
- weechat_plugin->config_new(weechat_plugin, __filename, \
+ weechat_plugin->config_new(weechat_plugin, __name, \
__callback_reload, \
__callback_reload_data)
-#define weechat_config_new_section(__config, __name, __cb_read, \
- __cb_read_data, __cb_write_std, \
- __cb_write_std_data, __cb_write_def, \
- __cb_write_def_data) \
- weechat_plugin->config_new_section(__config, __name, __cb_read, \
- __cb_read_data, __cb_write_std, \
- __cb_write_std_data,\
- __cb_write_def, \
- __cb_write_def_data)
+#define weechat_config_new_section(__config, __name, \
+ __cb_read, __cb_read_data, \
+ __cb_write_std, __cb_write_std_data, \
+ __cb_write_def, __cb_write_def_data, \
+ __cb_create_option, \
+ __cb_create_option_data) \
+ weechat_plugin->config_new_section(__config, __name, \
+ __cb_read, __cb_read_data, \
+ __cb_write_std, \
+ __cb_write_std_data, \
+ __cb_write_def, \
+ __cb_write_def_data, \
+ __cb_create_option, \
+ __cb_create_option_data)
#define weechat_config_search_section(__config, __name) \
weechat_plugin->config_search_section(__config, __name)
#define weechat_config_new_option(__config, __section, __name, __type, \
__desc, __string_values, __min, \
- __max, __default, __callback, \
- __callback_data) \
+ __max, __default, __callback_check, \
+ __callback_check_data, \
+ __callback_change, \
+ __callback_change_data, \
+ __callback_delete, \
+ __callback_delete_data) \
weechat_plugin->config_new_option(__config, __section, __name, \
__type, __desc, __string_values, \
__min, __max, __default, \
- __callback, __callback_data)
+ __callback_check, \
+ __callback_check_data, \
+ __callback_change, \
+ __callback_change_data, \
+ __callback_delete, \
+ __callback_delete_data)
#define weechat_config_search_option(__config, __section, __name) \
weechat_plugin->config_search_option(__config, __section, __name)
+#define weechat_config_search_section_option(__config, __section, \
+ __name, __section_found, \
+ __option_found) \
+ weechat_plugin->config_search_section_option(__config, __section, \
+ __name, \
+ __section_found, \
+ __option_found);
+#define weechat_config_search_with_string(__name, __config, __section, \
+ __option, __pos_option) \
+ weechat_plugin->config_search_with_string(__name, __config, \
+ __section, __option, \
+ __pos_option);
#define weechat_config_string_to_boolean(__string) \
weechat_plugin->config_string_to_boolean(__string)
#define weechat_config_option_set(__option, __value, __run_callback) \
weechat_plugin->config_option_set(__option, __value, \
__run_callback)
+#define weechat_config_option_get_pointer(__option, __property) \
+ weechat_plugin->config_option_get_pointer(__option, __property)
#define weechat_config_boolean(__option) \
weechat_plugin->config_boolean(__option)
#define weechat_config_integer(__option) \
@@ -553,6 +615,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->config_read(__config)
#define weechat_config_reload(__config) \
weechat_plugin->config_reload(__config)
+#define weechat_config_option_free(__section, __option) \
+ weechat_plugin->config_option_free(__section, __option)
+#define weechat_config_section_free_options(__section) \
+ weechat_plugin->config_section_free_options(__section)
+#define weechat_config_section_free(__config, __section) \
+ weechat_plugin->config_section_free(__config, __section)
#define weechat_config_free(__config) \
weechat_plugin->config_free(__config)
#define weechat_config_get_weechat(__option) \
@@ -619,9 +687,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_hook_signal_send(__signal, __type_data, __signal_data) \
weechat_plugin->hook_signal_send(__signal, __type_data, \
__signal_data)
-#define weechat_hook_config(__type, __option, __callback, __data) \
- weechat_plugin->hook_config(weechat_plugin, __type, __option, \
- __callback, __data)
+#define weechat_hook_config(__option, __callback, __data) \
+ weechat_plugin->hook_config(weechat_plugin, __option, __callback, \
+ __data)
#define weechat_hook_completion(__completion, __callback, __data) \
weechat_plugin->hook_completion(weechat_plugin, __completion, \
__callback, __data)