mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Removed LocalPasscode global variable from facades.
This commit is contained in:
parent
7852c82eab
commit
54dd63d61a
13 changed files with 74 additions and 51 deletions
|
@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "passport/passport_encryption.h"
|
#include "passport/passport_encryption.h"
|
||||||
#include "passport/passport_panel_edit_contact.h"
|
#include "passport/passport_panel_edit_contact.h"
|
||||||
#include "settings/settings_privacy_security.h"
|
#include "settings/settings_privacy_security.h"
|
||||||
#include "facades.h"
|
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_passport.h"
|
#include "styles/style_passport.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
@ -119,7 +118,12 @@ PasscodeBox::PasscodeBox(
|
||||||
, _turningOff(turningOff)
|
, _turningOff(turningOff)
|
||||||
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
|
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
|
||||||
, _oldPasscode(this, st::defaultInputField, tr::lng_passcode_enter_old())
|
, _oldPasscode(this, st::defaultInputField, tr::lng_passcode_enter_old())
|
||||||
, _newPasscode(this, st::defaultInputField, Global::LocalPasscode() ? tr::lng_passcode_enter_new() : tr::lng_passcode_enter_first())
|
, _newPasscode(
|
||||||
|
this,
|
||||||
|
st::defaultInputField,
|
||||||
|
session->domain().local().hasLocalPasscode()
|
||||||
|
? tr::lng_passcode_enter_new()
|
||||||
|
: tr::lng_passcode_enter_first())
|
||||||
, _reenterPasscode(this, st::defaultInputField, tr::lng_passcode_confirm_new())
|
, _reenterPasscode(this, st::defaultInputField, tr::lng_passcode_confirm_new())
|
||||||
, _passwordHint(this, st::defaultInputField, tr::lng_cloud_password_hint())
|
, _passwordHint(this, st::defaultInputField, tr::lng_cloud_password_hint())
|
||||||
, _recoverEmail(this, st::defaultInputField, tr::lng_cloud_password_email())
|
, _recoverEmail(this, st::defaultInputField, tr::lng_cloud_password_email())
|
||||||
|
@ -164,7 +168,9 @@ rpl::producer<> PasscodeBox::clearUnconfirmedPassword() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PasscodeBox::currentlyHave() const {
|
bool PasscodeBox::currentlyHave() const {
|
||||||
return _cloudPwd ? (!!_cloudFields.curRequest) : Global::LocalPasscode();
|
return _cloudPwd
|
||||||
|
? (!!_cloudFields.curRequest)
|
||||||
|
: _session->domain().local().hasLocalPasscode();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PasscodeBox::onlyCheckCurrent() const {
|
bool PasscodeBox::onlyCheckCurrent() const {
|
||||||
|
@ -520,7 +526,7 @@ void PasscodeBox::save(bool force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core::App().domain().local().checkPasscode(old.toUtf8())) {
|
if (_session->domain().local().checkPasscode(old.toUtf8())) {
|
||||||
cSetPasscodeBadTries(0);
|
cSetPasscodeBadTries(0);
|
||||||
if (_turningOff) pwd = conf = QString();
|
if (_turningOff) pwd = conf = QString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -588,7 +594,7 @@ void PasscodeBox::save(bool force) {
|
||||||
closeReplacedBy();
|
closeReplacedBy();
|
||||||
const auto weak = Ui::MakeWeak(this);
|
const auto weak = Ui::MakeWeak(this);
|
||||||
cSetPasscodeBadTries(0);
|
cSetPasscodeBadTries(0);
|
||||||
Core::App().domain().local().setPasscode(pwd.toUtf8());
|
_session->domain().local().setPasscode(pwd.toUtf8());
|
||||||
Core::App().localPasscodeChanged();
|
Core::App().localPasscodeChanged();
|
||||||
if (weak) {
|
if (weak) {
|
||||||
closeBox();
|
closeBox();
|
||||||
|
|
|
@ -321,8 +321,6 @@ void Application::startDomain() {
|
||||||
startSettingsAndBackground();
|
startSettingsAndBackground();
|
||||||
}
|
}
|
||||||
if (state != Storage::StartResult::Success) {
|
if (state != Storage::StartResult::Success) {
|
||||||
Global::SetLocalPasscode(true);
|
|
||||||
Global::RefLocalPasscodeChanged().notify();
|
|
||||||
lockByPasscode();
|
lockByPasscode();
|
||||||
DEBUG_LOG(("Application Info: passcode needed..."));
|
DEBUG_LOG(("Application Info: passcode needed..."));
|
||||||
}
|
}
|
||||||
|
@ -910,7 +908,7 @@ bool Application::someSessionExists() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::checkAutoLock() {
|
void Application::checkAutoLock() {
|
||||||
if (!Global::LocalPasscode()
|
if (!_domain->local().hasLocalPasscode()
|
||||||
|| passcodeLocked()
|
|| passcodeLocked()
|
||||||
|| !someSessionExists()) {
|
|| !someSessionExists()) {
|
||||||
_shouldLockAt = 0;
|
_shouldLockAt = 0;
|
||||||
|
@ -1146,7 +1144,7 @@ void Application::startShortcuts() {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
request->check(Command::Lock) && request->handle([=] {
|
request->check(Command::Lock) && request->handle([=] {
|
||||||
if (!passcodeLocked() && Global::LocalPasscode()) {
|
if (!passcodeLocked() && _domain->local().hasLocalPasscode()) {
|
||||||
lockByPasscode();
|
lockByPasscode();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
@ -34,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_main_menu.h"
|
#include "window/window_main_menu.h"
|
||||||
#include "storage/storage_media_prepare.h"
|
#include "storage/storage_media_prepare.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
|
#include "storage/storage_domain.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
|
@ -268,8 +270,13 @@ Widget::Widget(
|
||||||
_cancelSearch->setClickedCallback([this] { onCancelSearch(); });
|
_cancelSearch->setClickedCallback([this] { onCancelSearch(); });
|
||||||
_jumpToDate->entity()->setClickedCallback([this] { showJumpToDate(); });
|
_jumpToDate->entity()->setClickedCallback([this] { showJumpToDate(); });
|
||||||
_chooseFromUser->entity()->setClickedCallback([this] { showSearchFrom(); });
|
_chooseFromUser->entity()->setClickedCallback([this] { showSearchFrom(); });
|
||||||
_lockUnlock->setVisible(Global::LocalPasscode());
|
rpl::single(
|
||||||
subscribe(Global::RefLocalPasscodeChanged(), [this] { updateLockUnlockVisibility(); });
|
rpl::empty_value()
|
||||||
|
) | rpl::then(
|
||||||
|
session().domain().local().localPasscodeChanged()
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
updateLockUnlockVisibility();
|
||||||
|
}, lifetime());
|
||||||
_lockUnlock->setClickedCallback([this] {
|
_lockUnlock->setClickedCallback([this] {
|
||||||
_lockUnlock->setIconOverride(&st::dialogsUnlockIcon, &st::dialogsUnlockIconOver);
|
_lockUnlock->setIconOverride(&st::dialogsUnlockIcon, &st::dialogsUnlockIconOver);
|
||||||
Core::App().lockByPasscode();
|
Core::App().lockByPasscode();
|
||||||
|
@ -1502,7 +1509,7 @@ void Widget::updateLockUnlockVisibility() {
|
||||||
if (_a_show.animating()) {
|
if (_a_show.animating()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto hidden = !Global::LocalPasscode();
|
const auto hidden = !session().domain().local().hasLocalPasscode();
|
||||||
if (_lockUnlock->isHidden() != hidden) {
|
if (_lockUnlock->isHidden() != hidden) {
|
||||||
_lockUnlock->setVisible(!hidden);
|
_lockUnlock->setVisible(!hidden);
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
@ -1560,7 +1567,7 @@ void Widget::updateControlsGeometry() {
|
||||||
auto smallLayoutWidth = (st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x());
|
auto smallLayoutWidth = (st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x());
|
||||||
auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.;
|
auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.;
|
||||||
auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x();
|
auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x();
|
||||||
auto filterRight = (Global::LocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();
|
auto filterRight = (_lockUnlock->isVisible() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();
|
||||||
auto filterWidth = qMax(width(), st::columnMinimalWidthLeft) - filterLeft - filterRight;
|
auto filterWidth = qMax(width(), st::columnMinimalWidthLeft) - filterLeft - filterRight;
|
||||||
auto filterAreaHeight = st::topBarHeight;
|
auto filterAreaHeight = st::topBarHeight;
|
||||||
_searchControls->setGeometry(0, filterAreaTop, width(), filterAreaHeight);
|
_searchControls->setGeometry(0, filterAreaTop, width(), filterAreaHeight);
|
||||||
|
|
|
@ -352,9 +352,6 @@ struct Data {
|
||||||
bool UseProxyForCalls = false;
|
bool UseProxyForCalls = false;
|
||||||
base::Observable<void> ConnectionTypeChanged;
|
base::Observable<void> ConnectionTypeChanged;
|
||||||
|
|
||||||
bool LocalPasscode = false;
|
|
||||||
base::Observable<void> LocalPasscodeChanged;
|
|
||||||
|
|
||||||
base::Variable<DBIWorkMode> WorkMode = { dbiwmWindowAndTray };
|
base::Variable<DBIWorkMode> WorkMode = { dbiwmWindowAndTray };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -392,9 +389,6 @@ DefineVar(Global, MTP::ProxyData::Settings, ProxySettings);
|
||||||
DefineVar(Global, bool, UseProxyForCalls);
|
DefineVar(Global, bool, UseProxyForCalls);
|
||||||
DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged);
|
DefineRefVar(Global, base::Observable<void>, ConnectionTypeChanged);
|
||||||
|
|
||||||
DefineVar(Global, bool, LocalPasscode);
|
|
||||||
DefineRefVar(Global, base::Observable<void>, LocalPasscodeChanged);
|
|
||||||
|
|
||||||
DefineRefVar(Global, base::Variable<DBIWorkMode>, WorkMode);
|
DefineRefVar(Global, base::Variable<DBIWorkMode>, WorkMode);
|
||||||
|
|
||||||
} // namespace Global
|
} // namespace Global
|
||||||
|
|
|
@ -124,9 +124,6 @@ DeclareVar(MTP::ProxyData::Settings, ProxySettings);
|
||||||
DeclareVar(bool, UseProxyForCalls);
|
DeclareVar(bool, UseProxyForCalls);
|
||||||
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);
|
DeclareRefVar(base::Observable<void>, ConnectionTypeChanged);
|
||||||
|
|
||||||
DeclareVar(bool, LocalPasscode);
|
|
||||||
DeclareRefVar(base::Observable<void>, LocalPasscodeChanged);
|
|
||||||
|
|
||||||
DeclareRefVar(base::Variable<DBIWorkMode>, WorkMode);
|
DeclareRefVar(base::Variable<DBIWorkMode>, WorkMode);
|
||||||
|
|
||||||
} // namespace Global
|
} // namespace Global
|
||||||
|
|
|
@ -340,7 +340,7 @@ bool Domain::removePasscodeIfEmpty() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Local::reset();
|
Local::reset();
|
||||||
if (!Global::LocalPasscode()) {
|
if (!_local->hasLocalPasscode()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// We completely logged out, remove the passcode if it was there.
|
// We completely logged out, remove the passcode if it was there.
|
||||||
|
|
|
@ -27,8 +27,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/update_checker.h"
|
#include "core/update_checker.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
|
#include "storage/storage_domain.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "mtproto/facade.h"
|
#include "mtproto/facade.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
|
@ -313,7 +315,9 @@ void SetupSpellchecker(
|
||||||
#endif // !TDESKTOP_DISABLE_SPELLCHECK
|
#endif // !TDESKTOP_DISABLE_SPELLCHECK
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSystemIntegrationContent(not_null<Ui::VerticalLayout*> container) {
|
void SetupSystemIntegrationContent(
|
||||||
|
Window::SessionController *controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
const auto checkbox = [&](rpl::producer<QString> &&label, bool checked) {
|
const auto checkbox = [&](rpl::producer<QString> &&label, bool checked) {
|
||||||
return object_ptr<Ui::Checkbox>(
|
return object_ptr<Ui::Checkbox>(
|
||||||
container,
|
container,
|
||||||
|
@ -409,9 +413,10 @@ void SetupSystemIntegrationContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
}, nativeFrame->lifetime());
|
}, nativeFrame->lifetime());
|
||||||
}
|
}
|
||||||
if (Platform::AutostartSupported()) {
|
if (Platform::AutostartSupported() && controller) {
|
||||||
const auto minimizedToggled = [] {
|
const auto minimizedToggled = [=] {
|
||||||
return cStartMinimized() && !Global::LocalPasscode();
|
return cStartMinimized()
|
||||||
|
&& !controller->session().domain().local().hasLocalPasscode();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto autostart = addCheckbox(
|
const auto autostart = addCheckbox(
|
||||||
|
@ -441,7 +446,7 @@ void SetupSystemIntegrationContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
) | rpl::filter([=](bool checked) {
|
) | rpl::filter([=](bool checked) {
|
||||||
return (checked != minimizedToggled());
|
return (checked != minimizedToggled());
|
||||||
}) | rpl::start_with_next([=](bool checked) {
|
}) | rpl::start_with_next([=](bool checked) {
|
||||||
if (Global::LocalPasscode()) {
|
if (controller->session().domain().local().hasLocalPasscode()) {
|
||||||
minimized->entity()->setChecked(false);
|
minimized->entity()->setChecked(false);
|
||||||
Ui::show(Box<InformBox>(
|
Ui::show(Box<InformBox>(
|
||||||
tr::lng_error_start_minimized_passcoded(tr::now)));
|
tr::lng_error_start_minimized_passcoded(tr::now)));
|
||||||
|
@ -451,8 +456,7 @@ void SetupSystemIntegrationContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
}
|
}
|
||||||
}, minimized->lifetime());
|
}, minimized->lifetime());
|
||||||
|
|
||||||
base::ObservableViewer(
|
controller->session().domain().local().localPasscodeChanged(
|
||||||
Global::RefLocalPasscodeChanged()
|
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
minimized->entity()->setChecked(minimizedToggled());
|
minimized->entity()->setChecked(minimizedToggled());
|
||||||
}, minimized->lifetime());
|
}, minimized->lifetime());
|
||||||
|
@ -474,9 +478,11 @@ void SetupSystemIntegrationContent(not_null<Ui::VerticalLayout*> container) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSystemIntegrationOptions(not_null<Ui::VerticalLayout*> container) {
|
void SetupSystemIntegrationOptions(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
auto wrap = object_ptr<Ui::VerticalLayout>(container);
|
||||||
SetupSystemIntegrationContent(wrap.data());
|
SetupSystemIntegrationContent(controller, wrap.data());
|
||||||
if (wrap->count() > 0) {
|
if (wrap->count() > 0) {
|
||||||
container->add(object_ptr<Ui::OverrideMargins>(
|
container->add(object_ptr<Ui::OverrideMargins>(
|
||||||
container,
|
container,
|
||||||
|
@ -544,6 +550,7 @@ void SetupPerformance(
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSystemIntegration(
|
void SetupSystemIntegration(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
Fn<void(Type)> showOther) {
|
Fn<void(Type)> showOther) {
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
|
@ -556,7 +563,7 @@ void SetupSystemIntegration(
|
||||||
)->addClickHandler([=] {
|
)->addClickHandler([=] {
|
||||||
showOther(Type::Calls);
|
showOther(Type::Calls);
|
||||||
});
|
});
|
||||||
SetupSystemIntegrationOptions(container);
|
SetupSystemIntegrationOptions(controller, container);
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +608,7 @@ void Advanced::setupContent(not_null<Window::SessionController*> controller) {
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
SetupDataStorage(controller, content);
|
SetupDataStorage(controller, content);
|
||||||
SetupAutoDownload(controller, content);
|
SetupAutoDownload(controller, content);
|
||||||
SetupSystemIntegration(content, [=](Type type) {
|
SetupSystemIntegration(controller, content, [=](Type type) {
|
||||||
_showOther.fire_copy(type);
|
_showOther.fire_copy(type);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ void SetupConnectionType(
|
||||||
not_null<Ui::VerticalLayout*> container);
|
not_null<Ui::VerticalLayout*> container);
|
||||||
bool HasUpdate();
|
bool HasUpdate();
|
||||||
void SetupUpdate(not_null<Ui::VerticalLayout*> container);
|
void SetupUpdate(not_null<Ui::VerticalLayout*> container);
|
||||||
void SetupSystemIntegrationContent(not_null<Ui::VerticalLayout*> container);
|
void SetupSystemIntegrationContent(
|
||||||
|
Window::SessionController *controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container);
|
||||||
void SetupAnimations(not_null<Ui::VerticalLayout*> container);
|
void SetupAnimations(not_null<Ui::VerticalLayout*> container);
|
||||||
|
|
||||||
class Advanced : public Section {
|
class Advanced : public Section {
|
||||||
|
|
|
@ -75,7 +75,9 @@ object_ptr<Ui::RpWidget> CreateIntroSettings(
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto wrap = object_ptr<Ui::VerticalLayout>(result);
|
auto wrap = object_ptr<Ui::VerticalLayout>(result);
|
||||||
SetupSystemIntegrationContent(wrap.data());
|
SetupSystemIntegrationContent(
|
||||||
|
window->sessionController(),
|
||||||
|
wrap.data());
|
||||||
if (wrap->count() > 0) {
|
if (wrap->count() > 0) {
|
||||||
AddDivider(result);
|
AddDivider(result);
|
||||||
AddSkip(result);
|
AddSkip(result);
|
||||||
|
|
|
@ -39,7 +39,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "storage/storage_domain.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
|
@ -56,14 +58,6 @@ constexpr auto kUpdateTimeout = 60 * crl::time(1000);
|
||||||
|
|
||||||
using Privacy = ApiWrap::Privacy;
|
using Privacy = ApiWrap::Privacy;
|
||||||
|
|
||||||
rpl::producer<> PasscodeChanges() {
|
|
||||||
return rpl::single(
|
|
||||||
rpl::empty_value()
|
|
||||||
) | rpl::then(base::ObservableViewer(
|
|
||||||
Global::RefLocalPasscodeChanged()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PrivacyBase(Privacy::Key key, Privacy::Option option) {
|
QString PrivacyBase(Privacy::Key key, Privacy::Option option) {
|
||||||
using Key = Privacy::Key;
|
using Key = Privacy::Key;
|
||||||
using Option = Privacy::Option;
|
using Option = Privacy::Option;
|
||||||
|
@ -257,9 +251,12 @@ void SetupLocalPasscode(
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, tr::lng_settings_passcode_title());
|
AddSubsectionTitle(container, tr::lng_settings_passcode_title());
|
||||||
|
|
||||||
auto has = PasscodeChanges(
|
auto has = rpl::single(
|
||||||
) | rpl::map([] {
|
rpl::empty_value()
|
||||||
return Global::LocalPasscode();
|
) | rpl::then(
|
||||||
|
controller->session().domain().local().localPasscodeChanged()
|
||||||
|
) | rpl::map([=] {
|
||||||
|
return controller->session().domain().local().hasLocalPasscode();
|
||||||
});
|
});
|
||||||
auto text = rpl::combine(
|
auto text = rpl::combine(
|
||||||
tr::lng_passcode_change(),
|
tr::lng_passcode_change(),
|
||||||
|
|
|
@ -838,7 +838,6 @@ bool ReadSetting(
|
||||||
if (!CheckStreamStatus(stream)) return false;
|
if (!CheckStreamStatus(stream)) return false;
|
||||||
|
|
||||||
Core::App().settings().setAutoLock(v);
|
Core::App().settings().setAutoLock(v);
|
||||||
Global::RefLocalPasscodeChanged().notify();
|
|
||||||
context.legacyRead = true;
|
context.legacyRead = true;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "facades.h"
|
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -116,6 +115,7 @@ void Domain::encryptLocalKey(const QByteArray &passcode) {
|
||||||
EncryptedDescriptor passKeyData(MTP::AuthKey::kSize);
|
EncryptedDescriptor passKeyData(MTP::AuthKey::kSize);
|
||||||
_localKey->write(passKeyData.stream);
|
_localKey->write(passKeyData.stream);
|
||||||
_passcodeKeyEncrypted = PrepareEncrypted(passKeyData, _passcodeKey);
|
_passcodeKeyEncrypted = PrepareEncrypted(passKeyData, _passcodeKey);
|
||||||
|
_hasLocalPasscode = !passcode.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Domain::StartModernResult Domain::startModern(
|
Domain::StartModernResult Domain::startModern(
|
||||||
|
@ -156,6 +156,7 @@ Domain::StartModernResult Domain::startModern(
|
||||||
|
|
||||||
_passcodeKeyEncrypted = keyEncrypted;
|
_passcodeKeyEncrypted = keyEncrypted;
|
||||||
_passcodeKeySalt = salt;
|
_passcodeKeySalt = salt;
|
||||||
|
_hasLocalPasscode = !passcode.isEmpty();
|
||||||
|
|
||||||
if (!DecryptLocal(info, infoEncrypted, _localKey)) {
|
if (!DecryptLocal(info, infoEncrypted, _localKey)) {
|
||||||
LOG(("App Error: could not decrypt info."));
|
LOG(("App Error: could not decrypt info."));
|
||||||
|
@ -261,8 +262,7 @@ void Domain::setPasscode(const QByteArray &passcode) {
|
||||||
encryptLocalKey(passcode);
|
encryptLocalKey(passcode);
|
||||||
writeAccounts();
|
writeAccounts();
|
||||||
|
|
||||||
Global::SetLocalPasscode(!passcode.isEmpty());
|
_passcodeKeyChanged.fire({});
|
||||||
Global::RefLocalPasscodeChanged().notify();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Domain::oldVersion() const {
|
int Domain::oldVersion() const {
|
||||||
|
@ -277,4 +277,12 @@ QString Domain::webviewDataPath() const {
|
||||||
return BaseGlobalPath() + "webview";
|
return BaseGlobalPath() + "webview";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> Domain::localPasscodeChanged() const {
|
||||||
|
return _passcodeKeyChanged.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Domain::hasLocalPasscode() const {
|
||||||
|
return _hasLocalPasscode;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
|
@ -46,6 +46,9 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] QString webviewDataPath() const;
|
[[nodiscard]] QString webviewDataPath() const;
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<> localPasscodeChanged() const;
|
||||||
|
[[nodiscard]] bool hasLocalPasscode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class StartModernResult {
|
enum class StartModernResult {
|
||||||
Success,
|
Success,
|
||||||
|
@ -70,6 +73,9 @@ private:
|
||||||
QByteArray _passcodeKeyEncrypted;
|
QByteArray _passcodeKeyEncrypted;
|
||||||
int _oldVersion = 0;
|
int _oldVersion = 0;
|
||||||
|
|
||||||
|
bool _hasLocalPasscode = false;
|
||||||
|
rpl::event_stream<> _passcodeKeyChanged;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
Loading…
Add table
Reference in a new issue