summaryrefslogtreecommitdiff
path: root/src/plugins/xfer
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/xfer')
-rw-r--r--src/plugins/xfer/xfer-buffer.c17
-rw-r--r--src/plugins/xfer/xfer-chat.c10
-rw-r--r--src/plugins/xfer/xfer-command.c10
-rw-r--r--src/plugins/xfer/xfer-dcc.c2
-rw-r--r--src/plugins/xfer/xfer-network.c24
-rw-r--r--src/plugins/xfer/xfer.c109
-rw-r--r--src/plugins/xfer/xfer.h7
7 files changed, 107 insertions, 72 deletions
diff --git a/src/plugins/xfer/xfer-buffer.c b/src/plugins/xfer/xfer-buffer.c
index e8e1f9cf7..3fe3c9b4e 100644
--- a/src/plugins/xfer/xfer-buffer.c
+++ b/src/plugins/xfer/xfer-buffer.c
@@ -46,6 +46,7 @@ xfer_buffer_refresh (const char *hotlist)
{
struct t_xfer *ptr_xfer, *xfer_selected;
char str_color[256], suffix[32], status[64], date[128], eta[128];
+ char str_ip[32];
char *progress_bar, *str_pos, *str_total, *str_bytes_per_sec;
int i, length, line, progress_bar_size, num_bars;
unsigned long long pos, pct_complete;
@@ -93,9 +94,20 @@ xfer_buffer_refresh (const char *hotlist)
weechat_config_string (xfer_config_color_text),
weechat_config_string (xfer_config_color_text_bg));
+ str_ip[0] = '\0';
+ if (ptr_xfer->remote_address != 0)
+ {
+ snprintf (str_ip, sizeof (str_ip),
+ " (%ld.%ld.%ld.%ld)",
+ ptr_xfer->remote_address >> 24,
+ (ptr_xfer->remote_address >> 16) & 0xff,
+ (ptr_xfer->remote_address >> 8) & 0xff,
+ ptr_xfer->remote_address & 0xff);
+ }
+
/* display first line with remote nick, filename and plugin name/id */
weechat_printf_y (xfer_buffer, (line * 2) + 2,
- "%s%s%-24s %s%s%s%s (%s.%s)",
+ "%s%s%-24s %s%s%s%s (%s.%s)%s",
weechat_color(str_color),
(line == xfer_buffer_selected_line) ?
"*** " : " ",
@@ -106,7 +118,8 @@ xfer_buffer_refresh (const char *hotlist)
(XFER_IS_FILE(ptr_xfer->type)) ? "\"" : "",
suffix,
ptr_xfer->plugin_name,
- ptr_xfer->plugin_id);
+ ptr_xfer->plugin_id,
+ str_ip);
snprintf (status, sizeof (status),
"%s", _(xfer_status_string[ptr_xfer->status]));
diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c
index 3a1338d75..e13f41c54 100644
--- a/src/plugins/xfer/xfer-chat.c
+++ b/src/plugins/xfer/xfer-chat.c
@@ -341,13 +341,13 @@ xfer_chat_open_buffer (struct t_xfer *xfer)
}
weechat_printf (xfer->buffer,
- _("Connected to %s (%d.%d.%d.%d) via "
+ _("Connected to %s (%ld.%ld.%ld.%ld) via "
"xfer chat"),
xfer->remote_nick,
- xfer->address >> 24,
- (xfer->address >> 16) & 0xff,
- (xfer->address >> 8) & 0xff,
- xfer->address & 0xff);
+ xfer->remote_address >> 24,
+ (xfer->remote_address >> 16) & 0xff,
+ (xfer->remote_address >> 8) & 0xff,
+ xfer->remote_address & 0xff);
free (name);
}
diff --git a/src/plugins/xfer/xfer-command.c b/src/plugins/xfer/xfer-command.c
index c8146e829..02c834234 100644
--- a/src/plugins/xfer/xfer-command.c
+++ b/src/plugins/xfer/xfer-command.c
@@ -159,15 +159,15 @@ xfer_command_xfer_list (int full)
weechat_printf (NULL,
_(" plugin: %s (id: %s), file: %llu "
"bytes (position: %llu), address: "
- "%d.%d.%d.%d (port %d)"),
+ "%ld.%ld.%ld.%ld (port %d)"),
ptr_xfer->plugin_name,
ptr_xfer->plugin_id,
ptr_xfer->size,
ptr_xfer->pos,
- ptr_xfer->address >> 24,
- (ptr_xfer->address >> 16) & 0xff,
- (ptr_xfer->address >> 8) & 0xff,
- ptr_xfer->address & 0xff,
+ ptr_xfer->remote_address >> 24,
+ (ptr_xfer->remote_address >> 16) & 0xff,
+ (ptr_xfer->remote_address >> 8) & 0xff,
+ ptr_xfer->remote_address & 0xff,
ptr_xfer->port);
date[0] = '\0';
date_tmp = localtime (&(ptr_xfer->start_transfer));
diff --git a/src/plugins/xfer/xfer-dcc.c b/src/plugins/xfer/xfer-dcc.c
index a5fabd89b..4885c4fdb 100644
--- a/src/plugins/xfer/xfer-dcc.c
+++ b/src/plugins/xfer/xfer-dcc.c
@@ -189,7 +189,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
/* first connect to sender (blocking) */
if (!weechat_network_connect_to (xfer->proxy, xfer->sock,
- xfer->address, xfer->port))
+ xfer->remote_address, xfer->port))
{
xfer_network_write_pipe (xfer, XFER_STATUS_FAILED,
XFER_ERROR_CONNECT_SENDER);
diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c
index 9580bf073..e33612f67 100644
--- a/src/plugins/xfer/xfer-network.c
+++ b/src/plugins/xfer/xfer-network.c
@@ -215,6 +215,22 @@ xfer_network_send_file_fork (struct t_xfer *xfer)
_exit (EXIT_SUCCESS);
}
+ weechat_printf (NULL,
+ _("%s: sending file to %s (%ld.%ld.%ld.%ld, %s.%s), "
+ "name: %s (local filename: %s), %llu bytes (protocol: %s)"),
+ XFER_PLUGIN_NAME,
+ xfer->remote_nick,
+ xfer->remote_address >> 24,
+ (xfer->remote_address >> 16) & 0xff,
+ (xfer->remote_address >> 8) & 0xff,
+ xfer->remote_address & 0xff,
+ xfer->plugin_name,
+ xfer->plugin_id,
+ xfer->filename,
+ xfer->local_filename,
+ xfer->size,
+ xfer_protocol_string[xfer->protocol]);
+
/* parent process */
xfer->child_pid = pid;
close (xfer->child_write);
@@ -364,7 +380,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return WEECHAT_RC_OK;
}
- xfer->address = ntohl (addr.sin_addr.s_addr);
+ xfer->remote_address = ntohl (addr.sin_addr.s_addr);
xfer->status = XFER_STATUS_ACTIVE;
xfer->start_transfer = time (NULL);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
@@ -406,7 +422,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd)
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return WEECHAT_RC_OK;
}
- xfer->address = ntohl (addr.sin_addr.s_addr);
+ xfer->remote_address = ntohl (addr.sin_addr.s_addr);
xfer->status = XFER_STATUS_ACTIVE;
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
xfer->hook_fd = weechat_hook_fd (xfer->sock,
@@ -506,8 +522,8 @@ xfer_network_connect (struct t_xfer *xfer)
flags = 0;
if (fcntl (xfer->sock, F_SETFL, flags | O_NONBLOCK) == -1)
return 0;
- weechat_network_connect_to (xfer->proxy, xfer->sock, xfer->address,
- xfer->port);
+ weechat_network_connect_to (xfer->proxy, xfer->sock,
+ xfer->remote_address, xfer->port);
xfer->hook_fd = weechat_hook_fd (xfer->sock,
1, 0, 0,
diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c
index 371390293..8bc7b071b 100644
--- a/src/plugins/xfer/xfer.c
+++ b/src/plugins/xfer/xfer.c
@@ -285,16 +285,17 @@ xfer_close (struct t_xfer *xfer, enum t_xfer_status status)
if (XFER_IS_FILE(xfer->type))
{
weechat_printf (NULL,
- _("%s%s: file %s %s %s: %s"),
- (xfer->status == XFER_STATUS_DONE) ?
- "" : weechat_prefix ("error"),
+ _("%s%s: file %s %s %s (%ld.%ld.%ld.%ld): %s"),
+ (xfer->status == XFER_STATUS_DONE) ? "" : weechat_prefix ("error"),
XFER_PLUGIN_NAME,
xfer->filename,
- (xfer->type == XFER_TYPE_FILE_SEND) ?
- _("sent to") : _("received from"),
+ (xfer->type == XFER_TYPE_FILE_SEND) ? _("sent to") : _("received from"),
xfer->remote_nick,
- (xfer->status == XFER_STATUS_DONE) ?
- _("OK") : _("FAILED"));
+ xfer->remote_address >> 24,
+ (xfer->remote_address >> 16) & 0xff,
+ (xfer->remote_address >> 8) & 0xff,
+ xfer->remote_address & 0xff,
+ (xfer->status == XFER_STATUS_DONE) ? _("OK") : _("FAILED"));
xfer_network_child_kill (xfer);
}
}
@@ -304,13 +305,13 @@ xfer_close (struct t_xfer *xfer, enum t_xfer_status status)
{
weechat_printf (xfer->buffer,
_("%s: chat closed with %s "
- "(%d.%d.%d.%d)"),
+ "(%ld.%ld.%ld.%ld)"),
XFER_PLUGIN_NAME,
xfer->remote_nick,
- xfer->address >> 24,
- (xfer->address >> 16) & 0xff,
- (xfer->address >> 8) & 0xff,
- xfer->address & 0xff);
+ xfer->remote_address >> 24,
+ (xfer->remote_address >> 16) & 0xff,
+ (xfer->remote_address >> 8) & 0xff,
+ xfer->remote_address & 0xff);
}
}
@@ -412,33 +413,23 @@ xfer_send_signal (struct t_xfer *xfer, const char *signal)
item = weechat_infolist_new_item (infolist);
if (item)
{
- weechat_infolist_new_var_string (item, "plugin_name",
- xfer->plugin_name);
- weechat_infolist_new_var_string (item, "plugin_id",
- xfer->plugin_id);
- weechat_infolist_new_var_string (item, "type",
- xfer_type_string[xfer->type]);
- weechat_infolist_new_var_string (item, "protocol",
- xfer_protocol_string[xfer->protocol]);
- weechat_infolist_new_var_string (item, "remote_nick",
- xfer->remote_nick);
- weechat_infolist_new_var_string (item, "local_nick",
- xfer->local_nick);
- weechat_infolist_new_var_string (item, "charset_modifier",
- xfer->charset_modifier);
- weechat_infolist_new_var_string (item, "filename",
- xfer->filename);
+ weechat_infolist_new_var_string (item, "plugin_name", xfer->plugin_name);
+ weechat_infolist_new_var_string (item, "plugin_id", xfer->plugin_id);
+ weechat_infolist_new_var_string (item, "type", xfer_type_string[xfer->type]);
+ weechat_infolist_new_var_string (item, "protocol", xfer_protocol_string[xfer->protocol]);
+ weechat_infolist_new_var_string (item, "remote_nick", xfer->remote_nick);
+ weechat_infolist_new_var_string (item, "local_nick", xfer->local_nick);
+ weechat_infolist_new_var_string (item, "charset_modifier", xfer->charset_modifier);
+ weechat_infolist_new_var_string (item, "filename", xfer->filename);
snprintf (str_long, sizeof (str_long), "%llu", xfer->size);
- weechat_infolist_new_var_string (item, "size",
- str_long);
+ weechat_infolist_new_var_string (item, "size", str_long);
snprintf (str_long, sizeof (str_long), "%llu", xfer->start_resume);
- weechat_infolist_new_var_string (item, "start_resume",
- str_long);
- snprintf (str_long, sizeof (str_long), "%lu", xfer->address);
- weechat_infolist_new_var_string (item, "address",
- str_long);
- weechat_infolist_new_var_integer (item, "port",
- xfer->port);
+ weechat_infolist_new_var_string (item, "start_resume", str_long);
+ snprintf (str_long, sizeof (str_long), "%lu", xfer->local_address);
+ weechat_infolist_new_var_string (item, "local_address", str_long);
+ snprintf (str_long, sizeof (str_long), "%lu", xfer->remote_address);
+ weechat_infolist_new_var_string (item, "remote_address", str_long);
+ weechat_infolist_new_var_integer (item, "port", xfer->port);
weechat_hook_signal_send (signal, WEECHAT_HOOK_SIGNAL_POINTER,
infolist);
@@ -466,7 +457,8 @@ xfer_alloc ()
/* default values */
new_xfer->filename = NULL;
new_xfer->size = 0;
- new_xfer->address = 0;
+ new_xfer->local_address = 0;
+ new_xfer->remote_address = 0;
new_xfer->port = 0;
new_xfer->remote_nick = NULL;
new_xfer->local_nick = NULL;
@@ -559,7 +551,16 @@ xfer_new (const char *plugin_name, const char *plugin_id,
new_xfer->filename = strdup (_("xfer chat"));
new_xfer->size = size;
new_xfer->proxy = (proxy) ? strdup (proxy) : NULL;
- new_xfer->address = address;
+ if (XFER_IS_RECV(type))
+ {
+ new_xfer->local_address = 0;
+ new_xfer->remote_address = address;
+ }
+ else
+ {
+ new_xfer->local_address = address;
+ new_xfer->remote_address = 0;
+ }
new_xfer->port = port;
new_xfer->status = XFER_STATUS_WAITING;
@@ -575,16 +576,16 @@ xfer_new (const char *plugin_name, const char *plugin_id,
case XFER_TYPE_FILE_RECV:
weechat_printf (NULL,
_("%s: incoming file from %s "
- "(%s.%s), ip: %d.%d.%d.%d, name: %s, %llu bytes "
+ "(%ld.%ld.%ld.%ld, %s.%s), name: %s, %llu bytes "
"(protocol: %s)"),
XFER_PLUGIN_NAME,
remote_nick,
- plugin_name,
- plugin_id,
address >> 24,
(address >> 16) & 0xff,
(address >> 8) & 0xff,
address & 0xff,
+ plugin_name,
+ plugin_id,
filename,
size,
xfer_protocol_string[protocol]);
@@ -592,7 +593,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
break;
case XFER_TYPE_FILE_SEND:
weechat_printf (NULL,
- _("%s: sending file to %s (%s.%s): %s "
+ _("%s: offering file to %s (%s.%s), name: %s "
"(local filename: %s), %llu bytes (protocol: %s)"),
XFER_PLUGIN_NAME,
remote_nick,
@@ -607,15 +608,15 @@ xfer_new (const char *plugin_name, const char *plugin_id,
case XFER_TYPE_CHAT_RECV:
weechat_printf (NULL,
_("%s: incoming chat request from %s "
- "(%s.%s), ip: %d.%d.%d.%d"),
+ "(%ld.%ld.%ld.%ld, %s.%s)"),
XFER_PLUGIN_NAME,
remote_nick,
- plugin_name,
- plugin_id,
address >> 24,
(address >> 16) & 0xff,
(address >> 8) & 0xff,
- address & 0xff);
+ address & 0xff,
+ plugin_name,
+ plugin_id);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
break;
case XFER_TYPE_CHAT_SEND:
@@ -902,13 +903,13 @@ xfer_add_cb (void *data, const char *signal, const char *type_data,
if (XFER_IS_RECV(type))
{
- sscanf (weechat_infolist_string (infolist, "address"), "%lu", &local_addr);
+ sscanf (weechat_infolist_string (infolist, "remote_address"), "%lu", &local_addr);
port = weechat_infolist_integer (infolist, "port");
}
else
{
/* get local IP address */
- sscanf (weechat_infolist_string (infolist, "address"), "%lu", &local_addr);
+ sscanf (weechat_infolist_string (infolist, "local_address"), "%lu", &local_addr);
memset (&addr, 0, sizeof (struct sockaddr_in));
addr.sin_family = AF_INET;
@@ -1306,8 +1307,11 @@ xfer_add_to_infolist (struct t_infolist *infolist, struct t_xfer *xfer)
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "proxy", xfer->proxy))
return 0;
- snprintf (value, sizeof (value), "%lu", xfer->address);
- if (!weechat_infolist_new_var_string (ptr_item, "address", value))
+ snprintf (value, sizeof (value), "%lu", xfer->local_address);
+ if (!weechat_infolist_new_var_string (ptr_item, "local_address", value))
+ return 0;
+ snprintf (value, sizeof (value), "%lu", xfer->remote_address);
+ if (!weechat_infolist_new_var_string (ptr_item, "remote_address", value))
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "port", xfer->port))
return 0;
@@ -1401,7 +1405,8 @@ xfer_print_log ()
weechat_log_printf (" filename. . . . . . : '%s'", ptr_xfer->filename);
weechat_log_printf (" size. . . . . . . . : %llu", ptr_xfer->size);
weechat_log_printf (" proxy . . . . . . . : '%s'", ptr_xfer->proxy);
- weechat_log_printf (" address . . . . . . : %lu", ptr_xfer->address);
+ weechat_log_printf (" local_address . . . : %lu", ptr_xfer->local_address);
+ weechat_log_printf (" remote_address. . . : %lu", ptr_xfer->remote_address);
weechat_log_printf (" port. . . . . . . . : %d", ptr_xfer->port);
weechat_log_printf (" status. . . . . . . : %d (%s)",
diff --git a/src/plugins/xfer/xfer.h b/src/plugins/xfer/xfer.h
index 90626bc60..d854830fe 100644
--- a/src/plugins/xfer/xfer.h
+++ b/src/plugins/xfer/xfer.h
@@ -78,8 +78,8 @@ enum t_xfer_error
/* xfer blocksize */
-#define XFER_BLOCKSIZE_MIN 1024 /* min blocksize when sending file */
-#define XFER_BLOCKSIZE_MAX 102400 /* max blocksize when sending file */
+#define XFER_BLOCKSIZE_MIN 1024 /* min blocksize */
+#define XFER_BLOCKSIZE_MAX 102400 /* max blocksize */
/* separator in filenames */
@@ -119,7 +119,8 @@ struct t_xfer
char *filename; /* filename */
unsigned long long size; /* file size */
char *proxy; /* proxy to use (optional) */
- unsigned long address; /* local or remote IP address */
+ unsigned long local_address; /* local IP address */
+ unsigned long remote_address; /* remote IP address */
int port; /* remote port */
/* internal data */