Example #1
0
void ApiWrap::requestFullPeer(PeerData *peer) {
	if (!peer || _fullPeerRequests.contains(peer)) return;

	mtpRequestId req;
	if (peer->chat) {
		req = MTP::send(MTPmessages_GetFullChat(MTP_int(App::chatFromPeer(peer->id))), rpcDone(&ApiWrap::gotChatFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	} else {
		req = MTP::send(MTPusers_GetFullUser(peer->asUser()->inputUser), rpcDone(&ApiWrap::gotUserFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	}
	_fullPeerRequests.insert(peer, req);
}
Example #2
0
void ApiWrap::requestFullPeer(PeerData *peer) {
	if (!peer || _fullPeerRequests.contains(peer)) return;

	mtpRequestId req = 0;
	if (peer->isUser()) {
		req = MTP::send(MTPusers_GetFullUser(peer->asUser()->inputUser), rpcDone(&ApiWrap::gotUserFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	} else if (peer->isChat()) {
		req = MTP::send(MTPmessages_GetFullChat(peer->asChat()->inputChat), rpcDone(&ApiWrap::gotChatFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	} else if (peer->isChannel()) {
		req = MTP::send(MTPchannels_GetFullChannel(peer->asChannel()->inputChannel), rpcDone(&ApiWrap::gotChatFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	}
	if (req) _fullPeerRequests.insert(peer, req);
}
Example #3
0
void PhoneWidget::submit() {
	if (_sentRequest || isHidden()) return;

	const auto phone = fullNumber();
	if (!AllowPhoneAttempt(phone)) {
		showPhoneError(langFactory(lng_bad_phone));
		_phone->setFocus();
		return;
	}

	hidePhoneError();

	_checkRequest->start(1000);

	_sentPhone = phone;
	Core::App().mtp()->setUserPhone(_sentPhone);
	//_sentRequest = MTP::send(MTPauth_CheckPhone(MTP_string(_sentPhone)), rpcDone(&PhoneWidget::phoneCheckDone), rpcFail(&PhoneWidget::phoneSubmitFail));
	_sentRequest = MTP::send(
		MTPauth_SendCode(
			MTP_string(_sentPhone),
			MTP_int(ApiId),
			MTP_string(ApiHash),
			MTP_codeSettings(
				MTP_flags(0),
				MTPstring())),
		rpcDone(&PhoneWidget::phoneSubmitDone),
		rpcFail(&PhoneWidget::phoneSubmitFail));
}
Example #4
0
void ApiWrap::resolveWebPages() {
	QVector<MTPint> ids;
	const WebPageItems &items(App::webPageItems());
	ids.reserve(_webPagesPending.size());
	int32 t = unixtime(), m = INT_MAX;
	for (WebPagesPending::const_iterator i = _webPagesPending.cbegin(), e = _webPagesPending.cend(); i != e; ++i) {
		if (i.value()) continue;
		if (i.key()->pendingTill <= t) {
			WebPageItems::const_iterator j = items.constFind(i.key());
			if (j != items.cend() && !j.value().isEmpty()) {
				ids.push_back(MTP_int(j.value().begin().key()->id));
			}
		} else {
			m = qMin(m, i.key()->pendingTill - t);
		}
	}
	if (!ids.isEmpty()) {
		mtpRequestId req = MTP::send(MTPmessages_GetMessages(MTP_vector<MTPint>(ids)), rpcDone(&ApiWrap::gotWebPages));
		for (WebPagesPending::iterator i = _webPagesPending.begin(); i != _webPagesPending.cend(); ++i) {
			if (i.value()) continue;
			if (i.key()->pendingTill <= t) {
				i.value() = req;
			}
		}
	}
	if (m < INT_MAX) _webPagesTimer.start(m * 1000);
}
Example #5
0
void ApiWrap::requestPeers(const QList<PeerData*> &peers) {
	QVector<MTPint> chats;
	QVector<MTPInputUser> users;
	chats.reserve(peers.size());
	users.reserve(peers.size());
	for (QList<PeerData*>::const_iterator i = peers.cbegin(), e = peers.cend(); i != e; ++i) {
		if (!*i || _fullPeerRequests.contains(*i) || _peerRequests.contains(*i)) continue;
		if ((*i)->chat) {
			chats.push_back(MTP_int(App::chatFromPeer((*i)->id)));
		} else {
			users.push_back((*i)->asUser()->inputUser);
		}
	}
	if (!chats.isEmpty()) MTP::send(MTPmessages_GetChats(MTP_vector<MTPint>(chats)), rpcDone(&ApiWrap::gotChats));
	if (!users.isEmpty()) MTP::send(MTPusers_GetUsers(MTP_vector<MTPInputUser>(users)), rpcDone(&ApiWrap::gotUsers));
}
Example #6
0
void PhoneWidget::submit() {
	if (_sentRequest || isHidden()) return;

	if (!App::isValidPhone(fullNumber())) {
		showPhoneError(langFactory(lng_bad_phone));
		_phone->setFocus();
		return;
	}

	hidePhoneError();

	_checkRequest->start(1000);

	_sentPhone = fullNumber();
	Messenger::Instance().mtp()->setUserPhone(_sentPhone);
	//_sentRequest = MTP::send(MTPauth_CheckPhone(MTP_string(_sentPhone)), rpcDone(&PhoneWidget::phoneCheckDone), rpcFail(&PhoneWidget::phoneSubmitFail));
	_sentRequest = MTP::send(
		MTPauth_SendCode(
			MTP_flags(0),
			MTP_string(_sentPhone),
			MTPBool(),
			MTP_int(ApiId),
			MTP_string(ApiHash)),
		rpcDone(&PhoneWidget::phoneSubmitDone),
		rpcFail(&PhoneWidget::phoneSubmitFail));
}
Example #7
0
void SessionsBox::onAllTerminated() {
	MTP::send(MTPaccount_GetAuthorizations(), rpcDone(&SessionsBox::gotAuthorizations));
	if (_shortPollRequest) {
		MTP::cancel(_shortPollRequest);
		_shortPollRequest = 0;
	}
}
Example #8
0
void ApiWrap::resolveReplyTo() {
	if (_replyToRequests.isEmpty() && _channelReplyToRequests.isEmpty()) return;

	MessageIds ids = collectMessageIds(_replyToRequests);
	if (!ids.isEmpty()) {
		mtpRequestId req = MTP::send(MTPmessages_GetMessages(MTP_vector<MTPint>(ids)), rpcDone(&ApiWrap::gotReplyTo, (ChannelData*)0), RPCFailHandlerPtr(), 0, 5);
		for (ReplyToRequests::iterator i = _replyToRequests.begin(); i != _replyToRequests.cend(); ++i) {
			if (i.value().req > 0) continue;
			i.value().req = req;
		}
	}
	for (ChannelReplyToRequests::iterator j = _channelReplyToRequests.begin(); j != _channelReplyToRequests.cend();) {
		if (j->isEmpty()) {
			j = _channelReplyToRequests.erase(j);
			continue;
		}
		MessageIds ids = collectMessageIds(j.value());
		if (!ids.isEmpty()) {
			mtpRequestId req = MTP::send(MTPchannels_GetMessages(j.key()->inputChannel, MTP_vector<MTPint>(ids)), rpcDone(&ApiWrap::gotReplyTo, j.key()), RPCFailHandlerPtr(), 0, 5);
			for (ReplyToRequests::iterator i = j->begin(); i != j->cend(); ++i) {
				if (i.value().req > 0) continue;
				i.value().req = req;
			}
		}
		++j;
	}
}
Example #9
0
IntroWidget::IntroWidget(QWidget *parent) : TWidget(parent)
, _a_stage(animation(this, &IntroWidget::step_stage))
, _a_show(animation(this, &IntroWidget::step_show))
, _back(this, st::setClose) {
	setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight));

	connect(&_back, SIGNAL(clicked()), this, SLOT(onBack()));
	_back.hide();

	_countryForReg = psCurrentCountry();

	MTP::send(MTPhelp_GetNearestDc(), rpcDone(&IntroWidget::gotNearestDC));

	_stepHistory.push_back(new IntroStart(this));
	_back.raise();

	connect(parent, SIGNAL(resized(const QSize&)), this, SLOT(onParentResize(const QSize&)));

	show();
	setFocus();

	cSetPasswordRecovered(false);

	_back.move(st::setClosePos.x(), st::setClosePos.y());

#ifndef TDESKTOP_DISABLE_AUTOUPDATE
	Sandbox::startUpdateCheck();
#endif
}
Example #10
0
void MTProtoConfigLoader::load() {
	if (loadingConfig) return;
	loadingConfig = true;

	MTP::send(MTPhelp_GetConfig(), rpcDone(configLoaded), rpcFail(configFailed));

	_enumDCTimer.start(MTPEnumDCTimeout);
}
Example #11
0
void ConfirmPhoneBox::onCallStatusTimer() {
	if (_callStatus.state == CallState::Waiting) {
		if (--_callStatus.timeout <= 0) {
			_callStatus.state = CallState::Calling;
			_callTimer->stop();
			MTP::send(MTPauth_ResendCode(MTP_string(_phone), MTP_string(_phoneHash)), rpcDone(&ConfirmPhoneBox::callDone));
		}
	}
	update();
}
Example #12
0
void UsernameBox::onCheck() {
	if (_checkRequest) {
		MTP::cancel(_checkRequest);
	}
	QString name = getName();
	if (name.size() >= MinUsernameLength) {
		_checkUsername = getName();
		_checkRequest = MTP::send(MTPaccount_CheckUsername(MTP_string(name)), rpcDone(&UsernameBox::onCheckDone), rpcFail(&UsernameBox::onCheckFail));
	}
}
Example #13
0
BackgroundInner::BackgroundInner() :
_bgCount(0), _rows(0), _over(-1), _overDown(-1) {
	if (App::cServerBackgrounds().isEmpty()) {
		resize(BackgroundsInRow * (st::backgroundSize.width() + st::backgroundPadding) + st::backgroundPadding, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
		MTP::send(MTPaccount_GetWallPapers(), rpcDone(&BackgroundInner::gotWallpapers));
	} else {
		updateWallpapers();
	}
	setMouseTracking(true);
}
Example #14
0
StickerSetInner::StickerSetInner(const MTPInputStickerSet &set) :
_loaded(false), _setId(0), _setAccess(0), _setCount(0), _setHash(0), _setFlags(0), _bottom(0),
_input(set), _installRequest(0), _panel(0) {
	switch (set.type()) {
	case mtpc_inputStickerSetID: _setId = set.c_inputStickerSetID().vid.v; _setAccess = set.c_inputStickerSetID().vaccess_hash.v; break;
	case mtpc_inputStickerSetShortName: _setShortName = qs(set.c_inputStickerSetShortName().vshort_name); break;
	}
	MTP::send(MTPmessages_GetStickerSet(_input), rpcDone(&StickerSetInner::gotSet), rpcFail(&StickerSetInner::failedSet));
	cSetLastStickersUpdate(0);
	App::main()->updateStickers();
}
Example #15
0
void SessionsBox::Inner::onTerminateAll() {
	if (_terminateBox) _terminateBox->deleteLater();
	_terminateBox = Ui::show(Box<ConfirmBox>(lang(lng_settings_reset_sure), lang(lng_settings_reset_button), st::attentionBoxButton, base::lambda_guarded(this, [this] {
		if (_terminateBox) {
			_terminateBox->closeBox();
			_terminateBox = nullptr;
		}
		MTP::send(MTPauth_ResetAuthorizations(), rpcDone(&Inner::terminateAllDone), rpcFail(&Inner::terminateAllFail));
		emit terminateAll();
	})), LayerOption::KeepOther);
}
Example #16
0
void mtpLogoutOtherDCs() {
	QList<int32> dcs;
	{
		QMutexLocker lock(&_keysMapForWriteMutex);
		dcs = _keysMapForWrite.keys();
	}
	for (int32 i = 0, cnt = dcs.size(); i != cnt; ++i) {
		if (dcs[i] != MTP::maindc()) {
			logoutGuestMap.insert(MTP::lgt + dcs[i], MTP::send(MTPauth_LogOut(), rpcDone(&logoutDone), rpcFail(&logoutDone), MTP::lgt + dcs[i]));
		}
	}
}
Example #17
0
void IntroPwdCheck::onSubmitPwd(bool force) {
	if (sentRequest) return;
	if (_pwdField.isHidden()) {
		if (!force && !_codeField.isEnabled()) return;
		QString code = _codeField.text().trimmed();
		if (code.isEmpty()) {
			_codeField.notaBene();
			return;
		}

		sentRequest = MTP::send(MTPauth_RecoverPassword(MTP_string(code)), rpcDone(&IntroPwdCheck::pwdSubmitDone, true), rpcFail(&IntroPwdCheck::codeSubmitFail));
	} else {
		if (!force && !_pwdField.isEnabled()) return;

		_pwdField.setDisabled(true);
		setFocus();

		showError("");

		QByteArray pwdData = _salt + _pwdField.text().toUtf8() + _salt, pwdHash(32, Qt::Uninitialized);
		hashSha256(pwdData.constData(), pwdData.size(), pwdHash.data());
		sentRequest = MTP::send(MTPauth_CheckPassword(MTP_string(pwdHash)), rpcDone(&IntroPwdCheck::pwdSubmitDone, false), rpcFail(&IntroPwdCheck::pwdSubmitFail));
	}
}
Example #18
0
void PhoneWidget::submit() {
	if (_sentRequest || isHidden()) return;

	if (!App::isValidPhone(fullNumber())) {
		showPhoneError(langFactory(lng_bad_phone));
		_phone->setFocus();
		return;
	}

	hidePhoneError();

	_checkRequest->start(1000);

	_sentPhone = fullNumber();
	_sentRequest = MTP::send(MTPauth_CheckPhone(MTP_string(_sentPhone)), rpcDone(&PhoneWidget::phoneCheckDone), rpcFail(&PhoneWidget::phoneSubmitFail));
}
Example #19
0
void IntroPhone::onSubmitPhone() {
	if (sentRequest || isHidden()) return;

	if (!App::isValidPhone(fullNumber())) {
		showError(lang(lng_bad_phone));
		phone.setFocus();
		return;
	}

	disableAll();
	showError(QString());

	checkRequest.start(1000);

	sentPhone = fullNumber();
	sentRequest = MTP::send(MTPauth_CheckPhone(MTP_string(sentPhone)), rpcDone(&IntroPhone::phoneCheckDone), rpcFail(&IntroPhone::phoneSubmitFail));
}
Example #20
0
void ApiWrap::resolveReplyTo() {
	if (_replyToRequests.isEmpty()) return;

	QVector<MTPint> ids;
	ids.reserve(_replyToRequests.size());
	for (ReplyToRequests::const_iterator i = _replyToRequests.cbegin(), e = _replyToRequests.cend(); i != e; ++i) {
		if (!i.value().req) {
			ids.push_back(MTP_int(i.key()));
		}
	}
	if (!ids.isEmpty()) {
		mtpRequestId req = MTP::send(MTPmessages_GetMessages(MTP_vector<MTPint>(ids)), rpcDone(&ApiWrap::gotReplyTo));
		for (ReplyToRequests::iterator i = _replyToRequests.begin(), e = _replyToRequests.end(); i != e; ++i) {
			i.value().req = req;
		}
	}
}
Example #21
0
IntroWidget::IntroWidget(Window *window) : QWidget(window),
	wnd(window), cacheForHideInd(0), cacheForShowInd(0), _callTimeout(60),
	steps(new IntroSteps(this)), phone(0), code(0), signup(0), current(0), moving(0), visibilityChanging(0) {
	setGeometry(QRect(0, st::titleHeight, wnd->width(), wnd->height() - st::titleHeight));

	countryForReg = psCurrentCountry();

	MTP::send(MTPhelp_GetNearestDc(), rpcDone(gotNearestDC));
	signalEmitOn = this;

	stages[0] = steps;
	memset(stages + 1, 0, sizeof(QWidget*) * 3);

	connect(window, SIGNAL(resized(const QSize &)), this, SLOT(onParentResize(const QSize &)));

	show();
	setFocus();
}
Example #22
0
void SessionsBox::Inner::onTerminate() {
	for (auto i = _terminateButtons.begin(), e = _terminateButtons.end(); i != e; ++i) {
		if (i.value()->isOver()) {
			if (_terminateBox) _terminateBox->deleteLater();
			_terminateBox = Ui::show(Box<ConfirmBox>(lang(lng_settings_reset_one_sure), lang(lng_settings_reset_button), st::attentionBoxButton, base::lambda_guarded(this, [this, terminating = i.key()] {
				if (_terminateBox) {
					_terminateBox->closeBox();
					_terminateBox = nullptr;
				}
				MTP::send(MTPaccount_ResetAuthorization(MTP_long(terminating)), rpcDone(&Inner::terminateDone, terminating), rpcFail(&Inner::terminateFail, terminating));
				auto i = _terminateButtons.find(terminating);
				if (i != _terminateButtons.cend()) {
					i.value()->clearState();
					i.value()->hide();
				}
			})), LayerOption::KeepOther);
		}
	}
}
Example #23
0
IntroWidget::IntroWidget(Window *window) : TWidget(window)
, _langChangeTo(0)
, _a_stage(animation(this, &IntroWidget::step_stage))
, _cacheHideIndex(0)
, _cacheShowIndex(0)
, _a_show(animation(this, &IntroWidget::step_show))
, steps(new IntroSteps(this))
, phone(0)
, code(0)
, signup(0)
, pwdcheck(0)
, current(0)
, moving(0)
, _callTimeout(60)
, _registered(false)
, _hasRecovery(false)
, _codeByTelegram(false)
, _back(this, st::setClose)
, _backFrom(0)
, _backTo(0) {
	setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight));

	connect(&_back, SIGNAL(clicked()), this, SLOT(onIntroBack()));
	_back.hide();

	countryForReg = psCurrentCountry();

	MTP::send(MTPhelp_GetNearestDc(), rpcDone(gotNearestDC));
	signalEmitOn = this;

	stages[0] = steps;
	memset(stages + 1, 0, sizeof(QWidget*) * 3);
	_back.raise();

	connect(window, SIGNAL(resized(const QSize&)), this, SLOT(onParentResize(const QSize&)));

	show();
	setFocus();

	cSetPasswordRecovered(false);

	_back.move(st::setClosePos.x(), st::setClosePos.y());
}
Example #24
0
void SessionsBox::prepare() {
	setTitle(langFactory(lng_sessions_other_header));

	addButton(langFactory(lng_close), [this] { closeBox(); });

	setDimensions(st::boxWideWidth, st::sessionsHeight);

	connect(_inner, SIGNAL(oneTerminated()), this, SLOT(onOneTerminated()));
	connect(_inner, SIGNAL(allTerminated()), this, SLOT(onAllTerminated()));
	connect(_inner, SIGNAL(terminateAll()), this, SLOT(onTerminateAll()));
	connect(App::wnd(), SIGNAL(checkNewAuthorization()), this, SLOT(onCheckNewAuthorization()));
	connect(_shortPollTimer, SIGNAL(timeout()), this, SLOT(onShortPollAuthorizations()));

	_inner = setInnerWidget(object_ptr<Inner>(this, &_list, &_current), st::sessionsScroll);
	_inner->resize(width(), st::noContactsHeight);

	setLoading(true);

	MTP::send(MTPaccount_GetAuthorizations(), rpcDone(&SessionsBox::gotAuthorizations));
}
Example #25
0
void SettingsInner::peerUpdated(PeerData *data) {
	if (_self && data == _self) {
		if (_self->photoId) {
			PhotoData *selfPhoto = App::photo(_self->photoId);
			if (selfPhoto->date) {
				_photoLink = TextLinkPtr(new PhotoLink(selfPhoto));
			} else {
				_photoLink = TextLinkPtr();
				MTP::send(MTPusers_GetFullUser(_self->inputUser), rpcDone(&SettingsInner::gotFullSelf));
			}
		} else {
			_photoLink = TextLinkPtr();
		}

		if (_nameCache != _self->name) {
			_nameCache = _self->name;
			_nameText.setText(st::setNameFont, _nameCache, _textNameOptions);
			update();
		}
	}
}
Example #26
0
void ChangePhoneBox::EnterCode::submit() {
	if (_requestId) {
		return;
	}
	hideError();

	const auto code = _code->getDigitsOnly();
	_requestId = MTP::send(MTPaccount_ChangePhone(
		MTP_string(_phone),
		MTP_string(_hash),
		MTP_string(code)
	), rpcDone([weak = make_weak(this)](const MTPUser &result) {
		App::feedUser(result);
		if (weak) {
			Ui::hideLayer();
		}
		Ui::Toast::Show(lang(lng_change_phone_success));
	}), rpcFail(crl::guard(this, [this](const RPCError &error) {
		return sendCodeFail(error);
	})));
}
Example #27
0
void MTProtoConfigLoader::enumDC() {
	if (!loadingConfig) return;

	if (_enumRequest) MTP::cancel(_enumRequest);

	if (!_enumCurrent) {
		_enumCurrent = mainDC;
	} else {
		MTP::killSession(MTP::cfg + _enumCurrent);
	}
	const mtpDcOptions &options(cDcOptions());
	for (mtpDcOptions::const_iterator i = options.cbegin(), e = options.cend(); i != e; ++i) {
		if (i.key() == _enumCurrent) {
			_enumCurrent = (++i == e) ? options.cbegin().key() : i.key();
			break;
		}
	}

	_enumRequest = MTP::send(MTPhelp_GetConfig(), rpcDone(configLoaded), rpcFail(configFailed), MTP::cfg + _enumCurrent);

	_enumDCTimer.start(MTPEnumDCTimeout);
}
Example #28
0
bool mtpFileLoader::loadPart() {
	if (complete || requestId) return false;

	int32 limit = DocumentDownloadPartSize;
	MTPInputFileLocation loc;
	switch (locationType) {
	case 0: loc = MTP_inputFileLocation(MTP_long(volume), MTP_int(local), MTP_long(secret)); limit = DownloadPartSize; break;
	case mtpc_inputVideoFileLocation: loc = MTP_inputVideoFileLocation(MTP_long(id), MTP_long(access)); break;
	case mtpc_inputAudioFileLocation: loc = MTP_inputAudioFileLocation(MTP_long(id), MTP_long(access)); break;
	case mtpc_inputDocumentFileLocation: loc = MTP_inputDocumentFileLocation(MTP_long(id), MTP_long(access)); break;
	default:
		finishFail();
		return false;
	break;
	}

	++queue->queries;
	int32 offset = currentOffset();
	MTPupload_GetFile request(MTPupload_getFile(loc, MTP_int(offset), MTP_int(limit)));
	requestId = MTP::send(request, rpcDone(&mtpFileLoader::partLoaded, offset), rpcFail(&mtpFileLoader::partFailed), MTP::dld + dc, 50);
	return true;
}
Example #29
0
void IntroPwdCheck::onToRecover() {
	if (_hasRecovery) {
		if (sentRequest) {
			MTP::cancel(sentRequest);
			sentRequest = 0;
		}
		showError("");
		_toRecover.hide();
		_toPassword.show();
		_pwdField.hide();
		_pwdField.setText(QString());
		_codeField.show();
		_codeField.setFocus();
		if (_emailPattern.isEmpty()) {
			MTP::send(MTPauth_RequestPasswordRecovery(), rpcDone(&IntroPwdCheck::recoverStarted), rpcFail(&IntroPwdCheck::recoverStartFail));
		}
		update();
	} else {
		ConfirmBox *box = new InformBox(lang(lng_signin_no_email_forgot));
		App::wnd()->showLayer(box);
		connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onToReset()));
	}
}
Example #30
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;
}