1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

Add null values for options, new syntax for /set, reintroduce temporary IRC server feature, improve IRC server options, new functions in API

This commit is contained in:
Sebastien Helleu
2009-01-02 23:05:23 +01:00
parent e9b7d2bc46
commit e7e2da5a9c
60 changed files with 4555 additions and 2881 deletions
+4 -2
View File
@@ -631,7 +631,8 @@ alias_config_create_option (void *data, struct t_config_file *config_file,
weechat_config_new_option (
config_file, section,
option_name, "string", NULL,
NULL, 0, 0, "", value, NULL, NULL,
NULL, 0, 0, "", value, 0,
NULL, NULL,
&alias_config_change_cb, NULL,
&alias_config_delete_cb, NULL);
@@ -750,7 +751,8 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
weechat_config_new_option (
alias_config_file, alias_config_section_cmd,
alias_name, "string", NULL,
NULL, 0, 0, "", argv_eol[2], NULL, NULL,
NULL, 0, 0, "", argv_eol[2], 0,
NULL, NULL,
&alias_config_change_cb, NULL,
&alias_config_delete_cb, NULL);
+7 -6
View File
@@ -191,7 +191,8 @@ weechat_aspell_config_dict_create_option (void *data,
config_file, section,
option_name, "string",
_("comma separated list of dictionaries to use on this buffer"),
NULL, 0, 0, "", value, NULL, NULL,
NULL, 0, 0, "", value, 0,
NULL, NULL,
&weechat_aspell_config_dict_change, NULL,
NULL, NULL);
rc = (ptr_option) ?
@@ -272,7 +273,7 @@ weechat_aspell_config_init ()
weechat_aspell_config_file, ptr_section,
"color", "color",
N_("color used for mispelled words"),
NULL, 0, 0, "lightred", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* check */
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "check",
@@ -293,7 +294,7 @@ weechat_aspell_config_init ()
"enabled (spell checking is disabled for all other commands)"),
NULL, 0, 0,
"ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,"
"quit,topic", NULL,
"quit,topic", NULL, 0,
NULL, NULL, &weechat_aspell_config_change_commands, NULL, NULL, NULL);
weechat_aspell_config_check_default_dict = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
@@ -301,19 +302,19 @@ weechat_aspell_config_init ()
N_("default dictionary (or comma separated list of dictionaries) to "
"use when buffer has no dictionary defined (leave blank to disable "
"aspell on buffers for which you didn't explicitely enabled it)"),
NULL, 0, 0, "", NULL,
NULL, 0, 0, "", NULL, 0,
NULL, NULL, &weechat_aspell_config_change_default_dict, NULL, NULL, NULL);
weechat_aspell_config_check_word_min_length = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"word_min_length", "integer",
N_("minimum length for a word to be spell checked (use 0 to check all "
"words)"),
NULL, 0, INT_MAX, "2", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, INT_MAX, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
weechat_aspell_config_check_during_search = weechat_config_new_option (
weechat_aspell_config_file, ptr_section,
"during_search", "boolean",
N_("check words during text search in buffer"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* dict */
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "dict",
+4 -3
View File
@@ -109,7 +109,8 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
ptr_option = weechat_config_new_option (
config_file, section,
option_name, "string", NULL,
NULL, 0, 0, "", value, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "", value, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -163,13 +164,13 @@ charset_config_init ()
(charset_terminal && charset_internal
&& (strcasecmp (charset_terminal,
charset_internal) != 0)) ?
charset_terminal : "iso-8859-1", NULL,
charset_terminal : "iso-8859-1", NULL, 0,
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, 0, 0, "", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (charset_config_file, "decode",
+155 -228
View File
@@ -530,10 +530,8 @@ int
irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
struct t_irc_server server_tmp;
int i, nb_connect, connect_ok, all_servers, no_join, port, ipv6, ssl;
int default_ipv6, default_ssl;
char *error, value[16];
char *name, *error;
long number;
IRC_GET_SERVER(buffer);
@@ -606,65 +604,21 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
}
else
{
irc_server_init (&server_tmp);
default_ipv6 = server_tmp.ipv6;
default_ssl = server_tmp.ssl;
server_tmp.name = irc_server_get_name_without_port (argv[i]);
server_tmp.addresses = strdup (argv[i]);
server_tmp.ipv6 = ipv6;
server_tmp.ssl = ssl;
ptr_server = irc_server_new (server_tmp.name,
server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
server_tmp.proxy,
server_tmp.addresses,
server_tmp.ipv6,
server_tmp.ssl,
server_tmp.password,
server_tmp.nicks,
server_tmp.username,
server_tmp.realname,
server_tmp.local_hostname,
server_tmp.command,
1, /* command_delay */
server_tmp.autojoin,
1); /* autorejoin */
name = irc_server_get_name_without_port (argv[i]);
ptr_server = irc_server_alloc ((name) ? name : argv[i]);
if (name)
free (name);
if (ptr_server)
{
ptr_server->temp_server = 1;
weechat_config_option_set (ptr_server->options[IRC_SERVER_OPTION_ADDRESSES],
argv[i], 1);
weechat_printf (NULL,
_("%s: server %s%s%s created"),
_("%s: server %s%s%s created (temporary server, NOT SAVED!)"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
server_tmp.name,
ptr_server->name,
IRC_COLOR_CHAT);
/* create server options */
irc_server_new_option (&server_tmp,
IRC_CONFIG_SERVER_ADDRESSES,
server_tmp.addresses);
if (default_ipv6 != server_tmp.ipv6)
{
snprintf (value, sizeof (value),
"%s",
(server_tmp.ipv6) ? "on" : "off");
irc_server_new_option (&server_tmp,
IRC_CONFIG_SERVER_IPV6,
value);
}
if (default_ssl != server_tmp.ssl)
{
snprintf (value, sizeof (value),
"%s",
(server_tmp.ssl) ? "on" : "off");
irc_server_new_option (&server_tmp,
IRC_CONFIG_SERVER_SSL,
value);
}
if (!irc_command_connect_one_server (ptr_server, 0))
connect_ok = 0;
}
@@ -2776,12 +2730,9 @@ int
irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
int i, detailed_list, one_server_found, length;
int default_autoconnect, default_ipv6, default_ssl;
struct t_irc_server server_tmp, *ptr_server2, *server_found, *new_server;
char *server_name, *mask, value[16], charset_modifier[256];
struct t_infolist *infolist;
struct t_config_option *ptr_option;
int i, detailed_list, one_server_found;
struct t_irc_server *ptr_server2, *server_found, *new_server;
char *server_name, charset_modifier[256];
IRC_GET_SERVER_CHANNEL(buffer);
@@ -2852,6 +2803,124 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "add") == 0)
{
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_PLUGIN_NAME,
argv[2]);
return WEECHAT_RC_ERROR;
}
new_server = irc_server_alloc (argv[2]);
if (!new_server)
{
weechat_printf (NULL,
_("%s%s: unable to create server"),
weechat_prefix ("error"), IRC_PLUGIN_NAME);
return WEECHAT_RC_ERROR;
}
weechat_config_option_set (new_server->options[IRC_SERVER_OPTION_ADDRESSES],
argv[3], 1);
/* parse arguments */
for (i = 4; i < argc; i++)
{
if (argv[i][0] == '-')
{
if (weechat_strcasecmp (argv[i], "-auto") == 0)
{
weechat_config_option_set (new_server->options[IRC_SERVER_OPTION_AUTOCONNECT],
"on", 1);
}
if (weechat_strcasecmp (argv[i], "-noauto") == 0)
{
weechat_config_option_set (new_server->options[IRC_SERVER_OPTION_AUTOCONNECT],
"off", 1);
}
if (weechat_strcasecmp (argv[i], "-ipv6") == 0)
{
weechat_config_option_set (new_server->options[IRC_SERVER_OPTION_IPV6],
"on", 1);
}
if (weechat_strcasecmp (argv[i], "-ssl") == 0)
{
weechat_config_option_set (new_server->options[IRC_SERVER_OPTION_SSL],
"on", 1);
}
}
}
weechat_printf (NULL,
_("%s: server %s%s%s created"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
new_server->name,
IRC_COLOR_CHAT);
if (IRC_SERVER_OPTION_BOOLEAN(new_server, IRC_SERVER_OPTION_AUTOCONNECT))
irc_server_connect (new_server, 0);
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "copy") == 0)
{
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_PLUGIN_NAME,
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_PLUGIN_NAME,
argv[3], "server copy");
return WEECHAT_RC_ERROR;
}
/* copy server */
new_server = irc_server_copy (server_found, argv[3]);
if (new_server)
{
weechat_printf (NULL,
_("%s: server %s%s%s has been copied to "
"%s%s"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
argv[2],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
argv[3]);
return WEECHAT_RC_OK;
}
return WEECHAT_RC_ERROR;
}
if (weechat_strcasecmp (argv[1], "rename") == 0)
{
if (argc < 4)
@@ -2900,129 +2969,11 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
return WEECHAT_RC_ERROR;
}
if (weechat_strcasecmp (argv[1], "add") == 0)
if (weechat_strcasecmp (argv[1], "keep") == 0)
{
if (argc < 4)
if (argc < 3)
{
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_PLUGIN_NAME,
argv[2]);
return WEECHAT_RC_ERROR;
}
/* init server struct */
irc_server_init (&server_tmp);
default_autoconnect = server_tmp.autoconnect;
default_ipv6 = server_tmp.ipv6;
default_ssl = server_tmp.ssl;
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 (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;
}
}
/* create new server */
new_server = irc_server_new (server_tmp.name,
server_tmp.autoconnect,
server_tmp.autoreconnect,
server_tmp.autoreconnect_delay,
server_tmp.proxy,
server_tmp.addresses,
server_tmp.ipv6,
server_tmp.ssl,
server_tmp.password,
server_tmp.nicks,
server_tmp.username,
server_tmp.realname,
server_tmp.local_hostname,
server_tmp.command,
1, /* command_delay */
server_tmp.autojoin,
1); /* autorejoin */
if (new_server)
{
weechat_printf (NULL,
_("%s: server %s%s%s created"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
server_tmp.name,
IRC_COLOR_CHAT);
/* create server options */
irc_server_new_option (&server_tmp,
IRC_CONFIG_SERVER_ADDRESSES,
server_tmp.addresses);
if (default_autoconnect != server_tmp.autoconnect)
{
snprintf (value, sizeof (value),
"%s",
(server_tmp.autoconnect) ? "on" : "off");
irc_server_new_option (&server_tmp,
IRC_CONFIG_SERVER_AUTOCONNECT,
value);
}
if (default_ipv6 != server_tmp.ipv6)
{
snprintf (value, sizeof (value),
"%s",
(server_tmp.ipv6) ? "on" : "off");
irc_server_new_option (&server_tmp,
IRC_CONFIG_SERVER_IPV6,
value);
}
if (default_ssl != server_tmp.ssl)
{
snprintf (value, sizeof (value),
"%s",
(server_tmp.ssl) ? "on" : "off");
irc_server_new_option (&server_tmp,
IRC_CONFIG_SERVER_SSL,
value);
}
}
else
{
weechat_printf (NULL,
_("%s%s: unable to create server"),
weechat_prefix ("error"), IRC_PLUGIN_NAME);
irc_server_free_data (&server_tmp);
return WEECHAT_RC_ERROR;
}
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)
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server copy");
IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server keep");
}
/* look for server by name */
@@ -3033,38 +2984,31 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
_("%s%s: server \"%s\" not found for "
"\"%s\" command"),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
argv[2], "server copy");
argv[2], "server keep");
return WEECHAT_RC_ERROR;
}
/* check if target name already exists */
if (irc_server_search (argv[3]))
/* check that is it temporary server */
if (!server_found->temp_server)
{
weechat_printf (NULL,
_("%s%s: server \"%s\" already exists for "
"\"%s\" command"),
_("%s%s: server \"%s\" is not a temporary server"),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
argv[3], "server copy");
argv[2], "server keep");
return WEECHAT_RC_ERROR;
}
/* duplicate server */
new_server = irc_server_duplicate (server_found, argv[3]);
if (new_server)
{
weechat_printf (NULL,
_("%s: server %s%s%s has been copied to "
"%s%s"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
argv[2],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
argv[3]);
return WEECHAT_RC_OK;
}
/* remove temporary flag on server */
server_found->temp_server = 0;
return WEECHAT_RC_ERROR;
weechat_printf (NULL,
_("%s: server %s%s%s is not temporary any more"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
argv[2],
IRC_COLOR_CHAT);
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "del") == 0)
@@ -3097,27 +3041,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
}
server_name = strdup (server_found->name);
/* remove all options (server will be removed when last option is removed) */
length = 32 + strlen (server_found->name) + 1;
mask = malloc (length);
if (mask)
{
snprintf (mask, length, "irc.server.%s.*", server_found->name);
infolist = weechat_infolist_get ("option", NULL, mask);
free (mask);
while (weechat_infolist_next (infolist))
{
weechat_config_search_with_string (weechat_infolist_string (infolist,
"full_name"),
NULL, NULL, &ptr_option,
NULL);
if (ptr_option)
weechat_config_option_unset (ptr_option);
}
weechat_infolist_free (infolist);
}
irc_server_free (server_found);
weechat_printf (NULL,
_("%s: Server %s%s%s has been deleted"),
IRC_PLUGIN_NAME,
@@ -4114,7 +4038,8 @@ irc_command_init ()
"[-auto | -noauto] [-ipv6] [-ssl]] | "
"[copy servername newservername] | "
"[rename servername newservername] | "
"[del servername] | [deloutq] | [switch]"),
"[keep servername] | [del servername] | "
"[deloutq] | [switch]"),
N_(" list: list servers (no parameter implies "
"this list)\n"
" listfull: list servers with detailed info for "
@@ -4132,6 +4057,8 @@ irc_command_init ()
" ssl: use SSL protocol\n"
" copy: duplicate a server\n"
" rename: rename a server\n"
" keep: keep server in config file (for "
"temporary servers only)\n"
" del: delete a server\n"
" deloutq: delete messages out queue for all "
"servers (all messages WeeChat is currently "
@@ -4150,7 +4077,7 @@ irc_command_init ()
" /server del freenode\n"
" /server deloutq\n"
" /server switch"),
"add|copy|rename|del|deloutq|list|listfull|switch "
"add|copy|rename|keep|del|deloutq|list|listfull|switch "
"%(irc_servers) %(irc_servers)",
&irc_command_server, NULL);
weechat_hook_command ("servlist",
File diff suppressed because it is too large Load Diff
+4 -29
View File
@@ -26,29 +26,6 @@
#define IRC_CONFIG_DISPLAY_AWAY_LOCAL 1
#define IRC_CONFIG_DISPLAY_AWAY_CHANNEL 2
enum t_irc_config_server_option
{
IRC_CONFIG_SERVER_AUTOCONNECT = 0,
IRC_CONFIG_SERVER_AUTORECONNECT,
IRC_CONFIG_SERVER_AUTORECONNECT_DELAY,
IRC_CONFIG_SERVER_PROXY,
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_LOCAL_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,
};
#define IRC_CONFIG_SERVER_DEFAULT_AUTOCONNECT 0
#define IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT 1
#define IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT_DELAY 30
@@ -58,7 +35,6 @@ enum t_irc_config_server_option
#define IRC_CONFIG_SERVER_DEFAULT_AUTOREJOIN 0
extern char *irc_config_server_option_string[];
extern struct t_config_file *irc_config_file;
extern struct t_config_section *irc_config_section_server_default;
extern struct t_config_section *irc_config_section_server;
@@ -96,7 +72,6 @@ extern struct t_config_option *irc_config_network_send_unknown_commands;
extern struct t_config_option *irc_config_server_default[];
extern int irc_config_search_server_option (const char *option_name);
extern void irc_config_server_change_cb (void *data,
struct t_config_option *option);
extern void irc_config_server_delete_cb (void *data,
@@ -105,14 +80,14 @@ struct t_config_option *irc_config_server_new_option (struct t_config_file *conf
struct t_config_section *section,
int index_option,
const char *option_name,
const char *default_value,
const char *value,
int null_value_allowed,
void *callback_change,
void *callback_change_data,
void *callback_delete,
void *callback_delete_data);
void *callback_change_data);
extern int irc_config_init ();
extern int irc_config_read ();
extern int irc_config_write ();
extern int irc_config_write (int write_temp_servers);
extern void irc_config_free ();
#endif /* irc-config.h */
+144 -53
View File
@@ -152,11 +152,11 @@ irc_display_server (struct t_irc_server *server, int with_detail)
{
char *string;
int num_channels, num_pv;
if (with_detail)
{
weechat_printf (NULL, "");
weechat_printf (NULL, _("%sServer: %s%s %s[%s%s%s]"),
weechat_printf (NULL, _("%sServer: %s%s %s[%s%s%s]%s%s"),
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
server->name,
@@ -164,61 +164,150 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT,
(server->is_connected) ?
_("connected") : _("not connected"),
IRC_COLOR_CHAT_DELIMITERS);
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
(server->temp_server) ? _(" (temporary)") : "");
weechat_printf (NULL, " autoconnect . . . . : %s",
(server->autoconnect) ? _("on") : _("off"));
weechat_printf (NULL, " autoreconnect . . . : %s",
(server->autoreconnect) ? _("on") : _("off"));
weechat_printf (NULL, " autoreconnect_delay : %d %s",
server->autoreconnect_delay,
NG_("second", "seconds", server->autoreconnect_delay));
weechat_printf (NULL, " addresses . . . . . : %s",
(server->addresses && server->addresses[0]) ?
server->addresses : "");
weechat_printf (NULL, " ipv6 . . . . . . . : %s",
(server->ipv6) ? _("on") : _("off"));
weechat_printf (NULL, " ssl . . . . . . . . : %s",
(server->ssl) ? _("on") : _("off"));
weechat_printf (NULL, " password . . . . . : %s",
(server->password && server->password[0]) ?
_("(hidden)") : "");
weechat_printf (NULL, " nicks . . . . . . . : %s",
(server->nicks && server->nicks[0]) ?
server->nicks : "");
weechat_printf (NULL, " username . . . . . : %s",
(server->username && server->username[0]) ?
server->username : "");
weechat_printf (NULL, " realname . . . . . : %s",
(server->realname && server->realname[0]) ?
server->realname : "");
weechat_printf (NULL, " local_hostname . . : %s",
(server->local_hostname && server->local_hostname[0]) ?
server->local_hostname : "");
if (server->command && server->command[0])
string = strdup (server->command);
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ADDRESSES]))
weechat_printf (NULL, " addresses. . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES));
else
string = NULL;
if (string)
weechat_printf (NULL, " addresses. . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
weechat_config_string (server->options[IRC_SERVER_OPTION_ADDRESSES]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PROXY]))
weechat_printf (NULL, " proxy. . . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY));
else
weechat_printf (NULL, " proxy. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
weechat_config_string (server->options[IRC_SERVER_OPTION_PROXY]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_IPV6]))
weechat_printf (NULL, " ipv6 . . . . . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6)) ?
_("on") : _("off"));
else
weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL]))
weechat_printf (NULL, " ssl. . . . . . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL)) ?
_("on") : _("off"));
else
weechat_printf (NULL, " ssl. . . . . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD]))
weechat_printf (NULL, " password . . . . . . : %s",
_("(hidden)"));
else
weechat_printf (NULL, " password . . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
_("(hidden)"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOCONNECT]))
weechat_printf (NULL, " autoconnect. . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOCONNECT)) ?
_("on") : _("off"));
else
weechat_printf (NULL, " autoconnect. . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
weechat_printf (NULL, " autoreconnect. . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTORECONNECT)) ?
_("on") : _("off"));
else
weechat_printf (NULL, " autoreconnect. . . . : %s%s",
IRC_COLOR_CHAT_HOST,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
weechat_printf (NULL, " autoreconnect_delay. : (%d %s)",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY),
NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY)));
else
weechat_printf (NULL, " autoreconnect_delay. : %s%d %s",
IRC_COLOR_CHAT_HOST,
weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY])));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS]))
weechat_printf (NULL, " nicks. . . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS));
else
weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_printf (NULL, " username . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME));
else
weechat_printf (NULL, " username . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
weechat_config_string (server->options[IRC_SERVER_OPTION_USERNAME]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_REALNAME]))
weechat_printf (NULL, " realname . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME));
else
weechat_printf (NULL, " realname . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
weechat_config_string (server->options[IRC_SERVER_OPTION_REALNAME]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]))
weechat_printf (NULL, " local_hostname . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME));
else
weechat_printf (NULL, " local_hostname . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
weechat_config_string (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND]))
{
if (weechat_config_boolean (irc_config_look_hide_nickserv_pwd))
string = strdup (IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND));
if (string && weechat_config_boolean (irc_config_look_hide_nickserv_pwd))
irc_display_hide_password (string, 1);
weechat_printf (NULL, " command . . . . . . : %s",
string);
free (string);
weechat_printf (NULL, " command. . . . . . . : ('%s')",
(string) ? string : IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND));
if (string)
free (string);
}
else
{
weechat_printf (NULL, " command . . . . . . : %s",
(server->command && server->command[0]) ?
server->command : "");
string = strdup (weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND]));
if (string && weechat_config_boolean (irc_config_look_hide_nickserv_pwd))
irc_display_hide_password (string, 1);
weechat_printf (NULL, " command. . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
(string) ? string : weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND]));
if (string)
free (string);
}
weechat_printf (NULL, " command_delay . . . : %d %s",
server->command_delay,
NG_("second", "seconds", server->command_delay));
weechat_printf (NULL, " autojoin . . . . . : %s",
(server->autojoin && server->autojoin[0]) ?
server->autojoin : "");
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]))
weechat_printf (NULL, " command_delay. . . . : (%d %s)",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY),
NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY)));
else
weechat_printf (NULL, " command_delay. . . . : %s%d %s",
IRC_COLOR_CHAT_HOST,
weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY])));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOJOIN]))
weechat_printf (NULL, " autojoin . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN));
else
weechat_printf (NULL, " autojoin . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
weechat_config_string (server->options[IRC_SERVER_OPTION_AUTOJOIN]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN]))
weechat_printf (NULL, " autorejoin . . . . . : (%s)",
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOREJOIN)) ?
_("on") : _("off"));
else
weechat_printf (NULL, " autorejoin . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
_("on") : _("off"));
}
else
{
@@ -226,7 +315,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
{
num_channels = irc_server_get_channel_count (server);
num_pv = irc_server_get_pv_count (server);
weechat_printf (NULL, " %s %s%s %s[%s%s%s]%s, %d %s, %d pv",
weechat_printf (NULL, " %s %s%s %s[%s%s%s]%s%s, %d %s, %d pv",
(server->is_connected) ? "*" : " ",
IRC_COLOR_CHAT_SERVER,
server->name,
@@ -236,16 +325,18 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("connected") : _("not connected"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
(server->temp_server) ? _(" (temporary)") : "",
num_channels,
NG_("channel", "channels", num_channels),
num_pv);
}
else
{
weechat_printf (NULL, " %s %s%s",
(server->is_connected) ? "*" : " ",
weechat_printf (NULL, " %s%s%s%s",
IRC_COLOR_CHAT_SERVER,
server->name);
server->name,
IRC_COLOR_CHAT,
(server->temp_server) ? _(" (temporary)") : "");
}
}
}
+10 -6
View File
@@ -456,7 +456,7 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command,
/* my nick was kicked => free all nicks, channel is not active any
more */
irc_nick_free_all (ptr_channel);
if (server->autorejoin)
if (IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN))
irc_command_join_server (server, ptr_channel->name);
}
else
@@ -1589,7 +1589,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_infolist_new_var_string (item, "local_nick", server->nick);
weechat_infolist_new_var_string (item, "filename", pos_file);
weechat_infolist_new_var_string (item, "size", pos_size);
weechat_infolist_new_var_string (item, "proxy", server->proxy);
weechat_infolist_new_var_string (item, "proxy",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY));
weechat_infolist_new_var_string (item, "address", pos_addr);
weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
weechat_hook_signal_send ("xfer_add",
@@ -1922,7 +1923,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_infolist_new_var_string (item, "type", "chat_recv");
weechat_infolist_new_var_string (item, "remote_nick", nick);
weechat_infolist_new_var_string (item, "local_nick", server->nick);
weechat_infolist_new_var_string (item, "proxy", server->proxy);
weechat_infolist_new_var_string (item, "proxy",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY));
weechat_infolist_new_var_string (item, "address", pos_addr);
weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
weechat_hook_signal_send ("xfer_add",
@@ -2382,6 +2384,7 @@ irc_protocol_cmd_001 (struct t_irc_server *server, const char *command,
{
char **commands, **ptr_cmd, *vars_replaced;
char *away_msg;
const char *ptr_command;
/* 001 message looks like:
:server 001 mynick :Welcome to the dancer-ircd Network
@@ -2416,10 +2419,11 @@ irc_protocol_cmd_001 (struct t_irc_server *server, const char *command,
WEECHAT_HOOK_SIGNAL_STRING, server->name);
/* execute command when connected */
if (server->command && server->command[0])
ptr_command = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND);
if (ptr_command && ptr_command[0])
{
/* splitting command on ';' which can be escaped with '\;' */
commands = weechat_string_split_command (server->command, ';');
commands = weechat_string_split_command (ptr_command, ';');
if (commands)
{
for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++)
@@ -2434,7 +2438,7 @@ irc_protocol_cmd_001 (struct t_irc_server *server, const char *command,
weechat_string_free_splitted_command (commands);
}
if (server->command_delay > 0)
if (IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY) > 0)
server->command_time = time (NULL) + 1;
else
irc_server_autojoin_channels (server);
File diff suppressed because it is too large Load Diff
+52 -27
View File
@@ -31,6 +31,49 @@
#define NI_MAXHOST 256
#endif
enum t_irc_server_option
{
IRC_SERVER_OPTION_ADDRESSES = 0,
IRC_SERVER_OPTION_PROXY,
IRC_SERVER_OPTION_IPV6,
IRC_SERVER_OPTION_SSL,
IRC_SERVER_OPTION_PASSWORD,
IRC_SERVER_OPTION_AUTOCONNECT,
IRC_SERVER_OPTION_AUTORECONNECT,
IRC_SERVER_OPTION_AUTORECONNECT_DELAY,
IRC_SERVER_OPTION_NICKS,
IRC_SERVER_OPTION_USERNAME,
IRC_SERVER_OPTION_REALNAME,
IRC_SERVER_OPTION_LOCAL_HOSTNAME,
IRC_SERVER_OPTION_COMMAND,
IRC_SERVER_OPTION_COMMAND_DELAY,
IRC_SERVER_OPTION_AUTOJOIN,
IRC_SERVER_OPTION_AUTOREJOIN,
/* number of server options */
IRC_SERVER_NUM_OPTIONS,
};
#define IRC_SERVER_OPTION_BOOLEAN(__server, __index) \
((!weechat_config_option_is_null (__server->options[__index])) ? \
weechat_config_boolean(__server->options[__index]) : \
((!weechat_config_option_is_null (irc_config_server_default[__index])) ? \
weechat_config_boolean(irc_config_server_default[__index]) \
: weechat_config_boolean_default(irc_config_server_default[__index])))
#define IRC_SERVER_OPTION_INTEGER(__server, __index) \
((!weechat_config_option_is_null (__server->options[__index])) ? \
weechat_config_integer(__server->options[__index]) : \
((!weechat_config_option_is_null (irc_config_server_default[__index])) ? \
weechat_config_integer(irc_config_server_default[__index]) \
: weechat_config_integer_default(irc_config_server_default[__index])))
#define IRC_SERVER_OPTION_STRING(__server, __index) \
((!weechat_config_option_is_null (__server->options[__index])) ? \
weechat_config_string(__server->options[__index]) : \
((!weechat_config_option_is_null (irc_config_server_default[__index])) ? \
weechat_config_string(irc_config_server_default[__index]) \
: weechat_config_string_default(irc_config_server_default[__index])))
#define IRC_SERVER_DEFAULT_PORT 6667
#define IRC_SERVER_DEFAULT_PREFIXES_LIST "@%+~&!-"
#define IRC_SERVER_DEFAULT_NICKS "weechat1,weechat2,weechat3," \
@@ -59,25 +102,12 @@ struct t_irc_outqueue
struct t_irc_server
{
/* user choices */
char *name; /* internal name of server */
int autoconnect; /* = 1 if auto connect at startup */
int autoreconnect; /* = 1 if auto reco when disconnected */
int autoreconnect_delay; /* delay before trying again reconnect */
char *proxy; /* proxy used for this server (optional) */
char *addresses; /* server addresses (IP/name with port) */
int ipv6; /* use IPv6 protocol */
int ssl; /* SSL protocol */
char *password; /* password for server */
char *nicks; /* nicknames as one string */
char *username; /* user name */
char *realname; /* real name */
char *local_hostname; /* custom local hostname */
char *command; /* command to run once connected */
int command_delay; /* delay after execution of command */
char *autojoin; /* channels to automatically join */
int autorejoin; /* auto rejoin channels when kicked */
char *name; /* internal name of server */
struct t_config_option *options[IRC_SERVER_NUM_OPTIONS];
/* internal vars */
int temp_server; /* temporary server (not saved) */
int reloading_from_config; /* 1 if reloading from config file */
int reloaded_from_config; /* 1 if reloaded from config file */
int addresses_count; /* number of addresses */
char **addresses_array; /* exploded addresses */
@@ -138,21 +168,16 @@ extern const int gnutls_cert_type_prio[];
extern const int gnutls_prot_prio[];
#endif
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
extern char *irc_server_option_string[];
extern char *irc_server_option_default[];
extern int irc_server_valid (struct t_irc_server *server);
extern int irc_server_search_option (const char *option_name);
extern char *irc_server_get_name_without_port (const char *name);
extern void irc_server_new_option (struct t_irc_server *server,
int index_option,
const char *value);
extern void irc_server_set_addresses (struct t_irc_server *server,
const char *addresses);
extern void irc_server_set_nicks (struct t_irc_server *server, const 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_set_nick (struct t_irc_server *server, const char *nick);
extern void irc_server_init (struct t_irc_server *server);
extern struct t_irc_server *irc_server_alloc (const char *name);
extern int irc_server_alloc_with_url (const char *irc_url);
extern void irc_server_free_all ();
@@ -172,8 +197,8 @@ extern struct t_irc_server *irc_server_new (const char *name, int autoconnect,
int command_delay,
const char *autojoin,
int autorejoin);
extern struct t_irc_server *irc_server_duplicate (struct t_irc_server *server,
const char *new_name);
extern struct t_irc_server *irc_server_copy (struct t_irc_server *server,
const char *new_name);
extern int irc_server_rename (struct t_irc_server *server, const char *new_name);
extern void irc_server_send_signal (struct t_irc_server *server,
const char *signal, const char *command,
+2
View File
@@ -184,6 +184,8 @@ irc_upgrade_read_cb (int object_id,
irc_upgrade_current_server = irc_server_search (weechat_infolist_string (infolist, "name"));
if (irc_upgrade_current_server)
{
irc_upgrade_current_server->temp_server =
weechat_infolist_integer (infolist, "temp_server");
irc_upgrade_current_server->buffer = NULL;
buffer_name = weechat_infolist_string (infolist, "buffer_name");
if (buffer_name && buffer_name[0])
+6 -2
View File
@@ -193,12 +193,16 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
if (irc_hook_timer_check_away)
weechat_unhook (irc_hook_timer_check_away);
irc_config_write ();
if (irc_signal_upgrade_received)
{
irc_config_write (1);
irc_upgrade_save ();
}
else
{
irc_config_write (0);
irc_server_disconnect_all ();
}
irc_server_free_all ();
+9 -9
View File
@@ -148,7 +148,7 @@ logger_config_level_create_option (void *data,
option_name, "integer",
_("logging level for this buffer (0 = logging disabled, "
"1 = a few messages (most important) .. 9 = all messages)"),
NULL, 0, 9, "9", value, NULL, NULL,
NULL, 0, 9, "9", value, 0, NULL, NULL,
&logger_config_level_change, NULL,
NULL, NULL);
rc = (ptr_option) ?
@@ -275,7 +275,7 @@ logger_config_mask_create_option (void *data,
option_name, "string",
_("file mask for log file; local buffer variables are "
"permitted"),
NULL, 0, 0, "", value, NULL, NULL,
NULL, 0, 0, "", value, 0, NULL, NULL,
&logger_config_mask_change, NULL,
NULL, NULL);
rc = (ptr_option) ?
@@ -339,7 +339,7 @@ logger_config_init ()
"backlog", "integer",
N_("maximum number of lines to display from log file when creating "
"new buffer (0 = no backlog)"),
NULL, 0, INT_MAX, "20", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, INT_MAX, "20", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* file */
ptr_section = weechat_config_new_section (logger_config_file, "file",
@@ -358,19 +358,19 @@ logger_config_init ()
"auto_log", "boolean",
N_("automatically save content of buffers to files (unless a buffer "
"disables log)"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_name_lower_case = weechat_config_new_option (
logger_config_file, ptr_section,
"name_lower_case", "boolean",
N_("use only lower case for log filenames"),
NULL, 0, 0, "on", NULL, NULL, NULL,
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
&logger_config_change_file_option_restart_log, NULL, NULL, NULL);
logger_config_file_path = weechat_config_new_option (
logger_config_file, ptr_section,
"path", "string",
N_("path for WeeChat log files ('%h' will be replaced by WeeChat "
"home, ~/.weechat by default)"),
NULL, 0, 0, "%h/logs/", NULL, NULL, NULL,
NULL, 0, 0, "%h/logs/", NULL, 0, NULL, NULL,
&logger_config_change_file_option_restart_log, NULL, NULL, NULL);
logger_config_file_mask = weechat_config_new_option (
logger_config_file, ptr_section,
@@ -378,20 +378,20 @@ logger_config_init ()
N_("default file name mask for log files (format is 'directory/to/file' "
"or 'file', without first '/' because 'path' option is used to "
"build complete path to file); local buffer variables are permitted"),
NULL, 0, 0, "$plugin.$name.weechatlog", NULL, NULL, NULL,
NULL, 0, 0, "$plugin.$name.weechatlog", NULL, 0, NULL, NULL,
&logger_config_change_file_option_restart_log, NULL, NULL, NULL);
logger_config_file_info_lines = weechat_config_new_option (
logger_config_file, ptr_section,
"info_lines", "boolean",
N_("write information line in log file when log starts or ends for a "
"buffer"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
logger_config_file_time_format = weechat_config_new_option (
logger_config_file, ptr_section,
"time_format", "string",
N_("timestamp used in log files (see man strftime for date/time "
"specifiers)"),
NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
/* level */
ptr_section = weechat_config_new_section (logger_config_file, "level",
+3 -3
View File
@@ -987,11 +987,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
" disable logging for current buffer:\n"
" /logger disable\n\n"
" set level to 3 for all IRC buffers:\n"
" /set logger.level.irc = 3\n"
" /set logger.level.irc 3\n"
" disable logging for main WeeChat buffer:\n"
" /set logger.level.core.weechat = 0\n"
" /set logger.level.core.weechat 0\n"
" use a directory per IRC server and a file per channel inside:\n"
" /set logger.mask.irc = $server/$channel.weechatlog\n\n"
" /set logger.mask.irc \"$server/$channel.weechatlog\"\n\n"
"Log levels used by IRC plugin:\n"
" 1: user message, notice, private\n"
" 2: nick change\n"
+1 -1
View File
@@ -263,7 +263,7 @@ notify_config_create_option (void *data, struct t_config_file *config_file,
config_file, section,
option_name, "integer", NULL,
"none|highlight|message|all",
0, 0, "", value, NULL, NULL, NULL, NULL, NULL, NULL);
0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
+2 -2
View File
@@ -96,7 +96,7 @@ plugin_config_set_internal (const char *option, const char *value)
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);
NULL, 0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
@@ -164,7 +164,7 @@ plugin_config_create_option (void *data, struct t_config_file *config_file,
ptr_option = config_file_new_option (
config_file, section,
option_name, "string", NULL,
NULL, 0, 0, "", value, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
return (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
+7
View File
@@ -397,13 +397,20 @@ plugin_load (const char *filename)
new_plugin->config_string_to_boolean = &config_file_string_to_boolean;
new_plugin->config_option_reset = &config_file_option_reset;
new_plugin->config_option_set = &config_file_option_set;
new_plugin->config_option_set_null = &config_file_option_set_null;
new_plugin->config_option_unset = &config_file_option_unset;
new_plugin->config_option_rename = &config_file_option_rename;
new_plugin->config_option_get_pointer = &config_file_option_get_pointer;
new_plugin->config_option_is_null = &config_file_option_is_null;
new_plugin->config_boolean = &config_file_option_boolean;
new_plugin->config_boolean_default = &config_file_option_boolean_default;
new_plugin->config_integer = &config_file_option_integer;
new_plugin->config_integer_default = &config_file_option_integer_default;
new_plugin->config_string = &config_file_option_string;
new_plugin->config_string_default = &config_file_option_string_default;
new_plugin->config_color = &config_file_option_color;
new_plugin->config_color_default = &config_file_option_color_default;
new_plugin->config_write_option = &config_file_write_option;
new_plugin->config_write_line = &config_file_write_line;
new_plugin->config_write = &config_file_write;
new_plugin->config_read = &config_file_read;
+10 -10
View File
@@ -106,7 +106,7 @@ relay_config_init ()
relay_config_file, ptr_section,
"auto_open_buffer", "boolean",
N_("auto open relay buffer when a new client is connecting"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (relay_config_file, "color",
0, 0,
@@ -123,49 +123,49 @@ relay_config_init ()
relay_config_file, ptr_section,
"text", "color",
N_("text color"),
NULL, 0, 0, "default", NULL,
NULL, 0, 0, "default", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
relay_config_color_text_bg = weechat_config_new_option (
relay_config_file, ptr_section,
"text_bg", "color",
N_("background color"),
NULL, 0, 0, "default", NULL,
NULL, 0, 0, "default", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
relay_config_color_text_selected = weechat_config_new_option (
relay_config_file, ptr_section,
"text_selected", "color",
N_("text color of selected client line"),
NULL, 0, 0, "white", NULL,
NULL, 0, 0, "white", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_CONNECTING] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_connecting", "color",
N_("text color for \"connecting\" status"),
NULL, 0, 0, "yellow", NULL,
NULL, 0, 0, "yellow", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_WAITING_AUTH] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_waiting_auth", "color",
N_("text color for \"waiting authentication\" status"),
NULL, 0, 0, "brown", NULL,
NULL, 0, 0, "brown", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_CONNECTED] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_active", "color",
N_("text color for \"connected\" status"),
NULL, 0, 0, "lightblue", NULL,
NULL, 0, 0, "lightblue", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_AUTH_FAILED] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_auth_failed", "color",
N_("text color for \"authentication failed\" status"),
NULL, 0, 0, "lightred", NULL,
NULL, 0, 0, "lightred", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
relay_config_color_status[RELAY_STATUS_DISCONNECTED] = weechat_config_new_option (
relay_config_file, ptr_section,
"status_disconnected", "color",
N_("text color for \"disconnected\" status"),
NULL, 0, 0, "lightred", NULL,
NULL, 0, 0, "lightred", NULL, 0,
NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (relay_config_file, "network",
@@ -185,7 +185,7 @@ relay_config_init ()
N_("port number (or range of ports) that relay plugin listens on "
"(syntax: a single port, ie. 5000 or a port "
"range, ie. 5000-5015)"),
NULL, 0, 0, "22373-22400", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "22373-22400", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
return 1;
}
+176 -17
View File
@@ -1461,7 +1461,7 @@ weechat_lua_api_config_new_option (lua_State *L)
const char *string_values, *default_value, *value;
const char *function_check_value, *function_change, *function_delete;
char *result;
int n, min, max;
int n, min, max, null_value_allowed;
/* make C compiler happy */
(void) L;
@@ -1482,28 +1482,30 @@ weechat_lua_api_config_new_option (lua_State *L)
max = 0;
default_value = NULL;
value = NULL;
null_value_allowed = 0;
function_check_value = NULL;
function_change = NULL;
function_delete = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 13)
if (n < 14)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
LUA_RETURN_EMPTY;
}
config_file = lua_tostring (lua_current_interpreter, -13);
section = lua_tostring (lua_current_interpreter, -12);
name = lua_tostring (lua_current_interpreter, -11);
type = lua_tostring (lua_current_interpreter, -10);
description = lua_tostring (lua_current_interpreter, -9);
string_values = lua_tostring (lua_current_interpreter, -8);
min = lua_tonumber (lua_current_interpreter, -7);
max = lua_tonumber (lua_current_interpreter, -6);
default_value = lua_tostring (lua_current_interpreter, -5);
value = lua_tostring (lua_current_interpreter, -4);
config_file = lua_tostring (lua_current_interpreter, -14);
section = lua_tostring (lua_current_interpreter, -13);
name = lua_tostring (lua_current_interpreter, -12);
type = lua_tostring (lua_current_interpreter, -11);
description = lua_tostring (lua_current_interpreter, -10);
string_values = lua_tostring (lua_current_interpreter, -9);
min = lua_tonumber (lua_current_interpreter, -8);
max = lua_tonumber (lua_current_interpreter, -7);
default_value = lua_tostring (lua_current_interpreter, -6);
value = lua_tostring (lua_current_interpreter, -5);
null_value_allowed = lua_tonumber (lua_current_interpreter, -4);
function_check_value = lua_tostring (lua_current_interpreter, -3);
function_change = lua_tostring (lua_current_interpreter, -2);
function_delete = lua_tostring (lua_current_interpreter, -1);
@@ -1520,6 +1522,7 @@ weechat_lua_api_config_new_option (lua_State *L)
max,
default_value,
value,
null_value_allowed,
&weechat_lua_api_config_option_check_value_cb,
function_check_value,
&weechat_lua_api_config_option_change_cb,
@@ -1664,7 +1667,7 @@ weechat_lua_api_config_option_set (lua_State *L)
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
LUA_RETURN_INT(0);
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = NULL;
@@ -1676,7 +1679,7 @@ weechat_lua_api_config_option_set (lua_State *L)
if (n < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
LUA_RETURN_INT(0);
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = lua_tostring (lua_current_interpreter, -3);
@@ -1690,6 +1693,46 @@ weechat_lua_api_config_option_set (lua_State *L)
LUA_RETURN_INT(rc);
}
/*
* weechat_lua_api_config_option_set_null: set null (undefined) value for
* option
*/
static int
weechat_lua_api_config_option_set_null (lua_State *L)
{
const char *option;
int n, run_callback, rc;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = NULL;
run_callback = 0;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = lua_tostring (lua_current_interpreter, -2);
run_callback = lua_tonumber (lua_current_interpreter, -1);
rc = weechat_config_option_set_null (script_str2ptr (option),
run_callback);
LUA_RETURN_INT(rc);
}
/*
* weechat_lua_api_config_option_unset: unset an option
*/
@@ -1706,7 +1749,7 @@ weechat_lua_api_config_option_unset (lua_State *L)
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
LUA_RETURN_INT(0);
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
option = NULL;
@@ -1716,7 +1759,7 @@ weechat_lua_api_config_option_unset (lua_State *L)
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
LUA_RETURN_INT(0);
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
option = lua_tostring (lua_current_interpreter, -1);
@@ -1741,7 +1784,7 @@ weechat_lua_api_config_option_rename (lua_State *L)
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");;
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");
LUA_RETURN_ERROR;
}
@@ -1765,6 +1808,79 @@ weechat_lua_api_config_option_rename (lua_State *L)
LUA_RETURN_OK;
}
/*
* weechat_lua_api_config_option_is_null: return 1 if value of option is null
*/
static int
weechat_lua_api_config_option_is_null (lua_State *L)
{
const char *option;
int n, value;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
LUA_RETURN_INT(1);
}
option = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
LUA_RETURN_INT(1);
}
option = lua_tostring (lua_current_interpreter, -1);
value = weechat_config_option_is_null (script_str2ptr (option));
LUA_RETURN_INT(value);
}
/*
* weechat_lua_api_config_option_default_is_null: return 1 if default value of
* option is null
*/
static int
weechat_lua_api_config_option_default_is_null (lua_State *L)
{
const char *option;
int n, value;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
LUA_RETURN_INT(1);
}
option = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
LUA_RETURN_INT(1);
}
option = lua_tostring (lua_current_interpreter, -1);
value = weechat_config_option_default_is_null (script_str2ptr (option));
LUA_RETURN_INT(value);
}
/*
* weechat_lua_api_config_boolean: return boolean value of option
*/
@@ -1909,6 +2025,45 @@ weechat_lua_api_config_color (lua_State *L)
LUA_RETURN_STRING(result);
}
/*
* weechat_lua_api_config_write_option: write an option in configuration file
*/
static int
weechat_lua_api_config_write_option (lua_State *L)
{
const char *config_file, *option;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
LUA_RETURN_ERROR;
}
config_file = NULL;
option = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
LUA_RETURN_ERROR;
}
config_file = lua_tostring (lua_current_interpreter, -2);
option = lua_tostring (lua_current_interpreter, -1);
weechat_config_write_option (script_str2ptr (config_file),
script_str2ptr (option));
LUA_RETURN_OK;
}
/*
* weechat_lua_api_config_write_line: write a line in configuration file
*/
@@ -5880,12 +6035,16 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "config_string_to_boolean", &weechat_lua_api_config_string_to_boolean },
{ "config_option_reset", &weechat_lua_api_config_option_reset },
{ "config_option_set", &weechat_lua_api_config_option_set },
{ "config_option_set_null", &weechat_lua_api_config_option_set_null },
{ "config_option_unset", &weechat_lua_api_config_option_unset },
{ "config_option_rename", &weechat_lua_api_config_option_rename },
{ "config_option_is_null", &weechat_lua_api_config_option_is_null },
{ "config_option_default_is_null", &weechat_lua_api_config_option_default_is_null },
{ "config_boolean", &weechat_lua_api_config_boolean },
{ "config_integer", &weechat_lua_api_config_integer },
{ "config_string", &weechat_lua_api_config_string },
{ "config_color", &weechat_lua_api_config_color },
{ "config_write_option", &weechat_lua_api_config_write_option },
{ "config_write_line", &weechat_lua_api_config_write_line },
{ "config_write", &weechat_lua_api_config_write },
{ "config_read", &weechat_lua_api_config_read },
+136 -8
View File
@@ -1260,7 +1260,7 @@ static XS (XS_weechat_api_config_new_option)
PERL_RETURN_EMPTY;
}
if (items < 13)
if (items < 14)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
PERL_RETURN_EMPTY;
@@ -1274,9 +1274,9 @@ static XS (XS_weechat_api_config_new_option)
string_values = SvPV (ST (5), PL_na);
default_value = SvPV (ST (8), PL_na);
value = SvPV (ST (9), PL_na);
function_check_value = SvPV (ST (10), PL_na);
function_change = SvPV (ST (11), PL_na);
function_delete = SvPV (ST (12), PL_na);
function_check_value = SvPV (ST (11), PL_na);
function_change = SvPV (ST (12), PL_na);
function_delete = SvPV (ST (13), PL_na);
result = script_ptr2str (script_api_config_new_option (weechat_perl_plugin,
perl_current_script,
script_str2ptr (config_file),
@@ -1289,6 +1289,7 @@ static XS (XS_weechat_api_config_new_option)
SvIV (ST (7)), /* max */
default_value,
value,
SvIV (ST (10)), /* null_value_allowed */
&weechat_perl_api_config_option_check_value_cb,
function_check_value,
&weechat_perl_api_config_option_change_cb,
@@ -1410,13 +1411,13 @@ static XS (XS_weechat_api_config_option_set)
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
PERL_RETURN_INT(0);
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
if (items < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
PERL_RETURN_INT(0);
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = SvPV (ST (0), PL_na);
@@ -1428,6 +1429,38 @@ static XS (XS_weechat_api_config_option_set)
PERL_RETURN_INT(rc);
}
/*
* weechat::config_option_set_null: set null (undefined) value for option
*/
static XS (XS_weechat_api_config_option_set_null)
{
int rc;
char *option;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = SvPV (ST (0), PL_na);
rc = weechat_config_option_set_null (script_str2ptr (option),
SvIV (ST (1))); /* run_callback */
PERL_RETURN_INT(rc);
}
/*
* weechat::config_option_unset: unset an option
*/
@@ -1444,13 +1477,13 @@ static XS (XS_weechat_api_config_option_unset)
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
PERL_RETURN_INT(0);
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
PERL_RETURN_INT(0);
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
option = SvPV (ST (0), PL_na);
@@ -1491,6 +1524,65 @@ static XS (XS_weechat_api_config_option_rename)
PERL_RETURN_OK;
}
/*
* weechat::config_option_is_null: return 1 if value of option is null
*/
static XS (XS_weechat_api_config_option_is_null)
{
int value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
PERL_RETURN_INT(1);
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
PERL_RETURN_INT(1);
}
value = weechat_config_option_is_null (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
PERL_RETURN_INT(value);
}
/*
* weechat::config_option_default_is_null: return 1 if default value of option
* is null
*/
static XS (XS_weechat_api_config_option_default_is_null)
{
int value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
PERL_RETURN_INT(1);
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
PERL_RETURN_INT(1);
}
value = weechat_config_option_default_is_null (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
PERL_RETURN_INT(value);
}
/*
* weechat::config_boolean: return boolean value of option
*/
@@ -1607,6 +1699,38 @@ static XS (XS_weechat_api_config_color)
PERL_RETURN_STRING(result);
}
/*
* weechat::config_write_option: write an option in configuration file
*/
static XS (XS_weechat_api_config_write_option)
{
char *config_file, *option;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
PERL_RETURN_ERROR;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
PERL_RETURN_ERROR;
}
config_file = SvPV (ST (0), PL_na);
option = SvPV (ST (1), PL_na);
weechat_config_write_option (script_str2ptr (config_file),
script_str2ptr (option));
PERL_RETURN_OK;
}
/*
* weechat::config_write_line: write a line in configuration file
*/
@@ -4624,12 +4748,16 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::config_string_to_boolean", XS_weechat_api_config_string_to_boolean, "weechat");
newXS ("weechat::config_option_reset", XS_weechat_api_config_option_reset, "weechat");
newXS ("weechat::config_option_set", XS_weechat_api_config_option_set, "weechat");
newXS ("weechat::config_option_set_null", XS_weechat_api_config_option_set_null, "weechat");
newXS ("weechat::config_option_unset", XS_weechat_api_config_option_unset, "weechat");
newXS ("weechat::config_option_rename", XS_weechat_api_config_option_rename, "weechat");
newXS ("weechat::config_option_is_null", XS_weechat_api_config_option_is_null, "weechat");
newXS ("weechat::config_option_default_is_null", XS_weechat_api_config_option_default_is_null, "weechat");
newXS ("weechat::config_boolean", XS_weechat_api_config_boolean, "weechat");
newXS ("weechat::config_integer", XS_weechat_api_config_integer, "weechat");
newXS ("weechat::config_string", XS_weechat_api_config_string, "weechat");
newXS ("weechat::config_color", XS_weechat_api_config_color, "weechat");
newXS ("weechat::config_write_option", XS_weechat_api_config_write_option, "weechat");
newXS ("weechat::config_write_line", XS_weechat_api_config_write_line, "weechat");
newXS ("weechat::config_write", XS_weechat_api_config_write, "weechat");
newXS ("weechat::config_read", XS_weechat_api_config_read, "weechat");
+147 -8
View File
@@ -1316,7 +1316,7 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args)
char *config_file, *section, *name, *type, *description, *string_values;
char *default_value, *value, *result;
char *function_check_value, *function_change, *function_delete;
int min, max;
int min, max, null_value_allowed;
PyObject *object;
/* make C compiler happy */
@@ -1340,10 +1340,11 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args)
function_change = NULL;
function_delete = NULL;
if (!PyArg_ParseTuple (args, "ssssssiisssss", &config_file, &section, &name,
if (!PyArg_ParseTuple (args, "ssssssiississs", &config_file, &section, &name,
&type, &description, &string_values, &min, &max,
&default_value, &value, &function_check_value,
&function_change, &function_delete))
&default_value, &value, &null_value_allowed,
&function_check_value, &function_change,
&function_delete))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
PYTHON_RETURN_EMPTY;
@@ -1361,6 +1362,7 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args)
max,
default_value,
value,
null_value_allowed,
&weechat_python_api_config_option_check_value_cb,
function_check_value,
&weechat_python_api_config_option_change_cb,
@@ -1489,7 +1491,7 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
PYTHON_RETURN_INT(0);
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = NULL;
@@ -1499,7 +1501,7 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple (args, "ssi", &option, &new_value, &run_callback))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
PYTHON_RETURN_INT(0);
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
rc = weechat_config_option_set (script_str2ptr (option),
@@ -1509,6 +1511,41 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
PYTHON_RETURN_INT(rc);
}
/*
* weechat_python_api_config_option_set_null: set null (undefined) value for
* option
*/
static PyObject *
weechat_python_api_config_option_set_null (PyObject *self, PyObject *args)
{
char *option;
int run_callback, rc;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = NULL;
run_callback = 0;
if (!PyArg_ParseTuple (args, "si", &option, &run_callback))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
rc = weechat_config_option_set_null (script_str2ptr (option),
run_callback);
PYTHON_RETURN_INT(rc);
}
/*
* weechat_python_api_config_option_unset: unset an option
*/
@@ -1525,7 +1562,7 @@ weechat_python_api_config_option_unset (PyObject *self, PyObject *args)
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
PYTHON_RETURN_INT(0);
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
option = NULL;
@@ -1533,7 +1570,7 @@ weechat_python_api_config_option_unset (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple (args, "s", &option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
PYTHON_RETURN_INT(0);
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
rc = weechat_config_option_unset (script_str2ptr (option));
@@ -1574,6 +1611,71 @@ weechat_python_api_config_option_rename (PyObject *self, PyObject *args)
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_config_option_is_null: return 1 if value of option is null
*/
static PyObject *
weechat_python_api_config_option_is_null (PyObject *self, PyObject *args)
{
char *option;
int value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
PYTHON_RETURN_INT(1);
}
option = NULL;
if (!PyArg_ParseTuple (args, "s", &option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
PYTHON_RETURN_INT(1);
}
value = weechat_config_option_is_null (script_str2ptr (option));
PYTHON_RETURN_INT(value);
}
/*
* weechat_python_api_config_option_default_is_null: return 1 if default value
* of option is null
*/
static PyObject *
weechat_python_api_config_option_default_is_null (PyObject *self, PyObject *args)
{
char *option;
int value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
PYTHON_RETURN_INT(1);
}
option = NULL;
if (!PyArg_ParseTuple (args, "s", &option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
PYTHON_RETURN_INT(1);
}
value = weechat_config_option_default_is_null (script_str2ptr (option));
PYTHON_RETURN_INT(value);
}
/*
* weechat_python_api_config_boolean: return boolean value of option
*/
@@ -1702,6 +1804,39 @@ weechat_python_api_config_color (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING(result);
}
/*
* weechat_python_api_config_write_option: write an option in configuration file
*/
static PyObject *
weechat_python_api_config_write_option (PyObject *self, PyObject *args)
{
char *config_file, *option;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
PYTHON_RETURN_ERROR;
}
config_file = NULL;
option = NULL;
if (!PyArg_ParseTuple (args, "ss", &config_file, &option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
PYTHON_RETURN_ERROR;
}
weechat_config_write_option (script_str2ptr (config_file),
script_str2ptr (option));
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_config_write_line: write a line in configuration file
*/
@@ -4911,12 +5046,16 @@ PyMethodDef weechat_python_funcs[] =
{ "config_string_to_boolean", &weechat_python_api_config_string_to_boolean, METH_VARARGS, "" },
{ "config_option_reset", &weechat_python_api_config_option_reset, METH_VARARGS, "" },
{ "config_option_set", &weechat_python_api_config_option_set, METH_VARARGS, "" },
{ "config_option_set_null", &weechat_python_api_config_option_set_null, METH_VARARGS, "" },
{ "config_option_unset", &weechat_python_api_config_option_unset, METH_VARARGS, "" },
{ "config_option_rename", &weechat_python_api_config_option_rename, METH_VARARGS, "" },
{ "config_option_is_null", &weechat_python_api_config_option_is_null, METH_VARARGS, "" },
{ "config_option_default_is_null", &weechat_python_api_config_option_default_is_null, METH_VARARGS, "" },
{ "config_boolean", &weechat_python_api_config_boolean, METH_VARARGS, "" },
{ "config_integer", &weechat_python_api_config_integer, METH_VARARGS, "" },
{ "config_string", &weechat_python_api_config_string, METH_VARARGS, "" },
{ "config_color", &weechat_python_api_config_color, METH_VARARGS, "" },
{ "config_write_option", &weechat_python_api_config_write_option, METH_VARARGS, "" },
{ "config_write_line", &weechat_python_api_config_write_line, METH_VARARGS, "" },
{ "config_write", &weechat_python_api_config_write, METH_VARARGS, "" },
{ "config_read", &weechat_python_api_config_read, METH_VARARGS, "" },
+170 -8
View File
@@ -1477,7 +1477,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
VALUE section, VALUE name, VALUE type,
VALUE description, VALUE string_values,
VALUE min, VALUE max, VALUE default_value,
VALUE value,
VALUE value, VALUE null_value_allowed,
VALUE function_check_value,
VALUE function_change,
VALUE function_delete)
@@ -1485,7 +1485,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
char *c_config_file, *c_section, *c_name, *c_type, *c_description;
char *c_string_values, *c_default_value, *c_value, *result;
char *c_function_check_value, *c_function_change, *c_function_delete;
int c_min, c_max;
int c_min, c_max, c_null_value_allowed;
VALUE return_value;
/* make C compiler happy */
@@ -1507,13 +1507,14 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
c_max = 0;
c_default_value = NULL;
c_value = NULL;
c_null_value_allowed = 0;
c_function_check_value = NULL;
c_function_change = NULL;
c_function_delete = NULL;
if (NIL_P (config_file) || NIL_P (section) || NIL_P (name) || NIL_P (type)
|| NIL_P (description) || NIL_P (string_values)
|| NIL_P (default_value) || NIL_P (value)
|| NIL_P (default_value) || NIL_P (value) || NIL_P (null_value_allowed)
|| NIL_P (function_check_value) || NIL_P (function_change)
|| NIL_P (function_delete))
{
@@ -1531,6 +1532,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
Check_Type (max, T_FIXNUM);
Check_Type (default_value, T_STRING);
Check_Type (value, T_STRING);
Check_Type (null_value_allowed, T_FIXNUM);
Check_Type (function_check_value, T_STRING);
Check_Type (function_change, T_STRING);
Check_Type (function_delete, T_STRING);
@@ -1545,6 +1547,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
c_max = FIX2INT (max);
c_default_value = STR2CSTR (default_value);
c_value = STR2CSTR (value);
c_null_value_allowed = FIX2INT (null_value_allowed);
c_function_check_value = STR2CSTR (function_check_value);
c_function_change = STR2CSTR (function_change);
c_function_delete = STR2CSTR (function_delete);
@@ -1561,6 +1564,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
c_max,
c_default_value,
c_value,
c_null_value_allowed,
&weechat_ruby_api_config_option_check_value_cb,
c_function_check_value,
&weechat_ruby_api_config_option_change_cb,
@@ -1710,7 +1714,7 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
RUBY_RETURN_INT(0);
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
c_option = NULL;
@@ -1720,7 +1724,7 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
if (NIL_P (option) || NIL_P (new_value) || NIL_P (run_callback))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
RUBY_RETURN_INT(0);
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
Check_Type (option, T_STRING);
@@ -1738,6 +1742,48 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
RUBY_RETURN_INT(rc);
}
/*
* weechat_ruby_api_config_option_set_null: set null (undefined) value for
* option
*/
static VALUE
weechat_ruby_api_config_option_set_null (VALUE class, VALUE option,
VALUE run_callback)
{
char *c_option;
int c_run_callback, rc;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
c_option = NULL;
c_run_callback = 0;
if (NIL_P (option) || NIL_P (run_callback))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
Check_Type (option, T_STRING);
Check_Type (run_callback, T_FIXNUM);
c_option = STR2CSTR (option);
c_run_callback = FIX2INT (run_callback);
rc = weechat_config_option_set_null (script_str2ptr (c_option),
c_run_callback);
RUBY_RETURN_INT(rc);
}
/*
* weechat_ruby_api_config_option_unset: unset an option
*/
@@ -1754,7 +1800,7 @@ weechat_ruby_api_config_option_unset (VALUE class, VALUE option)
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
RUBY_RETURN_INT(0);
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
c_option = NULL;
@@ -1762,7 +1808,7 @@ weechat_ruby_api_config_option_unset (VALUE class, VALUE option)
if (NIL_P (option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
RUBY_RETURN_INT(0);
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
Check_Type (option, T_STRING);
@@ -1814,6 +1860,78 @@ weechat_ruby_api_config_option_rename (VALUE class, VALUE option,
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_config_option_is_null: return 1 if value of option is null
*/
static VALUE
weechat_ruby_api_config_option_is_null (VALUE class, VALUE option)
{
char *c_option;
int value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
RUBY_RETURN_INT(1);
}
c_option = NULL;
if (NIL_P (option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
RUBY_RETURN_INT(1);
}
Check_Type (option, T_STRING);
c_option = STR2CSTR (option);
value = weechat_config_option_is_null (script_str2ptr (c_option));
RUBY_RETURN_INT(value);
}
/*
* weechat_ruby_api_config_option_default_is_null: return 1 if value of option is null
*/
static VALUE
weechat_ruby_api_config_option_default_is_null (VALUE class, VALUE option)
{
char *c_option;
int value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
RUBY_RETURN_INT(1);
}
c_option = NULL;
if (NIL_P (option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
RUBY_RETURN_INT(1);
}
Check_Type (option, T_STRING);
c_option = STR2CSTR (option);
value = weechat_config_option_default_is_null (script_str2ptr (c_option));
RUBY_RETURN_INT(value);
}
/*
* weechat_ruby_api_config_boolean: return boolean value of option
*/
@@ -1958,6 +2076,46 @@ weechat_ruby_api_config_color (VALUE class, VALUE option)
RUBY_RETURN_STRING(result);
}
/*
* weechat_ruby_api_config_write_option: write an option in configuration file
*/
static VALUE
weechat_ruby_api_config_write_option (VALUE class, VALUE config_file,
VALUE option)
{
char *c_config_file, *c_option;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
RUBY_RETURN_ERROR;
}
c_config_file = NULL;
c_option = NULL;
if (NIL_P (config_file) || NIL_P (option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
RUBY_RETURN_ERROR;
}
Check_Type (config_file, T_STRING);
Check_Type (option, T_STRING);
c_config_file = STR2CSTR (config_file);
c_option = STR2CSTR (option);
weechat_config_write_option (script_str2ptr (c_config_file),
script_str2ptr (c_option));
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_config_write_line: write a line in configuration file
*/
@@ -5636,17 +5794,21 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
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, 9);
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, 13);
rb_define_module_function (ruby_mWeechat, "config_new_option", &weechat_ruby_api_config_new_option, 14);
rb_define_module_function (ruby_mWeechat, "config_search_option", &weechat_ruby_api_config_search_option, 3);
rb_define_module_function (ruby_mWeechat, "config_string_to_boolean", &weechat_ruby_api_config_string_to_boolean, 1);
rb_define_module_function (ruby_mWeechat, "config_option_reset", &weechat_ruby_api_config_option_reset, 2);
rb_define_module_function (ruby_mWeechat, "config_option_set", &weechat_ruby_api_config_option_set, 3);
rb_define_module_function (ruby_mWeechat, "config_option_set_null", &weechat_ruby_api_config_option_set_null, 2);
rb_define_module_function (ruby_mWeechat, "config_option_unset", &weechat_ruby_api_config_option_unset, 1);
rb_define_module_function (ruby_mWeechat, "config_option_rename", &weechat_ruby_api_config_option_rename, 2);
rb_define_module_function (ruby_mWeechat, "config_option_is_null", &weechat_ruby_api_config_option_is_null, 1);
rb_define_module_function (ruby_mWeechat, "config_option_default_is_null", &weechat_ruby_api_config_option_default_is_null, 1);
rb_define_module_function (ruby_mWeechat, "config_boolean", &weechat_ruby_api_config_boolean, 1);
rb_define_module_function (ruby_mWeechat, "config_integer", &weechat_ruby_api_config_integer, 1);
rb_define_module_function (ruby_mWeechat, "config_string", &weechat_ruby_api_config_string, 1);
rb_define_module_function (ruby_mWeechat, "config_color", &weechat_ruby_api_config_color, 1);
rb_define_module_function (ruby_mWeechat, "config_write_option", &weechat_ruby_api_config_write_option, 2);
rb_define_module_function (ruby_mWeechat, "config_write_line", &weechat_ruby_api_config_write_line, 3);
rb_define_module_function (ruby_mWeechat, "config_write", &weechat_ruby_api_config_write, 1);
rb_define_module_function (ruby_mWeechat, "config_read", &weechat_ruby_api_config_read, 1);
+2
View File
@@ -347,6 +347,7 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
int min, int max,
const char *default_value,
const char *value,
int null_value_allowed,
void (*callback_check_value)(void *data,
struct t_config_option *option,
const char *value),
@@ -416,6 +417,7 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
new_option = weechat_config_new_option (config_file, section, name, type,
description, string_values, min,
max, default_value, value,
null_value_allowed,
callback1, new_script_callback1,
callback2, new_script_callback2,
callback3, new_script_callback3);
+1
View File
@@ -68,6 +68,7 @@ extern struct t_config_option *script_api_config_new_option (struct t_weechat_pl
int min, int max,
const char *default_value,
const char *value,
int null_value_allowed,
void (*callback_check_value)(void *data,
struct t_config_option *option,
const char *value),
+165 -18
View File
@@ -1458,10 +1458,6 @@ weechat_tcl_api_config_option_delete_cb (void *data,
}
}
/*
* weechat_tcl_api_config_new_option: create a new option in section
*/
@@ -1474,7 +1470,7 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
char *result, *config_file, *section, *name, *type;
char *description, *string_values, *default_value, *value;
char *function_check_value, *function_change, *function_delete;
int i,min,max;
int i, min, max, null_value_allowed;
/* make C compiler happy */
(void) clientData;
@@ -1485,14 +1481,15 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_EMPTY;
}
if (objc < 14)
if (objc < 15)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
TCL_RETURN_EMPTY;
}
if ((Tcl_GetIntFromObj (interp, objv[7], &min) != TCL_OK)
|| (Tcl_GetIntFromObj (interp, objv[8], &max) != TCL_OK))
|| (Tcl_GetIntFromObj (interp, objv[8], &max) != TCL_OK)
|| (Tcl_GetIntFromObj (interp, objv[11], &null_value_allowed) != TCL_OK))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
TCL_RETURN_EMPTY;
@@ -1506,9 +1503,9 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
string_values = Tcl_GetStringFromObj (objv[6], &i);
default_value = Tcl_GetStringFromObj (objv[9], &i);
value = Tcl_GetStringFromObj (objv[10], &i);
function_check_value = Tcl_GetStringFromObj (objv[11], &i);
function_change = Tcl_GetStringFromObj (objv[12], &i);
function_delete = Tcl_GetStringFromObj (objv[13], &i);
function_check_value = Tcl_GetStringFromObj (objv[12], &i);
function_change = Tcl_GetStringFromObj (objv[13], &i);
function_delete = Tcl_GetStringFromObj (objv[14], &i);
result = script_ptr2str (script_api_config_new_option (weechat_tcl_plugin,
tcl_current_script,
@@ -1522,6 +1519,7 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
max,
default_value,
value,
null_value_allowed,
&weechat_tcl_api_config_option_check_value_cb,
function_check_value,
&weechat_tcl_api_config_option_change_cb,
@@ -1653,7 +1651,7 @@ weechat_tcl_api_config_option_set (ClientData clientData, Tcl_Interp *interp,
Tcl_Obj* objp;
int rc;
char *option, *new_value;
int i,run_cb;
int i, run_callback;
/* make C compiler happy */
(void) clientData;
@@ -1661,26 +1659,67 @@ weechat_tcl_api_config_option_set (ClientData clientData, Tcl_Interp *interp,
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
TCL_RETURN_INT(0);
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
if (objc < 4)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
TCL_RETURN_INT(0);
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
if (Tcl_GetIntFromObj (interp, objv[3], &run_cb) != TCL_OK)
if (Tcl_GetIntFromObj (interp, objv[3], &run_callback) != TCL_OK)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
TCL_RETURN_INT(0);
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = Tcl_GetStringFromObj (objv[1], &i);
new_value = Tcl_GetStringFromObj (objv[2], &i);
rc = weechat_config_option_set (script_str2ptr (option),
new_value,
run_cb); /* run_callback */
run_callback);
TCL_RETURN_INT(rc);
}
/*
* weechat_tcl_api_config_option_set_null: set null (undefined)value for option
*/
static int
weechat_tcl_api_config_option_set_null (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
int rc;
char *option;
int i, run_callback;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
if (Tcl_GetIntFromObj (interp, objv[2], &run_callback) != TCL_OK)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
option = Tcl_GetStringFromObj (objv[1], &i);
rc = weechat_config_option_set_null (script_str2ptr (option),
run_callback);
TCL_RETURN_INT(rc);
}
@@ -1704,13 +1743,13 @@ weechat_tcl_api_config_option_unset (ClientData clientData, Tcl_Interp *interp,
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
TCL_RETURN_INT(0);
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
if (objc < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
TCL_RETURN_INT(0);
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
}
option = Tcl_GetStringFromObj (objv[1], &i);
@@ -1748,12 +1787,77 @@ weechat_tcl_api_config_option_rename (ClientData clientData, Tcl_Interp *interp,
option = Tcl_GetStringFromObj (objv[1], &i);
new_name = Tcl_GetStringFromObj (objv[2], &i);
weechat_config_option_rename (script_str2ptr (option),
new_name);
TCL_RETURN_OK;
}
/*
* weechat_tcl_api_config_option_is_null: return 1 if value of option is null
*/
static int
weechat_tcl_api_config_option_is_null (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
int result, i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
TCL_RETURN_INT(1);
}
if (objc < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
TCL_RETURN_INT(1);
}
result = weechat_config_option_is_null (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i))); /* option */
TCL_RETURN_INT(result);
}
/*
* weechat_tcl_api_config_option_default_is_null: return 1 if default value of
* option is null
*/
static int
weechat_tcl_api_config_option_default_is_null (ClientData clientData,
Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
int result, i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
TCL_RETURN_INT(1);
}
if (objc < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
TCL_RETURN_INT(1);
}
result = weechat_config_option_default_is_null (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i))); /* option */
TCL_RETURN_INT(result);
}
/*
* weechat_tcl_api_config_boolean: return boolean value of option
*/
@@ -1880,6 +1984,41 @@ weechat_tcl_api_config_color (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING(result);
}
/*
* weechat_tcl_api_config_write_option: write an option in configuration file
*/
static int
weechat_tcl_api_config_write_option (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *config_file, *option;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
TCL_RETURN_ERROR;
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
TCL_RETURN_ERROR;
}
config_file = Tcl_GetStringFromObj (objv[1], &i);
option = Tcl_GetStringFromObj (objv[2], &i);
weechat_config_write_option (script_str2ptr (config_file),
script_str2ptr (option));
TCL_RETURN_OK;
}
/*
* weechat_tcl_api_config_write_line: write a line in configuration file
*/
@@ -5324,10 +5463,16 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
weechat_tcl_api_config_option_reset, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_option_set",
weechat_tcl_api_config_option_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_option_set_null",
weechat_tcl_api_config_option_set_null, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_option_unset",
weechat_tcl_api_config_option_unset, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_option_rename",
weechat_tcl_api_config_option_rename, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_option_is_null",
weechat_tcl_api_config_option_is_null, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_option_default_is_null",
weechat_tcl_api_config_option_default_is_null, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_boolean",
weechat_tcl_api_config_boolean, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_integer",
@@ -5336,6 +5481,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
weechat_tcl_api_config_string, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_color",
weechat_tcl_api_config_color, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_write_option",
weechat_tcl_api_config_write_option, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_write_line",
weechat_tcl_api_config_write_line, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::config_write",
+32
View File
@@ -60,6 +60,9 @@ struct t_weelist;
#define WEECHAT_CONFIG_WRITE_ERROR -1
#define WEECHAT_CONFIG_WRITE_MEMORY_ERROR -2
/* null value for option */
#define WEECHAT_CONFIG_OPTION_NULL "null"
/* return codes for config option set */
#define WEECHAT_CONFIG_OPTION_SET_OK_CHANGED 2
#define WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE 1
@@ -254,6 +257,7 @@ struct t_weechat_plugin
int max,
const char *default_value,
const char *value,
int null_value_allowed,
int (*callback_check_value)(void *data,
struct t_config_option *option,
const char *value),
@@ -282,15 +286,25 @@ struct t_weechat_plugin
int run_callback);
int (*config_option_set) (struct t_config_option *option,
const char *value, int run_callback);
int (*config_option_set_null) (struct t_config_option *option,
int run_callback);
int (*config_option_unset) (struct t_config_option *option);
void (*config_option_rename) (struct t_config_option *option,
const char *new_name);
void *(*config_option_get_pointer) (struct t_config_option *option,
const char *property);
int (*config_option_is_null) (struct t_config_option *option);
int (*config_option_default_is_null) (struct t_config_option *option);
int (*config_boolean) (struct t_config_option *option);
int (*config_boolean_default) (struct t_config_option *option);
int (*config_integer) (struct t_config_option *option);
int (*config_integer_default) (struct t_config_option *option);
const char *(*config_string) (struct t_config_option *option);
const char *(*config_string_default) (struct t_config_option *option);
const char *(*config_color) (struct t_config_option *option);
const char *(*config_color_default) (struct t_config_option *option);
void (*config_write_option) (struct t_config_file *config_file,
struct t_config_option *option);
void (*config_write_line) (struct t_config_file *config_file,
const char *option_name,
const char *value, ...);
@@ -761,6 +775,7 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_config_new_option(__config, __section, __name, __type, \
__desc, __string_values, __min, \
__max, __default, __value, \
__null_value_allowed, \
__callback_check, \
__callback_check_data, \
__callback_change, \
@@ -770,6 +785,7 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->config_new_option(__config, __section, __name, \
__type, __desc, __string_values, \
__min, __max, __default, __value, \
__null_value_allowed, \
__callback_check, \
__callback_check_data, \
__callback_change, \
@@ -797,20 +813,36 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_config_option_set(__option, __value, __run_callback) \
weechat_plugin->config_option_set(__option, __value, \
__run_callback)
#define weechat_config_option_set_null(__option, __run_callback) \
weechat_plugin->config_option_set_null(__option, __run_callback)
#define weechat_config_option_unset(__option) \
weechat_plugin->config_option_unset(__option)
#define weechat_config_option_rename(__option, __new_name) \
weechat_plugin->config_option_rename(__option, __new_name)
#define weechat_config_option_get_pointer(__option, __property) \
weechat_plugin->config_option_get_pointer(__option, __property)
#define weechat_config_option_is_null(__option) \
weechat_plugin->config_option_is_null(__option)
#define weechat_config_option_default_is_null(__option) \
weechat_plugin->config_option_default_is_null(__option)
#define weechat_config_boolean(__option) \
weechat_plugin->config_boolean(__option)
#define weechat_config_boolean_default(__option) \
weechat_plugin->config_boolean_default(__option)
#define weechat_config_integer(__option) \
weechat_plugin->config_integer(__option)
#define weechat_config_integer_default(__option) \
weechat_plugin->config_integer_default(__option)
#define weechat_config_string(__option) \
weechat_plugin->config_string(__option)
#define weechat_config_string_default(__option) \
weechat_plugin->config_string_default(__option)
#define weechat_config_color(__option) \
weechat_plugin->config_color(__option)
#define weechat_config_color_default(__option) \
weechat_plugin->config_color_default(__option)
#define weechat_config_write_option(__config, __option) \
weechat_plugin->config_write_option(__config, __option)
#define weechat_config_write_line(__config, __option, __value...) \
weechat_plugin->config_write_line(__config, __option, ##__value)
#define weechat_config_write(__config) \
+25 -25
View File
@@ -124,12 +124,12 @@ xfer_config_init ()
"auto_open_buffer", "boolean",
N_("auto open xfer buffer when a new xfer is added "
"to list"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_look_progress_bar_size = weechat_config_new_option (
xfer_config_file, ptr_section,
"progress_bar_size", "integer",
N_("size of progress bar, in chars (if 0, progress bar is disabled)"),
NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20", NULL,
NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (xfer_config_file, "color",
@@ -147,55 +147,55 @@ xfer_config_init ()
xfer_config_file, ptr_section,
"text", "color",
N_("text color"),
NULL, 0, 0, "default", NULL,
NULL, 0, 0, "default", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_text_bg = weechat_config_new_option (
xfer_config_file, ptr_section,
"text_bg", "color",
N_("background color"),
NULL, 0, 0, "default", NULL,
NULL, 0, 0, "default", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_text_selected = weechat_config_new_option (
xfer_config_file, ptr_section,
"text_selected", "color",
N_("text color of selected xfer line"),
NULL, 0, 0, "white", NULL,
NULL, 0, 0, "white", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_WAITING] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_waiting", "color",
N_("text color for \"waiting\" status"),
NULL, 0, 0, "lightcyan", NULL,
NULL, 0, 0, "lightcyan", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_CONNECTING] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_connecting", "color",
N_("text color for \"connecting\" status"),
NULL, 0, 0, "yellow", NULL,
NULL, 0, 0, "yellow", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_ACTIVE] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_active", "color",
N_("text color for \"active\" status"),
NULL, 0, 0, "lightblue", NULL,
NULL, 0, 0, "lightblue", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_DONE] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_done", "color",
N_("text color for \"done\" status"),
NULL, 0, 0, "lightgreen", NULL,
NULL, 0, 0, "lightgreen", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_FAILED] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_failed", "color",
N_("text color for \"failed\" status"),
NULL, 0, 0, "lightred", NULL,
NULL, 0, 0, "lightred", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
xfer_config_color_status[XFER_STATUS_ABORTED] = weechat_config_new_option (
xfer_config_file, ptr_section,
"status_aborted", "color",
N_("text color for \"aborted\" status"),
NULL, 0, 0, "lightred", NULL,
NULL, 0, 0, "lightred", NULL, 0,
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (xfer_config_file, "network",
@@ -213,37 +213,37 @@ xfer_config_init ()
xfer_config_file, ptr_section,
"timeout", "integer",
N_("timeout for xfer request (in seconds)"),
NULL, 5, INT_MAX, "300", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 5, INT_MAX, "300", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_blocksize = weechat_config_new_option (
xfer_config_file, ptr_section,
"blocksize", "integer",
N_("block size for sending packets, in bytes"),
NULL, XFER_BLOCKSIZE_MIN, XFER_BLOCKSIZE_MAX, "65536", NULL,
NULL, XFER_BLOCKSIZE_MIN, XFER_BLOCKSIZE_MAX, "65536", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_fast_send = weechat_config_new_option (
xfer_config_file, ptr_section,
"fast_send", "boolean",
N_("does not wait for ACK when sending file"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_port_range = weechat_config_new_option (
xfer_config_file, ptr_section,
"port_range", "string",
N_("restricts outgoing files/chats 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, NULL, NULL, NULL, NULL);
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_own_ip = weechat_config_new_option (
xfer_config_file, ptr_section,
"own_ip", "string",
N_("IP or DNS address used for sending files/chats "
"(if empty, local interface IP is used)"),
NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_network_speed_limit = weechat_config_new_option (
xfer_config_file, ptr_section,
"speed_limit", "integer",
N_("speed limit for sending files, in kilo-bytes by second (0 means "
"no limit)"),
NULL, 0, INT_MAX, "0", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (xfer_config_file, "file",
0, 0,
@@ -260,44 +260,44 @@ xfer_config_init ()
xfer_config_file, ptr_section,
"download_path", "string",
N_("path for writing incoming files"),
NULL, 0, 0, "%h/xfer", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "%h/xfer", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_upload_path = weechat_config_new_option (
xfer_config_file, ptr_section,
"upload_path", "string",
N_("path for reading files when sending (when no path is "
"specified by user)"),
NULL, 0, 0, "~", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "~", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_use_nick_in_filename = weechat_config_new_option (
xfer_config_file, ptr_section,
"use_nick_in_filename", "boolean",
N_("use remote nick as prefix in local filename when receiving a file"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_convert_spaces = weechat_config_new_option (
xfer_config_file, ptr_section,
"convert_spaces", "boolean",
N_("convert spaces to underscores when sending files"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_rename = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_rename", "boolean",
N_("rename incoming files if already exists (add '.1', '.2', ...)"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_resume = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_resume", "boolean",
N_("automatically resume file transfer if connection with remote host "
"is lost"),
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_accept_files = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_accept_files", "boolean",
N_("automatically accept incoming files (use carefully!)"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
xfer_config_file_auto_accept_chats = weechat_config_new_option (
xfer_config_file, ptr_section,
"auto_accept_chats", "boolean",
N_("automatically accept chat requests (use carefully!)"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
return 1;
}