Re: [Spice-devel] [PATCH spice-gtk 1/2] main: remove SpiceFileTransferTaskPrivate

2016-05-25 Thread Victor Toso
Hi,

On Wed, May 25, 2016 at 11:01:47PM +0200, Victor Toso wrote:
> Hi,
>
> On Wed, May 25, 2016 at 05:42:48PM +0200, Pavel Grunt wrote:
> > Of course it is correct, but I would wait with it after applying:
> >  https://lists.freedesktop.org/archives/spice-devel/2016-May/029359.html
> > or if Victor is ok with it?
>
> No problem Besides the typo in the commit log /o\ :D

Really, I should not reply so late. I confused this patch with yours
patch [0]. Indeed, I would prefer that this change comes after the
file-transfer move, if that works for you... Unless that gets nacked.

[0] https://cgit.freedesktop.org/spice/spice-gtk/commit/?id=2210a5c22027

>
> >
> > Pavel
> > 
> > On Wed, 2016-05-25 at 17:33 +0200, Marc-André Lureau wrote:
> > > The struct is already private
> > > 
> > > Signed-off-by: Marc-André Lureau 
> > > ---
> > >  src/channel-main.c | 227 
> > > +++-
> > > -
> > >  src/spice-file-transfer-task.h |   1 -
> > >  2 files changed, 107 insertions(+), 121 deletions(-)
> > > 
> > > diff --git a/src/channel-main.c b/src/channel-main.c
> > > index b91daa5..c9bc668 100644
> > > --- a/src/channel-main.c
> > > +++ b/src/channel-main.c
> > > @@ -81,30 +81,6 @@ struct _SpiceFileTransferTask
> > >  {
> > >  GObject parent;
> > >  
> > > -SpiceFileTransferTaskPrivate *priv;
> > > -};
> > > -
> > > -/**
> > > - * SpiceFileTransferTaskClass:
> > > - * @parent_class: Parent class.
> > > - *
> > > - * Class structure for #SpiceFileTransferTask.
> > > - */
> > > -struct _SpiceFileTransferTaskClass
> > > -{
> > > -GObjectClass parent_class;
> > > -};
> > > -
> > > -G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, 
> > > G_TYPE_OBJECT)
> > > -
> > > -#define FILE_TRANSFER_TASK_PRIVATE(o) \
> > > -(G_TYPE_INSTANCE_GET_PRIVATE((o), SPICE_TYPE_FILE_TRANSFER_TASK,
> > > SpiceFileTransferTaskPrivate))
> > > -
> > > -#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
> > > -struct _SpiceFileTransferTaskPrivate
> > > -
> > > -/* private */
> > > -{
> > >  uint32_t   id;
> > >  gboolean   pending;
> > >  GFile  *file;
> > > @@ -124,6 +100,21 @@ struct _SpiceFileTransferTaskPrivate
> > >  GError *error;
> > >  };
> > >  
> > > +/**
> > > + * SpiceFileTransferTaskClass:
> > > + * @parent_class: Parent class.
> > > + *
> > > + * Class structure for #SpiceFileTransferTask.
> > > + */
> > > +struct _SpiceFileTransferTaskClass
> > > +{
> > > +GObjectClass parent_class;
> > > +};
> > > +
> > > +G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, 
> > > G_TYPE_OBJECT)
> > > +
> > > +#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
> > > +
> > >  enum {
> > >  PROP_TASK_ID = 1,
> > >  PROP_TASK_CHANNEL,
> > > @@ -1837,23 +1828,23 @@ static void file_xfer_close_cb(GObject  
> > > *object,
> > >  
> > >  /* Notify to user that files have been transferred or something error
> > > happened. */
> > > -task = g_task_new(self->priv->channel,
> > > -  self->priv->cancellable,
> > > -  self->priv->callback,
> > > -  self->priv->user_data);
> > > +task = g_task_new(self->channel,
> > > +  self->cancellable,
> > > +  self->callback,
> > > +  self->user_data);
> > >  
> > > -if (self->priv->error) {
> > > -g_task_return_error(task, self->priv->error);
> > > +if (self->error) {
> > > +g_task_return_error(task, self->error);
> > >  } else {
> > >  g_task_return_boolean(task, TRUE);
> > >  if (spice_util_get_debug()) {
> > >  gint64 now = g_get_monotonic_time();
> > > -gchar *basename = g_file_get_basename(self->priv->file);
> > > -double seconds = (double) (now - self->priv->start_time) /
> > > G_TIME_SPAN_SECOND;
> > > -gchar *file_size_str = g_format_size(self->priv->file_size);
> > > -gchar *transfer_speed_str = 
> > > g_format_size(self->priv->file_size /
> > > seconds);
> > > +gchar *basename = g_file_get_basename(self->file);
> > > +double seconds = (double) (now - self->start_time) /
> > > G_TIME_SPAN_SECOND;
> > > +gchar *file_size_str = g_format_size(self->file_size);
> > > +gchar *transfer_speed_str = g_format_size(self->file_size /
> > > seconds);
> > >  
> > > -g_warn_if_fail(self->priv->read_bytes == 
> > > self->priv->file_size);
> > > +g_warn_if_fail(self->read_bytes == self->file_size);
> > >  SPICE_DEBUG("transferred file %s of %s size in %.1f seconds
> > > (%s/s)",
> > >  basename, file_size_str, seconds,
> > > transfer_speed_str);
> > >  
> > > @@ -1875,9 +1866,9 @@ static void file_xfer_data_flushed_cb(GObject
> > > 

Re: [Spice-devel] [PATCH spice-gtk 1/2] main: remove SpiceFileTransferTaskPrivate

2016-05-25 Thread Victor Toso
Hi,

On Wed, May 25, 2016 at 05:42:48PM +0200, Pavel Grunt wrote:
> Of course it is correct, but I would wait with it after applying:
>  https://lists.freedesktop.org/archives/spice-devel/2016-May/029359.html
> or if Victor is ok with it?

No problem Besides the typo in the commit log /o\ :D

>
> Pavel
> 
> On Wed, 2016-05-25 at 17:33 +0200, Marc-André Lureau wrote:
> > The struct is already private
> > 
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  src/channel-main.c | 227 
> > +++-
> > -
> >  src/spice-file-transfer-task.h |   1 -
> >  2 files changed, 107 insertions(+), 121 deletions(-)
> > 
> > diff --git a/src/channel-main.c b/src/channel-main.c
> > index b91daa5..c9bc668 100644
> > --- a/src/channel-main.c
> > +++ b/src/channel-main.c
> > @@ -81,30 +81,6 @@ struct _SpiceFileTransferTask
> >  {
> >  GObject parent;
> >  
> > -SpiceFileTransferTaskPrivate *priv;
> > -};
> > -
> > -/**
> > - * SpiceFileTransferTaskClass:
> > - * @parent_class: Parent class.
> > - *
> > - * Class structure for #SpiceFileTransferTask.
> > - */
> > -struct _SpiceFileTransferTaskClass
> > -{
> > -GObjectClass parent_class;
> > -};
> > -
> > -G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, 
> > G_TYPE_OBJECT)
> > -
> > -#define FILE_TRANSFER_TASK_PRIVATE(o) \
> > -(G_TYPE_INSTANCE_GET_PRIVATE((o), SPICE_TYPE_FILE_TRANSFER_TASK,
> > SpiceFileTransferTaskPrivate))
> > -
> > -#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
> > -struct _SpiceFileTransferTaskPrivate
> > -
> > -/* private */
> > -{
> >  uint32_t   id;
> >  gboolean   pending;
> >  GFile  *file;
> > @@ -124,6 +100,21 @@ struct _SpiceFileTransferTaskPrivate
> >  GError *error;
> >  };
> >  
> > +/**
> > + * SpiceFileTransferTaskClass:
> > + * @parent_class: Parent class.
> > + *
> > + * Class structure for #SpiceFileTransferTask.
> > + */
> > +struct _SpiceFileTransferTaskClass
> > +{
> > +GObjectClass parent_class;
> > +};
> > +
> > +G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, 
> > G_TYPE_OBJECT)
> > +
> > +#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
> > +
> >  enum {
> >  PROP_TASK_ID = 1,
> >  PROP_TASK_CHANNEL,
> > @@ -1837,23 +1828,23 @@ static void file_xfer_close_cb(GObject  *object,
> >  
> >  /* Notify to user that files have been transferred or something error
> > happened. */
> > -task = g_task_new(self->priv->channel,
> > -  self->priv->cancellable,
> > -  self->priv->callback,
> > -  self->priv->user_data);
> > +task = g_task_new(self->channel,
> > +  self->cancellable,
> > +  self->callback,
> > +  self->user_data);
> >  
> > -if (self->priv->error) {
> > -g_task_return_error(task, self->priv->error);
> > +if (self->error) {
> > +g_task_return_error(task, self->error);
> >  } else {
> >  g_task_return_boolean(task, TRUE);
> >  if (spice_util_get_debug()) {
> >  gint64 now = g_get_monotonic_time();
> > -gchar *basename = g_file_get_basename(self->priv->file);
> > -double seconds = (double) (now - self->priv->start_time) /
> > G_TIME_SPAN_SECOND;
> > -gchar *file_size_str = g_format_size(self->priv->file_size);
> > -gchar *transfer_speed_str = 
> > g_format_size(self->priv->file_size /
> > seconds);
> > +gchar *basename = g_file_get_basename(self->file);
> > +double seconds = (double) (now - self->start_time) /
> > G_TIME_SPAN_SECOND;
> > +gchar *file_size_str = g_format_size(self->file_size);
> > +gchar *transfer_speed_str = g_format_size(self->file_size /
> > seconds);
> >  
> > -g_warn_if_fail(self->priv->read_bytes == 
> > self->priv->file_size);
> > +g_warn_if_fail(self->read_bytes == self->file_size);
> >  SPICE_DEBUG("transferred file %s of %s size in %.1f seconds
> > (%s/s)",
> >  basename, file_size_str, seconds,
> > transfer_speed_str);
> >  
> > @@ -1875,9 +1866,9 @@ static void file_xfer_data_flushed_cb(GObject
> > *source_object,
> >  SpiceMainChannel *channel = (SpiceMainChannel *)source_object;
> >  GError *error = NULL;
> >  
> > -self->priv->pending = FALSE;
> > +self->pending = FALSE;
> >  file_xfer_flush_finish(channel, res, );
> > -if (error || self->priv->error) {
> > +if (error || self->error) {
> >  spice_file_transfer_task_completed(self, error);
> >  return;
> >  }
> > @@ -1886,19 +1877,19 @@ static void file_xfer_data_flushed_cb(GObject
> > *source_object,
> >  const GTimeSpan interval = 20 * G_TIME_SPAN_SECOND;
> >  gint64 now = 

Re: [Spice-devel] [PATCH spice-gtk 1/2] main: remove SpiceFileTransferTaskPrivate

2016-05-25 Thread Pavel Grunt
Of course it is correct, but I would wait with it after applying:
 https://lists.freedesktop.org/archives/spice-devel/2016-May/029359.html
or if Victor is ok with it?

Pavel

On Wed, 2016-05-25 at 17:33 +0200, Marc-André Lureau wrote:
> The struct is already private
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  src/channel-main.c | 227 +++-
> -
>  src/spice-file-transfer-task.h |   1 -
>  2 files changed, 107 insertions(+), 121 deletions(-)
> 
> diff --git a/src/channel-main.c b/src/channel-main.c
> index b91daa5..c9bc668 100644
> --- a/src/channel-main.c
> +++ b/src/channel-main.c
> @@ -81,30 +81,6 @@ struct _SpiceFileTransferTask
>  {
>  GObject parent;
>  
> -SpiceFileTransferTaskPrivate *priv;
> -};
> -
> -/**
> - * SpiceFileTransferTaskClass:
> - * @parent_class: Parent class.
> - *
> - * Class structure for #SpiceFileTransferTask.
> - */
> -struct _SpiceFileTransferTaskClass
> -{
> -GObjectClass parent_class;
> -};
> -
> -G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, G_TYPE_OBJECT)
> -
> -#define FILE_TRANSFER_TASK_PRIVATE(o) \
> -(G_TYPE_INSTANCE_GET_PRIVATE((o), SPICE_TYPE_FILE_TRANSFER_TASK,
> SpiceFileTransferTaskPrivate))
> -
> -#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
> -struct _SpiceFileTransferTaskPrivate
> -
> -/* private */
> -{
>  uint32_t   id;
>  gboolean   pending;
>  GFile  *file;
> @@ -124,6 +100,21 @@ struct _SpiceFileTransferTaskPrivate
>  GError *error;
>  };
>  
> +/**
> + * SpiceFileTransferTaskClass:
> + * @parent_class: Parent class.
> + *
> + * Class structure for #SpiceFileTransferTask.
> + */
> +struct _SpiceFileTransferTaskClass
> +{
> +GObjectClass parent_class;
> +};
> +
> +G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, G_TYPE_OBJECT)
> +
> +#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
> +
>  enum {
>  PROP_TASK_ID = 1,
>  PROP_TASK_CHANNEL,
> @@ -1837,23 +1828,23 @@ static void file_xfer_close_cb(GObject  *object,
>  
>  /* Notify to user that files have been transferred or something error
> happened. */
> -task = g_task_new(self->priv->channel,
> -  self->priv->cancellable,
> -  self->priv->callback,
> -  self->priv->user_data);
> +task = g_task_new(self->channel,
> +  self->cancellable,
> +  self->callback,
> +  self->user_data);
>  
> -if (self->priv->error) {
> -g_task_return_error(task, self->priv->error);
> +if (self->error) {
> +g_task_return_error(task, self->error);
>  } else {
>  g_task_return_boolean(task, TRUE);
>  if (spice_util_get_debug()) {
>  gint64 now = g_get_monotonic_time();
> -gchar *basename = g_file_get_basename(self->priv->file);
> -double seconds = (double) (now - self->priv->start_time) /
> G_TIME_SPAN_SECOND;
> -gchar *file_size_str = g_format_size(self->priv->file_size);
> -gchar *transfer_speed_str = g_format_size(self->priv->file_size /
> seconds);
> +gchar *basename = g_file_get_basename(self->file);
> +double seconds = (double) (now - self->start_time) /
> G_TIME_SPAN_SECOND;
> +gchar *file_size_str = g_format_size(self->file_size);
> +gchar *transfer_speed_str = g_format_size(self->file_size /
> seconds);
>  
> -g_warn_if_fail(self->priv->read_bytes == self->priv->file_size);
> +g_warn_if_fail(self->read_bytes == self->file_size);
>  SPICE_DEBUG("transferred file %s of %s size in %.1f seconds
> (%s/s)",
>  basename, file_size_str, seconds,
> transfer_speed_str);
>  
> @@ -1875,9 +1866,9 @@ static void file_xfer_data_flushed_cb(GObject
> *source_object,
>  SpiceMainChannel *channel = (SpiceMainChannel *)source_object;
>  GError *error = NULL;
>  
> -self->priv->pending = FALSE;
> +self->pending = FALSE;
>  file_xfer_flush_finish(channel, res, );
> -if (error || self->priv->error) {
> +if (error || self->error) {
>  spice_file_transfer_task_completed(self, error);
>  return;
>  }
> @@ -1886,19 +1877,19 @@ static void file_xfer_data_flushed_cb(GObject
> *source_object,
>  const GTimeSpan interval = 20 * G_TIME_SPAN_SECOND;
>  gint64 now = g_get_monotonic_time();
>  
> -if (interval < now - self->priv->last_update) {
> -gchar *basename = g_file_get_basename(self->priv->file);
> -self->priv->last_update = now;
> +if (interval < now - self->last_update) {
> +gchar *basename = g_file_get_basename(self->file);
> +self->last_update = now;
>  SPICE_DEBUG("transferred %.2f%% of the file 

[Spice-devel] [PATCH spice-gtk 1/2] main: remove SpiceFileTransferTaskPrivate

2016-05-25 Thread Marc-André Lureau
The struct is already private

Signed-off-by: Marc-André Lureau 
---
 src/channel-main.c | 227 +++--
 src/spice-file-transfer-task.h |   1 -
 2 files changed, 107 insertions(+), 121 deletions(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index b91daa5..c9bc668 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -81,30 +81,6 @@ struct _SpiceFileTransferTask
 {
 GObject parent;
 
-SpiceFileTransferTaskPrivate *priv;
-};
-
-/**
- * SpiceFileTransferTaskClass:
- * @parent_class: Parent class.
- *
- * Class structure for #SpiceFileTransferTask.
- */
-struct _SpiceFileTransferTaskClass
-{
-GObjectClass parent_class;
-};
-
-G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, G_TYPE_OBJECT)
-
-#define FILE_TRANSFER_TASK_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), SPICE_TYPE_FILE_TRANSFER_TASK, 
SpiceFileTransferTaskPrivate))
-
-#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
-struct _SpiceFileTransferTaskPrivate
-
-/* private */
-{
 uint32_t   id;
 gboolean   pending;
 GFile  *file;
@@ -124,6 +100,21 @@ struct _SpiceFileTransferTaskPrivate
 GError *error;
 };
 
+/**
+ * SpiceFileTransferTaskClass:
+ * @parent_class: Parent class.
+ *
+ * Class structure for #SpiceFileTransferTask.
+ */
+struct _SpiceFileTransferTaskClass
+{
+GObjectClass parent_class;
+};
+
+G_DEFINE_TYPE(SpiceFileTransferTask, spice_file_transfer_task, G_TYPE_OBJECT)
+
+#define FILE_XFER_CHUNK_SIZE (VD_AGENT_MAX_DATA_SIZE * 32)
+
 enum {
 PROP_TASK_ID = 1,
 PROP_TASK_CHANNEL,
@@ -1837,23 +1828,23 @@ static void file_xfer_close_cb(GObject  *object,
 
 /* Notify to user that files have been transferred or something error
happened. */
-task = g_task_new(self->priv->channel,
-  self->priv->cancellable,
-  self->priv->callback,
-  self->priv->user_data);
+task = g_task_new(self->channel,
+  self->cancellable,
+  self->callback,
+  self->user_data);
 
-if (self->priv->error) {
-g_task_return_error(task, self->priv->error);
+if (self->error) {
+g_task_return_error(task, self->error);
 } else {
 g_task_return_boolean(task, TRUE);
 if (spice_util_get_debug()) {
 gint64 now = g_get_monotonic_time();
-gchar *basename = g_file_get_basename(self->priv->file);
-double seconds = (double) (now - self->priv->start_time) / 
G_TIME_SPAN_SECOND;
-gchar *file_size_str = g_format_size(self->priv->file_size);
-gchar *transfer_speed_str = g_format_size(self->priv->file_size / 
seconds);
+gchar *basename = g_file_get_basename(self->file);
+double seconds = (double) (now - self->start_time) / 
G_TIME_SPAN_SECOND;
+gchar *file_size_str = g_format_size(self->file_size);
+gchar *transfer_speed_str = g_format_size(self->file_size / 
seconds);
 
-g_warn_if_fail(self->priv->read_bytes == self->priv->file_size);
+g_warn_if_fail(self->read_bytes == self->file_size);
 SPICE_DEBUG("transferred file %s of %s size in %.1f seconds 
(%s/s)",
 basename, file_size_str, seconds, transfer_speed_str);
 
@@ -1875,9 +1866,9 @@ static void file_xfer_data_flushed_cb(GObject 
*source_object,
 SpiceMainChannel *channel = (SpiceMainChannel *)source_object;
 GError *error = NULL;
 
-self->priv->pending = FALSE;
+self->pending = FALSE;
 file_xfer_flush_finish(channel, res, );
-if (error || self->priv->error) {
+if (error || self->error) {
 spice_file_transfer_task_completed(self, error);
 return;
 }
@@ -1886,19 +1877,19 @@ static void file_xfer_data_flushed_cb(GObject 
*source_object,
 const GTimeSpan interval = 20 * G_TIME_SPAN_SECOND;
 gint64 now = g_get_monotonic_time();
 
-if (interval < now - self->priv->last_update) {
-gchar *basename = g_file_get_basename(self->priv->file);
-self->priv->last_update = now;
+if (interval < now - self->last_update) {
+gchar *basename = g_file_get_basename(self->file);
+self->last_update = now;
 SPICE_DEBUG("transferred %.2f%% of the file %s",
-100.0 * self->priv->read_bytes / 
self->priv->file_size, basename);
+100.0 * self->read_bytes / self->file_size, basename);
 g_free(basename);
 }
 }
 
-if (self->priv->progress_callback) {
+if (self->progress_callback) {
 goffset read = 0;
 goffset total = 0;
-SpiceMainChannel *main_channel = self->priv->channel;
+SpiceMainChannel *main_channel = self->channel;