1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 10:13:12 +02:00

irc: remove temporary servers and option irc.look.temporary_servers

This commit is contained in:
Sébastien Helleu
2025-11-01 09:15:54 +01:00
parent 234244f8d5
commit 07ef353b1b
32 changed files with 7533 additions and 5668 deletions
+14 -85
View File
@@ -1875,8 +1875,9 @@ IRC_COMMAND_CALLBACK(connect)
connect_ok = 0;
}
}
else if (weechat_config_boolean (irc_config_look_temporary_servers))
else
{
name = NULL;
if ((strncmp (argv[i], "irc", 3) == 0)
&& strstr (argv[i], "://"))
{
@@ -1895,22 +1896,17 @@ IRC_COMMAND_CALLBACK(connect)
/* add server with address */
name = irc_server_get_name_without_port (argv[i]);
ptr_server = irc_server_alloc ((name) ? name : argv[i]);
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 added: %s%s%s%s%s"),
_("%s: server added: %s%s"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
ptr_server->name,
IRC_COLOR_RESET,
_(" (temporary)"),
"");
ptr_server->name);
irc_server_apply_command_line_options (ptr_server,
argc, argv);
if (!irc_command_connect_one_server (ptr_server, 0, 0))
@@ -1921,29 +1917,14 @@ IRC_COMMAND_CALLBACK(connect)
{
weechat_printf (
NULL,
_("%s%s: unable to add temporary server \"%s\" "
_("%s%s: unable to add server \"%s\" "
"(check if there is already a server with this "
"name)"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, argv[i]);
weechat_prefix ("error"),
IRC_PLUGIN_NAME,
(name) ? name : argv[i]);
}
}
else
{
weechat_printf (
NULL,
_("%s%s: unable to add temporary server \"%s\" "
"because the addition of temporary servers with "
"command /connect is currently disabled"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, argv[i]);
weechat_printf (
NULL,
_("%s%s: if you want to add a standard server, "
"use the command \"/server add\" (see /help "
"server); if you really want to add a temporary "
"server (NOT SAVED), turn on the option "
"irc.look.temporary_servers"),
weechat_prefix ("error"),
IRC_PLUGIN_NAME);
free (name);
}
}
else
@@ -5298,7 +5279,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
if (with_detail)
{
weechat_printf (NULL, "");
weechat_printf (NULL, _("Server: %s%s %s[%s%s%s]%s%s%s%s"),
weechat_printf (NULL, _("Server: %s%s %s[%s%s%s]%s%s%s"),
IRC_COLOR_CHAT_SERVER,
server->name,
IRC_COLOR_CHAT_DELIMITERS,
@@ -5308,8 +5289,6 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_nick,
/* TRANSLATORS: "temporary IRC server" */
(server->temp_server) ? _(" (temporary)") : "",
/* TRANSLATORS: "fake IRC server" */
(server->fake_server) ? _(" (fake)") : "");
/* addresses */
@@ -5725,7 +5704,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
num_pv = irc_server_get_pv_count (server);
weechat_printf (
NULL,
" %s %s%s %s[%s%s%s]%s%s%s%s, %d %s, %d pv",
" %s %s%s %s[%s%s%s]%s%s%s, %d %s, %d pv",
(server->is_connected) ? "*" : " ",
IRC_COLOR_CHAT_SERVER,
server->name,
@@ -5735,8 +5714,6 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_nick,
/* TRANSLATORS: "temporary IRC server" */
(server->temp_server) ? _(" (temporary)") : "",
/* TRANSLATORS: "fake IRC server" */
(server->fake_server) ? _(" (fake)") : "",
num_channels,
@@ -5747,12 +5724,10 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
{
weechat_printf (
NULL,
" %s%s%s%s%s",
" %s%s%s%s",
IRC_COLOR_CHAT_SERVER,
server->name,
IRC_COLOR_RESET,
/* TRANSLATORS: "temporary IRC server" */
(server->temp_server) ? _(" (temporary)") : "",
/* TRANSLATORS: "fake IRC server" */
(server->fake_server) ? _(" (fake)") : "");
}
@@ -6097,47 +6072,6 @@ IRC_COMMAND_CALLBACK(server)
return WEECHAT_RC_OK;
}
if (weechat_strcmp (argv[1], "keep") == 0)
{
WEECHAT_COMMAND_MIN_ARGS(3, argv[1]);
/* 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 keep");
return WEECHAT_RC_ERROR;
}
/* check that is it temporary server */
if (!server_found->temp_server)
{
weechat_printf (
NULL,
_("%s%s: server \"%s\" is not a temporary server"),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
argv[2], "server keep");
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 anymore"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_SERVER,
argv[2],
IRC_COLOR_RESET);
return WEECHAT_RC_OK;
}
if (weechat_strcmp (argv[1], "del") == 0)
{
WEECHAT_COMMAND_MIN_ARGS(3, argv[1]);
@@ -7306,8 +7240,6 @@ irc_command_init (void)
"for TLS, 6667 otherwise"),
N_("> - URL with format: irc[6][s]://[nickname[:password]@]"
"irc.example.org[:port][/#channel1][,#channel2[...]]"),
N_("> Note: for an address/IP/URL, a temporary server is "
"added (NOT SAVED), see /help irc.look.temporary_servers"),
N_("option: set option for server (for boolean option, value can be "
"omitted)"),
N_("raw[nooption]: set boolean option to \"off\" (for example: -notls)"),
@@ -7972,12 +7904,12 @@ irc_command_init (void)
N_("list, add or remove IRC servers"),
/* TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated */
N_("list|listfull [-connected] [<name>]"
" || add|addreplace <name> <hostname>[/<port>] [-temp] [-<option>[=<value>]] "
" || add|addreplace <name> <hostname>[/<port>] [-<option>[=<value>]] "
"[-no<option>]"
" || copy|rename <name> <new_name>"
" || reorder <name>..."
" || open <name>|-all [<name>...]"
" || del|keep <name>"
" || del <name>"
" || deloutq|jump"
" || raw [<filter>]"),
WEECHAT_CMD_ARGS_DESC(
@@ -7992,14 +7924,12 @@ irc_command_init (void)
N_("hostname: name or IP address of server, with optional port "
"(default: 6697 for TLS, 6667 otherwise), many addresses can be "
"separated by a comma"),
N_("raw[-temp]: add a temporary server (not saved)"),
N_("option: set option for server (for boolean option, value can be omitted)"),
N_("raw[nooption]: set boolean option to \"off\" (for example: -notls)"),
N_("raw[copy]: duplicate a server"),
N_("raw[rename]: rename a server"),
N_("raw[reorder]: reorder list of servers"),
N_("raw[open]: open the server buffer without connecting"),
N_("raw[keep]: keep server in config file (for temporary servers only)"),
N_("raw[del]: delete a server"),
N_("raw[deloutq]: delete messages out queue for all servers (all messages "
"WeeChat is currently sending)"),
@@ -8043,7 +7973,6 @@ irc_command_init (void)
" || add|addreplace %(irc_servers)"
" || copy %(irc_servers) %(irc_servers)"
" || rename %(irc_servers) %(irc_servers)"
" || keep %(irc_servers)"
" || reorder %(irc_servers)|%*"
" || open %(irc_servers)|-all %(irc_servers)|%*"
" || del %(irc_servers)"
+5 -20
View File
@@ -133,7 +133,6 @@ struct t_config_option *irc_config_look_smart_filter_mode = NULL;
struct t_config_option *irc_config_look_smart_filter_nick = NULL;
struct t_config_option *irc_config_look_smart_filter_quit = NULL;
struct t_config_option *irc_config_look_smart_filter_setname = NULL;
struct t_config_option *irc_config_look_temporary_servers = NULL;
struct t_config_option *irc_config_look_topic_strip_colors = NULL;
/* IRC config, color section */
@@ -193,8 +192,6 @@ struct t_hashtable *irc_config_hashtable_color_term_remap = NULL;
char **irc_config_nicks_hide_password = NULL;
int irc_config_num_nicks_hide_password = 0;
int irc_config_write_temp_servers = 0;
/*
* Gets server pointer with name of option.
@@ -2898,14 +2895,11 @@ irc_config_server_write_cb (const void *pointer, void *data,
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (!ptr_server->temp_server || irc_config_write_temp_servers)
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
{
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
{
if (!weechat_config_write_option (config_file,
ptr_server->options[i]))
return WEECHAT_CONFIG_WRITE_ERROR;
}
if (!weechat_config_write_option (config_file,
ptr_server->options[i]))
return WEECHAT_CONFIG_WRITE_ERROR;
}
}
@@ -3834,13 +3828,6 @@ irc_config_init (void)
N_("enable smart filter for \"setname\" messages"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_temporary_servers = weechat_config_new_option (
irc_config_file, irc_config_section_look,
"temporary_servers", "boolean",
N_("enable automatic addition of temporary servers with command "
"/connect"),
NULL, 0, 0, "off", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_topic_strip_colors = weechat_config_new_option (
irc_config_file, irc_config_section_look,
"topic_strip_colors", "boolean",
@@ -4288,10 +4275,8 @@ irc_config_read (void)
*/
int
irc_config_write (int write_temp_servers)
irc_config_write (void)
{
irc_config_write_temp_servers = write_temp_servers;
return weechat_config_write (irc_config_file);
}
+1 -2
View File
@@ -167,7 +167,6 @@ extern struct t_config_option *irc_config_look_smart_filter_mode;
extern struct t_config_option *irc_config_look_smart_filter_nick;
extern struct t_config_option *irc_config_look_smart_filter_quit;
extern struct t_config_option *irc_config_look_smart_filter_setname;
extern struct t_config_option *irc_config_look_temporary_servers;
extern struct t_config_option *irc_config_look_topic_strip_colors;
extern struct t_config_option *irc_config_color_input_nick;
@@ -248,7 +247,7 @@ struct t_config_option *irc_config_server_new_option (struct t_config_file *conf
void *callback_change_data);
extern int irc_config_init (void);
extern int irc_config_read (void);
extern int irc_config_write (int write_temp_servers);
extern int irc_config_write (void);
extern void irc_config_free (void);
#endif /* WEECHAT_PLUGIN_IRC_CONFIG_H */
+15 -38
View File
@@ -603,7 +603,6 @@ irc_server_get_name_without_port (const char *name)
/*
* Gets a string with description of server, that includes:
* - addresses + ports
* - temporary server?
* - fake server?
* - TLS option (enabled/disabled).
*
@@ -639,12 +638,6 @@ irc_server_get_short_description (struct t_irc_server *server)
}
weechat_string_dyn_concat (result, " (", -1);
if (server->temp_server)
{
/* TRANSLATORS: "temporary IRC server" */
weechat_string_dyn_concat (result, _("temporary"), -1);
weechat_string_dyn_concat (result, ", ", -1);
}
if (server->fake_server)
{
/* TRANSLATORS: "fake IRC server" */
@@ -1739,7 +1732,6 @@ irc_server_alloc (const char *name)
new_server->name = strdup (name);
/* internal vars */
new_server->temp_server = 0;
new_server->fake_server = 0;
new_server->reloading_from_config = 0;
new_server->reloaded_from_config = 0;
@@ -2057,7 +2049,6 @@ irc_server_alloc_with_url (const char *irc_url)
ptr_server = irc_server_alloc (pos_address);
if (ptr_server)
{
ptr_server->temp_server = 1;
if (pos_address && pos_address[0])
{
if (weechat_asprintf (
@@ -2157,30 +2148,22 @@ irc_server_apply_command_line_options (struct t_irc_server *server,
}
if (option_name)
{
if (weechat_strcmp (option_name, "temp") == 0)
index_option = irc_server_search_option (option_name);
if (index_option < 0)
{
/* temporary server, not saved */
server->temp_server = 1;
/* look if option is negative, like "-noxxx" */
if (weechat_strncmp (argv[i], "-no", 3) == 0)
{
free (option_name);
option_name = strdup (argv[i] + 3);
index_option = irc_server_search_option (option_name);
ptr_value = value_boolean[0];
}
}
else
if (index_option >= 0)
{
index_option = irc_server_search_option (option_name);
if (index_option < 0)
{
/* look if option is negative, like "-noxxx" */
if (weechat_strncmp (argv[i], "-no", 3) == 0)
{
free (option_name);
option_name = strdup (argv[i] + 3);
index_option = irc_server_search_option (option_name);
ptr_value = value_boolean[0];
}
}
if (index_option >= 0)
{
weechat_config_option_set (server->options[index_option],
ptr_value, 1);
}
weechat_config_option_set (server->options[index_option],
ptr_value, 1);
}
free (option_name);
}
@@ -2456,8 +2439,7 @@ irc_server_copy (struct t_irc_server *server, const char *new_name)
if (!new_server)
return NULL;
/* duplicate temporary/fake server flags */
new_server->temp_server = server->temp_server;
/* duplicate fake server flag */
new_server->fake_server = server->fake_server;
/* duplicate options */
@@ -5627,7 +5609,7 @@ irc_server_auto_connect_timer_cb (const void *pointer, void *data,
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if ((auto_connect || ptr_server->temp_server)
if (auto_connect
&& (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_AUTOCONNECT)))
{
if (!irc_server_connect (ptr_server))
@@ -5642,7 +5624,6 @@ irc_server_auto_connect_timer_cb (const void *pointer, void *data,
* Auto-connects to servers (called at startup).
*
* If auto_connect == 1, auto-connects to all servers with flag "autoconnect".
* If auto_connect == 0, auto-connect to temporary servers only.
*/
void
@@ -6477,7 +6458,6 @@ irc_server_hdata_server_cb (const void *pointer, void *data,
{
WEECHAT_HDATA_VAR(struct t_irc_server, name, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, options, POINTER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, temp_server, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, fake_server, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, reloading_from_config, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, reloaded_from_config, INTEGER, 0, NULL, NULL);
@@ -6747,8 +6727,6 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_string (ptr_item, "msg_quit",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_MSG_QUIT)))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "temp_server", server->temp_server))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "fake_server", server->fake_server))
return 0;
if (server->is_connected && force_disconnected_state)
@@ -7248,7 +7226,6 @@ irc_server_print_log (void)
weechat_log_printf (" msg_quit. . . . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_MSG_QUIT]));
/* other server variables */
weechat_log_printf (" temp_server . . . . . . . : %d", ptr_server->temp_server);
weechat_log_printf (" fake_server . . . . . . . : %d", ptr_server->fake_server);
weechat_log_printf (" reloading_from_config . . : %d", ptr_server->reloaded_from_config);
weechat_log_printf (" reloaded_from_config. . . : %d", ptr_server->reloaded_from_config);
-1
View File
@@ -192,7 +192,6 @@ struct t_irc_server
struct t_config_option *options[IRC_SERVER_NUM_OPTIONS];
/* internal vars */
int temp_server; /* temporary server (not saved) */
int fake_server; /* fake server (no I/O, for tests) */
int reloading_from_config; /* 1 if reloading from config file */
int reloaded_from_config; /* 1 if reloaded from config file */
-2
View File
@@ -384,8 +384,6 @@ irc_upgrade_read_cb (const void *pointer, void *data,
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->fake_server =
weechat_infolist_integer (infolist, "fake_server");
irc_upgrade_current_server->buffer = NULL;
+4 -9
View File
@@ -290,7 +290,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
weechat_printf (
NULL,
_("%s%s: unable to add temporary server \"%s\" (check "
_("%s%s: unable to add server \"%s\" (check "
"if there is already a server with this name)"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, argv[i]);
}
@@ -337,15 +337,10 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
irc_hook_timer = NULL;
}
if (weechat_irc_plugin->unload_with_upgrade)
{
irc_config_write (1);
}
else
{
irc_config_write (0);
irc_config_write ();
if (!weechat_irc_plugin->unload_with_upgrade)
irc_server_disconnect_all ();
}
irc_ignore_free_all ();