Example #1
0
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;
}
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
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;
}
Example #5
0
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;
}
Example #6
0
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;
}
Example #7
0
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;
}
Example #8
0
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;
}
Example #9
0
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;
}
Example #10
0
bool CodeWidget::codeSubmitFail(const RPCError &error) {
	if (MTP::isFloodError(error)) {
		stopCheck();
		_sentRequest = 0;
		showCodeError(langFactory(lng_flood_error));
		return true;
	}
	if (MTP::isDefaultHandledError(error)) return false;

	stopCheck();
	_sentRequest = 0;
	auto &err = error.type();
	if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED")) { // show error
		goBack();
		return true;
	} else if (err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID")) {
		showCodeError(langFactory(lng_bad_code));
		return true;
	} else if (err == qstr("PHONE_NUMBER_UNOCCUPIED")) { // success, need to signUp
		getData()->code = _sentCode;
		goReplace(new Intro::SignupWidget(parentWidget(), getData()));
		return true;
	} else if (err == qstr("SESSION_PASSWORD_NEEDED")) {
		getData()->code = _sentCode;
		_checkRequest->start(1000);
		_sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&CodeWidget::gotPassword), rpcFail(&CodeWidget::codeSubmitFail));
		return true;
	}
	if (Logs::DebugEnabled()) { // internal server error
		auto text = err + ": " + error.description();
		showCodeError([text] { return text; });
	} else {
		showCodeError(&Lang::Hard::ServerError);
	}
	return false;
}
Example #11
0
	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;
	}
Example #12
0
bool Application::peerPhotoFail(PeerId peer, const RPCError &e) {
	LOG(("Application Error: update photo failed %1: %2").arg(e.type()).arg(e.description()));
	cancelPhotoUpdate(peer);
	emit peerPhotoFail(peer);
	return true;
}