diff options
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-bar-item.c | 24 | ||||
-rw-r--r-- | src/plugins/irc/irc-buffer.c | 198 | ||||
-rw-r--r-- | src/plugins/irc/irc-buffer.h | 9 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 160 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 78 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 9 | ||||
-rw-r--r-- | src/plugins/irc/irc-info.c | 12 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 248 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.h | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 320 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-upgrade.c | 9 | ||||
-rw-r--r-- | src/plugins/irc/irc.c | 2 |
14 files changed, 343 insertions, 744 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c index 29d026251..2292a6edd 100644 --- a/src/plugins/irc/irc-bar-item.c +++ b/src/plugins/irc/irc-bar-item.c @@ -143,24 +143,12 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item, { if (server && !channel) { - if (weechat_config_boolean (irc_config_look_one_server_buffer)) - { - snprintf (buf_name, sizeof (buf_name), "%s%s[<%s%s%s>]", - _("servers"), - IRC_COLOR_BAR_DELIM, - IRC_COLOR_STATUS_NAME, - (irc_current_server) ? irc_current_server->name : "-", - IRC_COLOR_BAR_DELIM); - } - else - { - snprintf (buf_name, sizeof (buf_name), "%s%s[%s%s%s]", - _("server"), - IRC_COLOR_BAR_DELIM, - IRC_COLOR_STATUS_NAME, - server->name, - IRC_COLOR_BAR_DELIM); - } + snprintf (buf_name, sizeof (buf_name), "%s%s[%s%s%s]", + _("server"), + IRC_COLOR_BAR_DELIM, + IRC_COLOR_STATUS_NAME, + server->name, + IRC_COLOR_BAR_DELIM); } else { diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c index 8d6989a09..5cd1146b3 100644 --- a/src/plugins/irc/irc-buffer.c +++ b/src/plugins/irc/irc-buffer.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <limits.h> #include "../weechat-plugin.h" #include "irc.h" @@ -33,10 +34,6 @@ #include "irc-server.h" -/* buffer for all servers (if using one buffer for all servers) */ -struct t_gui_buffer *irc_buffer_servers = NULL; - - /* * irc_buffer_get_server_channel: get IRC server and channel pointers with a * buffer pointer @@ -66,12 +63,7 @@ irc_buffer_get_server_channel (struct t_gui_buffer *buffer, if (ptr_server->buffer == buffer) { if (server) - { - if (weechat_config_boolean (irc_config_look_one_server_buffer)) - *server = irc_current_server; - else - *server = ptr_server; - } + *server = ptr_server; return; } @@ -116,156 +108,6 @@ irc_buffer_build_name (const char *server, const char *channel) } /* - * irc_buffer_get_server_prefix: return prefix, with server name if server - * buffers are displayed in only one buffer - */ - -char * -irc_buffer_get_server_prefix (struct t_irc_server *server, char *prefix_code) -{ - static char buf[256]; - const char *prefix; - - prefix = (prefix_code && prefix_code[0]) ? - weechat_prefix (prefix_code) : NULL; - - if (weechat_config_boolean (irc_config_look_one_server_buffer) && server) - { - snprintf (buf, sizeof (buf), "%s%s[%s%s%s]%s ", - (prefix) ? prefix : "", - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_SERVER, - server->name, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT); - } - else - { - snprintf (buf, sizeof (buf), "%s", - (prefix) ? prefix : ""); - } - return buf; -} - -/* - * irc_buffer_merge_servers: merge server buffers in one buffer - */ - -void -irc_buffer_merge_servers () -{ - struct t_irc_server *ptr_server; - struct t_gui_buffer *ptr_buffer; - int number, number_selected; - char charset_modifier[256]; - - irc_buffer_servers = NULL; - irc_current_server = NULL; - - /* choose server buffer with lower number (should be first created) */ - number_selected = -1; - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - if (ptr_server->buffer) - { - number = weechat_buffer_get_integer (ptr_server->buffer, "number"); - if ((number_selected == -1) || (number < number_selected)) - { - irc_buffer_servers = ptr_server->buffer; - irc_current_server = ptr_server; - number_selected = number; - } - } - } - - if (irc_buffer_servers) - { - weechat_buffer_set (irc_buffer_servers, - "name", IRC_BUFFER_ALL_SERVERS_NAME); - weechat_buffer_set (irc_buffer_servers, - "short_name", IRC_BUFFER_ALL_SERVERS_NAME); - weechat_buffer_set (irc_buffer_servers, - "localvar_set_server", IRC_BUFFER_ALL_SERVERS_NAME); - weechat_buffer_set (irc_buffer_servers, - "localvar_set_channel", IRC_BUFFER_ALL_SERVERS_NAME); - snprintf (charset_modifier, sizeof (charset_modifier), - "irc.%s", irc_current_server->name); - weechat_buffer_set (irc_buffer_servers, - "localvar_set_charset_modifier", - charset_modifier); - weechat_hook_signal_send ("logger_stop", - WEECHAT_HOOK_SIGNAL_POINTER, - irc_buffer_servers); - weechat_hook_signal_send ("logger_start", - WEECHAT_HOOK_SIGNAL_POINTER, - irc_buffer_servers); - - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - if (ptr_server->buffer - && (ptr_server->buffer != irc_buffer_servers)) - { - ptr_buffer = ptr_server->buffer; - ptr_server->buffer = irc_buffer_servers; - weechat_buffer_close (ptr_buffer); - } - } - - irc_server_set_buffer_title (irc_current_server); - irc_server_buffer_set_highlight_words (irc_buffer_servers); - } -} - -/* - * irc_buffer_split_server: split the server buffer into many buffers (one by server) - */ - -void -irc_buffer_split_server () -{ - struct t_irc_server *ptr_server; - char buffer_name[256], charset_modifier[256]; - - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - if (ptr_server->buffer && (ptr_server != irc_current_server)) - { - irc_server_create_buffer (ptr_server, 0); - } - } - - if (irc_current_server) - { - snprintf (buffer_name, sizeof (buffer_name), - "server.%s", irc_current_server->name); - weechat_buffer_set (irc_current_server->buffer, "name", buffer_name); - weechat_buffer_set (irc_current_server->buffer, - "short_name", irc_current_server->name); - weechat_buffer_set (irc_current_server->buffer, - "localvar_set_server", irc_current_server->name); - weechat_buffer_set (irc_current_server->buffer, - "localvar_set_channel", irc_current_server->name); - snprintf (charset_modifier, sizeof (charset_modifier), - "irc.%s", irc_current_server->name); - weechat_buffer_set (irc_current_server->buffer, - "localvar_set_charset_modifier", - charset_modifier); - weechat_hook_signal_send ("logger_stop", - WEECHAT_HOOK_SIGNAL_POINTER, - irc_current_server->buffer); - weechat_hook_signal_send ("logger_start", - WEECHAT_HOOK_SIGNAL_POINTER, - irc_current_server->buffer); - } - - irc_buffer_servers = NULL; - irc_current_server = NULL; -} - -/* * irc_buffer_close_cb: callback called when a buffer is closed */ @@ -310,12 +152,40 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer) irc_server_disconnect (ptr_server, 0); ptr_server->buffer = NULL; } - if (irc_buffer_servers == buffer) - irc_buffer_servers = NULL; - if (ptr_server && (irc_current_server == ptr_server)) - irc_current_server = NULL; } } return WEECHAT_RC_OK; } + +/* + * irc_buffer_search_first_for_all_servers: search first server buffer that + * will be used to merge all IRC + * server buffers + */ + +struct t_gui_buffer * +irc_buffer_search_first_for_all_servers () +{ + struct t_gui_buffer *ptr_buffer; + struct t_irc_server *ptr_server; + int number, number_found; + + ptr_buffer = NULL; + number_found = INT_MAX; + + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + if (ptr_server->buffer) + { + number = weechat_buffer_get_integer (ptr_server->buffer, "number"); + if (number < number_found) + { + number_found = number; + ptr_buffer = ptr_server->buffer; + } + } + } + return ptr_buffer; +} diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h index 74d97ed2b..87959a38e 100644 --- a/src/plugins/irc/irc-buffer.h +++ b/src/plugins/irc/irc-buffer.h @@ -20,8 +20,6 @@ #ifndef __WEECHAT_IRC_BUFFER_H #define __WEECHAT_IRC_BUFFER_H 1 -#define IRC_BUFFER_ALL_SERVERS_NAME "servers" - #define IRC_BUFFER_RAW_NAME "irc_raw" #define IRC_BUFFER_RAW_PREFIX_RECV "-->" #define IRC_BUFFER_RAW_PREFIX_RECV_MOD "==>" @@ -32,16 +30,11 @@ struct t_gui_buffer; struct t_irc_server; struct t_irc_channel; -extern struct t_gui_buffer *irc_buffer_servers; - extern void irc_buffer_get_server_channel (struct t_gui_buffer *buffer, struct t_irc_server **server, struct t_irc_channel **channel); extern char *irc_buffer_build_name (const char *server, const char *channel); -extern char *irc_buffer_get_server_prefix (struct t_irc_server *server, - char *prefix_code); -extern void irc_buffer_merge_servers (); -extern void irc_buffer_split_server (); extern int irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer); +extern struct t_gui_buffer *irc_buffer_search_first_for_all_servers (); #endif /* irc-buffer.h */ diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 2a852a806..37cf1bef9 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -232,8 +232,7 @@ irc_command_amsg (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: cannot find nick for " "sending message"), - irc_buffer_get_server_prefix (ptr_server, - "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME); } } @@ -296,11 +295,8 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, /* reset "unread" indicator on server and channels/pv buffers */ if (reset_unread_marker) { - if (!weechat_config_boolean (irc_config_look_one_server_buffer)) - { - if (weechat_buffer_get_integer (server->buffer, "num_displayed") > 0) - weechat_buffer_set (server->buffer, "unread", ""); - } + if (weechat_buffer_get_integer (server->buffer, "num_displayed") > 0) + weechat_buffer_set (server->buffer, "unread", ""); for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { @@ -319,8 +315,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, string = irc_color_decode (arguments, weechat_config_boolean (irc_config_network_colors_receive)); weechat_printf (server->buffer, - _("%s%s: future away: %s"), - irc_buffer_get_server_prefix (server, NULL), + _("%s: future away: %s"), IRC_PLUGIN_NAME, (string) ? string : arguments); if (string) @@ -378,8 +373,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, /* server not connected, remove away message but do not send anything */ weechat_printf (server->buffer, - _("%s%s: future away removed"), - irc_buffer_get_server_prefix (server, NULL), + _("%s: future away removed"), IRC_PLUGIN_NAME); } } @@ -464,8 +458,8 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "ban"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "ban"); return WEECHAT_RC_OK; } } @@ -485,8 +479,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "ban"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "ban"); return WEECHAT_RC_OK; } irc_server_sendf (ptr_server, 0, "MODE %s +b", ptr_channel->name); @@ -698,8 +691,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc, irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01PING %d %d\01", argv[1], tv.tv_sec, tv.tv_usec); weechat_printf (ptr_server->buffer, - "%sCTCP%s(%s%s%s)%s: %s%s %s%d %d", - irc_buffer_get_server_prefix (ptr_server, NULL), + "CTCP%s(%s%s%s)%s: %s%s %s%d %d", IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[1], @@ -717,8 +709,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc, irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01%s %s\01", argv[1], irc_cmd, argv_eol[3]); weechat_printf (ptr_server->buffer, - "%sCTCP%s(%s%s%s)%s: %s%s %s%s", - irc_buffer_get_server_prefix (ptr_server, NULL), + "CTCP%s(%s%s%s)%s: %s%s %s%s", IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[1], @@ -734,8 +725,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc, irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01%s\01", argv[1], irc_cmd); weechat_printf (ptr_server->buffer, - "%sCTCP%s(%s%s%s)%s: %s%s", - irc_buffer_get_server_prefix (ptr_server, NULL), + "CTCP%s(%s%s%s)%s: %s%s", IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[1], @@ -800,8 +790,8 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can not be executed " "on a server buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "cycle"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "cycle"); return WEECHAT_RC_OK; } @@ -821,8 +811,7 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can not be executed on " "a server buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "part"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "part"); return WEECHAT_RC_OK; } @@ -953,8 +942,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc, { weechat_printf (ptr_server->buffer, _("%s%s: wrong arguments for \"%s\" command"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "dcc"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "dcc"); return WEECHAT_RC_OK; } } @@ -996,8 +984,7 @@ irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be executed in " "a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "dehalfop"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "dehalfop"); return WEECHAT_RC_OK; } return WEECHAT_RC_OK; @@ -1033,8 +1020,7 @@ irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be executed in " "a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "deop"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "deop"); return WEECHAT_RC_OK; } return WEECHAT_RC_OK; @@ -1070,8 +1056,7 @@ irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "devoice"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "devoice"); return WEECHAT_RC_OK; } return WEECHAT_RC_OK; @@ -1150,15 +1135,14 @@ irc_command_disconnect_one_server (struct t_irc_server *server) { weechat_printf (server->buffer, _("%s%s: not connected to server \"%s\"!"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, server->name); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + server->name); return 0; } if (server->reconnect_start > 0) { weechat_printf (server->buffer, - _("%s%s: auto-reconnection is cancelled"), - irc_buffer_get_server_prefix (server, NULL), + _("%s: auto-reconnection is cancelled"), IRC_PLUGIN_NAME); } irc_command_quit_server (server, NULL); @@ -1261,8 +1245,7 @@ irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "halfop"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "halfop"); return WEECHAT_RC_OK; } return WEECHAT_RC_OK; @@ -1506,8 +1489,8 @@ irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "invite"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "invite"); return WEECHAT_RC_OK; } @@ -1604,8 +1587,8 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: wrong arguments for \"%s\" " "command"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "kick"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "kick"); return WEECHAT_RC_OK; } pos_channel = argv[1]; @@ -1625,8 +1608,8 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "kick"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "kick"); return WEECHAT_RC_OK; } } @@ -1671,8 +1654,8 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: wrong arguments for \"%s\" " "command"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "kickban"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "kickban"); return WEECHAT_RC_OK; } pos_channel = argv[1]; @@ -1692,8 +1675,8 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "kickban"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "kickban"); return WEECHAT_RC_OK; } } @@ -1818,8 +1801,8 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" is not a valid regular " "expression (%s)"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, argv_eol, buf); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + argv_eol, buf); return WEECHAT_RC_OK; } else @@ -1830,8 +1813,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: not enough memory for regular " "expression"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); return WEECHAT_RC_OK; } } @@ -1884,8 +1866,7 @@ irc_command_me (void *data, struct t_gui_buffer *buffer, int argc, char **argv, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can not be executed " "on a server buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "me"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "me"); return WEECHAT_RC_OK; } irc_command_me_channel (ptr_server, ptr_channel, @@ -1941,8 +1922,8 @@ irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: you must specify channel for \"%s\" " "command if you're not in a channel"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "mode"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "mode"); return WEECHAT_RC_OK; } irc_command_mode_server (ptr_server, ptr_channel, argv_eol[1]); @@ -2038,8 +2019,7 @@ 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"), - irc_buffer_get_server_prefix (ptr_server, - "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "msg *"); return WEECHAT_RC_OK; } @@ -2093,8 +2073,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, weechat_config_boolean (irc_config_network_colors_receive)); weechat_printf (ptr_server->buffer, "%s%s-%s%s%s- %s%s", - irc_buffer_get_server_prefix (ptr_server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, targets[i], @@ -2123,8 +2102,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, { weechat_printf (ptr_server->buffer, "%sMSG%s(%s%s%s)%s: %s", - irc_buffer_get_server_prefix (ptr_server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, targets[i], @@ -2173,8 +2151,8 @@ irc_command_names (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "names"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "names"); return WEECHAT_RC_OK; } } @@ -2219,8 +2197,7 @@ irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc, { weechat_printf (ptr_server->buffer, _("%s%s: wrong arguments for \"%s\" command"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "nick"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "nick"); return WEECHAT_RC_OK; } for (ptr_server = irc_servers; ptr_server; @@ -2274,8 +2251,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc, string = irc_color_decode (argv_eol[arg_text], weechat_config_boolean (irc_config_network_colors_receive)); weechat_printf (ptr_server->buffer, - "%sNotice -> %s%s%s: %s", - irc_buffer_get_server_prefix (ptr_server, NULL), + "Notice -> %s%s%s: %s", IRC_COLOR_CHAT_NICK, argv[arg_nick], IRC_COLOR_CHAT, @@ -2324,8 +2300,7 @@ irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "op"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "op"); return WEECHAT_RC_OK; } return WEECHAT_RC_OK; @@ -2418,8 +2393,8 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc, _("%s%s: \"%s\" command can only be " "executed in a channel or " "private buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "part"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "part"); return WEECHAT_RC_OK; } channel_name = ptr_channel->name; @@ -2434,8 +2409,7 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc, _("%s%s: \"%s\" command can only be " "executed in a channel or private " "buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "part"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "part"); return WEECHAT_RC_OK; } if (!ptr_channel->nicks) @@ -2543,8 +2517,8 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: cannot create new private " "buffer \"%s\""), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, argv[arg_nick]); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + argv[arg_nick]); return WEECHAT_RC_OK; } } @@ -2625,8 +2599,8 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join) { weechat_printf (server->buffer, _("%s%s: not connected to server \"%s\"!"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, server->name); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + server->name); return 0; } irc_command_quit_server (server, NULL); @@ -3115,13 +3089,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, return WEECHAT_RC_OK; } - if (weechat_strcasecmp (argv[1], "switch") == 0) - { - if (weechat_config_boolean (irc_config_look_one_server_buffer)) - irc_server_switch_next (); - return WEECHAT_RC_OK; - } - weechat_printf (NULL, _("%s%s: unknown option for \"%s\" command"), weechat_prefix ("error"), IRC_PLUGIN_NAME, "server"); @@ -3345,8 +3312,8 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "topic"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "topic"); return WEECHAT_RC_OK; } } @@ -3437,8 +3404,8 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "unban"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "unban"); return WEECHAT_RC_OK; } } @@ -3455,8 +3422,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc, { weechat_printf (ptr_server->buffer, _("%s%s: wrong argument count for \"%s\" command"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "unban"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "unban"); return WEECHAT_RC_OK; } @@ -3572,8 +3538,7 @@ irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc, weechat_printf (ptr_server->buffer, _("%s%s: \"%s\" command can only be " "executed in a channel buffer"), - irc_buffer_get_server_prefix (ptr_server, "error"), - IRC_PLUGIN_NAME, "voice"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "voice"); return WEECHAT_RC_OK; } @@ -4047,7 +4012,7 @@ irc_command_init () "[copy servername newservername] | " "[rename servername newservername] | " "[keep servername] | [del servername] | " - "[deloutq] | [raw] | [switch]"), + "[deloutq] | [raw]"), N_(" list: list servers (no parameter implies " "this list)\n" " listfull: list servers with detailed info for " @@ -4071,10 +4036,7 @@ irc_command_init () " deloutq: delete messages out queue for all " "servers (all messages WeeChat is currently " "sending)\n" - " raw: open buffer with raw IRC data\n" - " switch: switch active server (when one " - "buffer is used for all servers, default key: " - "alt-s on server buffer)\n\n" + " raw: open buffer with raw IRC data\n\n" "Examples:\n" " /server listfull\n" " /server add oftc irc.oftc.net/6697 -ssl\n" diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h index 12b2b526d..6bd14219d 100644 --- a/src/plugins/irc/irc-command.h +++ b/src/plugins/irc/irc-command.h @@ -26,8 +26,7 @@ struct t_irc_channel; #define IRC_COMMAND_TOO_FEW_ARGUMENTS(__buffer, __command) \ weechat_printf (__buffer, \ _("%s%s: too few arguments for \"%s\" command"), \ - irc_buffer_get_server_prefix (ptr_server, "error"), \ - IRC_PLUGIN_NAME, \ + weechat_prefix ("error"), IRC_PLUGIN_NAME, \ __command); \ return WEECHAT_RC_OK; diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 6529d827f..b0fa3c072 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -43,7 +43,7 @@ struct t_config_section *irc_config_section_server = NULL; /* IRC config, look section */ struct t_config_option *irc_config_look_color_nicks_in_server_messages; -struct t_config_option *irc_config_look_one_server_buffer; +struct t_config_option *irc_config_look_server_buffer; struct t_config_option *irc_config_look_open_near_server; struct t_config_option *irc_config_look_nick_prefix; struct t_config_option *irc_config_look_nick_suffix; @@ -153,22 +153,50 @@ irc_config_change_look_color_nicks_number (void *data, const char *option, } /* - * irc_config_change_look_one_server_buffer: called when the "one server buffer" - * option is changed + * irc_config_change_look_server_buffer: called when the "one server buffer" + * option is changed */ void -irc_config_change_look_one_server_buffer (void *data, - struct t_config_option *option) +irc_config_change_look_server_buffer (void *data, + struct t_config_option *option) { + struct t_irc_server *ptr_server; + struct t_gui_buffer *ptr_buffer; + /* make C compiler happy */ (void) data; (void) option; - - if (weechat_config_boolean (irc_config_look_one_server_buffer)) - irc_buffer_merge_servers (); - else - irc_buffer_split_server (); + + /* first unmerge all IRC server buffers */ + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + if (ptr_server->buffer) + weechat_buffer_unmerge (ptr_server->buffer, -1); + } + + /* merge IRC server buffers with core buffer or another buffer */ + if ((weechat_config_integer (irc_config_look_server_buffer) == + IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE) + || (weechat_config_integer (irc_config_look_server_buffer) == + IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITHOUT_CORE)) + { + ptr_buffer = + (weechat_config_integer (irc_config_look_server_buffer) == + IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE) ? + weechat_buffer_search_main () : irc_buffer_search_first_for_all_servers (); + + if (ptr_buffer) + { + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { + if (ptr_server->buffer && (ptr_server->buffer != ptr_buffer)) + weechat_buffer_merge (ptr_server->buffer, ptr_buffer); + } + } + } } /* @@ -340,26 +368,15 @@ irc_config_change_network_send_unknown_commands (void *data, (weechat_config_boolean (irc_config_network_send_unknown_commands)) ? "1" : "0"); - if (weechat_config_boolean (irc_config_look_one_server_buffer)) + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) { - if (irc_buffer_servers) + if (ptr_server->buffer) { - weechat_buffer_set (irc_buffer_servers, + weechat_buffer_set (ptr_server->buffer, "input_get_unknown_commands", value); } } - else - { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - if (ptr_server->buffer) - { - weechat_buffer_set (ptr_server->buffer, - "input_get_unknown_commands", value); - } - } - } for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) @@ -1055,12 +1072,13 @@ irc_config_init () N_("use nick color in messages from server"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_one_server_buffer = weechat_config_new_option ( + irc_config_look_server_buffer = weechat_config_new_option ( irc_config_file, ptr_section, - "one_server_buffer", "boolean", - N_("use same buffer for all servers"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, - &irc_config_change_look_one_server_buffer, NULL, NULL, NULL); + "server_buffer", "integer", + N_("merge server buffers"), + "merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core", + NULL, 0, NULL, NULL, + &irc_config_change_look_server_buffer, NULL, NULL, NULL); irc_config_look_open_near_server = weechat_config_new_option ( irc_config_file, ptr_section, "open_near_server", "boolean", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 30be39987..d79e15b7b 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -22,6 +22,13 @@ #define IRC_CONFIG_NAME "irc" +enum t_irc_config_look_server_buffer +{ + IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE = 0, + IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITHOUT_CORE, + IRC_CONFIG_LOOK_SERVER_BUFFER_INDEPENDENT, +}; + enum t_irc_config_nick_completion { IRC_CONFIG_NICK_COMPLETION_SMART_OFF = 0, @@ -41,7 +48,7 @@ extern struct t_config_section *irc_config_section_server_default; extern struct t_config_section *irc_config_section_server; extern struct t_config_option *irc_config_look_color_nicks_in_server_messages; -extern struct t_config_option *irc_config_look_one_server_buffer; +extern struct t_config_option *irc_config_look_server_buffer; extern struct t_config_option *irc_config_look_open_near_server; extern struct t_config_option *irc_config_look_nick_prefix; extern struct t_config_option *irc_config_look_nick_suffix; diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index de55223c9..d7a1cf400 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -166,14 +166,6 @@ irc_info_get_info_cb (void *data, const char *info_name, } } } - else if (weechat_strcasecmp (info_name, "irc_current_server") == 0) - { - if (weechat_config_boolean (irc_config_look_one_server_buffer) - && irc_current_server) - { - return irc_current_server->name; - } - } return NULL; } @@ -391,10 +383,6 @@ irc_info_init () &irc_info_get_info_cb, NULL); weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel"), &irc_info_get_info_cb, NULL); - weechat_hook_info ("irc_current_server", - N_("currently selected server (only if one buffer is " - "used for all servers)"), - &irc_info_get_info_cb, NULL); /* infolist hooks */ weechat_hook_infolist ("irc_server", N_("list of IRC servers"), diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index c60e2ad87..17e908ee8 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -252,7 +252,7 @@ irc_protocol_cmd_error (struct t_irc_server *server, const char *command, weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer, irc_protocol_tags (command, "irc_error"), "%s%s%s%s%s%s", - (ptr_channel) ? weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), (ptr_channel && chan_nick && (strcmp (chan_nick, ptr_channel->name) == 0)) ? IRC_COLOR_CHAT_CHANNEL : "", @@ -292,7 +292,7 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "notify_highlight"), _("%sYou have been invited to %s%s%s by " "%s%s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, (argv[3][0] == ':') ? argv[3] + 1 : argv[3], IRC_COLOR_CHAT, @@ -339,8 +339,8 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot create new channel \"%s\""), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, pos_channel); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + pos_channel); return WEECHAT_RC_ERROR; } } @@ -413,8 +413,8 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: channel \"%s\" not found for " "\"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, argv[2], "kick"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, argv[2], + "kick"); return WEECHAT_RC_ERROR; } @@ -584,7 +584,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command, ptr_channel->buffer : server->buffer, irc_protocol_tags (command, NULL), _("%sMode %s%s %s[%s%s%s]%s by %s%s"), - (ptr_channel) ? weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, (ptr_channel) ? ptr_channel->name : argv[2], IRC_COLOR_CHAT_DELIMITERS, @@ -603,7 +603,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, NULL), _("%sUser mode %s[%s%s%s]%s by %s%s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, pos_modes, @@ -770,7 +770,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, NULL), _("%sCTCP %sVERSION%s reply from %s%s%s: %s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, IRC_COLOR_CHAT, IRC_COLOR_CHAT_NICK, @@ -809,8 +809,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_ctcp"), _("%sCTCP %sPING%s reply from " "%s%s%s: %ld.%ld %s"), - irc_buffer_get_server_prefix (server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, IRC_COLOR_CHAT, IRC_COLOR_CHAT_NICK, @@ -836,8 +835,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer, irc_protocol_tags (command, NULL), "%sNotice%s(%s%s%s)%s: %s", - (ptr_channel) ? - weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), (nick && nick[0]) ? nick : "?", @@ -870,8 +868,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: cannot create new " "private buffer \"%s\""), - irc_buffer_get_server_prefix (server, - "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, nick); return WEECHAT_RC_ERROR; } @@ -895,8 +892,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, irc_protocol_tags (command, (notify_private) ? "notify_private" : NULL), "%s%s%s %s(%s%s%s)%s: %s", - irc_buffer_get_server_prefix (server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, nick, IRC_COLOR_CHAT_DELIMITERS, @@ -914,8 +910,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, irc_protocol_tags (command, (notify_private) ? "notify_private" : NULL), "%s%s%s%s: %s", - irc_buffer_get_server_prefix (server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, nick, IRC_COLOR_CHAT, @@ -927,8 +922,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, irc_protocol_tags (command, (notify_private) ? "notify_private" : NULL), "%s%s", - irc_buffer_get_server_prefix (server, - "network"), + weechat_prefix ("network"), pos_args); } } @@ -1161,8 +1155,7 @@ irc_protocol_reply_version (struct t_irc_server *server, weechat_printf (ptr_buffer, _("%sCTCP %sVERSION%s received from %s%s%s: " "%s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, IRC_COLOR_CHAT, IRC_COLOR_CHAT_NICK, @@ -1174,8 +1167,7 @@ irc_protocol_reply_version (struct t_irc_server *server, { weechat_printf (ptr_buffer, _("%sCTCP %sVERSION%s received from %s%s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, IRC_COLOR_CHAT, IRC_COLOR_CHAT_NICK, @@ -1426,7 +1418,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: channel \"%s\" not found for \"%s\" " "command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, argv[2], "privmsg"); return WEECHAT_RC_ERROR; } @@ -1471,8 +1463,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_ctcp"), _("%sCTCP %sPING%s received from %s%s"), - irc_buffer_get_server_prefix (server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, IRC_COLOR_CHAT, IRC_COLOR_CHAT_NICK, @@ -1498,7 +1489,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return WEECHAT_RC_ERROR; } @@ -1511,7 +1502,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return WEECHAT_RC_ERROR; } @@ -1529,7 +1520,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; @@ -1548,7 +1539,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; @@ -1567,7 +1558,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; @@ -1629,7 +1620,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return WEECHAT_RC_ERROR; } @@ -1642,7 +1633,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); return WEECHAT_RC_ERROR; } @@ -1660,7 +1651,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; @@ -1679,7 +1670,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; @@ -1735,8 +1726,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); return WEECHAT_RC_ERROR; } @@ -1748,8 +1739,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); return WEECHAT_RC_ERROR; } @@ -1766,8 +1757,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; } @@ -1785,8 +1776,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; } @@ -1841,8 +1832,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); return WEECHAT_RC_ERROR; } @@ -1854,8 +1845,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: not enough memory for \"%s\" " "command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); return WEECHAT_RC_ERROR; } @@ -1872,8 +1863,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; } @@ -1890,8 +1881,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: cannot parse \"%s\" command"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "privmsg"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + "privmsg"); free (dcc_args); return WEECHAT_RC_ERROR; } @@ -1907,7 +1898,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: unknown DCC CHAT type " "received from %s%s%s: \"%s\""), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, IRC_COLOR_CHAT_NICK, nick, @@ -1976,8 +1967,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: cannot create new " "private buffer \"%s\""), - irc_buffer_get_server_prefix (server, - "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, remote_nick); return WEECHAT_RC_ERROR; } @@ -2042,8 +2032,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_ctcp"), _("%sUnknown CTCP %s%s%s " "received from %s%s%s: %s"), - irc_buffer_get_server_prefix (server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, pos_args, IRC_COLOR_CHAT, @@ -2058,8 +2047,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_ctcp"), _("%sUnknown CTCP %s%s%s " "received from %s%s"), - irc_buffer_get_server_prefix (server, - "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, pos_args, IRC_COLOR_CHAT, @@ -2091,8 +2079,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: cannot create new " "private buffer \"%s\""), - irc_buffer_get_server_prefix (server, - "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, remote_nick); return WEECHAT_RC_ERROR; } @@ -2241,7 +2228,7 @@ irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, const char *co weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s: %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), pos_mode, (pos_args) ? pos_args : ""); @@ -2276,7 +2263,7 @@ irc_protocol_cmd_numeric (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), pos_args); return WEECHAT_RC_OK; @@ -2306,8 +2293,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, { weechat_printf (server->buffer, _("%s%s: \"%s\" command received without channel"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, "topic"); + weechat_prefix ("error"), IRC_PLUGIN_NAME, "topic"); return WEECHAT_RC_ERROR; } @@ -2333,8 +2319,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, irc_protocol_tags (command, NULL), _("%s%s%s%s has changed topic for %s%s%s " "from \"%s%s\" to \"%s%s\""), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT, @@ -2354,8 +2339,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, irc_protocol_tags (command, NULL), _("%s%s%s%s has changed topic for %s%s%s to " "\"%s%s\""), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT, @@ -2373,8 +2357,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, NULL), _("%s%s%s%s has unset topic for %s%s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT, @@ -2409,7 +2392,7 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, NULL), _("%sWallops from %s%s %s(%s%s%s)%s: %s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, nick, IRC_COLOR_CHAT_DELIMITERS, @@ -2475,11 +2458,6 @@ irc_protocol_cmd_001 (struct t_irc_server *server, const char *command, commands = weechat_string_split_command (ptr_command, ';'); if (commands) { - if (weechat_config_boolean (irc_config_look_one_server_buffer) - && (irc_current_server != server)) - { - irc_server_set_current_server (server); - } for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++) { vars_replaced = irc_protocol_replace_vars (server, NULL, @@ -2565,7 +2543,7 @@ irc_protocol_cmd_221 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%sUser mode for %s%s%s is %s[%s%s%s]"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, argv[2], IRC_COLOR_CHAT, @@ -2612,8 +2590,7 @@ irc_protocol_cmd_301 (struct t_irc_server *server, const char *command, weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, "irc_numeric"), _("%s%s[%s%s%s]%s is away: %s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -2652,7 +2629,7 @@ irc_protocol_cmd_303 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%sUsers online: %s%s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); @@ -2681,7 +2658,7 @@ irc_protocol_cmd_305 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); } @@ -2715,7 +2692,7 @@ irc_protocol_cmd_306 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); } @@ -2744,7 +2721,7 @@ irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, const char *comman weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -2772,7 +2749,7 @@ irc_protocol_cmd_311 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] (%s%s@%s%s)%s: %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -2804,7 +2781,7 @@ irc_protocol_cmd_312 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s %s(%s%s%s)", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -2836,7 +2813,7 @@ irc_protocol_cmd_314 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%s%s%s %s(%s%s@%s%s)%s was %s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, argv[3], IRC_COLOR_CHAT_DELIMITERS, @@ -2876,7 +2853,7 @@ irc_protocol_cmd_315 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s]%s %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -2923,7 +2900,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command, _("%s%s[%s%s%s]%s idle: %s%d %s%s, " "%s%02d %s%s %s%02d %s%s %s%02d " "%s%s, signon at: %s%s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -2955,7 +2932,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command, _("%s%s[%s%s%s]%s idle: %s%02d %s%s " "%s%02d %s%s %s%02d %s%s, " "signon at: %s%s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -3002,7 +2979,7 @@ irc_protocol_cmd_321 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s%s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), argv[3], (pos_args) ? " " : "", (pos_args) ? pos_args : ""); @@ -3035,7 +3012,7 @@ irc_protocol_cmd_322 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s%s%s(%s%s%s)%s%s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT_DELIMITERS, @@ -3075,7 +3052,7 @@ irc_protocol_cmd_323 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), (pos_args && pos_args[0]) ? pos_args : ""); return WEECHAT_RC_OK; @@ -3145,7 +3122,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s %s %s(%s%s%s)", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -3163,7 +3140,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -3248,7 +3225,7 @@ irc_protocol_cmd_329 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%sChannel %s%s%s created on %s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT, @@ -3275,7 +3252,7 @@ irc_protocol_cmd_330 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s %s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -3313,8 +3290,7 @@ irc_protocol_cmd_331 (struct t_irc_server *server, const char *command, weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, "irc_numeric"), _("%sNo topic set for channel %s%s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3]); @@ -3361,8 +3337,7 @@ irc_protocol_cmd_332 (struct t_irc_server *server, const char *command, weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, "irc_numeric"), _("%sTopic for %s%s%s is \"%s%s\""), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT, @@ -3412,7 +3387,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%sTopic for %s%s%s set by %s%s%s on %s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT, @@ -3442,7 +3417,7 @@ irc_protocol_cmd_338 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s]%s %s %s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_NICK, argv[3], @@ -3475,7 +3450,7 @@ irc_protocol_cmd_341 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%s%s%s%s has invited %s%s%s on %s%s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, argv[2], IRC_COLOR_CHAT, @@ -3505,7 +3480,7 @@ irc_protocol_cmd_344 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%sChannel reop %s%s%s: %s%s"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT, @@ -3532,7 +3507,7 @@ irc_protocol_cmd_345 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s%s%s: %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT, @@ -3573,8 +3548,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_numeric"), _("%s%s[%s%s%s]%s exception %s%s%s " "by %s%s %s(%s%s%s)%s on %s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -3597,8 +3571,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, const char *command, weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, "irc_numeric"), _("%s%s[%s%s%s]%s exception %s%s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -3638,8 +3611,7 @@ irc_protocol_cmd_349 (struct t_irc_server *server, const char *command, weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s]%s%s%s", - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -3670,7 +3642,7 @@ irc_protocol_cmd_351 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s %s (%s)", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), argv[3], argv[4], (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]); @@ -3680,7 +3652,7 @@ irc_protocol_cmd_351 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), argv[3], argv[4]); } @@ -3744,7 +3716,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s%s(%s%s@%s%s)%s " "%s%s%s%s(%s)", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -3870,7 +3842,7 @@ irc_protocol_cmd_353 (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: cannot create nick \"%s\" " "for channel \"%s\""), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, pos_nick, ptr_channel->name); } } @@ -3881,7 +3853,7 @@ irc_protocol_cmd_353 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), _("%sNicks %s%s%s: %s[%s%s%s]"), - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, pos_channel, IRC_COLOR_CHAT, @@ -4025,7 +3997,7 @@ irc_protocol_cmd_366 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s%s%s: %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT, @@ -4066,8 +4038,7 @@ irc_protocol_cmd_367 (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_numeric"), _("%s%s[%s%s%s] %s%s%s banned by " "%s%s %s(%s%s%s)%s on %s"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -4090,8 +4061,7 @@ irc_protocol_cmd_367 (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_numeric"), _("%s%s[%s%s%s] %s%s%s banned by " "%s%s %s(%s%s%s)"), - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -4137,8 +4107,7 @@ irc_protocol_cmd_368 (struct t_irc_server *server, const char *command, weechat_printf_tags (ptr_buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s]%s%s%s", - (ptr_buffer == server->buffer) ? - irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), + weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], @@ -4187,7 +4156,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command, _("%s%s: all declared nicknames are " "already in use or invalid, closing " "connection with server"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME); irc_server_disconnect (server, 1); return WEECHAT_RC_OK; @@ -4196,7 +4165,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command, weechat_printf (server->buffer, _("%s%s: nickname \"%s\" is invalid, " "trying nickname #%d (\"%s\")"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME, server->nick, nick_to_use + 1, server->nicks_array[nick_to_use]); @@ -4243,16 +4212,15 @@ irc_protocol_cmd_433 (struct t_irc_server *server, const char *command, _("%s%s: all declared nicknames are " "already in use, closing " "connection with server"), - irc_buffer_get_server_prefix (server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME); irc_server_disconnect (server, 1); return WEECHAT_RC_OK; } weechat_printf (server->buffer, - _("%s%s: nickname \"%s\" is already in use, " + _("%s: nickname \"%s\" is already in use, " "trying nickname #%d (\"%s\")"), - irc_buffer_get_server_prefix (server, NULL), IRC_PLUGIN_NAME, server->nick, nick_to_use + 1, server->nicks_array[nick_to_use]); @@ -4287,7 +4255,7 @@ irc_protocol_cmd_438 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s (%s => %s)", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4], argv[2], argv[3]); @@ -4297,7 +4265,7 @@ irc_protocol_cmd_438 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s %s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), argv[2], argv[3]); } @@ -4324,7 +4292,7 @@ irc_protocol_cmd_901 (struct t_irc_server *server, const char *command, weechat_printf_tags (server->buffer, irc_protocol_tags (command, "irc_numeric"), "%s%s", - irc_buffer_get_server_prefix (server, "network"), + weechat_prefix ("network"), (argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]); } else @@ -4522,12 +4490,11 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line, { weechat_printf (server->buffer, _("%s%s: command \"%s\" not found:"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, command); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + command); weechat_printf (server->buffer, "%s%s", - irc_buffer_get_server_prefix (server, "error"), - entire_line); + weechat_prefix ("error"), entire_line); return; } } @@ -4561,12 +4528,11 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line, weechat_printf (server->buffer, _("%s%s: failed to parse command \"%s\" (please " "report to developers):"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, command); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + command); weechat_printf (server->buffer, "%s%s", - irc_buffer_get_server_prefix (server, "error"), - entire_line); + weechat_prefix ("error"), entire_line); } /* send signal with received command */ diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h index db1fe18b4..0a36867e5 100644 --- a/src/plugins/irc/irc-protocol.h +++ b/src/plugins/irc/irc-protocol.h @@ -41,8 +41,8 @@ _("%s%s: too few arguments received from IRC " \ "server for command \"%s\" (received: %d " \ "arguments, expected: at least %d)"), \ - irc_buffer_get_server_prefix (server, "error"), \ - IRC_PLUGIN_NAME, command, argc, __min_args); \ + weechat_prefix ("error"), IRC_PLUGIN_NAME, \ + command, argc, __min_args); \ return WEECHAT_RC_ERROR; \ } @@ -52,8 +52,8 @@ weechat_printf (server->buffer, \ _("%s%s: \"%s\" command received without " \ "host"), \ - irc_buffer_get_server_prefix (server, "error"), \ - IRC_PLUGIN_NAME, command); \ + weechat_prefix ("error"), IRC_PLUGIN_NAME, \ + command); \ return WEECHAT_RC_ERROR; \ } diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index dc18745dc..774dc8cfc 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -53,9 +53,6 @@ struct t_irc_server *irc_servers = NULL; struct t_irc_server *last_irc_server = NULL; -/* current server when there is one buffer for all servers */ -struct t_irc_server *irc_current_server = NULL; - struct t_irc_message *irc_recv_msgq = NULL; struct t_irc_message *irc_msgq_last_msg = NULL; @@ -220,44 +217,6 @@ irc_server_set_nicks (struct t_irc_server *server, const char *nicks) } /* - * irc_server_buffer_set_highlight_words: set highlight words for buffer with - * all servers - */ - -void -irc_server_buffer_set_highlight_words (struct t_gui_buffer *buffer) -{ - struct t_irc_server *ptr_server; - int length; - char *words; - - length = 0; - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - if (ptr_server->is_connected && ptr_server->nick) - length += strlen (ptr_server->nick) + 1; - } - words = malloc (length + 1); - if (words) - { - words[0] = '\0'; - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - if (ptr_server->is_connected && ptr_server->nick) - { - if (words[0]) - strcat (words, ","); - strcat (words, ptr_server->nick); - } - } - weechat_buffer_set (buffer, "highlight_words", words); - free (words); - } -} - -/* * irc_server_set_nick: set nickname for a server */ @@ -270,10 +229,7 @@ irc_server_set_nick (struct t_irc_server *server, const char *nick) free (server->nick); server->nick = (nick) ? strdup (nick) : NULL; - if (weechat_config_boolean (irc_config_look_one_server_buffer)) - irc_server_buffer_set_highlight_words (server->buffer); - else - weechat_buffer_set (server->buffer, "highlight_words", nick); + weechat_buffer_set (server->buffer, "highlight_words", nick); /* set local variable "nick" for server and all channels/pv */ weechat_buffer_set (server->buffer, "localvar_set_nick", nick); @@ -635,48 +591,6 @@ irc_server_outqueue_free_all (struct t_irc_server *server) } /* - * irc_server_switch_next: swicth to next server - */ - -void -irc_server_switch_next () -{ - struct t_irc_server *ptr_server; - - if (irc_current_server) - { - ptr_server = irc_current_server->next_server; - if (!ptr_server) - ptr_server = irc_servers; - while (ptr_server != irc_current_server) - { - if (ptr_server->buffer) - { - irc_current_server = ptr_server; - break; - } - ptr_server = ptr_server->next_server; - if (!ptr_server) - ptr_server = irc_servers; - } - } - else - { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - if (ptr_server->buffer) - { - irc_current_server = ptr_server; - break; - } - } - } - if (irc_current_server) - irc_server_set_current_server (irc_current_server); -} - -/* * irc_server_free_data: free server data */ @@ -734,13 +648,6 @@ irc_server_free (struct t_irc_server *server) if (!server) return; - if (irc_current_server == server) - { - irc_server_switch_next (); - if (irc_current_server == server) - irc_current_server = NULL; - } - /* close all channels/privates */ irc_channel_free_all (server); @@ -958,8 +865,7 @@ irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf) _("%s%s: error sending data to IRC server: empty " "buffer (please report problem to " "developers)"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); return 0; } @@ -974,8 +880,8 @@ irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf) { weechat_printf (server->buffer, _("%s%s: error sending data to IRC server (%s)"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, strerror (errno)); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + strerror (errno)); } return rc; @@ -1351,8 +1257,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, const char *msg) { weechat_printf (server->buffer, _("%s%s: not enough memory for received message"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); return; } message->server = server; @@ -1364,8 +1269,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, const char *msg) { weechat_printf (server->buffer, _("%s%s: not enough memory for received message"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); } else { @@ -1412,8 +1316,7 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, const char *strin { weechat_printf (server->buffer, _("%s%s: not enough memory for received message"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); } else strcat (server->unterminated_message, string); @@ -1425,8 +1328,7 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, const char *strin { weechat_printf (server->buffer, _("%s%s: not enough memory for received message"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); } } } @@ -1646,8 +1548,7 @@ irc_server_recv_cb (void *arg_server, int fd) weechat_printf (server->buffer, _("%s%s: cannot read data from socket, " "disconnecting from server..."), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); irc_server_disconnect (server, 1); } @@ -1717,11 +1618,8 @@ irc_server_timer_cb (void *data, int remaining_calls) if (diff / 1000 > weechat_config_integer (irc_config_network_lag_disconnect) * 60) { weechat_printf (ptr_server->buffer, - _("%s%s: lag is high, " - "disconnecting from " - "server..."), - irc_buffer_get_server_prefix (ptr_server, - NULL), + _("%s: lag is high, disconnecting " + "from server..."), IRC_PLUGIN_NAME); irc_server_disconnect (ptr_server, 1); } @@ -1825,8 +1723,7 @@ irc_server_reconnect_schedule (struct t_irc_server *server) server->reconnect_start = time (NULL); delay = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY); weechat_printf (server->buffer, - _("%s%s: reconnecting to server in %d %s"), - irc_buffer_get_server_prefix (server, NULL), + _("%s: reconnecting to server in %d %s"), IRC_PLUGIN_NAME, delay, NG_("second", "seconds", delay)); @@ -1882,8 +1779,7 @@ irc_server_switch_address (struct t_irc_server *server) { server->index_current_address++; weechat_printf (server->buffer, - _("%s%s: switching address to %s/%d"), - irc_buffer_get_server_prefix (server, NULL), + _("%s: switching address to %s/%d"), IRC_PLUGIN_NAME, server->addresses_array[server->index_current_address], server->ports_array[server->index_current_address]); @@ -1918,8 +1814,7 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, free (server->current_ip); server->current_ip = (ip_address) ? strdup (ip_address) : NULL; weechat_printf (server->buffer, - _("%s%s: connected to %s (%s)"), - irc_buffer_get_server_prefix (server, NULL), + _("%s: connected to %s (%s)"), IRC_PLUGIN_NAME, server->addresses_array[server->index_current_address], (server->current_ip) ? server->current_ip : "?"); @@ -1934,15 +1829,13 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, (proxy && proxy[0]) ? _("%s%s: proxy address \"%s\" not found") : _("%s%s: address \"%s\" not found"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, server->addresses_array[server->index_current_address]); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -1953,14 +1846,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, (proxy && proxy[0]) ? _("%s%s: proxy IP address not found") : _("%s%s: IP address not found"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -1971,14 +1862,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, (proxy && proxy[0]) ? _("%s%s: proxy connection refused") : _("%s%s: connection refused"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -1991,14 +1880,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, "(check username/password if used " "and if server address/port is allowed by " "proxy)"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -2007,14 +1894,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, case WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR: weechat_printf (server->buffer, _("%s%s: unable to set local hostname/IP"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -2023,14 +1908,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, case WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR: weechat_printf (server->buffer, _("%s%s: TLS init error"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -2039,14 +1922,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, case WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR: weechat_printf (server->buffer, _("%s%s: TLS handshake failed"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -2055,14 +1936,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error, case WEECHAT_HOOK_CONNECT_MEMORY_ERROR: weechat_printf (server->buffer, _("%s%s: not enough memory"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); if (error && error[0]) { weechat_printf (server->buffer, _("%s%s: error: %s"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, + weechat_prefix ("error"), IRC_PLUGIN_NAME, error); } irc_server_close_connection (server); @@ -2112,36 +1991,36 @@ irc_server_set_buffer_title (struct t_irc_server *server) */ struct t_gui_buffer * -irc_server_create_buffer (struct t_irc_server *server, int all_servers) +irc_server_create_buffer (struct t_irc_server *server) { char buffer_name[256], charset_modifier[256]; + struct t_gui_buffer *ptr_buffer_for_merge; - if (all_servers) - { - snprintf (buffer_name, sizeof (buffer_name), - IRC_BUFFER_ALL_SERVERS_NAME); - } - else + ptr_buffer_for_merge = NULL; + switch (weechat_config_integer (irc_config_look_server_buffer)) { - snprintf (buffer_name, sizeof (buffer_name), - "server.%s", server->name); + case IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE: + /* merge with WeeChat core buffer */ + ptr_buffer_for_merge = weechat_buffer_search_main (); + break; + case IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITHOUT_CORE: + /* find buffer used to merge all IRC server buffers */ + ptr_buffer_for_merge = irc_buffer_search_first_for_all_servers (); + break; } + + snprintf (buffer_name, sizeof (buffer_name), + "server.%s", server->name); server->buffer = weechat_buffer_new (buffer_name, &irc_input_data_cb, NULL, &irc_buffer_close_cb, NULL); if (!server->buffer) return NULL; - weechat_buffer_set (server->buffer, "short_name", - (weechat_config_boolean (irc_config_look_one_server_buffer)) ? - IRC_BUFFER_ALL_SERVERS_NAME : server->name); + weechat_buffer_set (server->buffer, "short_name", server->name); weechat_buffer_set (server->buffer, "localvar_set_type", "server"); - weechat_buffer_set (server->buffer, "localvar_set_server", - (weechat_config_boolean (irc_config_look_one_server_buffer)) ? - IRC_BUFFER_ALL_SERVERS_NAME : server->name); - weechat_buffer_set (server->buffer, "localvar_set_channel", - (weechat_config_boolean (irc_config_look_one_server_buffer)) ? - IRC_BUFFER_ALL_SERVERS_NAME : server->name); + weechat_buffer_set (server->buffer, "localvar_set_server", server->name); + weechat_buffer_set (server->buffer, "localvar_set_channel", server->name); snprintf (charset_modifier, sizeof (charset_modifier), "irc.%s", server->name); weechat_buffer_set (server->buffer, "localvar_set_charset_modifier", @@ -2165,29 +2044,11 @@ irc_server_create_buffer (struct t_irc_server *server, int all_servers) irc_server_set_buffer_title (server); - return server->buffer; -} - -/* - * irc_server_set_current_server: set new current server (when all servers are - * in one buffer) - */ - -void -irc_server_set_current_server (struct t_irc_server *server) -{ - char charset_modifier[256]; - - irc_current_server = server; + /* merge buffer if needed */ + if (ptr_buffer_for_merge) + weechat_buffer_merge (server->buffer, ptr_buffer_for_merge); - irc_server_set_buffer_title (irc_current_server); - snprintf (charset_modifier, sizeof (charset_modifier), - "irc.%s", irc_current_server->name); - weechat_buffer_set (irc_current_server->buffer, - "localvar_set_charset_modifier", - charset_modifier); - weechat_bar_item_update ("buffer_name"); - weechat_bar_item_update ("input_prompt"); + return server->buffer; } /* @@ -2200,40 +2061,16 @@ int irc_server_connect (struct t_irc_server *server) { int set, length; - char *option_name, charset_modifier[256]; + char *option_name; struct t_config_option *proxy_type, *proxy_ipv6, *proxy_address, *proxy_port; const char *proxy, *str_proxy_type, *str_proxy_address; if (!server->buffer) { - if (weechat_config_boolean (irc_config_look_one_server_buffer) - && irc_buffer_servers) - { - server->buffer = irc_buffer_servers; - irc_server_set_buffer_title (server); - } - else - { - if (!irc_server_create_buffer (server, - weechat_config_boolean (irc_config_look_one_server_buffer))) - return 0; - } - - if (weechat_config_boolean (irc_config_look_one_server_buffer)) - { - irc_current_server = server; - if (!irc_buffer_servers) - irc_buffer_servers = server->buffer; - - snprintf (charset_modifier, sizeof (charset_modifier), - "irc.%s", irc_current_server->name); - weechat_buffer_set (irc_buffer_servers, - "localvar_set_charset_modifier", - charset_modifier); - } + if (!irc_server_create_buffer (server)) + return 0; weechat_buffer_set (server->buffer, "display", "auto"); - weechat_bar_item_update ("buffer_name"); } @@ -2242,8 +2079,8 @@ irc_server_connect (struct t_irc_server *server) weechat_printf (server->buffer, _("%s%s: addresses not defined for server \"%s\", " "cannot connect"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, server->name); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + server->name); return 0; } @@ -2263,8 +2100,7 @@ irc_server_connect (struct t_irc_server *server) { weechat_printf (server->buffer, _("%s%s: not enough memory"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); return 0; } snprintf (option_name, length, "weechat.proxy.%s.type", proxy); @@ -2281,8 +2117,8 @@ irc_server_connect (struct t_irc_server *server) weechat_printf (server->buffer, _("%s%s: proxy \"%s\" not found for server " "\"%s\", cannot connect"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, proxy, server->name); + weechat_prefix ("error"), IRC_PLUGIN_NAME, proxy, + server->name); return 0; } str_proxy_type = weechat_config_string (proxy_type); @@ -2293,8 +2129,7 @@ irc_server_connect (struct t_irc_server *server) weechat_printf (server->buffer, _("%s%s: missing proxy settings, check options " "for proxy \"%s\""), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, proxy); + weechat_prefix ("error"), IRC_PLUGIN_NAME, proxy); return 0; } } @@ -2304,8 +2139,8 @@ irc_server_connect (struct t_irc_server *server) weechat_printf (server->buffer, _("%s%s: nicks not defined for server \"%s\", " "cannot connect"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME, server->name); + weechat_prefix ("error"), IRC_PLUGIN_NAME, + server->name); return 0; } @@ -2315,17 +2150,15 @@ irc_server_connect (struct t_irc_server *server) weechat_printf (server->buffer, _("%s%s: cannot connect with SSL because WeeChat " "was not built with GnuTLS support"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); return 0; } #endif if (proxy_type) { weechat_printf (server->buffer, - _("%s%s: connecting to server %s/%d%s%s via %s " + _("%s: connecting to server %s/%d%s%s via %s " "proxy %s/%d%s..."), - irc_buffer_get_server_prefix (server, NULL), IRC_PLUGIN_NAME, server->addresses_array[server->index_current_address], server->ports_array[server->index_current_address], @@ -2353,8 +2186,7 @@ irc_server_connect (struct t_irc_server *server) else { weechat_printf (server->buffer, - _("%s%s: connecting to server %s/%d%s%s..."), - irc_buffer_get_server_prefix (server, NULL), + _("%s: connecting to server %s/%d%s%s..."), IRC_PLUGIN_NAME, server->addresses_array[server->index_current_address], server->ports_array[server->index_current_address], @@ -2393,8 +2225,7 @@ irc_server_connect (struct t_irc_server *server) { weechat_printf (server->buffer, _("%s%s: cannot create socket"), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); return 0; } @@ -2406,8 +2237,7 @@ irc_server_connect (struct t_irc_server *server) weechat_printf (server->buffer, _("%s%s: cannot set socket option " "\"SO_REUSEADDR\""), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); } /* set SO_KEEPALIVE option for socket */ @@ -2418,8 +2248,7 @@ irc_server_connect (struct t_irc_server *server) weechat_printf (server->buffer, _("%s%s: cannot set socket option " "\"SO_KEEPALIVE\""), - irc_buffer_get_server_prefix (server, "error"), - IRC_PLUGIN_NAME); + weechat_prefix ("error"), IRC_PLUGIN_NAME); } /* init SSL if asked */ @@ -2458,8 +2287,7 @@ void irc_server_reconnect (struct t_irc_server *server) { weechat_printf (server->buffer, - _("%s%s: reconnecting to server..."), - irc_buffer_get_server_prefix (server, NULL), + _("%s: reconnecting to server..."), IRC_PLUGIN_NAME); server->reconnect_start = 0; server->index_current_address = 0; @@ -2519,8 +2347,7 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect) if (server->buffer) { weechat_printf (server->buffer, - _("%s%s: disconnected from server"), - irc_buffer_get_server_prefix (server, NULL), + _("%s: disconnected from server"), IRC_PLUGIN_NAME); } @@ -3023,11 +2850,6 @@ irc_server_add_to_infolist (struct t_infolist *infolist, (server->buffer) ? weechat_buffer_get_string (server->buffer, "short_name") : "")) return 0; - if (!weechat_infolist_new_var_integer (ptr_item, "selected", - (weechat_config_boolean (irc_config_look_one_server_buffer) - && (irc_current_server != server)) ? - 0 : 1)) - return 0; if (!weechat_infolist_new_var_string (ptr_item, "addresses", IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES))) return 0; diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 49344adc0..23ec2f30c 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -153,7 +153,6 @@ struct t_irc_message }; extern struct t_irc_server *irc_servers; -extern struct t_irc_server *irc_current_server; #ifdef HAVE_GNUTLS extern const int gnutls_cert_type_prio[]; extern const int gnutls_prot_prio[]; @@ -168,11 +167,9 @@ extern char *irc_server_get_name_without_port (const char *name); extern void irc_server_set_addresses (struct t_irc_server *server, const char *addresses); extern void irc_server_set_nicks (struct t_irc_server *server, const char *nicks); -extern void irc_server_buffer_set_highlight_words (struct t_gui_buffer *buffer); extern void irc_server_set_nick (struct t_irc_server *server, const char *nick); extern struct t_irc_server *irc_server_alloc (const char *name); extern int irc_server_alloc_with_url (const char *irc_url); -extern void irc_server_switch_next (); extern void irc_server_free_all (); extern struct t_irc_server *irc_server_copy (struct t_irc_server *server, const char *new_name); @@ -184,9 +181,7 @@ extern void irc_server_sendf (struct t_irc_server *server, int queue_msg, 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, - int all_servers); -extern void irc_server_set_current_server (struct t_irc_server *server); +extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server); extern int irc_server_connect (struct t_irc_server *server); extern void irc_server_auto_connect (); extern void irc_server_autojoin_channels (); diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index 01bbad4a9..cacc9ed19 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -226,16 +226,7 @@ irc_upgrade_read_cb (void *data, ptr_buffer = weechat_buffer_search (IRC_PLUGIN_NAME, buffer_name); if (ptr_buffer) - { irc_upgrade_current_server->buffer = ptr_buffer; - if (weechat_config_boolean (irc_config_look_one_server_buffer) - && !irc_buffer_servers) - { - irc_buffer_servers = ptr_buffer; - } - if (weechat_infolist_integer (infolist, "selected")) - irc_current_server = irc_upgrade_current_server; - } } irc_upgrade_current_server->index_current_address = weechat_infolist_integer (infolist, "index_current_address"); diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c index f36956b3d..d349fe7b7 100644 --- a/src/plugins/irc/irc.c +++ b/src/plugins/irc/irc.c @@ -113,7 +113,7 @@ irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data, weechat_printf (ptr_server->buffer, _("%s%s: disconnecting from server because upgrade " "can't work for servers connected via SSL"), - irc_buffer_get_server_prefix (ptr_server, "error"), + weechat_prefix ("error"), IRC_PLUGIN_NAME); irc_server_disconnect (ptr_server, 0); /* schedule reconnection: WeeChat will reconnect to this server |