spice_main_file_copy_async() allows you to pass a NULL-terminated array of files to transfer to the guest. It also allows you to pass a progress_callback function to monitor the progress of the transfer, but this progress callback is called separately for each file that is transferred, and there are no parameters that allow the caller to determine which file a given callback corresponds to. This makes it very difficult to monitor the progress. To make this more usable, I've changed it so that the progress callback doesn't simply report the number of bytes read and total size of the current file. Instead, every we add up the status of all current transfers and report that in the callback. --- src/channel-main.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/channel-main.c b/src/channel-main.c index 339005c..9712191 100644 --- a/src/channel-main.c +++ b/src/channel-main.c @@ -1787,9 +1787,25 @@ static void file_xfer_data_flushed_cb(GObject *source_object, } } - if (task->progress_callback) - task->progress_callback(task->read_bytes, task->file_size, - task->progress_callback_data); + if (task->progress_callback) { + goffset read = 0; + goffset total = 0; + SpiceMainChannel *main_channel = task->channel; + GHashTableIter iter; + gpointer key, value; + + /* since the progress_callback does not have a parameter to indicate + * which file the progress is associated with, report progress on all + * current transfers */ + g_hash_table_iter_init(&iter, main_channel->priv->file_xfer_tasks); + while (g_hash_table_iter_next(&iter, &key, &value)) { + SpiceFileXferTask *t = (SpiceFileXferTask *)value; + read += t->read_bytes; + total += t->file_size; + } + + task->progress_callback(read, total, task->progress_callback_data); + } /* Read more data */ file_xfer_continue_read(task); -- 2.1.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel