mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Move output recoding in irc_send_cmd_full.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4715 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
a0400dc3d2
commit
0eb386ecd8
@ -24,7 +24,6 @@
|
|||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "special-vars.h"
|
#include "special-vars.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "recode.h"
|
|
||||||
|
|
||||||
#include "chat-protocols.h"
|
#include "chat-protocols.h"
|
||||||
#include "servers.h"
|
#include "servers.h"
|
||||||
@ -350,7 +349,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)
|
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
char *target, *origtarget, *msg, *recoded;
|
char *target, *origtarget, *msg;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int free_ret, target_type = SEND_TARGET_NICK;
|
int free_ret, target_type = SEND_TARGET_NICK;
|
||||||
|
|
||||||
@ -402,16 +401,14 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
|
SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recoded = recode_out(server, msg, target);
|
|
||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
signal_emit("server sendmsg", 4, server, target, recoded,
|
signal_emit("server sendmsg", 4, server, target, msg,
|
||||||
GINT_TO_POINTER(target_type));
|
GINT_TO_POINTER(target_type));
|
||||||
}
|
}
|
||||||
signal_emit(target != NULL && target_type == SEND_TARGET_CHANNEL ?
|
signal_emit(target != NULL && target_type == SEND_TARGET_CHANNEL ?
|
||||||
"message own_public" : "message own_private", 4,
|
"message own_public" : "message own_private", 4,
|
||||||
server, recoded, target, origtarget);
|
server, msg, target, origtarget);
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
if (free_ret && target != NULL) g_free(target);
|
if (free_ret && target != NULL) g_free(target);
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "servers.h"
|
#include "servers.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "servers-setup.h"
|
#include "servers-setup.h"
|
||||||
#include "recode.h"
|
|
||||||
|
|
||||||
#include "autorun.h"
|
#include "autorun.h"
|
||||||
#include "fe-core-commands.h"
|
#include "fe-core-commands.h"
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
#include "recode.h"
|
|
||||||
|
|
||||||
#include "window-items.h"
|
#include "window-items.h"
|
||||||
#include "fe-queries.h"
|
#include "fe-queries.h"
|
||||||
@ -259,7 +258,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
|||||||
WINDOW_REC *window;
|
WINDOW_REC *window;
|
||||||
CHANNEL_REC *channel;
|
CHANNEL_REC *channel;
|
||||||
const char *nickmode;
|
const char *nickmode;
|
||||||
char *freemsg = NULL, *recoded;
|
char *freemsg = NULL;
|
||||||
int print_channel;
|
int print_channel;
|
||||||
channel = channel_find(server, target);
|
channel = channel_find(server, target);
|
||||||
if (channel != NULL)
|
if (channel != NULL)
|
||||||
@ -280,18 +279,14 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
|||||||
if (settings_get_bool("emphasis"))
|
if (settings_get_bool("emphasis"))
|
||||||
msg = freemsg = expand_emphasis((WI_ITEM_REC *) channel, msg);
|
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) {
|
if (!print_channel) {
|
||||||
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||||
TXT_OWN_MSG, server->nick, recoded, nickmode);
|
TXT_OWN_MSG, server->nick, msg, nickmode);
|
||||||
} else {
|
} else {
|
||||||
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||||
TXT_OWN_MSG_CHANNEL, server->nick, target, recoded, nickmode);
|
TXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
g_free_not_null(freemsg);
|
g_free_not_null(freemsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +294,7 @@ static void sig_message_own_private(SERVER_REC *server, const char *msg,
|
|||||||
const char *target, const char *origtarget)
|
const char *target, const char *origtarget)
|
||||||
{
|
{
|
||||||
QUERY_REC *query;
|
QUERY_REC *query;
|
||||||
char *freemsg = NULL, *recoded;
|
char *freemsg = NULL;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
g_return_if_fail(msg != NULL);
|
g_return_if_fail(msg != NULL);
|
||||||
@ -322,15 +317,11 @@ static void sig_message_own_private(SERVER_REC *server, const char *msg,
|
|||||||
if (settings_get_bool("emphasis"))
|
if (settings_get_bool("emphasis"))
|
||||||
msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
|
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,
|
printformat(server, target,
|
||||||
MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||||
query == NULL ? TXT_OWN_MSG_PRIVATE :
|
query == NULL ? TXT_OWN_MSG_PRIVATE :
|
||||||
TXT_OWN_MSG_PRIVATE_QUERY, target, recoded, server->nick);
|
TXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
g_free_not_null(freemsg);
|
g_free_not_null(freemsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +402,6 @@ static void sig_message_quit(SERVER_REC *server, const char *nick,
|
|||||||
if (once || count == 0) {
|
if (once || count == 0) {
|
||||||
if (chans->len > 0)
|
if (chans->len > 0)
|
||||||
g_string_truncate(chans, chans->len-1);
|
g_string_truncate(chans, chans->len-1);
|
||||||
/* at least recode_fallback will be used */
|
|
||||||
printformat(server, print_channel, MSGLEVEL_QUITS,
|
printformat(server, print_channel, MSGLEVEL_QUITS,
|
||||||
count <= 1 ? TXT_QUIT : TXT_QUIT_ONCE,
|
count <= 1 ? TXT_QUIT : TXT_QUIT_ONCE,
|
||||||
nick, address, reason, chans->str);
|
nick, address, reason, chans->str);
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "module-formats.h"
|
#include "module-formats.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "recode.h"
|
|
||||||
#include "special-vars.h"
|
#include "special-vars.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@ -45,7 +44,6 @@
|
|||||||
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *target;
|
const char *target;
|
||||||
char *recoded;
|
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
if (!IS_IRC_ITEM(item))
|
if (!IS_IRC_ITEM(item))
|
||||||
@ -55,15 +53,12 @@ static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
cmd_return_error(CMDERR_NOT_CONNECTED);
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
||||||
|
|
||||||
target = window_item_get_target(item);
|
target = window_item_get_target(item);
|
||||||
recoded = recode_out(SERVER(server), data, target);
|
|
||||||
|
|
||||||
signal_emit("message irc own_action", 3, server, recoded,
|
signal_emit("message irc own_action", 3, server, data,
|
||||||
item->visible_name);
|
item->visible_name);
|
||||||
|
|
||||||
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001",
|
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001",
|
||||||
target, recoded);
|
target, data);
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: ACTION [-<server tag>] <target> <message> */
|
/* SYNTAX: ACTION [-<server tag>] <target> <message> */
|
||||||
@ -71,7 +66,6 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
|
|||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
const char *target, *text;
|
const char *target, *text;
|
||||||
char *recoded;
|
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -87,12 +81,10 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
|
|||||||
if (server == NULL || !server->connected)
|
if (server == NULL || !server->connected)
|
||||||
cmd_param_error(CMDERR_NOT_CONNECTED);
|
cmd_param_error(CMDERR_NOT_CONNECTED);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), text, target);
|
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, text);
|
||||||
irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001", target, recoded);
|
|
||||||
|
|
||||||
signal_emit("message irc own_action", 3, server, recoded, target);
|
signal_emit("message irc own_action", 3, server, text, target);
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +92,6 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
|||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *target, *msg;
|
const char *target, *msg;
|
||||||
char *recoded;
|
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -114,10 +105,8 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
|||||||
if (*target == '\0' || *msg == '\0')
|
if (*target == '\0' || *msg == '\0')
|
||||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), msg, target);
|
signal_emit("message irc own_notice", 3, server, msg, target);
|
||||||
signal_emit("message irc own_notice", 3, server, recoded, target);
|
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "recode.h"
|
|
||||||
|
|
||||||
#include "irc-servers.h"
|
#include "irc-servers.h"
|
||||||
#include "irc-channels.h"
|
#include "irc-channels.h"
|
||||||
@ -68,7 +67,7 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
|||||||
const char *target, const char *origtarget)
|
const char *target, const char *origtarget)
|
||||||
{
|
{
|
||||||
const char *oldtarget;
|
const char *oldtarget;
|
||||||
char *nickmode, *recoded;
|
char *nickmode;
|
||||||
|
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(IRC_SERVER(server), target);
|
target = skip_target(IRC_SERVER(server), target);
|
||||||
@ -78,15 +77,12 @@ static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
|||||||
nickmode = channel_get_nickmode(channel_find(server, target),
|
nickmode = channel_get_nickmode(channel_find(server, target),
|
||||||
server->nick);
|
server->nick);
|
||||||
|
|
||||||
/* ugly: recode the sent message back for printing */
|
|
||||||
recoded = recode_in(SERVER(server), msg, target);
|
|
||||||
printformat_module("fe-common/core", server, target,
|
printformat_module("fe-common/core", server, target,
|
||||||
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
|
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
|
||||||
MSGLEVEL_NO_ACT,
|
MSGLEVEL_NO_ACT,
|
||||||
TXT_OWN_MSG_CHANNEL,
|
TXT_OWN_MSG_CHANNEL,
|
||||||
server->nick, oldtarget, recoded, nickmode);
|
server->nick, oldtarget, msg, nickmode);
|
||||||
g_free(nickmode);
|
g_free(nickmode);
|
||||||
g_free(recoded);
|
|
||||||
signal_stop();
|
signal_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,21 +110,18 @@ 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,
|
static void sig_message_own_wall(SERVER_REC *server, const char *msg,
|
||||||
const char *target)
|
const char *target)
|
||||||
{
|
{
|
||||||
char *nickmode, *optarget, *recoded;
|
char *nickmode, *optarget;
|
||||||
|
|
||||||
nickmode = channel_get_nickmode(channel_find(server, target),
|
nickmode = channel_get_nickmode(channel_find(server, target),
|
||||||
server->nick);
|
server->nick);
|
||||||
|
|
||||||
optarget = g_strconcat("@", target, NULL);
|
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,
|
printformat_module("fe-common/core", server, target,
|
||||||
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
|
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
|
||||||
MSGLEVEL_NO_ACT,
|
MSGLEVEL_NO_ACT,
|
||||||
TXT_OWN_MSG_CHANNEL,
|
TXT_OWN_MSG_CHANNEL,
|
||||||
server->nick, optarget, recoded, nickmode);
|
server->nick, optarget, msg, nickmode);
|
||||||
g_free(nickmode);
|
g_free(nickmode);
|
||||||
g_free(recoded);
|
|
||||||
g_free(optarget);
|
g_free(optarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +130,7 @@ static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
{
|
{
|
||||||
void *item;
|
void *item;
|
||||||
const char *oldtarget;
|
const char *oldtarget;
|
||||||
char *freemsg = NULL, *recoded;
|
char *freemsg = NULL;
|
||||||
|
|
||||||
oldtarget = target;
|
oldtarget = target;
|
||||||
target = skip_target(IRC_SERVER(server), target);
|
target = skip_target(IRC_SERVER(server), target);
|
||||||
@ -149,15 +142,11 @@ static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
if (settings_get_bool("emphasis"))
|
if (settings_get_bool("emphasis"))
|
||||||
msg = freemsg = expand_emphasis(item, msg);
|
msg = freemsg = expand_emphasis(item, msg);
|
||||||
|
|
||||||
/* ugly: recode the sent message back for printing */
|
|
||||||
recoded = recode_in(SERVER(server), msg, target);
|
|
||||||
|
|
||||||
printformat(server, target,
|
printformat(server, target,
|
||||||
MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT |
|
MSGLEVEL_ACTIONS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT |
|
||||||
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
|
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS),
|
||||||
item != NULL && oldtarget == target ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
|
item != NULL && oldtarget == target ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
|
||||||
server->nick, recoded, oldtarget);
|
server->nick, msg, oldtarget);
|
||||||
g_free(recoded);
|
|
||||||
g_free_not_null(freemsg);
|
g_free_not_null(freemsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,12 +202,9 @@ static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
|
|||||||
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
|
static void sig_message_own_notice(IRC_SERVER_REC *server, const char *msg,
|
||||||
const char *target)
|
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 |
|
printformat(server, skip_target(server, target), MSGLEVEL_NOTICES |
|
||||||
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||||
IRCTXT_OWN_NOTICE, target, recoded);
|
IRCTXT_OWN_NOTICE, target, msg);
|
||||||
g_free(recoded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
|
static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "channels-setup.h"
|
#include "channels-setup.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "recode.h"
|
|
||||||
|
|
||||||
#include "irc-servers.h"
|
#include "irc-servers.h"
|
||||||
#include "irc-channels.h"
|
#include "irc-channels.h"
|
||||||
@ -122,18 +121,13 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel,
|
|||||||
time_t settime)
|
time_t settime)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
CHANNEL_REC *chanrec;
|
||||||
char *recoded = NULL;
|
|
||||||
|
|
||||||
chanrec = channel_find(SERVER(server), channel);
|
chanrec = channel_find(SERVER(server), channel);
|
||||||
if (chanrec == NULL) return;
|
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) {
|
if (topic != NULL) {
|
||||||
g_free_not_null(chanrec->topic);
|
g_free_not_null(chanrec->topic);
|
||||||
chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded);
|
chanrec->topic = g_strdup(topic);
|
||||||
}
|
}
|
||||||
g_free(recoded);
|
|
||||||
|
|
||||||
g_free_not_null(chanrec->topic_by);
|
g_free_not_null(chanrec->topic_by);
|
||||||
chanrec->topic_by = g_strdup(setby);
|
chanrec->topic_by = g_strdup(setby);
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "recode.h"
|
|
||||||
#include "special-vars.h"
|
#include "special-vars.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "window-item-def.h"
|
#include "window-item-def.h"
|
||||||
@ -64,7 +63,6 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
|||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *target, *msg;
|
const char *target, *msg;
|
||||||
char *recoded;
|
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -77,9 +75,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
|||||||
if (*target == '\0' || *msg == '\0')
|
if (*target == '\0' || *msg == '\0')
|
||||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), msg, target);
|
g_string_sprintf(tmpstr, "NOTICE %s :%s", target, msg);
|
||||||
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);
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
|
||||||
|
|
||||||
@ -108,11 +104,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
|
|||||||
if (*ctcpdata == '\0')
|
if (*ctcpdata == '\0')
|
||||||
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s\001", target, ctcpcmd);
|
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s\001", target, ctcpcmd);
|
||||||
else {
|
else {
|
||||||
char *recoded;
|
g_string_sprintf(tmpstr, "PRIVMSG %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
|
||||||
|
|
||||||
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);
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
|
||||||
@ -125,7 +117,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
|
|||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *target;
|
const char *target;
|
||||||
char *ctcpcmd, *ctcpdata, *recoded;
|
char *ctcpcmd, *ctcpdata;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -139,9 +131,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
|
|||||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
g_strup(ctcpcmd);
|
g_strup(ctcpcmd);
|
||||||
recoded = recode_out(SERVER(server), ctcpdata, target);
|
g_string_sprintf(tmpstr, "NOTICE %s :\001%s %s\001", target, ctcpcmd, ctcpdata);
|
||||||
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);
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
|
||||||
|
|
||||||
@ -153,7 +143,6 @@ static void cmd_part(const char *data, IRC_SERVER_REC *server,
|
|||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *channame, *msg;
|
char *channame, *msg;
|
||||||
char *recoded = NULL;
|
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -168,19 +157,16 @@ static void cmd_part(const char *data, IRC_SERVER_REC *server,
|
|||||||
if (server->cmdcount > MAX_COMMANDS_ON_PART_UNTIL_PURGE)
|
if (server->cmdcount > MAX_COMMANDS_ON_PART_UNTIL_PURGE)
|
||||||
irc_server_purge_output(server, channame);
|
irc_server_purge_output(server, channame);
|
||||||
|
|
||||||
if (*msg != '\0')
|
irc_send_cmdv(server, *msg == '\0' ? "PART %s" : "PART %s :%s",
|
||||||
recoded = recode_out(SERVER(server), msg, channame);
|
channame, msg);
|
||||||
irc_send_cmdv(server, ! recoded ? "PART %s" : "PART %s :%s",
|
|
||||||
channame, recoded);
|
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: KICK [<channel>] <nicks> [<reason>] */
|
/* SYNTAX: KICK [<channel>] <nicks> [<reason>] */
|
||||||
static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *channame, *nicks, *reason, *recoded;
|
char *channame, *nicks, *reason;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -193,9 +179,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 (*channame == '\0' || *nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
if (!ischannel(*channame)) cmd_param_error(CMDERR_NOT_JOINED);
|
if (!ischannel(*channame)) cmd_param_error(CMDERR_NOT_JOINED);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), reason, channame);
|
g_string_sprintf(tmpstr, "KICK %s %s :%s", channame, nicks, reason);
|
||||||
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);
|
irc_send_cmd_split(server, tmpstr->str, 3, server->max_kicks_in_cmd);
|
||||||
|
|
||||||
@ -207,7 +191,7 @@ static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
|
|||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
char *channame, *topic;
|
char *channame, *topic;
|
||||||
char *recoded = NULL;
|
int set = 0;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -218,10 +202,9 @@ static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (*topic != '\0' || g_hash_table_lookup(optlist, "delete") != NULL)
|
if (*topic != '\0' || g_hash_table_lookup(optlist, "delete") != NULL)
|
||||||
recoded = recode_out(SERVER(server), topic, channame);
|
set = 1;
|
||||||
irc_send_cmdv(server, recoded == NULL ? "TOPIC %s" : "TOPIC %s :%s",
|
irc_send_cmdv(server, !set ? "TOPIC %s" : "TOPIC %s :%s",
|
||||||
channame, recoded);
|
channame, topic);
|
||||||
g_free(recoded);
|
|
||||||
|
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
@ -625,7 +608,7 @@ static void cmd_wait(const char *data, IRC_SERVER_REC *server)
|
|||||||
/* SYNTAX: WALL [<channel>] <message> */
|
/* SYNTAX: WALL [<channel>] <message> */
|
||||||
static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *channame, *msg, *args, *recoded;
|
char *channame, *msg, *args;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
IRC_CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
GSList *tmp, *nicks;
|
GSList *tmp, *nicks;
|
||||||
@ -655,18 +638,15 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||||||
SERVER(server), item, args, NULL, 0);
|
SERVER(server), item, args, NULL, 0);
|
||||||
g_free(args);
|
g_free(args);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), msg, channame);
|
|
||||||
|
|
||||||
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
||||||
NICK_REC *rec = tmp->data;
|
NICK_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec != chanrec->ownnick) {
|
if (rec != chanrec->ownnick) {
|
||||||
irc_send_cmdv(server, "NOTICE %s :%s",
|
irc_send_cmdv(server, "NOTICE %s :%s",
|
||||||
rec->nick, recoded);
|
rec->nick, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
g_free(msg);
|
g_free(msg);
|
||||||
g_slist_free(nicks);
|
g_slist_free(nicks);
|
||||||
}
|
}
|
||||||
@ -679,7 +659,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||||||
and it supports NOTICE @#channel anyway */
|
and it supports NOTICE @#channel anyway */
|
||||||
static void cmd_wallchops(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
static void cmd_wallchops(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *channame, *msg, *recoded;
|
char *channame, *msg;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
@ -689,10 +669,8 @@ static void cmd_wallchops(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC
|
|||||||
return;
|
return;
|
||||||
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), msg, channame);
|
irc_send_cmdv(server, "WALLCHOPS %s :%s", channame, msg);
|
||||||
irc_send_cmdv(server, "WALLCHOPS %s :%s", channame, recoded);
|
|
||||||
|
|
||||||
g_free(recoded);
|
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,7 +679,7 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
|
|||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
IRC_CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *channel, *nicks, *reason, *kickcmd, *bancmd, *recoded;
|
char *channel, *nicks, *reason, *kickcmd, *bancmd;
|
||||||
char **nicklist, *spacenicks;
|
char **nicklist, *spacenicks;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
@ -724,9 +702,7 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
|
|||||||
spacenicks = g_strjoinv(" ", nicklist);
|
spacenicks = g_strjoinv(" ", nicklist);
|
||||||
g_strfreev(nicklist);
|
g_strfreev(nicklist);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), reason, channel);
|
kickcmd = g_strdup_printf("%s %s %s", chanrec->name, nicks, reason);
|
||||||
kickcmd = g_strdup_printf("%s %s %s", chanrec->name, nicks, recoded);
|
|
||||||
g_free(recoded);
|
|
||||||
|
|
||||||
bancmd = g_strdup_printf("%s %s", chanrec->name, spacenicks);
|
bancmd = g_strdup_printf("%s %s", chanrec->name, spacenicks);
|
||||||
g_free(spacenicks);
|
g_free(spacenicks);
|
||||||
@ -786,7 +762,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|||||||
IRC_CHANNEL_REC *channel)
|
IRC_CHANNEL_REC *channel)
|
||||||
{
|
{
|
||||||
KNOCKOUT_REC *rec;
|
KNOCKOUT_REC *rec;
|
||||||
char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd, *recoded;
|
char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd;
|
||||||
char **nicklist, *spacenicks, *banmasks;
|
char **nicklist, *spacenicks, *banmasks;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int timeleft;
|
int timeleft;
|
||||||
@ -823,9 +799,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|||||||
banmasks = ban_get_masks(channel, spacenicks, 0);
|
banmasks = ban_get_masks(channel, spacenicks, 0);
|
||||||
g_free(spacenicks);
|
g_free(spacenicks);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), reason, channel->name);
|
kickcmd = g_strdup_printf("%s %s %s", channel->name, nicks, reason);
|
||||||
kickcmd = g_strdup_printf("%s %s %s", channel->name, nicks, recoded);
|
|
||||||
g_free(recoded);
|
|
||||||
|
|
||||||
bancmd = *banmasks == '\0'? NULL :
|
bancmd = *banmasks == '\0'? NULL :
|
||||||
g_strdup_printf("%s %s", channel->name, banmasks);
|
g_strdup_printf("%s %s", channel->name, banmasks);
|
||||||
|
@ -50,6 +50,7 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
|
|||||||
{
|
{
|
||||||
char str[513];
|
char str[513];
|
||||||
int len;
|
int len;
|
||||||
|
char *params, *target, *recoded_line;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
g_return_if_fail(cmd != NULL);
|
g_return_if_fail(cmd != NULL);
|
||||||
@ -57,6 +58,8 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
|
|||||||
if (server->connection_lost)
|
if (server->connection_lost)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
params = event_get_params(cmd, 2, NULL, &target);
|
||||||
|
cmd = recoded_line = recode_out(SERVER(server), cmd, target);
|
||||||
len = strlen(cmd);
|
len = strlen(cmd);
|
||||||
server->cmdcount++;
|
server->cmdcount++;
|
||||||
|
|
||||||
@ -100,6 +103,8 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd,
|
|||||||
server->redirect_next);
|
server->redirect_next);
|
||||||
}
|
}
|
||||||
server->redirect_next = NULL;
|
server->redirect_next = NULL;
|
||||||
|
g_free(params);
|
||||||
|
g_free(recoded_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send command to IRC server */
|
/* Send command to IRC server */
|
||||||
|
Loading…
Reference in New Issue
Block a user