summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-03 21:49:35 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-03 22:11:31 +0200
commitf6b69c9098d7fde8ea038afb97e72c460665983c (patch)
tree8f8a68b046f1512f2b8696cd0af2ac0b66d41ec7 /src
parentbd5e8dc33bde66a7eff97831e35413b833504fea (diff)
downloadweechat-f6b69c9098d7fde8ea038afb97e72c460665983c.zip
irc: add support of capability "batch" (closes #1292)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/CMakeLists.txt1
-rw-r--r--src/plugins/irc/irc-batch.c379
-rw-r--r--src/plugins/irc/irc-batch.h62
-rw-r--r--src/plugins/irc/irc-channel.c1
-rw-r--r--src/plugins/irc/irc-command.c13
-rw-r--r--src/plugins/irc/irc-command.h8
-rw-r--r--src/plugins/irc/irc-ctcp.c17
-rw-r--r--src/plugins/irc/irc-info.c4
-rw-r--r--src/plugins/irc/irc-input.c2
-rw-r--r--src/plugins/irc/irc-protocol.c345
-rw-r--r--src/plugins/irc/irc-protocol.h6
-rw-r--r--src/plugins/irc/irc-server.c28
-rw-r--r--src/plugins/irc/irc-server.h2
13 files changed, 731 insertions, 137 deletions
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt
index a0a853e9c..6ca8cab7c 100644
--- a/src/plugins/irc/CMakeLists.txt
+++ b/src/plugins/irc/CMakeLists.txt
@@ -20,6 +20,7 @@
add_library(irc MODULE
irc.c irc.h
irc-bar-item.c irc-bar-item.h
+ irc-batch.c irc-batch.h
irc-buffer.c irc-buffer.h
irc-channel.c irc-channel.h
irc-color.c irc-color.h
diff --git a/src/plugins/irc/irc-batch.c b/src/plugins/irc/irc-batch.c
new file mode 100644
index 000000000..02f557d3e
--- /dev/null
+++ b/src/plugins/irc/irc-batch.c
@@ -0,0 +1,379 @@
+/*
+ * irc-batch.c - functions for managing batched events
+ *
+ * Copyright (C) 2023 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WeeChat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "../weechat-plugin.h"
+#include "irc.h"
+#include "irc-batch.h"
+#include "irc-message.h"
+#include "irc-protocol.h"
+#include "irc-server.h"
+
+
+/*
+ * Searches a batch reference.
+ *
+ * Returns pointer to batch, NULL if not found.
+ */
+
+struct t_irc_batch *
+irc_batch_search (struct t_irc_server *server, const char *reference)
+{
+ struct t_irc_batch *ptr_batch;
+
+ if (!server || !reference)
+ return NULL;
+
+ for (ptr_batch = server->batches; ptr_batch;
+ ptr_batch = ptr_batch->next_batch)
+ {
+ if (strcmp (ptr_batch->reference, reference) == 0)
+ return ptr_batch;
+ }
+
+ /* batch not found */
+ return NULL;
+}
+
+/*
+ * Adds a batch to list of batched events.
+ */
+
+void
+irc_batch_add_to_list (struct t_irc_server *server, struct t_irc_batch *batch)
+{
+ if (server->last_batch)
+ server->last_batch->next_batch = batch;
+ else
+ server->batches = batch;
+ batch->prev_batch = server->last_batch;
+ batch->next_batch = NULL;
+ server->last_batch = batch;
+}
+
+/*
+ * Starts a batch.
+ *
+ * Returns pointer to new batch, NULL if error.
+ */
+
+struct t_irc_batch *
+irc_batch_start_batch (struct t_irc_server *server, const char *reference,
+ const char *parent_ref, const char *type,
+ const char *parameters)
+{
+ struct t_irc_batch *ptr_batch;
+
+ if (!server || !reference || !type)
+ return NULL;
+
+ /* check if reference already exists */
+ ptr_batch = irc_batch_search (server, reference);
+ if (ptr_batch)
+ return NULL;
+
+ ptr_batch = malloc (sizeof (*ptr_batch));
+ if (!ptr_batch)
+ return NULL;
+
+ ptr_batch->reference = strdup (reference);
+ ptr_batch->parent_ref = (parent_ref) ? strdup (parent_ref) : NULL;
+ ptr_batch->type = strdup (type);
+ ptr_batch->parameters = (parameters) ? strdup (parameters) : NULL;
+ ptr_batch->start_time = time (NULL);
+ ptr_batch->messages = NULL;
+ ptr_batch->end_received = 0;
+ ptr_batch->messages_processed = 0;
+
+ irc_batch_add_to_list (server, ptr_batch);
+
+ return ptr_batch;
+}
+
+/*
+ * Adds an IRC message to a batch reference.
+ *
+ * Returns:
+ * 1: OK, message added
+ * 0: error, message not added
+ */
+
+int
+irc_batch_add_message (struct t_irc_server *server, const char *reference,
+ const char *irc_message)
+{
+ struct t_irc_batch *ptr_batch;
+
+ if (!server || !reference || !irc_message)
+ return 0;
+
+ ptr_batch = irc_batch_search (server, reference);
+ if (!ptr_batch)
+ return 0;
+
+ if (!ptr_batch->messages)
+ ptr_batch->messages = weechat_string_dyn_alloc (256);
+ if (!ptr_batch->messages)
+ return 0;
+
+ if ((*(ptr_batch->messages))[0])
+ weechat_string_dyn_concat (ptr_batch->messages, "\n", -1);
+ weechat_string_dyn_concat (ptr_batch->messages, irc_message, -1);
+
+ return 1;
+}
+
+/*
+ * Frees a batch.
+ */
+
+void
+irc_batch_free (struct t_irc_server *server, struct t_irc_batch *batch)
+{
+ if (batch->reference)
+ free (batch->reference);
+ if (batch->parent_ref)
+ free (batch->parent_ref);
+ if (batch->type)
+ free (batch->type);
+ if (batch->parameters)
+ free (batch->parameters);
+ if (batch->messages)
+ weechat_string_dyn_free (batch->messages, 1);
+
+ /* remove batch from list */
+ if (batch->prev_batch)
+ (batch->prev_batch)->next_batch = batch->next_batch;
+ if (batch->next_batch)
+ (batch->next_batch)->prev_batch = batch->prev_batch;
+ if (server->batches == batch)
+ server->batches = batch->next_batch;
+ if (server->last_batch == batch)
+ server->last_batch = batch->prev_batch;
+
+ free (batch);
+}
+
+/*
+ * Frees all batches from server.
+ */
+
+void
+irc_batch_free_all (struct t_irc_server *server)
+{
+ while (server->batches)
+ {
+ irc_batch_free (server, server->batches);
+ }
+}
+
+/*
+ * Processes messages in a batch.
+ */
+
+void
+irc_batch_process_messages (struct t_irc_server *server,
+ struct t_irc_batch *batch)
+{
+ char **list_messages, *command, *channel, modifier_data[1024], *new_messages;
+ int i, count_messages;
+
+ if (!batch || !batch->messages)
+ return;
+
+ snprintf (modifier_data, sizeof (modifier_data),
+ "%s,%s,%s",
+ server->name,
+ batch->type,
+ batch->parameters);
+ new_messages = weechat_hook_modifier_exec ("irc_batch", modifier_data,
+ *(batch->messages));
+
+ /* no changes in new messages */
+ if (new_messages && (strcmp (*(batch->messages), new_messages) == 0))
+ {
+ free (new_messages);
+ new_messages = NULL;
+ }
+
+ /* messages not dropped? */
+ if (!new_messages || new_messages[0])
+ {
+ list_messages = weechat_string_split (
+ (new_messages) ? new_messages : *(batch->messages),
+ "\n", NULL, 0, 0, &count_messages);
+ if (list_messages)
+ {
+ for (i = 0; i < count_messages; i++)
+ {
+ irc_message_parse (server,
+ list_messages[i],
+ NULL, /* tags */
+ NULL, /* message_without_tags */
+ NULL, /* nick */
+ NULL, /* user */
+ NULL, /* host */
+ &command,
+ &channel,
+ NULL, /* arguments */
+ NULL, /* text */
+ NULL, /* params */
+ NULL, /* num_params */
+ NULL, /* pos_command */
+ NULL, /* pos_arguments */
+ NULL, /* pos_channel */
+ NULL); /* pos_text */
+ /* call receive callback, ignoring batch tags */
+ irc_protocol_recv_command (server, list_messages[i], command,
+ channel, 1);
+ if (command)
+ free (command);
+ if (channel)
+ free (channel);
+ }
+ weechat_string_free_split (list_messages);
+ }
+ }
+
+ if (new_messages)
+ free (new_messages);
+}
+
+/*
+ * Ends a batch reference.
+ */
+
+void
+irc_batch_end_batch (struct t_irc_server *server, const char *reference)
+{
+ struct t_irc_batch *ptr_batch, *ptr_next_batch, *ptr_parent_batch;
+ int num_processed;
+
+ if (!server || !reference)
+ return;
+
+ ptr_batch = irc_batch_search (server, reference);
+ if (!ptr_batch)
+ return;
+
+ ptr_batch->end_received = 1;
+
+ /*
+ * process messages in all batches, if these conditions are met:
+ * - end_received = 1
+ * - no parent or the parent has messages_processed = 1
+ */
+ while (1)
+ {
+ num_processed = 0;
+ for (ptr_batch = server->batches; ptr_batch;
+ ptr_batch = ptr_batch->next_batch)
+ {
+ if (!ptr_batch->end_received || ptr_batch->messages_processed)
+ continue;
+ ptr_parent_batch = irc_batch_search (server, ptr_batch->parent_ref);
+ if (!ptr_parent_batch || ptr_parent_batch->messages_processed)
+ {
+ irc_batch_process_messages (server, ptr_batch);
+ ptr_batch->messages_processed = 1;
+ num_processed++;
+ }
+ }
+ if (num_processed == 0)
+ break;
+ }
+
+ /* remove all batches that are processed */
+ ptr_batch = server->batches;
+ while (ptr_batch)
+ {
+ ptr_next_batch = ptr_batch->next_batch;
+ if (ptr_batch->messages_processed)
+ irc_batch_free (server, ptr_batch);
+ ptr_batch = ptr_next_batch;
+ }
+}
+
+/*
+ * Returns hdata for batch.
+ */
+
+struct t_hdata *
+irc_batch_hdata_batch_cb (const void *pointer, void *data,
+ const char *hdata_name)
+{
+ struct t_hdata *hdata;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+
+ hdata = weechat_hdata_new (hdata_name, "prev_batch", "next_batch",
+ 0, 0, NULL, NULL);
+ if (hdata)
+ {
+ WEECHAT_HDATA_VAR(struct t_irc_batch, reference, STRING, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, parent_ref, STRING, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, type, STRING, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, parameters, STRING, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, start_time, TIME, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, messages, POINTER, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, end_received, INTEGER, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, messages_processed, INTEGER, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, prev_batch, POINTER, 0, NULL, hdata_name);
+ WEECHAT_HDATA_VAR(struct t_irc_batch, next_batch, POINTER, 0, NULL, hdata_name);
+ }
+ return hdata;
+}
+
+/*
+ * Prints batch infos in WeeChat log file (usually for crash dump).
+ */
+
+void
+irc_batch_print_log (struct t_irc_server *server)
+{
+ struct t_irc_batch *ptr_batch;
+
+ for (ptr_batch = server->batches; ptr_batch;
+ ptr_batch = ptr_batch->next_batch)
+ {
+ weechat_log_printf ("");
+ weechat_log_printf (" => batch (addr:0x%lx):", ptr_batch);
+ weechat_log_printf (" reference . . . . . : '%s'", ptr_batch->reference);
+ weechat_log_printf (" parent_ref. . . . . : '%s'", ptr_batch->parent_ref);
+ weechat_log_printf (" type. . . . . . . . : '%s'", ptr_batch->type);
+ weechat_log_printf (" parameters. . . . . : '%s'", ptr_batch->parameters);
+ weechat_log_printf (" start_time. . . . . : %lld", (long long)ptr_batch->start_time);
+ weechat_log_printf (" message . . . . . . : 0x%lx ('%s')",
+ ptr_batch->messages,
+ (ptr_batch->messages) ? *(ptr_batch->messages) : NULL);
+ weechat_log_printf (" end_received. . . . : %d", ptr_batch->end_received);
+ weechat_log_printf (" messages_processed. : %d", ptr_batch->messages_processed);
+ weechat_log_printf (" prev_batch. . . . . : 0x%lx", ptr_batch->prev_batch);
+ weechat_log_printf (" next_batch. . . . . : 0x%lx", ptr_batch->next_batch);
+ }
+}
diff --git a/src/plugins/irc/irc-batch.h b/src/plugins/irc/irc-batch.h
new file mode 100644
index 000000000..bd8dec30c
--- /dev/null
+++ b/src/plugins/irc/irc-batch.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2023 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WeeChat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef WEECHAT_PLUGIN_IRC_BATCH_H
+#define WEECHAT_PLUGIN_IRC_BATCH_H
+
+#include <time.h>
+
+struct t_irc_server;
+
+struct t_irc_batch
+{
+ char *reference; /* batch reference */
+ char *parent_ref; /* ref of parent batch (optional) */
+ char *type; /* type */
+ char *parameters; /* parameters */
+ time_t start_time; /* start time (to auto-purge if */
+ /* batch end is not received) */
+ char **messages; /* messages separated by '\n' */
+ int end_received; /* batch end reference received */
+ int messages_processed; /* 1 if msgs have been processed */
+ struct t_irc_batch *prev_batch; /* link to previous batch */
+ struct t_irc_batch *next_batch; /* link to next batch */
+};
+
+extern struct t_irc_batch *irc_batch_search (struct t_irc_server *server,
+ const char *reference);
+extern struct t_irc_batch *irc_batch_start_batch (struct t_irc_server *server,
+ const char *reference,
+ const char *parent_ref,
+ const char *type,
+ const char *parameters);
+extern int irc_batch_add_message (struct t_irc_server *server,
+ const char *reference,
+ const char *irc_message);
+extern void irc_batch_end_batch (struct t_irc_server *server,
+ const char *reference);
+extern void irc_batch_free (struct t_irc_server *server,
+ struct t_irc_batch *batch);
+extern void irc_batch_free_all (struct t_irc_server *server);
+extern struct t_hdata *irc_batch_hdata_batch_cb (const void *pointer,
+ void *data,
+ const char *hdata_name);
+extern void irc_batch_print_log (struct t_irc_server *server);
+
+#endif /* WEECHAT_PLUGIN_IRC_BATCH_H */
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 0369fd98d..fe5342973 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -1491,6 +1491,7 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
ptr_channel->buffer,
0,
irc_protocol_tags (
+ server,
"nick_back",
NULL,
NULL,
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 1e8ec65c4..35c618d54 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -1078,7 +1078,8 @@ irc_command_me_channel_display (struct t_irc_server *server,
weechat_printf_date_tags (
channel->buffer,
0,
- irc_protocol_tags ("privmsg",
+ irc_protocol_tags (server,
+ "privmsg",
NULL,
"irc_action,self_msg,notify_none,no_highlight",
server->nick, NULL),
@@ -1904,7 +1905,8 @@ IRC_COMMAND_CALLBACK(ctcp)
irc_msgbuffer_get_target_buffer (
ptr_server, ctcp_target, NULL, "ctcp", NULL),
0,
- irc_protocol_tags ("privmsg",
+ irc_protocol_tags (ptr_server,
+ "privmsg",
NULL,
"irc_ctcp,self_msg,notify_none,no_highlight",
NULL, NULL),
@@ -3802,6 +3804,7 @@ IRC_COMMAND_CALLBACK(msg)
ptr_server->buffer,
0,
irc_protocol_tags (
+ ptr_server,
"privmsg",
NULL,
"self_msg,notify_none,no_highlight",
@@ -6953,9 +6956,9 @@ irc_command_init ()
"Without argument, \"ls\" and \"list\" are sent.\n"
"\n"
"Capabilities supported by WeeChat are: "
- "account-notify, away-notify, cap-notify, chghost, extended-join, "
- "invite-notify, message-tags, multi-prefix, server-time, setname, "
- "userhost-in-names.\n"
+ "account-notify, away-notify, batch, cap-notify, chghost, "
+ "extended-join, invite-notify, message-tags, multi-prefix, "
+ "server-time, setname, userhost-in-names.\n"
"\n"
"The capabilities to automatically enable on servers can be set "
"in option irc.server_default.capabilities (or by server in "
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index 1afc3ed42..e97372edf 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -54,10 +54,10 @@ struct t_irc_channel;
}
/* list of supported capabilities (for completion in command /cap) */
-#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \
- "account-notify|away-notify|cap-notify|chghost|extended-join|" \
- "invite-notify|message-tags|multi-prefix|server-time|setname|" \
- "userhost-in-names"
+#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \
+ "account-notify|away-notify|batch|cap-notify|chghost|" \
+ "extended-join|invite-notify|message-tags|multi-prefix|" \
+ "server-time|setname|userhost-in-names"
/* list of supported CTCPs (for completion in command /ctcp) */
#define IRC_COMMAND_CTCP_SUPPORTED_COMPLETION \
diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c
index 2197867ce..28a96d714 100644
--- a/src/plugins/irc/irc-ctcp.c
+++ b/src/plugins/irc/irc-ctcp.c
@@ -143,7 +143,7 @@ irc_ctcp_display_request (struct t_irc_server *server,
server, nick, NULL, "ctcp",
(channel) ? channel->buffer : NULL),
date,
- irc_protocol_tags (command, tags, "irc_ctcp", NULL, address),
+ irc_protocol_tags (server, command, tags, "irc_ctcp", NULL, address),
_("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 0, NULL, nick),
@@ -211,7 +211,8 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server, time_t date,
irc_msgbuffer_get_target_buffer (
server, nick, NULL, "ctcp", NULL),
date,
- irc_protocol_tags (command, tags, "irc_ctcp", NULL, NULL),
+ irc_protocol_tags (server, command, tags, "irc_ctcp",
+ NULL, NULL),
/* TRANSLATORS: %.3fs is a float number + "s" ("seconds") */
_("%sCTCP reply from %s%s%s: %s%s%s %.3fs"),
weechat_prefix ("network"),
@@ -230,7 +231,8 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server, time_t date,
irc_msgbuffer_get_target_buffer (
server, nick, NULL, "ctcp", NULL),
date,
- irc_protocol_tags (command, tags, "irc_ctcp", NULL, address),
+ irc_protocol_tags (server, command, tags, "irc_ctcp", NULL,
+ address),
_("%sCTCP reply from %s%s%s: %s%s%s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 0, NULL, nick),
@@ -249,7 +251,7 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server, time_t date,
irc_msgbuffer_get_target_buffer (
server, nick, NULL, "ctcp", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%sCTCP reply from %s%s%s: %s%s%s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 0, NULL, nick),
@@ -344,6 +346,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
(channel) ? channel->buffer : NULL),
0,
irc_protocol_tags (
+ server,
command,
tags,
"irc_ctcp,irc_ctcp_reply,self_msg,notify_none,"
@@ -1101,6 +1104,7 @@ irc_ctcp_recv (struct t_irc_server *server, time_t date,
channel->buffer,
date,
irc_protocol_tags (
+ server,
command,
tags,
(nick_is_me) ?
@@ -1144,6 +1148,7 @@ irc_ctcp_recv (struct t_irc_server *server, time_t date,
ptr_channel->buffer,
date,
irc_protocol_tags (
+ server,
command,
tags,
(nick_is_me) ?
@@ -1227,8 +1232,8 @@ irc_ctcp_recv (struct t_irc_server *server, time_t date,
server, nick, NULL, "ctcp",
(channel) ? channel->buffer : NULL),
date,
- irc_protocol_tags (command, tags, "irc_ctcp", NULL,
- address),
+ irc_protocol_tags (server, command, tags, "irc_ctcp",
+ NULL, address),
_("%sUnknown CTCP requested by %s%s%s: %s%s%s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 0, NULL, nick),
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index 16475ed02..c2fe9c421 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -25,6 +25,7 @@
#include "../weechat-plugin.h"
#include "irc.h"
+#include "irc-batch.h"
#include "irc-channel.h"
#include "irc-color.h"
#include "irc-config.h"
@@ -1294,4 +1295,7 @@ irc_info_init ()
weechat_hook_hdata (
"irc_server", N_("irc server"),
&irc_server_hdata_server_cb, NULL, NULL);
+ weechat_hook_hdata (
+ "irc_batch", N_("irc batch"),
+ &irc_batch_hdata_batch_cb, NULL, NULL);
}
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index 46ed15fb6..9dce7c594 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -102,6 +102,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
buffer,
0,
irc_protocol_tags (
+ ptr_server,
"privmsg",
NULL,
str_tags,
@@ -121,6 +122,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
buffer,
0,
irc_protocol_tags (
+ ptr_server,
"privmsg",
NULL,
str_tags,
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 56ccbacd5..b3eb2d226 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -41,6 +41,7 @@
#include "irc.h"
#include "irc-protocol.h"
#include "irc-bar-item.h"
+#include "irc-batch.h"
#include "irc-buffer.h"
#include "irc-channel.h"
#include "irc-color.h"
@@ -158,13 +159,15 @@ irc_protocol_tags_add_cb (void *data,
*/
const char *
-irc_protocol_tags (const char *command, struct t_hashtable *irc_msg_tags,
- const char *extra_tags, const char *nick,
- const char *address)
+irc_protocol_tags (struct t_irc_server *server, const char *command,
+ struct t_hashtable *irc_msg_tags, const char *extra_tags,
+ const char *nick, const char *address)
{
static char string[4096];
int log_level, is_numeric, has_irc_tags;
+ const char *ptr_tag_batch;
char str_log_level[32], **str_irc_tags;
+ struct t_irc_batch *ptr_batch;
str_log_level[0] = '\0';
@@ -181,6 +184,23 @@ irc_protocol_tags (const char *command, struct t_hashtable *irc_msg_tags,
str_irc_tags = weechat_string_dyn_alloc (256);
weechat_hashtable_map (irc_msg_tags, irc_protocol_tags_add_cb,
str_irc_tags);
+ if (server)
+ {
+ ptr_tag_batch = weechat_hashtable_get (irc_msg_tags, "batch");
+ if (ptr_tag_batch && ptr_tag_batch)
+ {
+ ptr_batch = irc_batch_search (server, ptr_tag_batch);
+ if (ptr_batch)
+ {
+ if (*str_irc_tags[0])
+ weechat_string_dyn_concat (str_irc_tags, ",", -1);
+ weechat_string_dyn_concat (str_irc_tags,
+ "irc_batch_type_", -1);
+ weechat_string_dyn_concat (str_irc_tags,
+ ptr_batch->type, -1);
+ }
+ }
+ }
}
else
{
@@ -379,7 +399,7 @@ irc_protocol_print_error_warning_msg (struct t_irc_server *server,
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s%s%s%s[%s%s%s]%s %s",
(prefix) ? prefix : "",
(label) ? label : "",
@@ -451,6 +471,7 @@ IRC_PROTOCOL_CALLBACK(account)
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (
+ server,
command,
tags,
NULL,
@@ -483,6 +504,7 @@ IRC_PROTOCOL_CALLBACK(account)
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (
+ server,
command,
tags,
(smart_filter) ? "irc_smart_filter" : NULL,
@@ -632,6 +654,46 @@ IRC_PROTOCOL_CALLBACK(away)
}
/*
+ * Callback for the IRC command "BATCH": start/end batched events
+ * (with capability "batch").
+ *
+ * Command looks like:
+ * BATCH +yXNAbvnRHTRBv netsplit irc.hub other.host
+ * BATCH -yXNAbvnRHTRBv
+ */
+
+IRC_PROTOCOL_CALLBACK(batch)
+{
+ char *str_params;
+
+ IRC_PROTOCOL_MIN_PARAMS(1);
+
+ if (params[0][0] == '+')
+ {
+ /* start batch */
+ if (num_params < 2)
+ return WEECHAT_RC_ERROR;
+ str_params = (num_params > 2) ?
+ irc_protocol_string_params (params, 2, num_params - 1) : NULL;
+ irc_batch_start_batch (
+ server,
+ params[0] + 1, /* reference */
+ weechat_hashtable_get (tags, "batch"), /* parent ref */
+ params[1], /* type */
+ str_params);
+ if (str_params)
+ free (str_params);
+ }
+ else if (params[0][0] == '-')
+ {
+ /* end batch */
+ irc_batch_end_batch (server, params[0] + 1);
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Callback for IRC server capabilities string hashtable map.
*/
@@ -1274,7 +1336,8 @@ IRC_PROTOCOL_CALLBACK(chghost)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, nick, address),
+ irc_protocol_tags (server, command, tags, NULL, nick,
+ address),
_("%s%s%s%s (%s%s%s)%s has changed host to %s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, nick),
@@ -1307,6 +1370,7 @@ IRC_PROTOCOL_CALLBACK(chghost)
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (
+ server,
command,
tags,
(smart_filter) ? "irc_smart_filter" : NULL,
@@ -1352,7 +1416,7 @@ IRC_PROTOCOL_CALLBACK(error)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("error"),
str_error);
@@ -1432,7 +1496,7 @@ IRC_PROTOCOL_CALLBACK(generic_error)
|| (strcmp (command, "402") == 0)) ? "whois" : NULL,
ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s",
weechat_prefix ("network"),
str_target,
@@ -1497,7 +1561,8 @@ IRC_PROTOCOL_CALLBACK(invite)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, "notify_highlight", nick, address),
+ irc_protocol_tags (server, command, tags, "notify_highlight", nick,
+ address),
_("%sYou have been invited to %s%s%s by %s%s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -1514,7 +1579,7 @@ IRC_PROTOCOL_CALLBACK(invite)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, nick, address),
+ irc_protocol_tags (server, command, tags, NULL, nick, address),
_("%s%s%s%s has invited %s%s%s to %s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, nick),
@@ -1667,7 +1732,8 @@ IRC_PROTOCOL_CALLBACK(join)
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
ptr_channel->buffer),
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
(smart_filter) ? "irc_smart_filter" : NULL,
nick, address),
@@ -1749,7 +1815,7 @@ IRC_PROTOCOL_CALLBACK(kick)
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%s%s%s has kicked %s%s%s %s(%s%s%s)"),
weechat_prefix ("quit"),
irc_nick_color_for_msg (server, 1, ptr_nick, nick),
@@ -1769,7 +1835,7 @@ IRC_PROTOCOL_CALLBACK(kick)
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%s%s%s has kicked %s%s%s"),
weechat_prefix ("quit"),
irc_nick_color_for_msg (server, 1, ptr_nick, nick),
@@ -1869,7 +1935,7 @@ IRC_PROTOCOL_CALLBACK(kill)
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%sYou were killed by %s%s%s %s(%s%s%s)"),
weechat_prefix ("quit"),
IRC_COLOR_MESSAGE_KICK,
@@ -1887,7 +1953,7 @@ IRC_PROTOCOL_CALLBACK(kill)
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%sYou were killed by %s%s%s"),
weechat_prefix ("quit"),
IRC_COLOR_MESSAGE_KICK,
@@ -1944,7 +2010,7 @@ IRC_PROTOCOL_CALLBACK(knock_reply)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -1998,7 +2064,8 @@ IRC_PROTOCOL_CALLBACK(mode)
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL,
ptr_buffer),
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
(smart_filter && !local_mode) ?
"irc_smart_filter" : NULL,
@@ -2024,7 +2091,7 @@ IRC_PROTOCOL_CALLBACK(mode)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%sUser mode %s[%s%s%s]%s by %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -2088,7 +2155,7 @@ IRC_PROTOCOL_CALLBACK(nick)
weechat_printf_date_tags (
server->buffer,
date,
- irc_protocol_tags (command, tags, str_tags, NULL, address),
+ irc_protocol_tags (server, command, tags, str_tags, NULL, address),
_("%sYou are now known as %s%s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK_SELF,
@@ -2151,7 +2218,7 @@ IRC_PROTOCOL_CALLBACK(nick)
weechat_printf_date_tags (
ptr_channel->buffer,
date,
- irc_protocol_tags (command, tags, str_tags,
+ irc_protocol_tags (server, command, tags, str_tags,
NULL, address),
_("%s%s%s%s is now known as %s%s%s"),
weechat_prefix ("network"),
@@ -2192,7 +2259,8 @@ IRC_PROTOCOL_CALLBACK(nick)
params[0]);
weechat_printf_date_tags (ptr_channel->buffer,
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
str_tags,
NULL,
@@ -2226,8 +2294,8 @@ IRC_PROTOCOL_CALLBACK(nick)
weechat_printf_date_tags (
ptr_channel->buffer,
date,
- irc_protocol_tags (command, tags, str_tags,
- NULL, address),
+ irc_protocol_tags (server, command, tags,
+ str_tags, NULL, address),
_("%s%s%s%s is now known as %s%s%s"),
weechat_prefix ("network"),
weechat_config_boolean (irc_config_look_color_nicks_in_server_messages) ?
@@ -2405,7 +2473,8 @@ IRC_PROTOCOL_CALLBACK(notice)
weechat_printf_date_tags (
(ptr_channel) ? ptr_channel->buffer : server->buffer,
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
(is_channel_orig) ?
"notify_message" :
@@ -2486,8 +2555,8 @@ IRC_PROTOCOL_CALLBACK(notice)
weechat_printf_date_tags (
ptr_channel->buffer,
date,
- irc_protocol_tags (command, tags, "notify_private", nick,
- address),
+ irc_protocol_tags (server, command, tags, "notify_private",
+ nick, address),
"%s%s%s%s: %s",
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 0, NULL, nick),
@@ -2514,7 +2583,8 @@ IRC_PROTOCOL_CALLBACK(notice)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
(notify_private) ? "notify_private" : NULL,
server->nick, address),
@@ -2536,7 +2606,8 @@ IRC_PROTOCOL_CALLBACK(notice)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
(notify_private) ? "notify_private" : NULL,
nick, address),
@@ -2607,7 +2678,8 @@ IRC_PROTOCOL_CALLBACK(part)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
(local_part
|| (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
@@ -2641,7 +2713,8 @@ IRC_PROTOCOL_CALLBACK(part)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command,
+ irc_protocol_tags (server,
+ command,
tags,
(local_part
|| (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
@@ -2798,7 +2871,7 @@ IRC_PROTOCOL_CALLBACK(pong)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"PONG%s%s",
(str_params) ? ": " : "",
(str_params) ? str_params : "");
@@ -2894,8 +2967,8 @@ IRC_PROTOCOL_CALLBACK(privmsg)
weechat_printf_date_tags (
ptr_channel->buffer,
date,
- irc_protocol_tags (command, tags, "notify_message", nick,
- address),
+ irc_protocol_tags (server, command, tags, "notify_message",
+ nick, address),
"%s%s%s%s%s(%s%s%s)%s: %s",
weechat_prefix ("network"),
"Msg",
@@ -2923,7 +2996,8 @@ IRC_PROTOCOL_CALLBACK(privmsg)
weechat_printf_date_tags (
ptr_channel->buffer,
date,
- irc_protocol_tags (command, tags, str_tags, nick, address),
+ irc_protocol_tags (server, command, tags, str_tags, nick,
+ address),
"%s%s",
irc_nick_as_prefix (server, ptr_nick,
(ptr_nick) ? NULL : nick,
@@ -3030,7 +3104,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
weechat_printf_date_tags (
ptr_channel->buffer,
date,
- irc_protocol_tags (command, tags, str_tags, nick, address),
+ irc_protocol_tags (server, command, tags, str_tags, nick, address),
"%s%s",
irc_nick_as_prefix (
server, NULL, nick,
@@ -3113,6 +3187,7 @@ IRC_PROTOCOL_CALLBACK(quit)
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (
+ server,
command,
tags,
(local_quit
@@ -3146,6 +3221,7 @@ IRC_PROTOCOL_CALLBACK(quit)
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (
+ server,
command,
tags,
(local_quit
@@ -3231,7 +3307,8 @@ IRC_PROTOCOL_CALLBACK(setname)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL,
+ NULL),
_("%s%s%s%s has changed real name to %s\"%s%s%s\"%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, nick),
@@ -3263,6 +3340,7 @@ IRC_PROTOCOL_CALLBACK(setname)
server, NULL, command, NULL, ptr_channel->buffer),
date,
irc_protocol_tags (
+ server,
command,
tags,
(smart_filter) ? "irc_smart_filter" : NULL,
@@ -3295,7 +3373,7 @@ IRC_PROTOCOL_CALLBACK(setname)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%sYour real name has been set to %s\"%s%s%s\"%s"),
weechat_prefix ("network"),
IRC_COLOR_MESSAGE_SETNAME,
@@ -3394,7 +3472,7 @@ IRC_PROTOCOL_CALLBACK(server_mode_reason)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s%s",
weechat_prefix ("network"),
pos_mode,
@@ -3429,7 +3507,7 @@ IRC_PROTOCOL_CALLBACK(numeric)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_params);
@@ -3493,7 +3571,7 @@ IRC_PROTOCOL_CALLBACK(topic)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%s%s%s has changed topic for %s%s%s from \"%s%s%s\" to "
"\"%s%s%s\""),
weechat_prefix ("network"),
@@ -3518,7 +3596,7 @@ IRC_PROTOCOL_CALLBACK(topic)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%s%s%s has changed topic for %s%s%s to \"%s%s%s\""),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, ptr_nick, nick),
@@ -3546,7 +3624,7 @@ IRC_PROTOCOL_CALLBACK(topic)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%s%s%s has unset topic for %s%s%s (old topic: "
"\"%s%s%s\")"),
weechat_prefix ("network"),
@@ -3568,7 +3646,7 @@ IRC_PROTOCOL_CALLBACK(topic)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%s%s%s has unset topic for %s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, ptr_nick, nick),
@@ -3616,7 +3694,8 @@ IRC_PROTOCOL_CALLBACK(wallops)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, "notify_private", nick, address),
+ irc_protocol_tags (server, command, tags, "notify_private", nick,
+ address),
_("%sWallops from %s: %s"),
weechat_prefix ("network"),
(nick_address[0]) ? nick_address : "?",
@@ -3918,7 +3997,7 @@ IRC_PROTOCOL_CALLBACK(008)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%sServer notice mask for %s%s%s: %s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, params[0]),
@@ -3950,7 +4029,7 @@ IRC_PROTOCOL_CALLBACK(221)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%sUser mode for %s%s%s is %s[%s%s%s]"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, params[0]),
@@ -4007,7 +4086,7 @@ IRC_PROTOCOL_CALLBACK(301)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%s%s[%s%s%s]%s is away: %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4047,7 +4126,7 @@ IRC_PROTOCOL_CALLBACK(303)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%sUsers online: %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
@@ -4079,7 +4158,7 @@ IRC_PROTOCOL_CALLBACK(305)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "unaway", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_away_msg);
@@ -4115,7 +4194,7 @@ IRC_PROTOCOL_CALLBACK(306)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "away", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_away_msg);
@@ -4154,7 +4233,7 @@ IRC_PROTOCOL_CALLBACK(whois_nick_msg)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4198,7 +4277,7 @@ IRC_PROTOCOL_CALLBACK(whowas_nick_msg)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whowas", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4246,7 +4325,7 @@ IRC_PROTOCOL_CALLBACK(311)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] (%s%s@%s%s)%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4290,7 +4369,7 @@ IRC_PROTOCOL_CALLBACK(312)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4334,7 +4413,7 @@ IRC_PROTOCOL_CALLBACK(314)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whowas", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4380,7 +4459,7 @@ IRC_PROTOCOL_CALLBACK(315)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "who", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s]%s %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4427,7 +4506,7 @@ IRC_PROTOCOL_CALLBACK(317)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s idle: %s%d %s%s, %s%02d %s%s %s%02d %s%s %s%02d "
"%s%s, signon at: %s%s"),
weechat_prefix ("network"),
@@ -4460,7 +4539,7 @@ IRC_PROTOCOL_CALLBACK(317)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s idle: %s%02d %s%s %s%02d %s%s %s%02d %s%s, "
"signon at: %s%s"),
weechat_prefix ("network"),
@@ -4507,7 +4586,7 @@ IRC_PROTOCOL_CALLBACK(321)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "list", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s%s",
weechat_prefix ("network"),
params[1],
@@ -4541,7 +4620,7 @@ IRC_PROTOCOL_CALLBACK(322)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "list", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s%s(%s%s%s)%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -4578,7 +4657,7 @@ IRC_PROTOCOL_CALLBACK(323)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, "list", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_params);
@@ -4627,7 +4706,7 @@ IRC_PROTOCOL_CALLBACK(324)
server, NULL, command, NULL,
(ptr_channel) ? ptr_channel->buffer : NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, address),
+ irc_protocol_tags (server, command, tags, NULL, NULL, address),
_("%sMode %s%s %s[%s%s%s]"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -4680,7 +4759,7 @@ IRC_PROTOCOL_CALLBACK(327)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4700,7 +4779,7 @@ IRC_PROTOCOL_CALLBACK(327)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4741,7 +4820,7 @@ IRC_PROTOCOL_CALLBACK(328)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%sURL for %s%s%s: %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -4782,7 +4861,7 @@ IRC_PROTOCOL_CALLBACK(329)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL,
+ irc_protocol_tags (server, command, tags, NULL,
NULL, NULL),
/* TRANSLATORS: "%s" after "created on" is a date */
_("%sChannel created on %s"),
@@ -4795,7 +4874,7 @@ IRC_PROTOCOL_CALLBACK(329)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "created on" is a date */
_("%sChannel %s%s%s created on %s"),
weechat_prefix ("network"),
@@ -4836,7 +4915,7 @@ IRC_PROTOCOL_CALLBACK(330_343)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4860,7 +4939,7 @@ IRC_PROTOCOL_CALLBACK(330_343)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -4896,7 +4975,7 @@ IRC_PROTOCOL_CALLBACK(331)
irc_msgbuffer_get_target_buffer (
server, params[1], command, NULL, ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%sNo topic set for channel %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -4957,7 +5036,7 @@ IRC_PROTOCOL_CALLBACK(332)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%sTopic for %s%s%s is \"%s%s%s\""),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -5022,7 +5101,7 @@ IRC_PROTOCOL_CALLBACK(333)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic set by %s%s%s%s%s%s%s%s%s on %s"),
weechat_prefix ("network"),
@@ -5043,7 +5122,7 @@ IRC_PROTOCOL_CALLBACK(333)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic set on %s"),
weechat_prefix ("network"),
@@ -5059,7 +5138,7 @@ IRC_PROTOCOL_CALLBACK(333)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic for %s%s%s set by %s%s%s%s%s%s%s%s%s on %s"),
weechat_prefix ("network"),
@@ -5083,7 +5162,7 @@ IRC_PROTOCOL_CALLBACK(333)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%sTopic for %s%s%s set on %s"),
weechat_prefix ("network"),
@@ -5127,7 +5206,7 @@ IRC_PROTOCOL_CALLBACK(338)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s]%s %s %s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5160,7 +5239,7 @@ IRC_PROTOCOL_CALLBACK(341)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, params[0], command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, params[0], address),
+ irc_protocol_tags (server, command, tags, NULL, params[0], address),
_("%s%s%s%s has invited %s%s%s to %s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, params[0]),
@@ -5199,7 +5278,7 @@ IRC_PROTOCOL_CALLBACK(344)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, "reop", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%sChannel reop %s%s%s: %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -5237,7 +5316,7 @@ IRC_PROTOCOL_CALLBACK(345)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, "reop", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -5308,7 +5387,7 @@ IRC_PROTOCOL_CALLBACK(346)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "invitelist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s] %s%s%s%s invited by %s on %s"),
weechat_prefix ("network"),
@@ -5331,7 +5410,7 @@ IRC_PROTOCOL_CALLBACK(346)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "invitelist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s invited by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5353,7 +5432,7 @@ IRC_PROTOCOL_CALLBACK(346)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "invitelist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s invited"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5408,7 +5487,7 @@ IRC_PROTOCOL_CALLBACK(347)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "invitelist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5481,7 +5560,7 @@ IRC_PROTOCOL_CALLBACK(348)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "exceptionlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s]%s%s exception %s%s%s by %s on %s"),
weechat_prefix ("network"),
@@ -5505,7 +5584,7 @@ IRC_PROTOCOL_CALLBACK(348)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "exceptionlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s%s exception %s%s%s by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5528,7 +5607,7 @@ IRC_PROTOCOL_CALLBACK(348)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "exceptionlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s]%s%s exception %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5583,7 +5662,7 @@ IRC_PROTOCOL_CALLBACK(349)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "exceptionlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5638,7 +5717,7 @@ IRC_PROTOCOL_CALLBACK(350)
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5684,7 +5763,7 @@ IRC_PROTOCOL_CALLBACK(351)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s %s (%s)",
weechat_prefix ("network"),
params[1],
@@ -5698,7 +5777,7 @@ IRC_PROTOCOL_CALLBACK(351)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s %s",
weechat_prefix ("network"),
params[1],
@@ -5790,7 +5869,7 @@ IRC_PROTOCOL_CALLBACK(352)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "who", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s %s%s%s%s%s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -5962,7 +6041,7 @@ IRC_PROTOCOL_CALLBACK(353)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "names", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%sNicks %s%s%s: %s[%s%s%s]"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -6016,7 +6095,7 @@ IRC_PROTOCOL_CALLBACK(354)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "who", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -6087,7 +6166,7 @@ IRC_PROTOCOL_CALLBACK(354)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "who", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s] %s%s %s[%s%s%s] (%s%s@%s%s)%s %s %s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -6218,7 +6297,7 @@ IRC_PROTOCOL_CALLBACK(366)
ptr_channel->buffer),
date,
irc_protocol_tags (
- command, tags, NULL, NULL, NULL),
+ server, command, tags, NULL, NULL, NULL),
_("%sNicks %s%s%s: %s[%s%s]"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -6288,7 +6367,7 @@ IRC_PROTOCOL_CALLBACK(366)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "names", ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%sChannel %s%s%s: %s%d%s %s %s(%s%s)"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -6318,7 +6397,7 @@ IRC_PROTOCOL_CALLBACK(366)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "names", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s%s%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -6399,7 +6478,7 @@ IRC_PROTOCOL_CALLBACK(367)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s] %s%s%s%s banned by %s on %s"),
weechat_prefix ("network"),
@@ -6422,7 +6501,7 @@ IRC_PROTOCOL_CALLBACK(367)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s banned by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -6444,7 +6523,7 @@ IRC_PROTOCOL_CALLBACK(367)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s banned"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -6502,7 +6581,7 @@ IRC_PROTOCOL_CALLBACK(368)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -6703,7 +6782,7 @@ IRC_PROTOCOL_CALLBACK(438)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s (%s => %s)",
weechat_prefix ("network"),
str_params,
@@ -6717,7 +6796,7 @@ IRC_PROTOCOL_CALLBACK(438)
weechat_printf_date_tags (
ptr_buffer,
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s %s",
weechat_prefix ("network"),
params[0],
@@ -6863,7 +6942,8 @@ IRC_PROTOCOL_CALLBACK(help)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, "notify_private", nick, address),
+ irc_protocol_tags (server, command, tags, "notify_private", nick,
+ address),
"%s%s",
weechat_prefix ("network"),
str_message);
@@ -6906,7 +6986,7 @@ IRC_PROTOCOL_CALLBACK(710)
irc_msgbuffer_get_target_buffer (
server, NULL, command, NULL, ptr_channel->buffer),
date,
- irc_protocol_tags (command, tags, "notify_message", NULL, NULL),
+ irc_protocol_tags (server, command, tags, "notify_message", NULL, NULL),
"%s%s %s",
weechat_prefix ("network"),
(nick_address[0]) ? nick_address : "?",
@@ -6978,7 +7058,7 @@ IRC_PROTOCOL_CALLBACK(728)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "quietlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
/* TRANSLATORS: "%s" after "on" is a date */
_("%s%s[%s%s%s] %s%s%s%s quieted by %s on %s"),
weechat_prefix ("network"),
@@ -7001,7 +7081,7 @@ IRC_PROTOCOL_CALLBACK(728)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "quietlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s quieted by %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -7023,7 +7103,7 @@ IRC_PROTOCOL_CALLBACK(728)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "quietlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
_("%s%s[%s%s%s] %s%s%s%s quieted"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -7081,7 +7161,7 @@ IRC_PROTOCOL_CALLBACK(729)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "quietlist", ptr_buffer),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -7214,7 +7294,7 @@ IRC_PROTOCOL_CALLBACK(732)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "monitor", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
(str_nicks) ? str_nicks : "");
@@ -7245,7 +7325,7 @@ IRC_PROTOCOL_CALLBACK(733)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "monitor", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
(str_params) ? str_params : "");
@@ -7276,7 +7356,7 @@ IRC_PROTOCOL_CALLBACK(734)
irc_msgbuffer_get_target_buffer (
server, NULL, command, "monitor", NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s (%s)",
weechat_prefix ("error"),
(str_params) ? str_params : "",
@@ -7312,7 +7392,7 @@ IRC_PROTOCOL_CALLBACK(900)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s %s(%s%s%s)",
weechat_prefix ("network"),
str_params,
@@ -7326,7 +7406,7 @@ IRC_PROTOCOL_CALLBACK(900)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
str_params);
@@ -7354,7 +7434,7 @@ IRC_PROTOCOL_CALLBACK(901)
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
- irc_protocol_tags (command, tags, NULL, NULL, NULL),
+ irc_protocol_tags (server, command, tags, NULL, NULL, NULL),
"%s%s",
weechat_prefix ("network"),
params[2]);
@@ -7435,20 +7515,27 @@ IRC_PROTOCOL_CALLBACK(sasl_end_fail)
* Executes action when an IRC command is received.
*
* Argument "irc_message" is the full message without optional tags.
+ *
+ * If ignore_batch_tag == 0, a message with tag "batch=xxx" is stored in this
+ * batch reference for further processing.
+ * If ignore_batch_tag == 1, the "batch" tag is ignored and message is
+ * processed immediately (this is the case when command BATCH is received
+ * with "-reference", which means end of batched events).
*/
void
irc_protocol_recv_command (struct t_irc_server *server,
const char *irc_message,
const char *msg_command,
- const char *msg_channel)
+ const char *msg_channel,
+ int ignore_batch_tag)
{
int i, cmd_found, return_code, decode_color, keep_trailing_spaces;
int message_ignored, num_params;
char *message_colors_decoded, *msg_to_parse, *pos_space, *tags, **params;
struct t_irc_channel *ptr_channel;
t_irc_recv_func *cmd_recv_func;
- const char *cmd_name, *ptr_msg_after_tags;
+ const char *cmd_name, *ptr_msg_after_tags, *ptr_batch_ref;
time_t date;
const char *nick1, *address1, *host1;
char *nick, *address, *address_color, *host, *host_no_color, *host_color;
@@ -7456,11 +7543,12 @@ irc_protocol_recv_command (struct t_irc_server *server,
struct t_irc_protocol_msg irc_protocol_messages[] = {
/* format: "command", decode_color, keep_trailing_spaces, func_cb */
- IRCB(account, 1, 0, account), /* account (cap account-notify) */
+ IRCB(account, 1, 0, account), /* account (cap "account-notify") */
IRCB(authenticate, 1, 0, authenticate), /* authenticate */
- IRCB(away, 1, 0, away), /* away (cap away-notify) */
+ IRCB(away, 1, 0, away), /* away (cap "away-notify") */
+ IRCB(batch, 1, 0, batch), /* batch (cap "batch") */
IRCB(cap, 1, 0, cap), /* client capability */
- IRCB(chghost, 1, 0, chghost), /* user/host change (cap chghost) */
+ IRCB(chghost, 1, 0, chghost), /* user/host change (cap "chghost")*/
IRCB(error, 1, 0, error), /* error received from server */
IRCB(fail, 1, 0, fail), /* error received from server */
IRCB(invite, 1, 0, invite), /* invite a nick on a channel */
@@ -7627,6 +7715,12 @@ irc_protocol_recv_command (struct t_irc_server *server,
if (!msg_command)
return;
+ nick = NULL;
+ address = NULL;
+ address_color = NULL;
+ host = NULL;
+ host_no_color = NULL;
+ host_color = NULL;
message_colors_decoded = NULL;
msg_to_parse = NULL;
date = 0;
@@ -7666,6 +7760,19 @@ irc_protocol_recv_command (struct t_irc_server *server,
ptr_msg_after_tags = NULL;
}
+ /* if message is not BATCH but has a batch tag, just store it for later */
+ if (!ignore_batch_tag
+ && hash_tags
+ && (weechat_strcasecmp (msg_command, "batch") != 0))
+ {
+ ptr_batch_ref = weechat_hashtable_get (hash_tags, "batch");
+ if (ptr_batch_ref)
+ {
+ if (irc_batch_add_message (server, ptr_batch_ref, irc_message))
+ goto end;
+ }
+ }
+
/* get nick/host/address from IRC message */
nick1 = NULL;
address1 = NULL;
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index ceb2da136..d351eab2e 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -99,7 +99,8 @@ struct t_irc_protocol_msg
t_irc_recv_func *recv_function; /* function called when msg is received */
};
-extern const char *irc_protocol_tags (const char *command,
+extern const char *irc_protocol_tags (struct t_irc_server *server,
+ const char *command,
struct t_hashtable *irc_msg_tags,
const char *extra_tags,
const char *nick,
@@ -108,6 +109,7 @@ extern time_t irc_protocol_parse_time (const char *time);
extern void irc_protocol_recv_command (struct t_irc_server *server,
const char *irc_message,
const char *msg_command,
- const char *msg_channel);
+ const char *msg_channel,
+ int ignore_batch_tag);
#endif /* WEECHAT_PLUGIN_IRC_PROTOCOL_H */
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index d61e8f938..2c2dfb00d 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -52,6 +52,7 @@
#include "irc.h"
#include "irc-server.h"
#include "irc-bar-item.h"
+#include "irc-batch.h"
#include "irc-buffer.h"
#include "irc-channel.h"
#include "irc-color.h"
@@ -1740,6 +1741,8 @@ irc_server_alloc (const char *name)
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_TIME,
NULL, NULL);
+ new_server->batches = NULL;
+ new_server->last_batch = NULL;
new_server->buffer = NULL;
new_server->buffer_as_string = NULL;
new_server->channels = NULL;
@@ -2218,6 +2221,7 @@ irc_server_free_data (struct t_irc_server *server)
irc_redirect_free_all (server);
irc_notify_free_all (server);
irc_channel_free_all (server);
+ irc_batch_free_all (server);
/* free hashtables */
weechat_hashtable_free (server->join_manual);
@@ -3552,7 +3556,8 @@ irc_server_msgq_flush ()
irc_recv_msgq->server,
ptr_msg2,
command,
- channel);
+ channel,
+ 0); /* ignore_batch_tag */
}
}
@@ -3855,6 +3860,7 @@ irc_server_timer_cb (const void *pointer, void *data, int remaining_calls)
struct t_irc_server *ptr_server;
struct t_irc_channel *ptr_channel;
struct t_irc_redirect *ptr_redirect, *ptr_next_redirect;
+ struct t_irc_batch *ptr_batch, *ptr_next_batch;
time_t current_time;
static struct timeval tv;
int away_check, refresh_lag;
@@ -4024,6 +4030,17 @@ irc_server_timer_cb (const void *pointer, void *data, int remaining_calls)
NULL);
}
}
+ ptr_batch = ptr_server->batches;
+ while (ptr_batch)
+ {
+ ptr_next_batch = ptr_batch->next_batch;
+ if (current_time > ptr_batch->start_time + (60 * 60))
+ {
+ /* batch expires after 1 hour if end not received */
+ irc_batch_free (ptr_server, ptr_batch);
+ }
+ ptr_batch = ptr_next_batch;
+ }
ptr_server->last_data_purge = current_time;
}
}
@@ -4115,6 +4132,9 @@ irc_server_close_connection (struct t_irc_server *server)
/* remove all keys for joins without switch */
weechat_hashtable_remove_all (server->join_noswitch);
+ /* remove all batched events pending */
+ irc_batch_free_all (server);
+
/* server is now disconnected */
server->authentication_method = IRC_SERVER_AUTH_METHOD_NONE;
server->sasl_mechanism_used = -1;
@@ -6319,6 +6339,8 @@ irc_server_hdata_server_cb (const void *pointer, void *data,
WEECHAT_HDATA_VAR(struct t_irc_server, join_manual, HASHTABLE, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, join_channel_key, HASHTABLE, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, join_noswitch, HASHTABLE, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_server, batches, POINTER, 0, NULL, "irc_batch");
+ WEECHAT_HDATA_VAR(struct t_irc_server, last_batch, POINTER, 0, NULL, "irc_batch");
WEECHAT_HDATA_VAR(struct t_irc_server, buffer, POINTER, 0, NULL, "buffer");
WEECHAT_HDATA_VAR(struct t_irc_server, buffer_as_string, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, channels, POINTER, 0, NULL, "irc_channel");
@@ -7088,6 +7110,8 @@ irc_server_print_log ()
weechat_log_printf (" join_noswitch . . . . . . : 0x%lx (hashtable: '%s')",
ptr_server->join_noswitch,
weechat_hashtable_get_string (ptr_server->join_noswitch, "keys_values"));
+ weechat_log_printf (" batches . . . . . . . . . : 0x%lx", ptr_server->batches);
+ weechat_log_printf (" last_batch. . . . . . . . : 0x%lx", ptr_server->last_batch);
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);
@@ -7099,6 +7123,8 @@ irc_server_print_log ()
irc_notify_print_log (ptr_server);
+ irc_batch_print_log (ptr_server);
+
for (ptr_channel = ptr_server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index fc78511c8..a674c96a9 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -278,6 +278,8 @@ struct t_irc_server
struct t_hashtable *join_manual; /* manual joins pending */
struct t_hashtable *join_channel_key; /* keys pending for joins */
struct t_hashtable *join_noswitch; /* joins w/o switch to buffer */
+ struct t_irc_batch *batches; /* batched events (cap "batch") */
+ struct t_irc_batch *last_batch; /* last batch */
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 */