[empathy: 41/148] Only close the FT operation after the state change



commit 7d5485549becfc095556d282f6622ce2b16caef0
Author: Cosimo Cecchi <cosimo cecchi collabora co uk>
Date:   Mon May 4 01:26:15 2009 +0200

    Only close the FT operation after the state change
    
    Close the FT operation only after the "completed" state change has been
    emitted, so that we can guarantee there will be no other progress
    signals emitted after TRANSFER_DONE.
    Also, add some other debug calls.
---
 libempathy/empathy-ft-handler.c |    2 ++
 libempathy/empathy-tp-file.c    |   13 +++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index c6babb8..f20e628 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -350,6 +350,8 @@ ft_transfer_operation_callback (EmpathyTpFile *tp_file,
   EmpathyFTHandler *handler = user_data;
   EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
 
+  DEBUG ("Transfer operation callback, error %p", error);
+
   if (error != NULL)
     {
       priv->is_cancelled = TRUE;
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index 0b12d02..7b0ace6 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -162,6 +162,8 @@ ft_operation_close_clean (EmpathyTpFile *tp_file)
 {
   EmpathyTpFilePriv *priv = GET_PRIV (tp_file);
 
+  DEBUG ("Splice close clean");
+
   if (priv->op_callback)
     priv->op_callback (tp_file, NULL, priv->op_user_data);
 }
@@ -172,6 +174,8 @@ ft_operation_close_with_error (EmpathyTpFile *tp_file,
 {
   EmpathyTpFilePriv *priv = GET_PRIV (tp_file);
 
+  DEBUG ("Splice close with error %s", error->message);
+
   if (priv->op_callback)
     priv->op_callback (tp_file, error, priv->op_user_data);
 }
@@ -194,8 +198,6 @@ splice_stream_ready_cb (GObject *source,
       g_clear_error (&error);
       return;
     }
-
-  ft_operation_close_clean (tp_file);
 }
 
 static void
@@ -301,6 +303,9 @@ tp_file_state_changed_cb (TpChannel *proxy,
       priv->in_stream ? "present" : "not present",
       priv->out_stream ? "present" : "not present");
 
+  priv->state = state;
+  priv->state_change_reason = reason;
+
   /* If the channel is open AND we have the socket path, we can start the
    * transfer. The socket path could be NULL if we are not doing the actual
    * data transfer but are just an observer for the channel.
@@ -309,8 +314,8 @@ tp_file_state_changed_cb (TpChannel *proxy,
       priv->unix_socket_path != NULL)
     tp_file_start_transfer (EMPATHY_TP_FILE (weak_object));
 
-  priv->state = state;
-  priv->state_change_reason = reason;
+  if (state == EMP_FILE_TRANSFER_STATE_COMPLETED)
+    ft_operation_close_clean (EMPATHY_TP_FILE (weak_object));
 
   g_object_notify (weak_object, "state");
 }



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