1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 02:25:41 +02:00

Add IRC command redirection (task #6703)

This commit is contained in:
Sebastien Helleu
2010-10-23 09:54:31 +02:00
parent 0cf04dca7c
commit 868df21122
25 changed files with 1930 additions and 59 deletions
+1
View File
@@ -37,6 +37,7 @@ irc-msgbuffer.c irc-msgbuffer.h
irc-nick.c irc-nick.h
irc-protocol.c irc-protocol.h
irc-raw.c irc-raw.h
irc-redirect.c irc-redirect.h
irc-sasl.c irc-sasl.h
irc-server.c irc-server.h
irc-upgrade.c irc-upgrade.h)
+2
View File
@@ -61,6 +61,8 @@ irc_la_SOURCES = irc.c \
irc-protocol.h \
irc-raw.c \
irc-raw.h \
irc-redirect.c \
irc-redirect.h \
irc-sasl.c \
irc-sasl.h \
irc-server.c \
+1 -1
View File
@@ -920,7 +920,7 @@ irc_channel_print_log (struct t_irc_channel *channel)
struct t_irc_nick *ptr_nick;
weechat_log_printf ("");
weechat_log_printf (" => channel %s (addr:0x%lx)]", channel->name, channel);
weechat_log_printf (" => channel %s (addr:0x%lx):", channel->name, channel);
weechat_log_printf (" type . . . . . . . . . . : %d", channel->type);
weechat_log_printf (" topic. . . . . . . . . . : '%s'", channel->topic);
weechat_log_printf (" modes. . . . . . . . . . : '%s'", channel->modes);
+3
View File
@@ -27,6 +27,7 @@
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-debug.h"
#include "irc-redirect.h"
#include "irc-server.h"
@@ -52,6 +53,8 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal,
irc_server_print_log ();
irc_redirect_pattern_print_log ();
weechat_log_printf ("");
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
weechat_plugin->name);
+35 -8
View File
@@ -211,10 +211,10 @@ irc_raw_message_add_to_list (time_t date, const char *prefix,
*/
struct t_irc_raw_message *
irc_raw_message_add (struct t_irc_server *server, int send, int modified,
irc_raw_message_add (struct t_irc_server *server, int flags,
const char *message)
{
char *buf, *buf2, prefix[256];
char *buf, *buf2, prefix[256], prefix_arrow[16];
const unsigned char *ptr_buf;
const char *hexa = "0123456789ABCDEF";
int pos_buf, pos_buf2, char_size, i;
@@ -247,16 +247,43 @@ irc_raw_message_add (struct t_irc_server *server, int send, int modified,
}
buf2[pos_buf2] = '\0';
}
/* build prefix with arrow */
prefix_arrow[0] = '\0';
switch (flags & (IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_SEND
| IRC_RAW_FLAG_MODIFIED | IRC_RAW_FLAG_REDIRECT))
{
case IRC_RAW_FLAG_RECV:
strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV);
break;
case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED:
strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_MODIFIED);
break;
case IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_REDIRECT:
strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV_REDIRECT);
break;
case IRC_RAW_FLAG_SEND:
strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
break;
case IRC_RAW_FLAG_SEND | IRC_RAW_FLAG_MODIFIED:
strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND_MODIFIED);
break;
default:
if (flags && IRC_RAW_FLAG_RECV)
strcpy (prefix_arrow, IRC_RAW_PREFIX_RECV);
else
strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
break;
}
snprintf (prefix, sizeof (prefix), "%s%s%s%s%s",
(server) ? weechat_color ("chat_server") : "",
(server) ? server->name : "",
(server) ? " " : "",
(send) ?
(flags & IRC_RAW_FLAG_SEND) ?
weechat_color ("chat_prefix_quit") :
weechat_color ("chat_prefix_join"),
(send) ?
((modified) ? IRC_RAW_PREFIX_SEND_MOD : IRC_RAW_PREFIX_SEND) :
((modified) ? IRC_RAW_PREFIX_RECV_MOD : IRC_RAW_PREFIX_RECV));
prefix_arrow);
new_raw_message = irc_raw_message_add_to_list (time (NULL),
prefix,
@@ -275,7 +302,7 @@ irc_raw_message_add (struct t_irc_server *server, int send, int modified,
*/
void
irc_raw_print (struct t_irc_server *server, int send, int modified,
irc_raw_print (struct t_irc_server *server, int flags,
const char *message)
{
struct t_irc_raw_message *new_raw_message;
@@ -287,7 +314,7 @@ irc_raw_print (struct t_irc_server *server, int send, int modified,
if (!irc_raw_buffer && (weechat_irc_plugin->debug >= 1))
irc_raw_open (0);
new_raw_message = irc_raw_message_add (server, send, modified, message);
new_raw_message = irc_raw_message_add (server, flags, message);
if (new_raw_message)
{
if (irc_raw_buffer)
+14 -7
View File
@@ -20,11 +20,18 @@
#ifndef __WEECHAT_IRC_RAW_H
#define __WEECHAT_IRC_RAW_H 1
#define IRC_RAW_BUFFER_NAME "irc_raw"
#define IRC_RAW_PREFIX_RECV "-->"
#define IRC_RAW_PREFIX_RECV_MOD "==>"
#define IRC_RAW_PREFIX_SEND "<--"
#define IRC_RAW_PREFIX_SEND_MOD "<=="
#define IRC_RAW_BUFFER_NAME "irc_raw"
#define IRC_RAW_PREFIX_RECV "-->"
#define IRC_RAW_PREFIX_RECV_MODIFIED "==>"
#define IRC_RAW_PREFIX_RECV_REDIRECT "R>>"
#define IRC_RAW_PREFIX_SEND "<--"
#define IRC_RAW_PREFIX_SEND_MODIFIED "<=="
#define IRC_RAW_FLAG_RECV 1
#define IRC_RAW_FLAG_SEND 2
#define IRC_RAW_FLAG_MODIFIED 4
#define IRC_RAW_FLAG_REDIRECT 8
struct t_irc_raw_message
{
@@ -45,8 +52,8 @@ extern void irc_raw_open (int switch_to_buffer);
extern struct t_irc_raw_message *irc_raw_message_add_to_list (time_t date,
const char *prefix,
const char *message);
extern void irc_raw_print (struct t_irc_server *server, int send,
int modified, const char *message);
extern void irc_raw_print (struct t_irc_server *server, int flags,
const char *message);
extern void irc_raw_message_free_all ();
extern int irc_raw_add_to_infolist (struct t_infolist *infolist,
struct t_irc_raw_message *raw_message);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3
View File
@@ -108,6 +108,7 @@ struct t_irc_outqueue
char *message_after_mod; /* msg after modifier(s) */
int modified; /* msg was modified by modifier(s) */
char *tags; /* tags (used by Relay plugin) */
struct t_irc_redirect *redirect; /* command redirection */
struct t_irc_outqueue *next_outqueue; /* link to next msg in queue */
struct t_irc_outqueue *prev_outqueue; /* link to prev msg in queue */
};
@@ -169,6 +170,8 @@ struct t_irc_server
struct t_irc_outqueue *outqueue[2]; /* queue for outgoing messages */
/* with 2 priorities (high/low) */
struct t_irc_outqueue *last_outqueue[2]; /* last outgoing message */
struct t_irc_redirect *redirects; /* command redirections */
struct t_irc_redirect *last_redirect; /* last command redirection */
struct t_gui_buffer *buffer; /* GUI buffer allocated for server */
char *buffer_as_string; /* used to return buffer info */
struct t_irc_channel *channels; /* opened channels on server */
File diff suppressed because it is too large Load Diff
+2
View File
@@ -30,6 +30,8 @@ enum t_irc_upgrade_type
IRC_UPGRADE_TYPE_CHANNEL,
IRC_UPGRADE_TYPE_NICK,
IRC_UPGRADE_TYPE_RAW_MESSAGE,
IRC_UPGRADE_TYPE_REDIRECT_PATTERN,
IRC_UPGRADE_TYPE_REDIRECT,
};
extern int irc_upgrade_save ();
+9
View File
@@ -40,6 +40,7 @@
#include "irc-channel.h"
#include "irc-nick.h"
#include "irc-raw.h"
#include "irc-redirect.h"
#include "irc-upgrade.h"
@@ -164,6 +165,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
irc_info_init ();
irc_redirect_init ();
/* hook some signals */
irc_debug_init ();
weechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
@@ -173,6 +176,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL);
weechat_hook_signal ("irc_input_send", &irc_input_send_cb, NULL);
/* hook hsignals for redirection */
weechat_hook_hsignal ("irc_redirect_pattern", &irc_redirect_pattern_hsignal_cb, NULL);
weechat_hook_hsignal ("irc_redirect_command", &irc_redirect_command_hsignal_cb, NULL);
/* modifiers */
weechat_hook_modifier ("irc_color_decode", &irc_color_modifier_cb, NULL);
weechat_hook_modifier ("irc_color_encode", &irc_color_modifier_cb, NULL);
@@ -262,5 +269,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
irc_config_free ();
irc_redirect_end ();
return WEECHAT_RC_OK;
}