bool CreateGroupBox::failed(const RPCError &e) { _createRequestId = 0; if (e.type() == "NO_CHAT_TITLE") { _name.setFocus(); return true; } else if (e.type() == "USERS_TOO_FEW") { emit closed(); return true; } return false; }
bool IntroPhone::phoneSubmitFail(const RPCError &error) { if (MTP::isFloodError(error)) { stopCheck(); sentRequest = 0; showError(lang(lng_flood_error)); enableAll(true); return true; } if (MTP::isDefaultHandledError(error)) return false; stopCheck(); sentRequest = 0; const QString &err = error.type(); if (err == qstr("PHONE_NUMBER_INVALID")) { // show error showError(lang(lng_bad_phone)); enableAll(true); return true; } if (cDebug()) { // internal server error showError(err + ": " + error.description()); } else { showError(lang(lng_server_error)); } enableAll(true); return false; }
bool UsernameBox::onUpdateFail(const RPCError &error) { if (mtpIsFlood(error)) return false; _saveRequestId = 0; QString err(error.type()); if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == App::self()->username) { App::self()->setName(textOneLine(App::self()->firstName), textOneLine(App::self()->lastName), textOneLine(App::self()->nameOrPhone), textOneLine(_sentUsername)); emit closed(); return true; } else if (err == "USERNAME_INVALID") { _username.setFocus(); _username.showError(); _copiedTextLink = QString(); _errorText = lang(lng_username_invalid); update(); return true; } else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") { _username.setFocus(); _username.showError(); _copiedTextLink = QString(); _errorText = lang(lng_username_occupied); update(); return true; } _username.setFocus(); return true; }
bool IntroCode::codeSubmitFail(const RPCError &error) { stopCheck(); code.setDisabled(false); const QString &err = error.type(); if (err == "PHONE_NUMBER_INVALID" || err == "PHONE_CODE_EXPIRED") { // show error onBack(); return true; } else if (err == "PHONE_CODE_EMPTY" || err == "PHONE_CODE_INVALID") { showError(lang(lng_bad_code)); code.setFocus(); return true; } else if (err == "PHONE_NUMBER_UNOCCUPIED") { // success, need to signUp intro()->setCode(sentCode); intro()->onIntroNext(); return true; } if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) { showError(lang(lng_flood_error)); code.setFocus(); return true; } if (cDebug()) { // internal server error showError(err + ": " + error.description()); } else { showError(lang(lng_server_error)); } code.setFocus(); return false; }
bool StickerSetInner::installFailed(const RPCError &error) { if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false; App::wnd()->showLayer(new ConfirmBox(lang(lng_stickers_not_found), true), true); return true; }
bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) { sentRequest = 0; stopCheck(); _pwdField.setDisabled(false); _codeField.setDisabled(false); const QString &err = error.type(); if (err == "PASSWORD_HASH_INVALID") { showError(lang(lng_signin_bad_password)); _pwdField.selectAll(); _pwdField.notaBene(); return true; } else if (err == "PASSWORD_EMPTY") { intro()->onIntroBack(); } else if (mtpIsFlood(error)) { showError(lang(lng_flood_error)); _pwdField.notaBene(); return true; } if (cDebug()) { // internal server error showError(err + ": " + error.description()); } else { showError(lang(lng_server_error)); } _pwdField.setFocus(); return false; }
bool IntroPwdCheck::codeSubmitFail(const RPCError &error) { sentRequest = 0; stopCheck(); _pwdField.setDisabled(false); _codeField.setDisabled(false); const QString &err = error.type(); if (err == "PASSWORD_EMPTY") { intro()->onIntroBack(); return true; } else if (err == "PASSWORD_RECOVERY_NA") { recoverStartFail(error); return true; } else if (err == "PASSWORD_RECOVERY_EXPIRED") { _emailPattern = QString(); onToPassword(); return true; } else if (err == "CODE_INVALID") { showError(lang(lng_signin_wrong_code)); _codeField.selectAll(); _codeField.notaBene(); return true; } else if (mtpIsFlood(error)) { showError(lang(lng_flood_error)); _codeField.notaBene(); return true; } if (cDebug()) { // internal server error showError(err + ": " + error.description()); } else { showError(lang(lng_server_error)); } _codeField.setFocus(); return false; }
bool PhoneWidget::phoneSubmitFail(const RPCError &error) { if (MTP::isFloodError(error)) { stopCheck(); _sentRequest = 0; showPhoneError(langFactory(lng_flood_error)); return true; } if (MTP::isDefaultHandledError(error)) return false; stopCheck(); _sentRequest = 0; auto &err = error.type(); if (err == qstr("PHONE_NUMBER_FLOOD")) { Ui::show(Box<InformBox>(lang(lng_error_phone_flood))); return true; } else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error showPhoneError(langFactory(lng_bad_phone)); return true; } if (cDebug()) { // internal server error auto text = err + ": " + error.description(); showPhoneError([text] { return text; }); } else { showPhoneError(langFactory(lng_server_error)); } return false; }
bool UsernameBox::onUpdateFail(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; _saveRequestId = 0; QString err(error.type()); if (err == qstr("USERNAME_NOT_MODIFIED") || _sentUsername == App::self()->username) { App::self()->setName(TextUtilities::SingleLine(App::self()->firstName), TextUtilities::SingleLine(App::self()->lastName), TextUtilities::SingleLine(App::self()->nameOrPhone), TextUtilities::SingleLine(_sentUsername)); closeBox(); return true; } else if (err == qstr("USERNAME_INVALID")) { _username->setFocus(); _username->showError(); _errorText = lang(lng_username_invalid); update(); return true; } else if (err == qstr("USERNAME_OCCUPIED") || err == qstr("USERNAMES_UNAVAILABLE")) { _username->setFocus(); _username->showError(); _errorText = lang(lng_username_occupied); update(); return true; } _username->setFocus(); return true; }
bool ChangePhoneBox::EnterPhone::sendPhoneFail(const QString &phoneNumber, const RPCError &error) { auto errorText = Lang::Hard::ServerError(); if (MTP::isFloodError(error)) { errorText = lang(lng_flood_error); } else if (MTP::isDefaultHandledError(error)) { return false; } else if (error.type() == qstr("PHONE_NUMBER_INVALID")) { errorText = lang(lng_bad_phone); } else if (error.type() == qstr("PHONE_NUMBER_OCCUPIED")) { Ui::show(Box<InformBox>(lng_change_phone_occupied(lt_phone, App::formatPhone(phoneNumber)), lang(lng_box_ok))); _requestId = 0; return true; } showError(errorText); _requestId = 0; return true; }
bool FileUploader::partFailed(const RPCError &error, mtpRequestId requestId) { if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false; if (requestsSent.constFind(requestId) != requestsSent.cend() || docRequestsSent.constFind(requestId) != docRequestsSent.cend()) { // failed to upload current file currentFailed(); } sendNext(); return true; }
bool UsernameBox::onCheckFail(const RPCError &error) { if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false; _checkRequest = 0; QString err(error.type()); if (err == "USERNAME_INVALID") { _errorText = lang(lng_username_invalid); update(); return true; } else if (err == "USERNAME_OCCUPIED" && _checkUsername != App::self()->username) { _errorText = lang(lng_username_occupied); update(); return true; } _goodText = QString(); _usernameInput.setFocus(); return true; }
bool AddContactBox::onSaveFail(const RPCError &error) { if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false; _addRequest = 0; QString err(error.type()); QString firstName = _firstInput.text().trimmed(), lastName = _lastInput.text().trimmed(); if (err == "CHAT_TITLE_NOT_MODIFIED") { _peer->updateName(firstName, QString(), QString()); emit closed(); return true; } else if (err == "NO_CHAT_TITLE") { _firstInput.setFocus(); _firstInput.notaBene(); return true; } _firstInput.setFocus(); return true; }
bool ApiWrap::gotSelfParticipantFail(ChannelData *channel, const RPCError &error) { if (mtpIsFlood(error)) return false; if (error.type() == qstr("USER_NOT_PARTICIPANT")) { channel->inviter = -1; } _selfParticipantRequests.remove(channel); return true; }
bool ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) { auto errorText = Lang::Hard::ServerError(); if (MTP::isFloodError(error)) { errorText = lang(lng_flood_error); } else if (MTP::isDefaultHandledError(error)) { return false; } else if (error.type() == qstr("PHONE_CODE_EMPTY") || error.type() == qstr("PHONE_CODE_INVALID")) { errorText = lang(lng_bad_code); } else if (error.type() == qstr("PHONE_CODE_EXPIRED")) { closeBox(); // Go back to phone input. _requestId = 0; return true; } else if (error.type() == qstr("PHONE_NUMBER_INVALID")) { errorText = lang(lng_bad_phone); } _requestId = 0; showError(errorText); return true; }
bool IntroPhone::phoneSubmitFail(const RPCError &error) { stopCheck(); const QString &err = error.type(); if (err == "PHONE_NUMBER_INVALID") { // show error showError(lang(lng_bad_phone)); enableAll(true); return true; } else if (error.type().startsWith(qsl("FLOOD_WAIT_"))) { showError(lang(lng_flood_error)); enableAll(true); return true; } if (cDebug()) { // internal server error showError(err + ": " + error.description()); } else { showError(lang(lng_server_error)); } enableAll(true); return false; }
bool AddContactBox::onSaveSelfFail(const RPCError &error) { if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false; QString err(error.type()); QString firstName = textOneLine(_firstInput.text()), lastName = textOneLine(_lastInput.text()); if (err == "NAME_NOT_MODIFIED") { App::self()->setName(firstName, lastName, QString(), textOneLine(App::self()->username)); emit closed(); return true; } else if (err == "FIRSTNAME_INVALID") { _firstInput.setFocus(); _firstInput.notaBene(); return true; } else if (err == "LASTNAME_INVALID") { _lastInput.setFocus(); _lastInput.notaBene(); return true; } _firstInput.setFocus(); return true; }
bool rpcErrorOccured(mtpRequestId requestId, const RPCFailHandlerPtr &onFail, const RPCError &err) { // return true if need to clean request data if (err.type().startsWith(qsl("FLOOD_WAIT_"))) { if (onFail && (*onFail)(requestId, err)) return true; } if (onErrorDefault(requestId, err)) { return false; } LOG(("RPC Error: request %1 got fail with code %2, error %3%4").arg(requestId).arg(err.code()).arg(err.type()).arg(err.description().isEmpty() ? QString() : QString(": %1").arg(err.description()))); onFail && (*onFail)(requestId, err); return true; }
bool UsernameBox::onUpdateFail(const RPCError &error) { if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false; _saveRequest = 0; QString err(error.type()), name = getName(); if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == App::self()->username) { App::self()->setName(textOneLine(App::self()->firstName), textOneLine(App::self()->lastName), textOneLine(App::self()->nameOrPhone), textOneLine(name)); emit closed(); return true; } else if (err == "USERNAME_INVALID") { _usernameInput.setFocus(); _usernameInput.notaBene(); _errorText = lang(lng_username_invalid); return true; } else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") { _usernameInput.setFocus(); _usernameInput.notaBene(); _errorText = lang(lng_username_occupied); return true; } _usernameInput.setFocus(); return true; }
bool AddContactBox::onSaveFail(const RPCError &error) { QString err(error.type()); QString firstName = _firstInput.text().trimmed(), lastName = _lastInput.text().trimmed(); if (err == "CHAT_TITLE_NOT_MODIFIED") { _peer->updateName(firstName, QString()); emit closed(); return true; } else if (err == "NO_CHAT_TITLE") { _firstInput.setFocus(); _firstInput.notaBene(); return true; } _firstInput.setFocus(); return true; }
bool CodeWidget::noTelegramCodeFail(const RPCError &error) { if (MTP::isFloodError(error)) { showCodeError(langFactory(lng_flood_error)); return true; } if (MTP::isDefaultHandledError(error)) return false; if (Logs::DebugEnabled()) { // internal server error auto text = error.type() + ": " + error.description(); showCodeError([text] { return text; }); } else { showCodeError(&Lang::Hard::ServerError); } return false; }
bool UsernameBox::onCheckFail(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; _checkRequestId = 0; QString err(error.type()); if (err == qstr("USERNAME_INVALID")) { _errorText = lang(lng_username_invalid); update(); return true; } else if (err == qstr("USERNAME_OCCUPIED") && _checkUsername != App::self()->username) { _errorText = lang(lng_username_occupied); update(); return true; } _goodText = QString(); _username->setFocus(); return true; }
bool ConfirmPhoneBox::confirmFail(const RPCError &error) { auto errorText = lang(lng_server_error); if (MTP::isFloodError(error)) { errorText = lang(lng_flood_error); } else if (MTP::isDefaultHandledError(error)) { return false; } else { auto &errorType = error.type(); if (errorType == qstr("PHONE_CODE_EMPTY") || errorType == qstr("PHONE_CODE_INVALID")) { errorText = lang(lng_bad_code); } } _sendCodeRequestId = 0; _code->setDisabled(false); _code->setFocus(); showError(errorText); return true; }
bool AddContactBox::onSaveUserFail(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; _addRequest = 0; QString err(error.type()); QString firstName = _first->getLastText().trimmed(), lastName = _last->getLastText().trimmed(); if (err == "CHAT_TITLE_NOT_MODIFIED") { _user->setName(firstName, lastName, _user->nameOrPhone, _user->username); closeBox(); return true; } else if (err == "NO_CHAT_TITLE") { _first->setFocus(); _first->showError(); return true; } _first->setFocus(); return true; }
bool EditCaptionBox::saveFail(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; _saveRequestId = 0; QString err = error.type(); if (err == qstr("MESSAGE_ID_INVALID") || err == qstr("CHAT_ADMIN_REQUIRED") || err == qstr("MESSAGE_EDIT_TIME_EXPIRED")) { _error = lang(lng_edit_error); } else if (err == qstr("MESSAGE_NOT_MODIFIED")) { closeBox(); return true; } else if (err == qstr("MESSAGE_EMPTY")) { _field->setFocus(); _field->showError(); } else { _error = lang(lng_edit_error); } update(); return true; }
bool UsernameBox::onCheckFail(const RPCError &error) { if (mtpIsFlood(error)) return false; _checkRequestId = 0; QString err(error.type()); if (err == "USERNAME_INVALID") { _errorText = lang(lng_username_invalid); update(); return true; } else if (err == "USERNAME_OCCUPIED" && _checkUsername != App::self()->username) { _errorText = lang(lng_username_occupied); update(); return true; } _goodText = QString(); _copiedTextLink = QString(); _username.setFocus(); return true; }
bool AddContactBox::onSaveSelfFail(const RPCError &error) { QString err(error.type()); QString firstName = textOneLine(_firstInput.text()), lastName = textOneLine(_lastInput.text()); if (err == "NAME_NOT_MODIFIED") { App::self()->setName(firstName, lastName, firstName + ' ' + lastName); emit closed(); return true; } else if (err == "FIRSTNAME_INVALID") { _firstInput.setFocus(); _firstInput.notaBene(); return true; } else if (err == "LASTNAME_INVALID") { _lastInput.setFocus(); _lastInput.notaBene(); return true; } _firstInput.setFocus(); return true; }
bool PasscodeBox::setPasswordFail(const RPCError &error) { if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose(); _setRequest = 0; QString err = error.type(); if (err == "PASSWORD_HASH_INVALID") { if (_oldPasscode.isHidden()) { emit reloadPassword(); onClose(); } else { onBadOldPasscode(); } } else if (err == "NEW_PASSWORD_BAD") { _newPasscode.setFocus(); _newPasscode.showError(); _newError = lang(lng_cloud_password_bad); update(); } else if (err == "NEW_SALT_INVALID") { emit reloadPassword(); onClose(); } else if (err == "EMAIL_INVALID") { _emailError = lang(lng_cloud_password_bad_email); _recoverEmail.setFocus(); _recoverEmail.showError(); update(); } else if (err == "EMAIL_UNCONFIRMED") { Ui::showLayer(new InformBox(lang(lng_cloud_password_almost))); emit reloadPassword(); } else if (mtpIsFlood(error)) { if (_oldPasscode.isHidden()) return false; _oldPasscode.selectAll(); _oldPasscode.setFocus(); _oldPasscode.showError(); _oldError = lang(lng_flood_error); if (_hasRecovery && _hintText.isEmpty()) { _recover.hide(); } update(); } return true; }
bool IntroPhone::phoneSubmitFail(const RPCError &error) { stopCheck(); const QString &err = error.type(); if (err == "PHONE_NUMBER_INVALID") { // show error showError(lang(lng_bad_phone)); enableAll(true); return true; } if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) { showError(lang(lng_flood_error)); enableAll(true); return true; } if (cDebug()) { // internal server error showError(err + ": " + error.description()); } else { showError(lang(lng_server_error)); } enableAll(true); return false; }
bool PhoneWidget::phoneSubmitFail(const RPCError &error) { if (MTP::isFloodError(error)) { stopCheck(); _sentRequest = 0; showPhoneError(langFactory(lng_flood_error)); return true; } if (MTP::isDefaultHandledError(error)) return false; stopCheck(); _sentRequest = 0; auto &err = error.type(); if (err == qstr("PHONE_NUMBER_FLOOD")) { Ui::show(Box<InformBox>(lang(lng_error_phone_flood))); return true; } else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error showPhoneError(langFactory(lng_bad_phone)); return true; } else if (err == qstr("PHONE_NUMBER_BANNED")) { const auto phone = _sentPhone; Ui::show(Box<ConfirmBox>( lang(lng_signin_banned_text), lang(lng_box_ok), lang(lng_signin_banned_help), [] { Ui::hideLayer(); }, [phone] { SendToBannedHelp(phone); Ui::hideLayer(); })); return true; } if (Logs::DebugEnabled()) { // internal server error auto text = err + ": " + error.description(); showPhoneError([text] { return text; }); } else { showPhoneError(&Lang::Hard::ServerError); } return false; }