static void silcpurple_ftp_cancel(PurpleXfer *x) { SilcPurpleXfer xfer = x->data; xfer->xfer->status = PURPLE_XFER_STATUS_CANCEL_LOCAL; purple_xfer_update_progress(xfer->xfer); silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); }
static void _qq_update_send_progess(PurpleConnection *gc, guint32 fragment_index) { guint32 mask; guint8 *buffer; gint readbytes; qq_data *qd = (qq_data *) gc->proto_data; PurpleXfer *xfer = qd->xfer; ft_info *info = (ft_info *) xfer->data; purple_debug_info("QQ", "receiving %dth fragment ack, slide window status %o, max_fragment_index %d\n", fragment_index, info->window, info->max_fragment_index); if (fragment_index < info->max_fragment_index || fragment_index >= info->max_fragment_index + sizeof(info->window)) { purple_debug_info("QQ", "duplicate %dth fragment, drop it!\n", fragment_index+1); return; } mask = 0x1 << (fragment_index % sizeof(info->window)); if ((info->window & mask) == 0) { info->window |= mask; if (fragment_index + 1 != info->fragment_num) { xfer->bytes_sent += info->fragment_len; } else { xfer->bytes_sent += purple_xfer_get_size(xfer) % info->fragment_len; } xfer->bytes_remaining = purple_xfer_get_size(xfer) - purple_xfer_get_bytes_sent(xfer); purple_xfer_update_progress(xfer); if (purple_xfer_get_bytes_remaining(xfer) <= 0) { /* We have finished sending the file */ purple_xfer_set_completed(xfer, TRUE); return; } mask = 0x1 << (info->max_fragment_index % sizeof(info->window)); while (info->window & mask) { /* move the slide window */ info->window &= ~mask; buffer = g_newa(guint8, info->fragment_len); readbytes = _qq_xfer_read_file(buffer, info->max_fragment_index + sizeof(info->window), info->fragment_len, xfer); if (readbytes > 0) _qq_send_file_data_packet(gc, QQ_FILE_CMD_FILE_OP, QQ_FILE_DATA_INFO, info->max_fragment_index + sizeof(info->window) + 1, 0, buffer, readbytes); info->max_fragment_index ++; if (mask & 0x8000) mask = 0x0001; else mask = mask << 1; } } purple_debug_info("QQ", "procceed %dth fragment ack, slide window status %o, max_fragment_index %d\n", fragment_index, info->window, info->max_fragment_index); }
void msn_xfer_progress_cb(MsnSlpCall *slpcall, gsize total_length, gsize len, gsize offset) { PurpleXfer *xfer; xfer = slpcall->xfer; xfer->bytes_sent = (offset + len); xfer->bytes_remaining = total_length - (offset + len); purple_xfer_update_progress(xfer); }
static gboolean tgprpl_xfer_upload_progress (gpointer _data) { PurpleXfer *X = _data; struct tgp_xfer_send_data *data = X->data; connection_data *conn = data->conn; PurpleXferType type = purple_xfer_get_type(X); switch (type) { case PURPLE_XFER_SEND: purple_xfer_set_size (X, conn->TLS->cur_uploading_bytes); purple_xfer_set_bytes_sent (X, conn->TLS->cur_uploaded_bytes); purple_xfer_update_progress (X); debug ("PURPLE_XFER_SEND progress %d / %d", conn->TLS->cur_uploaded_bytes, conn->TLS->cur_uploading_bytes); if (conn->TLS->cur_uploaded_bytes == conn->TLS->cur_uploading_bytes) { data->timer = 0; return FALSE; } break; case PURPLE_XFER_RECEIVE: purple_xfer_set_size (X, conn->TLS->cur_downloading_bytes); purple_xfer_set_bytes_sent (X, conn->TLS->cur_downloaded_bytes); purple_xfer_update_progress (X); debug ("PURPLE_XFER_RECEIVE progress %d / %d", conn->TLS->cur_downloaded_bytes, conn->TLS->cur_downloading_bytes); if (conn->TLS->cur_downloading_bytes == conn->TLS->cur_downloaded_bytes) { data->timer = 0; return FALSE; } break; default: case PURPLE_XFER_UNKNOWN: failure ("ERROR: tgprpl_xfer_upload_progress xfer type PURPLE_XFER_UNKNOWN."); return FALSE; break; } return TRUE; }
static void yahoo_process_filetrans_15_watcher(PurpleHttpConnection *hc, gboolean reading_state, int processed, int total, gpointer _xfer) { PurpleXfer *xfer = _xfer; if (reading_state != (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_RECEIVE)) { return; } purple_xfer_set_size(xfer, total); purple_xfer_update_progress(xfer); }
static void xfer_progress_cb(struct pn_peer_call *call, gsize total_length, gsize len, gsize offset) { PurpleXfer *xfer; xfer = call->xfer; xfer->bytes_sent = (offset + len); xfer->bytes_remaining = total_length - (offset + len); purple_xfer_update_progress(xfer); }
/* Checks if the WA protocol has data to output and schedules a write handler */ void waprpl_check_ssl_output(PurpleConnection * gc) { whatsapp_connection *wconn = purple_connection_get_protocol_data(gc); if (wconn->sslfd >= 0) { int r = waAPI_sslhasoutdata(wconn->waAPI); if (r > 0) { /* Need to watch for output data (if we are not doing it already) */ if (wconn->sslwh == 0) wconn->sslwh = purple_input_add(wconn->sslfd, PURPLE_INPUT_WRITE, waprpl_ssl_output_cb, gc); } else if (r < 0) { waprpl_ssl_cerr_cb(0, 0, gc); /* Finished the connection! */ } else { if (wconn->sslwh != 0) purple_input_remove(wconn->sslwh); wconn->sslwh = 0; } purple_debug_info(WHATSAPP_ID, "Watch for output is %d %d\n", r, errno); /* Update transfer status */ int rid, bytes_sent; if (waAPI_fileuploadprogress(wconn->waAPI, &rid, &bytes_sent)) { GList *xfers = purple_xfers_get_all(); while (xfers) { PurpleXfer *xfer = xfers->data; wa_file_upload *xinfo = (wa_file_upload *) xfer->data; if (xinfo->ref_id == rid) { purple_debug_info(WHATSAPP_ID, "Upload progress %d bytes done\n", bytes_sent); purple_xfer_set_bytes_sent(xfer, bytes_sent); purple_xfer_update_progress(xfer); break; } xfers = g_list_next(xfers); } } } // Check uploads to mark them as done :) waprpl_check_complete_uploads(gc); }
static void _qq_recv_file_progess(PurpleConnection *gc, guint8 *buffer, guint16 len, guint32 index, guint32 offset) { qq_data *qd = (qq_data *) gc->proto_data; PurpleXfer *xfer = qd->xfer; ft_info *info = (ft_info *) xfer->data; guint32 mask; purple_debug_info("QQ", "receiving %dth fragment with length %d, slide window status %o, max_fragment_index %d\n", index, len, info->window, info->max_fragment_index); if (info->window == 0 && info->max_fragment_index == 0) { if (_qq_xfer_open_file(purple_xfer_get_local_filename(xfer), "wb", xfer) == -1) { purple_xfer_cancel_local(xfer); return; } purple_debug_info("QQ", "object file opened for writing\n"); } mask = 0x1 << (index % sizeof(info->window)); if (index < info->max_fragment_index || (info->window & mask)) { purple_debug_info("QQ", "duplicate %dth fragment, drop it!\n", index+1); return; } info->window |= mask; _qq_xfer_write_file(buffer, index, len, xfer); xfer->bytes_sent += len; xfer->bytes_remaining -= len; purple_xfer_update_progress(xfer); mask = 0x1 << (info->max_fragment_index % sizeof(info->window)); while (info->window & mask) { info->window &= ~mask; info->max_fragment_index ++; if (mask & 0x8000) mask = 0x0001; else mask = mask << 1; } purple_debug_info("QQ", "procceed %dth fragment, slide window status %o, max_fragment_index %d\n", index, info->window, info->max_fragment_index); }
static void ggp_edisc_xfer_progress_watcher(PurpleHttpConnection *hc, gboolean reading_state, int processed, int total, gpointer _xfer) { PurpleXfer *xfer = _xfer; gboolean eof; int total_real; if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_RECEIVE) { if (!reading_state) return; } else { if (reading_state) return; } eof = (processed >= total); total_real = purple_xfer_get_size(xfer); if (eof || processed > total_real) processed = total_real; /* just to be sure */ purple_xfer_set_bytes_sent(xfer, processed); purple_xfer_update_progress(xfer); }
static void silcpurple_ftp_monitor(SilcClient client, SilcClientConnection conn, SilcClientMonitorStatus status, SilcClientFileError error, SilcUInt64 offset, SilcUInt64 filesize, SilcClientEntry client_entry, SilcUInt32 session_id, const char *filepath, void *context) { SilcPurpleXfer xfer = context; PurpleConnection *gc = xfer->sg->gc; char tmp[256]; if (status == SILC_CLIENT_FILE_MONITOR_CLOSED) { purple_xfer_unref(xfer->xfer); silc_free(xfer); return; } if (status == SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT) return; if (status == SILC_CLIENT_FILE_MONITOR_ERROR) { if (error == SILC_CLIENT_FILE_NO_SUCH_FILE) { g_snprintf(tmp, sizeof(tmp), "No such file %s", filepath ? filepath : "[N/A]"); purple_notify_error(gc, _("Secure File Transfer"), _("Error during file transfer"), tmp); } else if (error == SILC_CLIENT_FILE_PERMISSION_DENIED) { purple_notify_error(gc, _("Secure File Transfer"), _("Error during file transfer"), _("Permission denied")); } else if (error == SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED) { purple_notify_error(gc, _("Secure File Transfer"), _("Error during file transfer"), _("Key agreement failed")); } else if (error == SILC_CLIENT_FILE_UNKNOWN_SESSION) { purple_notify_error(gc, _("Secure File Transfer"), _("Error during file transfer"), _("File transfer session does not exist")); } else { purple_notify_error(gc, _("Secure File Transfer"), _("Error during file transfer"), NULL); } silc_client_file_close(client, conn, session_id); purple_xfer_unref(xfer->xfer); silc_free(xfer); return; } /* Update file transfer UI */ if (!offset && filesize) purple_xfer_set_size(xfer->xfer, filesize); if (offset && filesize) { xfer->xfer->bytes_sent = offset; xfer->xfer->bytes_remaining = filesize - offset; } purple_xfer_update_progress(xfer->xfer); if (status == SILC_CLIENT_FILE_MONITOR_SEND || status == SILC_CLIENT_FILE_MONITOR_RECEIVE) { if (offset == filesize) { /* Download finished */ purple_xfer_set_completed(xfer->xfer, TRUE); silc_client_file_close(client, conn, session_id); } } }