[Spice-devel] [PATCH] channel-main: allow transferring multiple files at once

Marc-André Lureau mlureau at redhat.com
Thu Aug 28 03:22:52 PDT 2014


looks fine, ack

----- Original Message -----
> Allow to drag and drop, from host to guest, more than one file at the
> same time.
> ---
>  gtk/channel-main.c | 53
>  ++++++++++++++++++++++++++---------------------------
>  1 file changed, 26 insertions(+), 27 deletions(-)
> 
> diff --git a/gtk/channel-main.c b/gtk/channel-main.c
> index f33b0fd..165f51b 100644
> --- a/gtk/channel-main.c
> +++ b/gtk/channel-main.c
> @@ -2728,7 +2728,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,
> @@ -2739,27 +2739,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;
> +    }
>  }
>  
>  /**
> @@ -2802,11 +2805,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),
> @@ -2819,7 +2818,7 @@ void spice_main_file_copy_async(SpiceMainChannel
> *channel,
>      }
>  
>      file_xfer_send_start_msg_async(channel,
> -                                   sources[0],
> +                                   sources,
>                                     flags,
>                                     cancellable,
>                                     progress_callback,
> --
> 1.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list