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

Fixed bugs with weechat_config_get() in plugin API

This commit is contained in:
Sebastien Helleu
2008-04-11 22:05:54 +02:00
parent d975629686
commit 00e75b9b94
8 changed files with 53 additions and 47 deletions
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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]);
+37 -34
View File
@@ -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)
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[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;
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)
{
+7 -4
View File
@@ -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;
}
/*
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
}
+3 -3
View File
@@ -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) \