static void
ft_transfer_progress_callback (EmpathyTpFile *tp_file,
    guint64 transferred_bytes,
    gpointer user_data)
{
  EmpathyFTHandler *handler = user_data;
  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);

  if (empathy_ft_handler_is_cancelled (handler))
    return;

  if (transferred_bytes == 0)
    {
      priv->last_update_time = empathy_time_get_current ();
      g_signal_emit (handler, signals[TRANSFER_STARTED], 0, tp_file);
    }

  if (priv->transferred_bytes != transferred_bytes)
    {
      update_remaining_time_and_speed (handler, transferred_bytes);

      g_signal_emit (handler, signals[TRANSFER_PROGRESS], 0,
          transferred_bytes, priv->total_bytes, priv->remaining_time,
          priv->speed);
    }
}
Esempio n. 2
0
static void
ft_transfer_transferred_bytes_cb (TpFileTransferChannel *channel,
    GParamSpec *pspec,
    EmpathyFTHandler *handler)
{
  EmpathyFTHandlerPriv *priv = handler->priv;
  guint64 bytes;

  (void)pspec;      /* suppress unused-parameter warning */

  if (empathy_ft_handler_is_cancelled (handler))
    return;

  bytes = tp_file_transfer_channel_get_transferred_bytes (channel);

  if (priv->transferred_bytes == 0)
    {
      priv->last_update_time = time_get_current ();
      g_signal_emit (handler, signals[TRANSFER_STARTED], 0, channel);
    }

  if (priv->transferred_bytes != bytes)
    {
      update_remaining_time_and_speed (handler, bytes);

      g_signal_emit (handler, signals[TRANSFER_PROGRESS], 0,
          bytes, priv->total_bytes, priv->remaining_time,
          priv->speed);
    }
}