コード例 #1
0
ファイル: passcodewidget.cpp プロジェクト: Drru97/tdesktop
void PasscodeWidget::onSubmit() {
	if (_passcode->text().isEmpty()) {
		_passcode->showError();
		return;
	}
	if (!passcodeCanTry()) {
		_error = lang(lng_flood_error);
		_passcode->showError();
		update();
		return;
	}

	if (App::main()) {
		if (Local::checkPasscode(_passcode->text().toUtf8())) {
			cSetPasscodeBadTries(0);
			App::wnd()->clearPasscode(); // Destroys this widget.
			return;
		} else {
			cSetPasscodeBadTries(cPasscodeBadTries() + 1);
			cSetPasscodeLastTry(getms(true));
			onError();
			return;
		}
	} else {
		if (Local::readMap(_passcode->text().toUtf8()) != Local::ReadMapPassNeeded) {
			cSetPasscodeBadTries(0);

			MTP::start();
			if (MTP::authedId()) {
				App::wnd()->setupMain();
			} else {
				App::wnd()->setupIntro();
			}

			App::app()->checkMapVersion();
		} else {
			cSetPasscodeBadTries(cPasscodeBadTries() + 1);
			cSetPasscodeLastTry(getms(true));
			onError();
			return;
		}
	}
}
コード例 #2
0
ファイル: passcodebox.cpp プロジェクト: MobinRanjbar/tdesktop
void PasscodeBox::onSave(bool force) {
	if (_setRequest) return;

	QString old = _oldPasscode.text(), pwd = _newPasscode.text(), conf = _reenterPasscode.text();
	bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
	if (!_cloudPwd && (_turningOff || has)) {
		if (!passcodeCanTry()) {
			_oldError = lang(lng_flood_error);
			_oldPasscode.setFocus();
			_oldPasscode.showError();
			update();
			return;
		}

		if (Local::checkPasscode(old.toUtf8())) {
			cSetPasscodeBadTries(0);
			if (_turningOff) pwd = conf = QString();
		} else {
			cSetPasscodeBadTries(cPasscodeBadTries() + 1);
			cSetPasscodeLastTry(getms(true));
			onBadOldPasscode();
			return;
		}
	}
	if (!_turningOff && pwd.isEmpty()) {
		_newPasscode.setFocus();
		_newPasscode.showError();
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
		return;
	}
	if (pwd != conf) {
		_reenterPasscode.selectAll();
		_reenterPasscode.setFocus();
		_reenterPasscode.showError();
		if (!conf.isEmpty()) {
			_newError = lang(_cloudPwd ? lng_cloud_password_differ : lng_passcode_differ);
			update();
		}
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
	} else if (!_turningOff && has && old == pwd) {
		_newPasscode.setFocus();
		_newPasscode.showError();
		_newError = lang(_cloudPwd ? lng_cloud_password_is_same : lng_passcode_is_same);
		update();
		if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
	} else if (_cloudPwd) {
		QString hint = _passwordHint.getLastText(), email = _recoverEmail.getLastText().trimmed();
		if (_cloudPwd && pwd == hint && !_passwordHint.isHidden() && !_newPasscode.isHidden()) {
			_newPasscode.setFocus();
			_newPasscode.showError();
			_newError = lang(lng_cloud_password_bad);
			update();
			if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
			return;
		}
		if (!_recoverEmail.isHidden() && email.isEmpty() && !force) {
			_skipEmailWarning = true;
			_replacedBy = new ConfirmBox(lang(lng_cloud_password_about_recover), lang(lng_cloud_password_skip_email), st::attentionBoxButton);
			connect(_replacedBy, SIGNAL(confirmed()), this, SLOT(onForceNoMail()));
			connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*)));
			Ui::showLayer(_replacedBy, KeepOtherLayers);
		} else {