mirror of https://github.com/procxx/kepka.git
Wrap AuthSession in a new Main::Account object.
This commit is contained in:
parent
8c67a4b991
commit
bd2e1ceb02
|
@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "observer_peer.h"
|
#include "observer_peer.h"
|
||||||
#include "storage/storage_databases.h"
|
#include "storage/storage_databases.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include "main/main_account.h"
|
||||||
#include "media/view/media_view_overlay_widget.h"
|
#include "media/view/media_view_overlay_widget.h"
|
||||||
#include "mtproto/dc_options.h"
|
#include "mtproto/dc_options.h"
|
||||||
#include "mtproto/mtp_instance.h"
|
#include "mtproto/mtp_instance.h"
|
||||||
|
@ -84,6 +85,7 @@ Application::Application(not_null<Launcher*> launcher)
|
||||||
, _private(std::make_unique<Private>())
|
, _private(std::make_unique<Private>())
|
||||||
, _databases(std::make_unique<Storage::Databases>())
|
, _databases(std::make_unique<Storage::Databases>())
|
||||||
, _animationsManager(std::make_unique<Ui::Animations::Manager>())
|
, _animationsManager(std::make_unique<Ui::Animations::Manager>())
|
||||||
|
, _account(std::make_unique<Main::Account>(cDataFile()))
|
||||||
, _langpack(std::make_unique<Lang::Instance>())
|
, _langpack(std::make_unique<Lang::Instance>())
|
||||||
, _emojiKeywords(std::make_unique<ChatHelpers::EmojiKeywords>())
|
, _emojiKeywords(std::make_unique<ChatHelpers::EmojiKeywords>())
|
||||||
, _audio(std::make_unique<Media::Audio::Instance>())
|
, _audio(std::make_unique<Media::Audio::Instance>())
|
||||||
|
@ -198,7 +200,7 @@ void Application::run() {
|
||||||
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..."));
|
||||||
if (AuthSession::Exists()) {
|
if (activeAccount().sessionExists()) {
|
||||||
_window->setupMain();
|
_window->setupMain();
|
||||||
} else {
|
} else {
|
||||||
_window->setupIntro();
|
_window->setupIntro();
|
||||||
|
|
|
@ -34,6 +34,10 @@ namespace App {
|
||||||
void quit();
|
void quit();
|
||||||
} // namespace App
|
} // namespace App
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Account;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace Animations {
|
namespace Animations {
|
||||||
class Manager;
|
class Manager;
|
||||||
|
@ -143,11 +147,16 @@ public:
|
||||||
void configUpdated();
|
void configUpdated();
|
||||||
[[nodiscard]] rpl::producer<> configUpdates() const;
|
[[nodiscard]] rpl::producer<> configUpdates() const;
|
||||||
|
|
||||||
// Databases
|
// Databases.
|
||||||
Storage::Databases &databases() {
|
Storage::Databases &databases() {
|
||||||
return *_databases;
|
return *_databases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Account component.
|
||||||
|
Main::Account &activeAccount() {
|
||||||
|
return *_account;
|
||||||
|
}
|
||||||
|
|
||||||
// AuthSession component.
|
// AuthSession component.
|
||||||
AuthSession *authSession() {
|
AuthSession *authSession() {
|
||||||
return _authSession.get();
|
return _authSession.get();
|
||||||
|
@ -269,6 +278,7 @@ private:
|
||||||
|
|
||||||
const std::unique_ptr<Storage::Databases> _databases;
|
const std::unique_ptr<Storage::Databases> _databases;
|
||||||
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
||||||
|
const std::unique_ptr<Main::Account> _account;
|
||||||
std::unique_ptr<MainWindow> _window;
|
std::unique_ptr<MainWindow> _window;
|
||||||
std::unique_ptr<Media::View::OverlayWidget> _mediaView;
|
std::unique_ptr<Media::View::OverlayWidget> _mediaView;
|
||||||
const std::unique_ptr<Lang::Instance> _langpack;
|
const std::unique_ptr<Lang::Instance> _langpack;
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "main/main_account.h"
|
||||||
|
|
||||||
|
#include "auth_session.h"
|
||||||
|
#include "core/application.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
|
||||||
|
Account::Account(const QString &dataName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Account::sessionExists() const {
|
||||||
|
return Core::App().authSession() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthSession &Account::session() {
|
||||||
|
Expects(sessionExists());
|
||||||
|
|
||||||
|
return *Core::App().authSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<AuthSession*> Account::sessionValue() const {
|
||||||
|
return rpl::single(
|
||||||
|
rpl::empty_value()
|
||||||
|
) | rpl::then(
|
||||||
|
base::ObservableViewer(Core::App().authSessionChanged())
|
||||||
|
) | rpl::map([] {
|
||||||
|
return Core::App().authSession();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
MTP::Instance *Account::mtp() {
|
||||||
|
return MTP::MainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Main
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class AuthSession;
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
|
||||||
|
class Account final {
|
||||||
|
public:
|
||||||
|
explicit Account(const QString &dataName);
|
||||||
|
|
||||||
|
[[nodiscard]] bool sessionExists() const;
|
||||||
|
[[nodiscard]] AuthSession &session();
|
||||||
|
[[nodiscard]] rpl::producer<AuthSession*> sessionValue() const;
|
||||||
|
|
||||||
|
[[nodiscard]] MTP::Instance *mtp();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Main
|
|
@ -429,6 +429,8 @@
|
||||||
<(src_loc)/lang/lang_tag.h
|
<(src_loc)/lang/lang_tag.h
|
||||||
<(src_loc)/lang/lang_translator.cpp
|
<(src_loc)/lang/lang_translator.cpp
|
||||||
<(src_loc)/lang/lang_translator.h
|
<(src_loc)/lang/lang_translator.h
|
||||||
|
<(src_loc)/main/main_account.cpp
|
||||||
|
<(src_loc)/main/main_account.h
|
||||||
<(src_loc)/media/audio/media_audio.cpp
|
<(src_loc)/media/audio/media_audio.cpp
|
||||||
<(src_loc)/media/audio/media_audio.h
|
<(src_loc)/media/audio/media_audio.h
|
||||||
<(src_loc)/media/audio/media_audio_capture.cpp
|
<(src_loc)/media/audio/media_audio_capture.cpp
|
||||||
|
|
Loading…
Reference in New Issue