summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-channel.c6
-rw-r--r--src/plugins/irc/irc-command.c27
-rw-r--r--src/plugins/irc/irc-completion.c15
-rw-r--r--src/plugins/irc/irc-config.c220
-rw-r--r--src/plugins/irc/irc-config.h6
-rw-r--r--src/plugins/irc/irc-display.c64
-rw-r--r--src/plugins/irc/irc-nick.c6
-rw-r--r--src/plugins/irc/irc-server.c188
-rw-r--r--src/plugins/irc/irc-server.h15
-rw-r--r--src/plugins/irc/irc-upgrade.c1
-rw-r--r--src/plugins/irc/irc.c3
-rw-r--r--src/plugins/irc/irc.h1
12 files changed, 358 insertions, 194 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index caaf51c83..6271d59a6 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -382,9 +382,9 @@ irc_channel_check_away (struct t_irc_server *server,
{
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- if ((weechat_config_integer (irc_config_network_away_check) > 0)
- && ((weechat_config_integer (irc_config_network_away_check_max_nicks) == 0)
- || (channel->nicks_count <= weechat_config_integer (irc_config_network_away_check_max_nicks))))
+ if ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK) > 0)
+ && ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS) == 0)
+ || (channel->nicks_count <= IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS))))
{
channel->checking_away++;
irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index a1af1ea81..e51586dc8 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -907,7 +907,7 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
char *channel_name, *pos_args, *buf;
- const char *version, *ptr_arg;
+ const char *version, *ptr_arg, *msg_part;
char **channels;
int i, num_channels;
@@ -980,10 +980,10 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
ptr_channel->cycle = 1;
}
+ msg_part = IRC_SERVER_OPTION_STRING(ptr_server,
+ IRC_SERVER_OPTION_DEFAULT_MSG_PART);
ptr_arg = (pos_args) ? pos_args :
- (weechat_config_string (irc_config_network_default_msg_part)
- && weechat_config_string (irc_config_network_default_msg_part)[0]) ?
- weechat_config_string (irc_config_network_default_msg_part) : NULL;
+ ((msg_part && msg_part[0]) ? msg_part : NULL);
if (ptr_arg)
{
@@ -1267,7 +1267,7 @@ irc_command_die (void *data, struct t_gui_buffer *buffer, int argc,
void
irc_command_quit_server (struct t_irc_server *server, const char *arguments)
{
- const char *ptr_arg, *version;
+ const char *ptr_arg, *version, *msg_quit;
char *buf;
if (!server)
@@ -1275,10 +1275,10 @@ irc_command_quit_server (struct t_irc_server *server, const char *arguments)
if (server->is_connected)
{
+ msg_quit = IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_DEFAULT_MSG_QUIT);
ptr_arg = (arguments) ? arguments :
- (weechat_config_string (irc_config_network_default_msg_quit)
- && weechat_config_string (irc_config_network_default_msg_quit)[0]) ?
- weechat_config_string (irc_config_network_default_msg_quit) : NULL;
+ ((msg_quit && msg_quit[0]) ? msg_quit : NULL);
if (ptr_arg)
{
@@ -2706,14 +2706,13 @@ void
irc_command_part_channel (struct t_irc_server *server, const char *channel_name,
const char *part_message)
{
- const char *ptr_arg;
+ const char *ptr_arg, *version, *msg_part;
char *buf;
- const char *version;
+ msg_part = IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_DEFAULT_MSG_PART);
ptr_arg = (part_message) ? part_message :
- (weechat_config_string (irc_config_network_default_msg_part)
- && weechat_config_string (irc_config_network_default_msg_part)[0]) ?
- weechat_config_string (irc_config_network_default_msg_part) : NULL;
+ ((msg_part && msg_part[0]) ? msg_part : NULL);
if (ptr_arg)
{
@@ -2742,7 +2741,7 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
char *channel_name, *pos_args;
-
+
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("part", 1);
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index a91ad96f4..393d9f7e9 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -517,16 +517,19 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
+ const char *msg_part;
+
+ IRC_BUFFER_GET_SERVER(buffer);
+
/* make C compiler happy */
(void) data;
(void) completion_item;
- (void) buffer;
-
- if (weechat_config_string (irc_config_network_default_msg_part)
- && weechat_config_string (irc_config_network_default_msg_part)[0])
+
+ msg_part = IRC_SERVER_OPTION_STRING(ptr_server,
+ IRC_SERVER_OPTION_DEFAULT_MSG_PART);
+ if (msg_part && msg_part[0])
{
- weechat_hook_completion_list_add (completion,
- weechat_config_string (irc_config_network_default_msg_part),
+ weechat_hook_completion_list_add (completion, msg_part,
0, WEECHAT_LIST_POS_SORT);
}
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 2e4e7577d..2b99e9b46 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -105,16 +105,10 @@ struct t_config_option *irc_config_color_reason_quit;
struct t_config_option *irc_config_network_autoreconnect_delay_growing;
struct t_config_option *irc_config_network_autoreconnect_delay_max;
-struct t_config_option *irc_config_network_connection_timeout;
-struct t_config_option *irc_config_network_default_msg_part;
-struct t_config_option *irc_config_network_default_msg_quit;
-struct t_config_option *irc_config_network_away_check;
-struct t_config_option *irc_config_network_away_check_max_nicks;
struct t_config_option *irc_config_network_lag_check;
struct t_config_option *irc_config_network_lag_min_show;
struct t_config_option *irc_config_network_lag_disconnect;
struct t_config_option *irc_config_network_lag_refresh_interval;
-struct t_config_option *irc_config_network_anti_flood[2];
struct t_config_option *irc_config_network_colors_receive;
struct t_config_option *irc_config_network_colors_send;
struct t_config_option *irc_config_network_send_unknown_commands;
@@ -481,50 +475,6 @@ irc_config_change_color_nick_prefix (void *data,
}
/*
- * irc_config_change_network_away_check: called when away check is changed
- */
-
-void
-irc_config_change_network_away_check (void *data,
- struct t_config_option *option)
-{
- /* make C compiler happy */
- (void) data;
- (void) option;
-
- /*
- * if away check was disabled and is now enabled, check now away for all
- * servers/channels
- */
- if (!irc_hook_timer_check_away
- && (weechat_config_integer (irc_config_network_away_check) > 0))
- {
- irc_server_check_away ();
- }
-
- /* remove old timer */
- if (irc_hook_timer_check_away)
- {
- weechat_unhook (irc_hook_timer_check_away);
- irc_hook_timer_check_away = NULL;
- }
-
- if (weechat_config_integer (irc_config_network_away_check) > 0)
- {
- /* create new timer */
- irc_hook_timer_check_away = weechat_hook_timer (weechat_config_integer (irc_config_network_away_check) * 60 * 1000,
- 0, 0,
- &irc_server_timer_check_away_cb,
- NULL);
- }
- else
- {
- /* reset away flag for all servers/channels */
- irc_server_remove_away ();
- }
-}
-
-/*
* irc_config_change_network_lag_check: called when lag check is changed
*/
@@ -628,6 +578,11 @@ irc_config_server_default_change_cb (void *data, struct t_config_option *option)
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
+ /*
+ * when default value for a server option is changed, we apply it
+ * on all servers where value is "null" (inherited from default
+ * value)
+ */
if (weechat_config_option_is_null (ptr_server->options[index_option]))
{
switch (index_option)
@@ -640,6 +595,13 @@ irc_config_server_default_change_cb (void *data, struct t_config_option *option)
irc_server_set_nicks (ptr_server,
weechat_config_string (option));
break;
+ case IRC_SERVER_OPTION_AWAY_CHECK:
+ case IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS:
+ if (IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AWAY_CHECK) > 0)
+ irc_server_check_away (ptr_server);
+ else
+ irc_server_remove_away (ptr_server);
+ break;
}
}
}
@@ -676,6 +638,12 @@ irc_config_server_change_cb (void *data, struct t_config_option *option)
IRC_SERVER_OPTION_STRING(ptr_server,
IRC_SERVER_OPTION_NICKS));
break;
+ case IRC_SERVER_OPTION_AWAY_CHECK:
+ case IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS:
+ if (IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AWAY_CHECK) > 0)
+ irc_server_check_away (ptr_server);
+ else
+ irc_server_remove_away (ptr_server);
}
}
}
@@ -1306,6 +1274,101 @@ irc_config_server_new_option (struct t_config_file *config_file,
callback_change, callback_change_data,
NULL, NULL);
break;
+ case IRC_SERVER_OPTION_CONNECTION_TIMEOUT:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("timeout (in seconds) between TCP connection to server and "
+ "message 001 received, if this timeout is reached before "
+ "001 message is received, WeeChat will disconnect from "
+ "server"),
+ NULL, 1, 3600,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("anti-flood for high priority queue: number of seconds "
+ "between two user messages or commands sent to IRC server "
+ "(0 = no anti-flood)"),
+ NULL, 0, 60,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("anti-flood for low priority queue: number of seconds "
+ "between two messages sent to IRC server (messages like "
+ "automatic CTCP replies) (0 = no anti-flood)"),
+ NULL, 0, 60,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_AWAY_CHECK:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("interval between two checks for away (in minutes, "
+ "0 = never check)"),
+ NULL, 0, 60 * 24 * 7,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "integer",
+ N_("do not check away nicks on channels with high number of "
+ "nicks (0 = unlimited)"),
+ NULL, 0, 1000000,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_DEFAULT_MSG_PART:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("default part message (leaving channel) (\"%v\" will be "
+ "replaced by WeeChat version in string)"),
+ NULL, 0, 0,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
+ case IRC_SERVER_OPTION_DEFAULT_MSG_QUIT:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ N_("default quit message (disconnecting from server) (\"%v\" "
+ "will be replaced by WeeChat version in string)"),
+ NULL, 0, 0,
+ default_value, value,
+ null_value_allowed,
+ NULL, NULL,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
case IRC_SERVER_NUM_OPTIONS:
break;
}
@@ -1862,40 +1925,6 @@ irc_config_init ()
N_("maximum autoreconnect delay to server (in seconds, 0 = no maximum)"),
NULL, 0, 3600 * 24, "1800", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
- irc_config_network_connection_timeout = weechat_config_new_option (
- irc_config_file, ptr_section,
- "connection_timeout", "integer",
- N_("timeout (in seconds) between TCP connection to server and message "
- "001 received, if this timeout is reached before 001 message is "
- "received, WeeChat will disconnect from server"),
- NULL, 1, 3600, "60", NULL, 0, NULL, NULL,
- NULL, NULL, NULL, NULL);
- irc_config_network_default_msg_part = weechat_config_new_option (
- irc_config_file, ptr_section,
- "default_msg_part", "string",
- N_("default part message (leaving channel) (\"%v\" will be replaced "
- "by WeeChat version in string)"),
- NULL, 0, 0, "WeeChat %v", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
- irc_config_network_default_msg_quit = weechat_config_new_option (
- irc_config_file, ptr_section,
- "default_msg_quit", "string",
- N_("default quit message (disconnecting from server) (\"%v\" will be "
- "replaced by WeeChat version in string)"),
- NULL, 0, 0, "WeeChat %v", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
- irc_config_network_away_check = weechat_config_new_option (
- irc_config_file, ptr_section,
- "away_check", "integer",
- N_("interval between two checks for away (in minutes, 0 = never "
- "check)"),
- NULL, 0, 60 * 24 * 7, "0", NULL, 0, NULL, NULL,
- &irc_config_change_network_away_check, NULL, NULL, NULL);
- irc_config_network_away_check_max_nicks = weechat_config_new_option (
- irc_config_file, ptr_section,
- "away_check_max_nicks", "integer",
- N_("do not check away nicks on channels with high number of nicks "
- "(0 = unlimited)"),
- NULL, 0, 1000000, "25", NULL, 0, NULL, NULL,
- &irc_config_change_network_away_check, NULL, NULL, NULL);
irc_config_network_lag_check = weechat_config_new_option (
irc_config_file, ptr_section,
"lag_check", "integer",
@@ -1921,19 +1950,6 @@ irc_config_init ()
N_("interval between two refreshs of lag item, when lag is increasing "
"(in seconds)"),
NULL, 1, 3600, "1", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
- irc_config_network_anti_flood[0] = weechat_config_new_option (
- irc_config_file, ptr_section,
- "anti_flood_prio_high", "integer",
- N_("anti-flood for high priority queue: number of seconds between two "
- "user messages or commands sent to IRC server (0 = no anti-flood)"),
- NULL, 0, 60, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
- irc_config_network_anti_flood[1] = weechat_config_new_option (
- irc_config_file, ptr_section,
- "anti_flood_prio_low", "integer",
- N_("anti-flood for low priority queue: number of seconds between two "
- "messages sent to IRC server (messages like automatic CTCP replies) "
- "(0 = no anti-flood)"),
- NULL, 0, 60, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_colors_receive = weechat_config_new_option (
irc_config_file, ptr_section,
"colors_receive", "boolean",
@@ -2037,15 +2053,7 @@ irc_config_init ()
int
irc_config_read ()
{
- int rc;
-
- rc = weechat_config_read (irc_config_file);
- if (rc == WEECHAT_CONFIG_READ_OK)
- {
- irc_config_change_network_away_check (NULL, NULL);
- }
-
- return rc;
+ return weechat_config_read (irc_config_file);
}
/*
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 71a25aec5..e83bd8b1b 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -127,16 +127,10 @@ extern struct t_config_option *irc_config_color_reason_quit;
extern struct t_config_option *irc_config_network_autoreconnect_delay_growing;
extern struct t_config_option *irc_config_network_autoreconnect_delay_max;
-extern struct t_config_option *irc_config_network_connection_timeout;
-extern struct t_config_option *irc_config_network_default_msg_part;
-extern struct t_config_option *irc_config_network_default_msg_quit;
-extern struct t_config_option *irc_config_network_away_check;
-extern struct t_config_option *irc_config_network_away_check_max_nicks;
extern struct t_config_option *irc_config_network_lag_check;
extern struct t_config_option *irc_config_network_lag_min_show;
extern struct t_config_option *irc_config_network_lag_disconnect;
extern struct t_config_option *irc_config_network_lag_refresh_interval;
-extern struct t_config_option *irc_config_network_anti_flood[2];
extern struct t_config_option *irc_config_network_colors_receive;
extern struct t_config_option *irc_config_network_colors_send;
extern struct t_config_option *irc_config_network_send_unknown_commands;
diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c
index 96b936567..cc7be77ab 100644
--- a/src/plugins/irc/irc-display.c
+++ b/src/plugins/irc/irc-display.c
@@ -392,6 +392,70 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY])));
+ /* connection_timeout */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]))
+ weechat_printf (NULL, " connection_timeout . : (%d %s)",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT),
+ NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT)));
+ else
+ weechat_printf (NULL, " connection_timeout . : %s%d %s",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_integer (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]),
+ NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT])));
+ /* anti_flood_prio_high */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]))
+ weechat_printf (NULL, " anti_flood_prio_high : (%d %s)",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH),
+ NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH)));
+ else
+ weechat_printf (NULL, " anti_flood_prio_high : %s%d %s",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]),
+ NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH])));
+ /* anti_flood_prio_low */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]))
+ weechat_printf (NULL, " anti_flood_prio_low. : (%d %s)",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW),
+ NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW)));
+ else
+ weechat_printf (NULL, " anti_flood_prio_low. : %s%d %s",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]),
+ NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW])));
+ /* away_check */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AWAY_CHECK]))
+ weechat_printf (NULL, " away_check . . . . . : (%d %s)",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK),
+ NG_("minute", "minutes", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK)));
+ else
+ weechat_printf (NULL, " away_check . . . . . : %s%d %s",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK]),
+ NG_("minute", "minutes", weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK])));
+ /* away_check_max_nicks */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]))
+ weechat_printf (NULL, " away_check_max_nicks : (%d)",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS));
+ else
+ weechat_printf (NULL, " away_check_max_nicks : %s%d",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]));
+ /* default_msg_part */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]))
+ weechat_printf (NULL, " default_msg_part . . : ('%s')",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART));
+ else
+ weechat_printf (NULL, " default_msg_part . . : %s'%s'",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]));
+ /* default_msg_quit */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]))
+ weechat_printf (NULL, " default_msg_quit . . : ('%s')",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT));
+ else
+ weechat_printf (NULL, " default_msg_quit . . : %s'%s'",
+ IRC_COLOR_CHAT_VALUE,
+ weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]));
}
else
{
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index c2540623c..7666a4ff9 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -643,9 +643,9 @@ void
irc_nick_set_away (struct t_irc_server *server, struct t_irc_channel *channel,
struct t_irc_nick *nick, int is_away)
{
- if ((weechat_config_integer (irc_config_network_away_check) > 0)
- && ((weechat_config_integer (irc_config_network_away_check_max_nicks) == 0) ||
- (channel->nicks_count <= weechat_config_integer (irc_config_network_away_check_max_nicks))))
+ if ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK) > 0)
+ && ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS) == 0)
+ || (channel->nicks_count <= IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS))))
{
if (((is_away) && (!(nick->flags & IRC_NICK_AWAY))) ||
((!is_away) && (nick->flags & IRC_NICK_AWAY)))
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index bf77325c2..f26615784 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -68,6 +68,10 @@ char *irc_server_option_string[IRC_SERVER_NUM_OPTIONS] =
"autoconnect", "autoreconnect", "autoreconnect_delay",
"nicks", "username", "realname", "local_hostname",
"command", "command_delay", "autojoin", "autorejoin", "autorejoin_delay",
+ "connection_timeout",
+ "anti_flood_prio_high", "anti_flood_prio_low",
+ "away_check", "away_check_max_nicks",
+ "default_msg_part", "default_msg_quit",
};
char *irc_server_option_default[IRC_SERVER_NUM_OPTIONS] =
@@ -77,6 +81,10 @@ char *irc_server_option_default[IRC_SERVER_NUM_OPTIONS] =
"off", "on", "10",
"", "", "", "",
"", "0", "", "off", "30",
+ "60",
+ "2", "2",
+ "0", "25",
+ "WeeChat %v", "WeeChat %v",
};
const char *irc_server_send_default_tags = NULL; /* default tags when */
@@ -453,6 +461,7 @@ irc_server_alloc (const char *name)
new_server->lag_last_refresh = 0;
new_server->cmd_list_regexp = NULL;
new_server->last_user_message = 0;
+ new_server->last_away_check = 0;
for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
{
new_server->outqueue[i] = NULL;
@@ -1230,7 +1239,7 @@ irc_server_outqueue_send (struct t_irc_server *server)
{
time_t time_now;
char *pos, *tags_to_send;
- int priority;
+ int priority, anti_flood;
time_now = time (NULL);
@@ -1240,9 +1249,17 @@ irc_server_outqueue_send (struct t_irc_server *server)
for (priority = 0; priority < IRC_SERVER_NUM_OUTQUEUES_PRIO; priority++)
{
+ switch (priority)
+ {
+ case 0:
+ anti_flood = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH);
+ break;
+ default:
+ anti_flood = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW);
+ break;
+ }
if (server->outqueue[priority]
- && (time_now >= server->last_user_message +
- weechat_config_integer (irc_config_network_anti_flood[priority])))
+ && (time_now >= server->last_user_message + anti_flood))
{
if (server->outqueue[priority]->message_before_mod)
{
@@ -1486,7 +1503,7 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
char *new_msg, *pos, *nick, *command, *channel, *tags_to_send;
char *ptr_chan_nick, *msg_encoded;
char str_modifier[64], modifier_data[256];
- int rc, queue_msg, add_to_queue, first_message;
+ int rc, queue_msg, add_to_queue, first_message, anti_flood;
time_t time_now;
rc = 1;
@@ -1558,12 +1575,21 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
else if (flags && IRC_SERVER_SEND_OUTQ_PRIO_LOW)
queue_msg = 2;
+ switch (queue_msg - 1)
+ {
+ case 0:
+ anti_flood = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH);
+ break;
+ default:
+ anti_flood = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW);
+ break;
+ }
+
add_to_queue = 0;
if ((queue_msg > 0)
&& (server->outqueue[queue_msg - 1]
- || ((weechat_config_integer (irc_config_network_anti_flood[queue_msg - 1]) > 0)
- && (time_now - server->last_user_message <
- weechat_config_integer (irc_config_network_anti_flood[queue_msg - 1])))))
+ || ((anti_flood > 0)
+ && (time_now - server->last_user_message < anti_flood))))
{
add_to_queue = queue_msg;
}
@@ -2101,6 +2127,7 @@ irc_server_timer_cb (void *data, int remaining_calls)
struct t_irc_server *ptr_server;
time_t new_time;
static struct timeval tv;
+ int away_check;
/* make C compiler happy */
(void) data;
@@ -2137,6 +2164,19 @@ irc_server_timer_cb (void *data, int remaining_calls)
ptr_server->lag = 0;
ptr_server->lag_last_refresh = 0;
}
+ else
+ {
+ /* check away (only if lag check was not done) */
+ away_check = IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AWAY_CHECK);
+ if (away_check > 0)
+ {
+ if ((ptr_server->last_away_check == 0)
+ || (new_time >= ptr_server->last_away_check + (away_check * 60)))
+ {
+ irc_server_check_away (ptr_server);
+ }
+ }
+ }
/* check if it's time to autojoin channels (after command delay) */
if ((ptr_server->command_time != 0)
@@ -2180,24 +2220,6 @@ irc_server_timer_cb (void *data, int remaining_calls)
}
/*
- * irc_server_timer_check_away_cb: timer called to check away on servers
- * (according to option "irc_check_away")
- */
-
-int
-irc_server_timer_check_away_cb (void *data, int remaining_calls)
-{
- /* make C compiler happy */
- (void) data;
- (void) remaining_calls;
-
- if (weechat_config_integer (irc_config_network_away_check) > 0)
- irc_server_check_away ();
-
- return WEECHAT_RC_OK;
-}
-
-/*
* irc_server_close_connection: close server connection
*/
@@ -2368,10 +2390,11 @@ irc_server_login (struct t_irc_server *server)
if (server->hook_timer_connection)
weechat_unhook (server->hook_timer_connection);
- server->hook_timer_connection = weechat_hook_timer (weechat_config_integer (irc_config_network_connection_timeout) * 1000,
- 0, 1,
- &irc_server_timer_connection_cb,
- server);
+ server->hook_timer_connection = weechat_hook_timer (
+ IRC_SERVER_OPTION_INTEGER (server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT) * 1000,
+ 0, 1,
+ &irc_server_timer_connection_cb,
+ server);
}
/*
@@ -3477,44 +3500,40 @@ irc_server_get_pv_count (struct t_irc_server *server)
*/
void
-irc_server_remove_away ()
+irc_server_remove_away (struct t_irc_server *server)
{
- struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
- for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
+ if (server->is_connected)
{
- if (ptr_server->is_connected)
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
{
- for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel)
- {
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- irc_channel_remove_away (ptr_server, ptr_channel);
- }
+ if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ irc_channel_remove_away (server, ptr_channel);
}
+ server->last_away_check = 0;
}
}
/*
- * irc_server_check_away: check for away on all channels (for all servers)
+ * irc_server_check_away: check for away on all channels of a server
*/
void
-irc_server_check_away ()
+irc_server_check_away (struct t_irc_server *server)
{
- struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
- for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
+ if (server->is_connected)
{
- if (ptr_server->is_connected)
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
{
- for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel)
- {
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- irc_channel_check_away (ptr_server, ptr_channel);
- }
+ if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ irc_channel_check_away (server, ptr_channel);
}
+ server->last_away_check = time (NULL);
}
}
@@ -3849,6 +3868,27 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_integer (ptr_item, "autorejoin_delay",
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY)))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "connection_timeout",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT)))
+ return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "anti_flood_prio_high",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH)))
+ return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "anti_flood_prio_low",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW)))
+ return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "away_check",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK)))
+ return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "away_check_max_nicks",
+ IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS)))
+ return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "default_msg_part",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART)))
+ return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "default_msg_quit",
+ IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_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, "index_current_address", server->index_current_address))
@@ -3901,6 +3941,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_time (ptr_item, "last_user_message", server->last_user_message))
return 0;
+ if (!weechat_infolist_new_var_time (ptr_item, "last_away_check", server->last_away_check))
+ return 0;
return 1;
}
@@ -4088,6 +4130,55 @@ irc_server_print_log ()
else
weechat_log_printf (" autorejoin_delay . . : %d",
weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]));
+ /* connection_timeout */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]))
+ weechat_log_printf (" connection_timeout . : null (%d)",
+ IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT));
+ else
+ weechat_log_printf (" connection_timeout . : %d",
+ weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]));
+ /* anti_flood_prio_high */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]))
+ weechat_log_printf (" anti_flood_prio_high : null (%d)",
+ IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH));
+ else
+ weechat_log_printf (" anti_flood_prio_high : %d",
+ weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]));
+ /* anti_flood_prio_low */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]))
+ weechat_log_printf (" anti_flood_prio_low. : null (%d)",
+ IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW));
+ else
+ weechat_log_printf (" anti_flood_prio_low. : %d",
+ weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]));
+ /* away_check */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK]))
+ weechat_log_printf (" away_check . . . . . : null (%d)",
+ IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AWAY_CHECK));
+ else
+ weechat_log_printf (" away_check . . . . . : %d",
+ weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK]));
+ /* away_check_max_nicks */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]))
+ weechat_log_printf (" away_check_max_nicks : null (%d)",
+ IRC_SERVER_OPTION_INTEGER(ptr_server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS));
+ else
+ weechat_log_printf (" away_check_max_nicks : %d",
+ weechat_config_integer (ptr_server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS]));
+ /* default_msg_part */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]))
+ weechat_log_printf (" default_msg_part . . : null ('%s')",
+ IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_PART));
+ else
+ weechat_log_printf (" default_msg_part . . : '%s'",
+ weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART]));
+ /* default_msg_quit */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]))
+ weechat_log_printf (" default_msg_quit . . : null ('%s')",
+ IRC_SERVER_OPTION_STRING(ptr_server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT));
+ else
+ weechat_log_printf (" default_msg_quit . . : '%s'",
+ weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT]));
/* other server variables */
weechat_log_printf (" temp_server. . . . . : %d", ptr_server->temp_server);
weechat_log_printf (" reloading_from_config: %d", ptr_server->reloaded_from_config);
@@ -4133,6 +4224,7 @@ irc_server_print_log ()
weechat_log_printf (" lag_last_refresh . . : %ld", ptr_server->lag_last_refresh);
weechat_log_printf (" cmd_list_regexp. . . : 0x%lx", ptr_server->cmd_list_regexp);
weechat_log_printf (" last_user_message. . : %ld", ptr_server->last_user_message);
+ weechat_log_printf (" last_away_check. . . : %ld", ptr_server->last_away_check);
for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
{
weechat_log_printf (" outqueue[%02d] . . . . : 0x%lx", i, ptr_server->outqueue[i]);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 7d4400970..d841c761c 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -56,7 +56,14 @@ enum t_irc_server_option
IRC_SERVER_OPTION_COMMAND_DELAY, /* delay after execution of command */
IRC_SERVER_OPTION_AUTOJOIN, /* channels to automatically join */
IRC_SERVER_OPTION_AUTOREJOIN, /* auto rejoin channels when kicked */
- IRC_SERVER_OPTION_AUTOREJOIN_DELAY, /* delay before auto rejoin */
+ IRC_SERVER_OPTION_AUTOREJOIN_DELAY, /* delay before auto rejoin */
+ IRC_SERVER_OPTION_CONNECTION_TIMEOUT, /* timeout for connection */
+ IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH, /* anti-flood (high priority) */
+ IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW, /* anti-flood (low priority) */
+ IRC_SERVER_OPTION_AWAY_CHECK, /* delay between away checks */
+ IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS, /* max nicks for away check */
+ IRC_SERVER_OPTION_DEFAULT_MSG_PART, /* default part message */
+ IRC_SERVER_OPTION_DEFAULT_MSG_QUIT, /* default quit message */
/* number of server options */
IRC_SERVER_NUM_OPTIONS,
};
@@ -158,6 +165,7 @@ struct t_irc_server
time_t lag_last_refresh; /* last refresh of lag item */
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
time_t last_user_message; /* time of last user message (anti flood)*/
+ time_t last_away_check; /* time of last away check on server */
struct t_irc_outqueue *outqueue[2]; /* queue for outgoing messages */
/* with 2 priorities (high/low) */
struct t_irc_outqueue *last_outqueue[2]; /* last outgoing message */
@@ -223,15 +231,14 @@ extern void irc_server_autojoin_channels ();
extern int irc_server_recv_cb (void *data, int fd);
extern int irc_server_timer_sasl_cb (void *data, int remaining_calls);
extern int irc_server_timer_cb (void *data, int remaining_calls);
-extern int irc_server_timer_check_away_cb (void *data, int remaining_calls);
extern void irc_server_outqueue_free_all (struct t_irc_server *server,
int priority);
extern int irc_server_get_channel_count (struct t_irc_server *server);
extern int irc_server_get_pv_count (struct t_irc_server *server);
extern void irc_server_set_away (struct t_irc_server *server, const char *nick,
int is_away);
-extern void irc_server_remove_away ();
-extern void irc_server_check_away ();
+extern void irc_server_remove_away (struct t_irc_server *server);
+extern void irc_server_check_away (struct t_irc_server *server);
extern void irc_server_disconnect (struct t_irc_server *server,
int switch_address, int reconnect);
extern void irc_server_disconnect_all ();
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index 187265554..de5aa11d5 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -294,6 +294,7 @@ irc_upgrade_read_cb (void *data,
irc_upgrade_current_server->lag_next_check = weechat_infolist_time (infolist, "lag_next_check");
irc_upgrade_current_server->lag_last_refresh = weechat_infolist_time (infolist, "lag_last_refresh");
irc_upgrade_current_server->last_user_message = weechat_infolist_time (infolist, "last_user_message");
+ irc_upgrade_current_server->last_away_check = weechat_infolist_time (infolist, "last_away_check");
}
break;
case IRC_UPGRADE_TYPE_CHANNEL:
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index 489f9f651..61737e64f 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -52,7 +52,6 @@ WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE);
struct t_weechat_plugin *weechat_irc_plugin = NULL;
struct t_hook *irc_hook_timer = NULL;
-struct t_hook *irc_hook_timer_check_away = NULL;
int irc_signal_upgrade_received = 0; /* signal "upgrade" received ? */
@@ -245,8 +244,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
if (irc_hook_timer)
weechat_unhook (irc_hook_timer);
- if (irc_hook_timer_check_away)
- weechat_unhook (irc_hook_timer_check_away);
if (irc_signal_upgrade_received)
{
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index 4526c3f64..f836b5182 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -25,6 +25,5 @@
#define IRC_PLUGIN_NAME "irc"
extern struct t_weechat_plugin *weechat_irc_plugin;
-extern struct t_hook *irc_hook_timer_check_away;
#endif /* __WEECHAT_IRC_H */