[Spice-devel] [spice-gtk][PATCH v4] Added INFO messages about a file transfer

Christophe Fergeau cfergeau at redhat.com
Mon Oct 6 07:45:32 PDT 2014


On Mon, Oct 06, 2014 at 02:06:29PM +0200, Fabiano Fidêncio wrote:
> On Thu, Sep 18, 2014 at 4:31 PM, Pavel Grunt <pgrunt at redhat.com> wrote:
> 
> > When a file transfer starts / finishes an information message is printed
> > (in INFO log level).
> > Also INFO messages about the transfer progress are periodically printed.
> > ---
> > changes since v4:
> >   - logging is enabled when transferring more files simultaneously
> >
> >  gtk/channel-main.c | 42 +++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 41 insertions(+), 1 deletion(-)
> >
> > diff --git a/gtk/channel-main.c b/gtk/channel-main.c
> > index 1ad090f..1e0f940 100644
> > --- a/gtk/channel-main.c
> > +++ b/gtk/channel-main.c
> > @@ -70,6 +70,8 @@ typedef struct SpiceFileXferTask {
> >      char                           buffer[FILE_XFER_CHUNK_SIZE];
> >      uint64_t                       read_bytes;
> >      uint64_t                       file_size;
> > +    GDateTime                      *start_time;
> > +    GDateTime                      *last_update;
> >      GError                         *error;
> >  } SpiceFileXferTask;
> >
> > @@ -1529,15 +1531,31 @@ static void
> > main_handle_agent_disconnected(SpiceChannel *channel, SpiceMsgIn *in
> >  static void file_xfer_task_free(SpiceFileXferTask *task)
> >  {
> >      SpiceMainChannelPrivate *c;
> > -
> > +    gchar *basename;
> > +    double seconds;
> > +    GDateTime *now;
> >      g_return_if_fail(task != NULL);
> >
> > +    if (task->read_bytes == task->file_size) {
> > +        basename = g_file_get_basename(task->file);
> > +        now = g_date_time_new_now_local();
> > +        seconds = (double) g_date_time_difference(now, task->start_time)
> > / G_TIME_SPAN_SECOND;
> > +        g_date_time_unref(now);
> > +        g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,
> > +              "transferred file %s of %.2f kB size in %.2f seconds (%.2f
> > MB/s)",
> > +              basename, task->file_size / 1000.0, seconds,
> > +              (double) task->file_size / 1048576 / seconds);
> >
> 
> What does "1048576" mean? If it's not something we already have defined in
> glib, I'd go for a local define and a comment about the "1048576" value.

I'd use g_format_size_for_display () / g_format_size () here. Most
likely g_format_size() to avoid deprecation warnings with a fallback
implementation using g_format_size_for_display () in virt-glib-compat.c

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141006/48685aa1/attachment.sig>


More information about the Spice-devel mailing list