mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Fix contract violation in Call::startIncoming.
Also fix call answer while dhConfig is not received yet.
This commit is contained in:
parent
e99739ca0e
commit
8a4a7897a0
2 changed files with 15 additions and 3 deletions
|
@ -121,19 +121,21 @@ void Call::start(base::const_byte_span random) {
|
||||||
t_assert(!_dhConfig.p.empty());
|
t_assert(!_dhConfig.p.empty());
|
||||||
|
|
||||||
generateModExpFirst(random);
|
generateModExpFirst(random);
|
||||||
if (_state != State::Failed && _state != State::FailedHangingUp) {
|
if (_state == State::Starting || _state == State::Requesting) {
|
||||||
if (_type == Type::Outgoing) {
|
if (_type == Type::Outgoing) {
|
||||||
startOutgoing();
|
startOutgoing();
|
||||||
} else {
|
} else {
|
||||||
startIncoming();
|
startIncoming();
|
||||||
}
|
}
|
||||||
|
} else if (_state == State::ExchangingKeys && _answerAfterDhConfigReceived) {
|
||||||
|
answer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Call::startOutgoing() {
|
void Call::startOutgoing() {
|
||||||
Expects(_type == Type::Outgoing);
|
Expects(_type == Type::Outgoing);
|
||||||
|
Expects(_state == State::Requesting);
|
||||||
|
|
||||||
setState(State::Requesting);
|
|
||||||
request(MTPphone_RequestCall(_user->inputUser, MTP_int(rand_value<int32>()), MTP_bytes(_gaHash), MTP_phoneCallProtocol(MTP_flags(MTPDphoneCallProtocol::Flag::f_udp_p2p | MTPDphoneCallProtocol::Flag::f_udp_reflector), MTP_int(kMinLayer), MTP_int(kMaxLayer)))).done([this](const MTPphone_PhoneCall &result) {
|
request(MTPphone_RequestCall(_user->inputUser, MTP_int(rand_value<int32>()), MTP_bytes(_gaHash), MTP_phoneCallProtocol(MTP_flags(MTPDphoneCallProtocol::Flag::f_udp_p2p | MTPDphoneCallProtocol::Flag::f_udp_reflector), MTP_int(kMinLayer), MTP_int(kMaxLayer)))).done([this](const MTPphone_PhoneCall &result) {
|
||||||
Expects(result.type() == mtpc_phone_phoneCall);
|
Expects(result.type() == mtpc_phone_phoneCall);
|
||||||
|
|
||||||
|
@ -184,9 +186,17 @@ void Call::answer() {
|
||||||
Expects(_type == Type::Incoming);
|
Expects(_type == Type::Incoming);
|
||||||
|
|
||||||
if (_state != State::Starting && _state != State::WaitingIncoming) {
|
if (_state != State::Starting && _state != State::WaitingIncoming) {
|
||||||
return;
|
if (_state != State::ExchangingKeys || !_answerAfterDhConfigReceived) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setState(State::ExchangingKeys);
|
setState(State::ExchangingKeys);
|
||||||
|
if (_gb.empty()) {
|
||||||
|
_answerAfterDhConfigReceived = true;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_answerAfterDhConfigReceived = false;
|
||||||
|
}
|
||||||
request(MTPphone_AcceptCall(MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)), MTP_bytes(_gb), _protocol)).done([this](const MTPphone_PhoneCall &result) {
|
request(MTPphone_AcceptCall(MTP_inputPhoneCall(MTP_long(_id), MTP_long(_accessHash)), MTP_bytes(_gb), _protocol)).done([this](const MTPphone_PhoneCall &result) {
|
||||||
Expects(result.type() == mtpc_phone_phoneCall);
|
Expects(result.type() == mtpc_phone_phoneCall);
|
||||||
auto &call = result.c_phone_phoneCall();
|
auto &call = result.c_phone_phoneCall();
|
||||||
|
@ -234,6 +244,7 @@ void Call::redial() {
|
||||||
t_assert(_controller == nullptr);
|
t_assert(_controller == nullptr);
|
||||||
_type = Type::Outgoing;
|
_type = Type::Outgoing;
|
||||||
setState(State::Requesting);
|
setState(State::Requesting);
|
||||||
|
_answerAfterDhConfigReceived = false;
|
||||||
startWaitingTrack();
|
startWaitingTrack();
|
||||||
_delegate->callRedial(this);
|
_delegate->callRedial(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ private:
|
||||||
Type _type = Type::Outgoing;
|
Type _type = Type::Outgoing;
|
||||||
State _state = State::Starting;
|
State _state = State::Starting;
|
||||||
FinishType _finishAfterRequestingCall = FinishType::None;
|
FinishType _finishAfterRequestingCall = FinishType::None;
|
||||||
|
bool _answerAfterDhConfigReceived = false;
|
||||||
base::Observable<State> _stateChanged;
|
base::Observable<State> _stateChanged;
|
||||||
TimeMs _startTime = 0;
|
TimeMs _startTime = 0;
|
||||||
base::DelayedCallTimer _finishByTimeoutTimer;
|
base::DelayedCallTimer _finishByTimeoutTimer;
|
||||||
|
|
Loading…
Add table
Reference in a new issue