Exemplo n.º 1
0
/**
 * empathy_ft_handler_start_transfer:
 * @handler: an #EmpathyFTHandler
 *
 * Starts the transfer machinery. After this call, the transfer and hashing
 * signals will be emitted by the handler.
 */
void
empathy_ft_handler_start_transfer (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));

  priv = handler->priv;

  if (priv->channel == NULL)
    {
      ft_handler_complete_request (handler);
    }
  else
    {
      /* TODO: add support for resume. */
      tp_file_transfer_channel_accept_file_async (priv->channel,
          priv->gfile, 0, ft_transfer_accept_cb, handler);

      tp_g_signal_connect_object (priv->channel, "notify::state",
          G_CALLBACK (ft_transfer_state_cb), handler, 0);
      tp_g_signal_connect_object (priv->channel, "notify::transferred-bytes",
          G_CALLBACK (ft_transfer_transferred_bytes_cb), handler, 0);
    }
}
/**
 * empathy_ft_handler_get_contact:
 * @handler: an #EmpathyFTHandler
 *
 * Returns the remote #EmpathyContact at the other side of the transfer.
 *
 * Return value: the remote #EmpathyContact for @handler
 */
EmpathyContact *
empathy_ft_handler_get_contact (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL);

  priv = GET_PRIV (handler);

  return priv->contact;
}
/**
 * empathy_ft_handler_get_gfile:
 * @handler: an #EmpathyFTHandler
 *
 * Returns the #GFile where the transfer is being read/saved.
 *
 * Return value: the #GFile where the transfer is being read/saved
 */
GFile *
empathy_ft_handler_get_gfile (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL);

  priv = GET_PRIV (handler);

  return priv->gfile;
}
/**
 * empathy_ft_handler_get_total_bytes:
 * @handler: an #EmpathyFTHandler
 *
 * Returns the total size of the file being transferred by the handler.
 *
 * Return value: a number of bytes indicating the total size of the file being
 * transferred by the handler.
 */
guint64
empathy_ft_handler_get_total_bytes (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), 0);

  priv = GET_PRIV (handler);

  return priv->total_bytes;
}
/**
 * empathy_ft_handler_get_use_hash:
 * @handler: an #EmpathyFTHandler
 *
 * Returns whether @handler has checksumming enabled. This can depend on
 * the CM and the remote contact capabilities.
 *
 * Return value: %TRUE if the handler has checksumming enabled,
 * %FALSE otherwise.
 */
gboolean
empathy_ft_handler_get_use_hash (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), FALSE);

  priv = GET_PRIV (handler);

  return priv->use_hash;
}
Exemplo n.º 6
0
const char *
empathy_ft_handler_get_description (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL);

  priv = handler->priv;

  return priv->description;
}
Exemplo n.º 7
0
/**
 * empathy_ft_handler_get_transferred_bytes:
 * @handler: an #EmpathyFTHandler
 *
 * Returns the number of bytes already transferred by the handler.
 *
 * Return value: the number of bytes already transferred by the handler.
 */
guint64
empathy_ft_handler_get_transferred_bytes (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), 0);

  priv = handler->priv;

  return priv->transferred_bytes;
}
Exemplo n.º 8
0
/**
 * empathy_ft_handler_get_filename:
 * @handler: an #EmpathyFTHandler
 *
 * Returns the name of the file being transferred.
 *
 * Return value: the name of the file being transferred
 */
const char *
empathy_ft_handler_get_filename (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL);

  priv = handler->priv;

  return priv->filename;
}
/**
 * empathy_ft_handler_is_completed:
 * @handler: an #EmpathyFTHandler
 *
 * Returns whether the transfer for @handler has been completed succesfully.
 *
 * Return value: %TRUE if the handler has been transferred correctly, %FALSE
 * otherwise
 */
gboolean
empathy_ft_handler_is_completed (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), FALSE);

  priv = GET_PRIV (handler);

  return priv->is_completed;
}
Exemplo n.º 10
0
/**
 * empathy_ft_handler_get_content_type:
 * @handler: an #EmpathyFTHandler
 *
 * Returns the content type of the file being transferred.
 *
 * Return value: the content type of the file being transferred
 */
const char *
empathy_ft_handler_get_content_type (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), NULL);

  priv = GET_PRIV (handler);

  return priv->content_type;
}
Exemplo n.º 11
0
/**
 * empathy_ft_handler_is_cancelled:
 * @handler: an #EmpathyFTHandler
 *
 * Returns whether the transfer for @handler has been cancelled or has stopped
 * due to an error.
 *
 * Return value: %TRUE if the transfer for @handler has been cancelled
 * or has stopped due to an error, %FALSE otherwise.
 */
gboolean
empathy_ft_handler_is_cancelled (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), FALSE);

  priv = GET_PRIV (handler);

  return g_cancellable_is_cancelled (priv->cancellable);
}
Exemplo n.º 12
0
/**
 * empathy_ft_handler_is_incoming:
 * @handler: an #EmpathyFTHandler
 *
 * Returns whether @handler is incoming or outgoing.
 *
 * Return value: %TRUE if the handler is incoming, %FALSE otherwise.
 */
