[empathy: 48/148] Properly emit the TRANSFER_STARTED signal



commit 34ca5111a0a540b4b756f02592686668e80e538d
Author: Cosimo Cecchi <cosimo cecchi collabora co uk>
Date:   Mon May 4 03:05:24 2009 +0200

    Properly emit the TRANSFER_STARTED signal
    
    Emit the TRANSFER_STARTED signal when actually starting the transfer
    (after the DBus invocation callback).
---
 libempathy/empathy-ft-handler.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index d7a65aa..ad497de 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -192,6 +192,8 @@ do_finalize (GObject *object)
 {
   EmpathyFTHandlerPriv *priv = GET_PRIV (object);
 
+  DEBUG ("%p", object);
+
   g_free (priv->content_type);
   priv->content_type = NULL;
 
@@ -371,6 +373,8 @@ ft_transfer_operation_callback (EmpathyTpFile *tp_file,
     {
       priv->is_completed = TRUE;
       g_signal_emit (handler, signals[TRANSFER_DONE], 0, tp_file);
+
+      empathy_tp_file_close (tp_file);
     }
 }
 
@@ -382,6 +386,11 @@ ft_transfer_progress_callback (EmpathyTpFile *tp_file,
   EmpathyFTHandler *handler = user_data;
   EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
 
+  if (transferred_bytes == 0) {
+      g_signal_emit (handler, signals[TRANSFER_STARTED], 0, tp_file);
+  }
+    
+
   if (priv->transferred_bytes != transferred_bytes)
     {
       priv->transferred_bytes = transferred_bytes;
@@ -419,8 +428,6 @@ ft_handler_create_channel_cb (EmpathyDispatchOperation *operation,
   priv->tpfile = g_object_ref
       (empathy_dispatch_operation_get_channel_wrapper (operation));
 
-  g_signal_emit (handler, signals[TRANSFER_STARTED], 0, priv->tpfile);
-
   empathy_tp_file_offer (priv->tpfile, priv->gfile, priv->cancellable,
       ft_transfer_progress_callback, handler,
       ft_transfer_operation_callback, handler);
@@ -574,7 +581,6 @@ hash_job_async_close_stream_cb (GObject *source,
       TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHash", value);
 
 cleanup:
-  hash_data_free (hash_data);
 
   if (error != NULL)
     {
@@ -587,6 +593,8 @@ cleanup:
       /* the request is complete now, push it to the dispatcher */
       ft_handler_push_to_dispatcher (handler);
     }
+
+  hash_data_free (hash_data);
 }
 
 static void
@@ -928,11 +936,6 @@ empathy_ft_handler_start_transfer (EmpathyFTHandler *handler)
     }
   else
     {
-      /* emit the start signal now, so that we can catch errors in the
-       * op callback.
-       */
-      g_signal_emit (handler, signals[TRANSFER_STARTED], 0, priv->tpfile);
-
       /* TODO: add support for resume. */
       empathy_tp_file_accept (priv->tpfile, 0, priv->gfile, priv->cancellable,
           ft_transfer_progress_callback, handler,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]