mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 08:13:14 +02:00
irc: remove option irc.network.channel_encode, add server option "charset_message" (closes #832)
This new option controls which part of the IRC message is decoded/encoded to the target charset, and the new default behavior is to decode/encode the whole IRC message (behavior in WeeChat >= 1.3 was to decode/encode only the text by default).
This commit is contained in:
@@ -5076,7 +5076,6 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
|
||||
weechat_printf (NULL, " notify . . . . . . . : %s'%s'",
|
||||
IRC_COLOR_CHAT_VALUE,
|
||||
weechat_config_string (server->options[IRC_SERVER_OPTION_NOTIFY]));
|
||||
|
||||
/* split_msg_max_length */
|
||||
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH]))
|
||||
weechat_printf (NULL, " split_msg_max_length : (%d)",
|
||||
@@ -5085,6 +5084,14 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
|
||||
weechat_printf (NULL, " split_msg_max_length : %s%d",
|
||||
IRC_COLOR_CHAT_VALUE,
|
||||
weechat_config_integer (server->options[IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH]));
|
||||
/* charset_message */
|
||||
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_CHARSET_MESSAGE]))
|
||||
weechat_printf (NULL, " charset_message. . . : ('%s')",
|
||||
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CHARSET_MESSAGE));
|
||||
else
|
||||
weechat_printf (NULL, " charset_message. . . : %s'%s'",
|
||||
IRC_COLOR_CHAT_VALUE,
|
||||
weechat_config_string (server->options[IRC_SERVER_OPTION_CHARSET_MESSAGE]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -130,7 +130,6 @@ struct t_config_option *irc_config_color_topic_old;
|
||||
struct t_config_option *irc_config_network_autoreconnect_delay_growing;
|
||||
struct t_config_option *irc_config_network_autoreconnect_delay_max;
|
||||
struct t_config_option *irc_config_network_ban_mask_default;
|
||||
struct t_config_option *irc_config_network_channel_encode;
|
||||
struct t_config_option *irc_config_network_colors_receive;
|
||||
struct t_config_option *irc_config_network_colors_send;
|
||||
struct t_config_option *irc_config_network_lag_check;
|
||||
@@ -2394,6 +2393,28 @@ irc_config_server_new_option (struct t_config_file *config_file,
|
||||
callback_change_data,
|
||||
NULL, NULL, NULL);
|
||||
break;
|
||||
case IRC_SERVER_OPTION_CHARSET_MESSAGE:
|
||||
new_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "integer",
|
||||
N_("part of the IRC message (received or sent) which is "
|
||||
"decoded/encoded to the target charset; "
|
||||
"message = the whole IRC message (default), "
|
||||
"channel = starting from the channel name only "
|
||||
"(if found, with fallback on text), "
|
||||
"text = starting from the text only (you should try this "
|
||||
"value if you have issues with the channel name encoding)"),
|
||||
"message|channel|text", 0, 0,
|
||||
default_value, value,
|
||||
null_value_allowed,
|
||||
callback_check_value,
|
||||
callback_check_value_pointer,
|
||||
callback_check_value_data,
|
||||
callback_change,
|
||||
callback_change_pointer,
|
||||
callback_change_data,
|
||||
NULL, NULL, NULL);
|
||||
break;
|
||||
case IRC_SERVER_NUM_OPTIONS:
|
||||
break;
|
||||
}
|
||||
@@ -3271,15 +3292,6 @@ irc_config_init ()
|
||||
"default mask is used only if WeeChat knows the host for the nick"),
|
||||
NULL, 0, 0, "*!$ident@$host", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_network_channel_encode = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"channel_encode", "boolean",
|
||||
N_("decode/encode channel name inside messages using charset options; "
|
||||
"it is recommended to keep that off if you use only UTF-8 in "
|
||||
"channel names; you can enable this option if you are using an "
|
||||
"exotic charset like ISO in channel names"),
|
||||
NULL, 0, 0, "off", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_network_colors_receive = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"colors_receive", "boolean",
|
||||
|
||||
@@ -166,7 +166,6 @@ extern struct t_config_option *irc_config_color_topic_old;
|
||||
extern struct t_config_option *irc_config_network_autoreconnect_delay_growing;
|
||||
extern struct t_config_option *irc_config_network_autoreconnect_delay_max;
|
||||
extern struct t_config_option *irc_config_network_ban_mask_default;
|
||||
extern struct t_config_option *irc_config_network_channel_encode;
|
||||
extern struct t_config_option *irc_config_network_colors_receive;
|
||||
extern struct t_config_option *irc_config_network_colors_send;
|
||||
extern struct t_config_option *irc_config_network_lag_check;
|
||||
|
||||
@@ -119,6 +119,7 @@ char *irc_server_options[IRC_SERVER_NUM_OPTIONS][2] =
|
||||
{ "msg_quit", "WeeChat ${info:version}" },
|
||||
{ "notify", "" },
|
||||
{ "split_msg_max_length", "512" },
|
||||
{ "charset_message", "message" },
|
||||
};
|
||||
|
||||
char *irc_server_casemapping_string[IRC_SERVER_NUM_CASEMAPPING] =
|
||||
@@ -2499,10 +2500,19 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
|
||||
msg_encoded = NULL;
|
||||
irc_message_parse (server, ptr_msg, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, &pos_channel, &pos_text);
|
||||
if (weechat_config_boolean (irc_config_network_channel_encode))
|
||||
pos_encode = (pos_channel >= 0) ? pos_channel : pos_text;
|
||||
else
|
||||
pos_encode = pos_text;
|
||||
switch (IRC_SERVER_OPTION_INTEGER(server,
|
||||
IRC_SERVER_OPTION_CHARSET_MESSAGE))
|
||||
{
|
||||
case IRC_SERVER_CHARSET_MESSAGE_MESSAGE:
|
||||
pos_encode = 0;
|
||||
break;
|
||||
case IRC_SERVER_CHARSET_MESSAGE_CHANNEL:
|
||||
pos_encode = (pos_channel >= 0) ? pos_channel : pos_text;
|
||||
break;
|
||||
case IRC_SERVER_CHARSET_MESSAGE_TEXT:
|
||||
pos_encode = pos_text;
|
||||
break;
|
||||
}
|
||||
if (pos_encode >= 0)
|
||||
{
|
||||
ptr_chan_nick = (channel) ? channel : nick;
|
||||
@@ -3009,10 +3019,21 @@ irc_server_msgq_flush ()
|
||||
&pos_channel, &pos_text);
|
||||
|
||||
msg_decoded = NULL;
|
||||
if (weechat_config_boolean (irc_config_network_channel_encode))
|
||||
pos_decode = (pos_channel >= 0) ? pos_channel : pos_text;
|
||||
else
|
||||
pos_decode = pos_text;
|
||||
|
||||
|
||||
switch (IRC_SERVER_OPTION_INTEGER(irc_recv_msgq->server,
|
||||
IRC_SERVER_OPTION_CHARSET_MESSAGE))
|
||||
{
|
||||
case IRC_SERVER_CHARSET_MESSAGE_MESSAGE:
|
||||
pos_decode = 0;
|
||||
break;
|
||||
case IRC_SERVER_CHARSET_MESSAGE_CHANNEL:
|
||||
pos_decode = (pos_channel >= 0) ? pos_channel : pos_text;
|
||||
break;
|
||||
case IRC_SERVER_CHARSET_MESSAGE_TEXT:
|
||||
pos_decode = pos_text;
|
||||
break;
|
||||
}
|
||||
if (pos_decode >= 0)
|
||||
{
|
||||
/* convert charset for message */
|
||||
|
||||
@@ -42,6 +42,13 @@ enum t_irc_server_sasl_fail
|
||||
IRC_SERVER_NUM_SASL_FAIL,
|
||||
};
|
||||
|
||||
enum t_irc_server_charset_message
|
||||
{
|
||||
IRC_SERVER_CHARSET_MESSAGE_MESSAGE = 0,
|
||||
IRC_SERVER_CHARSET_MESSAGE_CHANNEL,
|
||||
IRC_SERVER_CHARSET_MESSAGE_TEXT,
|
||||
};
|
||||
|
||||
enum t_irc_server_option
|
||||
{
|
||||
IRC_SERVER_OPTION_ADDRESSES = 0, /* server addresses (IP/name with port) */
|
||||
@@ -85,6 +92,7 @@ enum t_irc_server_option
|
||||
IRC_SERVER_OPTION_MSG_QUIT, /* default quit message */
|
||||
IRC_SERVER_OPTION_NOTIFY, /* notify list */
|
||||
IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH, /* max length of messages */
|
||||
IRC_SERVER_OPTION_CHARSET_MESSAGE, /* what to decode/encode in msg */
|
||||
/* number of server options */
|
||||
IRC_SERVER_NUM_OPTIONS,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user