gboolean
empathy_ft_handler_is_incoming (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), FALSE);

  priv = handler->priv;

  if (priv->channel == NULL)
    return FALSE;

  return !tp_channel_get_requested ((TpChannel *) priv->channel);
}
/**
 * empathy_ft_factory_set_destination_for_incoming_handler:
 * @factory: an #EmpathyFTFactory
 * @handler: the #EmpathyFTHandler to set the destination of
 * @destination: the #GFile destination of the transfer
 *
 * Sets @destination as destination file for the transfer. After the call of
 * this method, the ::new-ft-handler will be emitted for the incoming handler.
 */
void
empathy_ft_factory_set_destination_for_incoming_handler (
    EmpathyFTFactory *factory,
    EmpathyFTHandler *handler,
    GFile *destination)
{
  g_return_if_fail (EMPATHY_IS_FT_FACTORY (factory));
  g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
  g_return_if_fail (G_IS_FILE (destination));

  empathy_ft_handler_incoming_set_destination (handler, destination);

  g_signal_emit (factory, signals[NEW_FT_HANDLER], 0, handler, NULL);
}
Exemplo n.º 14
0
/**
 * empathy_ft_handler_is_incoming:
 * @handler: an #EmpathyFTHandler
 *
 * Returns whether @handler is incoming or outgoing.
 *
 * Return value: %TRUE if the handler is incoming, %FALSE otherwise.
 */
gboolean
empathy_ft_handler_is_incoming (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_FT_HANDLER (handler), FALSE);

  priv = GET_PRIV (handler);

  if (priv->tpfile == NULL)
    return FALSE;

  return empathy_tp_file_is_incoming (priv->tpfile);
}
Exemplo n.º 15
0
void
empathy_ft_manager_add_handler (EmpathyFTHandler *handler)
{
  EmpathyFTManager *manager;
  EmpathyFTManagerPriv *priv;

  DEBUG ("Adding handler");

  g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));

  manager = g_object_new (EMPATHY_TYPE_FT_MANAGER, NULL);
  priv = GET_PRIV (manager);

  ft_manager_add_handler_to_list (manager, handler, NULL);
  gtk_window_present (GTK_WINDOW (priv->window));
}
Exemplo n.º 16
0
void
empathy_ft_manager_display_error (EmpathyFTHandler *handler,
                                  const GError *error)
{
  EmpathyFTManager *manager;
  EmpathyFTManagerPriv *priv;

  g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
  g_return_if_fail (error != NULL);

  manager = g_object_new (EMPATHY_TYPE_FT_MANAGER, NULL);
  priv = GET_PRIV (manager);

  ft_manager_add_handler_to_list (manager, handler, error);
  gtk_window_present (GTK_WINDOW (priv->window));
}
Exemplo n.º 17
0
/**
 * empathy_ft_handler_cancel_transfer:
 * @handler: an #EmpathyFTHandler
 *
 * Cancels an ongoing handler operation. Note that this doesn't destroy
 * the object, which will keep all the properties, altough it won't be able
 * to do any more I/O.
 */
void
empathy_ft_handler_cancel_transfer (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));

  priv = GET_PRIV (handler);

  /* if we don't have an EmpathyTpFile, we are hashing, so
   * we can just cancel the GCancellable to stop it.
   */
  if (priv->tpfile == NULL)
    g_cancellable_cancel (priv->cancellable);
  else
    empathy_tp_file_cancel (priv->tpfile);
}
Exemplo n.º 18
0
/**
 * empathy_ft_handler_cancel_transfer:
 * @handler: an #EmpathyFTHandler
 *
 * Cancels an ongoing handler operation. Note that this doesn't destroy
 * the object, which will keep all the properties, altough it won't be able
 * to do any more I/O.
 */
void
empathy_ft_handler_cancel_transfer (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));

  priv = handler->priv;

  /* if we don't have a channel, we are hashing, so
   * we can just cancel the GCancellable to stop it.
   */
  if (priv->channel == NULL)
    g_cancellable_cancel (priv->cancellable);
  else
    tp_channel_close_async (TP_CHANNEL (priv->channel), NULL, NULL);
}
Exemplo n.º 19
0
/**
 * empathy_ft_handler_start_transfer:
 * @handler: an #EmpathyFTHandler
 *
 * Starts the transfer machinery. After this call, the transfer and hashing
 * signals will be emitted by the handler.
 */
void
empathy_ft_handler_start_transfer (EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv;

  g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));

  priv = GET_PRIV (handler);

  if (priv->tpfile == NULL)
    {
      ft_handler_complete_request (handler);
    }
  else
    {
      /* TODO: add support for resume. */
      empathy_tp_file_accept (priv->tpfile, 0, priv->gfile, priv->cancellable,
          ft_transfer_progress_callback, handler,
          ft_transfer_operation_callback, handler);
    }
}
Exemplo n.º 20
0
/**
 * empathy_ft_handler_incoming_set_destination:
 * @handler: an #EmpathyFTHandler
 * @destination: the #GFile where the transfer should be saved
 *
 * Sets the destination of the incoming handler to be @destination.
 * Note that calling this method is mandatory before starting the transfer
 * for incoming handlers.
 */
void
empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler,
    GFile *destination)
{
  EmpathyFTHandlerPriv *priv;

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

  /* check if hash is 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;
  else
    priv->use_hash = TRUE;
}