diff options
Diffstat (limited to 'src/plugins/xfer')
-rw-r--r-- | src/plugins/xfer/xfer-buffer.c | 34 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-chat.c | 58 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-command.c | 26 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-completion.c | 6 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-config.c | 24 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-dcc.c | 28 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-file.c | 30 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-info.c | 10 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-network.c | 70 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-upgrade.c | 18 | ||||
-rw-r--r-- | src/plugins/xfer/xfer.c | 244 | ||||
-rw-r--r-- | src/plugins/xfer/xfer.h | 4 |
12 files changed, 276 insertions, 276 deletions
diff --git a/src/plugins/xfer/xfer-buffer.c b/src/plugins/xfer/xfer-buffer.c index c936fecbe..684406970 100644 --- a/src/plugins/xfer/xfer-buffer.c +++ b/src/plugins/xfer/xfer-buffer.c @@ -50,7 +50,7 @@ xfer_buffer_refresh (const char *hotlist) int i, length, line, progress_bar_size, num_bars; unsigned long long pct_complete; struct tm *date_tmp; - + if (xfer_buffer) { weechat_buffer_clear (xfer_buffer); @@ -85,14 +85,14 @@ xfer_buffer_refresh (const char *hotlist) snprintf (suffix, sizeof (suffix), " (.%d)", ptr_xfer->filename_suffix); } - + snprintf (str_color, sizeof (str_color), "%s,%s", (line == xfer_buffer_selected_line) ? weechat_config_string (xfer_config_color_text_selected) : weechat_config_string (xfer_config_color_text), weechat_config_string (xfer_config_color_text_bg)); - + /* display first line with remote nick and filename */ weechat_printf_y (xfer_buffer, (line * 2) + 2, "%s%s%-24s %s%s%s%s", @@ -105,7 +105,7 @@ xfer_buffer_refresh (const char *hotlist) ptr_xfer->filename : _("xfer chat"), (XFER_IS_FILE(ptr_xfer->type)) ? "\"" : "", suffix); - + snprintf (status, sizeof (status), "%s", _(xfer_status_string[ptr_xfer->status])); length = weechat_utf8_strlen_screen (status); @@ -116,7 +116,7 @@ xfer_buffer_refresh (const char *hotlist) strcat (status, " "); } } - + if (XFER_IS_CHAT(ptr_xfer->type)) { /* display second line for chat with status and date */ @@ -166,7 +166,7 @@ xfer_buffer_refresh (const char *hotlist) } strcat (progress_bar, "] "); } - + /* computes percentage */ if (ptr_xfer->size == 0) { @@ -177,12 +177,12 @@ xfer_buffer_refresh (const char *hotlist) } else pct_complete = (unsigned long long)(((float)(ptr_xfer->pos)/(float)(ptr_xfer->size)) * 100); - + /* position, total and bytes per second */ str_pos = weechat_string_format_size (ptr_xfer->pos); str_total = weechat_string_format_size (ptr_xfer->size); str_bytes_per_sec = weechat_string_format_size (ptr_xfer->bytes_per_sec); - + /* ETA */ eta[0] = '\0'; if (ptr_xfer->status == XFER_STATUS_ACTIVE) @@ -194,7 +194,7 @@ xfer_buffer_refresh (const char *hotlist) (ptr_xfer->eta / 60) % 60, ptr_xfer->eta % 60); } - + /* display second line for file with status, progress bar and estimated time */ weechat_printf_y (xfer_buffer, (line * 2) + 3, "%s%s%s %s%s%s%s%3llu%% %s / %s (%s%s/s)", @@ -233,12 +233,12 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { struct t_xfer *xfer, *ptr_xfer, *next_xfer; - + /* make C compiler happy */ (void) data; - + xfer = xfer_search_by_number (xfer_buffer_selected_line); - + /* accept xfer */ if (weechat_strcasecmp (input_data, "a") == 0) { @@ -284,7 +284,7 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer, xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); } } - + return WEECHAT_RC_OK; } @@ -298,9 +298,9 @@ xfer_buffer_close_cb (void *data, struct t_gui_buffer *buffer) /* make C compiler happy */ (void) data; (void) buffer; - + xfer_buffer = NULL; - + return WEECHAT_RC_OK; } @@ -316,11 +316,11 @@ xfer_buffer_open () xfer_buffer = weechat_buffer_new (XFER_BUFFER_NAME, &xfer_buffer_input_cb, NULL, &xfer_buffer_close_cb, NULL); - + /* failed to create buffer ? then exit */ if (!xfer_buffer) return; - + weechat_buffer_set (xfer_buffer, "type", "free"); weechat_buffer_set (xfer_buffer, "title", _("Xfer list")); weechat_buffer_set (xfer_buffer, "key_bind_meta2-A", "/xfer up"); diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c index baf2acdb9..3d05f19ce 100644 --- a/src/plugins/xfer/xfer-chat.c +++ b/src/plugins/xfer/xfer-chat.c @@ -43,7 +43,7 @@ xfer_chat_send (struct t_xfer *xfer, const char *buffer, int size_buf) { if (!xfer) return -1; - + return send (xfer->sock, buffer, size_buf, 0); } @@ -55,21 +55,21 @@ void xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...) { char *ptr_msg, *msg_encoded; - + if (!xfer || (xfer->sock < 0)) return; - + weechat_va_format (format); if (!vbuffer) return; - + msg_encoded = (xfer->charset_modifier) ? weechat_hook_modifier_exec ("charset_encode", xfer->charset_modifier, vbuffer) : NULL; - + ptr_msg = (msg_encoded) ? msg_encoded : vbuffer; - + if (xfer_chat_send (xfer, ptr_msg, strlen (ptr_msg)) <= 0) { weechat_printf (NULL, @@ -78,10 +78,10 @@ xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...) xfer->remote_nick); xfer_close (xfer, XFER_STATUS_FAILED); } - + if (msg_encoded) free (msg_encoded); - + free (vbuffer); } @@ -98,17 +98,17 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) char *ptr_buf_decoded, *ptr_buf_without_weechat_colors, *ptr_buf_color; char str_tags[256]; int num_read, length, ctcp_action; - + /* make C compiler happy */ (void) fd; - + xfer = (struct t_xfer *)arg_xfer; - + num_read = recv (xfer->sock, buffer, sizeof (buffer) - 2, 0); if (num_read > 0) { buffer[num_read] = '\0'; - + buf2 = NULL; ptr_buf = buffer; if (xfer->unterminated_message) @@ -124,7 +124,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) free (xfer->unterminated_message); xfer->unterminated_message = NULL; } - + while (ptr_buf && ptr_buf[0]) { next_ptr_buf = NULL; @@ -140,7 +140,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) ptr_buf = NULL; next_ptr_buf = NULL; } - + if (ptr_buf) { ctcp_action = 0; @@ -156,7 +156,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) ctcp_action = 1; } } - + ptr_buf_decoded = (xfer->charset_modifier) ? weechat_hook_modifier_exec ("charset_decode", xfer->charset_modifier, @@ -206,10 +206,10 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) if (ptr_buf_color) free (ptr_buf_color); } - + ptr_buf = next_ptr_buf; } - + if (buf2) free (buf2); } @@ -218,7 +218,7 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) xfer_close (xfer, XFER_STATUS_ABORTED); xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); } - + return WEECHAT_RC_OK; } @@ -233,12 +233,12 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer, { struct t_xfer *ptr_xfer; char *input_data_color; - + /* make C compiler happy */ (void) data; - + ptr_xfer = xfer_search_by_buffer (buffer); - + if (ptr_xfer) { if (!XFER_HAS_ENDED(ptr_xfer->status)) @@ -260,7 +260,7 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer, } } } - + return WEECHAT_RC_OK; } @@ -273,7 +273,7 @@ int xfer_chat_buffer_close_cb (void *data, struct t_gui_buffer *buffer) { struct t_xfer *ptr_xfer; - + /* make C compiler happy */ (void) data; (void) buffer; @@ -290,7 +290,7 @@ xfer_chat_buffer_close_cb (void *data, struct t_gui_buffer *buffer) ptr_xfer->buffer = NULL; } } - + return WEECHAT_RC_OK; } @@ -303,9 +303,9 @@ xfer_chat_open_buffer (struct t_xfer *xfer) { char *name; int length, buffer_created; - + buffer_created = 0; - + length = strlen (xfer->plugin_name) + 8 + strlen (xfer->plugin_id) + 1 + strlen (xfer->remote_nick) + 1; name = malloc (length); @@ -320,7 +320,7 @@ xfer_chat_open_buffer (struct t_xfer *xfer) &xfer_chat_buffer_input_cb, NULL, &xfer_chat_buffer_close_cb, NULL); buffer_created = 1; - + /* failed to create buffer ? then return */ if (!xfer->buffer) return; @@ -339,7 +339,7 @@ xfer_chat_open_buffer (struct t_xfer *xfer) weechat_buffer_set (xfer->buffer, "localvar_set_channel", xfer->remote_nick); weechat_buffer_set (xfer->buffer, "highlight_words_add", "$nick"); } - + weechat_printf (xfer->buffer, _("Connected to %s (%d.%d.%d.%d) via " "xfer chat"), @@ -348,7 +348,7 @@ xfer_chat_open_buffer (struct t_xfer *xfer) (xfer->address >> 16) & 0xff, (xfer->address >> 8) & 0xff, xfer->address & 0xff); - + free (name); } } diff --git a/src/plugins/xfer/xfer-command.c b/src/plugins/xfer/xfer-command.c index 57e87a107..ad57a834a 100644 --- a/src/plugins/xfer/xfer-command.c +++ b/src/plugins/xfer/xfer-command.c @@ -41,12 +41,12 @@ 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) @@ -57,7 +57,7 @@ xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc, 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", @@ -71,7 +71,7 @@ xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc, weechat_color ("chat"), (argv_eol[1]) ? argv_eol[1] : ""); } - + return WEECHAT_RC_OK; } @@ -87,7 +87,7 @@ xfer_command_xfer_list (int full) char date[128]; unsigned long long pct_complete; struct tm *date_tmp; - + if (xfer_list) { weechat_printf (NULL, ""); @@ -107,7 +107,7 @@ xfer_command_xfer_list (int full) } else pct_complete = (unsigned long long)(((float)(ptr_xfer->pos)/(float)(ptr_xfer->size)) * 100); - + weechat_printf (NULL, _("%3d. %s (%s), file: \"%s\" (local: " "\"%s\"), %s %s, status: %s%s%s " @@ -146,7 +146,7 @@ xfer_command_xfer_list (int full) xfer_config_color_status[ptr_xfer->status])), _(xfer_status_string[ptr_xfer->status])); } - + if (full) { /* second line of xfer info */ @@ -202,20 +202,20 @@ xfer_command_xfer (void *data, struct t_gui_buffer *buffer, int argc, xfer_command_xfer_list (0); return WEECHAT_RC_OK; } - + if ((argc > 1) && (weechat_strcasecmp (argv[1], "listfull") == 0)) { xfer_command_xfer_list (1); return WEECHAT_RC_OK; } - + if (!xfer_buffer) xfer_buffer_open (); - + if (xfer_buffer) { weechat_buffer_set (xfer_buffer, "display", "1"); - + if (argc > 1) { if (strcmp (argv[1], "up") == 0) @@ -230,9 +230,9 @@ xfer_command_xfer (void *data, struct t_gui_buffer *buffer, int argc, } } } - + xfer_buffer_refresh (NULL); - + return WEECHAT_RC_OK; } diff --git a/src/plugins/xfer/xfer-completion.c b/src/plugins/xfer/xfer-completion.c index 6e5aecb40..feb81ba7e 100644 --- a/src/plugins/xfer/xfer-completion.c +++ b/src/plugins/xfer/xfer-completion.c @@ -40,11 +40,11 @@ xfer_completion_nick_cb (void *data, const char *completion_item, struct t_gui_completion *completion) { struct t_xfer *ptr_xfer; - + /* make C compiler happy */ (void) data; (void) completion_item; - + ptr_xfer = xfer_search_by_buffer (buffer); if (ptr_xfer) { @@ -59,7 +59,7 @@ xfer_completion_nick_cb (void *data, const char *completion_item, 1, WEECHAT_LIST_POS_END); } - + return WEECHAT_RC_OK; } diff --git a/src/plugins/xfer/xfer-config.c b/src/plugins/xfer/xfer-config.c index 2cffb1036..cc48a4fa9 100644 --- a/src/plugins/xfer/xfer-config.c +++ b/src/plugins/xfer/xfer-config.c @@ -77,7 +77,7 @@ xfer_config_refresh_cb (void *data, struct t_config_option *option) /* make C compiler happy */ (void) data; (void) option; - + if (xfer_buffer) xfer_buffer_refresh (NULL); } @@ -91,7 +91,7 @@ xfer_config_reload (void *data, struct t_config_file *config_file) { /* make C compiler happy */ (void) data; - + return weechat_config_reload (config_file); } @@ -104,12 +104,12 @@ int xfer_config_init () { struct t_config_section *ptr_section; - + xfer_config_file = weechat_config_new (XFER_CONFIG_NAME, &xfer_config_reload, NULL); if (!xfer_config_file) return 0; - + ptr_section = weechat_config_new_section (xfer_config_file, "look", 0, 0, NULL, NULL, NULL, NULL, @@ -120,7 +120,7 @@ xfer_config_init () weechat_config_free (xfer_config_file); return 0; } - + xfer_config_look_auto_open_buffer = weechat_config_new_option ( xfer_config_file, ptr_section, "auto_open_buffer", "boolean", @@ -133,7 +133,7 @@ xfer_config_init () N_("size of progress bar, in chars (if 0, progress bar is disabled)"), NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20", NULL, 0, NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); - + ptr_section = weechat_config_new_section (xfer_config_file, "color", 0, 0, NULL, NULL, NULL, NULL, @@ -144,7 +144,7 @@ xfer_config_init () weechat_config_free (xfer_config_file); return 0; } - + xfer_config_color_text = weechat_config_new_option ( xfer_config_file, ptr_section, "text", "color", @@ -199,7 +199,7 @@ xfer_config_init () N_("text color for \"aborted\" status"), NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); - + ptr_section = weechat_config_new_section (xfer_config_file, "network", 0, 0, NULL, NULL, NULL, NULL, @@ -210,7 +210,7 @@ xfer_config_init () weechat_config_free (xfer_config_file); return 0; } - + xfer_config_network_timeout = weechat_config_new_option ( xfer_config_file, ptr_section, "timeout", "integer", @@ -248,7 +248,7 @@ xfer_config_init () N_("speed limit for sending files, in kilo-bytes by second (0 means " "no limit)"), NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - + ptr_section = weechat_config_new_section (xfer_config_file, "file", 0, 0, NULL, NULL, NULL, NULL, @@ -259,7 +259,7 @@ xfer_config_init () weechat_config_free (xfer_config_file); return 0; } - + xfer_config_file_download_path = weechat_config_new_option ( xfer_config_file, ptr_section, "download_path", "string", @@ -304,7 +304,7 @@ xfer_config_init () "auto_accept_chats", "boolean", N_("automatically accept chat requests (use carefully!)"), NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - + return 1; } diff --git a/src/plugins/xfer/xfer-dcc.c b/src/plugins/xfer/xfer-dcc.c index aba22869b..40a93205b 100644 --- a/src/plugins/xfer/xfer-dcc.c +++ b/src/plugins/xfer/xfer-dcc.c @@ -51,14 +51,14 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) uint32_t ack; time_t last_sent, new_time, last_second, sent_ok; unsigned long long sent_last_second; - + blocksize = xfer->blocksize; if (weechat_config_integer (xfer_config_network_speed_limit) > 0) { if (blocksize > weechat_config_integer (xfer_config_network_speed_limit) * 1024) blocksize = weechat_config_integer (xfer_config_network_speed_limit) * 1024; } - + last_sent = time (NULL); last_second = time (NULL); sent_ok = 0; @@ -83,7 +83,7 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) { recv (xfer->sock, (char *) &ack, 4, 0); xfer->ack = ntohl (ack); - + /* DCC send ok? */ if ((xfer->pos >= xfer->size) && (xfer->ack >= xfer->size)) @@ -97,7 +97,7 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) break; } } - + /* send a block to receiver */ if ((xfer->pos < xfer->size) && (xfer->fast_send || (xfer->pos <= xfer->ack))) @@ -153,14 +153,14 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) } else usleep (1000); - + new_time = time (NULL); if (new_time > last_second) { last_second = new_time; sent_last_second = 0; } - + /* * if send if ok since 2 seconds or more, and that no ack was received, * then consider it's ok @@ -185,7 +185,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer) static char buffer[XFER_BLOCKSIZE_MAX]; uint32_t pos; time_t last_sent, new_time; - + /* first connect to sender (blocking) */ if (!weechat_network_connect_to (xfer->proxy, xfer->sock, xfer->address, xfer->port)) @@ -194,11 +194,11 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer) XFER_ERROR_CONNECT_SENDER); return; } - + /* connection is ok, change DCC status (inform parent process) */ xfer_network_write_pipe (xfer, XFER_STATUS_ACTIVE, XFER_NO_ERROR); - + last_sent = time (NULL); while (1) { @@ -223,20 +223,20 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer) XFER_ERROR_RECV_BLOCK); return; } - + if (write (xfer->file, buffer, num_read) == -1) { xfer_network_write_pipe (xfer, XFER_STATUS_FAILED, XFER_ERROR_WRITE_LOCAL); return; } - + xfer->pos += (unsigned long long) num_read; pos = htonl (xfer->pos); - + /* we don't check return code, not a problem if an ACK send failed */ send (xfer->sock, (char *) &pos, 4, 0); - + /* file received ok? */ if (xfer->pos >= xfer->size) { @@ -244,7 +244,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer) XFER_NO_ERROR); return; } - + new_time = time (NULL); if (last_sent != new_time) { diff --git a/src/plugins/xfer/xfer-file.c b/src/plugins/xfer/xfer-file.c index af4760846..630e9aeec 100644 --- a/src/plugins/xfer/xfer-file.c +++ b/src/plugins/xfer/xfer-file.c @@ -47,10 +47,10 @@ int xfer_file_resume (struct t_xfer *xfer, const char *filename) { struct stat st; - + if (!weechat_config_boolean (xfer_config_file_auto_resume)) return 0; - + if (access (filename, W_OK) == 0) { if (stat (filename, &st) != -1) @@ -64,7 +64,7 @@ xfer_file_resume (struct t_xfer *xfer, const char *filename) } } } - + /* not resumable */ return 0; } @@ -80,14 +80,14 @@ xfer_file_find_filename (struct t_xfer *xfer) { const char *weechat_home, *dir_separator; char *dir1, *dir2, *filename2; - + if (!XFER_IS_FILE(xfer->type)) return; - + dir1 = weechat_string_expand_home (weechat_config_string (xfer_config_file_download_path)); if (!dir1) return; - + weechat_home = weechat_info_get ("weechat_dir", ""); if (!weechat_home) { @@ -100,13 +100,13 @@ xfer_file_find_filename (struct t_xfer *xfer) free (dir1); return; } - + xfer->local_filename = malloc (strlen (dir2) + strlen (xfer->remote_nick) + strlen (xfer->filename) + 4); if (!xfer->local_filename) return; - + strcpy (xfer->local_filename, dir2); dir_separator = weechat_info_get("dir_separator", ""); if (dir_separator @@ -118,18 +118,18 @@ xfer_file_find_filename (struct t_xfer *xfer) strcat (xfer->local_filename, "."); } strcat (xfer->local_filename, xfer->filename); - + if (dir1) free (dir1); if (dir2 ) free (dir2); - + /* file already exists? */ if (access (xfer->local_filename, F_OK) == 0) { if (xfer_file_resume (xfer, xfer->local_filename)) return; - + /* if auto rename is not set, then abort xfer */ if (!xfer_config_file_auto_rename) { @@ -137,7 +137,7 @@ xfer_file_find_filename (struct t_xfer *xfer) xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); return; } - + filename2 = malloc (strlen (xfer->local_filename) + 16); if (!filename2) { @@ -161,7 +161,7 @@ xfer_file_find_filename (struct t_xfer *xfer) break; } while (1); - + free (xfer->local_filename); xfer->local_filename = strdup (filename2); free (filename2); @@ -177,7 +177,7 @@ xfer_file_calculate_speed (struct t_xfer *xfer, int ended) { time_t local_time, elapsed; unsigned long long bytes_per_sec_total; - + local_time = time (NULL); if (ended || local_time > xfer->last_check_time) { @@ -200,7 +200,7 @@ xfer_file_calculate_speed (struct t_xfer *xfer, int ended) if (bytes_per_sec_total == 0) bytes_per_sec_total = 1; xfer->eta = (xfer->size - xfer->pos) / bytes_per_sec_total; - + /* calculate bytes per second (since last check time) */ elapsed = local_time - xfer->last_check_time; if (elapsed == 0) diff --git a/src/plugins/xfer/xfer-info.c b/src/plugins/xfer/xfer-info.c index 28d95c581..93a3ab9cc 100644 --- a/src/plugins/xfer/xfer-info.c +++ b/src/plugins/xfer/xfer-info.c @@ -38,19 +38,19 @@ xfer_info_get_infolist_cb (void *data, const char *infolist_name, { struct t_infolist *ptr_infolist; struct t_xfer *ptr_xfer; - + /* make C compiler happy */ (void) data; (void) arguments; - + if (!infolist_name || !infolist_name[0]) return NULL; - + if (weechat_strcasecmp (infolist_name, "xfer") == 0) { if (pointer && !xfer_valid (pointer)) return NULL; - + ptr_infolist = weechat_infolist_new (); if (ptr_infolist) { @@ -80,7 +80,7 @@ xfer_info_get_infolist_cb (void *data, const char *infolist_name, } } } - + return NULL; } diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c index f588aa022..6626aaf81 100644 --- a/src/plugins/xfer/xfer-network.c +++ b/src/plugins/xfer/xfer-network.c @@ -51,7 +51,7 @@ int xfer_network_create_pipe (struct t_xfer *xfer) { int child_pipe[2]; - + if (pipe (child_pipe) < 0) { weechat_printf (NULL, @@ -61,10 +61,10 @@ xfer_network_create_pipe (struct t_xfer *xfer) xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); return 0; } - + xfer->child_read = child_pipe[0]; xfer->child_write = child_pipe[1]; - + return 1; } @@ -77,7 +77,7 @@ xfer_network_write_pipe (struct t_xfer *xfer, int status, int error) { char buffer[1 + 1 + 32 + 1]; /* status + error + pos + \0 */ int num_written; - + snprintf (buffer, sizeof (buffer), "%c%c%032llu", status + '0', error + '0', xfer->pos); num_written = write (xfer->child_write, buffer, sizeof (buffer)); @@ -94,19 +94,19 @@ xfer_network_child_read_cb (void *arg_xfer, int fd) struct t_xfer *xfer; char bufpipe[1 + 1 + 32 + 1]; int num_read; - + /* make C compiler happy */ (void) fd; - + xfer = (struct t_xfer *)arg_xfer; - + num_read = read (xfer->child_read, bufpipe, sizeof (bufpipe)); if (num_read > 0) { sscanf (bufpipe + 2, "%llu", &xfer->pos); xfer->last_activity = time (NULL); xfer_file_calculate_speed (xfer, 0); - + /* read error code */ switch (bufpipe[1] - '0') { @@ -143,7 +143,7 @@ xfer_network_child_read_cb (void *arg_xfer, int fd) weechat_prefix ("error"), XFER_PLUGIN_NAME); break; } - + /* read new DCC status */ switch (bufpipe[0] - '0') { @@ -169,7 +169,7 @@ xfer_network_child_read_cb (void *arg_xfer, int fd) break; } } - + return WEECHAT_RC_OK; } @@ -181,12 +181,12 @@ void xfer_network_send_file_fork (struct t_xfer *xfer) { pid_t pid; - + if (!xfer_network_create_pipe (xfer)) return; - + xfer->file = open (xfer->local_filename, O_RDONLY | O_NONBLOCK, 0644); - + switch (pid = fork ()) { /* fork failed */ @@ -214,7 +214,7 @@ xfer_network_send_file_fork (struct t_xfer *xfer) } _exit (EXIT_SUCCESS); } - + /* parent process */ xfer->child_pid = pid; close (xfer->child_write); @@ -233,10 +233,10 @@ void xfer_network_recv_file_fork (struct t_xfer *xfer) { pid_t pid; - + if (!xfer_network_create_pipe (xfer)) return; - + if (xfer->start_resume > 0) xfer->file = open (xfer->local_filename, O_APPEND | O_WRONLY | O_NONBLOCK); @@ -244,7 +244,7 @@ xfer_network_recv_file_fork (struct t_xfer *xfer) xfer->file = open (xfer->local_filename, O_CREAT | O_TRUNC | O_WRONLY | O_NONBLOCK, 0644); - + switch (pid = fork ()) { /* fork failed */ @@ -272,7 +272,7 @@ xfer_network_recv_file_fork (struct t_xfer *xfer) } _exit (EXIT_SUCCESS); } - + /* parent process */ xfer->child_pid = pid; close (xfer->child_write); @@ -297,7 +297,7 @@ xfer_network_child_kill (struct t_xfer *xfer) waitpid (xfer->child_pid, NULL, 0); xfer->child_pid = 0; } - + /* close pipe used with child */ if (xfer->child_read != -1) { @@ -322,12 +322,12 @@ xfer_network_fd_cb (void *arg_xfer, int fd) int sock; struct sockaddr_in addr; socklen_t length; - + /* make C compiler happy */ (void) fd; - + xfer = (struct t_xfer *)arg_xfer; - + if (xfer->status == XFER_STATUS_CONNECTING) { if (xfer->type == XFER_TYPE_FILE_SEND) @@ -368,7 +368,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd) xfer_network_send_file_fork (xfer); } } - + if (xfer->status == XFER_STATUS_WAITING) { if (xfer->type == XFER_TYPE_CHAT_SEND) @@ -410,7 +410,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd) xfer_chat_open_buffer (xfer); } } - + return WEECHAT_RC_OK; } @@ -423,12 +423,12 @@ int xfer_network_timer_cb (void *arg_xfer, int remaining_calls) { struct t_xfer *xfer; - + /* make C compiler happy */ (void) remaining_calls; - + xfer = (struct t_xfer *)arg_xfer; - + if ((xfer->status == XFER_STATUS_WAITING) || (xfer->status == XFER_STATUS_CONNECTING)) { @@ -439,7 +439,7 @@ xfer_network_timer_cb (void *arg_xfer, int remaining_calls) xfer_close (xfer, XFER_STATUS_FAILED); xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); } - + return WEECHAT_RC_OK; } @@ -454,14 +454,14 @@ xfer_network_connect (struct t_xfer *xfer) xfer->status = XFER_STATUS_WAITING; else xfer->status = XFER_STATUS_CONNECTING; - + if (xfer->sock < 0) { xfer->sock = socket (AF_INET, SOCK_STREAM, 0); if (xfer->sock < 0) return 0; } - + if (XFER_IS_SEND(xfer->type)) { /* listen to socket */ @@ -476,7 +476,7 @@ xfer_network_connect (struct t_xfer *xfer) 1, 0, 0, &xfer_network_fd_cb, xfer); - + /* add timeout */ if (weechat_config_integer (xfer_config_network_timeout) > 0) { @@ -486,7 +486,7 @@ xfer_network_connect (struct t_xfer *xfer) xfer); } } - + /* for chat receiving, connect to listening host */ if (xfer->type == XFER_TYPE_CHAT_RECV) { @@ -494,15 +494,15 @@ xfer_network_connect (struct t_xfer *xfer) return 0; weechat_network_connect_to (xfer->proxy, xfer->sock, xfer->address, xfer->port); - + xfer->hook_fd = weechat_hook_fd (xfer->sock, 1, 0, 0, &xfer_chat_recv_cb, xfer); } - + /* for file receiving, connection is made in child process (blocking) */ - + return 1; } diff --git a/src/plugins/xfer/xfer-upgrade.c b/src/plugins/xfer/xfer-upgrade.c index 4c17a5c7d..b3c811796 100644 --- a/src/plugins/xfer/xfer-upgrade.c +++ b/src/plugins/xfer/xfer-upgrade.c @@ -52,15 +52,15 @@ xfer_upgrade_save () { int rc; struct t_upgrade_file *upgrade_file; - + upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 1); if (!upgrade_file) return 0; - + rc = xfer_upgrade_save_xfers (upgrade_file); - + weechat_upgrade_close (upgrade_file); - + return rc; } @@ -74,7 +74,7 @@ xfer_upgrade_set_buffer_callbacks () { struct t_infolist *infolist; struct t_gui_buffer *ptr_buffer; - + infolist = weechat_infolist_get ("buffer", NULL, NULL); if (infolist) { @@ -111,7 +111,7 @@ xfer_upgrade_read_cb (void *data, (void) upgrade_file; (void) object_id; (void) infolist; - + return WEECHAT_RC_OK; } @@ -125,11 +125,11 @@ xfer_upgrade_load () { int rc; struct t_upgrade_file *upgrade_file; - + xfer_upgrade_set_buffer_callbacks (); - + upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 0); rc = weechat_upgrade_read (upgrade_file, &xfer_upgrade_read_cb, NULL); - + return rc; } diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c index d15dc98df..7d84d0b63 100644 --- a/src/plugins/xfer/xfer.c +++ b/src/plugins/xfer/xfer.c @@ -61,7 +61,7 @@ char *xfer_type_string[] = /* strings for types */ char *xfer_protocol_string[] = /* strings for protocols */ { "none", "dcc" }; - + char *xfer_status_string[] = /* strings for status */ { N_("waiting"), N_("connecting"), N_("active"), N_("done"), N_("failed"), @@ -85,17 +85,17 @@ int xfer_valid (struct t_xfer *xfer) { struct t_xfer *ptr_xfer; - + if (!xfer) return 0; - + for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) { if (ptr_xfer == xfer) return 1; } - + /* xfer not found */ return 0; } @@ -113,9 +113,9 @@ xfer_signal_upgrade_cb (void *data, const char *signal, const char *type_data, (void) signal; (void) type_data; (void) signal_data; - + xfer_signal_upgrade_received = 1; - + return WEECHAT_RC_OK; } @@ -129,7 +129,7 @@ xfer_create_directories () { const char *weechat_dir; char *dir1, *dir2; - + /* create download directory */ weechat_dir = weechat_info_get ("weechat_dir", ""); if (weechat_dir) @@ -154,13 +154,13 @@ int xfer_search_type (const char *type) { int i; - + for (i = 0; i < XFER_NUM_TYPES; i++) { if (weechat_strcasecmp (xfer_type_string[i], type) == 0) return i; } - + /* xfer type not found */ return -1; } @@ -174,13 +174,13 @@ int xfer_search_protocol (const char *protocol) { int i; - + for (i = 0; i < XFER_NUM_PROTOCOLS; i++) { if (weechat_strcasecmp (xfer_protocol_string[i], protocol) == 0) return i; } - + /* xfer protocol not found */ return -1; } @@ -194,7 +194,7 @@ xfer_search (const char *plugin_name, const char *plugin_id, enum t_xfer_type ty enum t_xfer_status status, int port) { struct t_xfer *ptr_xfer; - + for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) { if ((weechat_strcasecmp (ptr_xfer->plugin_name, plugin_name) == 0) @@ -204,7 +204,7 @@ xfer_search (const char *plugin_name, const char *plugin_id, enum t_xfer_type ty && (ptr_xfer->port == port)) return ptr_xfer; } - + /* xfer not found */ return NULL; } @@ -218,7 +218,7 @@ xfer_search_by_number (int number) { struct t_xfer *ptr_xfer; int i; - + i = 0; for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) { @@ -226,7 +226,7 @@ xfer_search_by_number (int number) return ptr_xfer; i++; } - + /* xfer not found */ return NULL; } @@ -239,16 +239,16 @@ struct t_xfer * xfer_search_by_buffer (struct t_gui_buffer *buffer) { struct t_xfer *ptr_xfer; - + if (!buffer) return NULL; - + for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) { if (ptr_xfer->buffer == buffer) return ptr_xfer; } - + /* xfer not found */ return NULL; } @@ -261,13 +261,13 @@ void xfer_close (struct t_xfer *xfer, enum t_xfer_status status) { struct stat st; - + xfer->status = status; - + if (XFER_HAS_ENDED(xfer->status)) { xfer_send_signal (xfer, "xfer_ended"); - + if (xfer->hook_fd) { weechat_unhook (xfer->hook_fd); @@ -309,7 +309,7 @@ xfer_close (struct t_xfer *xfer, enum t_xfer_status status) xfer->address & 0xff); } } - + /* remove empty file if received file failed and nothing was transfered */ if (((xfer->status == XFER_STATUS_FAILED) || (xfer->status == XFER_STATUS_ABORTED)) @@ -325,10 +325,10 @@ xfer_close (struct t_xfer *xfer, enum t_xfer_status status) unlink (xfer->local_filename); } } - + if (XFER_IS_FILE(xfer->type)) xfer_file_calculate_speed (xfer, 1); - + if (xfer->sock >= 0) { close (xfer->sock); @@ -350,14 +350,14 @@ int xfer_port_in_use (int port) { struct t_xfer *ptr_xfer; - + /* skip any currently used ports */ for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) { if ((ptr_xfer->port == port) && (!XFER_HAS_ENDED(ptr_xfer->status))) return 1; } - + /* port not in use */ return 0; } @@ -372,7 +372,7 @@ xfer_send_signal (struct t_xfer *xfer, const char *signal) struct t_infolist *infolist; struct t_infolist_item *item; char str_long[128]; - + infolist = weechat_infolist_new (); if (infolist) { @@ -406,7 +406,7 @@ xfer_send_signal (struct t_xfer *xfer, const char *signal) str_long); weechat_infolist_new_var_integer (item, "port", xfer->port); - + weechat_hook_signal_send (signal, WEECHAT_HOOK_SIGNAL_POINTER, infolist); } @@ -423,13 +423,13 @@ xfer_alloc () { struct t_xfer *new_xfer; time_t time_now; - + /* create new xfer struct */ if ((new_xfer = malloc (sizeof (*new_xfer))) == NULL) return NULL; time_now = time (NULL); - + /* default values */ new_xfer->filename = NULL; new_xfer->size = 0; @@ -438,7 +438,7 @@ xfer_alloc () new_xfer->remote_nick = NULL; new_xfer->local_nick = NULL; new_xfer->charset_modifier = NULL; - + new_xfer->type = 0; new_xfer->protocol = 0; new_xfer->status = 0; @@ -466,7 +466,7 @@ xfer_alloc () new_xfer->last_activity = 0; new_xfer->bytes_per_sec = 0; new_xfer->eta = 0; - + new_xfer->prev_xfer = NULL; new_xfer->next_xfer = xfer_list; if (xfer_list) @@ -474,9 +474,9 @@ xfer_alloc () else last_xfer = new_xfer; xfer_list = new_xfer; - + xfer_count++; - + return new_xfer; } @@ -494,7 +494,7 @@ xfer_new (const char *plugin_name, const char *plugin_id, { struct t_xfer *new_xfer; const char *ptr_color; - + new_xfer = xfer_alloc (); if (!new_xfer) { @@ -503,13 +503,13 @@ xfer_new (const char *plugin_name, const char *plugin_id, weechat_prefix ("error"), XFER_PLUGIN_NAME); return NULL; } - + if (!xfer_buffer && weechat_config_boolean (xfer_config_look_auto_open_buffer)) { xfer_buffer_open (); } - + /* initialize new xfer */ new_xfer->plugin_name = strdup (plugin_name); new_xfer->plugin_id = strdup (plugin_id); @@ -528,14 +528,14 @@ xfer_new (const char *plugin_name, const char *plugin_id, new_xfer->proxy = (proxy) ? strdup (proxy) : NULL; new_xfer->address = address; new_xfer->port = port; - + new_xfer->status = XFER_STATUS_WAITING; new_xfer->sock = sock; if (local_filename) new_xfer->local_filename = strdup (local_filename); else xfer_file_find_filename (new_xfer); - + /* write info message on server buffer */ switch (type) { @@ -588,14 +588,14 @@ xfer_new (const char *plugin_name, const char *plugin_id, case XFER_NUM_TYPES: break; } - + if (XFER_IS_FILE(type) && (!new_xfer->local_filename)) { xfer_close (new_xfer, XFER_STATUS_FAILED); xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); return NULL; } - + if (XFER_IS_FILE(type) && (new_xfer->start_resume > 0)) { weechat_printf (NULL, @@ -607,7 +607,7 @@ xfer_new (const char *plugin_name, const char *plugin_id, new_xfer->start_resume); xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); } - + /* connect if needed and display again xfer buffer */ if (XFER_IS_SEND(type)) { @@ -618,7 +618,7 @@ xfer_new (const char *plugin_name, const char *plugin_id, return NULL; } } - + if ( ( (type == XFER_TYPE_FILE_RECV) && (weechat_config_boolean (xfer_config_file_auto_accept_files)) ) || ( (type == XFER_TYPE_CHAT_RECV) @@ -626,7 +626,7 @@ xfer_new (const char *plugin_name, const char *plugin_id, xfer_network_accept (new_xfer); else xfer_buffer_refresh (WEECHAT_HOTLIST_PRIVATE); - + return new_xfer; } @@ -638,10 +638,10 @@ void xfer_free (struct t_xfer *xfer) { struct t_xfer *new_xfer_list; - + if (!xfer) return; - + /* remove xfer from list */ if (last_xfer == xfer) last_xfer = xfer->prev_xfer; @@ -654,7 +654,7 @@ xfer_free (struct t_xfer *xfer) new_xfer_list = xfer->next_xfer; if (xfer->next_xfer) (xfer->next_xfer)->prev_xfer = xfer->prev_xfer; - + /* free data */ if (xfer->plugin_id) free (xfer->plugin_id); @@ -672,11 +672,11 @@ xfer_free (struct t_xfer *xfer) free (xfer->unterminated_message); if (xfer->local_filename) free (xfer->local_filename); - + free (xfer); - + xfer_list = new_xfer_list; - + xfer_count--; if (xfer_buffer_selected_line >= xfer_count) xfer_buffer_selected_line = (xfer_count == 0) ? 0 : xfer_count - 1; @@ -704,12 +704,12 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, unsigned long local_addr; unsigned long long file_size; struct t_xfer *ptr_xfer; - + /* make C compiler happy */ (void) data; (void) signal; (void) type_data; - + if (!signal_data) { weechat_printf (NULL, @@ -717,9 +717,9 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, weechat_prefix ("error"), XFER_PLUGIN_NAME, "xfer_add"); return WEECHAT_RC_ERROR; } - + infolist = (struct t_infolist *)signal_data; - + if (!weechat_infolist_next (infolist)) { weechat_printf (NULL, @@ -730,10 +730,10 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, filename2 = NULL; short_filename = NULL; - + sock = -1; port = 0; - + plugin_name = weechat_infolist_string (infolist, "plugin_name"); plugin_id = weechat_infolist_string (infolist, "plugin_id"); str_type = weechat_infolist_string (infolist, "type"); @@ -744,7 +744,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, filename = weechat_infolist_string (infolist, "filename"); proxy = weechat_infolist_string (infolist, "proxy"); protocol = XFER_NO_PROTOCOL; - + if (!plugin_name || !plugin_id || !str_type || !remote_nick || !local_nick) { weechat_printf (NULL, @@ -761,7 +761,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, weechat_prefix ("error"), XFER_PLUGIN_NAME, str_type); goto error; } - + if (XFER_IS_FILE(type) && (!filename || !str_protocol)) { weechat_printf (NULL, @@ -769,7 +769,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, weechat_prefix ("error"), XFER_PLUGIN_NAME, "xfer_add"); goto error; } - + if (XFER_IS_FILE(type)) { protocol = xfer_search_protocol (str_protocol); @@ -782,17 +782,17 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, goto error; } } - + filename2 = NULL; file_size = 0; port = 0; - + if (type == XFER_TYPE_FILE_RECV) { filename2 = strdup (filename); sscanf (weechat_infolist_string (infolist, "size"), "%llu", &file_size); } - + if (type == XFER_TYPE_FILE_SEND) { /* add home if filename not beginning with '/' or '~' (not for Win32) */ @@ -813,7 +813,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, weechat_prefix ("error"), XFER_PLUGIN_NAME); goto error; } - + weechat_dir = weechat_info_get ("weechat_dir", ""); dir2 = weechat_string_replace (dir1, "%h", weechat_dir); if (!dir2) @@ -857,7 +857,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, } file_size = st.st_size; } - + if (XFER_IS_RECV(type)) { sscanf (weechat_infolist_string (infolist, "address"), "%lu", &local_addr); @@ -867,11 +867,11 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, { /* get local IP address */ sscanf (weechat_infolist_string (infolist, "address"), "%lu", &local_addr); - + memset (&addr, 0, sizeof (struct sockaddr_in)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl (local_addr); - + /* look up the IP address from network_own_ip, if set */ if (weechat_config_string(xfer_config_network_own_ip) && weechat_config_string(xfer_config_network_own_ip)[0]) @@ -900,7 +900,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, weechat_config_string (xfer_config_network_own_ip)); } } - + /* open socket for xfer */ sock = socket (AF_INET, SOCK_STREAM, 0); if (sock < 0) @@ -912,10 +912,10 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, free (filename2); goto error; } - + /* look for port */ port = 0; - + if (weechat_config_string (xfer_config_network_port_range) && weechat_config_string (xfer_config_network_port_range)[0]) { @@ -927,7 +927,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, port = port_start; if (args == 1) port_end = port_start; - + /* loop through the entire allowed port range */ while (port <= port_end) { @@ -940,12 +940,12 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, } port++; } - + if (port > port_end) port = -1; } } - + if (port == 0) { /* find port automatically */ @@ -959,7 +959,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, else port = -1; } - + if (port == -1) { /* Could not find any port to bind */ @@ -972,7 +972,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, goto error; } } - + if (XFER_IS_FILE(type)) { /* extract short filename (without path) */ @@ -981,7 +981,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, short_filename = strdup (pos + 1); else short_filename = strdup (filename2); - + /* convert spaces to underscore if asked and needed */ pos = short_filename; while (pos[0]) @@ -1003,7 +1003,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, filename2 = NULL; } } - + /* add xfer entry and listen to socket if type is file or chat "send" */ if (XFER_IS_FILE(type)) ptr_xfer = xfer_new (plugin_name, plugin_id, type, protocol, @@ -1014,7 +1014,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, ptr_xfer = xfer_new (plugin_name, plugin_id, type, protocol, remote_nick, local_nick, charset_modifier, NULL, 0, proxy, local_addr, port, sock, NULL); - + if (!ptr_xfer) { weechat_printf (NULL, @@ -1027,19 +1027,19 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, free (filename2); goto error; } - + /* send signal if type is file or chat "send" */ if (XFER_IS_SEND(ptr_xfer->type) && !XFER_HAS_ENDED(ptr_xfer->status)) xfer_send_signal (ptr_xfer, "xfer_send_ready"); - + if (short_filename) free (short_filename); if (filename2) free (filename2); - + weechat_infolist_reset_item_cursor (infolist); return WEECHAT_RC_OK; - + error: weechat_infolist_reset_item_cursor (infolist); return WEECHAT_RC_ERROR; @@ -1058,12 +1058,12 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data, const char *plugin_name, *plugin_id, *filename, *str_start_resume; int port; unsigned long long start_resume; - + /* make C compiler happy */ (void) data; (void) signal; (void) type_data; - + if (!signal_data) { weechat_printf (NULL, @@ -1072,9 +1072,9 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data, "xfer_start_resume"); return WEECHAT_RC_ERROR; } - + infolist = (struct t_infolist *)signal_data; - + if (!weechat_infolist_next (infolist)) { weechat_printf (NULL, @@ -1098,9 +1098,9 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data, "xfer_start_resume"); goto error; } - + sscanf (str_start_resume, "%llu", &start_resume); - + ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_RECV, XFER_STATUS_CONNECTING, port); if (ptr_xfer) @@ -1120,10 +1120,10 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data, weechat_prefix ("error"), XFER_PLUGIN_NAME, filename, port, start_resume); } - + weechat_infolist_reset_item_cursor (infolist); return WEECHAT_RC_OK; - + error: weechat_infolist_reset_item_cursor (infolist); return WEECHAT_RC_ERROR; @@ -1143,12 +1143,12 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data, const char *plugin_name, *plugin_id, *filename, *str_start_resume; int port; unsigned long long start_resume; - + /* make C compiler happy */ (void) data; (void) signal; (void) type_data; - + if (!signal_data) { weechat_printf (NULL, @@ -1157,9 +1157,9 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data, "xfer_accept_resume"); return WEECHAT_RC_ERROR; } - + infolist = (struct t_infolist *)signal_data; - + if (!weechat_infolist_next (infolist)) { weechat_printf (NULL, @@ -1183,9 +1183,9 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data, "xfer_accept_resume"); goto error; } - + sscanf (str_start_resume, "%llu", &start_resume); - + ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_SEND, XFER_STATUS_CONNECTING, port); if (ptr_xfer) @@ -1195,7 +1195,7 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data, ptr_xfer->start_resume = start_resume; ptr_xfer->last_check_pos = start_resume; xfer_send_signal (ptr_xfer, "xfer_send_accept_resume"); - + weechat_printf (NULL, _("%s: file %s resumed at position %llu"), XFER_PLUGIN_NAME, @@ -1212,10 +1212,10 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data, weechat_prefix ("error"), XFER_PLUGIN_NAME, filename, port, start_resume); } - + weechat_infolist_reset_item_cursor (infolist); return WEECHAT_RC_OK; - + error: weechat_infolist_reset_item_cursor (infolist); return WEECHAT_RC_ERROR; @@ -1231,14 +1231,14 @@ xfer_add_to_infolist (struct t_infolist *infolist, struct t_xfer *xfer) { struct t_infolist_item *ptr_item; char value[128]; - + if (!infolist || !xfer) return 0; - + ptr_item = weechat_infolist_new_item (infolist); if (!ptr_item) return 0; - + if (!weechat_infolist_new_var_string (ptr_item, "plugin_name", xfer->plugin_name)) return 0; if (!weechat_infolist_new_var_string (ptr_item, "plugin_id", xfer->plugin_id)) @@ -1328,7 +1328,7 @@ xfer_add_to_infolist (struct t_infolist *infolist, struct t_xfer *xfer) snprintf (value, sizeof (value), "%llu", xfer->eta); if (!weechat_infolist_new_var_string (ptr_item, "eta", value)) return 0; - + return 1; } @@ -1340,7 +1340,7 @@ void xfer_print_log () { struct t_xfer *ptr_xfer; - + for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) { weechat_log_printf (""); @@ -1361,7 +1361,7 @@ xfer_print_log () weechat_log_printf (" proxy . . . . . . . : '%s'", ptr_xfer->proxy); weechat_log_printf (" address . . . . . . : %lu", ptr_xfer->address); weechat_log_printf (" port. . . . . . . . : %d", ptr_xfer->port); - + weechat_log_printf (" status. . . . . . . : %d (%s)", ptr_xfer->status, xfer_status_string[ptr_xfer->status]); @@ -1406,21 +1406,21 @@ xfer_debug_dump_cb (void *data, const char *signal, const char *type_data, (void) data; (void) signal; (void) type_data; - + if (!signal_data || (weechat_strcasecmp ((char *)signal_data, XFER_PLUGIN_NAME) == 0)) { weechat_log_printf (""); weechat_log_printf ("***** \"%s\" plugin dump *****", weechat_plugin->name); - + xfer_print_log (); - + weechat_log_printf (""); weechat_log_printf ("***** End of \"%s\" plugin dump *****", weechat_plugin->name); } - + return WEECHAT_RC_OK; } @@ -1432,29 +1432,29 @@ int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { int i, upgrading; - + weechat_plugin = plugin; - + if (!xfer_config_init ()) return WEECHAT_RC_ERROR; - + if (xfer_config_read () < 0) return WEECHAT_RC_ERROR; - + xfer_create_directories (); - + xfer_command_init (); - + /* hook some signals */ weechat_hook_signal ("upgrade", &xfer_signal_upgrade_cb, NULL); weechat_hook_signal ("xfer_add", &xfer_add_cb, NULL); weechat_hook_signal ("xfer_start_resume", &xfer_start_resume_cb, NULL); weechat_hook_signal ("xfer_accept_resume", &xfer_accept_resume_cb, NULL); weechat_hook_signal ("debug_dump", &xfer_debug_dump_cb, NULL); - + /* hook completions */ xfer_completion_init (); - + xfer_info_init (); /* look at arguments */ @@ -1464,10 +1464,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) if (weechat_strcasecmp (argv[i], "--upgrade") == 0) upgrading = 1; } - + if (upgrading) xfer_upgrade_load (); - + return WEECHAT_RC_OK; } @@ -1479,12 +1479,12 @@ int weechat_plugin_end (struct t_weechat_plugin *plugin) { struct t_xfer *ptr_xfer; - + /* make C compiler happy */ (void) plugin; - + xfer_config_write (); - + if (xfer_signal_upgrade_received) xfer_upgrade_save (); else @@ -1508,6 +1508,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin) } } } - + return WEECHAT_RC_OK; } diff --git a/src/plugins/xfer/xfer.h b/src/plugins/xfer/xfer.h index 8525c8d35..d5694f949 100644 --- a/src/plugins/xfer/xfer.h +++ b/src/plugins/xfer/xfer.h @@ -60,7 +60,7 @@ enum t_xfer_status /* number of xfer status */ XFER_NUM_STATUS, }; - + /* xfer errors */ enum t_xfer_error @@ -121,7 +121,7 @@ struct t_xfer char *proxy; /* proxy to use (optional) */ unsigned long address; /* local or remote IP address */ int port; /* remote port */ - + /* internal data */ enum t_xfer_status status; /* xfer status (waiting, sending,..) */ struct t_gui_buffer *buffer; /* buffer (for chat only) */ |