summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2014-08-28 10:46:14 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-09-18 13:21:55 +0200
commit18fc36c0542db120d78bd5a4a4c4d89b44607f5d (patch)
tree9ecd2548bb77cc8de9cdc95a479b43c3f9cc5d12
parentf54458db9b0a1801d9e50f396eac121ee7c2a0fd (diff)
channel-main: allow transferring multiple files at once
Allow to drag and drop, from host to guest, more than one file at the same time.
-rw-r--r--gtk/channel-main.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 021fa83..1ad090f 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -2729,7 +2729,7 @@ static void file_xfer_read_async_cb(GObject *obj, GAsyncResult *res, gpointer da
}
static void file_xfer_send_start_msg_async(SpiceMainChannel *channel,
- GFile *file,
+ GFile **files,
GFileCopyFlags flags,
GCancellable *cancellable,
GFileProgressCallback progress_callback,
@@ -2740,27 +2740,30 @@ static void file_xfer_send_start_msg_async(SpiceMainChannel *channel,
SpiceMainChannelPrivate *c = channel->priv;
SpiceFileXferTask *task;
static uint32_t xfer_id; /* Used to identify task id */
+ gint i;
- task = g_malloc0(sizeof(SpiceFileXferTask));
- task->id = ++xfer_id;
- task->channel = g_object_ref(channel);
- task->file = g_object_ref(file);
- task->flags = flags;
- task->cancellable = cancellable;
- task->progress_callback = progress_callback;
- task->progress_callback_data = progress_callback_data;
- task->callback = callback;
- task->user_data = user_data;
-
- CHANNEL_DEBUG(task->channel, "Insert a xfer task:%d to task list", task->id);
- g_hash_table_insert(c->file_xfer_tasks, GUINT_TO_POINTER(task->id), task);
-
- g_file_read_async(file,
- G_PRIORITY_DEFAULT,
- cancellable,
- file_xfer_read_async_cb,
- task);
- task->pending = TRUE;
+ for (i = 0; files[i] != NULL && !g_cancellable_is_cancelled(cancellable); i++) {
+ task = g_malloc0(sizeof(SpiceFileXferTask));
+ task->id = ++xfer_id;
+ task->channel = g_object_ref(channel);
+ task->file = g_object_ref(files[i]);
+ task->flags = flags;
+ task->cancellable = cancellable;
+ task->progress_callback = progress_callback;
+ task->progress_callback_data = progress_callback_data;
+ task->callback = callback;
+ task->user_data = user_data;
+
+ CHANNEL_DEBUG(task->channel, "Insert a xfer task:%d to task list", task->id);
+ g_hash_table_insert(c->file_xfer_tasks, GUINT_TO_POINTER(task->id), task);
+
+ g_file_read_async(files[i],
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ file_xfer_read_async_cb,
+ task);
+ task->pending = TRUE;
+ }
}
/**
@@ -2803,11 +2806,7 @@ void spice_main_file_copy_async(SpiceMainChannel *channel,
g_return_if_fail(channel != NULL);
g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
- g_return_if_fail(sources != NULL && sources[0] != NULL);
-
- /* At the moment, the copy() method is limited to a single file,
- support for copying multi-files will be implemented later. */
- g_return_if_fail(sources[1] == NULL);
+ g_return_if_fail(sources != NULL);
if (!c->agent_connected) {
g_simple_async_report_error_in_idle(G_OBJECT(channel),
@@ -2820,7 +2819,7 @@ void spice_main_file_copy_async(SpiceMainChannel *channel,
}
file_xfer_send_start_msg_async(channel,
- sources[0],
+ sources,
flags,
cancellable,
progress_callback,