2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Use getters in MTP classes.

This commit is contained in:
John Preston
2019-07-05 15:38:38 +02:00
parent 3ca28c0cf9
commit 567bf60644
100 changed files with 2807 additions and 2672 deletions

View File

@@ -229,12 +229,12 @@ void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) {
stopCheck();
_sentRequest = 0;
auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
if (d.vuser().type() != mtpc_user || !d.vuser().c_user().is_self()) { // wtf?
showCodeError(rpl::single(Lang::Hard::ServerError()));
return;
}
cSetLoggedPhoneNumber(getData()->phone);
finish(d.vuser);
finish(d.vuser());
}
bool CodeWidget::codeSubmitFail(const RPCError &error) {
@@ -314,7 +314,7 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) {
_sentRequest = 0;
const auto &d = result.c_account_password();
getData()->pwdRequest = Core::ParseCloudPasswordCheckRequest(d);
if (!d.has_current_algo() || !d.has_srp_id() || !d.has_srp_B()) {
if (!d.vcurrent_algo() || !d.vsrp_id() || !d.vsrp_B()) {
LOG(("API Error: No current password received on login."));
_code->setFocus();
return;
@@ -331,7 +331,7 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) {
return;
}
getData()->hasRecovery = d.is_has_recovery();
getData()->pwdHint = qs(d.vhint);
getData()->pwdHint = qs(d.vhint().value_or_empty());
getData()->pwdNotEmptyPassport = d.is_has_secure_values();
goReplace(new Intro::PwdCheckWidget(parentWidget(), getData()));
}
@@ -377,9 +377,10 @@ void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) {
const auto &d = result.c_auth_sentCode();
fillSentCodeData(d);
_code->setDigitsCountMax(getData()->codeLength);
if (d.has_next_type() && d.vnext_type.type() == mtpc_auth_codeTypeCall) {
const auto next = d.vnext_type();
if (next && next->type() == mtpc_auth_codeTypeCall) {
getData()->callStatus = Widget::Data::CallStatus::Waiting;
getData()->callTimeout = d.has_timeout() ? d.vtimeout.v : 60;
getData()->callTimeout = d.vtimeout().value_or(60);
} else {
getData()->callStatus = Widget::Data::CallStatus::Disabled;
getData()->callTimeout = 0;

View File

@@ -153,11 +153,12 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
const auto &d = result.c_auth_sentCode();
fillSentCodeData(d);
getData()->phone = _sentPhone;
getData()->phoneHash = qba(d.vphone_code_hash);
getData()->phoneHash = qba(d.vphone_code_hash());
getData()->phoneIsRegistered = d.is_phone_registered();
if (d.has_next_type() && d.vnext_type.type() == mtpc_auth_codeTypeCall) {
const auto next = d.vnext_type();
if (next && next->type() == mtpc_auth_codeTypeCall) {
getData()->callStatus = Widget::Data::CallStatus::Waiting;
getData()->callTimeout = d.has_timeout() ? d.vtimeout.v : 60;
getData()->callTimeout = d.vtimeout().value_or(60);
} else {
getData()->callStatus = Widget::Data::CallStatus::Disabled;
getData()->callTimeout = 0;

View File

@@ -136,11 +136,11 @@ void PwdCheckWidget::pwdSubmitDone(bool recover, const MTPauth_Authorization &re
cSetPasswordRecovered(true);
}
auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
if (d.vuser().type() != mtpc_user || !d.vuser().c_user().is_self()) { // wtf?
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(d.vuser);
finish(d.vuser());
}
void PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
@@ -265,7 +265,7 @@ void PwdCheckWidget::codeSubmitFail(const RPCError &error) {
}
void PwdCheckWidget::recoverStarted(const MTPauth_PasswordRecovery &result) {
_emailPattern = qs(result.c_auth_passwordRecovery().vemail_pattern);
_emailPattern = qs(result.c_auth_passwordRecovery().vemail_pattern());
updateDescriptionText();
}

View File

@@ -121,11 +121,11 @@ void SignupWidget::onCheckRequest() {
void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
stopCheck();
auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
if (d.vuser().type() != mtpc_user || !d.vuser().c_user().is_self()) { // wtf?
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(d.vuser, _photo->takeResultImage());
finish(d.vuser(), _photo->takeResultImage());
}
bool SignupWidget::nameSubmitFail(const RPCError &error) {

View File

@@ -431,11 +431,11 @@ void Widget::getNearestDC() {
request(MTPhelp_GetNearestDc()).done([this](const MTPNearestDc &result) {
auto &nearest = result.c_nearestDc();
DEBUG_LOG(("Got nearest dc, country: %1, nearest: %2, this: %3"
).arg(qs(nearest.vcountry)
).arg(nearest.vnearest_dc.v
).arg(nearest.vthis_dc.v));
Core::App().suggestMainDcId(nearest.vnearest_dc.v);
auto nearestCountry = qs(nearest.vcountry);
).arg(qs(nearest.vcountry())
).arg(nearest.vnearest_dc().v
).arg(nearest.vthis_dc().v));
Core::App().suggestMainDcId(nearest.vnearest_dc().v);
auto nearestCountry = qs(nearest.vcountry());
if (getData()->country != nearestCountry) {
getData()->country = nearestCountry;
getData()->updated.notify();
@@ -648,7 +648,7 @@ rpl::producer<QString> Widget::Step::nextButtonText() const {
void Widget::Step::finish(const MTPUser &user, QImage &&photo) {
if (user.type() != mtpc_user
|| !user.c_user().is_self()
|| !user.c_user().vid.v) {
|| !user.c_user().vid().v) {
// No idea what to do here.
// We could've reset intro and MTP, but this really should not happen.
Ui::show(Box<InformBox>("Internal error: bad user.is_self() after sign in."));
@@ -776,26 +776,27 @@ bool Widget::Step::paintAnimated(Painter &p, QRect clip) {
}
void Widget::Step::fillSentCodeData(const MTPDauth_sentCode &data) {
if (data.has_terms_of_service()) {
const auto &terms = data.vterms_of_service.c_help_termsOfService();
getData()->termsLock = Window::TermsLock::FromMTP(terms);
if (const auto terms = data.vterms_of_service()) {
terms->match([&](const MTPDhelp_termsOfService &data) {
getData()->termsLock = Window::TermsLock::FromMTP(data);
});
} else {
getData()->termsLock = Window::TermsLock();
}
const auto &type = data.vtype;
const auto &type = data.vtype();
switch (type.type()) {
case mtpc_auth_sentCodeTypeApp: {
getData()->codeByTelegram = true;
getData()->codeLength = type.c_auth_sentCodeTypeApp().vlength.v;
getData()->codeLength = type.c_auth_sentCodeTypeApp().vlength().v;
} break;
case mtpc_auth_sentCodeTypeSms: {
getData()->codeByTelegram = false;
getData()->codeLength = type.c_auth_sentCodeTypeSms().vlength.v;
getData()->codeLength = type.c_auth_sentCodeTypeSms().vlength().v;
} break;
case mtpc_auth_sentCodeTypeCall: {
getData()->codeByTelegram = false;
getData()->codeLength = type.c_auth_sentCodeTypeCall().vlength.v;
getData()->codeLength = type.c_auth_sentCodeTypeCall().vlength().v;
} break;
case mtpc_auth_sentCodeTypeFlashCall: LOG(("Error: should not be flashcall!")); break;
}