summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-command.c16
-rw-r--r--src/plugins/xfer/xfer-chat.c59
-rw-r--r--src/plugins/xfer/xfer-chat.h1
-rw-r--r--src/plugins/xfer/xfer-command.c49
-rw-r--r--src/plugins/xfer/xfer.c9
-rw-r--r--src/plugins/xfer/xfer.h2
6 files changed, 118 insertions, 18 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 7f0314c42..0f06e9a83 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -41,6 +41,7 @@
#include "irc-nick.h"
#include "irc-display.h"
#include "irc-ignore.h"
+#include "irc-protocol.h"
#include "irc-raw.h"
@@ -339,13 +340,14 @@ irc_command_me_channel (struct t_irc_server *server,
string = (arguments && arguments[0]) ?
irc_color_decode (arguments,
weechat_config_boolean (irc_config_network_colors_receive)) : NULL;
- weechat_printf (channel->buffer,
- "%s%s%s %s%s",
- weechat_prefix ("action"),
- IRC_COLOR_CHAT_NICK_SELF,
- server->nick,
- IRC_COLOR_CHAT,
- (string) ? string : "");
+ weechat_printf_tags (channel->buffer,
+ irc_protocol_tags ("privmsg", "irc_action,no_highlight"),
+ "%s%s%s %s%s",
+ weechat_prefix ("action"),
+ IRC_COLOR_CHAT_NICK_SELF,
+ server->nick,
+ IRC_COLOR_CHAT,
+ (string) ? string : "");
if (string)
free (string);
}
diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c
index a294fc2ee..3bc3191a7 100644
--- a/src/plugins/xfer/xfer-chat.c
+++ b/src/plugins/xfer/xfer-chat.c
@@ -96,9 +96,9 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
{
struct t_xfer *xfer;
static char buffer[4096 + 2];
- char *buf2, *pos, *ptr_buf, *next_ptr_buf;
+ char *buf2, *pos, *ptr_buf, *ptr_buf2, *next_ptr_buf;
char *ptr_buf_decoded, *ptr_buf_without_weechat_colors, *ptr_buf_color;
- int num_read;
+ int num_read, length, ctcp_action;
/* make C compiler happy */
(void) fd;
@@ -144,6 +144,20 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
if (ptr_buf)
{
+ ctcp_action = 0;
+ length = strlen (ptr_buf);
+ if ((ptr_buf[0] == '\01')
+ && (ptr_buf[length - 1] == '\01'))
+ {
+ ptr_buf[length - 1] = '\0';
+ ptr_buf++;
+ if (strncmp (ptr_buf, "ACTION ", 7) == 0)
+ {
+ ptr_buf += 7;
+ ctcp_action = 1;
+ }
+ }
+
ptr_buf_decoded = (xfer->charset_modifier) ?
weechat_hook_modifier_exec ("charset_decode",
xfer->charset_modifier,
@@ -154,11 +168,32 @@ xfer_chat_recv_cb (void *arg_xfer, int fd)
"1",
(ptr_buf_without_weechat_colors) ?
ptr_buf_without_weechat_colors : ((ptr_buf_decoded) ? ptr_buf_decoded : ptr_buf));
- weechat_printf_tags (xfer->buffer, "notify_message", "%s\t%s",
- xfer->remote_nick,
- (ptr_buf_color) ?
- ptr_buf_color : ((ptr_buf_without_weechat_colors) ?
- ptr_buf_without_weechat_colors : ((ptr_buf_decoded) ? ptr_buf_decoded : ptr_buf)));
+ ptr_buf2 = (ptr_buf_color) ?
+ ptr_buf_color : ((ptr_buf_without_weechat_colors) ?
+ ptr_buf_without_weechat_colors : ((ptr_buf_decoded) ? ptr_buf_decoded : ptr_buf));
+ if (ctcp_action)
+ {
+ weechat_printf_tags (xfer->buffer,
+ "irc_privmsg,irc_action,notify_message",
+ "%s%s%s%s%s%s",
+ weechat_prefix ("action"),
+ (xfer->remote_nick_color) ?
+ xfer->remote_nick_color : weechat_color ("chat_nick_other"),
+ xfer->remote_nick,
+ weechat_color ("chat"),
+ (ptr_buf2[0]) ? " " : "",
+ ptr_buf2);
+ }
+ else
+ {
+ weechat_printf_tags (xfer->buffer,
+ "irc_privmsg,notify_message",
+ "%s%s\t%s",
+ (xfer->remote_nick_color) ?
+ xfer->remote_nick_color : weechat_color ("chat_nick_other"),
+ xfer->remote_nick,
+ ptr_buf2);
+ }
if (ptr_buf_decoded)
free (ptr_buf_decoded);
if (ptr_buf_without_weechat_colors)
@@ -216,10 +251,12 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
input_data_color = weechat_hook_modifier_exec ("irc_color_decode",
"1",
input_data);
- weechat_printf (buffer,
- "%s\t%s",
- ptr_xfer->local_nick,
- (input_data_color) ? input_data_color : input_data);
+ weechat_printf_tags (buffer,
+ "irc_privmsg,no_highlight",
+ "%s%s\t%s",
+ weechat_color ("chat_nick_self"),
+ ptr_xfer->local_nick,
+ (input_data_color) ? input_data_color : input_data);
if (input_data_color)
free (input_data_color);
}
diff --git a/src/plugins/xfer/xfer-chat.h b/src/plugins/xfer/xfer-chat.h
index 360d28938..eef1fa969 100644
--- a/src/plugins/xfer/xfer-chat.h
+++ b/src/plugins/xfer/xfer-chat.h
@@ -20,6 +20,7 @@
#ifndef __WEECHAT_XFER_CHAT_H
#define __WEECHAT_XFER_CHAT_H 1
+extern void xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...);
extern int xfer_chat_recv_cb (void *arg_xfer, int fd);
extern void xfer_chat_open_buffer (struct t_xfer *xfer);
diff --git a/src/plugins/xfer/xfer-command.c b/src/plugins/xfer/xfer-command.c
index c070bdd9f..e1634711b 100644
--- a/src/plugins/xfer/xfer-command.c
+++ b/src/plugins/xfer/xfer-command.c
@@ -26,10 +26,54 @@
#include "../weechat-plugin.h"
#include "xfer.h"
#include "xfer-buffer.h"
+#include "xfer-chat.h"
#include "xfer-config.h"
/*
+ * xfer_command_me: send a ctcp action to remote host
+ */
+
+int
+xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc,
+ char **argv, char **argv_eol)
+{
+ struct t_xfer *ptr_xfer;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) argc;
+ (void) argv;
+
+ ptr_xfer = xfer_search_by_buffer (buffer);
+
+ if (!ptr_xfer)
+ {
+ weechat_printf (NULL,
+ _("%s%s: can't find xfer for buffer \"%s\""),
+ weechat_prefix ("error"), XFER_PLUGIN_NAME,
+ weechat_buffer_get_string (buffer, "name"));
+ return WEECHAT_RC_OK;
+ }
+
+ if (!XFER_HAS_ENDED(ptr_xfer->status))
+ {
+ xfer_chat_sendf (ptr_xfer, "\01ACTION %s\01\n",
+ (argv_eol[1]) ? argv_eol[1] : "");
+ weechat_printf_tags (buffer,
+ "no_highlight",
+ "%s%s%s %s%s",
+ weechat_prefix ("action"),
+ weechat_color ("chat_nick_self"),
+ ptr_xfer->local_nick,
+ weechat_color ("chat"),
+ (argv_eol[1]) ? argv_eol[1] : "");
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* xfer_command_xfer_list: list xfer
*/
@@ -195,6 +239,11 @@ xfer_command_xfer (void *data, struct t_gui_buffer *buffer, int argc,
void
xfer_command_init ()
{
+ weechat_hook_command ("me",
+ N_("send a CTCP action to remote host"),
+ N_("message"),
+ N_("message: message to send"),
+ NULL, &xfer_command_me, NULL);
weechat_hook_command ("xfer",
N_("xfer control"),
"[list | listfull]",
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index 60c6aebab..9fb4f8c5d 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -440,6 +440,7 @@ xfer_alloc ()
new_xfer->protocol = 0;
new_xfer->status = 0;
new_xfer->buffer = NULL;
+ new_xfer->remote_nick_color = NULL;
new_xfer->fast_send = weechat_config_boolean (xfer_config_network_fast_send);
new_xfer->blocksize = weechat_config_integer (xfer_config_network_blocksize);
new_xfer->start_time = time_now;
@@ -489,6 +490,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
int port, int sock, const char *local_filename)
{
struct t_xfer *new_xfer;
+ const char *ptr_color;
new_xfer = xfer_alloc ();
if (!new_xfer)
@@ -511,6 +513,8 @@ xfer_new (const char *plugin_name, const char *plugin_id,
new_xfer->type = type;
new_xfer->protocol = protocol;
new_xfer->remote_nick = strdup (remote_nick);
+ ptr_color = weechat_info_get ("irc_nick_color", remote_nick);
+ new_xfer->remote_nick_color = (ptr_color) ? strdup (ptr_color) : NULL;
new_xfer->local_nick = (local_nick) ? strdup (local_nick) : NULL;
new_xfer->charset_modifier = (charset_modifier) ? strdup (charset_modifier) : NULL;
if (XFER_IS_FILE(type))
@@ -671,6 +675,8 @@ xfer_free (struct t_xfer *xfer)
free (xfer->charset_modifier);
if (xfer->filename)
free (xfer->filename);
+ if (xfer->remote_nick_color)
+ free (xfer->remote_nick_color);
if (xfer->unterminated_message)
free (xfer->unterminated_message);
if (xfer->local_filename)
@@ -1272,6 +1278,8 @@ xfer_add_to_infolist (struct t_infolist *infolist, struct t_xfer *xfer)
return 0;
if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", xfer->buffer))
return 0;
+ if (!weechat_infolist_new_var_string (ptr_item, "remote_nick_color", xfer->remote_nick_color))
+ return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "fast_send", xfer->fast_send))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "blocksize", xfer->blocksize))
@@ -1360,6 +1368,7 @@ xfer_print_log ()
ptr_xfer->status,
xfer_status_string[ptr_xfer->status]);
weechat_log_printf (" buffer. . . . . . . : 0x%lx", ptr_xfer->buffer);
+ weechat_log_printf (" remote_nick_color . : '%s'", ptr_xfer->remote_nick_color);
weechat_log_printf (" fast_send . . . . . : %d", ptr_xfer->fast_send);
weechat_log_printf (" blocksize . . . . . : %d", ptr_xfer->blocksize);
weechat_log_printf (" start_time. . . . . : %ld", ptr_xfer->start_time);
diff --git a/src/plugins/xfer/xfer.h b/src/plugins/xfer/xfer.h
index 25243cd8c..686582e10 100644
--- a/src/plugins/xfer/xfer.h
+++ b/src/plugins/xfer/xfer.h
@@ -123,6 +123,8 @@ struct t_xfer
/* internal data */
enum t_xfer_status status; /* xfer status (waiting, sending,..) */
struct t_gui_buffer *buffer; /* buffer (for chat only) */
+ char *remote_nick_color; /* color for remote nick (given by */
+ /* IRC plugin) */
int fast_send; /* fast send file: does not wait ACK */
int blocksize; /* block size for sending file */
time_t start_time; /* time when xfer started */