summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-channel.c3
-rw-r--r--src/plugins/irc/irc-command.c72
-rw-r--r--src/plugins/irc/irc-config.c19
-rw-r--r--src/plugins/irc/irc-config.h2
-rw-r--r--src/plugins/irc/irc-ctcp.c2
-rw-r--r--src/plugins/irc/irc-input.c7
-rw-r--r--src/plugins/irc/irc-server.c146
-rw-r--r--src/plugins/irc/irc-server.h12
8 files changed, 165 insertions, 98 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 533bc9f72..6acadd536 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -365,7 +365,8 @@ irc_channel_check_away (struct t_irc_server *server,
|| (channel->nicks_count <= weechat_config_integer (irc_config_network_away_check_max_nicks)))
{
channel->checking_away++;
- irc_server_sendf (server, 1, "WHO %s", channel->name);
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW,
+ "WHO %s", channel->name);
}
else
irc_channel_remove_away (channel);
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index a28d9757a..7f0314c42 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -332,7 +332,8 @@ irc_command_me_channel (struct t_irc_server *server,
{
char *string;
- irc_server_sendf (server, 1, "PRIVMSG %s :\01ACTION %s\01",
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :\01ACTION %s\01",
channel->name,
(arguments && arguments[0]) ? arguments : "");
string = (arguments && arguments[0]) ?
@@ -392,7 +393,8 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
{
server->is_away = 1;
server->away_time = time (NULL);
- irc_server_sendf (server, 1, "AWAY :%s", arguments);
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "AWAY :%s", arguments);
if (weechat_config_integer (irc_config_look_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF)
{
string = irc_color_decode (arguments,
@@ -452,7 +454,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
/* if server is connected, send away command now */
if (server->is_connected)
{
- irc_server_sendf (server, 1, "AWAY");
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "AWAY");
server->is_away = 0;
if (server->away_time != 0)
{
@@ -787,7 +789,8 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
gettimeofday (&tv, NULL);
snprintf (str_time, sizeof (str_time), "%ld %ld",
tv.tv_sec, tv.tv_usec);
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01PING %s\01",
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :\01PING %s\01",
argv[1], str_time);
weechat_printf (ptr_server->buffer,
_("%sCTCP query to %s%s%s: %s%s%s%s%s"),
@@ -803,7 +806,8 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
}
else
{
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01%s%s%s\01",
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :\01%s%s%s\01",
argv[1],
irc_cmd,
(argv_eol[3]) ? " " : "",
@@ -2158,7 +2162,8 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
if (string)
free (string);
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :%s",
ptr_channel->name, argv_eol[arg_text]);
}
else
@@ -2180,7 +2185,9 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
if (string)
free (string);
}
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server,
+ IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :%s",
targets[i], argv_eol[arg_text]);
}
else
@@ -2237,7 +2244,9 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
if (string)
free (string);
}
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server,
+ IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :%s",
targets[i], argv_eol[arg_text]);
}
}
@@ -2386,7 +2395,8 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
(string) ? string : argv_eol[arg_text]);
if (string)
free (string);
- irc_server_sendf (ptr_server, 1, "NOTICE %s :%s",
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "NOTICE %s :%s",
argv[arg_nick], argv_eol[arg_text]);
}
else
@@ -2661,7 +2671,8 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
(string) ? string : argv_eol[arg_text]);
if (string)
free (string);
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :%s",
argv[arg_nick], argv_eol[arg_text]);
}
}
@@ -2694,13 +2705,15 @@ irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc,
ptr_server = irc_server_search (argv[2]);
if (!ptr_server || (ptr_server->sock < 0))
return WEECHAT_RC_ERROR;
- irc_server_sendf (ptr_server, 1, "%s", argv_eol[3]);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "%s", argv_eol[3]);
}
else
{
if (!ptr_server || (ptr_server->sock < 0))
return WEECHAT_RC_ERROR;
- irc_server_sendf (ptr_server, 1, "%s", argv_eol[1]);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "%s", argv_eol[1]);
}
}
else
@@ -3307,7 +3320,10 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
for (ptr_server2 = irc_servers; ptr_server2;
ptr_server2 = ptr_server2->next_server)
{
- irc_server_outqueue_free_all (ptr_server2);
+ for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
+ {
+ irc_server_outqueue_free_all (ptr_server2, i);
+ }
}
weechat_printf (NULL,
_("%s: messages outqueue DELETED for all "
@@ -3402,10 +3418,12 @@ irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc,
if (argc > 1)
{
if (argc > 2)
- irc_server_sendf (ptr_server, 1, "SQUERY %s :%s",
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "SQUERY %s :%s",
argv[1], argv_eol[2]);
else
- irc_server_sendf (ptr_server, 1, "SQUERY %s", argv_eol[1]);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "SQUERY %s", argv_eol[1]);
}
else
{
@@ -3562,13 +3580,14 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
if (new_topic)
{
if (weechat_strcasecmp (new_topic, "-delete") == 0)
- irc_server_sendf (ptr_server, 1, "TOPIC %s :",
- channel_name);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "TOPIC %s :", channel_name);
else
{
new_topic_color = irc_color_encode (new_topic,
weechat_config_boolean (irc_config_network_colors_send));
- irc_server_sendf (ptr_server, 1, "TOPIC %s :%s",
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "TOPIC %s :%s",
channel_name,
(new_topic_color) ? new_topic_color : new_topic);
if (new_topic_color)
@@ -3576,7 +3595,8 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
}
}
else
- irc_server_sendf (ptr_server, 1, "TOPIC %s", channel_name);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "TOPIC %s", channel_name);
return WEECHAT_RC_OK;
}
@@ -3737,14 +3757,15 @@ irc_command_version (void *data, struct t_gui_buffer *buffer, int argc,
{
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
&& irc_nick_search (ptr_channel, argv[1]))
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01VERSION\01",
- argv[1]);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :\01VERSION\01", argv[1]);
else
- irc_server_sendf (ptr_server, 1, "VERSION %s",
- argv[1]);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "VERSION %s", argv[1]);
}
else
- irc_server_sendf (ptr_server, 1, "VERSION");
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "VERSION");
return WEECHAT_RC_OK;
}
@@ -3803,7 +3824,8 @@ irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc,
(void) argv;
if (argc > 1)
- irc_server_sendf (ptr_server, 1, "WALLOPS :%s", argv_eol[1]);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "WALLOPS :%s", argv_eol[1]);
else
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "wallops");
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index d411ce447..7a5ecce84 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -90,7 +90,7 @@ 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_anti_flood;
+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;
@@ -1559,12 +1559,19 @@ irc_config_init ()
N_("disconnect after important lag (in minutes, 0 = never "
"disconnect)"),
NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
- irc_config_network_anti_flood = weechat_config_new_option (
+ irc_config_network_anti_flood[0] = weechat_config_new_option (
irc_config_file, ptr_section,
- "anti_flood", "integer",
- N_("anti-flood: # seconds between two user messages (0 = no "
- "anti-flood)"),
- NULL, 0, 5, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ "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",
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 18900b1bc..e463928e8 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -108,7 +108,7 @@ 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_anti_flood;
+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-ctcp.c b/src/plugins/irc/irc-ctcp.c
index a2aeaff15..459ab2fee 100644
--- a/src/plugins/irc/irc-ctcp.c
+++ b/src/plugins/irc/irc-ctcp.c
@@ -245,7 +245,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
const char *nick, const char *ctcp,
const char *arguments)
{
- irc_server_sendf (server, 1,
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW,
"NOTICE %s :\01%s%s%s\01",
nick, ctcp,
(arguments) ? " " : "",
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index c7e68cb8f..2d75c1f41 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -124,8 +124,8 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, char *text)
}
}
- irc_server_sendf (ptr_server, 1, "PRIVMSG %s :%s",
- ptr_channel->name, text);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ "PRIVMSG %s :%s", ptr_channel->name, text);
irc_input_user_message_display (buffer, text);
if (next)
@@ -157,7 +157,8 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
&& (input_data[0] == '/') && (input_data[1] != '/'))
{
if (ptr_server)
- irc_server_sendf (ptr_server, 1, input_data + 1);
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ input_data + 1);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 087cc4735..eee8b4684 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -317,8 +317,11 @@ irc_server_alloc (const char *name)
weechat_config_integer (irc_config_network_lag_check);
new_server->cmd_list_regexp = NULL;
new_server->last_user_message = 0;
- new_server->outqueue = NULL;
- new_server->last_outqueue = NULL;
+ for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
+ {
+ new_server->outqueue[i] = NULL;
+ new_server->last_outqueue[i] = NULL;
+ }
new_server->buffer = NULL;
new_server->buffer_as_string = NULL;
new_server->channels = NULL;
@@ -581,8 +584,9 @@ irc_server_apply_command_line_options (struct t_irc_server *server,
*/
void
-irc_server_outqueue_add (struct t_irc_server *server, const char *command,
- const char *msg1, const char *msg2, int modified)
+irc_server_outqueue_add (struct t_irc_server *server, int priority,
+ const char *command, const char *msg1,
+ const char *msg2, int modified)
{
struct t_irc_outqueue *new_outqueue;
@@ -594,13 +598,13 @@ irc_server_outqueue_add (struct t_irc_server *server, const char *command,
new_outqueue->message_after_mod = (msg2) ? strdup (msg2) : NULL;
new_outqueue->modified = modified;
- new_outqueue->prev_outqueue = server->last_outqueue;
+ new_outqueue->prev_outqueue = server->last_outqueue[priority];
new_outqueue->next_outqueue = NULL;
- if (server->outqueue)
- server->last_outqueue->next_outqueue = new_outqueue;
+ if (server->outqueue[priority])
+ server->last_outqueue[priority]->next_outqueue = new_outqueue;
else
- server->outqueue = new_outqueue;
- server->last_outqueue = new_outqueue;
+ server->outqueue[priority] = new_outqueue;
+ server->last_outqueue[priority] = new_outqueue;
}
}
@@ -610,17 +614,18 @@ irc_server_outqueue_add (struct t_irc_server *server, const char *command,
void
irc_server_outqueue_free (struct t_irc_server *server,
+ int priority,
struct t_irc_outqueue *outqueue)
{
struct t_irc_outqueue *new_outqueue;
/* remove outqueue message */
- if (server->last_outqueue == outqueue)
- server->last_outqueue = outqueue->prev_outqueue;
+ if (server->last_outqueue[priority] == outqueue)
+ server->last_outqueue[priority] = outqueue->prev_outqueue;
if (outqueue->prev_outqueue)
{
(outqueue->prev_outqueue)->next_outqueue = outqueue->next_outqueue;
- new_outqueue = server->outqueue;
+ new_outqueue = server->outqueue[priority];
}
else
new_outqueue = outqueue->next_outqueue;
@@ -636,7 +641,7 @@ irc_server_outqueue_free (struct t_irc_server *server,
if (outqueue->message_after_mod)
free (outqueue->message_after_mod);
free (outqueue);
- server->outqueue = new_outqueue;
+ server->outqueue[priority] = new_outqueue;
}
/*
@@ -644,11 +649,12 @@ irc_server_outqueue_free (struct t_irc_server *server,
*/
void
-irc_server_outqueue_free_all (struct t_irc_server *server)
+irc_server_outqueue_free_all (struct t_irc_server *server, int priority)
{
- while (server->outqueue)
+ while (server->outqueue[priority])
{
- irc_server_outqueue_free (server, server->outqueue);
+ irc_server_outqueue_free (server, priority,
+ server->outqueue[priority]);
}
}
@@ -690,8 +696,10 @@ irc_server_free_data (struct t_irc_server *server)
free (server->prefix);
if (server->away_message)
free (server->away_message);
- if (server->outqueue)
- irc_server_outqueue_free_all (server);
+ for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
+ {
+ irc_server_outqueue_free_all (server, i);
+ }
if (server->channels)
irc_channel_free_all (server);
if (server->buffer_as_string)
@@ -971,49 +979,55 @@ irc_server_outqueue_send (struct t_irc_server *server)
{
time_t time_now;
char *pos;
+ int priority;
- if (server->outqueue)
+ time_now = time (NULL);
+
+ /* detect if system clock has been changed (now lower than before) */
+ if (server->last_user_message > time_now)
+ server->last_user_message = time_now;
+
+ for (priority = 0; priority < IRC_SERVER_NUM_OUTQUEUES_PRIO; priority++)
{
- time_now = time (NULL);
-
- /* detect if system clock has been changed (now lower than before) */
- if (server->last_user_message > time_now)
- server->last_user_message = time_now;
-
- if (time_now >= server->last_user_message +
- weechat_config_integer (irc_config_network_anti_flood))
+ if (server->outqueue[priority]
+ && (time_now >= server->last_user_message +
+ weechat_config_integer (irc_config_network_anti_flood[priority])))
{
- if (server->outqueue->message_before_mod)
+ if (server->outqueue[priority]->message_before_mod)
{
- pos = strchr (server->outqueue->message_before_mod, '\r');
+ pos = strchr (server->outqueue[priority]->message_before_mod,
+ '\r');
if (pos)
pos[0] = '\0';
irc_raw_print (server, 1, 0,
- server->outqueue->message_before_mod);
+ server->outqueue[priority]->message_before_mod);
if (pos)
pos[0] = '\r';
}
- if (server->outqueue->message_after_mod)
+ if (server->outqueue[priority]->message_after_mod)
{
- pos = strchr (server->outqueue->message_after_mod, '\r');
+ pos = strchr (server->outqueue[priority]->message_after_mod,
+ '\r');
if (pos)
pos[0] = '\0';
- irc_raw_print (server, 1, server->outqueue->modified,
- server->outqueue->message_after_mod);
+ irc_raw_print (server, 1, server->outqueue[priority]->modified,
+ server->outqueue[priority]->message_after_mod);
if (pos)
pos[0] = '\r';
/* send signal with command that will be sent to server */
irc_server_send_signal (server, "irc_out",
- server->outqueue->command,
- server->outqueue->message_after_mod);
+ server->outqueue[priority]->command,
+ server->outqueue[priority]->message_after_mod);
/* send command */
- irc_server_send (server, server->outqueue->message_after_mod,
- strlen (server->outqueue->message_after_mod));
+ irc_server_send (server, server->outqueue[priority]->message_after_mod,
+ strlen (server->outqueue[priority]->message_after_mod));
server->last_user_message = time_now;
}
- irc_server_outqueue_free (server, server->outqueue);
+ irc_server_outqueue_free (server, priority,
+ server->outqueue[priority]);
+ break;
}
}
}
@@ -1140,9 +1154,12 @@ irc_server_parse_message (const char *message, char **nick, char **host,
/*
* irc_server_send_one_msg: send one message to IRC server
- * if queue_msg == 1, then messages are in a queue and
+ * if queue_msg > 0, then messages are in a queue and
* sent slowly (to be sure there will not be any
- * "excess flood")
+ * "excess flood"), value of queue_msg is priority:
+ * 1 = higher priority, for user messages
+ * 2 = lower priority, for other messages (like
+ * auto reply to CTCP queries)
* return: 1 if ok, 0 if error
*/
@@ -1221,17 +1238,17 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg,
server->last_user_message = time_now;
add_to_queue = 0;
- if (queue_msg
- && (server->outqueue
- || ((weechat_config_integer (irc_config_network_anti_flood) > 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)))))
- add_to_queue = 1;
+ weechat_config_integer (irc_config_network_anti_flood[queue_msg - 1])))))
+ add_to_queue = queue_msg;
- if (add_to_queue)
+ if (add_to_queue > 0)
{
/* queue message (do not send anything now) */
- irc_server_outqueue_add (server, command,
+ irc_server_outqueue_add (server, add_to_queue - 1, command,
(new_msg && first_message) ? message : NULL,
buffer,
(new_msg) ? 1 : 0);
@@ -1252,7 +1269,7 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg,
rc = 0;
else
{
- if (queue_msg)
+ if (queue_msg > 0)
server->last_user_message = time_now;
}
}
@@ -1287,8 +1304,12 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg,
/*
* irc_server_sendf: send formatted data to IRC server
* many messages may be sent, separated by '\n'
- * if queue_msg == 1, then messages are in a queue and sent
- * slowly (to be sure there will not be any "excess flood")
+ * if queue_msg > 0, then messages are in a queue and sent
+ * slowly (to be sure there will not be any "excess flood"),
+ * value of queue_msg is priority:
+ * 1 = higher priority, for user messages
+ * 2 = lower priority, for other messages (like auto reply
+ * to CTCP queries)
*/
void
@@ -1773,6 +1794,8 @@ irc_server_timer_check_away_cb (void *data, int remaining_calls)
void
irc_server_close_connection (struct t_irc_server *server)
{
+ int i;
+
if (server->hook_fd)
{
weechat_unhook (server->hook_fd);
@@ -1813,7 +1836,10 @@ irc_server_close_connection (struct t_irc_server *server)
free (server->unterminated_message);
server->unterminated_message = NULL;
}
- irc_server_outqueue_free_all (server);
+ for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
+ {
+ irc_server_outqueue_free_all (server, i);
+ }
/* server is now disconnected */
server->is_connected = 0;
@@ -3024,7 +3050,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
{
filename = weechat_infolist_string (infolist, "filename");
spaces_in_name = (strchr (filename, ' ') != NULL);
- irc_server_sendf (server, 1,
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
"PRIVMSG %s :\01DCC SEND %s%s%s "
"%s %d %s\01",
weechat_infolist_string (infolist, "remote_nick"),
@@ -3037,7 +3063,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
}
else if (strcmp (type, "chat_send") == 0)
{
- irc_server_sendf (server, 1,
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
"PRIVMSG %s :\01DCC CHAT chat %s %d\01",
weechat_infolist_string (infolist, "remote_nick"),
weechat_infolist_string (infolist, "address"),
@@ -3094,7 +3120,7 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal,
{
filename = weechat_infolist_string (infolist, "filename");
spaces_in_name = (strchr (filename, ' ') != NULL);
- irc_server_sendf (server, 1,
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
"PRIVMSG %s :\01DCC RESUME %s%s%s %d %s\01",
weechat_infolist_string (infolist, "remote_nick"),
(spaces_in_name) ? "\"" : "",
@@ -3153,7 +3179,7 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal,
{
filename = weechat_infolist_string (infolist, "filename");
spaces_in_name = (strchr (filename, ' ') != NULL);
- irc_server_sendf (server, 1,
+ irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
"PRIVMSG %s :\01DCC ACCEPT %s%s%s %d %s\01",
weechat_infolist_string (infolist, "remote_nick"),
(spaces_in_name) ? "\"" : "",
@@ -3313,6 +3339,7 @@ irc_server_print_log ()
{
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
+ int i;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -3484,8 +3511,11 @@ irc_server_print_log ()
weechat_log_printf (" lag_next_check . . . : %ld", ptr_server->lag_next_check);
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 (" outqueue . . . . . . : 0x%lx", ptr_server->outqueue);
- weechat_log_printf (" last_outqueue. . . . : 0x%lx", ptr_server->last_outqueue);
+ for (i = 0; i < IRC_SERVER_NUM_OUTQUEUES_PRIO; i++)
+ {
+ weechat_log_printf (" outqueue[%02d] . . . . : 0x%lx", i, ptr_server->outqueue[i]);
+ weechat_log_printf (" last_outqueue[%02d]. . : 0x%lx", i, ptr_server->last_outqueue[i]);
+ }
weechat_log_printf (" buffer . . . . . . . : 0x%lx", ptr_server->buffer);
weechat_log_printf (" buffer_as_string . . : 0x%lx", ptr_server->buffer_as_string);
weechat_log_printf (" channels . . . . . . : 0x%lx", ptr_server->channels);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index bc7123d1e..bc3a129f9 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -83,6 +83,10 @@ enum t_irc_server_option
#define IRC_SERVER_DEFAULT_NICKS "weechat1,weechat2,weechat3," \
"weechat4,weechat5"
+#define IRC_SERVER_OUTQUEUE_PRIO_HIGH 1
+#define IRC_SERVER_OUTQUEUE_PRIO_LOW 2
+#define IRC_SERVER_NUM_OUTQUEUES_PRIO 2
+
/* output queue of messages to server (for sending slowly to server) */
struct t_irc_outqueue
@@ -137,8 +141,9 @@ struct t_irc_server
time_t lag_next_check; /* time for next check */
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
time_t last_user_message; /* time of last user message (anti flood)*/
- struct t_irc_outqueue *outqueue; /* queue for outgoing user msgs */
- struct t_irc_outqueue *last_outqueue; /* last outgoing user message */
+ 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 */
struct t_gui_buffer *buffer; /* GUI buffer allocated for server */
char *buffer_as_string; /* used to return buffer info */
struct t_irc_channel *channels; /* opened channels on server */
@@ -194,7 +199,8 @@ extern void irc_server_autojoin_channels ();
extern int irc_server_recv_cb (void *arg_server, int fd);
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);
+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,