예제 #1
0
static void tgprpl_xfer_send_on_finished (struct tgl_state *TLS, void *_data, int success, struct tgl_message *M) {
  debug ("tgprpl_xfer_on_finished()");
  struct tgp_xfer_send_data *data = _data;

  if (success) {
    if (! purple_xfer_is_canceled (data->xfer)) {
      debug ("purple_xfer_set_completed");
      purple_xfer_set_bytes_sent (data->xfer, purple_xfer_get_size (data->xfer));
      purple_xfer_set_completed (data->xfer, TRUE);
      purple_xfer_end (data->xfer);
    }
    write_secret_chat_file (TLS);
  } else {
    tgp_notify_on_error_gw (TLS, NULL, success);
    if (! purple_xfer_is_canceled (data->xfer)) {
      purple_xfer_cancel_remote (data->xfer);
    }
    failure ("send xfer failed");
  }

  data->loading = FALSE;

  data->xfer->data = NULL;
  purple_xfer_unref (data->xfer);
  tgprpl_xfer_free_data (data);
}
예제 #2
0
static void tgprpl_xfer_recv_on_finished (struct tgl_state *TLS, void *_data, int success, const char *filename) {
  debug ("tgprpl_xfer_recv_on_finished()");
  struct tgp_xfer_send_data *data = _data;
  char *selected = g_strdup (purple_xfer_get_local_filename (data->xfer));

  if (success) {
    debug ("purple_xfer_set_completed");

    // always completed the file transfer to avoid a warning dialogue when closing (Adium)
    purple_xfer_set_bytes_sent (data->xfer, purple_xfer_get_size (data->xfer));
    purple_xfer_set_completed (data->xfer, TRUE);

    if (! purple_xfer_is_canceled (data->xfer)) {
      purple_xfer_end (data->xfer);
    }
  } else {
    tgp_notify_on_error_gw (TLS, NULL, success);
    if (! purple_xfer_is_canceled (data->xfer)) {
      purple_xfer_cancel_remote (data->xfer);
    }
    failure ("recv xfer failed");
  }

  data->loading = FALSE;

  data->xfer->data = NULL;
  purple_xfer_unref (data->xfer);
  tgprpl_xfer_free_data (data);

  debug ("moving transferred file from tgl directory %s to selected target %s", selected, filename);
  g_unlink (selected);
  g_rename (filename, selected);
  g_free (selected);
}
예제 #3
0
void tgprpl_xfer_free_all (connection_data *conn) {
  GList *xfers = purple_xfers_get_all ();
  while (xfers) {
    PurpleXfer *xfer = xfers->data;

    if (purple_xfer_get_account (xfer) == conn->pa) {
      debug ("xfer: %s", xfer->filename);

      // cancel all non-completed file tranfsers to avoid them from being called
      // in future sessions, as they still contain references to already freed data.
      if (! purple_xfer_is_canceled (xfer) && ! purple_xfer_is_completed (xfer)) {
        purple_xfer_cancel_local (xfer);
      }

      // if a file transfer is still running while going offline, it will be canceled when
      // cleaning up libtgl memory. Since canceled file transfers are being kept (see
      // tgprpl_xfer_canceled() and tgprpl_xfer_recv_init()) those need to be freed now.
      struct tgp_xfer_send_data *data = xfer->data;
      if (data) {
        if (data->loading) {
          tgprpl_xfer_free_data (data);
          xfer->data = NULL;
          purple_xfer_unref (xfer);
        } else {
          g_warn_if_reached();
        }
      }
    }

    xfers = g_list_next(xfers);
  }
}
예제 #4
0
static void tgprpl_xfer_canceled (PurpleXfer *X) {
  debug ("tgprpl_xfer_canceled()");
  struct tgp_xfer_send_data *data = X->data;

  // the xfer data must not be freed when the transfer is still running, since there is no way to cancel
  // the running transfer and the callback still needs the xfer data. In that case transfer data will
  // be freed once the transfer finished or the account goes offline and all loading transfers are aborted.
  if (! data->loading) {
    data->xfer->data = NULL;
    tgprpl_xfer_free_data (data);
  }
}
예제 #5
0
static void tgprpl_xfer_on_finished (struct tgl_state *TLS, void *_data, int success, struct tgl_message *M) {
  debug ("tgprpl_xfer_on_finished()");
  struct tgp_xfer_send_data *data = _data;
  
  if (success) {
    if (!data->done) {
      debug ("purple_xfer_set_completed");
      purple_xfer_set_bytes_sent (data->xfer, purple_xfer_get_size (data->xfer));
      purple_xfer_set_completed (data->xfer, TRUE);
      purple_xfer_end(data->xfer);
    }
  } else {
    failure ("ERROR xfer failed");
  }
  
  data->xfer->data = NULL;
  tgprpl_xfer_free_data (data);
}
예제 #6
0
static void tgprpl_xfer_recv_on_finished (struct tgl_state *TLS, void *_data, int success, const char *filename) {
  debug ("tgprpl_xfer_recv_on_finished()");
  struct tgp_xfer_send_data *data = _data;

  if (success) {
    if (!data->done) {
      debug ("purple_xfer_set_completed");
      purple_xfer_set_bytes_sent (data->xfer, purple_xfer_get_size (data->xfer));
      purple_xfer_set_completed (data->xfer, TRUE);
      purple_xfer_end (data->xfer);
    }
    
    g_unlink (purple_xfer_get_local_filename (data->xfer));
    g_rename (filename, purple_xfer_get_local_filename (data->xfer));

  } else {
    failure ("ERROR xfer failed");
  }

  data->xfer->data = NULL;
  tgprpl_xfer_free_data (data);
}
예제 #7
0
static void tgprpl_xfer_canceled (PurpleXfer *X) {
  struct tgp_xfer_send_data *data = X->data;
  tgprpl_xfer_free_data (data);
}