Esempio n. 1
0
void tgprpl_recv_file (PurpleConnection * gc, const char *who, struct tgl_message *M) {
  debug ("tgprpl_recv_file()");
  PurpleXfer *X = tgprpl_new_xfer_recv (gc, who);
  const char *mime_type, *caption;
  long long access_hash;
  int flags, size;
  
  if (M->media.type == tgl_message_media_document_encr) {
    mime_type = M->media.encr_document->mime_type;
    caption = M->media.encr_document->caption;
    access_hash = M->media.encr_document->access_hash;
    flags = M->media.encr_document->flags;
    size = M->media.encr_document->size;
  } else {
    mime_type = M->media.document->mime_type;
    caption = M->media.document->caption;
    access_hash = M->media.document->access_hash;
    flags = M->media.document->flags;
    size = M->media.document->size;
  }

  char *filename = tgp_strdup_determine_filename (mime_type, caption, flags, access_hash);
  purple_xfer_set_filename (X, filename);
  g_free (filename);
  
  purple_xfer_set_size (X, size);
  
  tgprpl_xfer_init_data (X, purple_connection_get_protocol_data (gc), M);
  purple_xfer_request (X);
}
Esempio n. 2
0
void tgprpl_recv_encr_file (PurpleConnection * gc, const char *who, struct tgl_encr_document *D) {
  debug ("tgprpl_recv_encr_file()");
  PurpleXfer *X = tgprpl_new_xfer_recv (gc, who);
  
  char *filename = tgp_strdup_determine_filename (D->mime_type, D->caption, D->flags,
                                                  D->access_hash);
  purple_xfer_set_filename (X, filename);
  g_free (filename);
  
  purple_xfer_set_size (X, D->size);
  
  tgprpl_xfer_init_data (X, purple_connection_get_protocol_data (gc), NULL, D);
  purple_xfer_request (X);
}