diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-09-17 14:47:36 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-09-17 14:47:36 +0200 |
commit | d2d60d47110f49c3f4bb34c539da87222b76b9d4 (patch) | |
tree | 8943fca087668f8883ab2d77bddc05cb40f6a88d /src/plugins/irc | |
parent | 26a99c2912a30e994117bae5e042e60b2c229a26 (diff) | |
download | weechat-d2d60d47110f49c3f4bb34c539da87222b76b9d4.zip |
Beta version of IRC proxy feature in Relay plugin
Major changes in Relay plugin:
- IRC proxy feature (beta),
- raw buffer.
Changes in IRC plugin:
- add tags for messages sent to servers,
- add signal "irc_input_send" to simulate text/command on an IRC buffer,
- add prefix in infolist "irc_nick".
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 259 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-info.c | 5 | ||||
-rw-r--r-- | src/plugins/irc/irc-input.c | 173 | ||||
-rw-r--r-- | src/plugins/irc/irc-input.h | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 112 | ||||
-rw-r--r-- | src/plugins/irc/irc-raw.c | 47 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 164 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 16 | ||||
-rw-r--r-- | src/plugins/irc/irc-upgrade.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc.c | 2 |
15 files changed, 562 insertions, 236 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 8b03cb291..e1708ef71 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -373,7 +373,7 @@ irc_channel_check_away (struct t_irc_server *server, || (channel->nicks_count <= weechat_config_integer (irc_config_network_away_check_max_nicks)))) { channel->checking_away++; - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "WHO %s", channel->name); } else diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 3d6c786b0..b8db9e36b 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -74,7 +74,8 @@ irc_command_mode_nicks (struct t_irc_server *server, const char *channel, strcat (command, " "); strcat (command, argv[i]); } - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, "%s", command); + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, + "%s", command); free (command); } } @@ -96,11 +97,14 @@ irc_command_admin (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "ADMIN %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "ADMIN"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "ADMIN"); + } return WEECHAT_RC_OK; } @@ -339,7 +343,7 @@ irc_command_me_channel (struct t_irc_server *server, { char *string; - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01ACTION %s\01", channel->name, (arguments && arguments[0]) ? arguments : ""); @@ -401,7 +405,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, { server->is_away = 1; server->away_time = time (NULL); - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "AWAY :%s", arguments); if (weechat_config_integer (irc_config_look_display_away) != IRC_CONFIG_DISPLAY_AWAY_OFF) { @@ -464,7 +468,8 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, /* if server is connected, send away command now */ if (server->is_connected) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "AWAY"); + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "AWAY"); server->is_away = 0; if (server->away_time != 0) { @@ -630,7 +635,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, /* loop on users */ while (argv[pos_args]) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s +b %s", pos_channel, argv[pos_args]); pos_args++; @@ -646,7 +651,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, weechat_prefix ("error"), IRC_PLUGIN_NAME, "ban"); return WEECHAT_RC_OK; } - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s +b", ptr_channel->name); } @@ -851,7 +856,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc, gettimeofday (&tv, NULL); snprintf (str_time, sizeof (str_time), "%ld %ld", tv.tv_sec, tv.tv_usec); - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01PING %s\01", argv[1], str_time); weechat_printf (ptr_server->buffer, @@ -868,7 +873,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc, } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01%s%s%s\01", argv[1], irc_cmd, @@ -984,14 +989,14 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc, { version = weechat_info_get ("version", ""); buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : ""); - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PART %s :%s", channel_name, (buf) ? buf : ptr_arg); if (buf) free (buf); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PART %s", channel_name); return WEECHAT_RC_OK; @@ -1129,7 +1134,7 @@ irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc, { if (argc < 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s -h %s", ptr_channel->name, ptr_server->nick); @@ -1170,7 +1175,7 @@ irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc, { if (argc < 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s -o %s", ptr_channel->name, ptr_server->nick); @@ -1211,7 +1216,7 @@ irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc, { if (argc < 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s -v %s", ptr_channel->name, ptr_server->nick); @@ -1250,7 +1255,7 @@ irc_command_die (void *data, struct t_gui_buffer *buffer, int argc, (void) argv; (void) argv_eol; - irc_server_sendf (ptr_server, 0, "DIE"); + irc_server_sendf (ptr_server, 0, NULL, "DIE"); return WEECHAT_RC_OK; } @@ -1280,13 +1285,13 @@ irc_command_quit_server (struct t_irc_server *server, const char *arguments) version = weechat_info_get ("version", ""); buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : ""); - irc_server_sendf (server, 0, "QUIT :%s", + irc_server_sendf (server, 0, NULL, "QUIT :%s", (buf) ? buf : ptr_arg); if (buf) free (buf); } else - irc_server_sendf (server, 0, "QUIT"); + irc_server_sendf (server, 0, NULL, "QUIT"); } } @@ -1406,7 +1411,7 @@ irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc, { if (argc < 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s +h %s", ptr_channel->name, ptr_server->nick); @@ -1633,12 +1638,12 @@ irc_command_info (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "INFO %s", argv_eol[1]); } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "INFO"); } @@ -1662,14 +1667,14 @@ irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "INVITE %s %s", argv[1], argv[2]); } else { if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "INVITE %s %s", argv[1], ptr_channel->name); } @@ -1705,7 +1710,7 @@ irc_command_ison (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "ISON %s", argv_eol[1]); } else @@ -1725,12 +1730,12 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments) { if (irc_channel_is_channel (arguments)) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "JOIN %s", arguments); } else { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "JOIN #%s", arguments); } } @@ -1822,13 +1827,13 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc, if (pos_comment) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "KICK %s %s :%s", pos_channel, pos_nick, pos_comment); } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "KICK %s %s", pos_channel, pos_nick); } @@ -1923,7 +1928,8 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc, pos = strchr (pos_nick, '!'); snprintf (mask, length, "*!%s", (pos) ? pos + 1 : pos_nick); - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s +b %s", pos_channel, mask); free (mask); @@ -1931,13 +1937,14 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc, } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s +b %s", pos_channel, pos_nick); } /* kick nick */ - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "KICK %s %s%s%s", pos_channel, nick_only, @@ -1970,7 +1977,7 @@ irc_command_kill (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "KILL %s :%s", argv[1], argv_eol[2]); } else @@ -1999,11 +2006,14 @@ irc_command_links (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "LINKS %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "LINKS"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "LINKS"); + } return WEECHAT_RC_OK; } @@ -2057,7 +2067,8 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, } if (!ptr_channel_name && !ptr_server_name && !ptr_regex) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "LIST"); + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "LIST"); } else { @@ -2088,7 +2099,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, return WEECHAT_RC_OK; } } - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "LIST%s%s%s%s", (ptr_channel_name) ? " " : "", (ptr_channel_name) ? ptr_channel_name : "", @@ -2097,7 +2108,10 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, } } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "LIST"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "LIST"); + } return WEECHAT_RC_OK; } @@ -2119,11 +2133,14 @@ irc_command_lusers (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "LUSERS %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "LUSERS"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "LUSERS"); + } return WEECHAT_RC_OK; } @@ -2145,11 +2162,14 @@ irc_command_map (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MAP %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "MAP"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "MAP"); + } return WEECHAT_RC_OK; } @@ -2195,13 +2215,13 @@ irc_command_mode_server (struct t_irc_server *server, { if (channel && arguments) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "MODE %s %s", channel->name, arguments); } else { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "MODE %s", (channel) ? channel->name : arguments); } @@ -2269,11 +2289,14 @@ irc_command_motd (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MOTD %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "MOTD"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "MOTD"); + } return WEECHAT_RC_OK; } @@ -2347,7 +2370,8 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, if (string) free (string); - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :%s", ptr_channel->name, argv_eol[arg_text]); } @@ -2371,7 +2395,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, free (string); } irc_server_sendf (ptr_server, - IRC_SERVER_OUTQUEUE_PRIO_HIGH, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :%s", targets[i], argv_eol[arg_text]); } @@ -2430,7 +2454,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, free (string); } irc_server_sendf (ptr_server, - IRC_SERVER_OUTQUEUE_PRIO_HIGH, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :%s", targets[i], argv_eol[arg_text]); } @@ -2459,14 +2483,14 @@ irc_command_names (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "NAMES %s", argv_eol[1]); } else { if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "NAMES %s", ptr_channel->name); } else @@ -2495,7 +2519,7 @@ irc_send_nick_server (struct t_irc_server *server, const char *nickname) if (server->is_connected) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "NICK %s", nickname); } else @@ -2579,9 +2603,11 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc, weechat_config_boolean (irc_config_network_colors_receive)); ptr_channel = irc_channel_search (ptr_server, argv[arg_nick]); weechat_printf ((ptr_channel) ? ptr_channel->buffer : ptr_server->buffer, - "%s%sNotice%s -> %s%s%s: %s", + "%s%s%s%s -> %s%s%s: %s", weechat_prefix ("network"), IRC_COLOR_NOTICE, + /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ + _("Notice"), IRC_COLOR_CHAT, (irc_channel_is_channel (argv[arg_nick])) ? IRC_COLOR_CHAT_CHANNEL : IRC_COLOR_CHAT_NICK, @@ -2590,7 +2616,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc, (string) ? string : argv_eol[arg_text]); if (string) free (string); - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "NOTICE %s :%s", argv[arg_nick], argv_eol[arg_text]); } @@ -2622,7 +2648,7 @@ irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv, { if (argc < 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s +o %s", ptr_channel->name, ptr_server->nick); @@ -2661,7 +2687,7 @@ irc_command_oper (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "OPER %s", argv_eol[1]); } else @@ -2693,7 +2719,8 @@ irc_command_part_channel (struct t_irc_server *server, const char *channel_name, { version = weechat_info_get ("version", ""); buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : ""); - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "PART %s :%s", + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "PART %s :%s", channel_name, (buf) ? buf : ptr_arg); if (buf) @@ -2701,7 +2728,7 @@ irc_command_part_channel (struct t_irc_server *server, const char *channel_name, } else { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PART %s", channel_name); } } @@ -2787,7 +2814,7 @@ irc_command_ping (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PING %s", argv_eol[1]); } else @@ -2815,7 +2842,7 @@ irc_command_pong (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PONG %s", argv_eol[1]); } else @@ -2883,7 +2910,7 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc, (string) ? string : argv_eol[arg_text]); if (string) free (string); - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :%s", argv[arg_nick], argv_eol[arg_text]); } @@ -2909,7 +2936,7 @@ irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc, /* make C compiler happy */ (void) data; - + if (argc > 1) { if ((argc >= 4) && (weechat_strcasecmp (argv[1], "-server") == 0)) @@ -2917,14 +2944,14 @@ irc_command_quote (void *data, struct t_gui_buffer *buffer, int argc, ptr_server = irc_server_search (argv[2]); if (!ptr_server || (ptr_server->sock < 0)) return WEECHAT_RC_ERROR; - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "%s", argv_eol[3]); } else { if (!ptr_server || (ptr_server->sock < 0)) return WEECHAT_RC_ERROR; - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "%s", argv_eol[1]); } } @@ -3065,11 +3092,14 @@ irc_command_rehash (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "REHASH %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "REHASH"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "REHASH"); + } return WEECHAT_RC_OK; } @@ -3091,7 +3121,8 @@ irc_command_restart (void *data, struct t_gui_buffer *buffer, int argc, (void) argv; (void) argv_eol; - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "RESTART"); + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "RESTART"); return WEECHAT_RC_OK; } @@ -3112,7 +3143,7 @@ irc_command_sajoin (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SAJOIN %s %s", argv[1], argv_eol[2]); } else @@ -3139,7 +3170,7 @@ irc_command_samode (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SAMODE %s %s", argv[1], argv_eol[2]); } else @@ -3166,7 +3197,7 @@ irc_command_sanick (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SANICK %s %s", argv[1], argv_eol[2]); } else @@ -3193,7 +3224,7 @@ irc_command_sapart (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SAPART %s %s", argv[1], argv_eol[2]); } else @@ -3220,7 +3251,7 @@ irc_command_saquit (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SAQUIT %s :%s", argv[1], argv_eol[2]); } else @@ -3596,7 +3627,7 @@ irc_command_service (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SERVICE %s", argv_eol[1]); } else @@ -3624,12 +3655,12 @@ irc_command_servlist (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SERVLIST %s", argv_eol[1]); } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SERVLIST"); } @@ -3654,12 +3685,12 @@ irc_command_squery (void *data, struct t_gui_buffer *buffer, int argc, { if (argc > 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SQUERY %s :%s", argv[1], argv_eol[2]); } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SQUERY %s", argv_eol[1]); } } @@ -3687,7 +3718,7 @@ irc_command_squit (void *data, struct t_gui_buffer *buffer, int argc, (void) argv; if (argc > 1) - irc_server_sendf (ptr_server, 0, "SQUIT %s", argv_eol[1]); + irc_server_sendf (ptr_server, 0, NULL, "SQUIT %s", argv_eol[1]); else { IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "squit"); @@ -3713,11 +3744,14 @@ irc_command_stats (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "STATS %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "STATS"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "STATS"); + } return WEECHAT_RC_OK; } @@ -3740,7 +3774,7 @@ irc_command_summon (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "SUMMON %s", argv_eol[1]); } else @@ -3768,11 +3802,14 @@ irc_command_time (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "TIME %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "TIME"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "TIME"); + } return WEECHAT_RC_OK; } @@ -3827,13 +3864,13 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc, if (new_topic) { if (weechat_strcasecmp (new_topic, "-delete") == 0) - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "TOPIC %s :", channel_name); else { new_topic_color = irc_color_encode (new_topic, weechat_config_boolean (irc_config_network_colors_send)); - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "TOPIC %s :%s", channel_name, (new_topic_color) ? new_topic_color : new_topic); @@ -3842,7 +3879,7 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc, } } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "TOPIC %s", channel_name); return WEECHAT_RC_OK; @@ -3865,11 +3902,14 @@ irc_command_trace (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "TRACE %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "TRACE"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "TRACE"); + } return WEECHAT_RC_OK; } @@ -3924,7 +3964,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc, /* loop on users */ while (argv[pos_args]) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s -b %s", pos_channel, argv[pos_args]); pos_args++; @@ -3958,7 +3998,7 @@ irc_command_userhost (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "USERHOST %s", argv_eol[1]); } else @@ -3986,11 +4026,14 @@ irc_command_users (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "USERS %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "USERS"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "USERS"); + } return WEECHAT_RC_OK; } @@ -4016,18 +4059,18 @@ irc_command_version (void *data, struct t_gui_buffer *buffer, int argc, if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) && irc_nick_search (ptr_channel, argv[1])) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01VERSION\01", argv[1]); } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "VERSION %s", argv[1]); } } else { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "VERSION"); } @@ -4053,7 +4096,7 @@ irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc, { if (argc < 2) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "MODE %s +v %s", ptr_channel->name, ptr_server->nick); @@ -4133,9 +4176,11 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc, } weechat_printf (ptr_channel->buffer, - "%s%sNoticeOp%s -> %s%s%s: %s", + "%s%s%sOp%s -> %s%s%s: %s", weechat_prefix ("network"), IRC_COLOR_NOTICE, + /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ + _("Notice"), IRC_COLOR_CHAT, IRC_COLOR_CHAT_CHANNEL, ptr_channel->name, @@ -4153,7 +4198,7 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc, * if WALLCHOPS is supported, or if STATUSMSG includes '@', * then send a notice to @#channel */ - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "NOTICE @%s :%s", ptr_channel->name, argv_eol[pos_args]); } @@ -4169,7 +4214,8 @@ irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc, if (IRC_NICK_IS_OP(ptr_nick) && (strcmp (ptr_nick->name, ptr_server->nick) != 0)) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (ptr_server, + IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "NOTICE %s :%s", ptr_nick->name, argv_eol[pos_args]); } @@ -4202,7 +4248,7 @@ irc_command_wallops (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "WALLOPS :%s", argv_eol[1]); } else @@ -4230,11 +4276,14 @@ irc_command_who (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "WHO %s", argv_eol[1]); } else - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, "WHO"); + { + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + "WHO"); + } return WEECHAT_RC_OK; } @@ -4256,7 +4305,7 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "WHOIS %s", argv_eol[1]); } else @@ -4264,7 +4313,7 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc, if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "WHOIS %s", ptr_channel->name); } else @@ -4293,7 +4342,7 @@ irc_command_whowas (void *data, struct t_gui_buffer *buffer, int argc, if (argc > 1) { - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "WHOWAS %s", argv_eol[1]); } else @@ -4687,7 +4736,7 @@ irc_command_init () N_("send raw data to server without parsing"), N_("[-server server] data"), N_("server: send to this server (internal name)\n" - "data: raw data to send"), + " data: raw data to send"), NULL, &irc_command_quote, NULL); weechat_hook_command ("reconnect", N_("reconnect to server(s)"), diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 3f2695567..61bf79b43 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -1705,8 +1705,8 @@ irc_config_init () irc_config_look_raw_messages = weechat_config_new_option ( irc_config_file, ptr_section, "raw_messages", "integer", - N_("number of IRC raw messages to save in memory when raw data buffer " - "is closed (messages will be displayed when opening raw data buffer)"), + N_("number of raw messages to save in memory when raw data buffer is " + "closed (messages will be displayed when opening raw data buffer)"), NULL, 0, 65535, "256", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_smart_filter = weechat_config_new_option ( irc_config_file, ptr_section, diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 26f264bb4..9aa12359f 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -249,7 +249,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server, const char *nick, const char *ctcp, const char *arguments) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "NOTICE %s :\01%s%s%s\01", nick, ctcp, (arguments) ? " " : "", diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index 3a6c8849a..0026954c0 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -407,7 +407,9 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name, if (pointer) { /* build list with only one nick */ - if (!irc_nick_add_to_infolist (ptr_infolist, pointer)) + if (!irc_nick_add_to_infolist (ptr_infolist, + ptr_server, + pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -421,6 +423,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name, ptr_nick = ptr_nick->next_nick) { if (!irc_nick_add_to_infolist (ptr_infolist, + ptr_server, ptr_nick)) { weechat_infolist_free (ptr_infolist); diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c index 71a190aeb..7f2e445d9 100644 --- a/src/plugins/irc/irc-input.c +++ b/src/plugins/irc/irc-input.c @@ -73,21 +73,22 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text) } /* - * irc_input_send_user_message: send a PRIVMSG message, and split it - * if > 512 bytes - * warning: this function makes temporarirly - * changes in "text" + * irc_input_send_user_message: send a PRIVMSG message, and split it it message + * size is > 512 bytes + * Warning: this function makes temporarirly + * changes in "message" */ void -irc_input_send_user_message (struct t_gui_buffer *buffer, char *text) +irc_input_send_user_message (struct t_gui_buffer *buffer, int flags, + const char *tags, char *message) { int max_length; char *pos, *pos_max, *last_space, *pos_next, *next, saved_char; IRC_BUFFER_GET_SERVER_CHANNEL(buffer); - if (!ptr_server || !ptr_channel || !text || !text[0]) + if (!ptr_server || !ptr_channel || !message || !message[0]) return; if (!ptr_server->is_connected) @@ -107,10 +108,10 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, char *text) if (max_length > 0) { - if ((int)strlen (text) > max_length) + if ((int)strlen (message) > max_length) { - pos = text; - pos_max = text + max_length; + pos = message; + pos_max = message + max_length; while (pos && pos[0]) { if (pos[0] == ' ') @@ -128,14 +129,14 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, char *text) } } - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, - "PRIVMSG %s :%s", ptr_channel->name, text); - irc_input_user_message_display (buffer, text); + irc_server_sendf (ptr_server, flags, tags, + "PRIVMSG %s :%s", ptr_channel->name, message); + irc_input_user_message_display (buffer, message); if (next) { next[0] = saved_char; - irc_input_send_user_message (buffer, next); + irc_input_send_user_message (buffer, flags, tags, next); } } @@ -170,7 +171,8 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer, && !weechat_string_input_for_buffer (input_data)) { if (ptr_server) - irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (ptr_server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, weechat_utf8_next_char (input_data)); return WEECHAT_RC_OK; } @@ -186,7 +188,10 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer, msg = strdup ((data_with_colors) ? data_with_colors : ptr_data); if (msg) { - irc_input_send_user_message (buffer, msg); + irc_input_send_user_message (buffer, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, + NULL, + msg); free (msg); } @@ -203,3 +208,141 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer, return WEECHAT_RC_OK; } + +/* + * irc_input_send_cb: callback for "irc_input_send" signal + * This signal can be used by other plugins/scripts, it + * simulates input or command from user on an IRC buffer + * (it is used for example by Relay plugin) + * Format of signal_data (string) is: + * "server;channel;flags;tags;text" + * - server: server name (required) + * - channel: channel name (optional) + * - flags: flags for irc_server_sendf() (optional) + * - tags: tags for irc_server_sendf() (optional) + * - text: text or command (required) + */ + +int +irc_input_send_cb (void *data, const char *signal, + const char *type_data, void *signal_data) +{ + const char *ptr_string, *ptr_message; + char *pos_semicol1, *pos_semicol2, *pos_semicol3, *pos_semicol4, *error; + char *server, *channel, *flags, *tags; + long flags_value; + char *data_with_colors; + struct t_irc_server *ptr_server; + struct t_irc_channel *ptr_channel; + struct t_gui_buffer *ptr_buffer; + + /* make C compiler happy */ + (void) data; + (void) signal; + (void) type_data; + + ptr_string = (const char *)signal_data; + + server = NULL; + channel = NULL; + flags = NULL; + tags = NULL; + ptr_message = NULL; + ptr_server = NULL; + ptr_channel = NULL; + + pos_semicol1 = strchr (ptr_string, ';'); + if (pos_semicol1) + { + if (pos_semicol1 > ptr_string + 1) + { + server = weechat_strndup (ptr_string, pos_semicol1 - ptr_string); + } + pos_semicol2 = strchr (pos_semicol1 + 1, ';'); + if (pos_semicol2) + { + if (pos_semicol2 > pos_semicol1 + 1) + { + channel = weechat_strndup (pos_semicol1 + 1, + pos_semicol2 - pos_semicol1 - 1); + } + pos_semicol3 = strchr (pos_semicol2 + 1, ';'); + if (pos_semicol3) + { + if (pos_semicol3 > pos_semicol2 + 1) + { + flags = weechat_strndup (pos_semicol2 + 1, + pos_semicol3 - pos_semicol2 - 1); + } + pos_semicol4 = strchr (pos_semicol3 + 1, ';'); + if (pos_semicol4) + { + if (pos_semicol4 > pos_semicol3 + 1) + { + tags = weechat_strndup (pos_semicol3 + 1, + pos_semicol4 - pos_semicol3 - 1); + } + ptr_message = pos_semicol4 + 1; + } + } + } + } + + flags_value = 0; + if (flags) + { + error = NULL; + flags_value = strtol (flags, &error, 10); + if (flags_value < 0) + flags_value = 0; + } + + if (server && ptr_message) + { + ptr_server = irc_server_search (server); + if (ptr_server) + { + ptr_buffer = ptr_server->buffer; + if (channel) + { + ptr_channel = irc_channel_search (ptr_server, channel); + if (ptr_channel) + ptr_buffer = ptr_channel->buffer; + } + + /* set tags to use by default */ + irc_server_set_send_default_tags (tags); + + /* send text to buffer, or execute command */ + if (weechat_string_input_for_buffer (ptr_message)) + { + /* text as input */ + irc_input_data_cb (NULL, ptr_buffer, ptr_message); + } + else + { + /* command */ + data_with_colors = irc_color_encode (ptr_message, + weechat_config_boolean (irc_config_network_colors_send)); + weechat_command (ptr_buffer, + (data_with_colors) ? data_with_colors : ptr_message); + if (data_with_colors) + free (data_with_colors); + } + + /* reset tags to use by default */ + irc_server_set_send_default_tags (NULL); + } + } + + if (server) + free (server); + if (channel) + free (channel); + if (flags) + free (flags); + if (tags) + free (tags); + + return WEECHAT_RC_OK; +} diff --git a/src/plugins/irc/irc-input.h b/src/plugins/irc/irc-input.h index 8a8dd61e4..b508a8149 100644 --- a/src/plugins/irc/irc-input.h +++ b/src/plugins/irc/irc-input.h @@ -26,5 +26,7 @@ extern void irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text); extern int irc_input_data_cb (void *data, struct t_gui_buffer *buffer, const char *input_data); +extern int irc_input_send_cb (void *data, const char *signal, + const char *type_data, void *signal_data); #endif /* __WEECHAT_IRC_INPUT_H */ diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index a9e5110af..c2540623c 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -741,9 +741,11 @@ irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname) int irc_nick_add_to_infolist (struct t_infolist *infolist, + struct t_irc_server *server, struct t_irc_nick *nick) { struct t_infolist_item *ptr_item; + char prefix[2]; if (!infolist || !nick) return 0; @@ -760,6 +762,11 @@ irc_nick_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color)) return 0; + prefix[0] = ' '; + prefix[1] = '\0'; + irc_nick_get_gui_infos (server, nick, prefix, NULL, NULL, NULL); + if (!weechat_infolist_new_var_string (ptr_item, "prefix", prefix)) + return 0; return 1; } diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index 1b05d85eb..9dffce6ea 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -114,6 +114,7 @@ extern char *irc_nick_as_prefix (struct t_irc_server *server, extern const char * irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname); extern int irc_nick_add_to_infolist (struct t_infolist *infolist, + struct t_irc_server *server, struct t_irc_nick *nick); extern void irc_nick_print_log (struct t_irc_nick *nick); diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index c13152912..884d1d6d5 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -310,7 +310,7 @@ IRC_PROTOCOL_CALLBACK(authenticate) } if (answer) { - irc_server_sendf (server, 0, "AUTHENTICATE %s", answer); + irc_server_sendf (server, 0, NULL, "AUTHENTICATE %s", answer); free (answer); } else @@ -320,7 +320,7 @@ IRC_PROTOCOL_CALLBACK(authenticate) "SASL authentication, using mechanism \"%s\""), weechat_prefix ("error"), IRC_PLUGIN_NAME, irc_sasl_mechanism_string[IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_MECHANISM)]); - irc_server_sendf (server, 0, "CAP END"); + irc_server_sendf (server, 0, NULL, "CAP END"); } } @@ -375,7 +375,7 @@ IRC_PROTOCOL_CALLBACK(cap) _("%s%s: client capability, requesting: sasl"), weechat_prefix ("network"), IRC_PLUGIN_NAME); - irc_server_sendf (server, 0, "CAP REQ :sasl"); + irc_server_sendf (server, 0, NULL, "CAP REQ :sasl"); } else { @@ -383,7 +383,7 @@ IRC_PROTOCOL_CALLBACK(cap) _("%s%s: client capability: sasl not supported"), weechat_prefix ("network"), IRC_PLUGIN_NAME); - irc_server_sendf (server, 0, "CAP END"); + irc_server_sendf (server, 0, NULL, "CAP END"); } } } @@ -403,7 +403,8 @@ IRC_PROTOCOL_CALLBACK(cap) { case IRC_SASL_MECHANISM_DH_BLOWFISH: #ifdef HAVE_GCRYPT - irc_server_sendf (server, 0, "AUTHENTICATE DH-BLOWFISH"); + irc_server_sendf (server, 0, NULL, + "AUTHENTICATE DH-BLOWFISH"); #else weechat_printf (server->buffer, _("%s%s: cannot authenticate with SASL " @@ -412,12 +413,13 @@ IRC_PROTOCOL_CALLBACK(cap) "libgcrypt support"), weechat_prefix ("error"), IRC_PLUGIN_NAME); - irc_server_sendf (server, 0, "CAP END"); + irc_server_sendf (server, 0, NULL, "CAP END"); #endif break; case IRC_SASL_MECHANISM_PLAIN: default: - irc_server_sendf (server, 0, "AUTHENTICATE PLAIN"); + irc_server_sendf (server, 0, NULL, + "AUTHENTICATE PLAIN"); break; } if (server->hook_timer_sasl) @@ -441,7 +443,7 @@ IRC_PROTOCOL_CALLBACK(cap) weechat_prefix ("error"), IRC_PLUGIN_NAME, ptr_caps); if (!server->is_connected) - irc_server_sendf (server, 0, "CAP END"); + irc_server_sendf (server, 0, NULL, "CAP END"); } } @@ -831,7 +833,7 @@ IRC_PROTOCOL_CALLBACK(mode) { if (irc_mode_channel_set (server, ptr_channel, pos_modes)) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "MODE %s", ptr_channel->name); } } @@ -1049,9 +1051,11 @@ IRC_PROTOCOL_CALLBACK(notice) ptr_nick = irc_nick_search (ptr_channel, nick); weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer, irc_protocol_tags (command, "notify_message"), - "%s%sNotice%s%s(%s%s%s)%s: %s", + "%s%s%s%s%s(%s%s%s)%s: %s", weechat_prefix ("network"), IRC_COLOR_NOTICE, + /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ + _("Notice"), (notice_op) ? "Op" : "", IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), @@ -1116,44 +1120,67 @@ IRC_PROTOCOL_CALLBACK(notice) ptr_buffer = irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL); - if (address && address[0]) + /* + * if notice is sent from myself (for example another WeeChat + * via relay), then display message of outgoing notice + */ + if (nick && strcmp (server->nick, nick) == 0) { weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, (notify_private) ? "notify_private" : NULL), - "%s%s%s %s(%s%s%s)%s: %s", + "%s%s%s%s -> %s%s%s: %s", weechat_prefix ("network"), + IRC_COLOR_NOTICE, + /* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */ + _("Notice"), + IRC_COLOR_CHAT, IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - address, - IRC_COLOR_CHAT_DELIMITERS, + pos_target, IRC_COLOR_CHAT, pos_args); } else { - if (nick && nick[0]) + if (address && address[0]) { weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, (notify_private) ? "notify_private" : NULL), - "%s%s%s%s: %s", + "%s%s%s %s(%s%s%s)%s: %s", weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + address, + IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, pos_args); } else { - weechat_printf_tags (ptr_buffer, - irc_protocol_tags (command, - (notify_private) ? "notify_private" : NULL), - "%s%s", - weechat_prefix ("network"), - pos_args); + if (nick && nick[0]) + { + weechat_printf_tags (ptr_buffer, + irc_protocol_tags (command, + (notify_private) ? "notify_private" : NULL), + "%s%s%s%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_args); + } + else + { + weechat_printf_tags (ptr_buffer, + irc_protocol_tags (command, + (notify_private) ? "notify_private" : NULL), + "%s%s", + weechat_prefix ("network"), + pos_args); + } } } } @@ -1322,7 +1349,7 @@ IRC_PROTOCOL_CALLBACK(ping) IRC_PROTOCOL_MIN_ARGS(2); - irc_server_sendf (server, 0, "PONG :%s", + irc_server_sendf (server, 0, NULL, "PONG :%s", (argv[1][0] == ':') ? argv[1] + 1 : argv[1]); return WEECHAT_RC_OK; @@ -1438,10 +1465,9 @@ IRC_PROTOCOL_CALLBACK(privmsg) } else { - if (strcmp (server->nick, nick) == 0) - remote_nick = argv[2]; - else - remote_nick = nick; + nick_is_me = (strcmp (server->nick, nick) == 0); + + remote_nick = (nick_is_me) ? argv[2] : nick; /* CTCP to user */ if ((pos_args[0] == '\01') @@ -1454,8 +1480,6 @@ IRC_PROTOCOL_CALLBACK(privmsg) } /* private message received => display it */ - nick_is_me = (strcmp (server->nick, nick) == 0); - ptr_channel = irc_channel_search (server, remote_nick); if (!ptr_channel) @@ -3844,7 +3868,7 @@ IRC_PROTOCOL_CALLBACK(432) irc_server_set_nick (server, server->nicks_array[nick_index]); - irc_server_sendf (server, 0, "NICK %s", server->nick); + irc_server_sendf (server, 0, NULL, "NICK %s", server->nick); } return WEECHAT_RC_OK; @@ -3895,7 +3919,7 @@ IRC_PROTOCOL_CALLBACK(433) irc_server_set_nick (server, server->nicks_array[nick_index]); - irc_server_sendf (server, 0, "NICK %s", server->nick); + irc_server_sendf (server, 0, NULL, "NICK %s", server->nick); } else { @@ -3960,7 +3984,7 @@ IRC_PROTOCOL_CALLBACK(437) irc_server_set_nick (server, server->nicks_array[nick_index]); - irc_server_sendf (server, 0, "NICK %s", server->nick); + irc_server_sendf (server, 0, NULL, "NICK %s", server->nick); } } @@ -4088,7 +4112,7 @@ IRC_PROTOCOL_CALLBACK(sasl_end) ignored, argc, argv, argv_eol); if (!server->is_connected) - irc_server_sendf (server, 0, "CAP END"); + irc_server_sendf (server, 0, NULL, "CAP END"); return WEECHAT_RC_OK; } @@ -4289,11 +4313,15 @@ irc_protocol_recv_command (struct t_irc_server *server, nick, host); /* send signal with received command, even if command is ignored */ - irc_server_send_signal (server, "irc_raw_in", msg_command, irc_message); + irc_server_send_signal (server, "irc_raw_in", msg_command, + irc_message, NULL); /* send signal with received command, only if message is not ignored */ if (!message_ignored) - irc_server_send_signal (server, "irc_in", msg_command, irc_message); + { + irc_server_send_signal (server, "irc_in", msg_command, + irc_message, NULL); + } /* look for IRC command */ cmd_found = -1; @@ -4369,11 +4397,15 @@ irc_protocol_recv_command (struct t_irc_server *server, /* send signal with received command (if message is not ignored) */ if (!message_ignored) - irc_server_send_signal (server, "irc_in2", msg_command, irc_message); + { + irc_server_send_signal (server, "irc_in2", msg_command, + irc_message, NULL); + } } /* send signal with received command, even if command is ignored */ - irc_server_send_signal (server, "irc_raw_in2", msg_command, irc_message); + irc_server_send_signal (server, "irc_raw_in2", msg_command, + irc_message, NULL); end: if (nick) diff --git a/src/plugins/irc/irc-raw.c b/src/plugins/irc/irc-raw.c index 2a8d91fff..d2e5764e4 100644 --- a/src/plugins/irc/irc-raw.c +++ b/src/plugins/irc/irc-raw.c @@ -67,9 +67,6 @@ void irc_raw_open (int switch_to_buffer) { struct t_irc_raw_message *ptr_raw_message; - int buffer_created; - - buffer_created = 0; if (!irc_raw_buffer) { @@ -80,30 +77,23 @@ irc_raw_open (int switch_to_buffer) irc_raw_buffer = weechat_buffer_new (IRC_RAW_BUFFER_NAME, &irc_input_data_cb, NULL, &irc_buffer_close_cb, NULL); - buffer_created = 1; /* failed to create buffer ? then return */ if (!irc_raw_buffer) return; - - if (buffer_created) - { - weechat_buffer_set (irc_raw_buffer, - "title", _("IRC raw messages")); - - weechat_buffer_set (irc_raw_buffer, "short_name", IRC_RAW_BUFFER_NAME); - weechat_buffer_set (irc_raw_buffer, "localvar_set_type", "debug"); - weechat_buffer_set (irc_raw_buffer, "localvar_set_server", IRC_RAW_BUFFER_NAME); - weechat_buffer_set (irc_raw_buffer, "localvar_set_channel", IRC_RAW_BUFFER_NAME); - weechat_buffer_set (irc_raw_buffer, "localvar_set_no_log", "1"); - - /* disable all highlights on this debug buffer */ - weechat_buffer_set (irc_raw_buffer, "highlight_words", "-"); - } - if (switch_to_buffer) - weechat_buffer_set (irc_raw_buffer, "display", "1"); + weechat_buffer_set (irc_raw_buffer, + "title", _("IRC raw messages")); + + weechat_buffer_set (irc_raw_buffer, "short_name", IRC_RAW_BUFFER_NAME); + weechat_buffer_set (irc_raw_buffer, "localvar_set_type", "debug"); + weechat_buffer_set (irc_raw_buffer, "localvar_set_server", IRC_RAW_BUFFER_NAME); + weechat_buffer_set (irc_raw_buffer, "localvar_set_channel", IRC_RAW_BUFFER_NAME); + weechat_buffer_set (irc_raw_buffer, "localvar_set_no_log", "1"); + /* disable all highlights on this buffer */ + weechat_buffer_set (irc_raw_buffer, "highlight_words", "-"); + /* print messages in list */ for (ptr_raw_message = irc_raw_messages; ptr_raw_message; ptr_raw_message = ptr_raw_message->next_message) @@ -112,11 +102,9 @@ irc_raw_open (int switch_to_buffer) } } } - else - { - if (switch_to_buffer) - weechat_buffer_set (irc_raw_buffer, "display", "1"); - } + + if (irc_raw_buffer && switch_to_buffer) + weechat_buffer_set (irc_raw_buffer, "display", "1"); } /* @@ -283,7 +271,7 @@ irc_raw_message_add (struct t_irc_server *server, int send, int modified, } /* - * irc_raw_print: print a message on IRC debug buffer + * irc_raw_print: print a message on IRC raw buffer */ void @@ -294,7 +282,8 @@ irc_raw_print (struct t_irc_server *server, int send, int modified, if (!message) return; - + + /* auto-open IRC raw buffer if debug for irc plugin is >= 1 */ if (!irc_raw_buffer && (weechat_irc_plugin->debug >= 1)) irc_raw_open (0); @@ -309,7 +298,7 @@ irc_raw_print (struct t_irc_server *server, int send, int modified, } /* - * irc_raw_add_to_infolist: add a raw messagt in an infolist + * irc_raw_add_to_infolist: add a raw message in an infolist * return 1 if ok, 0 if error */ diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index e449cb807..e929d321a 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -79,6 +79,9 @@ char *irc_server_option_default[IRC_SERVER_NUM_OPTIONS] = "", "0", "", "off", "30", }; +const char *irc_server_send_default_tags = NULL; /* default tags when */ + /* sending a message */ + void irc_server_reconnect (struct t_irc_server *server); void irc_server_free_data (struct t_irc_server *server); @@ -730,7 +733,7 @@ irc_server_apply_command_line_options (struct t_irc_server *server, void irc_server_outqueue_add (struct t_irc_server *server, int priority, const char *command, const char *msg1, - const char *msg2, int modified) + const char *msg2, int modified, const char *tags) { struct t_irc_outqueue *new_outqueue; @@ -741,6 +744,7 @@ irc_server_outqueue_add (struct t_irc_server *server, int priority, new_outqueue->message_before_mod = (msg1) ? strdup (msg1) : NULL; new_outqueue->message_after_mod = (msg2) ? strdup (msg2) : NULL; new_outqueue->modified = modified; + new_outqueue->tags = (tags) ? strdup (tags) : NULL; new_outqueue->prev_outqueue = server->last_outqueue[priority]; new_outqueue->next_outqueue = NULL; @@ -776,7 +780,7 @@ irc_server_outqueue_free (struct t_irc_server *server, if (outqueue->next_outqueue) (outqueue->next_outqueue)->prev_outqueue = outqueue->prev_outqueue; - + /* free data */ if (outqueue->command) free (outqueue->command); @@ -784,6 +788,8 @@ irc_server_outqueue_free (struct t_irc_server *server, free (outqueue->message_before_mod); if (outqueue->message_after_mod) free (outqueue->message_after_mod); + if (outqueue->tags) + free (outqueue->tags); free (outqueue); server->outqueue[priority] = new_outqueue; } @@ -1052,10 +1058,11 @@ irc_server_rename (struct t_irc_server *server, const char *new_server_name) void irc_server_send_signal (struct t_irc_server *server, const char *signal, - const char *command, const char *full_message) + const char *command, const char *full_message, + const char *tags) { int length; - char *str_signal; + char *str_signal, *full_message_tags; length = strlen (server->name) + 1 + strlen (signal) + 1 + strlen (command) + 1; str_signal = malloc (length); @@ -1063,8 +1070,25 @@ irc_server_send_signal (struct t_irc_server *server, const char *signal, { snprintf (str_signal, length, "%s,%s_%s", server->name, signal, command); - weechat_hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING, - (void *)full_message); + if (tags) + { + length = strlen (tags) + 1 + strlen (full_message) + 1; + full_message_tags = malloc (length); + if (full_message_tags) + { + snprintf (full_message_tags, length, + "%s;%s", tags, full_message); + weechat_hook_signal_send (str_signal, + WEECHAT_HOOK_SIGNAL_STRING, + (void *)full_message_tags); + free (full_message_tags); + } + } + else + { + weechat_hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING, + (void *)full_message); + } free (str_signal); } } @@ -1130,6 +1154,46 @@ irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf) } /* + * irc_server_set_send_default_tags: set default tags used when sending message + */ + +void +irc_server_set_send_default_tags (const char *tags) +{ + irc_server_send_default_tags = tags; +} + +/* + * irc_server_get_tags_to_send: get tags to send by concatenation of tags + * and irc_server_send_default_tags (if set) + * If returned value is not NULL, then it must be + * free() after use. + */ + +char * +irc_server_get_tags_to_send (const char *tags) +{ + int length; + char *buf; + + if (!tags && !irc_server_send_default_tags) + return NULL; + + if (!tags) + return strdup (irc_server_send_default_tags); + + if (!irc_server_send_default_tags) + return strdup (tags); + + /* concatenate tags and irc_server_send_default_tags */ + length = strlen (tags) + 1 + strlen (irc_server_send_default_tags) + 1; + buf = malloc (length); + if (buf) + snprintf (buf, length, "%s,%s", tags, irc_server_send_default_tags); + return buf; +} + +/* * irc_server_outqueue_send: send a message from outqueue */ @@ -1137,7 +1201,7 @@ void irc_server_outqueue_send (struct t_irc_server *server) { time_t time_now; - char *pos; + char *pos, *tags_to_send; int priority; time_now = time (NULL); @@ -1177,7 +1241,15 @@ irc_server_outqueue_send (struct t_irc_server *server) /* send signal with command that will be sent to server */ irc_server_send_signal (server, "irc_out", server->outqueue[priority]->command, - server->outqueue[priority]->message_after_mod); + server->outqueue[priority]->message_after_mod, + NULL); + tags_to_send = irc_server_get_tags_to_send (server->outqueue[priority]->tags); + irc_server_send_signal (server, "irc_outtags", + server->outqueue[priority]->command, + server->outqueue[priority]->message_after_mod, + (tags_to_send) ? tags_to_send : ""); + if (tags_to_send) + free (tags_to_send); /* send command */ irc_server_send (server, server->outqueue[priority]->message_after_mod, @@ -1367,9 +1439,10 @@ irc_server_parse_message_to_hashtable (const char *message) /* * irc_server_send_one_msg: send one message to IRC server - * if queue_msg > 0, then messages are in a queue and - * sent slowly (to be sure there will not be any - * "excess flood"), value of queue_msg is priority: + * if flag contains outqueue priority value, then + * messages are in a queue and sent slowly (to be sure + * there will not be any "excess flood"), value of + * queue_msg is priority: * 1 = higher priority, for user messages * 2 = lower priority, for other messages (like * auto reply to CTCP queries) @@ -1377,15 +1450,15 @@ irc_server_parse_message_to_hashtable (const char *message) */ int -irc_server_send_one_msg (struct t_irc_server *server, int queue_msg, - const char *message) +irc_server_send_one_msg (struct t_irc_server *server, int flags, + const char *message, const char *tags) { static char buffer[4096]; const char *ptr_msg; - char *new_msg, *pos, *nick, *command, *channel; + char *new_msg, *pos, *nick, *command, *channel, *tags_to_send; char *ptr_chan_nick, *msg_encoded; char str_modifier[64], modifier_data[256]; - int rc, add_to_queue, first_message; + int rc, queue_msg, add_to_queue, first_message; time_t time_now; rc = 1; @@ -1450,13 +1523,24 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg, if (server->last_user_message > time_now) server->last_user_message = time_now; + /* get queue from flags */ + queue_msg = 0; + if (flags && IRC_SERVER_SEND_OUTQ_PRIO_HIGH) + queue_msg = 1; + else if (flags && IRC_SERVER_SEND_OUTQ_PRIO_LOW) + queue_msg = 2; + add_to_queue = 0; if ((queue_msg > 0) && (server->outqueue[queue_msg - 1] || ((weechat_config_integer (irc_config_network_anti_flood[queue_msg - 1]) > 0) && (time_now - server->last_user_message < weechat_config_integer (irc_config_network_anti_flood[queue_msg - 1]))))) + { add_to_queue = queue_msg; + } + + tags_to_send = irc_server_get_tags_to_send (tags); if (add_to_queue > 0) { @@ -1464,7 +1548,8 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg, irc_server_outqueue_add (server, add_to_queue - 1, command, (new_msg && first_message) ? message : NULL, buffer, - (new_msg) ? 1 : 0); + (new_msg) ? 1 : 0, + tags_to_send); } else { @@ -1476,7 +1561,12 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg, /* send signal with command that will be sent to server */ irc_server_send_signal (server, "irc_out", (command) ? command : "unknown", - ptr_msg); + ptr_msg, + NULL); + irc_server_send_signal (server, "irc_outtags", + (command) ? command : "unknown", + ptr_msg, + (tags_to_send) ? tags_to_send : ""); if (irc_server_send (server, buffer, strlen (buffer)) <= 0) rc = 0; @@ -1486,6 +1576,10 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg, server->last_user_message = time_now; } } + + if (tags_to_send) + free (tags_to_send); + if (pos) { pos[0] = '\n'; @@ -1517,16 +1611,10 @@ irc_server_send_one_msg (struct t_irc_server *server, int queue_msg, /* * irc_server_sendf: send formatted data to IRC server * many messages may be sent, separated by '\n' - * if queue_msg > 0, then messages are in a queue and sent - * slowly (to be sure there will not be any "excess flood"), - * value of queue_msg is priority: - * 1 = higher priority, for user messages - * 2 = lower priority, for other messages (like auto reply - * to CTCP queries) */ void -irc_server_sendf (struct t_irc_server *server, int queue_msg, +irc_server_sendf (struct t_irc_server *server, int flags, const char *tags, const char *format, ...) { va_list args; @@ -1544,7 +1632,7 @@ irc_server_sendf (struct t_irc_server *server, int queue_msg, items = weechat_string_split (buffer, "\n", 0, 0, &items_count); for (i = 0; i < items_count; i++) { - if (!irc_server_send_one_msg (server, queue_msg, items[i])) + if (!irc_server_send_one_msg (server, flags, items[i], tags)) break; } if (items) @@ -1968,7 +2056,7 @@ irc_server_timer_sasl_cb (void *data, int remaining_calls) weechat_printf (server->buffer, _("%s%s: sasl authentication timeout"), weechat_prefix ("error"), IRC_PLUGIN_NAME); - irc_server_sendf (server, 0, "CAP END"); + irc_server_sendf (server, 0, NULL, "CAP END"); } return WEECHAT_RC_OK; @@ -2014,7 +2102,7 @@ irc_server_timer_cb (void *data, int remaining_calls) && (ptr_server->lag_check_time.tv_sec == 0) && (new_time >= ptr_server->lag_next_check)) { - irc_server_sendf (ptr_server, 0, "PING %s", + irc_server_sendf (ptr_server, 0, NULL, "PING %s", ptr_server->addresses_array[ptr_server->index_current_address]); gettimeofday (&(ptr_server->lag_check_time), NULL); ptr_server->lag = 0; @@ -2230,7 +2318,7 @@ irc_server_login (struct t_irc_server *server) realname = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME); if (password && password[0]) - irc_server_sendf (server, 0, "PASS %s", password); + irc_server_sendf (server, 0, NULL, "PASS %s", password); if (!server->nick) { @@ -2244,10 +2332,10 @@ irc_server_login (struct t_irc_server *server) if (irc_server_sasl_enabled (server)) { - irc_server_sendf (server, 0, "CAP LS"); + irc_server_sendf (server, 0, NULL, "CAP LS"); } - irc_server_sendf (server, 0, + irc_server_sendf (server, 0, NULL, "NICK %s\n" "USER %s %s %s :%s", server->nick, @@ -3210,13 +3298,15 @@ irc_server_autojoin_channels (struct t_irc_server *server) { if (ptr_channel->key) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (server, + IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "JOIN %s %s", ptr_channel->name, ptr_channel->key); } else { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_LOW, + irc_server_sendf (server, + IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, "JOIN %s", ptr_channel->name); } @@ -3468,7 +3558,8 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal, { filename = weechat_infolist_string (infolist, "filename"); spaces_in_name = (strchr (filename, ' ') != NULL); - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01DCC SEND %s%s%s " "%s %d %s\01", weechat_infolist_string (infolist, "remote_nick"), @@ -3481,7 +3572,8 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal, } else if (strcmp (type, "chat_send") == 0) { - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01DCC CHAT chat %s %d\01", weechat_infolist_string (infolist, "remote_nick"), weechat_infolist_string (infolist, "address"), @@ -3538,7 +3630,7 @@ irc_server_xfer_resume_ready_cb (void *data, const char *signal, { filename = weechat_infolist_string (infolist, "filename"); spaces_in_name = (strchr (filename, ' ') != NULL); - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01DCC RESUME %s%s%s %d %s\01", weechat_infolist_string (infolist, "remote_nick"), (spaces_in_name) ? "\"" : "", @@ -3597,7 +3689,7 @@ irc_server_xfer_send_accept_resume_cb (void *data, const char *signal, { filename = weechat_infolist_string (infolist, "filename"); spaces_in_name = (strchr (filename, ' ') != NULL); - irc_server_sendf (server, IRC_SERVER_OUTQUEUE_PRIO_HIGH, + irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PRIVMSG %s :\01DCC ACCEPT %s%s%s %d %s\01", weechat_infolist_string (infolist, "remote_nick"), (spaces_in_name) ? "\"" : "", diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 4b2d9108d..71555a76c 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -85,10 +85,13 @@ enum t_irc_server_option #define IRC_SERVER_DEFAULT_PORT 6667 #define IRC_SERVER_DEFAULT_NICKS "weechat1,weechat2,weechat3,weechat4,weechat5" -#define IRC_SERVER_OUTQUEUE_PRIO_HIGH 1 -#define IRC_SERVER_OUTQUEUE_PRIO_LOW 2 +/* number of queues for sending messages */ #define IRC_SERVER_NUM_OUTQUEUES_PRIO 2 +/* flags for irc_server_sendf() */ +#define IRC_SERVER_SEND_OUTQ_PRIO_HIGH 1 +#define IRC_SERVER_SEND_OUTQ_PRIO_LOW 2 + /* output queue of messages to server (for sending slowly to server) */ struct t_irc_outqueue @@ -97,6 +100,7 @@ struct t_irc_outqueue char *message_before_mod; /* msg before any modifier */ char *message_after_mod; /* msg after modifier(s) */ int modified; /* msg was modified by modifier(s) */ + char *tags; /* tags (used by Relay plugin) */ struct t_irc_outqueue *next_outqueue; /* link to next msg in queue */ struct t_irc_outqueue *prev_outqueue; /* link to prev msg in queue */ }; @@ -202,10 +206,12 @@ extern struct t_irc_server *irc_server_copy (struct t_irc_server *server, extern int irc_server_rename (struct t_irc_server *server, const char *new_name); extern void irc_server_send_signal (struct t_irc_server *server, const char *signal, const char *command, - const char *full_message); + const char *full_message, + const char *tags); extern struct t_hashtable *irc_server_parse_message_to_hashtable (const char *message); -extern void irc_server_sendf (struct t_irc_server *server, int queue_msg, - const char *format, ...); +extern void irc_server_set_send_default_tags (const char *tags); +extern void irc_server_sendf (struct t_irc_server *server, int flags, + const char *tags, const char *format, ...); extern struct t_irc_server *irc_server_search (const char *server_name); extern void irc_server_set_buffer_title (struct t_irc_server *server); extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server); diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index ad7ab38b7..ee154c9b8 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -99,7 +99,7 @@ irc_upgrade_save_all_data (struct t_upgrade_file *upgrade_file) infolist = weechat_infolist_new (); if (!infolist) return 0; - if (!irc_nick_add_to_infolist (infolist, ptr_nick)) + if (!irc_nick_add_to_infolist (infolist, ptr_server, ptr_nick)) { weechat_infolist_free (infolist); return 0; diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index 56e7ae00b..6e7ba0dab 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -35,6 +35,7 @@ #include "irc-config.h" #include "irc-debug.h" #include "irc-info.h" +#include "irc-input.h" #include "irc-server.h" #include "irc-channel.h" #include "irc-nick.h" @@ -171,6 +172,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) weechat_hook_signal ("xfer_send_ready", &irc_server_xfer_send_ready_cb, NULL); weechat_hook_signal ("xfer_resume_ready", &irc_server_xfer_resume_ready_cb, NULL); weechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL); + weechat_hook_signal ("irc_input_send", &irc_input_send_cb, NULL); /* modifiers */ weechat_hook_modifier ("irc_color_decode", &irc_color_modifier_cb, NULL); |