summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2008-08-02 13:15:38 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2008-08-02 13:15:38 +0000
commit9fa8cbe7a2ac1c17fa4494389b199319ec966aae (patch)
treed87ae801571f4a7dc7ad05f7f80df4286bc2ed7d
parentd788673eb92d68d796f69e70ab2dddeb01778585 (diff)
downloadirssi-9fa8cbe7a2ac1c17fa4494389b199319ec966aae.zip
Revert recode changes r4483 and r4715.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4867 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/core/chat-commands.c9
-rw-r--r--src/fe-common/core/fe-messages.c34
-rw-r--r--src/fe-common/irc/fe-events-numeric.c25
-rw-r--r--src/fe-common/irc/fe-events.c40
-rw-r--r--src/fe-common/irc/fe-irc-commands.c21
-rw-r--r--src/fe-common/irc/fe-irc-messages.c49
-rw-r--r--src/fe-common/irc/fe-whois.c25
-rw-r--r--src/irc/core/channel-events.c8
-rw-r--r--src/irc/core/irc-commands.c66
-rw-r--r--src/irc/core/irc.c27
10 files changed, 201 insertions, 103 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index 3b8b5df8..705ccb6b 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -24,6 +24,7 @@
#include "commands.h"
#include "special-vars.h"
#include "settings.h"
+#include "recode.h"
#include "chat-protocols.h"
#include "servers.h"
@@ -349,7 +350,7 @@ static void cmd_join(const char *data, SERVER_REC *server)
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
GHashTable *optlist;
- char *target, *origtarget, *msg;
+ char *target, *origtarget, *msg, *recoded;
void *free_arg;
int free_ret, target_type = SEND_TARGET_NICK;
@@ -401,14 +402,16 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
}
}
+ recoded = recode_out(server, msg, target);
if (target != NULL) {
- signal_emit("server sendmsg", 4, server, target, msg,
+ signal_emit("server sendmsg", 4, server, target, recoded,
GINT_TO_POINTER(target_type));
}
signal_emit(target != NULL && target_type == SEND_TARGET_CHANNEL ?
"message own_public" : "message own_private", 4,
- server, msg, target, origtarget);
+ server, recoded, target, origtarget);
+ g_free(recoded);
if (free_ret && target != NULL) g_free(target);
cmd_params_free(free_arg);
}
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index a5bcd2b0..d3949a31 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -31,6 +31,7 @@
#include "channels.h"
#include "nicklist.h"
#include "ignore.h"
+#include "recode.h"
#include "window-items.h"
#include "fe-queries.h"
@@ -258,7 +259,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
WINDOW_REC *window;
CHANNEL_REC *channel;
char *nickmode;
- char *freemsg = NULL;
+ char *freemsg = NULL, *recoded;
int print_channel;
channel = channel_find(server, target);
if (channel != NULL)
@@ -279,14 +280,18 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis((WI_ITEM_REC *) channel, msg);
+ /* ugly: recode the sent message back for printing */
+ recoded = recode_in(server, msg, target);
+
if (!print_channel) {
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
- TXT_OWN_MSG, server->nick, msg, nickmode);
+ TXT_OWN_MSG, server->nick, recoded, nickmode);
} else {
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
- TXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode);
+ TXT_OWN_MSG_CHANNEL, server->nick, target, recoded, nickmode);
}
+ g_free(recoded);
g_free_not_null(nickmode);
g_free_not_null(freemsg);
}
@@ -295,7 +300,7 @@ static void sig_message_own_private(SERVER_REC *server, const char *msg,
const char *target, const char *origtarget)
{
QUERY_REC *query;
- char *freemsg = NULL;
+ char *freemsg = NULL, *recoded;
g_return_if_fail(server != NULL);
g_return_if_fail(msg != NULL);
@@ -318,11 +323,15 @@ static void sig_message_own_private(SERVER_REC *server, const char *msg,
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
+ /* ugly: recode the sent message back for printing */
+ recoded = recode_in(server, msg, target);
+
printformat(server, target,
MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
query == NULL ? TXT_OWN_MSG_PRIVATE :
- TXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
+ TXT_OWN_MSG_PRIVATE_QUERY, target, recoded, server->nick);
+ g_free(recoded);
g_free_not_null(freemsg);
}
@@ -347,7 +356,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
WINDOW_REC *window;
GString *chans;
GSList *tmp, *windows;
- char *print_channel;
+ char *print_channel, *recoded;
int once, count;
if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS))
@@ -380,10 +389,12 @@ 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(server, reason, rec->visible_name);
printformat(server, rec->visible_name,
MSGLEVEL_QUITS,
- TXT_QUIT, nick, address, reason,
+ TXT_QUIT, nick, address, recoded,
rec->visible_name);
+ g_free(recoded);
}
}
count++;
@@ -395,17 +406,22 @@ 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(server, reason, nick);
printformat(server, nick, MSGLEVEL_QUITS,
- TXT_QUIT, nick, address, reason, "");
+ TXT_QUIT, nick, address, recoded, "");
+ g_free(recoded);
}
}
if (once || count == 0) {
if (chans->len > 0)
g_string_truncate(chans, chans->len-1);
+ /* at least recode_fallback will be used */
+ recoded = recode_in(server, reason, nick);
printformat(server, print_channel, MSGLEVEL_QUITS,
count <= 1 ? TXT_QUIT : TXT_QUIT_ONCE,
- nick, address, reason, chans->str);
+ nick, address, recoded, chans->str);
+ g_free(recoded);
}
g_string_free(chans, TRUE);
}
diff --git a/src/fe-common/irc/fe-events-numeric.c b/src/fe-common/irc/fe-events-numeric.c
index 0510c4ff..1de8e5dd 100644
--- a/src/fe-common/irc/fe-events-numeric.c
+++ b/src/fe-common/irc/fe-events-numeric.c
@@ -24,6 +24,7 @@
#include "misc.h"
#include "settings.h"
#include "levels.h"
+#include "recode.h"
#include "irc-servers.h"
#include "irc-channels.h"
@@ -105,7 +106,7 @@ static void event_end_of_names(IRC_SERVER_REC *server, const char *data,
static void event_who(IRC_SERVER_REC *server, const char *data)
{
char *params, *nick, *channel, *user, *host, *stat, *realname, *hops;
- char *serv;
+ char *serv, *recoded;
g_return_if_fail(data != NULL);
@@ -118,10 +119,12 @@ static void event_who(IRC_SERVER_REC *server, const char *data)
if (*realname == ' ')
*realname++ = '\0';
+ recoded = recode_in(SERVER(server), realname, nick);
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_WHO,
- channel, nick, stat, hops, user, host, realname, serv);
+ channel, nick, stat, hops, user, host, recoded, serv);
g_free(params);
+ g_free(recoded);
}
static void event_end_of_who(IRC_SERVER_REC *server, const char *data)
@@ -245,15 +248,17 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
static void event_topic_get(IRC_SERVER_REC *server, const char *data)
{
const char *channel;
- char *params, *topic;
+ char *params, *topic, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &channel, &topic);
+ recoded = recode_in(SERVER(server), topic, channel);
channel = get_visible_target(server, channel);
printformat(server, channel, MSGLEVEL_CRAP,
- IRCTXT_TOPIC, channel, topic);
+ IRCTXT_TOPIC, channel, recoded);
g_free(params);
+ g_free(recoded);
}
static void event_topic_info(IRC_SERVER_REC *server, const char *data)
@@ -323,11 +328,12 @@ static void event_unaway(IRC_SERVER_REC *server, const char *data)
static void event_away(IRC_SERVER_REC *server, const char *data)
{
- char *params, *nick, *awaymsg;
+ char *params, *nick, *awaymsg, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &awaymsg);
+ 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) {
@@ -339,9 +345,10 @@ static void event_away(IRC_SERVER_REC *server, const char *data)
last_away_msg = g_strdup(awaymsg);
printformat(server, nick, MSGLEVEL_CRAP,
- IRCTXT_NICK_AWAY, nick, awaymsg);
+ IRCTXT_NICK_AWAY, nick, recoded);
}
g_free(params);
+ g_free(recoded);
}
static void event_userhost(IRC_SERVER_REC *server, const char *data)
@@ -541,7 +548,7 @@ static void event_numeric(IRC_SERVER_REC *server, const char *data,
static void print_event_received(IRC_SERVER_REC *server, const char *data,
const char *nick, int target_param)
{
- char *target, *args, *ptr, *ptr2;
+ char *target, *args, *ptr, *ptr2, *recoded;
int format;
g_return_if_fail(data != NULL);
@@ -570,12 +577,14 @@ static void print_event_received(IRC_SERVER_REC *server, const char *data,
g_memmove(ptr+1, ptr+2, strlen(ptr+1));
}
+ recoded = recode_in(SERVER(server), args, NULL);
format = nick == NULL || server->real_address == NULL ||
strcmp(nick, server->real_address) == 0 ?
IRCTXT_DEFAULT_EVENT : IRCTXT_DEFAULT_EVENT_SERVER;
printformat(server, target, MSGLEVEL_CRAP, format,
- nick, args, current_server_event);
+ nick, recoded, current_server_event);
+ g_free(recoded);
g_free(args);
g_free(target);
}
diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c
index dc952a66..f5d03cf5 100644
--- a/src/fe-common/irc/fe-events.c
+++ b/src/fe-common/irc/fe-events.c
@@ -30,6 +30,7 @@
#include "servers-reconnect.h"
#include "queries.h"
#include "ignore.h"
+#include "recode.h"
#include "irc-servers.h"
#include "irc-channels.h"
@@ -44,7 +45,7 @@
static void event_privmsg(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{
- char *params, *target, *msg;
+ char *params, *target, *msg, *recoded;
g_return_if_fail(data != NULL);
@@ -53,46 +54,55 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
if (addr == NULL) addr = "";
if (*target == '@' && ischannel(target[1])) {
/* Hybrid 6 feature, send msg to all ops in channel */
+ recoded = recode_in(SERVER(server), msg, target+1);
signal_emit("message irc op_public", 5,
- server, msg, nick, addr,
+ server, recoded, nick, addr,
get_visible_target(server, target+1));
} else {
+ recoded = recode_in(SERVER(server), msg, ischannel(*target) ? target : nick);
signal_emit(ischannel(*target) ?
"message public" : "message private", 5,
- server, msg, nick, addr,
+ server, recoded, nick, addr,
get_visible_target(server, target));
}
g_free(params);
+ g_free(recoded);
}
static void ctcp_action(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr,
const char *target)
{
+ char *recoded;
+
g_return_if_fail(data != NULL);
+ recoded = recode_in(SERVER(server), data, target);
signal_emit("message irc action", 5,
- server, data, nick, addr,
+ server, recoded, nick, addr,
get_visible_target(server, target));
+ g_free(recoded);
}
static void event_notice(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{
- char *params, *target, *msg;
+ char *params, *target, *msg, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
+ recoded = recode_in(SERVER(server), msg, target);
if (nick == NULL) {
nick = server->real_address == NULL ?
server->connrec->address :
server->real_address;
}
- signal_emit("message irc notice", 5, server, msg, nick, addr,
+ signal_emit("message irc notice", 5, server, recoded, nick, addr,
get_visible_target(server, target));
g_free(params);
+ g_free(recoded);
}
static void event_join(IRC_SERVER_REC *server, const char *data,
@@ -114,15 +124,17 @@ static void event_join(IRC_SERVER_REC *server, const char *data,
static void event_part(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{
- char *params, *channel, *reason;
+ char *params, *channel, *reason, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
&channel, &reason);
+ recoded = recode_in(SERVER(server), reason, channel);
signal_emit("message part", 5, server,
- get_visible_target(server, channel), nick, addr, reason);
+ get_visible_target(server, channel), nick, addr, recoded);
g_free(params);
+ g_free(recoded);
}
static void event_quit(IRC_SERVER_REC *server, const char *data,
@@ -137,16 +149,18 @@ static void event_quit(IRC_SERVER_REC *server, const char *data,
static void event_kick(IRC_SERVER_REC *server, const char *data,
const char *kicker, const char *addr)
{
- char *params, *channel, *nick, *reason;
+ char *params, *channel, *nick, *reason, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3 | PARAM_FLAG_GETREST,
&channel, &nick, &reason);
+ recoded = recode_in(SERVER(server), reason, channel);
signal_emit("message kick", 6,
server, get_visible_target(server, channel),
- nick, kicker, addr, reason);
+ nick, kicker, addr, recoded);
g_free(params);
+ g_free(recoded);
}
static void event_kill(IRC_SERVER_REC *server, const char *data,
@@ -242,15 +256,17 @@ static void event_invite(IRC_SERVER_REC *server, const char *data,
static void event_topic(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr)
{
- char *params, *channel, *topic;
+ char *params, *channel, *topic, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
&channel, &topic);
+ recoded = recode_in(SERVER(server), topic, channel);
signal_emit("message topic", 5, server,
- get_visible_target(server, channel), topic, nick, addr);
+ get_visible_target(server, channel), recoded, nick, addr);
g_free(params);
+ g_free(recoded);
}
static void event_error(IRC_SERVER_REC *server, const char *data)
diff --git a/src/fe-common/irc/fe-irc-commands.c b/src/fe-common/irc/fe-irc-commands.c
index 54c5263f..37f8b9ab 100644
--- a/src/fe-common/irc/fe-irc-commands.c
+++ b/src/fe-common/irc/fe-irc-commands.c
@@ -22,6 +22,7 @@
#include "module-formats.h"
#include "signals.h"
#include "misc.h"
+#include "recode.h"
#include "special-vars.h"
#include "settings.h"
@@ -44,6 +45,7 @@
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
const char *target;
+ char *recoded;
CMD_IRC_SERVER(server);
if (!IS_IRC_ITEM(item))
@@ -53,12 +55,15 @@ 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(SERVER(server), data, target);
- signal_emit("message irc own_action", 3, server, data,
+ signal_emit("message irc own_action", 3, server, recoded,
item->visible_name);
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001",
- target, data);
+ target, recoded);
+
+ g_free(recoded);
}
/* SYNTAX: ACTION [-<server tag>] <target> <message> */
@@ -66,6 +71,7 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
{
GHashTable *optlist;
const char *target, *text;
+ char *recoded;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -81,10 +87,12 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
if (server == NULL || !server->connected)
cmd_param_error(CMDERR_NOT_CONNECTED);
- irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, text);
+ recoded = recode_out(SERVER(server), text, target);
+ irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, recoded);
- signal_emit("message irc own_action", 3, server, text, target);
+ signal_emit("message irc own_action", 3, server, recoded, target);
+ g_free(recoded);
cmd_params_free(free_arg);
}
@@ -92,6 +100,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
WI_ITEM_REC *item)
{
const char *target, *msg;
+ char *recoded;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -105,8 +114,10 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
if (*target == '\0' || *msg == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- signal_emit("message irc own_notice", 3, server, msg, target);
+ recoded = recode_out(SERVER(server), msg, target);
+ signal_emit("message irc own_notice", 3, server, recoded, target);
+ g_free(recoded);
cmd_params_free(free_arg);
}
diff --git a/src/fe-common/irc/fe-irc-messages.c b/src/fe-common/irc/fe-irc-messages.c
index 36194a9b..06159582 100644
--- a/src/fe-common/irc/fe-irc-messages.c
+++ b/src/fe-common/irc/fe-irc-messages.c
@@ -24,6 +24,7 @@
#include "channels.h"
#include "ignore.h"
#include "settings.h"
+#include "recode.h"
#include "irc-servers.h"
#include "irc-channels.h"
@@ -67,7 +68,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
const char *target, const char *origtarget)
{
const char *oldtarget;
- char *nickmode;
+ char *nickmode, *recoded;
oldtarget = target;
target = skip_target(IRC_SERVER(server), target);
@@ -77,12 +78,15 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
nickmode = channel_get_nickmode(channel_find(server, target),
server->nick);
+ /* ugly: recode the sent message back for printing */
+ recoded = recode_in(SERVER(server), msg, target);
printformat_module("fe-common/core", server, target,
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
MSGLEVEL_NO_ACT,
TXT_OWN_MSG_CHANNEL,
- server->nick, oldtarget, msg, nickmode);
+ server->nick, oldtarget, recoded, nickmode);
g_free(nickmode);
+ g_free(recoded);
signal_stop();
}
@@ -110,18 +114,21 @@ static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
static void sig_message_own_wall(SERVER_REC *server, const char *msg,
const char *target)
{
- char *nickmode, *optarget;
+ char *nickmode, *optarget, *recoded;
nickmode = channel_get_nickmode(channel_find(server, target),
server->nick);
optarget = g_strconcat("@", target, NULL);
+ /* ugly: recode the sent message back for printing */
+ recoded = recode_in(SERVER(server), msg, target);
printformat_module("fe-common/core", server, target,
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
MSGLEVEL_NO_ACT,
TXT_OWN_MSG_CHANNEL,
- server->nick, optarget, msg, nickmode);
+ server->nick, optarget, recoded, nickmode);
g_free(nickmode);
+ g_free(recoded);
g_free(optarget);
}
@@ -130,7 +137,7 @@ static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
{
void *item;
const char *oldtarget;
- char *freemsg = NULL;
+ char *freemsg = NULL, *recoded;
oldtarget = target;
target = skip_target(IRC_SERVER(server), target);
@@ -142,11 +149,15 @@ static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis(item, msg);
+ /* ugly: recode the sent message back for printing */
+ recoded = recode_in(SERVER(server), msg, target);
+
printformat(server, target,
MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT |
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
item != NULL && oldtarget == target ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
- server->nick, msg, oldtarget);
+ server->nick, recoded, oldtarget);
+ g_free(recoded);
g_free_not_null(freemsg);
}
@@ -156,7 +167,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
{
void *item;
const char *oldtarget;
- char *freemsg = NULL;
+ char *freemsg = NULL, *recoded;
int level;
oldtarget = target;
@@ -176,35 +187,40 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis(item, msg);
+ recoded = recode_in(SERVER(server), msg, target);
if (ischannel(*target)) {
/* channel action */
if (window_item_is_active(item) && target == oldtarget) {
/* message to active channel in window */
printformat(server, target, level,
- IRCTXT_ACTION_PUBLIC, nick, msg);
+ IRCTXT_ACTION_PUBLIC, nick, recoded);
} else {
/* message to not existing/active channel, or to @/+ */
printformat(server, target, level,
IRCTXT_ACTION_PUBLIC_CHANNEL,
- nick, oldtarget, msg);
+ nick, oldtarget, recoded);
}
} else {
/* private action */
printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
item == NULL ? IRCTXT_ACTION_PRIVATE :
IRCTXT_ACTION_PRIVATE_QUERY,
- nick, address == NULL ? "" : address, msg);
+ nick, address == NULL ? "" : address, recoded);
}
+ g_free(recoded);
g_free_not_null(freemsg);
}
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
const char *target)
{
+ /* ugly: recode the sent message back for printing */
+ char *recoded = recode_in(SERVER(server), msg, target);
printformat(server, skip_target(server, target), MSGLEVEL_NOTICES |
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
- IRCTXT_OWN_NOTICE, target, msg);
+ IRCTXT_OWN_NOTICE, target, recoded);
+ g_free(recoded);
}
static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
@@ -212,17 +228,20 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
const char *target)
{
const char *oldtarget;
+ char *recoded;
oldtarget = target;
target = skip_target(IRC_SERVER(server), target);
if (address == NULL || *address == '\0') {
/* notice from server */
+ recoded = recode_in(SERVER(server), msg, NULL);
if (!ignore_check(server, nick, "",
target, msg, MSGLEVEL_SNOTES)) {
printformat(server, target, MSGLEVEL_SNOTES,
- IRCTXT_NOTICE_SERVER, nick, msg);
+ IRCTXT_NOTICE_SERVER, nick, recoded);
}
+ g_free(recoded);
return;
}
@@ -231,17 +250,19 @@ static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
msg, MSGLEVEL_NOTICES))
return;
+ recoded = recode_in(SERVER(server), msg, target);
if (ischannel(*target)) {
/* notice in some channel */
printformat(server, target, MSGLEVEL_NOTICES,
- IRCTXT_NOTICE_PUBLIC, nick, oldtarget, msg);
+ IRCTXT_NOTICE_PUBLIC, nick, oldtarget, recoded);
} else {
/* private notice */
privmsg_get_query(SERVER(server), nick, FALSE,
MSGLEVEL_NOTICES);
printformat(server, nick, MSGLEVEL_NOTICES,
- IRCTXT_NOTICE_PRIVATE, nick, address, msg);
+ IRCTXT_NOTICE_PRIVATE, nick, address, recoded);
}
+ g_free(recoded);
}
static void sig_message_own_ctcp(IRC_SERVER_REC *server, const char *cmd,
diff --git a/src/fe-common/irc/fe-whois.c b/src/fe-common/irc/fe-whois.c
index 3505ade0..e48c99c6 100644
--- a/src/fe-common/irc/fe-whois.c
+++ b/src/fe-common/irc/fe-whois.c
@@ -6,6 +6,7 @@
#include "levels.h"
#include "misc.h"
#include "settings.h"
+#include "recode.h"
#include "irc-servers.h"
@@ -13,15 +14,17 @@
static void event_whois(IRC_SERVER_REC *server, const char *data)
{
- char *params, *nick, *user, *host, *realname;
+ char *params, *nick, *user, *host, *realname, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 6, NULL, &nick, &user,
&host, NULL, &realname);
+ recoded = recode_in(SERVER(server), realname, nick);
printformat(server, nick, MSGLEVEL_CRAP,
- IRCTXT_WHOIS, nick, user, host, realname);
+ IRCTXT_WHOIS, nick, user, host, recoded);
g_free(params);
+ g_free(recoded);
}
static void event_whois_special(IRC_SERVER_REC *server, const char *data)
@@ -275,7 +278,7 @@ static void hide_safe_channel_id(IRC_SERVER_REC *server, char *chans)
static void event_whois_channels(IRC_SERVER_REC *server, const char *data)
{
- char *params, *nick, *chans;
+ char *params, *nick, *chans, *recoded;
g_return_if_fail(data != NULL);
@@ -288,23 +291,27 @@ 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(SERVER(server), chans, nick);
printformat(server, nick, MSGLEVEL_CRAP,
- IRCTXT_WHOIS_CHANNELS, nick, chans);
+ IRCTXT_WHOIS_CHANNELS, nick, recoded);
g_free(chans);
g_free(params);
+ g_free(recoded);
}
static void event_whois_away(IRC_SERVER_REC *server, const char *data)
{
- char *params, *nick, *awaymsg;
+ char *params, *nick, *awaymsg, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &awaymsg);
+ recoded = recode_in(SERVER(server), awaymsg, nick);
printformat(server, nick, MSGLEVEL_CRAP,
- IRCTXT_WHOIS_AWAY, nick, awaymsg);
+ IRCTXT_WHOIS_AWAY, nick, recoded);
g_free(params);
+ g_free(recoded);
}
static void event_end_of_whois(IRC_SERVER_REC *server, const char *data)
@@ -335,15 +342,17 @@ static void event_whois_auth(IRC_SERVER_REC *server, const char *data)
static void event_whowas(IRC_SERVER_REC *server, const char *data)
{
- char *params, *nick, *user, *host, *realname;
+ char *params, *nick, *user, *host, *realname, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 6, NULL, &nick, &user,
&host, NULL, &realname);
+ recoded = recode_in(SERVER(server), realname, nick);
printformat(server, nick, MSGLEVEL_CRAP,
- IRCTXT_WHOWAS, nick, user, host, realname);
+ IRCTXT_WHOWAS, nick, user, host, recoded);
g_free(params);
+ g_free(recoded);
}
static void event_end_of_whowas(IRC_SERVER_REC *server, const char *data)
diff --git a/src/irc/core/channel-events.c b/src/irc/core/channel-events.c
index 21c3d90a..7d4fbd39 100644
--- a/src/irc/core/channel-events.c
+++ b/src/irc/core/channel-events.c
@@ -23,6 +23,7 @@
#include "misc.h"
#include "channels-setup.h"
#include "settings.h"
+#include "recode.h"
#include "irc-servers.h"
#include "irc-channels.h"
@@ -121,13 +122,18 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel,
time_t settime)
{
CHANNEL_REC *chanrec;
+ char *recoded = NULL;
chanrec = channel_find(SERVER(server), 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(SERVER(server), topic, channel);
if (topic != NULL) {
g_free_not_null(chanrec->topic);
- chanrec->topic = g_strdup(topic);
+ chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded);
}
+ g_free(recoded);
g_free_not_null(chanrec->topic_by);
chanrec->topic_by = g_strdup(setby);
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c
index 857f0b68..7d3b861f 100644
--- a/src/irc/core/irc-commands.c
+++ b/src/irc/core/irc-commands.c
@@ -20,6 +20,7 @@
#include "module.h"
#include "misc.h"
+#include "recode.h"
#include "special-vars.h"
#include "settings.h"
#include "window-item-def.h"
@@ -63,6 +64,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
WI_ITEM_REC *item)
{
const char *target, *msg;
+ char *recoded;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -75,7 +77,9 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
if (*target == '\0' || *msg == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- g_string_sprintf(tmpstr, "NOTICE %s :%s", target, msg);
+ recoded = recode_out(SERVER(server), msg, target);
+ g_string_sprintf(tmpstr, "NOTICE %s :%s", target, recoded);
+ g_free(recoded);
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
@@ -104,7 +108,11 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
if (*ctcpdata == '\0')
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s\001", target, ctcpcmd);
else {
- g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
+ char *recoded;
+
+ recoded = recode_out(SERVER(server), ctcpdata, target);
+ g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s %s\001", target, ctcpcmd, recoded);
+ g_free(recoded);
}
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
@@ -117,7 +125,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
WI_ITEM_REC *item)
{
const char *target;
- char *ctcpcmd, *ctcpdata;
+ char *ctcpcmd, *ctcpdata, *recoded;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -131,7 +139,9 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
g_strup(ctcpcmd);
- g_string_sprintf(tmpstr, "NOTICE %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
+ recoded = recode_out(SERVER(server), ctcpdata, target);
+ g_string_sprintf(tmpstr, "NOTICE %s :\001%s %s\001", target, ctcpcmd, recoded);
+ g_free(recoded);
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
@@ -143,6 +153,7 @@ static void cmd_part(const char *data, IRC_SERVER_REC *server,
WI_ITEM_REC *item)
{
char *channame, *msg;
+ char *recoded = NULL;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -157,16 +168,19 @@ static void cmd_part(const char *data, IRC_SERVER_REC *server,
if (server->cmdcount > MAX_COMMANDS_ON_PART_UNTIL_PURGE)
irc_server_purge_output(server, channame);
- irc_send_cmdv(server, *msg == '\0' ? "PART %s" : "PART %s :%s",
- channame, msg);
+ if (*msg != '\0')
+ recoded = recode_out(SERVER(server), msg, channame);
+ irc_send_cmdv(server, ! recoded ? "PART %s" : "PART %s :%s",
+ channame, recoded);
+ g_free(recoded);
cmd_params_free(free_arg);
}
/* SYNTAX: KICK [<channel>] <nicks> [<reason>] */
static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
- char *channame, *nicks, *reason;
+ char *channame, *nicks, *reason, *recoded;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -179,7 +193,9 @@ 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);
- g_string_sprintf(tmpstr, "KICK %s %s :%s", channame, nicks, reason);
+ recoded = recode_out(SERVER(server), reason, channame);
+ g_string_sprintf(tmpstr, "KICK %s %s :%s", channame, nicks, recoded);
+ g_free(recoded);
irc_send_cmd_split(server, tmpstr->str, 3, server->max_kicks_in_cmd);
@@ -191,7 +207,7 @@ static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
{
GHashTable *optlist;
char *channame, *topic;
- int set = 0;
+ char *recoded = NULL;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -202,9 +218,10 @@ 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)
- set = 1;
- irc_send_cmdv(server, !set ? "TOPIC %s" : "TOPIC %s :%s",
- channame, topic);
+ recoded = recode_out(SERVER(server), topic, channame);
+ irc_send_cmdv(server, recoded == NULL ? "TOPIC %s" : "TOPIC %s :%s",
+ channame, recoded);
+ g_free(recoded);
cmd_params_free(free_arg);
}
@@ -608,7 +625,7 @@ static void cmd_wait(const char *data, IRC_SERVER_REC *server)
/* SYNTAX: WALL [<channel>] <message> */
static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
- char *channame, *msg, *args;
+ char *channame, *msg, *args, *recoded;
void *free_arg;
IRC_CHANNEL_REC *chanrec;
GSList *tmp, *nicks;
@@ -638,15 +655,18 @@ 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(SERVER(server), msg, channame);
+
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
NICK_REC *rec = tmp->data;
if (rec != chanrec->ownnick) {
irc_send_cmdv(server, "NOTICE %s :%s",
- rec->nick, msg);
+ rec->nick, recoded);
}
}
+ g_free(recoded);
g_free(msg);
g_slist_free(nicks);
}
@@ -659,7 +679,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
and it supports NOTICE @#channel anyway */
static void cmd_wallchops(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
- char *channame, *msg;
+ char *channame, *msg, *recoded;
void *free_arg;
CMD_IRC_SERVER(server);
@@ -669,8 +689,10 @@ 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);
- irc_send_cmdv(server, "WALLCHOPS %s :%s", channame, msg);
+ recoded = recode_out(SERVER(server), msg, channame);
+ irc_send_cmdv(server, "WALLCHOPS %s :%s", channame, recoded);
+ g_free(recoded);
cmd_params_free(free_arg);
}
@@ -679,7 +701,7 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
WI_ITEM_REC *item)
{
IRC_CHANNEL_REC *chanrec;
- char *channel, *nicks, *reason, *kickcmd, *bancmd;
+ char *channel, *nicks, *reason, *kickcmd, *bancmd, *recoded;
char **nicklist, *spacenicks;
void *free_arg;
@@ -702,7 +724,9 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
spacenicks = g_strjoinv(" ", nicklist);
g_strfreev(nicklist);
- kickcmd = g_strdup_printf("%s %s %s", chanrec->name, nicks, reason);
+ recoded = recode_out(SERVER(server), reason, channel);
+ kickcmd = g_strdup_printf("%s %s %s", chanrec->name, nicks, recoded);
+ g_free(recoded);
bancmd = g_strdup_printf("%s %s", chanrec->name, spacenicks);
g_free(spacenicks);
@@ -762,7 +786,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
IRC_CHANNEL_REC *channel)
{
KNOCKOUT_REC *rec;
- char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd;
+ char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd, *recoded;
char **nicklist, *spacenicks, *banmasks;
void *free_arg;
int timeleft;
@@ -799,7 +823,9 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
banmasks = ban_get_masks(channel, spacenicks, 0);
g_free(spacenicks);
- kickcmd = g_strdup_printf("%s %s %s", channel->name, nicks, reason);
+ recoded = recode_out(SERVER(server), reason, channel->name);
+ kickcmd = g_strdup_printf("%s %s %s", channel->name, nicks, recoded);
+ g_free(recoded);
bancmd = *banmasks == '\0'? NULL :
g_strdup_printf("%s %s", channel->name, banmasks);
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index a607848f..0286df79 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -28,7 +28,6 @@
#include "irc-servers.h"
#include "irc-channels.h"
#include "servers-redirect.h"
-#include "recode.h"
char *current_server_event;
static int signal_default_event;
@@ -49,7 +48,6 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
{
char str[513];
int len;
- char *params, *target, *recoded_line;
g_return_if_fail(server != NULL);
g_return_if_fail(cmd != NULL);
@@ -57,8 +55,6 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
if (server->connection_lost)
return;
- params = event_get_params(cmd, 2, NULL, &target);
- cmd = recoded_line = recode_out(SERVER(server), cmd, target);
len = strlen(cmd);
server->cmdcount++;
@@ -102,8 +98,6 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
}
}
server->redirect_next = NULL;
- g_free(params);
- g_free(recoded_line);
}
/* Send command to IRC server */
@@ -286,28 +280,18 @@ static void irc_server_event(IRC_SERVER_REC *server, const char *line,
{
const char *signal;
char *event, *args;
- char *params, *target, *recoded_line, *recoded_nick;
g_return_if_fail(line != NULL);
- params = event_get_params(line, 2, NULL, &target);
- recoded_nick = recode_in(SERVER(server), nick, NULL);
- if (!ischannel(*target)) {
- if (*target == '@' && ischannel(target[1]))
- target++;
- else
- target = recoded_nick;
- }
- recoded_line = recode_in(SERVER(server), line, target);
/* split event / args */
- event = g_strconcat("event ", recoded_line, NULL);
+ event = g_strconcat("event ", line, NULL);
args = strchr(event+6, ' ');
if (args != NULL) *args++ = '\0'; else args = "";
while (*args == ' ') args++;
g_strdown(event);
/* check if event needs to be redirected */
- signal = server_redirect_get_signal(server, recoded_nick, event, args);
+ signal = server_redirect_get_signal(server, nick, event, args);
if (signal == NULL)
signal = event;
else
@@ -315,14 +299,11 @@ static void irc_server_event(IRC_SERVER_REC *server, const char *line,
/* emit it */
current_server_event = event+6;
- if (!signal_emit(signal, 4, server, args, recoded_nick, address))
- signal_emit_id(signal_default_event, 4, server, recoded_line, recoded_nick, address);
+ if (!signal_emit(signal, 4, server, args, nick, address))
+ signal_emit_id(signal_default_event, 4, server, line, nick, address);
current_server_event = NULL;
g_free(event);
- g_free(params);
- g_free(recoded_line);
- g_free(recoded_nick);
}
static char *irc_parse_prefix(char *line, char **nick, char **address)