# HG changeset patch # User Christian Hammond # Date 1044381377 0 # Node ID a2b2cce63fb8cb0148194d6f89a2be33d414e611 # Parent 2ad2f5caeb81d2eb410c365838d72964d7195f58 [gaim-migrate @ 4795] Some changes to handle unknown file sizes better. committer: Tailor Script diff -r 2ad2f5caeb81 -r a2b2cce63fb8 src/ft.c --- a/src/ft.c Tue Feb 04 15:46:05 2003 +0000 +++ b/src/ft.c Tue Feb 04 17:56:17 2003 +0000 @@ -238,6 +238,9 @@ if (xfer == NULL) return 0.0; + if (gaim_xfer_get_size(xfer) == 0) + return 0.0; + return ((double)gaim_xfer_get_bytes_sent(xfer) / (double)gaim_xfer_get_size(xfer)); } @@ -305,7 +308,7 @@ void gaim_xfer_set_size(struct gaim_xfer *xfer, size_t size) { - if (xfer == NULL || size == 0) + if (xfer == NULL) return; xfer->size = size; @@ -400,7 +403,10 @@ if (xfer == NULL || buffer == NULL) return 0; - s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096); + if (gaim_xfer_get_size(xfer) == 0) + s = 4096; + else + s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096); if (xfer->ops.read != NULL) r = xfer->ops.read(buffer, xfer); @@ -477,7 +483,7 @@ if (ui_ops != NULL && ui_ops->update_progress != NULL) ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer)); - if (xfer->bytes_remaining == 0) + if (r == 0) gaim_xfer_end(xfer); } diff -r 2ad2f5caeb81 -r a2b2cce63fb8 src/gtkft.c --- a/src/gtkft.c Tue Feb 04 15:46:05 2003 +0000 +++ b/src/gtkft.c Tue Feb 04 17:56:17 2003 +0000 @@ -516,39 +516,45 @@ data = (struct gaim_gtkxfer_ui_data *)xfer->ui_data; - now = time(NULL); - kb_rem = gaim_xfer_get_bytes_remaining(xfer) / 1024.0; - kb_sent = gaim_xfer_get_bytes_sent(xfer) / 1024.0; - elapsed = (now - data->start_time); - kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); - - secs_remaining = (int)(kb_rem / kbps); - - if (secs_remaining <= 0) { - GdkPixbuf *pixbuf = NULL; - + if (gaim_xfer_get_size(xfer) == 0) { *speed_buf = '\0'; - strncpy(estimate_buf, _("Done."), sizeof(estimate_buf)); - - pixbuf = gtk_widget_render_icon(xfer_dialog->window, - GAIM_STOCK_FILE_DONE, - GTK_ICON_SIZE_MENU, NULL); - - gtk_list_store_set(xfer_dialog->model, &data->iter, - COLUMN_STATUS, pixbuf, - -1); - - g_object_unref(pixbuf); + strncpy(estimate_buf, _("Unknown"), sizeof(estimate_buf)); } else { - int h = secs_remaining / 3600; - int m = (secs_remaining % 3600) / 60; - int s = secs_remaining % 60; + now = time(NULL); + kb_rem = gaim_xfer_get_bytes_remaining(xfer) / 1024.0; + kb_sent = gaim_xfer_get_bytes_sent(xfer) / 1024.0; + elapsed = (now - data->start_time); + kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); + + secs_remaining = (int)(kb_rem / kbps); + + if (secs_remaining <= 0) { + GdkPixbuf *pixbuf = NULL; + + *speed_buf = '\0'; + strncpy(estimate_buf, _("Done."), sizeof(estimate_buf)); - g_snprintf(estimate_buf, sizeof(estimate_buf), - _("%d:%02d:%02d"), h, m, s); - g_snprintf(speed_buf, sizeof(speed_buf), - _("%.2f KB/s"), kbps); + pixbuf = gtk_widget_render_icon(xfer_dialog->window, + GAIM_STOCK_FILE_DONE, + GTK_ICON_SIZE_MENU, NULL); + + gtk_list_store_set(xfer_dialog->model, &data->iter, + COLUMN_STATUS, pixbuf, + -1); + + g_object_unref(pixbuf); + } + else { + int h = secs_remaining / 3600; + int m = (secs_remaining % 3600) / 60; + int s = secs_remaining % 60; + + g_snprintf(estimate_buf, sizeof(estimate_buf), + _("%d:%02d:%02d"), h, m, s); + g_snprintf(speed_buf, sizeof(speed_buf), + _("%.2f KB/s"), kbps); + } } gtk_list_store_set(xfer_dialog->model, &data->iter,