summaryrefslogtreecommitdiff
path: root/src/irc/core
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 /src/irc/core
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
Diffstat (limited to 'src/irc/core')
-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
3 files changed, 57 insertions, 44 deletions
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)