summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValentin Batz <senneth@irssi.org>2004-12-20 13:59:15 +0000
committervb <vb@dbcabf3a-b0e7-0310-adc4-f8d773084564>2004-12-20 13:59:15 +0000
commit7be7dd374c23054f379fdf8361b31d3f658953c0 (patch)
tree525c6f344817828c6a6aab58333f85d5c1b1458e /src
parent5f81451df63acf5a809b5a551bc1b1e3e63ccfa0 (diff)
downloadirssi-7be7dd374c23054f379fdf8361b31d3f658953c0.zip
Added <tag>/<target> support for recode.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3692 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/core/chat-commands.c2
-rw-r--r--src/core/recode.c25
-rw-r--r--src/core/recode.h4
-rw-r--r--src/fe-common/core/fe-messages.c6
-rw-r--r--src/fe-common/core/fe-recode.c8
-rw-r--r--src/fe-common/irc/fe-events-numeric.c6
-rw-r--r--src/fe-common/irc/fe-events.c12
-rw-r--r--src/fe-common/irc/fe-irc-commands.c6
-rw-r--r--src/fe-common/irc/fe-whois.c8
-rw-r--r--src/irc/core/channel-events.c2
-rw-r--r--src/irc/core/irc-commands.c20
-rw-r--r--src/irc/proxy/dump.c2
12 files changed, 58 insertions, 43 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index 06fe5ce2..c7cc87d8 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -402,7 +402,7 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
}
}
- recoded = recode_out(msg, target);
+ recoded = recode_out(server, msg, target);
if (target != NULL) {
signal_emit("server sendmsg", 4, server, target, recoded,
GINT_TO_POINTER(target_type));
diff --git a/src/core/recode.c b/src/core/recode.c
index 11128635..78d0be55 100644
--- a/src/core/recode.c
+++ b/src/core/recode.c
@@ -65,13 +65,14 @@ static gboolean is_translit(const char *charset)
return (pos != NULL);
}
-char *recode_in(const char *str, const char *target)
+char *recode_in(const SERVER_REC *server, const char *str, const char *target)
{
#ifdef HAVE_GLIB2
const char *from = NULL;
const char *to = NULL;
char *translit_to = NULL;
char *recoded = NULL;
+ char *tagtarget = NULL;
gboolean term_is_utf8, str_is_utf8, translit;
int len;
@@ -83,7 +84,13 @@ char *recode_in(const char *str, const char *target)
str_is_utf8 = g_utf8_validate(str, len, NULL);
translit = settings_get_bool("recode_transliterate");
- if (target != NULL)
+ if (server != NULL)
+ tagtarget = server->tag == NULL ? NULL :
+ g_strdup_printf("%s/%s", server->tag, target);
+ if (tagtarget != NULL)
+ from = iconfig_get_str("conversions", tagtarget, NULL);
+ g_free(tagtarget);
+ if (target != NULL && from == NULL)
from = iconfig_get_str("conversions", target, NULL);
term_is_utf8 = recode_get_charset(&to);
@@ -115,7 +122,7 @@ char *recode_in(const char *str, const char *target)
#endif
}
-char *recode_out(const char *str, const char *target)
+char *recode_out(const SERVER_REC *server, const char *str, const char *target)
{
#ifdef HAVE_GLIB2
char *recoded = NULL;
@@ -133,8 +140,16 @@ char *recode_out(const char *str, const char *target)
if (target) {
const char *to = NULL;
char *translit_to = NULL;
-
- to = iconfig_get_str("conversions", target, NULL);
+ char *tagtarget = NULL;
+
+ if (server != NULL)
+ tagtarget = server->tag == NULL ? NULL :
+ g_strdup_printf("%s/%s", server->tag, target);
+ if (tagtarget != NULL)
+ to = iconfig_get_str("conversions", tagtarget, NULL);
+ else
+ to = iconfig_get_str("conversions", target, NULL);
+ g_free(tagtarget);
if (to == NULL || *to == '\0')
/* default outgoing charset if set */
to = settings_get_str("recode_out_default_charset");
diff --git a/src/core/recode.h b/src/core/recode.h
index 2a50da9e..f6c59e7c 100644
--- a/src/core/recode.h
+++ b/src/core/recode.h
@@ -1,8 +1,8 @@
#ifndef __RECODE_H
#define __RECODE_H
-char *recode_in (const char *str, const char *target);
-char *recode_out (const char *str, const char *target);
+char *recode_in (const SERVER_REC *server, const char *str, const char *target);
+char *recode_out (const SERVER_REC *server, const char *str, const char *target);
gboolean is_valid_charset(const char *charset);
void recode_init (void);
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index 00415341..41199d66 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -363,7 +363,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
window = window_item_window((WI_ITEM_REC *) rec);
if (g_slist_find(windows, window) == NULL) {
windows = g_slist_append(windows, window);
- recoded = recode_in(reason, rec->visible_name);
+ recoded = recode_in(server, reason, rec->visible_name);
printformat(server, rec->visible_name,
MSGLEVEL_QUITS,
TXT_QUIT, nick, address, recoded,
@@ -380,7 +380,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
display the quit there too */
QUERY_REC *query = query_find(server, nick);
if (query != NULL) {
- recoded = recode_in(reason, nick);
+ recoded = recode_in(server, reason, nick);
printformat(server, nick, MSGLEVEL_QUITS,
TXT_QUIT, nick, address, recoded, "");
g_free(recoded);
@@ -391,7 +391,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
if (chans->len > 0)
g_string_truncate(chans, chans->len-1);
/* at least recode_fallback will be used */
- recoded = recode_in(reason, nick);
+ recoded = recode_in(server, reason, nick);
printformat(server, print_channel, MSGLEVEL_QUITS,
count <= 1 ? TXT_QUIT : TXT_QUIT_ONCE,
nick, address, recoded, chans->str);
diff --git a/src/fe-common/core/fe-recode.c b/src/fe-common/core/fe-recode.c
index b26a5cbe..a7b5fe9f 100644
--- a/src/fe-common/core/fe-recode.c
+++ b/src/fe-common/core/fe-recode.c
@@ -192,7 +192,7 @@ static void message_own_public(const SERVER_REC *server, const char *msg,
const char *target)
{
char *recoded;
- recoded = recode_in(msg, target);
+ recoded = recode_in(server, msg, target);
signal_continue(3, server, recoded, target);
g_free(recoded);
}
@@ -201,7 +201,7 @@ static void message_own_private(const SERVER_REC *server, const char *msg,
const char *target, const char *orig_target)
{
char *recoded;
- recoded = recode_in(msg, target);
+ recoded = recode_in(server, msg, target);
signal_continue(4, server, recoded, target, orig_target);
g_free(recoded);
}
@@ -211,7 +211,7 @@ static void message_irc_own_action(const SERVER_REC *server, const char *msg,
const char *target)
{
char *recoded;
- recoded = recode_in(msg, target);
+ recoded = recode_in(server, msg, target);
signal_continue(5, server, recoded, nick, addr, target);
g_free(recoded);
}
@@ -220,7 +220,7 @@ static void message_irc_own_notice(const SERVER_REC *server, const char *msg,
const char *channel)
{
char *recoded;
- recoded = recode_in(msg, channel);
+ recoded = recode_in(server, msg, channel);
signal_continue(3, server, recoded, channel);
g_free(recoded);
}
diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c
index cb8604b5..459502a0 100644
--- a/src/fe-common/irc/fe-events-numeric.c
+++ b/src/fe-common/irc/fe-events-numeric.c
@@ -119,7 +119,7 @@ static void event_who(IRC_SERVER_REC *server, const char *data)
while (*realname == ' ') realname++;
if (realname > hops) realname[-1] = '\0';
- recoded = recode_in(realname, nick);
+ recoded = recode_in(SERVER(server), realname, nick);
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_WHO,
channel, nick, stat, hops, user, host, recoded, serv);
@@ -236,7 +236,7 @@ static void event_topic_get(IRC_SERVER_REC *server, const char *data)
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &channel, &topic);
- recoded = recode_in(topic, channel);
+ recoded = recode_in(SERVER(server), topic, channel);
channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
IRCTXT_TOPIC, channel, recoded);
@@ -316,7 +316,7 @@ static void event_away(IRC_SERVER_REC *server, const char *data)
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &awaymsg);
- recoded = recode_in(awaymsg, nick);
+ recoded = recode_in(SERVER(server), awaymsg, nick);
if (!settings_get_bool("show_away_once") ||
last_away_nick == NULL || g_strcasecmp(last_away_nick, nick) != 0 ||
last_away_msg == NULL || g_strcasecmp(last_away_msg, awaymsg) != 0) {
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c
index 6e157caa..2a2433d1 100644
--- a/src/fe-common/irc/fe-events.c
+++ b/src/fe-common/irc/fe-events.c
@@ -52,7 +52,7 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
if (nick == NULL) nick = server->real_address;
if (addr == NULL) addr = "";
- recoded = recode_in(msg, target);
+ recoded = recode_in(SERVER(server), msg, target);
if (*target == '@' && ischannel(target[1])) {
/* Hybrid 6 feature, send msg to all ops in channel */
signal_emit("message irc op_public", 5,
@@ -76,7 +76,7 @@ static void ctcp_action(IRC_SERVER_REC *server, const char *data,
char *recoded;
g_return_if_fail(data != NULL);
- recoded = recode_in(data, target);
+ recoded = recode_in(SERVER(server), data, target);
signal_emit("message irc action", 5,
server, recoded, nick, addr,
get_visible_target(server, target));
@@ -91,7 +91,7 @@ static void event_notice(IRC_SERVER_REC *server, const char *data,
g_return_if_fail(data != NULL);
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
- recoded = recode_in(msg, target);
+ recoded = recode_in(SERVER(server), msg, target);
if (nick == NULL) {
nick = server->real_address == NULL ?
server->connrec->address :
@@ -129,7 +129,7 @@ static void event_part(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
&channel, &reason);
- recoded = recode_in(reason, channel);
+ recoded = recode_in(SERVER(server), reason, channel);
signal_emit("message part", 5, server,
get_visible_target(server, channel), nick, addr, recoded);
g_free(params);
@@ -154,7 +154,7 @@ static void event_kick(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 3 | PARAM_FLAG_GETREST,
&channel, &nick, &reason);
- recoded = recode_in(reason, channel);
+ recoded = recode_in(SERVER(server), reason, channel);
signal_emit("message kick", 6,
server, get_visible_target(server, channel),
nick, kicker, addr, recoded);
@@ -261,7 +261,7 @@ static void event_topic(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
&channel, &topic);
- recoded = recode_in(topic, channel);
+ recoded = recode_in(SERVER(server), topic, channel);
signal_emit("message topic", 5, server,
get_visible_target(server, channel), recoded, nick, addr);
g_free(params);
diff --git a/src/fe-common/irc/fe-irc-commands.c b/src/fe-common/irc/fe-irc-commands.c
index 0c948dee..20ee904e 100644
--- a/src/fe-common/irc/fe-irc-commands.c
+++ b/src/fe-common/irc/fe-irc-commands.c
@@ -68,7 +68,7 @@ static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
cmd_return_error(CMDERR_NOT_CONNECTED);
target = window_item_get_target(item);
- recoded = recode_out(data, target);
+ recoded = recode_out(SERVER(server), data, target);
signal_emit("message irc own_action", 3, server, recoded,
item->visible_name);
@@ -100,7 +100,7 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
if (server == NULL || !server->connected)
cmd_param_error(CMDERR_NOT_CONNECTED);
- recoded = recode_out(text, target);
+ recoded = recode_out(SERVER(server), text, target);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, recoded);
target = skip_target(target);
@@ -128,7 +128,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
if (*target == '\0' || *msg == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- recoded = recode_out(msg, target);
+ recoded = recode_out(SERVER(server), msg, target);
signal_emit("message irc own_notice", 3, server, recoded, target);
g_free(recoded);
diff --git a/src/fe-common/irc/fe-whois.c b/src/fe-common/irc/fe-whois.c
index e9a6de2e..a9a1d499 100644
--- a/src/fe-common/irc/fe-whois.c
+++ b/src/fe-common/irc/fe-whois.c
@@ -20,7 +20,7 @@ static void event_whois(IRC_SERVER_REC *server, const char *data)
params = event_get_params(data, 6, NULL, &nick, &user,
&host, NULL, &realname);
- recoded = recode_in(realname, nick);
+ recoded = recode_in(SERVER(server), realname, nick);
printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_WHOIS, nick, user, host, recoded);
g_free(params);
@@ -255,7 +255,7 @@ static void event_whois_channels(IRC_SERVER_REC *server, const char *data)
chans = show_lowascii(chans);
if (settings_get_bool("whois_hide_safe_channel_id"))
hide_safe_channel_id(server, chans);
- recoded = recode_in(chans, nick);
+ recoded = recode_in(SERVER(server), chans, nick);
printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_WHOIS_CHANNELS, nick, recoded);
g_free(chans);
@@ -271,7 +271,7 @@ static void event_whois_away(IRC_SERVER_REC *server, const char *data)
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &awaymsg);
- recoded = recode_in(awaymsg, nick);
+ recoded = recode_in(SERVER(server), awaymsg, nick);
printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_WHOIS_AWAY, nick, recoded);
g_free(params);
@@ -312,7 +312,7 @@ static void event_whowas(IRC_SERVER_REC *server, const char *data)
params = event_get_params(data, 6, NULL, &nick, &user,
&host, NULL, &realname);
- recoded = recode_in(realname, nick);
+ recoded = recode_in(SERVER(server), realname, nick);
printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_WHOWAS, nick, user, host, recoded);
g_free(params);
diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c
index ac71e85f..f5c54932 100644
--- a/src/irc/core/channel-events.c
+++ b/src/irc/core/channel-events.c
@@ -143,7 +143,7 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel,
if (chanrec == NULL) return;
/* the topic may be send out encoded, so we need to
recode it back or /topic <tab> will not work properly */
- recoded = recode_in(topic, channel);
+ recoded = recode_in(SERVER(server), topic, channel);
if (topic != NULL) {
g_free_not_null(chanrec->topic);
chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded);
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c
index 107fec70..40159c9f 100644
--- a/src/irc/core/irc-commands.c
+++ b/src/irc/core/irc-commands.c
@@ -77,7 +77,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
if (*target == '\0' || *msg == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- recoded = recode_out(msg, target);
+ recoded = recode_out(SERVER(server), msg, target);
g_string_sprintf(tmpstr, "NOTICE %s :%s", target, recoded);
g_free(recoded);
@@ -110,7 +110,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
else {
char *recoded;
- recoded = recode_out(ctcpdata, target);
+ recoded = recode_out(SERVER(server), ctcpdata, target);
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s %s\001", target, ctcpcmd, recoded);
g_free(recoded);
}
@@ -139,7 +139,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
g_strup(ctcpcmd);
- recoded = recode_out(ctcpdata, target);
+ recoded = recode_out(SERVER(server), ctcpdata, target);
g_string_sprintf(tmpstr, "NOTICE %s :\001%s %s\001", target, ctcpcmd, recoded);
g_free(recoded);
@@ -169,7 +169,7 @@ static void cmd_part(const char *data, IRC_SERVER_REC *server,
irc_server_purge_output(server, channame);
if (*msg != '\0')
- recoded = recode_out(msg, channame);
+ recoded = recode_out(SERVER(server), msg, channame);
irc_send_cmdv(server, ! recoded ? "PART %s" : "PART %s :%s",
channame, recoded);
@@ -193,7 +193,7 @@ static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
if (*channame == '\0' || *nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
if (!ischannel(*channame)) cmd_param_error(CMDERR_NOT_JOINED);
- recoded = recode_out(reason, channame);
+ recoded = recode_out(SERVER(server), reason, channame);
g_string_sprintf(tmpstr, "KICK %s %s :%s", channame, nicks, recoded);
g_free(recoded);
@@ -218,7 +218,7 @@ static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
return;
if (*topic != '\0' || g_hash_table_lookup(optlist, "delete") != NULL)
- recoded = recode_out(topic, channame);
+ recoded = recode_out(SERVER(server), topic, channame);
irc_send_cmdv(server, recoded == NULL ? "TOPIC %s" : "TOPIC %s :%s",
channame, recoded);
g_free(recoded);
@@ -675,7 +675,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
SERVER(server), item, args, NULL, 0);
g_free(args);
- recoded = recode_out(msg, channame);
+ recoded = recode_out(SERVER(server), msg, channame);
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
NICK_REC *rec = tmp->data;
@@ -709,7 +709,7 @@ static void cmd_wallchops(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC
return;
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- recoded = recode_out(msg, channame);
+ recoded = recode_out(SERVER(server), msg, channame);
irc_send_cmdv(server, "WALLCHOPS %s :%s", channame, recoded);
g_free(recoded);
@@ -744,7 +744,7 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
spacenicks = g_strjoinv(" ", nicklist);
g_strfreev(nicklist);
- recoded = recode_out(reason, channel);
+ recoded = recode_out(SERVER(server), reason, channel);
kickcmd = g_strdup_printf("%s %s %s", chanrec->name, nicks, recoded);
g_free(recoded);
@@ -842,7 +842,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
banmasks = ban_get_masks(channel, spacenicks, 0);
g_free(spacenicks);
- recoded = recode_out(reason, channel->name);
+ recoded = recode_out(SERVER(server), reason, channel->name);
kickcmd = g_strdup_printf("%s %s %s", channel->name, nicks, recoded);
g_free(recoded);
diff --git a/src/irc/proxy/dump.c b/src/irc/proxy/dump.c
index a07c724a..a2959409 100644
--- a/src/irc/proxy/dump.c
+++ b/src/irc/proxy/dump.c
@@ -199,7 +199,7 @@ static void dump_join(IRC_CHANNEL_REC *channel, CLIENT_REC *client)
client->proxy_address, client->nick, channel->name);
if (channel->topic != NULL) {
/* this is needed because the topic may be encoded into other charsets internaly */
- recoded = recode_out(channel->topic, channel->name);
+ recoded = recode_out(SERVER(client->server), channel->topic, channel->name);
proxy_outdata(client, ":%s 332 %s %s :%s\n",
client->proxy_address, client->nick,
channel->name, recoded);