mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
parent
31ec831c71
commit
35659536c5
6 changed files with 38 additions and 48 deletions
|
@ -417,8 +417,9 @@ public:
|
||||||
if (range.first == range.second) {
|
if (range.first == range.second) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
const auto result = (range.second - range.first);
|
||||||
impl().erase(range.first, range.second);
|
impl().erase(range.first, range.second);
|
||||||
return (range.second - range.first);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator erase(const_iterator where) {
|
iterator erase(const_iterator where) {
|
||||||
|
|
|
@ -297,8 +297,9 @@ public:
|
||||||
if (range.first == range.second) {
|
if (range.first == range.second) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
const auto result = (range.second - range.first);
|
||||||
impl().erase(range.first, range.second);
|
impl().erase(range.first, range.second);
|
||||||
return (range.second - range.first);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator erase(const_iterator where) {
|
iterator erase(const_iterator where) {
|
||||||
|
|
|
@ -128,9 +128,11 @@ void MainWindow::firstShow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::clearWidgetsHook() {
|
void MainWindow::clearWidgetsHook() {
|
||||||
|
Expects(_passcodeLock == nullptr || !Global::LocalPasscode());
|
||||||
|
|
||||||
auto wasMain = (_main != nullptr);
|
auto wasMain = (_main != nullptr);
|
||||||
_passcodeLock.destroy();
|
|
||||||
_main.destroy();
|
_main.destroy();
|
||||||
|
_passcodeLock.destroy();
|
||||||
_intro.destroy();
|
_intro.destroy();
|
||||||
if (wasMain) {
|
if (wasMain) {
|
||||||
App::clearHistories();
|
App::clearHistories();
|
||||||
|
@ -177,18 +179,20 @@ void MainWindow::clearPasscodeLock() {
|
||||||
_passcodeLock.destroy();
|
_passcodeLock.destroy();
|
||||||
if (_intro) {
|
if (_intro) {
|
||||||
_intro->showAnimated(bg, true);
|
_intro->showAnimated(bg, true);
|
||||||
} else {
|
} else if (_main) {
|
||||||
Assert(_main != nullptr);
|
|
||||||
_main->showAnimated(bg, true);
|
_main->showAnimated(bg, true);
|
||||||
Messenger::Instance().checkStartUrl();
|
Messenger::Instance().checkStartUrl();
|
||||||
|
} else {
|
||||||
|
Messenger::Instance().startMtp();
|
||||||
|
if (AuthSession::Exists()) {
|
||||||
|
setupMain();
|
||||||
|
} else {
|
||||||
|
setupIntro();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupIntro() {
|
void MainWindow::setupIntro() {
|
||||||
if (_intro && !_intro->isHidden() && !_main) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ui::hideSettingsAndLayer(anim::type::instant);
|
Ui::hideSettingsAndLayer(anim::type::instant);
|
||||||
|
|
||||||
auto animated = (_main || _passcodeLock);
|
auto animated = (_main || _passcodeLock);
|
||||||
|
@ -273,13 +277,13 @@ void MainWindow::sendServiceHistoryRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupMain(const MTPUser *self) {
|
void MainWindow::setupMain(const MTPUser *self) {
|
||||||
|
Expects(AuthSession::Exists());
|
||||||
|
|
||||||
auto animated = (_intro || _passcodeLock);
|
auto animated = (_intro || _passcodeLock);
|
||||||
auto bg = animated ? grabInner() : QPixmap();
|
auto bg = animated ? grabInner() : QPixmap();
|
||||||
|
|
||||||
clearWidgets();
|
clearWidgets();
|
||||||
|
|
||||||
Assert(AuthSession::Exists());
|
|
||||||
|
|
||||||
_main.create(bodyWidget(), controller());
|
_main.create(bodyWidget(), controller());
|
||||||
_main->show();
|
_main->show();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
|
|
@ -151,24 +151,19 @@ Messenger::Messenger(not_null<Core::Launcher*> launcher)
|
||||||
if (state == Local::ReadMapPassNeeded) {
|
if (state == Local::ReadMapPassNeeded) {
|
||||||
Global::SetLocalPasscode(true);
|
Global::SetLocalPasscode(true);
|
||||||
Global::RefLocalPasscodeChanged().notify();
|
Global::RefLocalPasscodeChanged().notify();
|
||||||
|
lockByPasscode();
|
||||||
DEBUG_LOG(("Application Info: passcode needed..."));
|
DEBUG_LOG(("Application Info: passcode needed..."));
|
||||||
} else {
|
} else {
|
||||||
DEBUG_LOG(("Application Info: local map read..."));
|
DEBUG_LOG(("Application Info: local map read..."));
|
||||||
startMtp();
|
startMtp();
|
||||||
}
|
DEBUG_LOG(("Application Info: MTP started..."));
|
||||||
|
|
||||||
DEBUG_LOG(("Application Info: MTP started..."));
|
|
||||||
|
|
||||||
DEBUG_LOG(("Application Info: showing."));
|
|
||||||
if (state == Local::ReadMapPassNeeded) {
|
|
||||||
lockByPasscode();
|
|
||||||
} else {
|
|
||||||
if (AuthSession::Exists()) {
|
if (AuthSession::Exists()) {
|
||||||
_window->setupMain();
|
_window->setupMain();
|
||||||
} else {
|
} else {
|
||||||
_window->setupIntro();
|
_window->setupIntro();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DEBUG_LOG(("Application Info: showing."));
|
||||||
_window->firstShow();
|
_window->firstShow();
|
||||||
|
|
||||||
if (cStartToSettings()) {
|
if (cStartToSettings()) {
|
||||||
|
@ -1037,8 +1032,12 @@ void Messenger::lockByPasscode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Messenger::unlockPasscode() {
|
void Messenger::unlockPasscode() {
|
||||||
cSetPasscodeBadTries(0);
|
clearPasscodeLock();
|
||||||
_window->clearPasscodeLock();
|
_window->clearPasscodeLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Messenger::clearPasscodeLock() {
|
||||||
|
cSetPasscodeBadTries(0);
|
||||||
_passcodeLock = false;
|
_passcodeLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,6 +1201,7 @@ void Messenger::loggedOut() {
|
||||||
Global::SetLocalPasscode(false);
|
Global::SetLocalPasscode(false);
|
||||||
Global::RefLocalPasscodeChanged().notify();
|
Global::RefLocalPasscodeChanged().notify();
|
||||||
}
|
}
|
||||||
|
clearPasscodeLock();
|
||||||
Media::Player::mixer()->stopAndClear();
|
Media::Player::mixer()->stopAndClear();
|
||||||
if (const auto w = getActiveWindow()) {
|
if (const auto w = getActiveWindow()) {
|
||||||
w->tempDirDelete(Local::ClearManagerAll);
|
w->tempDirDelete(Local::ClearManagerAll);
|
||||||
|
|
|
@ -233,6 +233,7 @@ private:
|
||||||
void photoUpdated(const FullMsgId &msgId, const MTPInputFile &file);
|
void photoUpdated(const FullMsgId &msgId, const MTPInputFile &file);
|
||||||
void resetAuthorizationKeys();
|
void resetAuthorizationKeys();
|
||||||
void authSessionDestroy();
|
void authSessionDestroy();
|
||||||
|
void clearPasscodeLock();
|
||||||
void loggedOut();
|
void loggedOut();
|
||||||
|
|
||||||
not_null<Core::Launcher*> _launcher;
|
not_null<Core::Launcher*> _launcher;
|
||||||
|
|
|
@ -132,35 +132,18 @@ void PasscodeLockWidget::submit() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App::main()) {
|
const auto passcode = _passcode->text().toUtf8();
|
||||||
if (Local::checkPasscode(_passcode->text().toUtf8())) {
|
const auto correct = App::main()
|
||||||
Messenger::Instance().unlockPasscode(); // Destroys this widget.
|
? Local::checkPasscode(passcode)
|
||||||
return;
|
: (Local::readMap(passcode) != Local::ReadMapPassNeeded);
|
||||||
} else {
|
if (!correct) {
|
||||||
cSetPasscodeBadTries(cPasscodeBadTries() + 1);
|
cSetPasscodeBadTries(cPasscodeBadTries() + 1);
|
||||||
cSetPasscodeLastTry(getms(true));
|
cSetPasscodeLastTry(getms(true));
|
||||||
error();
|
error();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (Local::readMap(_passcode->text().toUtf8()) != Local::ReadMapPassNeeded) {
|
|
||||||
cSetPasscodeBadTries(0);
|
|
||||||
|
|
||||||
Messenger::Instance().startMtp();
|
|
||||||
|
|
||||||
// Destroys this widget.
|
|
||||||
if (AuthSession::Exists()) {
|
|
||||||
App::wnd()->setupMain();
|
|
||||||
} else {
|
|
||||||
App::wnd()->setupIntro();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cSetPasscodeBadTries(cPasscodeBadTries() + 1);
|
|
||||||
cSetPasscodeLastTry(getms(true));
|
|
||||||
error();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Messenger::Instance().unlockPasscode(); // Destroys this widget.
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasscodeLockWidget::error() {
|
void PasscodeLockWidget::error() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue