diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-12-19 17:43:37 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-12-19 17:43:37 +0100 |
commit | 13e3f3c7f04a805568ebb9a044d81d1eb32aedd6 (patch) | |
tree | 2cd321253a56b5a7f3ee7bca61a5cb90f3692a97 /src | |
parent | b97db3c31e10e75815d78d5a510953c63fcc2dbf (diff) | |
download | weechat-13e3f3c7f04a805568ebb9a044d81d1eb32aedd6.zip |
Fix charset problem with IRC plugin: use server charset if channel charset is not set
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/charset/charset.c | 23 | ||||
-rw-r--r-- | src/plugins/irc/irc-buffer.c | 13 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 43 |
4 files changed, 54 insertions, 32 deletions
diff --git a/src/plugins/charset/charset.c b/src/plugins/charset/charset.c index 8e95925e5..487fec0ab 100644 --- a/src/plugins/charset/charset.c +++ b/src/plugins/charset/charset.c @@ -390,7 +390,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc, struct t_config_section *ptr_section; int length; char *ptr_charset, *option_name; - const char *plugin_name, *name; + const char *plugin_name, *name, *charset_modifier; /* make C compiler happy */ (void) data; @@ -407,13 +407,20 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc, plugin_name = weechat_buffer_get_string (buffer, "plugin"); name = weechat_buffer_get_string (buffer, "name"); - - length = strlen (plugin_name) + 1 + strlen (name) + 1; - option_name = malloc (length); - if (!option_name) - return WEECHAT_RC_ERROR; - - snprintf (option_name, length, "%s.%s", plugin_name, name); + + charset_modifier = weechat_buffer_get_string (buffer, + "localvar_charset_modifier"); + if (charset_modifier) + option_name = strdup (charset_modifier); + else + { + length = strlen (plugin_name) + 1 + strlen (name) + 1; + option_name = malloc (length); + if (!option_name) + return WEECHAT_RC_ERROR; + + snprintf (option_name, length, "%s.%s", plugin_name, name); + } if ((argc > 1) && (weechat_strcasecmp (argv[1], "reset") == 0)) { diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c index 04d221908..53d8917f1 100644 --- a/src/plugins/irc/irc-buffer.c +++ b/src/plugins/irc/irc-buffer.c @@ -156,6 +156,7 @@ 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; @@ -189,6 +190,11 @@ irc_buffer_merge_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); @@ -220,7 +226,7 @@ void irc_buffer_split_server () { struct t_irc_server *ptr_server; - char buffer_name[256]; + char buffer_name[256], charset_modifier[256]; if (irc_buffer_servers) { @@ -247,6 +253,11 @@ irc_buffer_split_server () "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); diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index c064b3770..f6cf3abeb 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -2779,7 +2779,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, int i, detailed_list, one_server_found, length; int default_autoconnect, default_ipv6, default_ssl; struct t_irc_server server_tmp, *ptr_server2, *server_found, *new_server; - char *server_name, *mask, value[16]; + char *server_name, *mask, value[16], charset_modifier[256]; struct t_infolist *infolist; struct t_config_option *ptr_option; @@ -3179,6 +3179,11 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc, } } 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"); } diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 5b1ca70f4..c71e650eb 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1346,10 +1346,9 @@ irc_server_send_one_msg (struct t_irc_server *server, const char *message) else { snprintf (modifier_data, sizeof (modifier_data), - "%s.%s.%s", + "%s.%s", weechat_plugin->name, - server->name, - ptr_chan_nick); + server->name); } msg_encoded = weechat_hook_modifier_exec ("charset_encode", modifier_data, @@ -1671,24 +1670,14 @@ irc_server_msgq_flush () /* convert charset for message */ ptr_chan_nick = (channel) ? channel : nick; - if (ptr_chan_nick) + if (ptr_chan_nick + && (!nick || !host || (strcmp (nick, host) != 0))) { - /* message with no target (nick or channel) ? */ - if (nick && host && (strcmp (nick, host) == 0)) - { - snprintf (modifier_data, sizeof (modifier_data), - "%s.server.%s", - weechat_plugin->name, - irc_recv_msgq->server->name); - } - else - { - snprintf (modifier_data, sizeof (modifier_data), - "%s.%s.%s", - weechat_plugin->name, - irc_recv_msgq->server->name, - ptr_chan_nick); - } + snprintf (modifier_data, sizeof (modifier_data), + "%s.%s.%s", + weechat_plugin->name, + irc_recv_msgq->server->name, + ptr_chan_nick); } else { @@ -2168,7 +2157,7 @@ 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) { - char buffer_name[256]; + char buffer_name[256], charset_modifier[256]; if (all_servers) { @@ -2195,6 +2184,10 @@ irc_server_create_buffer (struct t_irc_server *server, int all_servers) weechat_buffer_set (server->buffer, "localvar_set_channel", (weechat_config_boolean (irc_config_look_one_server_buffer)) ? IRC_BUFFER_ALL_SERVERS_NAME : server->name); + snprintf (charset_modifier, sizeof (charset_modifier), + "irc.%s", server->name); + weechat_buffer_set (server->buffer, "localvar_set_charset_modifier", + charset_modifier); weechat_hook_signal_send ("logger_backlog", WEECHAT_HOOK_SIGNAL_POINTER, server->buffer); @@ -2224,7 +2217,7 @@ int irc_server_connect (struct t_irc_server *server, int disable_autojoin) { int set, length; - char *option_name; + char *option_name, charset_modifier[256]; struct t_config_option *proxy_type, *proxy_ipv6, *proxy_address, *proxy_port; const char *str_proxy_type, *str_proxy_address; @@ -2255,6 +2248,12 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin) 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); } weechat_buffer_set (server->buffer, "display", "1"); |