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 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 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 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 ApiWrap::lastParticipantsFail(ChannelData *peer, const RPCError &error, mtpRequestId req) { if (mtpIsFlood(error)) return false; if (_participantsRequests.value(peer) == req || _participantsRequests.value(peer) == -req) { _participantsRequests.remove(peer); } else if (_botsRequests.value(peer) == req) { _botsRequests.remove(peer); } return true; }
bool FileUploader::partFailed(const RPCError &error, mtpRequestId requestId) { if (mtpIsFlood(error)) return false; if (requestsSent.constFind(requestId) != requestsSent.cend() || docRequestsSent.constFind(requestId) != docRequestsSent.cend()) { // failed to upload current file currentFailed(); } sendNext(); return true; }
bool rpcErrorOccured(mtpRequestId requestId, const RPCFailHandlerPtr &onFail, const RPCError &err) { // return true if need to clean request data if (mtpIsFlood(err)) { 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::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 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 (mtpIsFlood(error)) { 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 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 ApiWrap::gotStickerSetFail(uint64 setId, const RPCError &error) { if (mtpIsFlood(error)) return false; _stickerSetRequests.remove(setId); return true; }
bool ApiWrap::kickParticipantFail(KickRequest kick, const RPCError &error, mtpRequestId req) { if (mtpIsFlood(error)) return false; _kickRequests.remove(kick); return true; }
bool ApiWrap::gotPeerFailed(PeerData *peer, const RPCError &error) { if (mtpIsFlood(error)) return false; _peerRequests.remove(peer); return true; }
bool mtpFileLoader::partFailed(const RPCError &error) { if (mtpIsFlood(error)) return false; finishFail(); return true; }
bool IntroPwdCheck::deleteFail(const RPCError &error) { if (mtpIsFlood(error)) return false; sentRequest = 0; showError(lang(lng_server_error)); return true; }