static void
ft_handler_create_channel_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyFTHandler *handler = user_data;
  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
  GError *error = NULL;
  TpChannel *channel = NULL;

  DEBUG ("Dispatcher create channel CB");

  channel = tp_account_channel_request_create_and_handle_channel_finish (
        TP_ACCOUNT_CHANNEL_REQUEST (source), result, NULL, &error);

  if (channel == NULL)
    DEBUG ("Failed to request FT channel: %s", error->message);
  else
    g_cancellable_set_error_if_cancelled (priv->cancellable, &error);

  if (error != NULL)
    {
      emit_error_signal (handler, error);

      g_error_free (error);
      goto out;
    }

  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);

out:
  tp_clear_object (&channel);
}
static void
handle_channels_cb (TpSimpleHandler *handler,
    TpAccount *account,
    TpConnection *connection,
    GList *channels,
    GList *requests_satisfied,
    gint64 user_action_time,
    TpHandleChannelsContext *context,
    gpointer user_data)
{
  EmpathyFTFactory *self = user_data;
  GList *l;

  for (l = channels; l != NULL; l = g_list_next (l))
    {
      TpChannel *channel = l->data;
      EmpathyTpFile *tp_file;

      if (tp_proxy_get_invalidated (channel) != NULL)
        continue;

      if (tp_channel_get_channel_type_id (channel) !=
          TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
        continue;

      tp_file = empathy_tp_file_new (channel);

      /* We handle only incoming FT */
      empathy_ft_handler_new_incoming (tp_file, ft_handler_incoming_ready_cb,
          self);

      g_object_unref (tp_file);
    }


  tp_handle_channels_context_accept (context);
}