mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
call after sms is optional now
This commit is contained in:
@@ -82,7 +82,7 @@ IntroCode::IntroCode(IntroWidget *parent) : IntroStep(parent)
|
||||
, _noTelegramCodeRequestId(0)
|
||||
, code(this, st::inpIntroCode, lang(lng_code_ph))
|
||||
, sentRequest(0)
|
||||
, waitTillCall(intro()->getCallTimeout()) {
|
||||
, callStatus(intro()->getCallStatus()) {
|
||||
setGeometry(parent->innerRect());
|
||||
|
||||
connect(&next, SIGNAL(clicked()), this, SLOT(onSubmitCode()));
|
||||
@@ -93,9 +93,10 @@ IntroCode::IntroCode(IntroWidget *parent) : IntroStep(parent)
|
||||
|
||||
updateDescText();
|
||||
|
||||
waitTillCall = intro()->getCallTimeout();
|
||||
if (!intro()->codeByTelegram()) {
|
||||
callTimer.start(1000);
|
||||
if (callStatus.type == IntroWidget::CallWaiting) {
|
||||
callTimer.start(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +107,8 @@ void IntroCode::updateDescText() {
|
||||
callTimer.stop();
|
||||
} else {
|
||||
_noTelegramCode.hide();
|
||||
waitTillCall = intro()->getCallTimeout();
|
||||
if (!callTimer.isActive()) {
|
||||
callStatus = intro()->getCallStatus();
|
||||
if (callStatus.type == IntroWidget::CallWaiting && !callTimer.isActive()) {
|
||||
callTimer.start(1000);
|
||||
}
|
||||
}
|
||||
@@ -130,15 +131,27 @@ void IntroCode::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
if (codeByTelegram) {
|
||||
} else {
|
||||
QString callText = lang(lng_code_calling);
|
||||
if (waitTillCall >= 3600) {
|
||||
callText = lng_code_call(lt_minutes, qsl("%1:%2").arg(waitTillCall / 3600).arg((waitTillCall / 60) % 60, 2, 10, QChar('0')), lt_seconds, qsl("%1").arg(waitTillCall % 60, 2, 10, QChar('0')));
|
||||
} else if (waitTillCall > 0) {
|
||||
callText = lng_code_call(lt_minutes, QString::number(waitTillCall / 60), lt_seconds, qsl("%1").arg(waitTillCall % 60, 2, 10, QChar('0')));
|
||||
} else if (waitTillCall < 0) {
|
||||
QString callText;
|
||||
switch (callStatus.type) {
|
||||
case IntroWidget::CallWaiting: {
|
||||
if (callStatus.timeout >= 3600) {
|
||||
callText = lng_code_call(lt_minutes, qsl("%1:%2").arg(callStatus.timeout / 3600).arg((callStatus.timeout / 60) % 60, 2, 10, QChar('0')), lt_seconds, qsl("%1").arg(callStatus.timeout % 60, 2, 10, QChar('0')));
|
||||
} else {
|
||||
callText = lng_code_call(lt_minutes, QString::number(callStatus.timeout / 60), lt_seconds, qsl("%1").arg(callStatus.timeout % 60, 2, 10, QChar('0')));
|
||||
}
|
||||
} break;
|
||||
|
||||
case IntroWidget::CallCalling: {
|
||||
callText = lang(lng_code_calling);
|
||||
} break;
|
||||
|
||||
case IntroWidget::CallCalled: {
|
||||
callText = lang(lng_code_called);
|
||||
} break;
|
||||
}
|
||||
if (!callText.isEmpty()) {
|
||||
p.drawText(QRect(textRect.left(), code.y() + code.height() + st::introCallSkip, st::introTextSize.width(), st::introErrHeight), callText, style::al_center);
|
||||
}
|
||||
p.drawText(QRect(textRect.left(), code.y() + code.height() + st::introCallSkip, st::introTextSize.width(), st::introErrHeight), callText, style::al_center);
|
||||
}
|
||||
if (_a_error.animating() || error.length()) {
|
||||
p.setOpacity(a_errorAlpha.current());
|
||||
@@ -291,16 +304,22 @@ void IntroCode::onInputChange() {
|
||||
}
|
||||
|
||||
void IntroCode::onSendCall() {
|
||||
if (!--waitTillCall) {
|
||||
callTimer.stop();
|
||||
MTP::send(MTPauth_ResendCode(MTP_string(intro()->getPhone()), MTP_string(intro()->getPhoneHash())), rpcDone(&IntroCode::callDone));
|
||||
if (callStatus.type == IntroWidget::CallWaiting) {
|
||||
if (--callStatus.timeout <= 0) {
|
||||
callStatus.type = IntroWidget::CallCalling;
|
||||
callTimer.stop();
|
||||
MTP::send(MTPauth_ResendCode(MTP_string(intro()->getPhone()), MTP_string(intro()->getPhoneHash())), rpcDone(&IntroCode::callDone));
|
||||
} else {
|
||||
intro()->setCallStatus(callStatus);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void IntroCode::callDone(const MTPBool &v) {
|
||||
if (!waitTillCall) {
|
||||
waitTillCall = -1;
|
||||
void IntroCode::callDone(const MTPauth_SentCode &v) {
|
||||
if (callStatus.type == IntroWidget::CallCalling) {
|
||||
callStatus.type = IntroWidget::CallCalled;
|
||||
intro()->setCallStatus(callStatus);
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -346,7 +365,24 @@ void IntroCode::onNoTelegramCode() {
|
||||
_noTelegramCodeRequestId = MTP::send(MTPauth_ResendCode(MTP_string(intro()->getPhone()), MTP_string(intro()->getPhoneHash())), rpcDone(&IntroCode::noTelegramCodeDone), rpcFail(&IntroCode::noTelegramCodeFail));
|
||||
}
|
||||
|
||||
void IntroCode::noTelegramCodeDone(const MTPBool &result) {
|
||||
void IntroCode::noTelegramCodeDone(const MTPauth_SentCode &result) {
|
||||
if (result.type() != mtpc_auth_sentCode) {
|
||||
showError(lang(lng_server_error));
|
||||
return;
|
||||
}
|
||||
|
||||
const MTPDauth_sentCode &d(result.c_auth_sentCode());
|
||||
switch (d.vtype.type()) {
|
||||
case mtpc_auth_sentCodeTypeApp: intro()->setCodeByTelegram(true);
|
||||
case mtpc_auth_sentCodeTypeSms:
|
||||
case mtpc_auth_sentCodeTypeCall: intro()->setCodeByTelegram(false);
|
||||
case mtpc_auth_sentCodeTypeFlashCall: LOG(("Error: should not be flashcall!")); break;
|
||||
}
|
||||
if (d.has_next_type() && d.vnext_type.type() == mtpc_auth_codeTypeCall) {
|
||||
intro()->setCallStatus({ IntroWidget::CallWaiting, d.has_timeout() ? d.vtimeout.v : 60 });
|
||||
} else {
|
||||
intro()->setCallStatus({ IntroWidget::CallDisabled, 0 });
|
||||
}
|
||||
intro()->setCodeByTelegram(false);
|
||||
updateDescText();
|
||||
}
|
||||
|
Reference in New Issue
Block a user