mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
Fix IRC /server command, fix bugs with IRC servers options, remove temporary server feature
This commit is contained in:
+112
-169
@@ -525,7 +525,8 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
struct t_irc_server server_tmp;
|
||||
int i, nb_connect, connect_ok, all_servers, no_join, port, ipv6, ssl;
|
||||
char *error;
|
||||
int default_ipv6, default_ssl;
|
||||
char *error, value[16];
|
||||
long number;
|
||||
|
||||
IRC_GET_SERVER(buffer);
|
||||
@@ -599,15 +600,19 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
else
|
||||
{
|
||||
irc_server_init (&server_tmp);
|
||||
server_tmp.name = strdup (argv[i]);
|
||||
|
||||
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,
|
||||
1, /* temp server */
|
||||
server_tmp.addresses,
|
||||
server_tmp.ipv6,
|
||||
server_tmp.ssl,
|
||||
@@ -623,13 +628,35 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
if (ptr_server)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s: server %s%s%s created "
|
||||
"(temporary server, "
|
||||
"NOT SAVED!)"),
|
||||
_("%s: server %s%s%s created"),
|
||||
"irc",
|
||||
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_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;
|
||||
}
|
||||
@@ -2518,9 +2545,12 @@ 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;
|
||||
int i, detailed_list, one_server_found, length;
|
||||
int default_autoconnect, default_ipv6, default_ssl;
|
||||
struct t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
|
||||
char *server_name;
|
||||
char *server_name, *mask, value[16];
|
||||
struct t_infolist *infolist;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -2638,14 +2668,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/* TODO: fix server command */
|
||||
weechat_printf (NULL,
|
||||
"%sSome server options are temporarirly disabled in "
|
||||
"this version, you can use /set irc.server.xxxx.yyyy = zzzz "
|
||||
"and /reload command to reload options from irc.conf",
|
||||
weechat_prefix ("error"));
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "add") == 0)
|
||||
{
|
||||
if (argc < 4)
|
||||
@@ -2663,6 +2685,10 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
/* 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]);
|
||||
@@ -2672,8 +2698,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
{
|
||||
if (weechat_strcasecmp (argv[i], "-temp") == 0)
|
||||
server_tmp.temp_server = 1;
|
||||
if (weechat_strcasecmp (argv[i], "-auto") == 0)
|
||||
server_tmp.autoconnect = 1;
|
||||
if (weechat_strcasecmp (argv[i], "-noauto") == 0)
|
||||
@@ -2682,76 +2706,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
server_tmp.ipv6 = 1;
|
||||
if (weechat_strcasecmp (argv[i], "-ssl") == 0)
|
||||
server_tmp.ssl = 1;
|
||||
if (weechat_strcasecmp (argv[i], "-pwd") == 0)
|
||||
{
|
||||
if (i == (argc - 1))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: missing argument for "
|
||||
"\"%s\" option"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
"-pwd");
|
||||
irc_server_free_data (&server_tmp);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
server_tmp.password = strdup (argv[++i]);
|
||||
}
|
||||
if (weechat_strcasecmp (argv[i], "-nicks") == 0)
|
||||
{
|
||||
if (i == (argc - 1))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: missing argument for "
|
||||
"\"%s\" option"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
"-nicks");
|
||||
irc_server_free_data (&server_tmp);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
server_tmp.nicks = strdup (argv[++i]);
|
||||
}
|
||||
if (weechat_strcasecmp (argv[i], "-username") == 0)
|
||||
{
|
||||
if (i == (argc - 1))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: missing argument for "
|
||||
"\"%s\" option"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
"-username");
|
||||
irc_server_free_data (&server_tmp);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
server_tmp.username = strdup (argv[++i]);
|
||||
}
|
||||
if (weechat_strcasecmp (argv[i], "-realname") == 0)
|
||||
{
|
||||
if (i == (argc - 1))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: missing argument for "
|
||||
"\"%s\" option"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
"-realname");
|
||||
irc_server_free_data (&server_tmp);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
server_tmp.realname = strdup (argv[++i]);
|
||||
}
|
||||
if (weechat_strcasecmp (argv[i], "-autojoin") == 0)
|
||||
{
|
||||
if (i == (argc - 1))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: missing argument for "
|
||||
"\"%s\" option"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
"-autojoin");
|
||||
irc_server_free_data (&server_tmp);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
server_tmp.autojoin = strdup (argv[++i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2760,7 +2714,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
server_tmp.autoconnect,
|
||||
server_tmp.autoreconnect,
|
||||
server_tmp.autoreconnect_delay,
|
||||
server_tmp.temp_server,
|
||||
server_tmp.addresses,
|
||||
server_tmp.ipv6,
|
||||
server_tmp.ssl,
|
||||
@@ -2781,6 +2734,38 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
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
|
||||
{
|
||||
@@ -2842,56 +2827,12 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
IRC_COLOR_CHAT,
|
||||
IRC_COLOR_CHAT_SERVER,
|
||||
argv[3]);
|
||||
//gui_window_redraw_all_buffers ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "keep") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
|
||||
}
|
||||
|
||||
/* look for server by name */
|
||||
server_found = irc_server_search (argv[2]);
|
||||
if (!server_found)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: server \"%s\" not found for "
|
||||
"\"%s\" command"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
argv[2], "server keep");
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/* check that it is temporary server */
|
||||
if (!server_found->temp_server)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: server \"%s\" is not a temporary "
|
||||
"server"),
|
||||
weechat_prefix ("error"), "irc", argv[2]);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/* remove temporary flag on server */
|
||||
server_found->temp_server = 0;
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: server %s%s%s is not temporary any "
|
||||
"more"),
|
||||
"irc",
|
||||
IRC_COLOR_CHAT_SERVER,
|
||||
argv[2],
|
||||
IRC_COLOR_CHAT);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (weechat_strcasecmp (argv[1], "del") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
@@ -2919,24 +2860,29 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_prefix ("error"), "irc",
|
||||
argv[2], argv[2]);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if ((ptr_buffer->protocol == irc_protocol)
|
||||
&& (IRC_BUFFER_SERVER(ptr_buffer) == server_found))
|
||||
{
|
||||
IRC_BUFFER_SERVER(ptr_buffer) = NULL;
|
||||
IRC_BUFFER_CHANNEL(ptr_buffer) = NULL;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
server_name = strdup (server_found->name);
|
||||
|
||||
irc_server_free (server_found);
|
||||
/* 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 ("options", 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);
|
||||
}
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: Server %s%s%s has been deleted"),
|
||||
@@ -2947,8 +2893,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
if (server_name)
|
||||
free (server_name);
|
||||
|
||||
//gui_window_redraw_buffer (window->buffer);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -2966,10 +2910,11 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
"irc");
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unknown option for \"%s\" command"),
|
||||
weechat_prefix ("error"), "irc", "server");
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
@@ -3593,8 +3538,7 @@ irc_command_init ()
|
||||
"servername: internal server name to connect\n"
|
||||
" -nojoin: do not join any channel (even if "
|
||||
"autojoin is enabled on server)\n"
|
||||
" hostname: hostname to connect, creating "
|
||||
"temporary server\n"
|
||||
" hostname: hostname to connect\n"
|
||||
" port: port for server (integer, default "
|
||||
"is 6667)\n"
|
||||
" ipv6: use IPv6 protocol\n"
|
||||
@@ -3857,14 +3801,11 @@ irc_command_init ()
|
||||
weechat_hook_command ("server",
|
||||
N_("list, add or remove servers"),
|
||||
N_("[list [servername]] | [listfull [servername]] | "
|
||||
"[add servername hostname[/port] [-temp] "
|
||||
"[-auto | -noauto] [-ipv6] [-ssl] [-pwd password] "
|
||||
"[-nicks nick1,nick2,...] [-username username] "
|
||||
"[-realname realname] "
|
||||
"[-autojoin channel[,channel]] ] | "
|
||||
"[add servername hostname[/port] "
|
||||
"[-auto | -noauto] [-ipv6] [-ssl]] | "
|
||||
"[copy servername newservername] | "
|
||||
"[rename servername newservername] | "
|
||||
"[keep servername] | [del servername]"),
|
||||
"[del servername]"),
|
||||
N_(" list: list servers (no parameter implies "
|
||||
"this list)\n"
|
||||
" listfull: list servers with detailed info for "
|
||||
@@ -3874,27 +3815,29 @@ irc_command_init ()
|
||||
"display use\n"
|
||||
" hostname: name or IP address of server, with "
|
||||
"optional port (default: 6667)\n"
|
||||
" temp: create temporary server (not saved "
|
||||
"in config file)\n"
|
||||
" auto: automatically connect to server "
|
||||
"when WeeChat starts\n"
|
||||
" noauto: do not connect to server when "
|
||||
"WeeChat starts (default)\n"
|
||||
" ipv6: use IPv6 protocol\n"
|
||||
" ssl: use SSL protocol\n"
|
||||
" password: password for server\n"
|
||||
"nick1,2,..: nicknames for server\n"
|
||||
" username: user name\n"
|
||||
" realname: real name of user\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 sending)"),
|
||||
"add|copy|rename|keep|del|deloutq|list|listfull "
|
||||
"WeeChat is currently sending)\n\n"
|
||||
"Examples:\n"
|
||||
" /server listfull\n"
|
||||
" /server add oftc irc.oftc.net/6697 -ssl\n"
|
||||
" /server add oftc6 irc6.oftc.net/6697 -ipv6 -ssl\n"
|
||||
" /server add freenode2 chat.eu.freenode.net/6697,"
|
||||
"chat.us.freenode.net/6667\n"
|
||||
" /server copy oftc oftcbis\n"
|
||||
" /server rename oftc newoftc\n"
|
||||
" /server del freenode\n"
|
||||
" /server deloutq"),
|
||||
"add|copy|rename|del|deloutq|list|listfull "
|
||||
"%(irc_servers) %(irc_servers)",
|
||||
&irc_command_server, NULL);
|
||||
weechat_hook_command ("servlist",
|
||||
|
||||
@@ -120,7 +120,7 @@ irc_config_get_server_from_option_name (const char *name)
|
||||
|
||||
if (name)
|
||||
{
|
||||
pos_option = strchr (name, '.');
|
||||
pos_option = strrchr (name, '.');
|
||||
if (pos_option)
|
||||
{
|
||||
server_name = weechat_strndup (name, pos_option - name);
|
||||
@@ -343,20 +343,21 @@ irc_config_reload_servers_from_config ()
|
||||
struct t_infolist *infolist;
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_config_option *ptr_option;
|
||||
char *name, *full_name, *server_name, *pos_option;
|
||||
char *full_name, *option_name, *server_name, *pos_option;
|
||||
int i, index_option;
|
||||
|
||||
infolist = weechat_infolist_get ("options", NULL, "irc.server.*");
|
||||
while (weechat_infolist_next (infolist))
|
||||
{
|
||||
name = weechat_infolist_string (infolist, "name");
|
||||
full_name = weechat_infolist_string (infolist, "full_name");
|
||||
if (name && full_name)
|
||||
option_name = weechat_infolist_string (infolist, "option_name");
|
||||
if (full_name && option_name)
|
||||
{
|
||||
pos_option = strchr (name, '.');
|
||||
pos_option = strrchr (option_name, '.');
|
||||
if (pos_option)
|
||||
{
|
||||
server_name = weechat_strndup (name, pos_option - name);
|
||||
server_name = weechat_strndup (option_name,
|
||||
pos_option - option_name);
|
||||
if (server_name)
|
||||
{
|
||||
pos_option++;
|
||||
@@ -502,7 +503,8 @@ struct t_config_option *
|
||||
irc_config_server_new_option (struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
int index_option,
|
||||
const char *option_name, const char *value,
|
||||
const char *option_name,
|
||||
const char *value,
|
||||
void *callback_change,
|
||||
void *callback_change_data,
|
||||
void *callback_delete,
|
||||
@@ -682,7 +684,7 @@ irc_config_server_create_option (void *data, struct t_config_file *config_file,
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
pos_option = strchr (option_name, '.');
|
||||
pos_option = strrchr (option_name, '.');
|
||||
if (pos_option)
|
||||
{
|
||||
server_name = weechat_strndup (option_name,
|
||||
|
||||
@@ -58,7 +58,9 @@ enum t_irc_config_server_option
|
||||
|
||||
|
||||
extern char *irc_config_server_option_string[];
|
||||
extern struct t_config_file *irc_config;
|
||||
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;
|
||||
|
||||
extern struct t_config_option *irc_config_look_one_server_buffer;
|
||||
extern struct t_config_option *irc_config_look_open_near_server;
|
||||
@@ -89,6 +91,20 @@ extern struct t_config_option *irc_config_log_hide_nickserv_pwd;
|
||||
|
||||
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,
|
||||
struct t_config_option *option);
|
||||
struct t_config_option *irc_config_server_new_option (struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
int index_option,
|
||||
const char *option_name,
|
||||
const char *value,
|
||||
void *callback_change,
|
||||
void *callback_change_data,
|
||||
void *callback_delete,
|
||||
void *callback_delete_data);
|
||||
extern int irc_config_init ();
|
||||
extern int irc_config_read ();
|
||||
extern int irc_config_write ();
|
||||
|
||||
@@ -166,10 +166,8 @@ irc_display_server (struct t_irc_server *server, int with_detail)
|
||||
_("connected") : _("not connected"),
|
||||
IRC_COLOR_CHAT_DELIMITERS);
|
||||
|
||||
weechat_printf (NULL, " autoconnect . . . . : %s%s",
|
||||
(server->autoconnect) ? _("on") : _("off"),
|
||||
(server->temp_server) ?
|
||||
_(" (temporary server, will not be saved)") : "");
|
||||
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",
|
||||
@@ -228,7 +226,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%s, %d %s, %d pv",
|
||||
weechat_printf (NULL, " %s %s%s %s[%s%s%s]%s, %d %s, %d pv",
|
||||
(server->is_connected) ? "*" : " ",
|
||||
IRC_COLOR_CHAT_SERVER,
|
||||
server->name,
|
||||
@@ -238,20 +236,16 @@ 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),
|
||||
NG_("channel", "channels", num_channels),
|
||||
num_pv);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL, " %s %s%s%s%s",
|
||||
weechat_printf (NULL, " %s %s%s",
|
||||
(server->is_connected) ? "*" : " ",
|
||||
IRC_COLOR_CHAT_SERVER,
|
||||
server->name,
|
||||
IRC_COLOR_CHAT,
|
||||
(server->temp_server) ? _(" (temporary)") : "");
|
||||
server->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+219
-44
@@ -48,6 +48,57 @@ struct t_irc_message *irc_recv_msgq = NULL;
|
||||
struct t_irc_message *irc_msgq_last_msg = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* irc_server_get_name_without_port: get name of server without port
|
||||
* (ends before first '/' if found)
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_server_get_name_without_port (const char *name)
|
||||
{
|
||||
char *pos;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
pos = strchr (name, '/');
|
||||
if (pos && (pos != name))
|
||||
return weechat_strndup (name, pos - name);
|
||||
|
||||
return strdup (name);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_new_option: create option in configuration for a server option
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_new_option (struct t_irc_server *server, int index_option,
|
||||
const char *value)
|
||||
{
|
||||
int length;
|
||||
char *option_name;
|
||||
|
||||
length = strlen (server->name) + 1 +
|
||||
strlen (irc_config_server_option_string[index_option]) + 1;
|
||||
option_name = malloc (length);
|
||||
if (option_name)
|
||||
{
|
||||
snprintf (option_name, length, "%s.%s",
|
||||
server->name,
|
||||
irc_config_server_option_string[index_option]);
|
||||
irc_config_server_new_option (irc_config_file,
|
||||
irc_config_section_server,
|
||||
index_option,
|
||||
option_name,
|
||||
value,
|
||||
&irc_config_server_change_cb,
|
||||
irc_config_server_option_string[index_option],
|
||||
&irc_config_server_delete_cb,
|
||||
irc_config_server_option_string[index_option]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_set_addresses: set addresses for server
|
||||
*/
|
||||
@@ -252,7 +303,6 @@ irc_server_init (struct t_irc_server *server)
|
||||
server->autoconnect = IRC_CONFIG_SERVER_DEFAULT_AUTOCONNECT;
|
||||
server->autoreconnect = IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT;
|
||||
server->autoreconnect_delay = IRC_CONFIG_SERVER_DEFAULT_AUTORECONNECT_DELAY;
|
||||
server->temp_server = 0;
|
||||
server->addresses = NULL;
|
||||
server->ipv6 = IRC_CONFIG_SERVER_DEFAULT_IPV6;
|
||||
server->ssl = IRC_CONFIG_SERVER_DEFAULT_SSL;
|
||||
@@ -320,6 +370,9 @@ struct t_irc_server *
|
||||
irc_server_alloc (const char *name)
|
||||
{
|
||||
struct t_irc_server *new_server;
|
||||
|
||||
if (irc_server_search (name))
|
||||
return NULL;
|
||||
|
||||
/* alloc memory for new server */
|
||||
if ((new_server = malloc (sizeof (*new_server))) == NULL)
|
||||
@@ -361,7 +414,9 @@ irc_server_alloc_with_url (const char *irc_url)
|
||||
{
|
||||
char *irc_url2, *url, *pos_server, *pos_channel, *pos, *pos2;
|
||||
char *password, *nick1, *nicks, *autojoin;
|
||||
int ipv6, ssl, length;
|
||||
char *default_nicks, *default_password, *default_autojoin, value[16];
|
||||
char *server_name;
|
||||
int ipv6, ssl, default_ipv6, default_ssl, length;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
irc_url2 = strdup (irc_url);
|
||||
@@ -447,15 +502,26 @@ irc_server_alloc_with_url (const char *irc_url)
|
||||
strcat (autojoin, pos_channel);
|
||||
}
|
||||
}
|
||||
|
||||
ptr_server = irc_server_alloc (pos_server);
|
||||
|
||||
/* server name ends before first '/' (if found) */
|
||||
server_name = irc_server_get_name_without_port (pos_server);
|
||||
ptr_server = irc_server_alloc (server_name);
|
||||
if (server_name)
|
||||
free (server_name);
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
irc_server_set_addresses (ptr_server, pos_server);
|
||||
|
||||
default_ipv6 = ptr_server->ipv6;
|
||||
default_ssl = ptr_server->ssl;
|
||||
default_nicks = (ptr_server->nicks) ? strdup (ptr_server->nicks) : NULL;
|
||||
default_password = (ptr_server->password) ? strdup (ptr_server->password) : NULL;
|
||||
default_autojoin = (ptr_server->autojoin) ? strdup (ptr_server->autojoin) : NULL;
|
||||
|
||||
ptr_server->ipv6 = ipv6;
|
||||
ptr_server->ssl = ssl;
|
||||
|
||||
|
||||
if (nick1)
|
||||
{
|
||||
length = ((strlen (nick1) + 2) * 5) + 1;
|
||||
@@ -471,10 +537,60 @@ irc_server_alloc_with_url (const char *irc_url)
|
||||
}
|
||||
ptr_server->password = (password) ? strdup (password) : NULL;
|
||||
ptr_server->autojoin = (autojoin) ? strdup (autojoin) : NULL;
|
||||
ptr_server->temp_server = 1;
|
||||
ptr_server->autoconnect = 1;
|
||||
|
||||
/* create server options */
|
||||
irc_server_new_option (ptr_server,
|
||||
IRC_CONFIG_SERVER_ADDRESSES,
|
||||
ptr_server->addresses);
|
||||
if (default_ipv6 != ptr_server->ipv6)
|
||||
{
|
||||
snprintf (value, sizeof (value),
|
||||
"%s",
|
||||
(ptr_server->ipv6) ? "on" : "off");
|
||||
irc_server_new_option (ptr_server,
|
||||
IRC_CONFIG_SERVER_IPV6,
|
||||
value);
|
||||
}
|
||||
if (default_ssl != ptr_server->ssl)
|
||||
{
|
||||
snprintf (value, sizeof (value),
|
||||
"%s",
|
||||
(ptr_server->ssl) ? "on" : "off");
|
||||
irc_server_new_option (ptr_server,
|
||||
IRC_CONFIG_SERVER_SSL,
|
||||
value);
|
||||
}
|
||||
if (ptr_server->nicks
|
||||
&& (!default_nicks || strcmp (default_nicks, ptr_server->nicks) != 0))
|
||||
{
|
||||
irc_server_new_option (ptr_server,
|
||||
IRC_CONFIG_SERVER_NICKS,
|
||||
ptr_server->nicks);
|
||||
}
|
||||
if (ptr_server->password
|
||||
&& (!default_password || strcmp (default_password, ptr_server->password) != 0))
|
||||
{
|
||||
irc_server_new_option (ptr_server,
|
||||
IRC_CONFIG_SERVER_PASSWORD,
|
||||
ptr_server->password);
|
||||
}
|
||||
if (ptr_server->autojoin
|
||||
&& (!default_autojoin || strcmp (default_autojoin, ptr_server->autojoin) != 0))
|
||||
{
|
||||
irc_server_new_option (ptr_server,
|
||||
IRC_CONFIG_SERVER_AUTOJOIN,
|
||||
ptr_server->autojoin);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: error creating new server \"%s\""),
|
||||
weechat_prefix ("error"), "irc",
|
||||
pos_server);
|
||||
}
|
||||
|
||||
if (password)
|
||||
free (password);
|
||||
if (nick1)
|
||||
@@ -621,13 +737,15 @@ void
|
||||
irc_server_free (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_server *new_irc_servers;
|
||||
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
|
||||
/* close any opened channel/private */
|
||||
while (server->channels)
|
||||
{
|
||||
irc_channel_free (server, server->channels);
|
||||
}
|
||||
|
||||
/* remove server from queue */
|
||||
if (last_irc_server == server)
|
||||
@@ -666,11 +784,11 @@ irc_server_free_all ()
|
||||
|
||||
struct t_irc_server *
|
||||
irc_server_new (const char *name, int autoconnect, int autoreconnect,
|
||||
int autoreconnect_delay, int temp_server, const char *addresses,
|
||||
int ipv6, int ssl, const char *password, const char *nicks,
|
||||
const char *username, const char *realname, const char *local_hostname,
|
||||
const char *command, int command_delay, const char *autojoin,
|
||||
int autorejoin)
|
||||
int autoreconnect_delay, const char *addresses, int ipv6,
|
||||
int ssl, const char *password, const char *nicks,
|
||||
const char *username, const char *realname,
|
||||
const char *local_hostname, const char *command,
|
||||
int command_delay, const char *autojoin, int autorejoin)
|
||||
{
|
||||
struct t_irc_server *new_server;
|
||||
|
||||
@@ -698,7 +816,6 @@ irc_server_new (const char *name, int autoconnect, int autoreconnect,
|
||||
new_server->autoconnect = autoconnect;
|
||||
new_server->autoreconnect = autoreconnect;
|
||||
new_server->autoreconnect_delay = autoreconnect_delay;
|
||||
new_server->temp_server = temp_server;
|
||||
irc_server_set_addresses (new_server, addresses);
|
||||
new_server->ipv6 = ipv6;
|
||||
new_server->ssl = ssl;
|
||||
@@ -730,20 +847,23 @@ irc_server_new (const char *name, int autoconnect, int autoreconnect,
|
||||
*/
|
||||
|
||||
struct t_irc_server *
|
||||
irc_server_duplicate (struct t_irc_server *server, const char *new_name)
|
||||
irc_server_duplicate (struct t_irc_server *server, const char *new_server_name)
|
||||
{
|
||||
struct t_irc_server *new_server;
|
||||
int length, index_option;
|
||||
char *mask, *option_name, *pos_option;
|
||||
struct t_config_option *ptr_option;
|
||||
struct t_infolist *infolist;
|
||||
|
||||
/* check if another server exists with this name */
|
||||
if (irc_server_search (new_name))
|
||||
return 0;
|
||||
if (irc_server_search (new_server_name))
|
||||
return NULL;
|
||||
|
||||
/* duplicate server */
|
||||
new_server = irc_server_new (new_name,
|
||||
new_server = irc_server_new (new_server_name,
|
||||
server->autoconnect,
|
||||
server->autoreconnect,
|
||||
server->autoreconnect_delay,
|
||||
server->temp_server,
|
||||
server->addresses,
|
||||
server->ipv6,
|
||||
server->ssl,
|
||||
@@ -757,6 +877,46 @@ irc_server_duplicate (struct t_irc_server *server, const char *new_name)
|
||||
server->autojoin,
|
||||
server->autorejoin);
|
||||
|
||||
if (new_server)
|
||||
{
|
||||
/* duplicate options */
|
||||
length = 32 + strlen (server->name) + 1;
|
||||
mask = malloc (length);
|
||||
if (!mask)
|
||||
return 0;
|
||||
snprintf (mask, length, "irc.server.%s.*", server->name);
|
||||
infolist = weechat_infolist_get ("options", 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)
|
||||
{
|
||||
option_name = weechat_infolist_string (infolist, "option_name");
|
||||
if (option_name)
|
||||
{
|
||||
pos_option = strrchr (option_name, '.');
|
||||
if (pos_option)
|
||||
{
|
||||
pos_option++;
|
||||
|
||||
index_option = irc_config_search_server_option (pos_option);
|
||||
if (index_option >= 0)
|
||||
{
|
||||
irc_server_new_option (new_server,
|
||||
index_option,
|
||||
weechat_infolist_string (infolist, "value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
return new_server;
|
||||
}
|
||||
|
||||
@@ -766,25 +926,26 @@ irc_server_duplicate (struct t_irc_server *server, const char *new_name)
|
||||
*/
|
||||
|
||||
int
|
||||
irc_server_rename (struct t_irc_server *server, const char *new_name)
|
||||
irc_server_rename (struct t_irc_server *server, const char *new_server_name)
|
||||
{
|
||||
int length;
|
||||
char *option_name, *name, *pos_option;
|
||||
char *mask, *option_name, *pos_option, *new_option_name;
|
||||
struct t_infolist *infolist;
|
||||
struct t_config_option *ptr_option;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
/* check if another server exists with this name */
|
||||
if (irc_server_search (new_name))
|
||||
if (irc_server_search (new_server_name))
|
||||
return 0;
|
||||
|
||||
/* rename options */
|
||||
length = 32 + strlen (server->name) + 1;
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
mask = malloc (length);
|
||||
if (!mask)
|
||||
return 0;
|
||||
snprintf (option_name, length, "irc.server.%s.*", server->name);
|
||||
infolist = weechat_infolist_get ("options", NULL, option_name);
|
||||
free (option_name);
|
||||
snprintf (mask, length, "irc.server.%s.*", server->name);
|
||||
infolist = weechat_infolist_get ("options", NULL, mask);
|
||||
free (mask);
|
||||
while (weechat_infolist_next (infolist))
|
||||
{
|
||||
weechat_config_search_with_string (weechat_infolist_string (infolist,
|
||||
@@ -793,18 +954,22 @@ irc_server_rename (struct t_irc_server *server, const char *new_name)
|
||||
NULL);
|
||||
if (ptr_option)
|
||||
{
|
||||
name = weechat_infolist_string (infolist, "name");
|
||||
pos_option = strchr (name, '.');
|
||||
if (pos_option)
|
||||
option_name = weechat_infolist_string (infolist, "option_name");
|
||||
if (option_name)
|
||||
{
|
||||
pos_option++;
|
||||
length = strlen (new_name) + 1 + strlen (pos_option) + 1;
|
||||
option_name = malloc (length);
|
||||
if (option_name)
|
||||
pos_option = strrchr (option_name, '.');
|
||||
if (pos_option)
|
||||
{
|
||||
snprintf (option_name, length, "%s.%s", new_name, pos_option);
|
||||
weechat_config_option_rename (ptr_option, option_name);
|
||||
free (option_name);
|
||||
pos_option++;
|
||||
length = strlen (new_server_name) + 1 + strlen (pos_option) + 1;
|
||||
new_option_name = malloc (length);
|
||||
if (new_option_name)
|
||||
{
|
||||
snprintf (new_option_name, length,
|
||||
"%s.%s", new_server_name, pos_option);
|
||||
weechat_config_option_rename (ptr_option, new_option_name);
|
||||
free (new_option_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -814,7 +979,21 @@ irc_server_rename (struct t_irc_server *server, const char *new_name)
|
||||
/* rename server */
|
||||
if (server->name)
|
||||
free (server->name);
|
||||
server->name = strdup (new_name);
|
||||
server->name = strdup (new_server_name);
|
||||
|
||||
/* change "category" for buffers with this server */
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->buffer)
|
||||
weechat_buffer_set (ptr_channel->buffer, "category", server->name);
|
||||
}
|
||||
if (server->buffer)
|
||||
{
|
||||
weechat_buffer_set (server->buffer, "category", server->name);
|
||||
weechat_buffer_set (server->buffer, "name", server->name);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2045,15 +2224,14 @@ irc_server_reconnect (struct t_irc_server *server)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_auto_connect (int auto_connect, int temp_server)
|
||||
irc_server_auto_connect (int auto_connect)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if ( ((temp_server) && (ptr_server->temp_server))
|
||||
|| ((!temp_server) && (auto_connect) && (ptr_server->autoconnect)) )
|
||||
if ((auto_connect) && (ptr_server->autoconnect))
|
||||
{
|
||||
if (!irc_server_connect (ptr_server, 0))
|
||||
irc_server_reconnect_schedule (ptr_server);
|
||||
@@ -2553,8 +2731,6 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "autoreconnect_delay", server->autoreconnect_delay))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "temp_server", server->temp_server))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "addresses", server->addresses))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "ipv6", server->ipv6))
|
||||
@@ -2642,7 +2818,6 @@ irc_server_print_log ()
|
||||
weechat_log_printf (" autoconnect . . . . : %d", ptr_server->autoconnect);
|
||||
weechat_log_printf (" autoreconnect . . . : %d", ptr_server->autoreconnect);
|
||||
weechat_log_printf (" autoreconnect_delay : %d", ptr_server->autoreconnect_delay);
|
||||
weechat_log_printf (" temp_server . . . . : %d", ptr_server->temp_server);
|
||||
weechat_log_printf (" addresses . . . . . : '%s'", ptr_server->addresses);
|
||||
weechat_log_printf (" ipv6. . . . . . . . : %d", ptr_server->ipv6);
|
||||
weechat_log_printf (" ssl . . . . . . . . : %d", ptr_server->ssl);
|
||||
|
||||
@@ -62,7 +62,6 @@ struct t_irc_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 */
|
||||
int temp_server; /* server is temporary (not saved!) */
|
||||
char *addresses; /* server addresses (IP/name with port) */
|
||||
int ipv6; /* use IPv6 protocol */
|
||||
int ssl; /* SSL protocol */
|
||||
@@ -136,6 +135,10 @@ extern const int gnutls_prot_prio[];
|
||||
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
|
||||
|
||||
|
||||
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);
|
||||
@@ -150,12 +153,17 @@ extern void irc_server_free_all ();
|
||||
extern struct t_irc_server *irc_server_new (const char *name, int autoconnect,
|
||||
int autoreconnect,
|
||||
int autoreconnect_delay,
|
||||
int temp_server, const char *addresses,
|
||||
int ipv6, int ssl,
|
||||
const char *password, const char *nicks,
|
||||
const char *username, const char *realname,
|
||||
const char *hostname, const char *command,
|
||||
int command_delay, const char *autojoin,
|
||||
const char *addresses,
|
||||
int ipv6,
|
||||
int ssl,
|
||||
const char *password,
|
||||
const char *nicks,
|
||||
const char *username,
|
||||
const char *realname,
|
||||
const char *hostname,
|
||||
const char *command,
|
||||
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);
|
||||
@@ -167,7 +175,7 @@ extern void irc_server_sendf (struct t_irc_server *server, const char *format, .
|
||||
extern struct t_irc_server *irc_server_search (const char *server_name);
|
||||
extern int irc_server_connect (struct t_irc_server *server,
|
||||
int disable_autojoin);
|
||||
extern void irc_server_auto_connect (int auto_connect, int temp_server);
|
||||
extern void irc_server_auto_connect (int auto_connect);
|
||||
extern void irc_server_autojoin_channels ();
|
||||
extern int irc_server_recv_cb (void *arg_server);
|
||||
extern int irc_server_timer_cb (void *data);
|
||||
|
||||
@@ -140,8 +140,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
if (!irc_server_alloc_with_url (argv[i]))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: invalid syntax for IRC server "
|
||||
"('%s'), ignored"),
|
||||
_("%s%s: error with IRC server from URL "
|
||||
"(\"s\"), ignored"),
|
||||
weechat_prefix ("error"), "irc",
|
||||
argv[i]);
|
||||
}
|
||||
@@ -151,11 +151,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
upgrading = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (upgrading)
|
||||
irc_upgrade_load ();
|
||||
else
|
||||
irc_server_auto_connect (auto_connect, 0);
|
||||
irc_server_auto_connect (auto_connect);
|
||||
|
||||
irc_hook_timer = weechat_hook_timer (1 * 1000, 0, 0,
|
||||
&irc_server_timer_cb, NULL);
|
||||
|
||||
@@ -349,6 +349,7 @@ 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_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_boolean = &config_file_option_boolean;
|
||||
|
||||
@@ -1478,6 +1478,42 @@ weechat_lua_api_config_option_set (lua_State *L)
|
||||
LUA_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_option_unset: unset an option
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_config_option_unset (lua_State *L)
|
||||
{
|
||||
const char *option;
|
||||
int n, rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
rc = weechat_config_option_unset (script_str2ptr (option));
|
||||
|
||||
LUA_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_option_rename: rename an option
|
||||
*/
|
||||
@@ -4950,6 +4986,7 @@ 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_unset", &weechat_lua_api_config_option_unset },
|
||||
{ "config_option_rename", &weechat_lua_api_config_option_rename },
|
||||
{ "config_boolean", &weechat_lua_api_config_boolean },
|
||||
{ "config_integer", &weechat_lua_api_config_integer },
|
||||
|
||||
@@ -1233,6 +1233,37 @@ static XS (XS_weechat_config_option_set)
|
||||
PERL_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_option_unset: unset an option
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_config_option_unset)
|
||||
{
|
||||
int rc;
|
||||
char *option;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = SvPV (ST (0), PL_na);
|
||||
rc = weechat_config_option_unset (script_str2ptr (option));
|
||||
|
||||
PERL_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_option_rename: rename an option
|
||||
*/
|
||||
@@ -3878,6 +3909,7 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::config_string_to_boolean", XS_weechat_config_string_to_boolean, "weechat");
|
||||
newXS ("weechat::config_option_reset", XS_weechat_config_option_reset, "weechat");
|
||||
newXS ("weechat::config_option_set", XS_weechat_config_option_set, "weechat");
|
||||
newXS ("weechat::config_option_unset", XS_weechat_config_option_unset, "weechat");
|
||||
newXS ("weechat::config_option_rename", XS_weechat_config_option_rename, "weechat");
|
||||
newXS ("weechat::config_boolean", XS_weechat_config_boolean, "weechat");
|
||||
newXS ("weechat::config_integer", XS_weechat_config_integer, "weechat");
|
||||
|
||||
@@ -1302,6 +1302,38 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_option_unset: unset an option
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_config_option_unset (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *option;
|
||||
int rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
rc = weechat_config_option_unset (script_str2ptr (option));
|
||||
|
||||
PYTHON_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_option_rename: rename an option
|
||||
*/
|
||||
@@ -4121,6 +4153,7 @@ 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_unset", &weechat_python_api_config_option_unset, METH_VARARGS, "" },
|
||||
{ "config_option_rename", &weechat_python_api_config_option_rename, METH_VARARGS, "" },
|
||||
{ "config_boolean", &weechat_python_api_config_boolean, METH_VARARGS, "" },
|
||||
{ "config_integer", &weechat_python_api_config_integer, METH_VARARGS, "" },
|
||||
|
||||
@@ -1509,6 +1509,42 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
|
||||
RUBY_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_option_unset: unset an option
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_config_option_unset (VALUE class, VALUE option)
|
||||
{
|
||||
char *c_option;
|
||||
int rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
c_option = NULL;
|
||||
|
||||
if (NIL_P (option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
Check_Type (option, T_STRING);
|
||||
|
||||
c_option = STR2CSTR (option);
|
||||
|
||||
rc = weechat_config_option_unset (script_str2ptr (c_option));
|
||||
|
||||
RUBY_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_option_rename: rename an option
|
||||
*/
|
||||
@@ -4756,6 +4792,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
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_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_boolean", &weechat_ruby_api_config_boolean, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_integer", &weechat_ruby_api_config_integer, 1);
|
||||
|
||||
@@ -263,6 +263,7 @@ 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_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,
|
||||
@@ -705,6 +706,8 @@ 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_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) \
|
||||
|
||||
Reference in New Issue
Block a user