From 0c52aee9583e68377b3c5da4d4f671761ae33e10 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 1 Jul 2010 17:05:32 +0200 Subject: stop using Empathy's internal dispatcher to request FT channel --- libempathy/empathy-ft-handler.c | 49 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'libempathy/empathy-ft-handler.c') diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c index 9fd993115..13568cef9 100644 --- a/libempathy/empathy-ft-handler.c +++ b/libempathy/empathy-ft-handler.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -711,55 +712,61 @@ ft_transfer_progress_callback (EmpathyTpFile *tp_file, } static void -ft_handler_create_channel_cb (EmpathyDispatchOperation *operation, - const GError *error, +ft_handler_create_channel_cb (GObject *source, + GAsyncResult *result, gpointer user_data) { EmpathyFTHandler *handler = user_data; EmpathyFTHandlerPriv *priv = GET_PRIV (handler); - GError *my_error = (GError *) error; + GError *error = NULL; + TpChannel *channel = NULL; DEBUG ("Dispatcher create channel CB"); - if (my_error == NULL) - { - g_cancellable_set_error_if_cancelled (priv->cancellable, &my_error); - } + channel = tp_account_channel_request_create_and_handle_channel_finish ( + TP_ACCOUNT_CHANNEL_REQUEST (source), result, NULL, &error); - if (my_error != NULL) - { - emit_error_signal (handler, my_error); + if (channel == NULL) + DEBUG ("Failed to request FT channel: %s", error->message); + else + g_cancellable_set_error_if_cancelled (priv->cancellable, &error); - if (my_error != error) - g_clear_error (&my_error); + if (error != NULL) + { + emit_error_signal (handler, error); - return; + g_error_free (error); + goto out; } - priv->tpfile = g_object_ref - (empathy_dispatch_operation_get_channel_wrapper (operation)); + priv->tpfile = empathy_tp_file_new (channel); 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); +out: + tp_clear_object (&channel); } static void ft_handler_push_to_dispatcher (EmpathyFTHandler *handler) { - TpConnection *connection; + TpAccount *account; EmpathyFTHandlerPriv *priv = GET_PRIV (handler); + TpAccountChannelRequest *req; DEBUG ("Pushing request to the dispatcher"); - connection = empathy_contact_get_connection (priv->contact); + account = empathy_contact_get_account (priv->contact); + + req = tp_account_channel_request_new (account, priv->request, + EMPATHY_DISPATCHER_NON_USER_ACTION); - /* I want to own a reference to the request, and destroy it later */ - empathy_dispatcher_create_channel (priv->dispatcher, connection, - g_hash_table_ref (priv->request), EMPATHY_DISPATCHER_NON_USER_ACTION, + tp_account_channel_request_create_and_handle_channel_async (req, NULL, ft_handler_create_channel_cb, handler); + + g_object_unref (req); } static void -- cgit v1.2.3