aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2009-02-18 02:48:01 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-06-01 23:46:05 +0800
commita5440333ee18a3174acc2437e2ba1e30365b1bca (patch)
treeca3106c11551fa5c0dd6ba9ecec73b544fe347ff /libempathy
parent5f52c3e662e717f2246f505eb590c32caca0883d (diff)
downloadgsoc2013-empathy-a5440333ee18a3174acc2437e2ba1e30365b1bca.tar
gsoc2013-empathy-a5440333ee18a3174acc2437e2ba1e30365b1bca.tar.gz
gsoc2013-empathy-a5440333ee18a3174acc2437e2ba1e30365b1bca.tar.bz2
gsoc2013-empathy-a5440333ee18a3174acc2437e2ba1e30365b1bca.tar.lz
gsoc2013-empathy-a5440333ee18a3174acc2437e2ba1e30365b1bca.tar.xz
gsoc2013-empathy-a5440333ee18a3174acc2437e2ba1e30365b1bca.tar.zst
gsoc2013-empathy-a5440333ee18a3174acc2437e2ba1e30365b1bca.zip
Modify EmpathyFTHandler to adapt to the changes in EmpathyTpFile API.
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-ft-handler.c47
-rw-r--r--libempathy/empathy-ft-handler.h5
-rw-r--r--libempathy/empathy-tp-file.c6
3 files changed, 45 insertions, 13 deletions
diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index 00bcf3087..85d70dbd2 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -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),
@@ -319,12 +319,41 @@ hash_data_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);
}
}
diff --git a/libempathy/empathy-ft-handler.h b/libempathy/empathy-ft-handler.h
index 41e33d76c..ee32ffd31 100644
--- a/libempathy/empathy-ft-handler.h
+++ b/libempathy/empathy-ft-handler.h
@@ -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);
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index 83707431a..6f794b287 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -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