summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-10-30 17:18:28 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-10-30 17:18:28 +0100
commit6f442bbfc13a73f9b993f5bbd5928cab9a1321c4 (patch)
treeb3367af39b4ec208f4b72fc458edb44b2c47b556 /src/plugins/irc
parent2f68ec7f3655efc9f814b2f4298d27029d1c6824 (diff)
downloadweechat-6f442bbfc13a73f9b993f5bbd5928cab9a1321c4.zip
Add new features to logger plugin (command /logger, log level, level by buffer, mask by buffer, ..), fix some bugs
New features: - new command /logger - log level, to log only some messages, according to importance (task #8592) - level by buffer: custom level for some buffers (or group of buffers) - log filename mask by buffer (or group of buffers) - marker line is added after display of backlog - add "delete" callback for config file sections - add "mkdir_parents" function to plugin API - remove old log options in IRC plugin Bug fix: - marker line is set only when user switches buffer (not when a plugin force switch, like IRC plugin does when opening server or channel buffer) - backlog fixed (sometimes lines were not properly displayed)
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-command.c2
-rw-r--r--src/plugins/irc/irc-config.c139
-rw-r--r--src/plugins/irc/irc-config.h6
-rw-r--r--src/plugins/irc/irc-display.c2
-rw-r--r--src/plugins/irc/irc-input.c14
-rw-r--r--src/plugins/irc/irc-protocol.c250
-rw-r--r--src/plugins/irc/irc-protocol.h1
-rw-r--r--src/plugins/irc/irc-server.c7
8 files changed, 173 insertions, 248 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 1c3082ae1..ee7a42ed0 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -2067,7 +2067,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
{
msg_pwd_hidden = strdup (argv_eol[2]);
if (msg_pwd_hidden
- && (weechat_config_boolean (irc_config_log_hide_nickserv_pwd)))
+ && (weechat_config_boolean (irc_config_look_hide_nickserv_pwd)))
irc_display_hide_password (msg_pwd_hidden, 0);
string = irc_color_decode (
(msg_pwd_hidden) ? msg_pwd_hidden : argv_eol[2],
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 240a6a842..e21874931 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -57,6 +57,7 @@ struct t_config_option *irc_config_look_nick_suffix;
struct t_config_option *irc_config_look_nick_completion_smart;
struct t_config_option *irc_config_look_display_away;
struct t_config_option *irc_config_look_display_channel_modes;
+struct t_config_option *irc_config_look_hide_nickserv_pwd;
struct t_config_option *irc_config_look_highlight_tags;
struct t_config_option *irc_config_look_show_away_once;
struct t_config_option *irc_config_look_smart_filter;
@@ -77,13 +78,6 @@ 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;
-/* IRC config, log section */
-
-struct t_config_option *irc_config_log_auto_log_server;
-struct t_config_option *irc_config_log_auto_log_channel;
-struct t_config_option *irc_config_log_auto_log_private;
-struct t_config_option *irc_config_log_hide_nickserv_pwd;
-
/* IRC config, server section */
struct t_config_option *irc_config_server_default[IRC_CONFIG_NUM_SERVER_OPTIONS];
@@ -176,27 +170,6 @@ irc_config_change_display_channel_modes (void *data,
}
/*
- * irc_config_change_smart_filter: called when the "smart_filter" option is
- * changed
- */
-
-void
-irc_config_change_smart_filter (void *data,
- struct t_config_option *option)
-{
- /* make C compiler happy */
- (void) data;
- (void) option;
-
- if (weechat_config_boolean (irc_config_look_smart_filter))
- {
- weechat_printf (NULL,
- _("You should now create filter on tag "
- "\"irc_smart_filter\" with command /filter."));
- }
-}
-
-/*
* irc_config_change_away_check: called when away check is changed
*/
@@ -228,60 +201,6 @@ irc_config_change_away_check (void *data,
}
/*
- * irc_config_change_log: called when log settings are changed
- * (for server/channel/private logging)
- */
-
-void
-irc_config_change_log (void *data,
- struct t_config_option *option)
-{
- /* make C compiler happy */
- (void) data;
- (void) option;
-
- /*t_gui_buffer *ptr_buffer;
- t_irc_server *ptr_server;
- t_irc_channel *ptr_channel;
-
- for (ptr_buffer = gui_buffers; ptr_buffer;
- ptr_buffer = ptr_buffer->next_buffer)
- {
- if (ptr_buffer->protocol == irc_protocol)
- {
- ptr_server = irc_server_search (ptr_buffer->category);
- ptr_channel = irc_channel_search (ptr_server, ptr_buffer->name);
-
- if (ptr_server && !ptr_channel)
- {
- if (irc_config_log_auto_server && !ptr_buffer->log_file)
- gui_log_start (ptr_buffer);
- else if (!irc_config_log_auto_server && ptr_buffer->log_file)
- gui_log_end (ptr_buffer);
- }
- if (ptr_server && ptr_channel)
- {
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- {
- if (irc_config_log_auto_channel && !ptr_buffer->log_file)
- gui_log_start (ptr_buffer);
- else if (!irc_config_log_auto_channel && ptr_buffer->log_file)
- gui_log_end (ptr_buffer);
- }
- else
- {
- if (irc_config_log_auto_private && !ptr_buffer->log_file)
- gui_log_start (ptr_buffer);
- else if (!irc_config_log_auto_private && ptr_buffer->log_file)
- gui_log_end (ptr_buffer);
- }
- }
- }
- }
- */
-}
-
-/*
* irc_config_server_default_change_cb: callback called when a default server
* option is modified
*/
@@ -1014,7 +933,8 @@ irc_config_init ()
ptr_section = weechat_config_new_section (irc_config_file, "look",
0, 0,
NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL,
+ NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -1056,6 +976,11 @@ irc_config_init ()
"display_channel_modes", "boolean",
N_("display channel modes in \"buffer_name\" bar item"),
NULL, 0, 0, "on", NULL, NULL, NULL, &irc_config_change_display_channel_modes, NULL, NULL, NULL);
+ irc_config_look_hide_nickserv_pwd = weechat_config_new_option (
+ irc_config_file, ptr_section,
+ "hide_nickserv_pwd", "boolean",
+ N_("hide password displayed by nickserv"),
+ NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_highlight_tags = weechat_config_new_option (
irc_config_file, ptr_section,
"highlight_tags", "string",
@@ -1072,8 +997,9 @@ irc_config_init ()
irc_config_file, ptr_section,
"smart_filter", "boolean",
N_("filter join/part/quit messages for a nick if not speaking for "
- "some minutes on channel"),
- NULL, 0, 0, "off", NULL, NULL, NULL, &irc_config_change_smart_filter, NULL, NULL, NULL);
+ "some minutes on channel (you must create a filter on tag "
+ "\"irc_smart_filter\")"),
+ NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_look_smart_filter_delay = weechat_config_new_option (
irc_config_file, ptr_section,
"smart_filter_delay", "integer",
@@ -1089,7 +1015,8 @@ irc_config_init ()
ptr_section = weechat_config_new_section (irc_config_file, "network",
0, 0,
NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL,
+ NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -1161,45 +1088,13 @@ irc_config_init ()
N_("send unknown commands to IRC server"),
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- /* log */
- ptr_section = weechat_config_new_section (irc_config_file, "log",
- 0, 0,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
- if (!ptr_section)
- {
- weechat_config_free (irc_config_file);
- return 0;
- }
-
- irc_config_log_auto_log_server = weechat_config_new_option (
- irc_config_file, ptr_section,
- "auto_log_server", "boolean",
- N_("automatically log server messages"),
- NULL, 0, 0, "off", NULL, NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
- irc_config_log_auto_log_channel = weechat_config_new_option (
- irc_config_file, ptr_section,
- "auto_log_channel", "boolean",
- N_("automatically log channel chats"),
- NULL, 0, 0, "off", NULL, NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
- irc_config_log_auto_log_private = weechat_config_new_option (
- irc_config_file, ptr_section,
- "auto_log_private", "boolean",
- N_("automatically log private chats"),
- NULL, 0, 0, "off", NULL, NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
- irc_config_log_hide_nickserv_pwd = weechat_config_new_option (
- irc_config_file, ptr_section,
- "hide_nickserv_pwd", "boolean",
- N_("hide password displayed by nickserv"),
- NULL, 0, 0, "on", NULL, NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
-
/* filters */
ptr_section = weechat_config_new_section (irc_config_file, "ignore",
0, 0,
&irc_config_ignore_read, NULL,
&irc_config_ignore_write, NULL,
&irc_config_ignore_write, NULL,
- NULL, NULL);
+ NULL, NULL, NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -1210,7 +1105,8 @@ irc_config_init ()
ptr_section = weechat_config_new_section (irc_config_file, "server_default",
0, 0,
NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL,
+ NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
@@ -1227,7 +1123,8 @@ irc_config_init ()
NULL, NULL,
NULL, NULL,
&irc_config_server_write_default, NULL,
- &irc_config_server_create_option, NULL);
+ &irc_config_server_create_option, NULL,
+ NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 4a16077a3..c18501634 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -69,6 +69,7 @@ extern struct t_config_option *irc_config_look_nick_suffix;
extern struct t_config_option *irc_config_look_nick_completion_smart;
extern struct t_config_option *irc_config_look_display_away;
extern struct t_config_option *irc_config_look_display_channel_modes;
+extern struct t_config_option *irc_config_look_hide_nickserv_pwd;
extern struct t_config_option *irc_config_look_highlight_tags;
extern struct t_config_option *irc_config_look_show_away_once;
extern struct t_config_option *irc_config_look_smart_filter;
@@ -87,11 +88,6 @@ 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;
-extern struct t_config_option *irc_config_log_auto_log_server;
-extern struct t_config_option *irc_config_log_auto_log_channel;
-extern struct t_config_option *irc_config_log_auto_log_private;
-extern struct t_config_option *irc_config_log_hide_nickserv_pwd;
-
extern struct t_config_option *irc_config_server_default[];
extern int irc_config_search_server_option (const char *option_name);
diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c
index e1c8a4a61..c221f739e 100644
--- a/src/plugins/irc/irc-display.c
+++ b/src/plugins/irc/irc-display.c
@@ -201,7 +201,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
string = NULL;
if (string)
{
- if (weechat_config_boolean (irc_config_log_hide_nickserv_pwd))
+ if (weechat_config_boolean (irc_config_look_hide_nickserv_pwd))
irc_display_hide_password (string, 1);
weechat_printf (NULL, " command . . . . . . : %s",
string);
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index 689ac735e..0d77558c1 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -30,6 +30,7 @@
#include "irc-nick.h"
#include "irc-color.h"
#include "irc-config.h"
+#include "irc-protocol.h"
/*
@@ -54,12 +55,13 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
else
ptr_nick = NULL;
- weechat_printf (buffer,
- "%s%s",
- irc_nick_as_prefix ((ptr_nick) ? ptr_nick : NULL,
- (ptr_nick) ? NULL : ptr_server->nick,
- IRC_COLOR_CHAT_NICK_SELF),
- (text_decoded) ? text_decoded : text);
+ weechat_printf_tags (buffer,
+ irc_protocol_tags ("privmsg", NULL),
+ "%s%s",
+ irc_nick_as_prefix ((ptr_nick) ? ptr_nick : NULL,
+ (ptr_nick) ? NULL : ptr_server->nick,
+ IRC_COLOR_CHAT_NICK_SELF),
+ (text_decoded) ? text_decoded : text);
}
if (text_decoded)
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 1e7257609..0e7b1df6a 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -100,27 +100,69 @@ irc_protocol_get_address_from_host (const char *host)
}
/*
+ * irc_protocol_log_level_for_command: get log level for IRC command
+ */
+
+int
+irc_protocol_log_level_for_command (const char *command)
+{
+ if (!command || !command[0])
+ return 0;
+
+ if ((strcmp (command, "privmsg") == 0)
+ || (strcmp (command, "notice") == 0))
+ return 1;
+
+ if (strcmp (command, "nick") == 0)
+ return 2;
+
+ if ((strcmp (command, "join") == 0)
+ || (strcmp (command, "part") == 0)
+ || (strcmp (command, "quit") == 0))
+ return 4;
+
+ return 3;
+}
+
+/*
* irc_protocol_tags: build tags list with IRC command and/or tags
*/
char *
irc_protocol_tags (const char *command, const char *tags)
{
- static char string[256];
+ static char string[512];
+ int log_level;
+ char str_log_level[32];
- if (command && tags)
+ log_level = 0;
+ str_log_level[0] = '\0';
+
+ if (command && command[0])
{
- snprintf (string, sizeof (string), "irc_cmd_%s,%s", command, tags);
+ log_level = irc_protocol_log_level_for_command (command);
+ if (log_level > 0)
+ {
+ snprintf (str_log_level, sizeof (str_log_level),
+ ",log%d", log_level);
+ }
+ }
+
+ if (command && command[0] && tags && tags[0])
+ {
+ snprintf (string, sizeof (string),
+ "irc_cmd_%s,%s%s", command, tags, str_log_level);
return string;
}
- if (command)
+ if (command && command[0])
{
- snprintf (string, sizeof (string), "irc_cmd_%s", command);
+ snprintf (string, sizeof (string),
+ "irc_cmd_%s%s", command, str_log_level);
return string;
}
- if (tags)
+ if (tags && tags[0])
{
snprintf (string, sizeof (string), "%s", tags);
return string;
@@ -243,7 +285,7 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command,
if (!irc_ignore_check (server, NULL, nick, host))
{
weechat_printf_tags (server->buffer,
- "irc_invite,notify_highlight",
+ irc_protocol_tags (command, "otify_highlight"),
_("%sYou have been invited to %s%s%s by "
"%s%s"),
irc_buffer_get_server_prefix (server, "network"),
@@ -305,10 +347,11 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command,
ptr_nick_speaking = (weechat_config_boolean (irc_config_look_smart_filter)) ?
irc_channel_nick_speaking_time_search (ptr_channel, nick, 1) : NULL;
weechat_printf_tags (ptr_channel->buffer,
- (local_join
- || !weechat_config_boolean (irc_config_look_smart_filter)
- || ptr_nick_speaking) ?
- "irc_join" : "irc_join,irc_smart_filter",
+ irc_protocol_tags (command,
+ (local_join
+ || !weechat_config_boolean (irc_config_look_smart_filter)
+ || ptr_nick_speaking) ?
+ NULL : "irc_smart_filter"),
_("%s%s%s %s(%s%s%s)%s has joined %s%s"),
weechat_prefix ("join"),
IRC_COLOR_CHAT_NICK,
@@ -378,7 +421,7 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command,
if (pos_comment)
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_kick",
+ irc_protocol_tags (command, NULL),
_("%s%s%s%s has kicked %s%s%s from %s%s "
"%s(%s%s%s)"),
weechat_prefix ("quit"),
@@ -398,7 +441,7 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_kick",
+ irc_protocol_tags (command, NULL),
_("%s%s%s%s has kicked %s%s%s from %s%s"),
weechat_prefix ("quit"),
IRC_COLOR_CHAT_NICK,
@@ -463,7 +506,7 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command,
if (pos_comment)
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_kill",
+ irc_protocol_tags (command, NULL),
_("%sYou were killed by %s%s %s(%s%s%s)"),
weechat_prefix ("quit"),
IRC_COLOR_CHAT_NICK,
@@ -476,7 +519,7 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_kill",
+ irc_protocol_tags (command, NULL),
_("%sYou were killed by %s%s"),
weechat_prefix ("quit"),
IRC_COLOR_CHAT_NICK,
@@ -536,7 +579,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
{
weechat_printf_tags ((ptr_channel) ?
ptr_channel->buffer : server->buffer,
- "irc_mode",
+ irc_protocol_tags (command, NULL),
_("%sMode %s%s %s[%s%s%s]%s by %s%s"),
(ptr_channel) ? weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -555,7 +598,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
if (!irc_ignore_check (server, NULL, nick, host))
{
weechat_printf_tags (server->buffer,
- "irc_mode",
+ irc_protocol_tags (command, NULL),
_("%sUser mode %s[%s%s%s]%s by %s%s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -627,7 +670,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command,
if (local_nick)
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_nick",
+ irc_protocol_tags (command, NULL),
_("%sYou are now known as "
"%s%s"),
weechat_prefix ("network"),
@@ -639,7 +682,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command,
if (!irc_ignore_check (server, ptr_channel, nick, host))
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_nick",
+ irc_protocol_tags (command, NULL),
_("%s%s%s%s is now known as "
"%s%s"),
weechat_prefix ("network"),
@@ -676,10 +719,11 @@ int
irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
- char *pos_target, *pos_args, *pos_end, *pos_usec, tags[128];
+ char *pos_target, *pos_args, *pos_end, *pos_usec;
struct timeval tv;
long sec1, usec1, sec2, usec2, difftime;
struct t_irc_channel *ptr_channel;
+ int notify_private;
/* NOTICE message looks like:
NOTICE AUTH :*** Looking up your hostname...
@@ -711,7 +755,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
if (pos_end)
pos_end[0] = '\0';
weechat_printf_tags (server->buffer,
- "irc_notice",
+ irc_protocol_tags (command, NULL),
_("%sCTCP %sVERSION%s reply from %s%s%s: %s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -749,7 +793,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
((sec1 * 1000000) + usec1);
weechat_printf_tags (server->buffer,
- "irc_notice,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sCTCP %sPING%s reply from "
"%s%s%s: %ld.%ld %s"),
irc_buffer_get_server_prefix (server,
@@ -776,7 +820,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
/* notice for channel */
ptr_channel = irc_channel_search (server, pos_target);
weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer,
- "irc_notice",
+ irc_protocol_tags (command, NULL),
"%sNotice%s(%s%s%s)%s: %s",
(ptr_channel) ?
weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"),
@@ -790,18 +834,13 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
else
{
/* notice for user */
+ notify_private = 0;
if (nick
&& (weechat_strcasecmp (nick, "nickserv") != 0)
&& (weechat_strcasecmp (nick, "chanserv") != 0)
&& (weechat_strcasecmp (nick, "memoserv") != 0))
{
- snprintf (tags, sizeof (tags),
- "%s", "irc_notice,notify_private");
- }
- else
- {
- snprintf (tags, sizeof (tags),
- "%s", "irc_notice");
+ notify_private = 1;
}
if (nick && weechat_config_boolean (irc_config_look_notice_as_pv))
@@ -827,7 +866,8 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
irc_channel_set_topic (ptr_channel, address);
weechat_printf_tags (ptr_channel->buffer,
- tags,
+ irc_protocol_tags (command,
+ (notify_private) ? "notify_private" : NULL),
"%s%s",
irc_nick_as_prefix (NULL, nick,
IRC_COLOR_CHAT_NICK_OTHER),
@@ -838,7 +878,8 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
if (address && address[0])
{
weechat_printf_tags (server->buffer,
- tags,
+ irc_protocol_tags (command,
+ (notify_private) ? "notify_private" : NULL),
"%s%s%s %s(%s%s%s)%s: %s",
irc_buffer_get_server_prefix (server,
"network"),
@@ -856,7 +897,8 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
if (nick && nick[0])
{
weechat_printf_tags (server->buffer,
- tags,
+ irc_protocol_tags (command,
+ (notify_private) ? "notify_private" : NULL),
"%s%s%s%s: %s",
irc_buffer_get_server_prefix (server,
"network"),
@@ -868,7 +910,8 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (server->buffer,
- tags,
+ irc_protocol_tags (command,
+ (notify_private) ? "notify_private" : NULL),
"%s%s",
irc_buffer_get_server_prefix (server,
"network"),
@@ -923,10 +966,11 @@ irc_protocol_cmd_part (struct t_irc_server *server, const char *command,
if (pos_comment)
{
weechat_printf_tags (ptr_channel->buffer,
- (local_part
- || !weechat_config_boolean (irc_config_look_smart_filter)
- || ptr_nick_speaking) ?
- "irc_part" : "irc_part,irc_smart_filter",
+ irc_protocol_tags (command,
+ (local_part
+ || !weechat_config_boolean (irc_config_look_smart_filter)
+ || ptr_nick_speaking) ?
+ NULL : "irc_smart_filter"),
_("%s%s%s %s(%s%s%s)%s has left %s%s "
"%s(%s%s%s)"),
weechat_prefix ("quit"),
@@ -947,10 +991,11 @@ irc_protocol_cmd_part (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (ptr_channel->buffer,
- (local_part
- || !weechat_config_boolean (irc_config_look_smart_filter)
- || ptr_nick_speaking) ?
- "irc_part" : "irc_part,irc_smart_filter",
+ irc_protocol_tags (command,
+ (local_part
+ || !weechat_config_boolean (irc_config_look_smart_filter)
+ || ptr_nick_speaking) ?
+ NULL : "irc_smart_filter"),
_("%s%s%s %s(%s%s%s)%s has left "
"%s%s"),
weechat_prefix ("quit"),
@@ -1173,7 +1218,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
pos_end_01[0] = '\0';
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_action,notify_message",
+ irc_protocol_tags (command,
+ "irc_action,notify_message"),
"%s%s%s %s%s",
weechat_prefix ("action"),
IRC_COLOR_CHAT_NICK,
@@ -1202,7 +1248,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
pos_end_01[0] = '\0';
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sReceived a CTCP %sSOUND%s \"%s\" "
"from %s%s"),
weechat_prefix ("network"),
@@ -1239,7 +1285,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
irc_server_sendf (server, "NOTICE %s :\01PING\01",
nick);
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sCTCP %sPING%s received from %s%s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -1290,7 +1336,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if (pos_message)
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sUnknown CTCP %s%s%s "
"received from %s%s%s: %s"),
weechat_prefix ("network"),
@@ -1305,7 +1351,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sUnknown CTCP %s%s%s "
"received from %s%s"),
weechat_prefix ("network"),
@@ -1334,7 +1380,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if (!irc_ignore_check (server, ptr_channel, nick, host))
{
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,notify_message",
+ irc_protocol_tags (command,
+ "notify_message"),
"%s%s",
irc_nick_as_prefix (ptr_nick,
(ptr_nick) ? NULL : nick,
@@ -1395,7 +1442,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
irc_server_sendf (server, "NOTICE %s :\01PING\01",
nick);
weechat_printf_tags (server->buffer,
- "irc_privmsg,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sCTCP %sPING%s received from %s%s"),
irc_buffer_get_server_prefix (server,
"network"),
@@ -1906,7 +1953,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
pos_end_01[0] = '\0';
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,irc_action,notify_private",
+ irc_protocol_tags (command,
+ "irc_action,notify_private"),
"%s%s%s %s%s",
weechat_prefix ("action"),
IRC_COLOR_CHAT_NICK,
@@ -1950,7 +1998,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
if (pos_message)
{
weechat_printf_tags (server->buffer,
- "irc_privmsg,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sUnknown CTCP %s%s%s "
"received from %s%s%s: %s"),
irc_buffer_get_server_prefix (server,
@@ -1966,7 +2014,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (server->buffer,
- "irc_privmsg,irc_ctcp",
+ irc_protocol_tags (command, "irc_ctcp"),
_("%sUnknown CTCP %s%s%s "
"received from %s%s"),
irc_buffer_get_server_prefix (server,
@@ -2011,7 +2059,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
irc_channel_set_topic (ptr_channel, address);
weechat_printf_tags (ptr_channel->buffer,
- "irc_privmsg,notify_private",
+ irc_protocol_tags (command, "notify_private"),
"%s%s",
irc_nick_as_prefix (NULL,
nick,
@@ -2076,10 +2124,11 @@ irc_protocol_cmd_quit (struct t_irc_server *server, const char *command,
if (pos_comment && pos_comment[0])
{
weechat_printf_tags (ptr_channel->buffer,
- (local_quit
- || !weechat_config_boolean (irc_config_look_smart_filter)
- || ptr_nick_speaking) ?
- "irc_quit" : "irc_quit,irc_smart_filter",
+ irc_protocol_tags (command,
+ (local_quit
+ || !weechat_config_boolean (irc_config_look_smart_filter)
+ || ptr_nick_speaking) ?
+ NULL : "irc_smart_filter"),
_("%s%s%s %s(%s%s%s)%s has quit "
"%s(%s%s%s)"),
weechat_prefix ("quit"),
@@ -2098,10 +2147,11 @@ irc_protocol_cmd_quit (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (ptr_channel->buffer,
- (local_quit
- || !weechat_config_boolean (irc_config_look_smart_filter)
- || ptr_nick_speaking) ?
- "irc_quit" : "irc_quit,irc_smart_filter",
+ irc_protocol_tags (command,
+ (local_quit
+ || !weechat_config_boolean (irc_config_look_smart_filter)
+ || ptr_nick_speaking) ?
+ NULL : "irc_smart_filter"),
_("%s%s%s %s(%s%s%s)%s has quit"),
weechat_prefix ("quit"),
IRC_COLOR_CHAT_NICK,
@@ -2229,7 +2279,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
topic_color = irc_color_decode (pos_topic,
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf_tags (ptr_buffer,
- "irc_topic",
+ irc_protocol_tags (command, NULL),
_("%s%s%s%s has changed topic for %s%s%s to: "
"\"%s%s\""),
(ptr_buffer == server->buffer) ?
@@ -2248,7 +2298,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (ptr_buffer,
- "irc_topic",
+ irc_protocol_tags (command, NULL),
_("%s%s%s%s has unset topic for %s%s"),
(ptr_buffer == server->buffer) ?
irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
@@ -2284,7 +2334,7 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, const char *command,
if (!irc_ignore_check (server, NULL, nick, host))
{
weechat_printf_tags (server->buffer,
- "irc_wallops",
+ irc_protocol_tags (command, NULL),
_("%sWallops from %s%s %s(%s%s%s)%s: %s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_NICK,
@@ -2553,15 +2603,7 @@ irc_protocol_cmd_305 (struct t_irc_server *server, const char *command,
server->is_away = 0;
server->away_time = 0;
- /*
- for (ptr_window = gui_windows; ptr_window;
- ptr_window = ptr_window->next_window)
- {
- if ((ptr_window->buffer->protocol == irc_protocol)
- && (IRC_BUFFER_SERVER(ptr_window->buffer) == server))
- gui_status_draw (ptr_window->buffer, 1);
- }
- */
+ weechat_bar_item_update ("buffer_name");
return WEECHAT_RC_OK;
}
@@ -2595,21 +2637,7 @@ irc_protocol_cmd_306 (struct t_irc_server *server, const char *command,
server->is_away = 1;
server->away_time = time (NULL);
- /*
- for (ptr_window = gui_windows; ptr_window;
- ptr_window = ptr_window->next_window)
- {
- if (ptr_window->buffer->protocol == irc_protocol)
- {
- if (IRC_BUFFER_SERVER(ptr_window->buffer) == server)
- {
- gui_status_draw (ptr_window->buffer, 1);
- ptr_window->buffer->last_read_line =
- ptr_window->buffer->last_line;
- }
- }
- }
- */
+ weechat_bar_item_update ("buffer_name");
return WEECHAT_RC_OK;
}
@@ -2689,7 +2717,7 @@ irc_protocol_cmd_312 (struct t_irc_server *server, const char *command,
IRC_PROTOCOL_MIN_ARGS(6);
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s %s(%s%s%s)",
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -2721,7 +2749,7 @@ irc_protocol_cmd_314 (struct t_irc_server *server, const char *command,
IRC_PROTOCOL_MIN_ARGS(8);
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%s%s%s %s(%s%s@%s%s)%s was %s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_NICK,
@@ -2761,7 +2789,7 @@ irc_protocol_cmd_315 (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s]%s %s",
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -2806,7 +2834,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
if (day > 0)
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%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"),
@@ -2838,7 +2866,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s]%s idle: %s%02d %s%s "
"%s%02d %s%s %s%02d %s%s, "
"signon at: %s%s"),
@@ -2887,7 +2915,7 @@ irc_protocol_cmd_321 (struct t_irc_server *server, const char *command,
((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL;
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s%s%s",
irc_buffer_get_server_prefix (server, "network"),
argv[3],
@@ -2920,7 +2948,7 @@ irc_protocol_cmd_322 (struct t_irc_server *server, const char *command,
(regexec (server->cmd_list_regexp, argv[3], 0, NULL, 0) == 0))
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s%s%s(%s%s%s)%s%s%s",
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -2960,7 +2988,7 @@ irc_protocol_cmd_323 (struct t_irc_server *server, const char *command,
((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s",
irc_buffer_get_server_prefix (server, "network"),
(pos_args && pos_args[0]) ? pos_args : "");
@@ -3030,7 +3058,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command,
if (pos_realname && pos_realname[0])
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s %s %s(%s%s%s)",
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -3048,7 +3076,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s %s",
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -3083,7 +3111,7 @@ irc_protocol_cmd_328 (struct t_irc_server *server, const char *command,
if (ptr_channel)
{
weechat_printf_tags (ptr_channel->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sURL for %s%s%s: %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -3123,7 +3151,7 @@ irc_protocol_cmd_329 (struct t_irc_server *server, const char *command,
if (ptr_channel->display_creation_date)
{
weechat_printf_tags (ptr_channel->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sChannel created on %s"),
weechat_prefix ("network"),
ctime (&datetime));
@@ -3133,7 +3161,7 @@ irc_protocol_cmd_329 (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sChannel %s%s%s created on %s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -3168,7 +3196,7 @@ irc_protocol_cmd_331 (struct t_irc_server *server, const char *command,
ptr_channel = irc_channel_search (server, argv[3]);
ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
weechat_printf_tags (ptr_buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sNo topic set for channel %s%s"),
(ptr_buffer == server->buffer) ?
irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
@@ -3209,7 +3237,7 @@ irc_protocol_cmd_332 (struct t_irc_server *server, const char *command,
ptr_buffer = server->buffer;
weechat_printf_tags (ptr_buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sTopic for %s%s%s is: \"%s%s\""),
(ptr_buffer == server->buffer) ?
irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
@@ -3245,7 +3273,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command,
if (ptr_channel && ptr_channel->nicks)
{
weechat_printf_tags (ptr_channel->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sTopic set by %s%s%s on %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
@@ -3256,7 +3284,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sTopic for %s%s%s set by %s%s%s on %s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -3286,7 +3314,7 @@ irc_protocol_cmd_338 (struct t_irc_server *server, const char *command,
IRC_PROTOCOL_MIN_ARGS(6);
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s]%s %s %s%s",
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_DELIMITERS,
@@ -3319,7 +3347,7 @@ irc_protocol_cmd_341 (struct t_irc_server *server, const char *command,
(void) argv_eol;
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%s%s%s%s has invited %s%s%s on %s%s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_NICK,
@@ -3349,7 +3377,7 @@ irc_protocol_cmd_344 (struct t_irc_server *server, const char *command,
IRC_PROTOCOL_MIN_ARGS(5);
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%sChannel reop %s%s%s: %s%s"),
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -3376,7 +3404,7 @@ irc_protocol_cmd_345 (struct t_irc_server *server, const char *command,
IRC_PROTOCOL_MIN_ARGS(5);
weechat_printf_tags (server->buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
"%s%s%s%s: %s",
irc_buffer_get_server_prefix (server, "network"),
IRC_COLOR_CHAT_CHANNEL,
@@ -3416,7 +3444,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, const char *command,
{
datetime = (time_t)(atol (argv[6]));
weechat_printf_tags (ptr_buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s]%s exception %s%s%s "
"by %s%s %s(%s%s%s)%s on %s"),
(ptr_buffer == server->buffer) ?
@@ -3441,7 +3469,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, const char *command,
else
{
weechat_printf_tags (ptr_buffer,
- irc_protocol_tags(command, "irc_numeric"),
+ irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s]%s exception %s%s"),
(ptr_buffer == server->buffer) ?
irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index 29b56bfac..cee34c829 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -70,6 +70,7 @@ struct t_irc_protocol_msg
};
extern char *irc_protocol_get_nick_from_host (const char *host);
+extern char *irc_protocol_tags (const char *command, const char *tags);
extern void irc_protocol_recv_command (struct t_irc_server *server,
const char *entire_line,
const char *host, const char *command,
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 3e298c0ab..b2f41342d 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -2111,6 +2111,10 @@ irc_server_create_buffer (struct t_irc_server *server, int all_servers)
if (!server->buffer)
return NULL;
+ weechat_buffer_set (server->buffer, "short_name", server->name);
+ weechat_buffer_set (server->buffer, "localvar_set_server", server->name);
+ weechat_buffer_set (server->buffer, "localvar_set_channel", server->name);
+
weechat_hook_signal_send ("logger_backlog",
WEECHAT_HOOK_SIGNAL_POINTER, server->buffer);
@@ -2192,9 +2196,6 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
irc_buffer_servers = server->buffer;
}
- weechat_buffer_set (server->buffer, "short_name", server->name);
- weechat_buffer_set (server->buffer, "localvar_set_server", server->name);
-
weechat_buffer_set (server->buffer, "display", "1");
weechat_bar_item_update ("buffer_name");