From: Mark D. <the...@us...> - 2006-04-09 17:38:51
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31993 Modified Files: gtkft.c ft.h ft.c Log Message: Previously our file transfer dialog showed "time elapsed" as the current time minus the time when the transfer was added to the ft dialog. When sending a file, the transfer is added when you offer the file to the remote user, not when the transfer actually starts. This meant the "time elapsed" was longer than it should have been, which threw off the transfer rate. This should fix that. Index: gtkft.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkft.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -p -r1.81 -r1.82 --- gtkft.c 2 Feb 2006 21:34:39 -0000 1.81 +++ gtkft.c 9 Apr 2006 17:38:38 -0000 1.82 @@ -84,9 +84,7 @@ struct _GaimGtkXferDialog typedef struct { GtkTreeIter iter; - time_t start_time; time_t last_updated_time; - time_t end_time; gboolean in_list; char *name; @@ -121,35 +119,39 @@ get_xfer_info_strings(GaimXfer *xfer, ch data = GAIM_GTKXFER(xfer); - if (data->end_time == -1 && - (gaim_xfer_is_canceled(xfer) || gaim_xfer_is_completed(xfer))) - data->end_time = time(NULL); - - if (data->end_time != -1) - now = data->end_time; + if (xfer->end_time != 0) + now = xfer->end_time; else now = time(NULL); kb_sent = gaim_xfer_get_bytes_sent(xfer) / 1024.0; kb_rem = gaim_xfer_get_bytes_remaining(xfer) / 1024.0; - elapsed = (now - data->start_time); + elapsed = (xfer->start_time > 0 ? now - xfer->start_time : 0); kbps = (elapsed > 0 ? (kb_sent / elapsed) : 0); if (kbsec != NULL) { *kbsec = g_strdup_printf(_("%.2f KB/s"), kbps); } - if (time_elapsed != NULL) { + if (time_elapsed != NULL) + { int h, m, s; int secs_elapsed; - secs_elapsed = now - data->start_time; + if (xfer->start_time > 0) + { + secs_elapsed = now - xfer->start_time; - h = secs_elapsed / 3600; - m = (secs_elapsed % 3600) / 60; - s = secs_elapsed % 60; + h = secs_elapsed / 3600; + m = (secs_elapsed % 3600) / 60; + s = secs_elapsed % 60; - *time_elapsed = g_strdup_printf("%d:%02d:%02d", h, m, s); + *time_elapsed = g_strdup_printf("%d:%02d:%02d", h, m, s); + } + else + { + *time_elapsed = g_strdup(_("Not started")); + } } if (time_remaining != NULL) { @@ -227,10 +229,10 @@ update_detailed_info(GaimGtkXferDialog * _("<b>Sending As:</b>")); } - gtk_label_set_text(GTK_LABEL(dialog->local_user_label), + gtk_label_set_text(GTK_LABEL(dialog->local_user_label), gaim_account_get_username(xfer->account)); gtk_label_set_text(GTK_LABEL(dialog->remote_user_label), xfer->who); - gtk_label_set_text(GTK_LABEL(dialog->protocol_label), + gtk_label_set_text(GTK_LABEL(dialog->protocol_label), gaim_account_get_protocol_name(xfer->account)); if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { @@ -892,9 +894,7 @@ gaim_gtkxfer_dialog_add_xfer(GaimGtkXfer gaim_gtkxfer_dialog_show(dialog); - data->start_time = time(NULL); data->last_updated_time = 0; - data->end_time = -1; type = gaim_xfer_get_type(xfer); Index: ft.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/ft.h,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -p -r1.44 -r1.45 --- ft.h 23 Jan 2006 04:17:27 -0000 1.44 +++ ft.h 9 Apr 2006 17:38:38 -0000 1.45 @@ -106,6 +106,8 @@ struct _GaimXfer size_t bytes_sent; /**< The number of bytes sent. */ size_t bytes_remaining; /**< The number of bytes remaining. */ + time_t start_time; /**< When the transfer of data began. */ + time_t end_time; /**< When the transfer of data ended. */ GaimXferStatusType status; /**< File Transfer's status. */ Index: ft.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/ft.c,v retrieving revision 1.98 retrieving revision 1.99 diff -u -d -p -r1.98 -r1.99 --- ft.c 7 Apr 2006 05:14:16 -0000 1.98 +++ ft.c 9 Apr 2006 17:38:38 -0000 1.99 @@ -909,6 +909,8 @@ begin_transfer(GaimXfer *xfer, GaimInput xfer->watcher = gaim_input_add(xfer->fd, cond, transfer_cb, xfer); + xfer->start_time = time(NULL); + if (xfer->ops.start != NULL) xfer->ops.start(xfer); } @@ -977,6 +979,7 @@ gaim_xfer_end(GaimXfer *xfer) return; } + xfer->end_time = time(NULL); if (xfer->ops.end != NULL) xfer->ops.end(xfer); @@ -1018,6 +1021,7 @@ gaim_xfer_cancel_local(GaimXfer *xfer) g_return_if_fail(xfer != NULL); gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL); + xfer->end_time = time(NULL); if (gaim_xfer_get_filename(xfer) != NULL) { @@ -1077,6 +1081,7 @@ gaim_xfer_cancel_remote(GaimXfer *xfer) gaim_request_close_with_handle(xfer); gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE); + xfer->end_time = time(NULL); account = gaim_xfer_get_account(xfer); buddy = gaim_find_buddy(account, xfer->who); |