diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2007-05-05 15:37:58 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2007-05-05 15:37:58 +0000 |
commit | bfc0b362e8f831dd47fec43a0ad18e4b2cfbba34 (patch) | |
tree | 969d5c50235b1247b7430ba5118dfb38a332df87 /src | |
parent | 2a915b21dede9b2ddac8822da7c9697ea8c71bbd (diff) | |
download | irssi-bfc0b362e8f831dd47fec43a0ad18e4b2cfbba34.zip |
Move input recoding in irc_server_event.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4483 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/core/fe-messages.c | 14 | ||||
-rw-r--r-- | src/fe-common/irc/fe-events-numeric.c | 25 | ||||
-rw-r--r-- | src/fe-common/irc/fe-events.c | 40 | ||||
-rw-r--r-- | src/fe-common/irc/fe-irc-messages.c | 21 | ||||
-rw-r--r-- | src/fe-common/irc/fe-whois.c | 25 | ||||
-rw-r--r-- | src/irc/core/irc.c | 22 |
6 files changed, 58 insertions, 89 deletions
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c index ee910f89..ce2da9c0 100644 --- a/src/fe-common/core/fe-messages.c +++ b/src/fe-common/core/fe-messages.c @@ -355,7 +355,7 @@ static void sig_message_quit(SERVER_REC *server, const char *nick, WINDOW_REC *window; GString *chans; GSList *tmp, *windows; - char *print_channel, *recoded; + char *print_channel; int once, count; if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS)) @@ -388,12 +388,10 @@ 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, recoded, + TXT_QUIT, nick, address, reason, rec->visible_name); - g_free(recoded); } } count++; @@ -405,10 +403,8 @@ 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, recoded, ""); - g_free(recoded); + TXT_QUIT, nick, address, reason, ""); } } @@ -416,11 +412,9 @@ 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(server, reason, nick); printformat(server, print_channel, MSGLEVEL_QUITS, count <= 1 ? TXT_QUIT : TXT_QUIT_ONCE, - nick, address, recoded, chans->str); - g_free(recoded); + nick, address, reason, chans->str); } 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 f8e2d102..06c45161 100644 --- a/src/fe-common/irc/fe-events-numeric.c +++ b/src/fe-common/irc/fe-events-numeric.c @@ -24,7 +24,6 @@ #include "misc.h" #include "settings.h" #include "levels.h" -#include "recode.h" #include "irc-servers.h" #include "irc-channels.h" @@ -106,7 +105,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, *recoded; + char *serv; g_return_if_fail(data != NULL); @@ -119,12 +118,10 @@ static void event_who(IRC_SERVER_REC *server, const char *data) while (*realname == ' ') realname++; if (realname > hops) realname[-1] = '\0'; - recoded = recode_in(SERVER(server), realname, nick); printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_WHO, - channel, nick, stat, hops, user, host, recoded, serv); + channel, nick, stat, hops, user, host, realname, serv); g_free(params); - g_free(recoded); } static void event_end_of_who(IRC_SERVER_REC *server, const char *data) @@ -231,17 +228,15 @@ 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, *recoded; + char *params, *topic; 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, recoded); + IRCTXT_TOPIC, channel, topic); g_free(params); - g_free(recoded); } static void event_topic_info(IRC_SERVER_REC *server, const char *data) @@ -311,12 +306,11 @@ 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, *recoded; + char *params, *nick, *awaymsg; 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) { @@ -328,10 +322,9 @@ 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, recoded); + IRCTXT_NICK_AWAY, nick, awaymsg); } g_free(params); - g_free(recoded); } static void event_userhost(IRC_SERVER_REC *server, const char *data) @@ -505,7 +498,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, *recoded; + char *target, *args, *ptr; int format; g_return_if_fail(data != NULL); @@ -540,14 +533,12 @@ 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, recoded, current_server_event); + nick, args, 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 8af264dd..c36bb3ba 100644 --- a/src/fe-common/irc/fe-events.c +++ b/src/fe-common/irc/fe-events.c @@ -30,7 +30,6 @@ #include "servers-reconnect.h" #include "queries.h" #include "ignore.h" -#include "recode.h" #include "irc-servers.h" #include "irc-channels.h" @@ -45,7 +44,7 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data, const char *nick, const char *addr) { - char *params, *target, *msg, *recoded; + char *params, *target, *msg; g_return_if_fail(data != NULL); @@ -54,55 +53,46 @@ 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, recoded, nick, addr, + server, msg, 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, recoded, nick, addr, + server, msg, 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, recoded, nick, addr, + server, data, 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, *recoded; + char *params, *target, *msg; 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, recoded, nick, addr, + signal_emit("message irc notice", 5, server, msg, nick, addr, get_visible_target(server, target)); g_free(params); - g_free(recoded); } static void event_join(IRC_SERVER_REC *server, const char *data, @@ -124,17 +114,15 @@ 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, *recoded; + char *params, *channel, *reason; 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, recoded); + get_visible_target(server, channel), nick, addr, reason); g_free(params); - g_free(recoded); } static void event_quit(IRC_SERVER_REC *server, const char *data, @@ -149,18 +137,16 @@ 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, *recoded; + char *params, *channel, *nick, *reason; 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, recoded); + nick, kicker, addr, reason); g_free(params); - g_free(recoded); } static void event_kill(IRC_SERVER_REC *server, const char *data, @@ -256,17 +242,15 @@ 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, *recoded; + char *params, *channel, *topic; 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), recoded, nick, addr); + get_visible_target(server, channel), topic, 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-messages.c b/src/fe-common/irc/fe-irc-messages.c index 5c3a95b3..5c924d27 100644 --- a/src/fe-common/irc/fe-irc-messages.c +++ b/src/fe-common/irc/fe-irc-messages.c @@ -150,7 +150,7 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg, const char *target) { void *item; - char *freemsg = NULL, *recoded; + char *freemsg = NULL; int level; level = MSGLEVEL_ACTIONS | @@ -167,28 +167,26 @@ 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)) { /* message to active channel in window */ printformat(server, target, level, - IRCTXT_ACTION_PUBLIC, nick, recoded); + IRCTXT_ACTION_PUBLIC, nick, msg); } else { /* message to not existing/active channel */ printformat(server, target, level, IRCTXT_ACTION_PUBLIC_CHANNEL, - nick, target, recoded); + nick, target, msg); } } else { /* private action */ printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS, item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY, - nick, address == NULL ? "" : address, recoded); + nick, address == NULL ? "" : address, msg); } - g_free(recoded); g_free_not_null(freemsg); } @@ -208,20 +206,17 @@ 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(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, recoded); + IRCTXT_NOTICE_SERVER, nick, msg); } - g_free(recoded); return; } @@ -230,19 +225,17 @@ 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, recoded); + IRCTXT_NOTICE_PUBLIC, nick, oldtarget, msg); } else { /* private notice */ privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_NOTICES); printformat(server, nick, MSGLEVEL_NOTICES, - IRCTXT_NOTICE_PRIVATE, nick, address, recoded); + IRCTXT_NOTICE_PRIVATE, nick, address, msg); } - 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 3f738ab6..64e11a14 100644 --- a/src/fe-common/irc/fe-whois.c +++ b/src/fe-common/irc/fe-whois.c @@ -6,7 +6,6 @@ #include "levels.h" #include "misc.h" #include "settings.h" -#include "recode.h" #include "irc-servers.h" @@ -14,17 +13,15 @@ static void event_whois(IRC_SERVER_REC *server, const char *data) { - char *params, *nick, *user, *host, *realname, *recoded; + char *params, *nick, *user, *host, *realname; 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, recoded); + IRCTXT_WHOIS, nick, user, host, realname); g_free(params); - g_free(recoded); } static void event_whois_special(IRC_SERVER_REC *server, const char *data) @@ -249,7 +246,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, *recoded; + char *params, *nick, *chans; g_return_if_fail(data != NULL); @@ -262,27 +259,23 @@ 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, recoded); + IRCTXT_WHOIS_CHANNELS, nick, chans); 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, *recoded; + char *params, *nick, *awaymsg; 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, recoded); + IRCTXT_WHOIS_AWAY, nick, awaymsg); g_free(params); - g_free(recoded); } static void event_end_of_whois(IRC_SERVER_REC *server, const char *data) @@ -313,17 +306,15 @@ 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, *recoded; + char *params, *nick, *user, *host, *realname; 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, recoded); + IRCTXT_WHOWAS, nick, user, host, realname); 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/irc.c b/src/irc/core/irc.c index 528e541f..63324762 100644 --- a/src/irc/core/irc.c +++ b/src/irc/core/irc.c @@ -29,6 +29,7 @@ #include "irc-servers.h" #include "irc-channels.h" #include "servers-redirect.h" +#include "recode.h" char *current_server_event; static int signal_default_event; @@ -281,11 +282,22 @@ 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, *recoded_channel; g_return_if_fail(line != NULL); + params = event_get_params(line, 1, &args); + recoded_nick = recode_in(SERVER(server), nick, NULL); + if (ischannel(*args) || + (*args++ == '@' && ischannel(*args))) + target = recoded_channel = recode_in(SERVER(server), args, NULL); + else { + target = recoded_nick; + recoded_channel = NULL; + } + recoded_line = recode_in(SERVER(server), line, target); /* split event / args */ - event = g_strconcat("event ", line, NULL); + event = g_strconcat("event ", recoded_line, NULL); args = strchr(event+6, ' '); if (args != NULL) *args++ = '\0'; else args = ""; while (*args == ' ') args++; @@ -300,11 +312,15 @@ 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, nick, address)) - signal_emit_id(signal_default_event, 4, server, line, nick, address); + if (!signal_emit(signal, 4, server, args, recoded_nick, address)) + signal_emit_id(signal_default_event, 4, server, recoded_line, recoded_nick, address); current_server_event = NULL; g_free(event); + g_free(params); + g_free(recoded_line); + g_free(recoded_nick); + g_free(recoded_channel); } /* Read line from server */ |