summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/CMakeLists.txt2
-rw-r--r--src/plugins/irc/Makefile.am2
-rw-r--r--src/plugins/irc/irc-bar-item.c2
-rw-r--r--src/plugins/irc/irc-bar-item.h2
-rw-r--r--src/plugins/irc/irc-buffer.c2
-rw-r--r--src/plugins/irc/irc-buffer.h2
-rw-r--r--src/plugins/irc/irc-channel.c4
-rw-r--r--src/plugins/irc/irc-channel.h9
-rw-r--r--src/plugins/irc/irc-color.c2
-rw-r--r--src/plugins/irc/irc-color.h2
-rw-r--r--src/plugins/irc/irc-command.c233
-rw-r--r--src/plugins/irc/irc-command.h11
-rw-r--r--src/plugins/irc/irc-completion.c80
-rw-r--r--src/plugins/irc/irc-completion.h2
-rw-r--r--src/plugins/irc/irc-config.c34
-rw-r--r--src/plugins/irc/irc-config.h3
-rw-r--r--src/plugins/irc/irc-ctcp.c2
-rw-r--r--src/plugins/irc/irc-ctcp.h2
-rw-r--r--src/plugins/irc/irc-debug.c2
-rw-r--r--src/plugins/irc/irc-debug.h2
-rw-r--r--src/plugins/irc/irc-ignore.c2
-rw-r--r--src/plugins/irc/irc-ignore.h2
-rw-r--r--src/plugins/irc/irc-info.c2
-rw-r--r--src/plugins/irc/irc-info.h2
-rw-r--r--src/plugins/irc/irc-input.c2
-rw-r--r--src/plugins/irc/irc-input.h2
-rw-r--r--src/plugins/irc/irc-message.c44
-rw-r--r--src/plugins/irc/irc-message.h2
-rw-r--r--src/plugins/irc/irc-mode.c2
-rw-r--r--src/plugins/irc/irc-mode.h2
-rw-r--r--src/plugins/irc/irc-msgbuffer.c2
-rw-r--r--src/plugins/irc/irc-msgbuffer.h2
-rw-r--r--src/plugins/irc/irc-nick.c16
-rw-r--r--src/plugins/irc/irc-nick.h6
-rw-r--r--src/plugins/irc/irc-notify.c2
-rw-r--r--src/plugins/irc/irc-notify.h2
-rw-r--r--src/plugins/irc/irc-protocol.c236
-rw-r--r--src/plugins/irc/irc-protocol.h2
-rw-r--r--src/plugins/irc/irc-raw.c2
-rw-r--r--src/plugins/irc/irc-raw.h2
-rw-r--r--src/plugins/irc/irc-redirect.c2
-rw-r--r--src/plugins/irc/irc-redirect.h2
-rw-r--r--src/plugins/irc/irc-sasl.c2
-rw-r--r--src/plugins/irc/irc-sasl.h2
-rw-r--r--src/plugins/irc/irc-server.c85
-rw-r--r--src/plugins/irc/irc-server.h4
-rw-r--r--src/plugins/irc/irc-upgrade.c6
-rw-r--r--src/plugins/irc/irc-upgrade.h2
-rw-r--r--src/plugins/irc/irc.c2
-rw-r--r--src/plugins/irc/irc.h2
50 files changed, 614 insertions, 229 deletions
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt
index 399dc89c4..b773dcf3e 100644
--- a/src/plugins/irc/CMakeLists.txt
+++ b/src/plugins/irc/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am
index 85af3f343..a086e3edf 100644
--- a/src/plugins/irc/Makefile.am
+++ b/src/plugins/irc/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c
index 740a6f6a9..08c365bf6 100644
--- a/src/plugins/irc/irc-bar-item.c
+++ b/src/plugins/irc/irc-bar-item.c
@@ -1,7 +1,7 @@
/*
* irc-bar-item.c - bar items for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-bar-item.h b/src/plugins/irc/irc-bar-item.h
index 688e9f665..948abd75d 100644
--- a/src/plugins/irc/irc-bar-item.h
+++ b/src/plugins/irc/irc-bar-item.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c
index a1be1c361..f7df9d267 100644
--- a/src/plugins/irc/irc-buffer.c
+++ b/src/plugins/irc/irc-buffer.c
@@ -1,7 +1,7 @@
/*
* irc-buffer.c - buffer functions for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h
index e02ffea1e..b31a5c2bb 100644
--- a/src/plugins/irc/irc-buffer.h
+++ b/src/plugins/irc/irc-buffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 11d0c4df1..fe7b92863 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -1,7 +1,7 @@
/*
* irc-channel.c - channel and private chat management for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -655,7 +655,7 @@ irc_channel_remove_account (struct t_irc_server *server,
{
if (ptr_nick->account)
free (ptr_nick->account);
- ptr_nick->account = strdup ("*");
+ ptr_nick->account = NULL;
}
}
}
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index 08f7f1e9b..479dbba45 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -78,6 +78,11 @@ struct t_irc_channel
extern int irc_channel_valid (struct t_irc_server *server,
struct t_irc_channel *channel);
+extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
+ const char *channel_name);
+extern struct t_gui_buffer *irc_channel_search_buffer (struct t_irc_server *server,
+ int channel_type,
+ const char *channel_name);
extern struct t_gui_buffer *irc_channel_create_buffer (struct t_irc_server *server,
int channel_type,
const char *channel_name,
@@ -98,8 +103,6 @@ extern void irc_channel_set_modes (struct t_irc_channel *channel,
extern void irc_channel_free (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_free_all (struct t_irc_server *server);
-extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
- const char *channel_name);
extern int irc_channel_is_channel (struct t_irc_server *server,
const char *string);
extern const char *irc_channel_get_auto_chantype (struct t_irc_server *server,
diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c
index f5f4d2688..194a32ac3 100644
--- a/src/plugins/irc/irc-color.c
+++ b/src/plugins/irc/irc-color.c
@@ -1,7 +1,7 @@
/*
* irc-color.c - IRC color decoding/encoding in messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-color.h b/src/plugins/irc/irc-color.h
index cc8f58bf6..9425db0ac 100644
--- a/src/plugins/irc/irc-color.h
+++ b/src/plugins/irc/irc-color.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index a5bb53559..d3fa3becf 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -1,7 +1,7 @@
/*
* irc-command.c - IRC commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -1366,69 +1366,106 @@ int
irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
- char *irc_cmd, str_time[512];
+ char **targets, *ctcp_type, str_time[512];
+ const char *ctcp_target, *ctcp_args;
+ int num_targets, arg_target, arg_type, arg_args, i;
struct timeval tv;
- IRC_BUFFER_GET_SERVER(buffer);
- IRC_COMMAND_CHECK_SERVER("ctcp", 1);
+ IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
WEECHAT_COMMAND_MIN_ARGS(3, "");
- irc_cmd = strdup (argv[2]);
- if (!irc_cmd)
+ arg_target = 1;
+ arg_type = 2;
+ arg_args = 3;
+
+ if ((argc >= 5) && (weechat_strcasecmp (argv[1], "-server") == 0))
+ {
+ ptr_server = irc_server_search (argv[2]);
+ ptr_channel = NULL;
+ arg_target = 3;
+ arg_type = 4;
+ arg_args = 5;
+ }
+
+ IRC_COMMAND_CHECK_SERVER("ctcp", 1);
+
+ targets = weechat_string_split (argv[arg_target], ",", 0, 0, &num_targets);
+ if (!targets)
+ WEECHAT_COMMAND_ERROR;
+
+ ctcp_type = strdup (argv[arg_type]);
+ if (!ctcp_type)
+ {
+ weechat_string_free_split (targets);
WEECHAT_COMMAND_ERROR;
+ }
- weechat_string_toupper (irc_cmd);
+ weechat_string_toupper (ctcp_type);
- if ((weechat_strcasecmp (argv[2], "ping") == 0) && !argv_eol[3])
+ if ((strcmp (ctcp_type, "PING") == 0) && !argv_eol[arg_args])
{
+ /* generate argument for PING if not provided */
gettimeofday (&tv, NULL);
snprintf (str_time, sizeof (str_time), "%ld %ld",
(long)tv.tv_sec, (long)tv.tv_usec);
- irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PRIVMSG %s :\01PING %s\01",
- argv[1], str_time);
- weechat_printf (
- irc_msgbuffer_get_target_buffer (
- ptr_server, argv[1], NULL, "ctcp", NULL),
- _("%sCTCP query to %s%s%s: %s%s%s%s%s"),
- weechat_prefix ("network"),
- irc_nick_color_for_msg (ptr_server, 0, NULL, argv[1]),
- argv[1],
- IRC_COLOR_RESET,
- IRC_COLOR_CHAT_CHANNEL,
- irc_cmd,
- IRC_COLOR_RESET,
- " ",
- str_time);
+ ctcp_args = str_time;
}
else
{
- irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PRIVMSG %s :\01%s%s%s\01",
- argv[1],
- irc_cmd,
- (argv_eol[3]) ? " " : "",
- (argv_eol[3]) ? argv_eol[3] : "");
- weechat_printf (
- irc_msgbuffer_get_target_buffer (
- ptr_server, argv[1], NULL, "ctcp", NULL),
- _("%sCTCP query to %s%s%s: %s%s%s%s%s"),
- weechat_prefix ("network"),
- irc_nick_color_for_msg (ptr_server, 0, NULL, argv[1]),
- argv[1],
- IRC_COLOR_RESET,
- IRC_COLOR_CHAT_CHANNEL,
- irc_cmd,
- IRC_COLOR_RESET,
- (argv_eol[3]) ? " " : "",
- (argv_eol[3]) ? argv_eol[3] : "");
- }
-
- free (irc_cmd);
+ ctcp_args = argv_eol[arg_args];
+ }
+
+ for (i = 0; i < num_targets; i++)
+ {
+ ctcp_target = targets[i];
+
+ if (strcmp (targets[i], "*") == 0)
+ {
+ if (!ptr_channel
+ || ((ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
+ && (ptr_channel->type != IRC_CHANNEL_TYPE_PRIVATE)))
+ {
+ weechat_printf (
+ ptr_server->buffer,
+ _("%s%s: \"%s\" command can only be executed in a channel "
+ "or private buffer"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "ctcp *");
+ ctcp_target = NULL;
+ }
+ else
+ ctcp_target = ptr_channel->name;
+ }
+
+ if (ctcp_target)
+ {
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "PRIVMSG %s :\01%s%s%s\01",
+ ctcp_target,
+ ctcp_type,
+ (ctcp_args) ? " " : "",
+ (ctcp_args) ? ctcp_args : "");
+ weechat_printf (
+ irc_msgbuffer_get_target_buffer (
+ ptr_server, ctcp_target, NULL, "ctcp", NULL),
+ _("%sCTCP query to %s%s%s: %s%s%s%s%s"),
+ weechat_prefix ("network"),
+ irc_nick_color_for_msg (ptr_server, 0, NULL, ctcp_target),
+ ctcp_target,
+ IRC_COLOR_RESET,
+ IRC_COLOR_CHAT_CHANNEL,
+ ctcp_type,
+ IRC_COLOR_RESET,
+ (ctcp_args) ? " " : "",
+ (ctcp_args) ? ctcp_args : "");
+ }
+ }
+
+ free (ctcp_type);
+ weechat_string_free_split (targets);
return WEECHAT_RC_OK;
}
@@ -3069,6 +3106,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
char **targets, *msg_pwd_hidden, *string;
int num_targets, i, j, arg_target, arg_text, is_channel, status_msg;
int hide_password;
+ struct t_irc_channel *ptr_channel2;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
@@ -3108,42 +3146,46 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
_("%s%s: \"%s\" command can only be executed in a channel "
"or private buffer"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, "msg *");
- return WEECHAT_RC_OK;
}
- string = irc_color_decode (argv_eol[arg_text],
- weechat_config_boolean (irc_config_network_colors_send));
- irc_input_user_message_display (ptr_channel->buffer, 0,
- (string) ? string : argv_eol[arg_text]);
- if (string)
- free (string);
+ else
+ {
+ string = irc_color_decode (
+ argv_eol[arg_text],
+ weechat_config_boolean (irc_config_network_colors_send));
+ irc_input_user_message_display (
+ ptr_channel->buffer, 0,
+ (string) ? string : argv_eol[arg_text]);
+ if (string)
+ free (string);
- irc_server_sendf (ptr_server,
- IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "PRIVMSG %s :%s",
- ptr_channel->name, argv_eol[arg_text]);
+ irc_server_sendf (ptr_server,
+ IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "PRIVMSG %s :%s",
+ ptr_channel->name, argv_eol[arg_text]);
+ }
}
else
{
is_channel = 0;
- ptr_channel = NULL;
+ ptr_channel2 = NULL;
status_msg = 0;
if (irc_server_prefix_char_statusmsg (ptr_server,
targets[i][0])
&& irc_channel_is_channel (ptr_server, targets[i] + 1))
{
- ptr_channel = irc_channel_search (ptr_server, targets[i] + 1);
+ ptr_channel2 = irc_channel_search (ptr_server, targets[i] + 1);
is_channel = 1;
status_msg = 1;
}
else
{
- ptr_channel = irc_channel_search (ptr_server, targets[i]);
- if (ptr_channel)
+ ptr_channel2 = irc_channel_search (ptr_server, targets[i]);
+ if (ptr_channel2)
is_channel = 1;
}
if (is_channel)
{
- if (ptr_channel)
+ if (ptr_channel2)
{
string = irc_color_decode (
argv_eol[arg_text],
@@ -3155,7 +3197,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
* (to "@#channel" or "+#channel")
*/
weechat_printf_tags (
- ptr_channel->buffer,
+ ptr_channel2->buffer,
"notify_none,no_highlight",
"%s%s%s -> %s%s%s: %s",
weechat_prefix ("network"),
@@ -3170,7 +3212,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
{
/* standard message (to "#channel") */
irc_input_user_message_display (
- ptr_channel->buffer,
+ ptr_channel2->buffer,
0,
(string) ? string : argv_eol[arg_text]);
}
@@ -3231,12 +3273,12 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
string = irc_color_decode (
argv_eol[arg_text],
weechat_config_boolean (irc_config_network_colors_send));
- ptr_channel = irc_channel_search (ptr_server,
- targets[i]);
- if (ptr_channel)
+ ptr_channel2 = irc_channel_search (ptr_server,
+ targets[i]);
+ if (ptr_channel2)
{
irc_input_user_message_display (
- ptr_channel->buffer,
+ ptr_channel2->buffer,
0,
(string) ? string : argv_eol[arg_text]);
}
@@ -4532,7 +4574,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6])) ?
_("on") : _("off"));
/* ssl */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL]))
@@ -4542,7 +4584,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " ssl. . . . . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL])) ?
_("on") : _("off"));
/* ssl_cert */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_CERT]))
@@ -4584,7 +4626,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " ssl_verify . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY])) ?
_("on") : _("off"));
/* password */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD]))
@@ -4660,7 +4702,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " autoconnect. . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT])) ?
_("on") : _("off"));
/* autoreconnect */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
@@ -4670,7 +4712,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " autoreconnect. . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT])) ?
_("on") : _("off"));
/* autoreconnect_delay */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
@@ -4690,6 +4732,16 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS]));
+ /* nicks_alternate */
+ if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE]))
+ weechat_printf (NULL, " nicks_alternate. . . : (%s)",
+ (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) ?
+ _("on") : _("off"));
+ else
+ weechat_printf (NULL, " nicks_alternate. . . : %s%s",
+ IRC_COLOR_CHAT_VALUE,
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) ?
+ _("on") : _("off"));
/* username */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_printf (NULL, " username . . . . . . : ('%s')",
@@ -4762,7 +4814,7 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
else
weechat_printf (NULL, " autorejoin . . . . . : %s%s",
IRC_COLOR_CHAT_VALUE,
- weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
+ (weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN])) ?
_("on") : _("off"));
/* autorejoin_delay */
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))
@@ -6138,19 +6190,18 @@ irc_command_init ()
"cap",
N_("client capability negotiation"),
N_("ls || list || req|ack [<capability> [<capability>...]]"
- " || clear || end"),
+ " || end"),
N_(" ls: list the capabilities supported by the server\n"
" list: list the capabilities currently enabled\n"
" req: request a capability\n"
" ack: acknowledge capabilities which require client-side "
"acknowledgement\n"
- "clear: clear the capabilities currently enabled\n"
" end: end the capability negotiation\n"
"\n"
"Without argument, \"ls\" and \"list\" are sent.\n"
"\n"
"Capabilities supported by WeeChat are: "
- "account-notify, away-notify, extended-join, "
+ "account-notify, away-notify, cap-notify, extended-join, "
"multi-prefix, server-time, userhost-in-names.\n"
"\n"
"The capabilities to automatically enable on servers can be set "
@@ -6159,13 +6210,11 @@ irc_command_init ()
"\n"
"Examples:\n"
" /cap\n"
- " /cap req multi-prefix\n"
- " /cap clear"),
+ " /cap req multi-prefix away-notify"),
"ls"
" || list"
" || req " IRC_COMMAND_CAP_SUPPORTED_COMPLETION
" || ack " IRC_COMMAND_CAP_SUPPORTED_COMPLETION
- " || clear"
" || end",
&irc_command_cap, NULL);
weechat_hook_command (
@@ -6209,12 +6258,20 @@ irc_command_init ()
weechat_hook_command (
"ctcp",
N_("send a CTCP message (Client-To-Client Protocol)"),
- N_("<target> <type> [<arguments>]"),
- N_(" target: nick or channel name to send CTCP to\n"
- " type: CTCP type (examples: \"version\", \"ping\", ..)\n"
- "arguments: arguments for CTCP"),
- "%(irc_channel)|%(nicks) action|clientinfo|finger|ping|source|time|"
- "userinfo|version",
+ N_("[-server <server>] <target>[,<target>...] <type> [<arguments>]"),
+ N_(" server: send to this server (internal name)\n"
+ " target: nick or channel ('*' = current channel)\n"
+ " type: CTCP type (examples: \"version\", \"ping\", ..)\n"
+ "arguments: arguments for CTCP\n"
+ "\n"
+ "Examples:\n"
+ " /ctcp toto time\n"
+ " /ctcp toto version\n"
+ " /ctcp * version"),
+ "-server %(irc_servers) %(irc_channel)|%(nicks)|* "
+ IRC_COMMAND_CTCP_SUPPORTED_COMPLETION
+ " || %(irc_channel)|%(nicks)|* "
+ IRC_COMMAND_CTCP_SUPPORTED_COMPLETION,
&irc_command_ctcp, NULL);
weechat_hook_command (
"cycle",
@@ -6481,8 +6538,8 @@ irc_command_init ()
N_("server: send to this server (internal name)\n"
"target: nick or channel (may be mask, '*' = current channel)\n"
" text: text to send"),
- "-server %(irc_servers) %(nicks)"
- " || %(nicks)",
+ "-server %(irc_servers) %(nicks)|*"
+ " || %(nicks)|*",
&irc_command_msg, NULL);
weechat_hook_command (
"names",
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index 358bc6385..ac48c941f 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -45,9 +45,12 @@ struct t_irc_channel;
/* list of supported capabilities (for completion in command /cap) */
#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \
- "account-notify|away-notify|extended-join|" \
- "multi-prefix|server-time|userhost-in-names" \
- "|%*"
+ "account-notify|away-notify|cap-notify|extended-join|" \
+ "multi-prefix|server-time|userhost-in-names|%*"
+
+/* list of supported CTCPs (for completion in command /ctcp) */
+#define IRC_COMMAND_CTCP_SUPPORTED_COMPLETION \
+ "action|clientinfo|finger|ping|source|time|userinfo|version"
extern void irc_command_away_server (struct t_irc_server *server,
const char *arguments,
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 831429fe9..153bad8d6 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -1,7 +1,7 @@
/*
* irc-completion.c - completion for IRC commands
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -93,26 +93,32 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel2;
- IRC_BUFFER_GET_SERVER(buffer);
+ IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
- (void) buffer;
if (ptr_server)
{
- for (ptr_channel = ptr_server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
+ for (ptr_channel2 = ptr_server->channels; ptr_channel2;
+ ptr_channel2 = ptr_channel2->next_channel)
{
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- weechat_hook_completion_list_add (completion, ptr_channel->name,
+ weechat_hook_completion_list_add (completion, ptr_channel2->name,
0, WEECHAT_LIST_POS_SORT);
}
}
+
+ /* add current channel first in list */
+ if (ptr_channel)
+ {
+ weechat_hook_completion_list_add (completion, ptr_channel->name,
+ 0, WEECHAT_LIST_POS_BEGINNING);
+ }
}
return WEECHAT_RC_OK;
@@ -134,7 +140,6 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
/* make C compiler happy */
(void) data;
(void) completion_item;
- (void) buffer;
if (ptr_server)
{
@@ -458,28 +463,65 @@ irc_completion_channels_cb (void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- struct t_irc_server *ptr_server;
- struct t_irc_channel *ptr_channel;
+ struct t_irc_server *ptr_server2;
+ struct t_irc_channel *ptr_channel2;
+ struct t_weelist *channels_current_server;
+ int i;
+
+ IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
(void) data;
(void) completion_item;
- (void) buffer;
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
+ channels_current_server = weechat_list_new ();
+
+ for (ptr_server2 = irc_servers; ptr_server2;
+ ptr_server2 = ptr_server2->next_server)
{
- for (ptr_channel = ptr_server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
+ for (ptr_channel2 = ptr_server2->channels; ptr_channel2;
+ ptr_channel2 = ptr_channel2->next_channel)
{
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- weechat_hook_completion_list_add (completion, ptr_channel->name,
- 0, WEECHAT_LIST_POS_SORT);
+ if (ptr_server2 == ptr_server)
+ {
+ /* will be added later to completions */
+ weechat_list_add (channels_current_server,
+ ptr_channel2->name,
+ WEECHAT_LIST_POS_SORT,
+ NULL);
+ }
+ else
+ {
+ weechat_hook_completion_list_add (completion,
+ ptr_channel2->name,
+ 0,
+ WEECHAT_LIST_POS_SORT);
+ }
}
}
}
+ /* add channels of current server first in list */
+ for (i = weechat_list_size (channels_current_server) - 1; i >= 0; i--)
+ {
+ weechat_hook_completion_list_add (
+ completion,
+ weechat_list_string (
+ weechat_list_get (channels_current_server, i)),
+ 0,
+ WEECHAT_LIST_POS_BEGINNING);
+ }
+ weechat_list_free (channels_current_server);
+
+ /* add current channel first in list */
+ if (ptr_channel)
+ {
+ weechat_hook_completion_list_add (completion, ptr_channel->name,
+ 0, WEECHAT_LIST_POS_BEGINNING);
+ }
+
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/irc/irc-completion.h b/src/plugins/irc/irc-completion.h
index aa2eb1a6f..20dacb576 100644
--- a/src/plugins/irc/irc-completion.h
+++ b/src/plugins/irc/irc-completion.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index fa879e4f8..20b6aff58 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -1,7 +1,7 @@
/*
* irc-config.c - IRC configuration options (file irc.conf)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -131,7 +131,6 @@ struct t_config_option *irc_config_color_topic_old;
/* IRC config, network section */
-struct t_config_option *irc_config_network_alternate_nick;
struct t_config_option *irc_config_network_autoreconnect_delay_growing;
struct t_config_option *irc_config_network_autoreconnect_delay_max;
struct t_config_option *irc_config_network_ban_mask_default;
@@ -1594,7 +1593,8 @@ irc_config_server_new_option (struct t_config_file *config_file,
config_file, section,
option_name, "string",
N_("list of hostname/port or IP/port for server (separated by "
- "comma)"),
+ "comma) "
+ "(note: content is evaluated, see /help eval)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
@@ -1885,6 +1885,22 @@ irc_config_server_new_option (struct t_config_file *config_file,
callback_change, callback_change_data,
NULL, NULL);
break;
+ case IRC_SERVER_OPTION_NICKS_ALTERNATE:
+ new_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "boolean",
+ N_("get an alternate nick when all the declared nicks are "
+ "already used on server: add some \"_\" until the nick has "
+ "a length of 9, and then replace last char (or the two "
+ "last chars) by a number from 1 to 99, until we find "
+ "a nick not used on server"),
+ NULL, 0, 0,
+ default_value, value,
+ null_value_allowed,
+ callback_check_value, callback_check_value_data,
+ callback_change, callback_change_data,
+ NULL, NULL);
+ break;
case IRC_SERVER_OPTION_USERNAME:
new_option = weechat_config_new_option (
config_file, section,
@@ -2893,8 +2909,8 @@ irc_config_init ()
"found, WeeChat will try with next modes received from server "
"(\"PREFIX\"); a special mode \"*\" can be used as default color "
"if no mode has been found in list)"),
- NULL, 0, 0, "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;"
- "v:yellow;*:lightblue", NULL, 0, NULL, NULL,
+ NULL, 0, 0, "y:lightred;q:lightred;a:lightcyan;o:lightgreen;"
+ "h:lightmagenta;v:yellow;*:lightblue", NULL, 0, NULL, NULL,
&irc_config_change_color_nick_prefixes, NULL, NULL, NULL);
irc_config_color_notice = weechat_config_new_option (
irc_config_file, ptr_section,
@@ -2940,14 +2956,6 @@ irc_config_init ()
return 0;
}
- irc_config_network_alternate_nick = weechat_config_new_option (
- irc_config_file, ptr_section,
- "alternate_nick", "boolean",
- N_("get an alternate nick when the nick is already used on server: add "
- "some \"_\" until the nick has a length of 9, and then replace last "
- "char (or the two last chars) by a number from 1 to 99, until we "
- "find a nick not used on server"),
- NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
irc_config_network_autoreconnect_delay_growing = weechat_config_new_option (
irc_config_file, ptr_section,
"autoreconnect_delay_growing", "integer",
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index cd0a766b5..caca3f6aa 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -172,7 +172,6 @@ extern struct t_config_option *irc_config_color_topic_current;
extern struct t_config_option *irc_config_color_topic_new;
extern struct t_config_option *irc_config_color_topic_old;
-extern struct t_config_option *irc_config_network_alternate_nick;
extern struct t_config_option *irc_config_network_autoreconnect_delay_growing;
extern struct t_config_option *irc_config_network_autoreconnect_delay_max;
extern struct t_config_option *irc_config_network_ban_mask_default;
diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c
index 55d7c6b2e..081a5414a 100644
--- a/src/plugins/irc/irc-ctcp.c
+++ b/src/plugins/irc/irc-ctcp.c
@@ -1,7 +1,7 @@
/*
* irc-ctcp.c - IRC CTCP protocol
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-ctcp.h b/src/plugins/irc/irc-ctcp.h
index 179f2ed21..0febcd0cc 100644
--- a/src/plugins/irc/irc-ctcp.h
+++ b/src/plugins/irc/irc-ctcp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-debug.c b/src/plugins/irc/irc-debug.c
index ea33f0a37..9e8ffca6d 100644
--- a/src/plugins/irc/irc-debug.c
+++ b/src/plugins/irc/irc-debug.c
@@ -1,7 +1,7 @@
/*
* irc-debug.c - debug functions for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-debug.h b/src/plugins/irc/irc-debug.h
index 199d9e7af..8daa12139 100644
--- a/src/plugins/irc/irc-debug.h
+++ b/src/plugins/irc/irc-debug.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c
index 2f18a4fea..4ef33d3ad 100644
--- a/src/plugins/irc/irc-ignore.c
+++ b/src/plugins/irc/irc-ignore.c
@@ -1,7 +1,7 @@
/*
* irc-ignore.c - ignore (nicks/hosts) management for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-ignore.h b/src/plugins/irc/irc-ignore.h
index 70d37c85f..9a8284903 100644
--- a/src/plugins/irc/irc-ignore.h
+++ b/src/plugins/irc/irc-ignore.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index f905a6a4b..46c9c1a8f 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -1,7 +1,7 @@
/*
* irc-info.c - info, infolist and hdata hooks for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-info.h b/src/plugins/irc/irc-info.h
index 888a1d93a..7f50323a8 100644
--- a/src/plugins/irc/irc-info.h
+++ b/src/plugins/irc/irc-info.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index f7e3b5af3..81cbcc044 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -1,7 +1,7 @@
/*
* irc-input.c - input data management for IRC buffers
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-input.h b/src/plugins/irc/irc-input.h
index f4fc4bdb4..9a7988102 100644
--- a/src/plugins/irc/irc-input.h
+++ b/src/plugins/irc/irc-input.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c
index e0c4dcf4f..1524a9f3b 100644
--- a/src/plugins/irc/irc-message.c
+++ b/src/plugins/irc/irc-message.c
@@ -1,7 +1,7 @@
/*
* irc-message.c - functions for IRC messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -70,7 +70,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
int *pos_command, int *pos_arguments, int *pos_channel,
int *pos_text)
{
- const char *ptr_message, *pos, *pos2, *pos3, *pos4;
+ const char *ptr_message, *pos, *pos2, *pos3, *pos4, *ptr_channel_found;
if (tags)
*tags = NULL;
@@ -96,6 +96,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
*pos_channel = -1;
if (pos_text)
*pos_text = -1;
+ ptr_channel_found = NULL;
if (!message)
return;
@@ -209,6 +210,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
{
if (irc_channel_is_channel (server, pos))
{
+ ptr_channel_found = pos;
pos2 = strchr (pos, ' ');
if (channel)
{
@@ -253,6 +255,7 @@ irc_message_parse (struct t_irc_server *server, const char *message,
}
if (irc_channel_is_channel (server, pos2))
{
+ ptr_channel_found = pos2;
pos4 = strchr (pos2, ' ');
if (channel)
{
@@ -277,13 +280,38 @@ irc_message_parse (struct t_irc_server *server, const char *message,
*pos_text = pos4 - message;
}
}
- else if ((channel && !*channel)
- || (pos_channel && (*pos_channel < 0)))
+ else
{
- if (channel)
- *channel = weechat_strndup (pos, pos3 - pos);
- if (pos_channel)
- *pos_channel = pos - message;
+ if (ptr_channel_found)
+ {
+ if (pos[0] == ':')
+ pos++;
+ if (text)
+ *text = strdup (pos);
+ if (pos_text)
+ *pos_text = pos - message;
+ }
+ else
+ {
+ if (channel)
+ *channel = weechat_strndup (pos, pos3 - pos);
+ if (pos_channel)
+ *pos_channel = pos - message;
+ pos4 = strchr (pos3, ' ');
+ if (pos4)
+ {
+ while (pos4[0] == ' ')
+ {
+ pos4++;
+ }
+ if (pos4[0] == ':')
+ pos4++;
+ if (text)
+ *text = strdup (pos4);
+ if (pos_text)
+ *pos_text = pos4 - message;
+ }
+ }
}
}
}
diff --git a/src/plugins/irc/irc-message.h b/src/plugins/irc/irc-message.h
index 026595b7e..a4478115c 100644
--- a/src/plugins/irc/irc-message.h
+++ b/src/plugins/irc/irc-message.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c
index 163e9cdd7..a31d64388 100644
--- a/src/plugins/irc/irc-mode.c
+++ b/src/plugins/irc/irc-mode.c
@@ -1,7 +1,7 @@
/*
* irc-mode.c - IRC channel/user modes management
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-mode.h b/src/plugins/irc/irc-mode.h
index f6a498626..8dbd2220e 100644
--- a/src/plugins/irc/irc-mode.h
+++ b/src/plugins/irc/irc-mode.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-msgbuffer.c b/src/plugins/irc/irc-msgbuffer.c
index 0e58a417a..27708fccb 100644
--- a/src/plugins/irc/irc-msgbuffer.c
+++ b/src/plugins/irc/irc-msgbuffer.c
@@ -1,7 +1,7 @@
/*
* irc-msgbuffer.c - target buffer for IRC messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-msgbuffer.h b/src/plugins/irc/irc-msgbuffer.h
index 370c2dd92..a27e7daa2 100644
--- a/src/plugins/irc/irc-msgbuffer.h
+++ b/src/plugins/irc/irc-msgbuffer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 0877f331a..98b470641 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -1,7 +1,7 @@
/*
* irc-nick.c - nick management for IRC plugin
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -626,7 +626,7 @@ irc_nick_nicklist_set_color_all ()
struct t_irc_nick *
irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
const char *nickname, const char *host, const char *prefixes,
- int away, const char *account)
+ int away, const char *account, const char *realname)
{
struct t_irc_nick *new_nick, *ptr_nick;
int length;
@@ -650,6 +650,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
if (ptr_nick->account)
free (ptr_nick->account);
ptr_nick->account = (account) ? strdup (account) : NULL;
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (realname) ? strdup (realname) : NULL;
/* add new nick in nicklist */
irc_nick_nicklist_add (server, channel, ptr_nick);
@@ -665,6 +668,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
new_nick->name = strdup (nickname);
new_nick->host = (host) ? strdup (host) : NULL;
new_nick->account = (account) ? strdup (account) : NULL;
+ new_nick->realname = (realname) ? strdup (realname) : NULL;
length = strlen (irc_server_get_prefix_chars (server));
new_nick->prefixes = malloc (length + 1);
if (!new_nick->name || !new_nick->prefixes)
@@ -675,6 +679,8 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
free (new_nick->host);
if (new_nick->account)
free (new_nick->account);
+ if (new_nick->realname)
+ free (new_nick->realname);
if (new_nick->prefixes)
free (new_nick->prefixes);
free (new_nick);
@@ -817,6 +823,8 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
free (nick->prefixes);
if (nick->account)
free (nick->account);
+ if (nick->realname)
+ free (nick->realname);
if (nick->color)
free (nick->color);
@@ -1137,6 +1145,7 @@ irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_nick, prefix, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, away, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, account, STRING, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_nick, realname, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, color, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_nick, prev_nick, POINTER, 0, NULL, hdata_name);
WEECHAT_HDATA_VAR(struct t_irc_nick, next_nick, POINTER, 0, NULL, hdata_name);
@@ -1177,6 +1186,8 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "account", nick->account))
return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "realname", nick->realname))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
return 0;
@@ -1197,6 +1208,7 @@ irc_nick_print_log (struct t_irc_nick *nick)
weechat_log_printf (" prefix . . . . : '%s'", nick->prefix);
weechat_log_printf (" away . . . . . : %d", nick->away);
weechat_log_printf (" account. . . . : '%s'", nick->account);
+ weechat_log_printf (" realname . . . : '%s'", nick->realname);
weechat_log_printf (" color. . . . . : '%s'", nick->color);
weechat_log_printf (" prev_nick. . . : 0x%lx", nick->prev_nick);
weechat_log_printf (" next_nick. . . : 0x%lx", nick->next_nick);
diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h
index 3079a437b..d723db180 100644
--- a/src/plugins/irc/irc-nick.h
+++ b/src/plugins/irc/irc-nick.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -39,6 +39,7 @@ struct t_irc_nick
/* prefixes) */
int away; /* 1 if nick is away */
char *account; /* account name of the user */
+ char *realname; /* realname (aka gecos) of the user */
char *color; /* color for nickname */
struct t_irc_nick *prev_nick; /* link to previous nick on channel */
struct t_irc_nick *next_nick; /* link to next nick on channel */
@@ -66,7 +67,8 @@ extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
const char *host,
const char *prefixes,
int away,
- const char *account);
+ const char *account,
+ const char *realname);
extern void irc_nick_change (struct t_irc_server *server,
struct t_irc_channel *channel,
struct t_irc_nick *nick, const char *new_nick);
diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c
index cb9a2e590..2d39250ca 100644
--- a/src/plugins/irc/irc-notify.c
+++ b/src/plugins/irc/irc-notify.c
@@ -1,7 +1,7 @@
/*
* irc-notify.c - notify lists for IRC plugin
*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-notify.h b/src/plugins/irc/irc-notify.h
index 19c310dba..63bd96347 100644
--- a/src/plugins/irc/irc-notify.h
+++ b/src/plugins/irc/irc-notify.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index f3d7bff92..689a3c91f 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1,7 +1,7 @@
/*
* irc-protocol.c - implementation of IRC protocol (RFCs 1459/2810/2811/2812/2813)
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2014 Shawn Smith <ShawnSmith0828@gmail.com>
*
@@ -206,9 +206,12 @@ IRC_PROTOCOL_CALLBACK(account)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
+ char *pos_account;
IRC_PROTOCOL_MIN_ARGS(3);
+ pos_account = (strcmp (argv[2], "*") != 0) ? argv[2] : NULL;
+
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -217,8 +220,8 @@ IRC_PROTOCOL_CALLBACK(account)
{
if (ptr_nick->account)
free (ptr_nick->account);
- ptr_nick->account = (server->cap_account_notify) ?
- strdup (argv[2]) : strdup ("*");
+ ptr_nick->account = (server->cap_account_notify && pos_account) ?
+ strdup (pos_account) : NULL;
}
}
@@ -337,11 +340,11 @@ IRC_PROTOCOL_CALLBACK(away)
IRC_PROTOCOL_CALLBACK(cap)
{
- char *ptr_caps, **caps_supported, **caps_requested, *cap_option, *cap_req;
- char str_msg_auth[512];
+ char *ptr_caps, **caps_supported, **caps_requested, **caps_added;
+ char **caps_removed, *cap_option, *cap_req, str_msg_auth[512];
const char *ptr_cap_option;
- int num_caps_supported, num_caps_requested;
- int sasl_requested, sasl_to_do, sasl_mechanism;
+ int num_caps_supported, num_caps_requested, num_caps_added;
+ int num_caps_removed, sasl_requested, sasl_to_do, sasl_mechanism;
int i, j, timeout, length;
IRC_PROTOCOL_MIN_ARGS(4);
@@ -363,9 +366,11 @@ IRC_PROTOCOL_CALLBACK(cap)
{
sasl_requested = irc_server_sasl_enabled (server);
sasl_to_do = 0;
- ptr_cap_option = IRC_SERVER_OPTION_STRING(server,
- IRC_SERVER_OPTION_CAPABILITIES);
- length = ((ptr_cap_option && ptr_cap_option[0]) ? strlen (ptr_cap_option) : 0) + 16;
+ ptr_cap_option = IRC_SERVER_OPTION_STRING(
+ server,
+ IRC_SERVER_OPTION_CAPABILITIES);
+ length = ((ptr_cap_option && ptr_cap_option[0]) ?
+ strlen (ptr_cap_option) : 0) + 16;
cap_option = malloc (length);
cap_req = malloc (length);
if (cap_option && cap_req)
@@ -473,6 +478,10 @@ IRC_PROTOCOL_CALLBACK(cap)
{
server->cap_account_notify = 1;
}
+ else if (strcmp (caps_supported[i], "extended-join") == 0)
+ {
+ server->cap_extended_join = 1;
+ }
}
weechat_string_free_split (caps_supported);
}
@@ -514,6 +523,103 @@ IRC_PROTOCOL_CALLBACK(cap)
irc_server_sendf (server, 0, NULL, "CAP END");
}
}
+ else if (strcmp (argv[3], "NEW") == 0)
+ {
+ if (argc > 4)
+ {
+ ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];
+ weechat_printf_date_tags (
+ server->buffer, date, NULL,
+ _("%s%s: client capability, now available: %s"),
+ weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
+
+ /*
+ * assume that we're not requesting any already-enabled
+ * capabilities
+ * TODO: SASL Reauthentication
+ */
+ ptr_cap_option = IRC_SERVER_OPTION_STRING(
+ server,
+ IRC_SERVER_OPTION_CAPABILITIES);
+ length = ((ptr_cap_option && ptr_cap_option[0]) ?
+ strlen (ptr_cap_option) : 0) + 16;
+ cap_option = malloc (length);
+ cap_req = malloc (length);
+ if (cap_option && cap_req)
+ {
+ cap_option[0] = '\0';
+ if (ptr_cap_option && ptr_cap_option[0])
+ strcat (cap_option, ptr_cap_option);
+ cap_req[0] = '\0';
+ caps_requested = weechat_string_split (cap_option, ",", 0, 0,
+ &num_caps_requested);
+ caps_added = weechat_string_split (ptr_caps, " ", 0, 0,
+ &num_caps_added);
+ if (caps_requested && caps_added)
+ {
+ for (i = 0; i < num_caps_requested; i++)
+ {
+ for (j = 0; j < num_caps_added; j++)
+ {
+ if (weechat_strcasecmp (caps_requested[i],
+ caps_added[j]) == 0)
+ {
+ if (cap_req[0])
+ strcat (cap_req, " ");
+ strcat (cap_req, caps_added[j]);
+ }
+ }
+ }
+ }
+ if (caps_requested)
+ weechat_string_free_split (caps_requested);
+ if (caps_added)
+ weechat_string_free_split (caps_added);
+ if (cap_req[0])
+ {
+ weechat_printf (
+ server->buffer,
+ _("%s%s: client capability, requesting: %s"),
+ weechat_prefix ("network"), IRC_PLUGIN_NAME,
+ cap_req);
+ irc_server_sendf (server, 0, NULL,
+ "CAP REQ :%s", cap_req);
+ }
+ }
+ if (cap_option)
+ free (cap_option);
+ if (cap_req)
+ free (cap_req);
+ }
+ }
+ else if (strcmp (argv[3], "DEL") == 0)
+ {
+ if (argc > 4)
+ {
+ ptr_caps = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4];
+ weechat_printf_date_tags (
+ server->buffer, date, NULL,
+ _("%s%s: client capability, removed: %s"),
+ weechat_prefix ("network"), IRC_PLUGIN_NAME, ptr_caps);
+ caps_removed = weechat_string_split (ptr_caps, " ", 0, 0,
+ &num_caps_removed);
+ if (caps_removed)
+ {
+ for (i = 0; i < num_caps_removed; i++)
+ {
+ if (strcmp (caps_removed[i], "away-notify") == 0)
+ {
+ server->cap_away_notify = 0;
+ }
+ else if (strcmp (caps_removed[i], "account-notify") == 0)
+ {
+ server->cap_account_notify = 0;
+ }
+ }
+ weechat_string_free_split (caps_removed);
+ }
+ }
+ }
return WEECHAT_RC_OK;
}
@@ -648,7 +754,7 @@ IRC_PROTOCOL_CALLBACK(invite)
*
* With extended-join capability:
* :nick!user@host JOIN :#channel * :real name
- * *nick!user@host JOIN :#channel account :real name
+ * :nick!user@host JOIN :#channel account :real name
*/
IRC_PROTOCOL_CALLBACK(join)
@@ -743,7 +849,8 @@ IRC_PROTOCOL_CALLBACK(join)
/* add nick in channel */
ptr_nick = irc_nick_new (server, ptr_channel, nick, address, NULL, 0,
- (pos_account) ? pos_account : "*");
+ (pos_account) ? pos_account : NULL,
+ (pos_realname) ? pos_realname : NULL);
/* rename the nick if it was in list with a different case */
irc_channel_nick_speaking_rename_if_present (server, ptr_channel, nick);
@@ -1179,7 +1286,7 @@ IRC_PROTOCOL_CALLBACK(nick)
/* temporary disable hotlist */
weechat_buffer_set (NULL, "hotlist", "-");
- /* set host for nick if needed */
+ /* set host in nick if needed */
if (!ptr_nick->host)
ptr_nick->host = strdup (address);
@@ -4068,7 +4175,7 @@ IRC_PROTOCOL_CALLBACK(352)
ptr_nick = (ptr_channel) ?
irc_nick_search (server, ptr_channel, argv[7]) : NULL;
- /* update host for nick */
+ /* update host in nick */
if (ptr_nick)
{
if (ptr_nick->host)
@@ -4079,13 +4186,22 @@ IRC_PROTOCOL_CALLBACK(352)
snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]);
}
- /* update away flag for nick */
+ /* update away flag in nick */
if (ptr_channel && ptr_nick && pos_attr)
{
irc_nick_set_away (server, ptr_channel, ptr_nick,
(pos_attr[0] == 'G') ? 1 : 0);
}
+ /* update realname in nick */
+ if (ptr_channel && ptr_nick && pos_realname)
+ {
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (pos_realname && server->cap_extended_join) ?
+ strdup (pos_realname) : NULL;
+ }
+
/* display output of who (manual who from user) */
if (!ptr_channel || (ptr_channel->checking_whox <= 0))
{
@@ -4196,7 +4312,7 @@ IRC_PROTOCOL_CALLBACK(353)
if (ptr_channel && ptr_channel->nicks)
{
if (!irc_nick_new (server, ptr_channel, nickname, pos_host,
- prefixes, 0, "*"))
+ prefixes, 0, NULL, NULL))
{
weechat_printf (
server->buffer,
@@ -4291,7 +4407,7 @@ IRC_PROTOCOL_CALLBACK(354)
ptr_nick = (ptr_channel) ?
irc_nick_search (server, ptr_channel, argv[7]) : NULL;
- /* update host for nick */
+ /* update host in nick */
if (ptr_nick)
{
if (ptr_nick->host)
@@ -4305,7 +4421,7 @@ IRC_PROTOCOL_CALLBACK(354)
snprintf (ptr_nick->host, length, "%s@%s", argv[4], argv[5]);
}
- /* update away flag for nick */
+ /* update away flag in nick */
if (ptr_channel && ptr_nick)
{
if (pos_attr
@@ -4326,14 +4442,24 @@ IRC_PROTOCOL_CALLBACK(354)
}
}
- /* update account flag for nick */
+ /* update account flag in nick */
if (ptr_nick)
{
if (ptr_nick->account)
free (ptr_nick->account);
ptr_nick->account = (ptr_channel && pos_account
&& server->cap_account_notify) ?
- strdup (pos_account) : strdup ("*");
+ strdup (pos_account) : NULL;
+ }
+
+ /* update realname in nick */
+ if (ptr_nick)
+ {
+ if (ptr_nick->realname)
+ free (ptr_nick->realname);
+ ptr_nick->realname = (ptr_channel && pos_realname
+ && server->cap_extended_join) ?
+ strdup (pos_realname) : NULL;
}
/* display output of who (manual who from user) */
@@ -4912,6 +5038,74 @@ IRC_PROTOCOL_CALLBACK(438)
}
/*
+ * Callback for the IRC message "470": forwarding to another channel.
+ *
+ * Message looks like:
+ * :server 470 mynick #channel ##channel :Forwarding to another channel
+ */
+
+IRC_PROTOCOL_CALLBACK(470)
+{
+ struct t_gui_buffer *ptr_buffer;
+ struct t_gui_lines *own_lines;
+ const char *buffer_name, *short_name, *localvar_channel;
+ int lines_count;
+
+ irc_protocol_cb_generic_error (server,
+ date, nick, address, host, command,
+ ignored, argc, argv, argv_eol);
+
+ if ((argc >= 5) && !irc_channel_search (server, argv[3]))
+ {
+ ptr_buffer = irc_channel_search_buffer (server,
+ IRC_CHANNEL_TYPE_CHANNEL,
+ argv[3]);
+ if (ptr_buffer)
+ {
+ short_name = weechat_buffer_get_string (ptr_buffer, "short_name");
+ localvar_channel = weechat_buffer_get_string (ptr_buffer,
+ "localvar_channel");
+ if (!short_name
+ || (localvar_channel
+ && (strcmp (localvar_channel, short_name) == 0)))
+ {
+ /*
+ * update the short_name only if it was not changed by the
+ * user
+ */
+ weechat_buffer_set (ptr_buffer, "short_name", argv[4]);
+ }
+ buffer_name = irc_buffer_build_name (server->name, argv[4]);
+ weechat_buffer_set (ptr_buffer, "name", buffer_name);
+ weechat_buffer_set (ptr_buffer, "localvar_set_channel", argv[4]);
+
+ /*
+ * check if logger backlog should be displayed for the new channel
+ * name: it is displayed only if the buffer is currently completely
+ * empty (no messages at all)
+ */
+ lines_count = 0;
+ own_lines = weechat_hdata_pointer (weechat_hdata_get ("buffer"),
+ ptr_buffer, "own_lines");
+ if (own_lines)
+ {
+ lines_count = weechat_hdata_integer (
+ weechat_hdata_get ("lines"),
+ own_lines, "lines_count");
+ }
+ if (lines_count == 0)
+ {
+ (void) weechat_hook_signal_send ("logger_backlog",
+ WEECHAT_HOOK_SIGNAL_POINTER,
+ ptr_buffer);
+ }
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Callback for the IRC message "728": quietlist.
*
* Message looks like:
@@ -5544,7 +5738,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
{ "464", /* password incorrect */ 1, 0, &irc_protocol_cb_generic_error },
{ "465", /* you are banned from this server */ 1, 0, &irc_protocol_cb_generic_error },
{ "467", /* channel key already set */ 1, 0, &irc_protocol_cb_generic_error },
- { "470", /* forwarding to another channel */ 1, 0, &irc_protocol_cb_generic_error },
+ { "470", /* forwarding to another channel */ 1, 0, &irc_protocol_cb_470 },
{ "471", /* channel is already full */ 1, 0, &irc_protocol_cb_generic_error },
{ "472", /* unknown mode char to me */ 1, 0, &irc_protocol_cb_generic_error },
{ "473", /* cannot join channel (invite only) */ 1, 0, &irc_protocol_cb_generic_error },
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index c1f88d0d5..186a0729b 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-raw.c b/src/plugins/irc/irc-raw.c
index 6518cac15..4e5155090 100644
--- a/src/plugins/irc/irc-raw.c
+++ b/src/plugins/irc/irc-raw.c
@@ -1,7 +1,7 @@
/*
* irc-raw.c - functions for IRC raw data messages
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-raw.h b/src/plugins/irc/irc-raw.h
index 82fc529b0..6d9b23d78 100644
--- a/src/plugins/irc/irc-raw.h
+++ b/src/plugins/irc/irc-raw.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c
index 576d6fd24..de1c71ee5 100644
--- a/src/plugins/irc/irc-redirect.c
+++ b/src/plugins/irc/irc-redirect.c
@@ -1,7 +1,7 @@
/*
* irc-redirect.c - redirection of IRC command output
*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-redirect.h b/src/plugins/irc/irc-redirect.h
index b78db090a..7fd841621 100644
--- a/src/plugins/irc/irc-redirect.h
+++ b/src/plugins/irc/irc-redirect.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2010-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-sasl.c b/src/plugins/irc/irc-sasl.c
index 623d12a27..f5bf4dd8b 100644
--- a/src/plugins/irc/irc-sasl.c
+++ b/src/plugins/irc/irc-sasl.c
@@ -1,7 +1,7 @@
/*
* irc-sasl.c - SASL authentication with IRC server
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-sasl.h b/src/plugins/irc/irc-sasl.h
index 2677f5247..d3b61ddd9 100644
--- a/src/plugins/irc/irc-sasl.h
+++ b/src/plugins/irc/irc-sasl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index f5824660c..6c081e3a0 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -1,7 +1,7 @@
/*
* irc-server.c - I/O communication with IRC servers
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2010 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2012 Simon Arlott
*
@@ -96,6 +96,7 @@ char *irc_server_options[IRC_SERVER_NUM_OPTIONS][2] =
{ "autoreconnect", "on" },
{ "autoreconnect_delay", "10" },
{ "nicks", "" },
+ { "nicks_alternate", "on" },
{ "username", "" },
{ "realname", "" },
{ "local_hostname", "" },
@@ -407,7 +408,7 @@ void
irc_server_set_addresses (struct t_irc_server *server, const char *addresses)
{
int i;
- char *pos, *error;
+ char *pos, *error, *addresses_eval;
long number;
/* free data */
@@ -431,8 +432,11 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses)
/* set new addresses/ports */
if (addresses && addresses[0])
{
+ addresses_eval = weechat_string_eval_expression (addresses,
+ NULL, NULL, NULL);
server->addresses_array = weechat_string_split (
- addresses, ",", 0, 0, &server->addresses_count);
+ (addresses_eval) ? addresses_eval : addresses,
+ ",", 0, 0, &server->addresses_count);
server->ports_array = malloc (
server->addresses_count * sizeof (server->ports_array[0]));
server->retry_array = malloc (
@@ -455,6 +459,8 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses)
}
server->retry_array[i] = 0;
}
+ if (addresses_eval)
+ free (addresses_eval);
}
}
@@ -624,8 +630,8 @@ irc_server_get_alternate_nick (struct t_irc_server *server)
/* now we have tried all nicks in list */
- /* if alternate nick is disabled, just return NULL */
- if (!weechat_config_boolean (irc_config_network_alternate_nick))
+ /* if alternate nicks are disabled, just return NULL */
+ if (!IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE))
return NULL;
/* use main nick and we will add "_" and then number if needed */
@@ -1011,6 +1017,7 @@ irc_server_alloc (const char *name)
new_server->nick_modes = NULL;
new_server->cap_away_notify = 0;
new_server->cap_account_notify = 0;
+ new_server->cap_extended_join = 0;
new_server->isupport = NULL;
new_server->prefix_modes = NULL;
new_server->prefix_chars = NULL;
@@ -1073,25 +1080,28 @@ irc_server_alloc (const char *name)
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
{
length = strlen (new_server->name) + 1 +
- strlen (irc_server_options[i][0]) + 1;
+ strlen (irc_server_options[i][0]) +
+ 512 + /* inherited option name (irc.server_default.xxx) */
+ 1;
option_name = malloc (length);
if (option_name)
{
- snprintf (option_name, length, "%s.%s",
+ snprintf (option_name, length, "%s.%s << irc.server_default.%s",
new_server->name,
+ irc_server_options[i][0],
irc_server_options[i][0]);
- new_server->options[i] =
- irc_config_server_new_option (irc_config_file,
- irc_config_section_server,
- i,
- option_name,
- NULL,
- NULL,
- 1,
- &irc_config_server_check_value_cb,
- irc_server_options[i][0],
- &irc_config_server_change_cb,
- irc_server_options[i][0]);
+ new_server->options[i] = irc_config_server_new_option (
+ irc_config_file,
+ irc_config_section_server,
+ i,
+ option_name,
+ NULL,
+ NULL,
+ 1,
+ &irc_config_server_check_value_cb,
+ irc_server_options[i][0],
+ &irc_config_server_change_cb,
+ irc_server_options[i][0]);
irc_config_server_change_cb (irc_server_options[i][0],
new_server->options[i]);
free (option_name);
@@ -3328,7 +3338,13 @@ irc_server_login (struct t_irc_server *server)
server, IRC_SERVER_OPTION_CAPABILITIES);
if (password && password[0])
- irc_server_sendf (server, 0, NULL, "PASS %s", password);
+ {
+ irc_server_sendf (
+ server, 0, NULL,
+ "PASS %s%s",
+ ((password[0] == ':') || (strchr (password, ' '))) ? ":" : "",
+ password);
+ }
if (!server->nick)
{
@@ -4678,6 +4694,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address,
}
server->cap_away_notify = 0;
server->cap_account_notify = 0;
+ server->cap_extended_join = 0;
server->is_away = 0;
server->away_time = 0;
server->lag = 0;
@@ -5261,6 +5278,7 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name)
WEECHAT_HDATA_VAR(struct t_irc_server, nick_modes, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, cap_away_notify, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, cap_account_notify, INTEGER, 0, NULL, NULL);
+ WEECHAT_HDATA_VAR(struct t_irc_server, cap_extended_join, INTEGER, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, isupport, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_modes, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_irc_server, prefix_chars, STRING, 0, NULL, NULL);
@@ -5402,6 +5420,9 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
if (!weechat_infolist_new_var_string (ptr_item, "nicks",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS)))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "nicks_alternate",
+ IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_NICKS_ALTERNATE)))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "username",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME)))
return 0;
@@ -5480,6 +5501,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "cap_account_notify", server->cap_account_notify))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "cap_extended_join", server->cap_extended_join))
+ return 0;
if (!weechat_infolist_new_var_string (ptr_item, "isupport", server->isupport))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "prefix_modes", server->prefix_modes))
@@ -5573,7 +5596,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" ipv6 . . . . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6])) ?
"on" : "off");
/* ssl */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL]))
@@ -5582,7 +5605,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" ssl. . . . . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL])) ?
"on" : "off");
/* ssl_cert */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_SSL_CERT]))
@@ -5619,7 +5642,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" ssl_verify . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_SSL_VERIFY])) ?
"on" : "off");
/* password */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_PASSWORD]))
@@ -5673,7 +5696,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" autoconnect. . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOCONNECT])) ?
"on" : "off");
/* autoreconnect */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
@@ -5682,7 +5705,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" autoreconnect. . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT])) ?
"on" : "off");
/* autoreconnect_delay */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
@@ -5698,6 +5721,15 @@ irc_server_print_log ()
else
weechat_log_printf (" nicks. . . . . . . . : '%s'",
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_NICKS]));
+ /* nicks_alternate */
+ if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE]))
+ weechat_log_printf (" nicks_alternate. . . : null (%s)",
+ (IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_NICKS_ALTERNATE)) ?
+ "on" : "off");
+ else
+ weechat_log_printf (" nicks_alternate. . . : %s",
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_NICKS_ALTERNATE])) ?
+ "on" : "off");
/* username */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_log_printf (" username . . . . . . : null ('%s')",
@@ -5745,7 +5777,7 @@ irc_server_print_log ()
"on" : "off");
else
weechat_log_printf (" autorejoin . . . . . : %s",
- weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
+ (weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN])) ?
"on" : "off");
/* autorejoin_delay */
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))
@@ -5843,6 +5875,7 @@ irc_server_print_log ()
weechat_log_printf (" nick_modes . . . . . : '%s'", ptr_server->nick_modes);
weechat_log_printf (" cap_away_notify. . . : %d", ptr_server->cap_away_notify);
weechat_log_printf (" cap_account_notify . : %d", ptr_server->cap_account_notify);
+ weechat_log_printf (" cap_extended_join. . : %d", ptr_server->cap_extended_join);
weechat_log_printf (" isupport . . . . . . : '%s'", ptr_server->isupport);
weechat_log_printf (" prefix_modes . . . . : '%s'", ptr_server->prefix_modes);
weechat_log_printf (" prefix_chars . . . . : '%s'", ptr_server->prefix_chars);
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index dd650c325..8ba3d96e6 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Simon Arlott
*
* This file is part of WeeChat, the extensible chat client.
@@ -64,6 +64,7 @@ enum t_irc_server_option
IRC_SERVER_OPTION_AUTORECONNECT, /* autoreconnect when disconnected */
IRC_SERVER_OPTION_AUTORECONNECT_DELAY, /* delay before trying again reco */
IRC_SERVER_OPTION_NICKS, /* nicknames (comma separated list) */
+ IRC_SERVER_OPTION_NICKS_ALTERNATE, /* use alternate nicknames */
IRC_SERVER_OPTION_USERNAME, /* user name */
IRC_SERVER_OPTION_REALNAME, /* real name */
IRC_SERVER_OPTION_LOCAL_HOSTNAME,/* custom local hostname */
@@ -186,6 +187,7 @@ struct t_irc_server
char *nick_modes; /* nick modes */
int cap_away_notify; /* 1 if capability away-notify is enabled*/
int cap_account_notify; /* 1 if CAP account-notify is enabled */
+ int cap_extended_join; /* 1 if CAP extended-join is enabled */
char *isupport; /* copy of message 005 (ISUPPORT) */
char *prefix_modes; /* prefix modes from msg 005 (eg "ohv") */
char *prefix_chars; /* prefix chars from msg 005 (eg "@%+") */
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index 08a7f023d..458bf0204 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -1,7 +1,7 @@
/*
* irc-upgrade.c - save/restore IRC plugin data when upgrading WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -373,6 +373,7 @@ irc_upgrade_read_cb (void *data,
irc_upgrade_current_server->nick_modes = strdup (str);
irc_upgrade_current_server->cap_away_notify = weechat_infolist_integer (infolist, "cap_away_notify");
irc_upgrade_current_server->cap_account_notify = weechat_infolist_integer (infolist, "cap_account_notify");
+ irc_upgrade_current_server->cap_extended_join = weechat_infolist_integer (infolist, "cap_extended_join");
str = weechat_infolist_string (infolist, "isupport");
if (str)
irc_upgrade_current_server->isupport = strdup (str);
@@ -574,7 +575,8 @@ irc_upgrade_read_cb (void *data,
weechat_infolist_string (infolist, "host"),
weechat_infolist_string (infolist, "prefixes"),
weechat_infolist_integer (infolist, "away"),
- weechat_infolist_string (infolist, "account"));
+ weechat_infolist_string (infolist, "account"),
+ weechat_infolist_string (infolist, "realname"));
if (ptr_nick)
{
/*
diff --git a/src/plugins/irc/irc-upgrade.h b/src/plugins/irc/irc-upgrade.h
index 17da632cd..0c9ab8730 100644
--- a/src/plugins/irc/irc-upgrade.h
+++ b/src/plugins/irc/irc-upgrade.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index 9222d3f88..934df21ce 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -1,7 +1,7 @@
/*
* irc.c - IRC (Internet Relay Chat) plugin for WeeChat
*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index 1ee4d538b..3e4cce9f2 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2015 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2016 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.