summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-04-11 22:05:54 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-04-11 22:05:54 +0200
commit00e75b9b94b485ec863b6282ecda65fc022cbcf5 (patch)
tree5f6481a2d4ecb39c7b5f8134cd3b8d600cf0655f /src
parentd975629686360821c020bb7304b7af1528a877f9 (diff)
downloadweechat-00e75b9b94b485ec863b6282ecda65fc022cbcf5.zip
Fixed bugs with weechat_config_get() in plugin API
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-nick.c2
-rw-r--r--src/plugins/irc/irc-protocol.c4
-rw-r--r--src/plugins/irc/irc-server.c71
-rw-r--r--src/plugins/plugin-api.c11
-rw-r--r--src/plugins/plugin-api.h2
-rw-r--r--src/plugins/plugin.c2
-rw-r--r--src/plugins/scripts/script.c2
-rw-r--r--src/plugins/weechat-plugin.h6
8 files changed, 53 insertions, 47 deletions
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 862d97c09..8eebd33ba 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -48,7 +48,7 @@ irc_nick_find_color (struct t_irc_nick *nick)
color += (int)(nick->name[i]);
}
color = (color %
- weechat_config_integer (weechat_config_get_weechat ("look_color_nicks_number")));
+ weechat_config_integer (weechat_config_get ("weechat.look.color_nicks_number")));
snprintf (color_name, sizeof (color_name),
"chat_nick_color%d", color);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 85b21f7c1..d1d592576 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -885,7 +885,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *command,
}
look_infobar_delay_highlight = weechat_config_integer (
- weechat_config_get_weechat ("look_infobar_delay_highlight"));
+ weechat_config_get ("weechat.look.infobar_delay_highlight"));
if (nick && strncmp (pos_args, "\01VERSION", 8) == 0)
{
@@ -1346,7 +1346,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command,
IRC_PROTOCOL_CHECK_HOST;
look_infobar_delay_highlight = weechat_config_integer (
- weechat_config_get_weechat ("look_infobar_delay_highlight"));
+ weechat_config_get ("weechat.look.infobar_delay_highlight"));
nick = irc_protocol_get_nick_from_host (argv[0]);
host = irc_protocol_get_address_from_host (argv[0]);
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 13dbf5a7b..a801bd427 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -100,28 +100,31 @@ irc_server_set_addresses (struct t_irc_server *server, char *addresses)
}
/* set new address */
- server->addresses = strdup (addresses);
- if (server->addresses)
+ if (addresses && addresses[0])
{
- 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++)
+ server->addresses = strdup (addresses);
+ if (server->addresses)
{
- 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->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++)
{
- server->ports_array[i] = IRC_SERVER_DEFAULT_PORT;
+ 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;
+ }
}
}
}
@@ -1972,7 +1975,7 @@ irc_server_child_read_cb (void *arg_server)
if (num_read > 0)
{
config_proxy_use = weechat_config_boolean (
- weechat_config_get_weechat ("proxy_use"));
+ weechat_config_get ("weechat.proxy.use"));
switch (buffer[0])
{
/* connection OK */
@@ -2134,9 +2137,9 @@ irc_server_pass_httpproxy (int sock, char *address, int port)
int n, m;
config_proxy_username = weechat_config_string (
- weechat_config_get_weechat ("proxy_username"));
+ weechat_config_get ("weechat.proxy.username"));
config_proxy_username = weechat_config_string (
- weechat_config_get_weechat ("proxy_password"));
+ weechat_config_get ("weechat.proxy.password"));
if (config_proxy_username && config_proxy_username[0])
{
@@ -2290,9 +2293,9 @@ irc_server_pass_socks5proxy (int sock, char *address, int port)
socks5.nmethods = 1;
config_proxy_username = weechat_config_string (
- weechat_config_get_weechat ("proxy_username"));
+ weechat_config_get ("weechat.proxy.username"));
config_proxy_username = weechat_config_string (
- weechat_config_get_weechat ("proxy_password"));
+ weechat_config_get ("weechat.proxy.password"));
if (config_proxy_username && config_proxy_username[0])
socks5.method = 2; /* with authentication */
@@ -2423,7 +2426,7 @@ irc_server_pass_proxy (int sock, char *address, int port, char *username)
char *config_proxy_type;
config_proxy_type = weechat_config_string (
- weechat_config_get_weechat ("proxy_type"));
+ weechat_config_get ("weechat.proxy.type"));
rc = 1;
if (config_proxy_type)
@@ -2454,13 +2457,13 @@ irc_server_child (struct t_irc_server *server)
res_local = NULL;
config_proxy_use = weechat_config_boolean (
- weechat_config_get_weechat ("proxy_use"));
+ weechat_config_get ("weechat.proxy.use"));
config_proxy_ipv6 = weechat_config_integer (
- weechat_config_get_weechat ("proxy_ipv6"));
+ weechat_config_get ("weechat.proxy.ipv6"));
config_proxy_port = weechat_config_integer (
- weechat_config_get_weechat ("proxy_port"));
+ weechat_config_get ("weechat.proxy.port"));
config_proxy_address = weechat_config_string (
- weechat_config_get_weechat ("proxy_address"));
+ weechat_config_get ("weechat.proxy.address"));
if (config_proxy_use)
{
@@ -2624,15 +2627,15 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
}
config_proxy_use = weechat_config_boolean (
- weechat_config_get_weechat ("proxy_use"));
+ weechat_config_get ("weechat.proxy.use"));
config_proxy_ipv6 = weechat_config_boolean (
- weechat_config_get_weechat ("proxy_ipv6"));
+ weechat_config_get ("weechat.proxy.ipv6"));
config_proxy_type = weechat_config_string (
- weechat_config_get_weechat ("proxy_type"));
+ weechat_config_get ("weechat.proxy.type"));
config_proxy_address = weechat_config_string (
- weechat_config_get_weechat ("proxy_address"));
+ weechat_config_get ("weechat.proxy.address"));
config_proxy_port = weechat_config_integer (
- weechat_config_get_weechat ("proxy_port"));
+ weechat_config_get ("weechat.proxy.port"));
if (!server->buffer)
{
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 2e942006b..04e3a6c9f 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -140,14 +140,17 @@ plugin_api_mkdir (char *directory, int mode)
}
/*
- * plugin_api_config_get_weechat: get value of a WeeChat config option
+ * plugin_api_config_get: get value of an option
*/
struct t_config_option *
-plugin_api_config_get_weechat (char *option_name)
+plugin_api_config_get (char *option_name)
{
- return config_file_search_option (weechat_config_file, NULL,
- option_name);
+ struct t_config_option *ptr_option;
+
+ config_file_search_with_string (option_name, NULL, NULL, &ptr_option, NULL);
+
+ return ptr_option;
}
/*
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index f89c5ac88..f90104c6c 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -31,7 +31,7 @@ extern int plugin_api_mkdir_home (char *directory, int mode);
extern int plugin_api_mkdir (char *directory, int mode);
/* config */
-extern struct t_config_option *plugin_api_config_get_weechat (char *option_name);
+extern struct t_config_option *plugin_api_config_get (char *option_name);
extern char *plugin_api_config_get_plugin (struct t_weechat_plugin *plugin,
char *option_name);
extern int plugin_api_config_set_plugin (struct t_weechat_plugin *plugin,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index a4cc64819..2b00d72a4 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -343,7 +343,7 @@ plugin_load (char *filename)
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_api_config_get;
new_plugin->config_get_plugin = &plugin_api_config_get_plugin;
new_plugin->config_set_plugin = &plugin_api_config_set_plugin;
diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c
index 108d0d12a..80e04609a 100644
--- a/src/plugins/scripts/script.c
+++ b/src/plugins/scripts/script.c
@@ -425,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 ("plugin_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);
}
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 9228b099f..0f50032a6 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -239,7 +239,7 @@ struct t_weechat_plugin
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);
+ struct t_config_option *(*config_get) (char *option_name);
char *(*config_get_plugin) (struct t_weechat_plugin *plugin,
char *option_name);
int (*config_set_plugin) (struct t_weechat_plugin *plugin,
@@ -623,8 +623,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->config_section_free(__config, __section)
#define weechat_config_free(__config) \
weechat_plugin->config_free(__config)
-#define weechat_config_get_weechat(__option) \
- weechat_plugin->config_get_weechat(__option)
+#define weechat_config_get(__option) \
+ weechat_plugin->config_get(__option)
#define weechat_config_get_plugin(__option) \
weechat_plugin->config_get_plugin(weechat_plugin, __option)
#define weechat_config_set_plugin(__option, __value) \