mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
File transfer fixes.
Don't allow non transferring files to be paused and then resumed starting the file transfer.
This commit is contained in:
parent
6315ff2362
commit
62dad7b3f7
|
@ -1198,10 +1198,11 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
|
||||||
if (control > FILECONTROL_KILL)
|
if (control > FILECONTROL_KILL)
|
||||||
return -4;
|
return -4;
|
||||||
|
|
||||||
if (control == FILECONTROL_PAUSE && (ft->paused & FILE_PAUSE_US))
|
if (control == FILECONTROL_PAUSE && ((ft->paused & FILE_PAUSE_US) || ft->status != FILESTATUS_TRANSFERRING))
|
||||||
return -5;
|
return -5;
|
||||||
|
|
||||||
if (control == FILECONTROL_ACCEPT && ft->status == FILESTATUS_TRANSFERRING) {
|
if (control == FILECONTROL_ACCEPT) {
|
||||||
|
if (ft->status == FILESTATUS_TRANSFERRING) {
|
||||||
if (!(ft->paused & FILE_PAUSE_US)) {
|
if (!(ft->paused & FILE_PAUSE_US)) {
|
||||||
if (ft->paused & FILE_PAUSE_OTHER) {
|
if (ft->paused & FILE_PAUSE_OTHER) {
|
||||||
return -6;
|
return -6;
|
||||||
|
@ -1209,6 +1210,13 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
|
||||||
return -7;
|
return -7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (ft->status != FILESTATUS_NOT_ACCEPTED)
|
||||||
|
return -7;
|
||||||
|
|
||||||
|
if (!send_receive)
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_file_control_packet(m, friendnumber, send_receive, file_number, control, 0, 0)) {
|
if (send_file_control_packet(m, friendnumber, send_receive, file_number, control, 0, 0)) {
|
||||||
|
@ -1550,15 +1558,23 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
|
||||||
}
|
}
|
||||||
|
|
||||||
if (control_type == FILECONTROL_ACCEPT) {
|
if (control_type == FILECONTROL_ACCEPT) {
|
||||||
|
if (receive_send && ft->status == FILESTATUS_NOT_ACCEPTED) {
|
||||||
ft->status = FILESTATUS_TRANSFERRING;
|
ft->status = FILESTATUS_TRANSFERRING;
|
||||||
|
} else {
|
||||||
if (ft->paused & FILE_PAUSE_OTHER) {
|
if (ft->paused & FILE_PAUSE_OTHER) {
|
||||||
ft->paused ^= FILE_PAUSE_OTHER;
|
ft->paused ^= FILE_PAUSE_OTHER;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->file_filecontrol)
|
if (m->file_filecontrol)
|
||||||
(*m->file_filecontrol)(m, friendnumber, real_filenumber, control_type, m->file_filecontrol_userdata);
|
(*m->file_filecontrol)(m, friendnumber, real_filenumber, control_type, m->file_filecontrol_userdata);
|
||||||
} else if (control_type == FILECONTROL_PAUSE) {
|
} else if (control_type == FILECONTROL_PAUSE) {
|
||||||
|
if ((ft->paused & FILE_PAUSE_OTHER) || ft->status != FILESTATUS_TRANSFERRING) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ft->paused |= FILE_PAUSE_OTHER;
|
ft->paused |= FILE_PAUSE_OTHER;
|
||||||
|
|
||||||
if (m->file_filecontrol)
|
if (m->file_filecontrol)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user