mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Replace a series of if
statements with a switch
.
This commit is contained in:
parent
941026266e
commit
2c06ef6ad4
|
@ -1 +1 @@
|
||||||
5796f74532156d61d5c715914b5013ae0544892f7d6dca237b1f6a828f49fc9c /usr/local/bin/tox-bootstrapd
|
139fe825b90c022bbefd3837c2a427ab9215be3ca62144ea7ff12ae7389c78ba /usr/local/bin/tox-bootstrapd
|
||||||
|
|
|
@ -1266,21 +1266,28 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_file_control_packet(m, friendnumber, inbound, file_number, control, nullptr, 0)) {
|
if (send_file_control_packet(m, friendnumber, inbound, file_number, control, nullptr, 0)) {
|
||||||
if (control == FILECONTROL_KILL) {
|
switch (control) {
|
||||||
|
case FILECONTROL_KILL: {
|
||||||
if (!inbound && (ft->status == FILESTATUS_TRANSFERRING || ft->status == FILESTATUS_FINISHED)) {
|
if (!inbound && (ft->status == FILESTATUS_TRANSFERRING || ft->status == FILESTATUS_FINISHED)) {
|
||||||
// We are actively sending that file, remove from list
|
// We are actively sending that file, remove from list
|
||||||
--m->friendlist[friendnumber].num_sending_files;
|
--m->friendlist[friendnumber].num_sending_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
ft->status = FILESTATUS_NONE;
|
ft->status = FILESTATUS_NONE;
|
||||||
} else if (control == FILECONTROL_PAUSE) {
|
break;
|
||||||
|
}
|
||||||
|
case FILECONTROL_PAUSE: {
|
||||||
ft->paused |= FILE_PAUSE_US;
|
ft->paused |= FILE_PAUSE_US;
|
||||||
} else if (control == FILECONTROL_ACCEPT) {
|
break;
|
||||||
|
}
|
||||||
|
case FILECONTROL_ACCEPT: {
|
||||||
ft->status = FILESTATUS_TRANSFERRING;
|
ft->status = FILESTATUS_TRANSFERRING;
|
||||||
|
|
||||||
if ((ft->paused & FILE_PAUSE_US) != 0) {
|
if ((ft->paused & FILE_PAUSE_US) != 0) {
|
||||||
ft->paused ^= FILE_PAUSE_US;
|
ft->paused ^= FILE_PAUSE_US;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return -8;
|
return -8;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user