summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-protocol.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-04-30 18:18:14 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-04-30 18:18:14 +0200
commitbbde23dec66de5ddf00b75fedb0abf6a93e6a079 (patch)
treef73196dc26f9a187e2535f9e0a67d1c7dc654eed /src/plugins/irc/irc-protocol.c
parent339be5544f8364920750921d2e4ef07c45370769 (diff)
downloadweechat-bbde23dec66de5ddf00b75fedb0abf6a93e6a079.zip
IRC colors reintroduced
Diffstat (limited to 'src/plugins/irc/irc-protocol.c')
-rw-r--r--src/plugins/irc/irc-protocol.c260
1 files changed, 137 insertions, 123 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index d4ac892d9..e051e67b8 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -41,6 +41,7 @@
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-protocol.h"
+#include "irc-color.h"
#include "irc-command.h"
#include "irc-config.h"
#include "irc-server.h"
@@ -2386,7 +2387,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command,
int argc, char **argv, char **argv_eol,
int highlight)
{
- char *pos_topic;
+ char *pos_topic, *topic_color;
struct t_irc_channel *ptr_channel;
struct t_gui_buffer *buffer;
@@ -2415,6 +2416,8 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command,
if (pos_topic && pos_topic[0])
{
+ topic_color = irc_color_decode (pos_topic,
+ weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf_tags (buffer,
"irc_topic",
_("%s%s%s%s has changed topic for %s%s%s to: "
@@ -2426,8 +2429,10 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command,
IRC_COLOR_CHAT_CHANNEL,
argv[2],
IRC_COLOR_CHAT,
- pos_topic,
+ (topic_color) ? topic_color : pos_topic,
IRC_COLOR_CHAT);
+ if (topic_color)
+ free (topic_color);
}
else
{
@@ -4432,129 +4437,129 @@ void
irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
char *host, char *command, char *arguments)
{
- int i, cmd_found, return_code, highlight, argc;
+ int i, cmd_found, return_code, highlight, argc, decode_color;
char *pos, *nick;
char *dup_entire_line, *dup_host, *dup_arguments, *irc_message;
t_irc_recv_func *cmd_recv_func;
char *cmd_name, **argv, **argv_eol;
struct t_irc_protocol_msg irc_protocol_messages[] =
- { { "error", N_("error received from IRC server"), &irc_protocol_cmd_error },
- { "invite", N_("invite a nick on a channel"), &irc_protocol_cmd_invite },
- { "join", N_("join a channel"), &irc_protocol_cmd_join },
- { "kick", N_("forcibly remove a user from a channel"), &irc_protocol_cmd_kick },
- { "kill", N_("close client-server connection"), &irc_protocol_cmd_kill },
- { "mode", N_("change channel or user mode"), &irc_protocol_cmd_mode },
- { "nick", N_("change current nickname"), &irc_protocol_cmd_nick },
- { "notice", N_("send notice message to user"), &irc_protocol_cmd_notice },
- { "part", N_("leave a channel"), &irc_protocol_cmd_part },
- { "ping", N_("ping server"), &irc_protocol_cmd_ping },
- { "pong", N_("answer to a ping message"), &irc_protocol_cmd_pong },
- { "privmsg", N_("message received"), &irc_protocol_cmd_privmsg },
- { "quit", N_("close all connections and quit"), &irc_protocol_cmd_quit },
- { "topic", N_("get/set channel topic"), &irc_protocol_cmd_topic },
+ { { "error", N_("error received from IRC server"), 1, &irc_protocol_cmd_error },
+ { "invite", N_("invite a nick on a channel"), 1, &irc_protocol_cmd_invite },
+ { "join", N_("join a channel"), 1, &irc_protocol_cmd_join },
+ { "kick", N_("forcibly remove a user from a channel"), 1, &irc_protocol_cmd_kick },
+ { "kill", N_("close client-server connection"), 1, &irc_protocol_cmd_kill },
+ { "mode", N_("change channel or user mode"), 1, &irc_protocol_cmd_mode },
+ { "nick", N_("change current nickname"), 1, &irc_protocol_cmd_nick },
+ { "notice", N_("send notice message to user"), 1, &irc_protocol_cmd_notice },
+ { "part", N_("leave a channel"), 1, &irc_protocol_cmd_part },
+ { "ping", N_("ping server"), 1, &irc_protocol_cmd_ping },
+ { "pong", N_("answer to a ping message"), 1, &irc_protocol_cmd_pong },
+ { "privmsg", N_("message received"), 1, &irc_protocol_cmd_privmsg },
+ { "quit", N_("close all connections and quit"), 1, &irc_protocol_cmd_quit },
+ { "topic", N_("get/set channel topic"), 0, &irc_protocol_cmd_topic },
{ "wallops", N_("send a message to all currently connected users who have "
"set the 'w' user mode "
- "for themselves"), &irc_protocol_cmd_wallops },
- { "001", N_("a server message"), &irc_protocol_cmd_001 },
- { "005", N_("a server message"), &irc_protocol_cmd_005 },
- { "221", N_("user mode string"), &irc_protocol_cmd_221 },
- { "301", N_("away message"), &irc_protocol_cmd_301 },
- { "303", N_("ison"), &irc_protocol_cmd_303 },
- { "305", N_("unaway"), &irc_protocol_cmd_305 },
- { "306", N_("now away"), &irc_protocol_cmd_306 },
- { "307", N_("whois (registered nick)"), &irc_protocol_cmd_whois_nick_msg },
- { "310", N_("whois (help mode)"), &irc_protocol_cmd_whois_nick_msg },
- { "311", N_("whois (user)"), &irc_protocol_cmd_311 },
- { "312", N_("whois (server)"), &irc_protocol_cmd_312 },
- { "313", N_("whois (operator)"), &irc_protocol_cmd_whois_nick_msg },
- { "314", N_("whowas"), &irc_protocol_cmd_314 },
- { "315", N_("end of /who list"), &irc_protocol_cmd_315 },
- { "317", N_("whois (idle)"), &irc_protocol_cmd_317 },
- { "318", N_("whois (end)"), &irc_protocol_cmd_whois_nick_msg },
- { "319", N_("whois (channels)"), &irc_protocol_cmd_whois_nick_msg },
- { "320", N_("whois (identified user)"), &irc_protocol_cmd_whois_nick_msg },
- { "321", N_("/list start"), &irc_protocol_cmd_321 },
- { "322", N_("channel (for /list)"), &irc_protocol_cmd_322 },
- { "323", N_("end of /list"), &irc_protocol_cmd_323 },
- { "324", N_("channel mode"), &irc_protocol_cmd_324 },
- { "326", N_("whois (has oper privs)"), &irc_protocol_cmd_whois_nick_msg },
- { "327", N_("whois (host)"), &irc_protocol_cmd_327 },
- { "329", N_("channel creation date"), &irc_protocol_cmd_329 },
- { "331", N_("no topic for channel"), &irc_protocol_cmd_331 },
- { "332", N_("topic of channel"), &irc_protocol_cmd_332 },
- { "333", N_("infos about topic (nick and date changed)"), &irc_protocol_cmd_333 },
- { "338", N_("whois (host)"), &irc_protocol_cmd_338 },
- { "341", N_("inviting"), &irc_protocol_cmd_341 },
- { "344", N_("channel reop"), &irc_protocol_cmd_344 },
- { "345", N_("end of channel reop list"), &irc_protocol_cmd_345 },
- { "348", N_("channel exception list"), &irc_protocol_cmd_348 },
- { "349", N_("end of channel exception list"), &irc_protocol_cmd_349 },
- { "351", N_("server version"), &irc_protocol_cmd_351 },
- { "352", N_("who"), &irc_protocol_cmd_352 },
- { "353", N_("list of nicks on channel"), &irc_protocol_cmd_353 },
- { "366", N_("end of /names list"), &irc_protocol_cmd_366 },
- { "367", N_("banlist"), &irc_protocol_cmd_367 },
- { "368", N_("end of banlist"), &irc_protocol_cmd_368 },
- { "378", N_("whois (connecting from)"), &irc_protocol_cmd_whois_nick_msg },
- { "379", N_("whois (using modes)"), &irc_protocol_cmd_whois_nick_msg },
- { "401", N_("no such nick/channel"), &irc_protocol_cmd_error },
- { "402", N_("no such server"), &irc_protocol_cmd_error },
- { "403", N_("no such channel"), &irc_protocol_cmd_error },
- { "404", N_("cannot send to channel"), &irc_protocol_cmd_error },
- { "405", N_("too many channels"), &irc_protocol_cmd_error },
- { "406", N_("was no such nick"), &irc_protocol_cmd_error },
- { "407", N_("was no such nick"), &irc_protocol_cmd_error },
- { "409", N_("no origin"), &irc_protocol_cmd_error },
- { "410", N_("no services"), &irc_protocol_cmd_error },
- { "411", N_("no recipient"), &irc_protocol_cmd_error },
- { "412", N_("no text to send"), &irc_protocol_cmd_error },
- { "413", N_("no toplevel"), &irc_protocol_cmd_error },
- { "414", N_("wilcard in toplevel domain"), &irc_protocol_cmd_error },
- { "421", N_("unknown command"), &irc_protocol_cmd_error },
- { "422", N_("MOTD is missing"), &irc_protocol_cmd_error },
- { "423", N_("no administrative info"), &irc_protocol_cmd_error },
- { "424", N_("file error"), &irc_protocol_cmd_error },
- { "431", N_("no nickname given"), &irc_protocol_cmd_error },
- { "432", N_("erroneous nickname"), &irc_protocol_cmd_432 },
- { "433", N_("nickname already in use"), &irc_protocol_cmd_433 },
- { "436", N_("nickname collision"), &irc_protocol_cmd_error },
- { "437", N_("resource unavailable"), &irc_protocol_cmd_error },
- { "438", N_("not authorized to change nickname"), &irc_protocol_cmd_438 },
- { "441", N_("user not in channel"), &irc_protocol_cmd_error },
- { "442", N_("not on channel"), &irc_protocol_cmd_error },
- { "443", N_("user already on channel"), &irc_protocol_cmd_error },
- { "444", N_("user not logged in"), &irc_protocol_cmd_error },
- { "445", N_("summon has been disabled"), &irc_protocol_cmd_error },
- { "446", N_("users has been disabled"), &irc_protocol_cmd_error },
- { "451", N_("you are not registered"), &irc_protocol_cmd_error },
- { "461", N_("not enough parameters"), &irc_protocol_cmd_error },
- { "462", N_("you may not register"), &irc_protocol_cmd_error },
- { "463", N_("your host isn't among the privileged"), &irc_protocol_cmd_error },
- { "464", N_("password incorrect"), &irc_protocol_cmd_error },
- { "465", N_("you are banned from this server"), &irc_protocol_cmd_error },
- { "467", N_("channel key already set"), &irc_protocol_cmd_error },
- { "470", N_("forwarding to another channel"), &irc_protocol_cmd_error },
- { "471", N_("channel is already full"), &irc_protocol_cmd_error },
- { "472", N_("unknown mode char to me"), &irc_protocol_cmd_error },
- { "473", N_("cannot join channel (invite only)"), &irc_protocol_cmd_error },
- { "474", N_("cannot join channel (banned from channel)"), &irc_protocol_cmd_error },
- { "475", N_("cannot join channel (bad channel key)"), &irc_protocol_cmd_error },
- { "476", N_("bad channel mask"), &irc_protocol_cmd_error },
- { "477", N_("channel doesn't support modes"), &irc_protocol_cmd_error },
- { "481", N_("you're not an IRC operator"), &irc_protocol_cmd_error },
- { "482", N_("you're not channel operator"), &irc_protocol_cmd_error },
- { "483", N_("you can't kill a server!"), &irc_protocol_cmd_error },
- { "484", N_("your connection is restricted!"), &irc_protocol_cmd_error },
- { "485", N_("user is immune from kick/deop"), &irc_protocol_cmd_error },
- { "487", N_("network split"), &irc_protocol_cmd_error },
- { "491", N_("no O-lines for your host"), &irc_protocol_cmd_error },
- { "501", N_("unknown mode flag"), &irc_protocol_cmd_error },
- { "502", N_("can't change mode for other users"), &irc_protocol_cmd_error },
- { "671", N_("whois (secure connection)"), &irc_protocol_cmd_whois_nick_msg },
- { "973", N_("whois (secure connection)"), &irc_protocol_cmd_server_mode_reason },
- { "974", N_("whois (secure connection)"), &irc_protocol_cmd_server_mode_reason },
- { "975", N_("whois (secure connection)"), &irc_protocol_cmd_server_mode_reason },
- { NULL, NULL, NULL }
+ "for themselves"), 1, &irc_protocol_cmd_wallops },
+ { "001", N_("a server message"), 1, &irc_protocol_cmd_001 },
+ { "005", N_("a server message"), 1, &irc_protocol_cmd_005 },
+ { "221", N_("user mode string"), 1, &irc_protocol_cmd_221 },
+ { "301", N_("away message"), 1, &irc_protocol_cmd_301 },
+ { "303", N_("ison"), 1, &irc_protocol_cmd_303 },
+ { "305", N_("unaway"), 1, &irc_protocol_cmd_305 },
+ { "306", N_("now away"), 1, &irc_protocol_cmd_306 },
+ { "307", N_("whois (registered nick)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "310", N_("whois (help mode)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "311", N_("whois (user)"), 1, &irc_protocol_cmd_311 },
+ { "312", N_("whois (server)"), 1, &irc_protocol_cmd_312 },
+ { "313", N_("whois (operator)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "314", N_("whowas"), 1, &irc_protocol_cmd_314 },
+ { "315", N_("end of /who list"), 1, &irc_protocol_cmd_315 },
+ { "317", N_("whois (idle)"), 1, &irc_protocol_cmd_317 },
+ { "318", N_("whois (end)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "319", N_("whois (channels)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "320", N_("whois (identified user)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "321", N_("/list start"), 1, &irc_protocol_cmd_321 },
+ { "322", N_("channel (for /list)"), 1, &irc_protocol_cmd_322 },
+ { "323", N_("end of /list"), 1, &irc_protocol_cmd_323 },
+ { "324", N_("channel mode"), 1, &irc_protocol_cmd_324 },
+ { "326", N_("whois (has oper privs)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "327", N_("whois (host)"), 1, &irc_protocol_cmd_327 },
+ { "329", N_("channel creation date"), 1, &irc_protocol_cmd_329 },
+ { "331", N_("no topic for channel"), 1, &irc_protocol_cmd_331 },
+ { "332", N_("topic of channel"), 1, &irc_protocol_cmd_332 },
+ { "333", N_("infos about topic (nick and date changed)"), 1, &irc_protocol_cmd_333 },
+ { "338", N_("whois (host)"), 1, &irc_protocol_cmd_338 },
+ { "341", N_("inviting"), 1, &irc_protocol_cmd_341 },
+ { "344", N_("channel reop"), 1, &irc_protocol_cmd_344 },
+ { "345", N_("end of channel reop list"), 1, &irc_protocol_cmd_345 },
+ { "348", N_("channel exception list"), 1, &irc_protocol_cmd_348 },
+ { "349", N_("end of channel exception list"), 1, &irc_protocol_cmd_349 },
+ { "351", N_("server version"), 1, &irc_protocol_cmd_351 },
+ { "352", N_("who"), 1, &irc_protocol_cmd_352 },
+ { "353", N_("list of nicks on channel"), 1, &irc_protocol_cmd_353 },
+ { "366", N_("end of /names list"), 1, &irc_protocol_cmd_366 },
+ { "367", N_("banlist"), 1, &irc_protocol_cmd_367 },
+ { "368", N_("end of banlist"), 1, &irc_protocol_cmd_368 },
+ { "378", N_("whois (connecting from)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "379", N_("whois (using modes)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "401", N_("no such nick/channel"), 1, &irc_protocol_cmd_error },
+ { "402", N_("no such server"), 1, &irc_protocol_cmd_error },
+ { "403", N_("no such channel"), 1, &irc_protocol_cmd_error },
+ { "404", N_("cannot send to channel"), 1, &irc_protocol_cmd_error },
+ { "405", N_("too many channels"), 1, &irc_protocol_cmd_error },
+ { "406", N_("was no such nick"), 1, &irc_protocol_cmd_error },
+ { "407", N_("was no such nick"), 1, &irc_protocol_cmd_error },
+ { "409", N_("no origin"), 1, &irc_protocol_cmd_error },
+ { "410", N_("no services"), 1, &irc_protocol_cmd_error },
+ { "411", N_("no recipient"), 1, &irc_protocol_cmd_error },
+ { "412", N_("no text to send"), 1, &irc_protocol_cmd_error },
+ { "413", N_("no toplevel"), 1, &irc_protocol_cmd_error },
+ { "414", N_("wilcard in toplevel domain"), 1, &irc_protocol_cmd_error },
+ { "421", N_("unknown command"), 1, &irc_protocol_cmd_error },
+ { "422", N_("MOTD is missing"), 1, &irc_protocol_cmd_error },
+ { "423", N_("no administrative info"), 1, &irc_protocol_cmd_error },
+ { "424", N_("file error"), 1, &irc_protocol_cmd_error },
+ { "431", N_("no nickname given"), 1, &irc_protocol_cmd_error },
+ { "432", N_("erroneous nickname"), 1, &irc_protocol_cmd_432 },
+ { "433", N_("nickname already in use"), 1, &irc_protocol_cmd_433 },
+ { "436", N_("nickname collision"), 1, &irc_protocol_cmd_error },
+ { "437", N_("resource unavailable"), 1, &irc_protocol_cmd_error },
+ { "438", N_("not authorized to change nickname"), 1, &irc_protocol_cmd_438 },
+ { "441", N_("user not in channel"), 1, &irc_protocol_cmd_error },
+ { "442", N_("not on channel"), 1, &irc_protocol_cmd_error },
+ { "443", N_("user already on channel"), 1, &irc_protocol_cmd_error },
+ { "444", N_("user not logged in"), 1, &irc_protocol_cmd_error },
+ { "445", N_("summon has been disabled"), 1, &irc_protocol_cmd_error },
+ { "446", N_("users has been disabled"), 1, &irc_protocol_cmd_error },
+ { "451", N_("you are not registered"), 1, &irc_protocol_cmd_error },
+ { "461", N_("not enough parameters"), 1, &irc_protocol_cmd_error },
+ { "462", N_("you may not register"), 1, &irc_protocol_cmd_error },
+ { "463", N_("your host isn't among the privileged"), 1, &irc_protocol_cmd_error },
+ { "464", N_("password incorrect"), 1, &irc_protocol_cmd_error },
+ { "465", N_("you are banned from this server"), 1, &irc_protocol_cmd_error },
+ { "467", N_("channel key already set"), 1, &irc_protocol_cmd_error },
+ { "470", N_("forwarding to another channel"), 1, &irc_protocol_cmd_error },
+ { "471", N_("channel is already full"), 1, &irc_protocol_cmd_error },
+ { "472", N_("unknown mode char to me"), 1, &irc_protocol_cmd_error },
+ { "473", N_("cannot join channel (invite only)"), 1, &irc_protocol_cmd_error },
+ { "474", N_("cannot join channel (banned from channel)"), 1, &irc_protocol_cmd_error },
+ { "475", N_("cannot join channel (bad channel key)"), 1, &irc_protocol_cmd_error },
+ { "476", N_("bad channel mask"), 1, &irc_protocol_cmd_error },
+ { "477", N_("channel doesn't support modes"), 1, &irc_protocol_cmd_error },
+ { "481", N_("you're not an IRC operator"), 1, &irc_protocol_cmd_error },
+ { "482", N_("you're not channel operator"), 1, &irc_protocol_cmd_error },
+ { "483", N_("you can't kill a server!"), 1, &irc_protocol_cmd_error },
+ { "484", N_("your connection is restricted!"), 1, &irc_protocol_cmd_error },
+ { "485", N_("user is immune from kick/deop"), 1, &irc_protocol_cmd_error },
+ { "487", N_("network split"), 1, &irc_protocol_cmd_error },
+ { "491", N_("no O-lines for your host"), 1, &irc_protocol_cmd_error },
+ { "501", N_("unknown mode flag"), 1, &irc_protocol_cmd_error },
+ { "502", N_("can't change mode for other users"), 1, &irc_protocol_cmd_error },
+ { "671", N_("whois (secure connection)"), 1, &irc_protocol_cmd_whois_nick_msg },
+ { "973", N_("whois (secure connection)"), 1, &irc_protocol_cmd_server_mode_reason },
+ { "974", N_("whois (secure connection)"), 1, &irc_protocol_cmd_server_mode_reason },
+ { "975", N_("whois (secure connection)"), 1, &irc_protocol_cmd_server_mode_reason },
+ { NULL, NULL, 0, NULL }
};
if (!command)
@@ -4578,6 +4583,7 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
if (irc_protocol_is_numeric_command (command))
{
cmd_name = command;
+ decode_color = 1;
cmd_recv_func = irc_protocol_cmd_numeric;
}
else
@@ -4594,21 +4600,29 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
else
{
cmd_name = irc_protocol_messages[cmd_found].name;
+ decode_color = irc_protocol_messages[cmd_found].decode_color;
cmd_recv_func = irc_protocol_messages[cmd_found].recv_function;
}
if (cmd_recv_func != NULL)
{
- argv = weechat_string_explode (entire_line, " ", 0, 0, &argc);
- argv_eol = weechat_string_explode (entire_line, " ", 1, 0, NULL);
- dup_entire_line = (entire_line) ? strdup (entire_line) : NULL;
+ if (entire_line)
+ {
+ if (decode_color)
+ dup_entire_line = irc_color_decode (entire_line,
+ weechat_config_boolean (irc_config_network_colors_receive));
+ else
+ dup_entire_line = strdup (entire_line);
+ }
+ else
+ dup_entire_line = NULL;
+ argv = weechat_string_explode (dup_entire_line, " ", 0, 0, &argc);
+ argv_eol = weechat_string_explode (dup_entire_line, " ", 1, 0, NULL);
dup_host = (host) ? strdup (host) : NULL;
dup_arguments = (arguments) ? strdup (arguments) : NULL;
highlight = 0;
-
-
//return_code = plugin_msg_handler_exec (server->name,
// cmd_name,
// dup_entire_line);