]> git.0d.be Git - empathy.git/commitdiff
Modify EmpathyFTHandler to adapt to the changes in EmpathyTpFile API.
authorCosimo Cecchi <cosimoc@gnome.org>
Tue, 17 Feb 2009 18:48:01 +0000 (19:48 +0100)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 1 Jun 2009 15:46:05 +0000 (17:46 +0200)
libempathy/empathy-ft-handler.c
libempathy/empathy-ft-handler.h
libempathy/empathy-tp-file.c

index 00bcf3087dc931f2a0070373e2e9db4042705d9b..85d70dbd283856a6efc51dc6ef322b4cea46ec27 100644 (file)
@@ -248,9 +248,9 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
   signals[TRANSFER_PROGRESS] =
     g_signal_new ("transfer-progress", G_TYPE_FROM_CLASS (klass),
         G_SIGNAL_RUN_LAST, 0, NULL, NULL,
-        _empathy_marshal_VOID__OBJECT_UINT64_UINT64,
+        _empathy_marshal_VOID__UINT64_UINT64,
         G_TYPE_NONE,
-        2, EMPATHY_TYPE_TP_FILE, G_TYPE_UINT64, G_TYPE_UINT64);
+        2, G_TYPE_UINT64, G_TYPE_UINT64);
 
   signals[HASHING_STARTED] =
     g_signal_new ("hashing-started", G_TYPE_FROM_CLASS (klass),
@@ -318,13 +318,42 @@ hash_data_free (HashingData *data)
   g_slice_free (HashingData, data);
 }
 
+static void
+ft_transfer_operation_callback (EmpathyTpFile *tp_file,
+                                const GError *error,
+                                gpointer user_data)
+{
+  EmpathyFTHandler *handler = user_data;
+
+  if (error != NULL)
+    g_signal_emit (handler, signals[TRANSFER_ERROR], 0, error);
+  else
+    g_signal_emit (handler, signals[TRANSFER_DONE], 0);
+}
+
+static void
+ft_transfer_progress_callback (EmpathyTpFile *tp_file,
+                               guint64 transferred_bytes,
+                               guint64 total_bytes,
+                               gpointer user_data)
+{
+  EmpathyFTHandler *handler = user_data;
+  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
+
+  if (priv->transferred_bytes != transferred_bytes)
+    {
+      priv->transferred_bytes = transferred_bytes;
+      g_signal_emit (handler, signals[TRANSFER_PROGRESS], 0,
+          transferred_bytes, total_bytes);
+    }
+}
+
 static void
 ft_handler_create_channel_cb (EmpathyDispatchOperation *operation,
                               const GError *error,
                               gpointer user_data)
 {
   EmpathyFTHandler *handler = user_data;
-  GError *myerr = NULL;
   EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
 
   DEBUG ("FT: dispatcher create channel CB");
@@ -337,7 +366,10 @@ ft_handler_create_channel_cb (EmpathyDispatchOperation *operation,
 
   priv->tpfile = g_object_ref
       (empathy_dispatch_operation_get_channel_wrapper (operation));
-  empathy_tp_file_offer (priv->tpfile, priv->gfile, &myerr);
+  empathy_tp_file_offer (priv->tpfile, priv->gfile, priv->cancellable,
+      ft_transfer_progress_callback, handler,
+      ft_transfer_operation_callback, handler);
+
   empathy_dispatch_operation_claim (operation);
 }
 
@@ -732,7 +764,7 @@ channel_get_all_properties_cb (TpProxy *proxy,
 
   if (error != NULL)
     {
-      cb_data->callback (NULL, error, cb_data->user_data);
+      cb_data->callback (NULL, (GError *) error, cb_data->user_data);
       g_object_unref (handler);
       return;
     }
@@ -835,7 +867,6 @@ empathy_ft_handler_start_transfer (EmpathyFTHandler *handler,
                                    GCancellable *cancellable)
 {
   EmpathyFTHandlerPriv *priv;
-  GError *error = NULL;
 
   g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
 
@@ -849,6 +880,8 @@ empathy_ft_handler_start_transfer (EmpathyFTHandler *handler,
   else
     {
       /* TODO: add support for resume. */
-      empathy_tp_file_accept (priv->tpfile, 0, priv->gfile, &error);
+      empathy_tp_file_accept (priv->tpfile, 0, priv->gfile, priv->cancellable,
+          ft_transfer_progress_callback, handler,
+          ft_transfer_operation_callback, handler);
     }
 }
index 41e33d76c969e573a7eb0fc6a8f55eebb56a48a0..ee32ffd31e1ee78c5d02e6e8bc15a2e03cb7d1b4 100644 (file)
@@ -60,8 +60,9 @@ typedef void (* EmpathyFTHandlerReadyCallback) (EmpathyFTHandler *handler,
 GType empathy_ft_handler_get_type (void);
 
 /* public methods */
-EmpathyFTHandler * empathy_ft_handler_new_outgoing (EmpathyContact *contact,
-    GFile *source);
+void empathy_ft_handler_new_outgoing (EmpathyContact *contact,
+    GFile *source, EmpathyFTHandlerReadyCallback callback,
+    gpointer user_data);
 void empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file,
     GFile *destination, EmpathyFTHandlerReadyCallback callback,
     gpointer user_data);
index 83707431a38338dc50be8ad9d98aba44471695d8..6f794b287e44b17a6c26c7545de658056b009c74 100644 (file)
@@ -409,10 +409,8 @@ tp_file_transferred_bytes_changed_cb (TpProxy *proxy,
 
   /* notify clients */
   if (priv->progress_callback)
-    {
-      priv->progress_callback (EMPATHY_TP_FILE (weak_object),
-          priv->transferred_bytes, priv->size, priv->progress_user_data);
-    }
+    priv->progress_callback (EMPATHY_TP_FILE (weak_object),
+        priv->transferred_bytes, priv->size, priv->progress_user_data);
 }
 
 static void