]> git.0d.be Git - empathy.git/commitdiff
Set use_hash according to what the CM returns
authorCosimo Cecchi <cosimoc@gnome.org>
Mon, 18 May 2009 12:55:01 +0000 (14:55 +0200)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 1 Jun 2009 15:53:20 +0000 (17:53 +0200)
Set use_hash according to what the CM returns and not what the user
would like it to be, so that clients won't be confused about whether
they should connect to "hashing-started" after "transfer-done".

libempathy/empathy-ft-handler.c
src/empathy-ft-manager.c

index e2172bcd54873ce3565684d5c466b0b46103eb77..beb57b1ed139f6b72280153e05564629aa31f972 100644 (file)
@@ -1277,14 +1277,25 @@ empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler,
     GFile *destination,
     gboolean use_hash)
 {
+  EmpathyFTHandlerPriv *priv;
+
   DEBUG ("Set incoming destination, use hash %s",
          use_hash ? "True" : "False");
 
   g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
   g_return_if_fail (G_IS_FILE (destination));
 
+  priv = GET_PRIV (handler);
+
   g_object_set (handler, "gfile", destination,
       "use-hash", use_hash, NULL);
+
+  /* check if hash is really supported. if it isn't, set use_hash to FALSE
+   * anyway, so that clients won't be expecting us to checksum.
+   */
+  if (EMP_STR_EMPTY (priv->content_hash) ||
+      priv->content_hash_type == TP_FILE_HASH_TYPE_NONE)
+    priv->use_hash = FALSE;
 }
 
 /**
index 858b2120831b09f254240594b7d4793427d58457..7b3e88a243ceaeb5b28f498f38e5b20b8f4880de 100644 (file)
@@ -491,16 +491,20 @@ ft_handler_transfer_done_cb (EmpathyFTHandler *handler,
                              EmpathyTpFile *tp_file,
                              EmpathyFTManager *manager)
 {
-  DEBUG ("Transfer done");
-
   if (empathy_ft_handler_is_incoming (handler) &&
       empathy_ft_handler_get_use_hash (handler))
     {
-      /* connect to the signal */
+      DEBUG ("Transfer done, waiting for hashing-started");
+
+      /* connect to the signal and return early */
       g_signal_connect (handler, "hashing-started",
           G_CALLBACK (ft_handler_hashing_started_cb), manager);
+
+      return;
     }
 
+  DEBUG ("Transfer done, no hashing");
+
   do_real_transfer_done (manager, handler);
 }