mirror of
https://github.com/Tha14/toxic.git
synced 2025-06-30 06:06:45 +02:00
Fix some filetransfer issues
- File transfers now timeout properly - Small refactor related to creating new transfers
This commit is contained in:
@ -38,9 +38,9 @@
|
||||
|
||||
typedef enum FILE_TRANSFER_STATE {
|
||||
FILE_TRANSFER_INACTIVE,
|
||||
FILE_TRANSFER_PAUSED,
|
||||
FILE_TRANSFER_PENDING,
|
||||
FILE_TRANSFER_STARTED,
|
||||
FILE_TRANSFER_PAUSED,
|
||||
} FILE_TRANSFER_STATE;
|
||||
|
||||
typedef enum FILE_TRANSFER_DIRECTION {
|
||||
@ -49,31 +49,36 @@ typedef enum FILE_TRANSFER_DIRECTION {
|
||||
} FILE_TRANSFER_DIRECTION;
|
||||
|
||||
struct FileTransfer {
|
||||
ToxWindow *window;
|
||||
FILE *file;
|
||||
FILE_TRANSFER_STATE state;
|
||||
FILE_TRANSFER_DIRECTION direction;
|
||||
uint8_t file_type;
|
||||
char file_name[TOX_MAX_FILENAME_LENGTH + 1];
|
||||
char file_path[PATH_MAX + 1]; /* Not used by senders */
|
||||
double bps;
|
||||
double bps;
|
||||
uint32_t filenum;
|
||||
uint32_t friendnum;
|
||||
size_t index;
|
||||
uint64_t file_size;
|
||||
uint64_t position;
|
||||
uint64_t last_progress;
|
||||
uint64_t last_line_progress; /* The last time we updated the progress bar */
|
||||
uint64_t last_keep_alive; /* The last time we sent or received data */
|
||||
uint32_t line_id;
|
||||
uint8_t file_id[TOX_FILE_ID_LENGTH];
|
||||
};
|
||||
|
||||
/* Checks for timed out file transfers and closes them. */
|
||||
void check_file_transfer_timeouts(Tox *m);
|
||||
|
||||
/* creates initial progress line that will be updated during file transfer.
|
||||
progline must be at lesat MAX_STR_SIZE bytes */
|
||||
void prep_prog_line(char *progline);
|
||||
void init_progress_bar(char *progline);
|
||||
|
||||
/* prints a progress bar for file transfers */
|
||||
void print_progress_bar(ToxWindow *self, double pct_done, double bps, uint32_t line_id);
|
||||
|
||||
/* refreshes active file transfer status bars for friendnum */
|
||||
/* refreshes active file transfer status bars. */
|
||||
void refresh_file_transfer_progress(ToxWindow *self, Tox *m, uint32_t friendnum);
|
||||
|
||||
/* Returns a pointer to friendnum's FileTransfer struct associated with filenum.
|
||||
@ -88,15 +93,11 @@ struct FileTransfer *get_file_transfer_struct(uint32_t friendnum, uint32_t filen
|
||||
struct FileTransfer *get_file_transfer_struct_index(uint32_t friendnum, uint32_t index,
|
||||
FILE_TRANSFER_DIRECTION direction);
|
||||
|
||||
/* Returns a pointer to an unused file sender.
|
||||
* Returns NULL if all file senders are in use.
|
||||
/* Initializes an unused file transfer and returns its pointer.
|
||||
* Returns NULL on failure.
|
||||
*/
|
||||
struct FileTransfer *get_new_file_sender(uint32_t friendnum);
|
||||
|
||||
/* Returns a pointer to an unused file receiver.
|
||||
* Returns NULL if all file receivers are in use.
|
||||
*/
|
||||
struct FileTransfer *get_new_file_receiver(uint32_t friendnum);
|
||||
struct FileTransfer *new_file_transfer(ToxWindow *window, uint32_t friendnum, uint32_t filenum,
|
||||
FILE_TRANSFER_DIRECTION direction, uint8_t type);
|
||||
|
||||
/* Closes file transfer ft.
|
||||
*
|
||||
|
Reference in New Issue
Block a user