diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-02-23 14:54:07 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-02-23 14:54:07 +0100 |
commit | 9beb263e4ae6c65a3e653bfd7c69572de2963cf1 (patch) | |
tree | a21e6d73f9e3f707234bfc2d5577f652984ded95 /src | |
parent | c17d3e155ca4b339de9b863087422b943bf1410b (diff) | |
download | weechat-9beb263e4ae6c65a3e653bfd7c69572de2963cf1.zip |
irc: hide passwords in commands or messages sent to nickserv with modifiers (bug #38346)
New modifiers: "irc_command_auth" and "irc_message_auth".
Option removed: irc.look.hide_nickserv_pwd
New option: irc.look.nicks_hide_password
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plugins/irc/Makefile.am | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 423 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 56 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-display.c | 481 | ||||
-rw-r--r-- | src/plugins/irc/irc-display.h | 28 |
7 files changed, 463 insertions, 532 deletions
diff --git a/src/plugins/irc/CMakeLists.txt b/src/plugins/irc/CMakeLists.txt index 447eba482..11c712a25 100644 --- a/src/plugins/irc/CMakeLists.txt +++ b/src/plugins/irc/CMakeLists.txt @@ -28,7 +28,6 @@ irc-completion.c irc-completion.h irc-config.c irc-config.h irc-ctcp.c irc-ctcp.h irc-debug.c irc-debug.h -irc-display.c irc-display.h irc-ignore.c irc-ignore.h irc-info.c irc-info.h irc-input.c irc-input.h diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am index 4ddbad8b9..e99cafd45 100644 --- a/src/plugins/irc/Makefile.am +++ b/src/plugins/irc/Makefile.am @@ -43,8 +43,6 @@ irc_la_SOURCES = irc.c \ irc-ctcp.h \ irc-debug.c \ irc-debug.h \ - irc-display.c \ - irc-display.h \ irc-ignore.c \ irc-ignore.h \ irc-info.c \ diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index e9e147859..9c27fa4a7 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -37,7 +37,6 @@ #include "irc-channel.h" #include "irc-color.h" #include "irc-config.h" -#include "irc-display.h" #include "irc-ignore.h" #include "irc-input.h" #include "irc-msgbuffer.h" @@ -45,6 +44,7 @@ #include "irc-notify.h" #include "irc-protocol.h" #include "irc-raw.h" +#include "irc-sasl.h" #include "irc-server.h" @@ -419,6 +419,35 @@ irc_command_me_all_channels (struct t_irc_server *server, const char *arguments) } /* + * Displays away on all channels of all servers. + */ + +void +irc_command_display_away (struct t_irc_server *server, const char *string1, + const char *string2) +{ + struct t_irc_channel *ptr_channel; + + for (ptr_channel = server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) + { + weechat_printf_tags (ptr_channel->buffer, + "away_info", + "%s[%s%s%s %s: %s%s]", + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK_SELF, + server->nick, + IRC_COLOR_RESET, + string1, + string2, + IRC_COLOR_CHAT_DELIMITERS); + } + } +} + +/* * Toggles away status for one server. */ @@ -451,8 +480,10 @@ 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)); if (weechat_config_integer (irc_config_look_display_away) == IRC_CONFIG_DISPLAY_AWAY_LOCAL) - irc_display_away (server, "away", - (string) ? string : arguments); + { + irc_command_display_away (server, "away", + (string) ? string : arguments); + } else { snprintf (buffer, sizeof (buffer), "is away: %s", @@ -525,7 +556,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments, (long int)(elapsed / 3600), (long int)((elapsed / 60) % 60), (long int)(elapsed % 60)); - irc_display_away (server, "back", buffer); + irc_command_display_away (server, "back", buffer); } else { @@ -2634,7 +2665,8 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { char **targets; - int num_targets, i, arg_target, arg_text, is_channel, msg_op_voice; + int num_targets, i, j, arg_target, arg_text, is_channel, msg_op_voice; + int hide_password; char *msg_pwd_hidden; char *string; @@ -2752,13 +2784,26 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc, } else { - /* message to nickserv with identify ? */ - if (weechat_strcasecmp (targets[i], "nickserv") == 0) + /* check if the password must be hidden for this nick */ + hide_password = 0; + if (irc_config_nicks_hide_password) { - msg_pwd_hidden = strdup (argv_eol[arg_text]); - if (msg_pwd_hidden - && (weechat_config_boolean (irc_config_look_hide_nickserv_pwd))) - irc_display_hide_password (msg_pwd_hidden, 0); + for (j = 0; j < irc_config_num_nicks_hide_password; j++) + { + if (weechat_strcasecmp (irc_config_nicks_hide_password[j], + targets[i]) == 0) + { + hide_password = 1; + break; + } + } + } + if (hide_password) + { + /* hide password in message displayed using modifier */ + msg_pwd_hidden = weechat_hook_modifier_exec ("irc_message_auth", + ptr_server->name, + argv_eol[arg_text]); string = irc_color_decode ( (msg_pwd_hidden) ? msg_pwd_hidden : argv_eol[arg_text], weechat_config_boolean (irc_config_network_colors_receive)); @@ -3946,6 +3991,358 @@ irc_command_saquit (void *data, struct t_gui_buffer *buffer, int argc, } /* + * Displays server options. + */ + +void +irc_command_display_server (struct t_irc_server *server, int with_detail) +{ + char *cmd_pwd_hidden; + int num_channels, num_pv; + + if (with_detail) + { + weechat_printf (NULL, ""); + weechat_printf (NULL, _("Server: %s%s %s[%s%s%s]%s%s"), + IRC_COLOR_CHAT_SERVER, + server->name, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (server->is_connected) ? + _("connected") : _("not connected"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (server->temp_server) ? _(" (temporary)") : ""); + /* addresses */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ADDRESSES])) + weechat_printf (NULL, " addresses. . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES)); + else + weechat_printf (NULL, " addresses. . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_ADDRESSES])); + /* proxy */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PROXY])) + weechat_printf (NULL, " proxy. . . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY)); + else + weechat_printf (NULL, " proxy. . . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_PROXY])); + /* ipv6 */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_IPV6])) + weechat_printf (NULL, " ipv6 . . . . . . . . : (%s)", + (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6)) ? + _("on") : _("off")); + else + weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ? + _("on") : _("off")); + /* ssl */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL])) + weechat_printf (NULL, " ssl. . . . . . . . . : (%s)", + (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL)) ? + _("on") : _("off")); + else + weechat_printf (NULL, " ssl. . . . . . . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ? + _("on") : _("off")); + /* ssl_cert */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_CERT])) + weechat_printf (NULL, " ssl_cert . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SSL_CERT)); + else + weechat_printf (NULL, " ssl_cert . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_SSL_CERT])); + /* ssl_priorities */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_PRIORITIES])) + weechat_printf (NULL, " ssl_priorities . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SSL_PRIORITIES)); + else + weechat_printf (NULL, " ssl_priorities . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_SSL_PRIORITIES])); + /* ssl_dhkey_size */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE])) + weechat_printf (NULL, " ssl_dhkey_size . . . : (%d)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE)); + else + weechat_printf (NULL, " ssl_dhkey_size . . . : %s%d", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE])); + /* ssl_verify */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_VERIFY])) + weechat_printf (NULL, " ssl_verify . . . . . : (%s)", + (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL_VERIFY)) ? + _("on") : _("off")); + else + weechat_printf (NULL, " ssl_verify . . . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ? + _("on") : _("off")); + /* password */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD])) + weechat_printf (NULL, " password . . . . . . : %s", + _("(hidden)")); + else + weechat_printf (NULL, " password . . . . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + _("(hidden)")); + /* client capabilities */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_CAPABILITIES])) + weechat_printf (NULL, " capabilities . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CAPABILITIES)); + else + weechat_printf (NULL, " capabilities . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_CAPABILITIES])); + /* sasl_mechanism */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_MECHANISM])) + weechat_printf (NULL, " sasl_mechanism . . . : ('%s')", + irc_sasl_mechanism_string[IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_MECHANISM)]); + else + weechat_printf (NULL, " sasl_mechanism . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + irc_sasl_mechanism_string[weechat_config_integer (server->options[IRC_SERVER_OPTION_SASL_MECHANISM])]); + /* sasl_username */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_USERNAME])) + weechat_printf (NULL, " sasl_username. . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SASL_USERNAME)); + else + weechat_printf (NULL, " sasl_username. . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_SASL_USERNAME])); + /* sasl_password */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_PASSWORD])) + weechat_printf (NULL, " sasl_password. . . . : %s", + _("(hidden)")); + else + weechat_printf (NULL, " sasl_password. . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + _("(hidden)")); + /* autoconnect */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOCONNECT])) + weechat_printf (NULL, " autoconnect. . . . . : (%s)", + (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOCONNECT)) ? + _("on") : _("off")); + else + weechat_printf (NULL, " autoconnect. . . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ? + _("on") : _("off")); + /* autoreconnect */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT])) + weechat_printf (NULL, " autoreconnect. . . . : (%s)", + (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTORECONNECT)) ? + _("on") : _("off")); + else + weechat_printf (NULL, " autoreconnect. . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ? + _("on") : _("off")); + /* autoreconnect_delay */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY])) + weechat_printf (NULL, " autoreconnect_delay. : (%d %s)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY), + NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY))); + else + weechat_printf (NULL, " autoreconnect_delay. : %s%d %s", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]), + NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))); + /* nicks */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS])) + weechat_printf (NULL, " nicks. . . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS)); + else + weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS])); + /* username */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME])) + weechat_printf (NULL, " username . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME)); + else + weechat_printf (NULL, " username . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_USERNAME])); + /* realname */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_REALNAME])) + weechat_printf (NULL, " realname . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME)); + else + weechat_printf (NULL, " realname . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_REALNAME])); + /* local_hostname */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME])) + weechat_printf (NULL, " local_hostname . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME)); + else + weechat_printf (NULL, " local_hostname . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME])); + /* command */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND])) + { + cmd_pwd_hidden = weechat_hook_modifier_exec ("irc_command_auth", + server->name, + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND)); + weechat_printf (NULL, " command. . . . . . . : ('%s')", + (cmd_pwd_hidden) ? cmd_pwd_hidden : IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND)); + if (cmd_pwd_hidden) + free (cmd_pwd_hidden); + } + else + { + cmd_pwd_hidden = weechat_hook_modifier_exec ("irc_command_auth", + server->name, + weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND])); + weechat_printf (NULL, " command. . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + (cmd_pwd_hidden) ? cmd_pwd_hidden : weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND])); + if (cmd_pwd_hidden) + free (cmd_pwd_hidden); + } + /* command_delay */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND_DELAY])) + weechat_printf (NULL, " command_delay. . . . : (%d %s)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY), + NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY))); + else + weechat_printf (NULL, " command_delay. . . . : %s%d %s", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]), + NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]))); + /* autojoin */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOJOIN])) + weechat_printf (NULL, " autojoin . . . . . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN)); + else + weechat_printf (NULL, " autojoin . . . . . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_AUTOJOIN])); + /* autorejoin */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN])) + weechat_printf (NULL, " autorejoin . . . . . : (%s)", + (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOREJOIN)) ? + _("on") : _("off")); + else + weechat_printf (NULL, " autorejoin . . . . . : %s%s", + IRC_COLOR_CHAT_VALUE, + weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ? + _("on") : _("off")); + /* autorejoin_delay */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY])) + weechat_printf (NULL, " autorejoin_delay . . : (%d %s)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY), + NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY))); + else + weechat_printf (NULL, " autorejoin_delay . . : %s%d %s", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]), + NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))); + /* connection_timeout */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT])) + weechat_printf (NULL, " connection_timeout . : (%d %s)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT), + NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT))); + else + weechat_printf (NULL, " connection_timeout . : %s%d %s", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]), + NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]))); + /* anti_flood_prio_high */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH])) + weechat_printf (NULL, " anti_flood_prio_high : (%d %s)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH), + NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH))); + else + weechat_printf (NULL, " anti_flood_prio_high : %s%d %s", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]), + NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]))); + /* anti_flood_prio_low */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW])) + weechat_printf (NULL, " anti_flood_prio_low. : (%d %s)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW), + NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW))); + else + weechat_printf (NULL, " anti_flood_prio_low. : %s%d %s", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]), + NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]))); + /* away_check */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AWAY_CHECK])) + weechat_printf (NULL, " away_check . . . . . : (%d %s)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK), + NG_("minute", "minutes", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK))); + else + weechat_printf (NULL, " away_check . . . . . : %s%d %s", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK]), + NG_("minute", "minutes", weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK]))); + /* away_check_max_nicks */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS])) + weechat_printf (NULL, " away_check_max_nicks : (%d)", + IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS)); + else + weechat_printf (NULL, " away_check_max_nicks : %s%d", + IRC_COLOR_CHAT_VALUE, + weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS])); + /* default_msg_part */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])) + weechat_printf (NULL, " default_msg_part . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART)); + else + weechat_printf (NULL, " default_msg_part . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])); + /* default_msg_quit */ + if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])) + weechat_printf (NULL, " default_msg_quit . . : ('%s')", + IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT)); + else + weechat_printf (NULL, " default_msg_quit . . : %s'%s'", + IRC_COLOR_CHAT_VALUE, + weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])); + } + else + { + if (server->is_connected) + { + num_channels = irc_server_get_channel_count (server); + num_pv = irc_server_get_pv_count (server); + weechat_printf (NULL, " %s %s%s %s[%s%s%s]%s%s, %d %s, %d pv", + (server->is_connected) ? "*" : " ", + IRC_COLOR_CHAT_SERVER, + server->name, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (server->is_connected) ? + _("connected") : _("not connected"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + (server->temp_server) ? _(" (temporary)") : "", + num_channels, + NG_("channel", "channels", num_channels), + num_pv); + } + else + { + weechat_printf (NULL, " %s%s%s%s", + IRC_COLOR_CHAT_SERVER, + server->name, + IRC_COLOR_RESET, + (server->temp_server) ? _(" (temporary)") : ""); + } + } +} + +/* * Callback for command "/server": manages IRC servers. */ @@ -3992,7 +4389,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, for (ptr_server2 = irc_servers; ptr_server2; ptr_server2 = ptr_server2->next_server) { - irc_display_server (ptr_server2, detailed_list); + irc_command_display_server (ptr_server2, detailed_list); } } else @@ -4014,7 +4411,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, server_name); } one_server_found = 1; - irc_display_server (ptr_server2, detailed_list); + irc_command_display_server (ptr_server2, detailed_list); } } if (!one_server_found) diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 9c9d40bad..d7f90517b 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -79,13 +79,13 @@ struct t_config_option *irc_config_look_item_away_message; struct t_config_option *irc_config_look_item_channel_modes_hide_key; struct t_config_option *irc_config_look_item_nick_modes; struct t_config_option *irc_config_look_item_nick_prefix; -struct t_config_option *irc_config_look_hide_nickserv_pwd; struct t_config_option *irc_config_look_highlight_server; struct t_config_option *irc_config_look_highlight_channel; struct t_config_option *irc_config_look_highlight_pv; struct t_config_option *irc_config_look_highlight_tags; struct t_config_option *irc_config_look_item_display_server; struct t_config_option *irc_config_look_msgbuffer_fallback; +struct t_config_option *irc_config_look_nicks_hide_password; struct t_config_option *irc_config_look_notice_as_pv; struct t_config_option *irc_config_look_notify_tags_ison; struct t_config_option *irc_config_look_notify_tags_whois; @@ -143,6 +143,8 @@ int irc_config_num_nick_colors = 0; struct t_hashtable *irc_config_hashtable_nick_color_force = NULL; struct t_hashtable *irc_config_hashtable_nick_prefixes = NULL; struct t_hashtable *irc_config_hashtable_color_mirc_remap = NULL; +char **irc_config_nicks_hide_password = NULL; +int irc_config_num_nicks_hide_password = 0; int irc_config_write_temp_servers = 0; @@ -491,6 +493,36 @@ irc_config_change_look_item_display_server (void *data, } /* + * Callback for changes on option "irc.look.nicks_hide_password". + */ + +void +irc_config_change_look_nicks_hide_password (void *data, + struct t_config_option *option) +{ + const char *nicks_hide_password; + + /* make C compiler happy */ + (void) data; + (void) option; + + if (irc_config_nicks_hide_password) + { + weechat_string_free_split (irc_config_nicks_hide_password); + irc_config_nicks_hide_password = NULL; + } + irc_config_num_nicks_hide_password = 0; + + nicks_hide_password = weechat_config_string (irc_config_look_nicks_hide_password); + if (nicks_hide_password && nicks_hide_password[0]) + { + irc_config_nicks_hide_password = weechat_string_split (nicks_hide_password, + ",", 0, 0, + &irc_config_num_nicks_hide_password); + } +} + +/* * Callback for changes on option "irc.look.topic_strip_colors". */ @@ -2195,11 +2227,6 @@ irc_config_init () N_("display nick prefix in \"input_prompt\" bar item"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, &irc_config_change_look_item_nick_prefix, NULL, NULL, NULL); - irc_config_look_hide_nickserv_pwd = weechat_config_new_option ( - irc_config_file, ptr_section, - "hide_nickserv_pwd", "boolean", - N_("hide password displayed by nickserv"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_highlight_server = weechat_config_new_option ( irc_config_file, ptr_section, "highlight_server", "string", @@ -2257,6 +2284,15 @@ irc_config_init () "private and that private buffer is not found"), "current|server", 0, 0, "current", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_nicks_hide_password = weechat_config_new_option ( + irc_config_file, ptr_section, + "nicks_hide_password", "string", + N_("comma separated list of nicks for which passwords will be hidden " + "when a message is sent, for example to hide password in message " + "displayed by \"/msg nickserv identify password\", example: " + "\"nickserv,nickbot\""), + NULL, 0, 0, "nickserv", NULL, 0, NULL, NULL, + &irc_config_change_look_nicks_hide_password, NULL, NULL, NULL); irc_config_look_notice_as_pv = weechat_config_new_option ( irc_config_file, ptr_section, "notice_as_pv", "integer", @@ -2647,6 +2683,7 @@ irc_config_read () { irc_notify_new_for_all_servers (); irc_config_change_look_nick_color_force (NULL, NULL); + irc_config_change_look_nicks_hide_password (NULL, NULL); irc_config_change_color_nick_prefixes (NULL, NULL); irc_config_change_color_mirc_remap (NULL, NULL); irc_config_change_network_notify_check_ison (NULL, NULL); @@ -2688,6 +2725,13 @@ irc_config_free () irc_config_num_nick_colors = 0; } + if (irc_config_nicks_hide_password) + { + weechat_string_free_split (irc_config_nicks_hide_password); + irc_config_nicks_hide_password = NULL; + irc_config_num_nicks_hide_password = 0; + } + if (irc_config_hashtable_nick_color_force) { weechat_hashtable_free (irc_config_hashtable_nick_color_force); diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 0f0d3d45c..c14aabb05 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -114,13 +114,13 @@ extern struct t_config_option *irc_config_look_item_away_message; extern struct t_config_option *irc_config_look_item_channel_modes_hide_key; extern struct t_config_option *irc_config_look_item_nick_modes; extern struct t_config_option *irc_config_look_item_nick_prefix; -extern struct t_config_option *irc_config_look_hide_nickserv_pwd; extern struct t_config_option *irc_config_look_highlight_server; extern struct t_config_option *irc_config_look_highlight_channel; extern struct t_config_option *irc_config_look_highlight_pv; extern struct t_config_option *irc_config_look_highlight_tags; extern struct t_config_option *irc_config_look_item_display_server; extern struct t_config_option *irc_config_look_msgbuffer_fallback; +extern struct t_config_option *irc_config_look_nicks_hide_password; extern struct t_config_option *irc_config_look_notice_as_pv; extern struct t_config_option *irc_config_look_notify_tags_ison; extern struct t_config_option *irc_config_look_notify_tags_whois; @@ -172,6 +172,8 @@ extern int irc_config_num_nick_colors; extern struct t_hashtable *irc_config_hashtable_nick_color_force; extern struct t_hashtable *irc_config_hashtable_nick_prefixes; extern struct t_hashtable *irc_config_hashtable_color_mirc_remap; +extern char **irc_config_nicks_hide_password; +extern int irc_config_num_nicks_hide_password; extern void irc_config_set_nick_colors (); extern int irc_config_server_check_value_cb (void *data, diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c deleted file mode 100644 index 99ec7cc35..000000000 --- a/src/plugins/irc/irc-display.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * irc-display.c - display functions for IRC plugin - * - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * WeeChat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> - -#include "../weechat-plugin.h" -#include "irc.h" -#include "irc-channel.h" -#include "irc-color.h" -#include "irc-command.h" -#include "irc-config.h" -#include "irc-nick.h" -#include "irc-server.h" -#include "irc-sasl.h" - - -/* - * Hides IRC password(s) in a string. - */ - -void -irc_display_hide_password (char *string, int look_for_nickserv) -{ - char *pos_nickserv, *pos, *pos_pwd; - int char_size; - - pos = string; - while (pos) - { - if (look_for_nickserv) - { - pos_nickserv = strstr (pos, "nickserv "); - if (!pos_nickserv) - return; - pos = pos_nickserv + 9; - while (pos[0] == ' ') - { - pos++; - } - if (strncmp (pos, "identify ", 9) == 0) - pos_pwd = pos + 9; - else if (strncmp (pos, "register ", 9) == 0) - pos_pwd = pos + 9; - else - pos_pwd = NULL; - } - else - { - pos_pwd = strstr (pos, "identify "); - if (pos_pwd) - pos_pwd += 9; - else - { - pos_pwd = strstr (pos, "register "); - if (pos_pwd) - pos_pwd += 9; - } - if (!pos_pwd) - return; - } - - if (pos_pwd) - { - while (pos_pwd[0] == ' ') - { - pos_pwd++; - } - - while (pos_pwd && pos_pwd[0]) - { - char_size = weechat_utf8_char_size (pos_pwd); - if (char_size > 0) - memset (pos_pwd, '*', char_size); - pos_pwd = weechat_utf8_next_char (pos_pwd); - } - pos = pos_pwd; - } - } -} - -/* - * Displays away on all channels of all servers. - */ - -void -irc_display_away (struct t_irc_server *server, const char *string1, - const char *string2) -{ - struct t_irc_channel *ptr_channel; - - for (ptr_channel = server->channels; ptr_channel; - ptr_channel = ptr_channel->next_channel) - { - if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) - { - weechat_printf_tags (ptr_channel->buffer, - "away_info", - "%s[%s%s%s %s: %s%s]", - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK_SELF, - server->nick, - IRC_COLOR_RESET, - string1, - string2, - IRC_COLOR_CHAT_DELIMITERS); - } - } -} - -/* - * Displays server options. - */ - -void -irc_display_server (struct t_irc_server *server, int with_detail) -{ - char *string; - int num_channels, num_pv; - - if (with_detail) - { - weechat_printf (NULL, ""); - weechat_printf (NULL, _("Server: %s%s %s[%s%s%s]%s%s"), - IRC_COLOR_CHAT_SERVER, - server->name, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (server->is_connected) ? - _("connected") : _("not connected"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (server->temp_server) ? _(" (temporary)") : ""); - /* addresses */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ADDRESSES])) - weechat_printf (NULL, " addresses. . . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES)); - else - weechat_printf (NULL, " addresses. . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_ADDRESSES])); - /* proxy */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PROXY])) - weechat_printf (NULL, " proxy. . . . . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY)); - else - weechat_printf (NULL, " proxy. . . . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_PROXY])); - /* ipv6 */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_IPV6])) - weechat_printf (NULL, " ipv6 . . . . . . . . : (%s)", - (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6)) ? - _("on") : _("off")); - else - weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ? - _("on") : _("off")); - /* ssl */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL])) - weechat_printf (NULL, " ssl. . . . . . . . . : (%s)", - (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL)) ? - _("on") : _("off")); - else - weechat_printf (NULL, " ssl. . . . . . . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ? - _("on") : _("off")); - /* ssl_cert */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_CERT])) - weechat_printf (NULL, " ssl_cert . . . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SSL_CERT)); - else - weechat_printf (NULL, " ssl_cert . . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_SSL_CERT])); - /* ssl_priorities */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_PRIORITIES])) - weechat_printf (NULL, " ssl_priorities . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SSL_PRIORITIES)); - else - weechat_printf (NULL, " ssl_priorities . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_SSL_PRIORITIES])); - /* ssl_dhkey_size */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE])) - weechat_printf (NULL, " ssl_dhkey_size . . . : (%d)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SSL_DHKEY_SIZE)); - else - weechat_printf (NULL, " ssl_dhkey_size . . . : %s%d", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_SSL_DHKEY_SIZE])); - /* ssl_verify */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL_VERIFY])) - weechat_printf (NULL, " ssl_verify . . . . . : (%s)", - (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_SSL_VERIFY)) ? - _("on") : _("off")); - else - weechat_printf (NULL, " ssl_verify . . . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL_VERIFY]) ? - _("on") : _("off")); - /* password */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD])) - weechat_printf (NULL, " password . . . . . . : %s", - _("(hidden)")); - else - weechat_printf (NULL, " password . . . . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - _("(hidden)")); - /* client capabilities */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_CAPABILITIES])) - weechat_printf (NULL, " capabilities . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CAPABILITIES)); - else - weechat_printf (NULL, " capabilities . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_CAPABILITIES])); - /* sasl_mechanism */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_MECHANISM])) - weechat_printf (NULL, " sasl_mechanism . . . : ('%s')", - irc_sasl_mechanism_string[IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_SASL_MECHANISM)]); - else - weechat_printf (NULL, " sasl_mechanism . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - irc_sasl_mechanism_string[weechat_config_integer (server->options[IRC_SERVER_OPTION_SASL_MECHANISM])]); - /* sasl_username */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_USERNAME])) - weechat_printf (NULL, " sasl_username. . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_SASL_USERNAME)); - else - weechat_printf (NULL, " sasl_username. . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_SASL_USERNAME])); - /* sasl_password */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SASL_PASSWORD])) - weechat_printf (NULL, " sasl_password. . . . : %s", - _("(hidden)")); - else - weechat_printf (NULL, " sasl_password. . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - _("(hidden)")); - /* autoconnect */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOCONNECT])) - weechat_printf (NULL, " autoconnect. . . . . : (%s)", - (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOCONNECT)) ? - _("on") : _("off")); - else - weechat_printf (NULL, " autoconnect. . . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ? - _("on") : _("off")); - /* autoreconnect */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT])) - weechat_printf (NULL, " autoreconnect. . . . : (%s)", - (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTORECONNECT)) ? - _("on") : _("off")); - else - weechat_printf (NULL, " autoreconnect. . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ? - _("on") : _("off")); - /* autoreconnect_delay */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY])) - weechat_printf (NULL, " autoreconnect_delay. : (%d %s)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY), - NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY))); - else - weechat_printf (NULL, " autoreconnect_delay. : %s%d %s", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]), - NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))); - /* nicks */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS])) - weechat_printf (NULL, " nicks. . . . . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS)); - else - weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS])); - /* username */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME])) - weechat_printf (NULL, " username . . . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME)); - else - weechat_printf (NULL, " username . . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_USERNAME])); - /* realname */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_REALNAME])) - weechat_printf (NULL, " realname . . . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME)); - else - weechat_printf (NULL, " realname . . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_REALNAME])); - /* local_hostname */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME])) - weechat_printf (NULL, " local_hostname . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME)); - else - weechat_printf (NULL, " local_hostname . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME])); - /* command */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND])) - { - string = strdup (IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND)); - if (string && weechat_config_boolean (irc_config_look_hide_nickserv_pwd)) - irc_display_hide_password (string, 1); - weechat_printf (NULL, " command. . . . . . . : ('%s')", - (string) ? string : IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND)); - if (string) - free (string); - } - else - { - string = strdup (weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND])); - if (string && weechat_config_boolean (irc_config_look_hide_nickserv_pwd)) - irc_display_hide_password (string, 1); - weechat_printf (NULL, " command. . . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - (string) ? string : weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND])); - if (string) - free (string); - } - /* command_delay */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND_DELAY])) - weechat_printf (NULL, " command_delay. . . . : (%d %s)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY), - NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY))); - else - weechat_printf (NULL, " command_delay. . . . : %s%d %s", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]), - NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]))); - /* autojoin */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOJOIN])) - weechat_printf (NULL, " autojoin . . . . . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN)); - else - weechat_printf (NULL, " autojoin . . . . . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_AUTOJOIN])); - /* autorejoin */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN])) - weechat_printf (NULL, " autorejoin . . . . . : (%s)", - (IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOREJOIN)) ? - _("on") : _("off")); - else - weechat_printf (NULL, " autorejoin . . . . . : %s%s", - IRC_COLOR_CHAT_VALUE, - weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ? - _("on") : _("off")); - /* autorejoin_delay */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY])) - weechat_printf (NULL, " autorejoin_delay . . : (%d %s)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY), - NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTOREJOIN_DELAY))); - else - weechat_printf (NULL, " autorejoin_delay . . : %s%d %s", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]), - NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTOREJOIN_DELAY]))); - /* connection_timeout */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT])) - weechat_printf (NULL, " connection_timeout . : (%d %s)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT), - NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT))); - else - weechat_printf (NULL, " connection_timeout . : %s%d %s", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]), - NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_CONNECTION_TIMEOUT]))); - /* anti_flood_prio_high */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH])) - weechat_printf (NULL, " anti_flood_prio_high : (%d %s)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH), - NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH))); - else - weechat_printf (NULL, " anti_flood_prio_high : %s%d %s", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]), - NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_HIGH]))); - /* anti_flood_prio_low */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW])) - weechat_printf (NULL, " anti_flood_prio_low. : (%d %s)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW), - NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW))); - else - weechat_printf (NULL, " anti_flood_prio_low. : %s%d %s", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]), - NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_ANTI_FLOOD_PRIO_LOW]))); - /* away_check */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AWAY_CHECK])) - weechat_printf (NULL, " away_check . . . . . : (%d %s)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK), - NG_("minute", "minutes", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK))); - else - weechat_printf (NULL, " away_check . . . . . : %s%d %s", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK]), - NG_("minute", "minutes", weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK]))); - /* away_check_max_nicks */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS])) - weechat_printf (NULL, " away_check_max_nicks : (%d)", - IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS)); - else - weechat_printf (NULL, " away_check_max_nicks : %s%d", - IRC_COLOR_CHAT_VALUE, - weechat_config_integer (server->options[IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS])); - /* default_msg_part */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])) - weechat_printf (NULL, " default_msg_part . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_PART)); - else - weechat_printf (NULL, " default_msg_part . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_PART])); - /* default_msg_quit */ - if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])) - weechat_printf (NULL, " default_msg_quit . . : ('%s')", - IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_MSG_QUIT)); - else - weechat_printf (NULL, " default_msg_quit . . : %s'%s'", - IRC_COLOR_CHAT_VALUE, - weechat_config_string (server->options[IRC_SERVER_OPTION_DEFAULT_MSG_QUIT])); - } - else - { - if (server->is_connected) - { - num_channels = irc_server_get_channel_count (server); - num_pv = irc_server_get_pv_count (server); - weechat_printf (NULL, " %s %s%s %s[%s%s%s]%s%s, %d %s, %d pv", - (server->is_connected) ? "*" : " ", - IRC_COLOR_CHAT_SERVER, - server->name, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (server->is_connected) ? - _("connected") : _("not connected"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - (server->temp_server) ? _(" (temporary)") : "", - num_channels, - NG_("channel", "channels", num_channels), - num_pv); - } - else - { - weechat_printf (NULL, " %s%s%s%s", - IRC_COLOR_CHAT_SERVER, - server->name, - IRC_COLOR_RESET, - (server->temp_server) ? _(" (temporary)") : ""); - } - } -} diff --git a/src/plugins/irc/irc-display.h b/src/plugins/irc/irc-display.h deleted file mode 100644 index 994785a54..000000000 --- a/src/plugins/irc/irc-display.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * WeeChat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __WEECHAT_IRC_DISPLAY_H -#define __WEECHAT_IRC_DISPLAY_H 1 - -extern void irc_display_hide_password (char *string, int look_for_nickserv); -extern void irc_display_away (struct t_irc_server *server, const char *string1, - const char *string2); -extern void irc_display_server (struct t_irc_server *server, int with_detail); - -#endif /* __WEECHAT_IRC_DISPLAY_H */ |