2017-02-23 13:59:19 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-02-23 13:59:19 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-18 12:28:14 +03:00
|
|
|
#include "mtproto/mtproto_auth_key.h"
|
2019-11-13 17:12:04 +03:00
|
|
|
#include "mtproto/mtproto_proxy_data.h"
|
2017-08-03 15:06:29 +02:00
|
|
|
#include "base/timer.h"
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2022-06-11 03:07:22 +03:00
|
|
|
class History;
|
2017-12-11 18:45:29 +04:00
|
|
|
|
2022-01-04 15:29:40 +03:00
|
|
|
namespace Platform {
|
|
|
|
class Integration;
|
|
|
|
} // namespace Platform
|
|
|
|
|
2018-08-29 16:23:16 +03:00
|
|
|
namespace Storage {
|
|
|
|
class Databases;
|
|
|
|
} // namespace Storage
|
|
|
|
|
2018-06-03 16:30:40 +03:00
|
|
|
namespace Window {
|
2019-06-06 14:20:21 +03:00
|
|
|
class Controller;
|
2018-06-03 16:30:40 +03:00
|
|
|
} // namespace Window
|
|
|
|
|
2020-06-19 16:59:31 +04:00
|
|
|
namespace Window {
|
|
|
|
namespace Notifications {
|
|
|
|
class System;
|
|
|
|
} // namespace Notifications
|
|
|
|
} // namespace Window
|
|
|
|
|
2019-03-28 12:48:32 +04:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class EmojiKeywords;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
2019-04-30 15:12:30 +04:00
|
|
|
namespace Main {
|
2020-06-18 22:04:16 +04:00
|
|
|
class Domain;
|
2019-04-30 15:12:30 +04:00
|
|
|
class Account;
|
2020-06-11 13:41:03 +04:00
|
|
|
class Session;
|
2019-04-30 15:12:30 +04:00
|
|
|
} // namespace Main
|
|
|
|
|
2019-02-04 16:34:50 +03:00
|
|
|
namespace Ui {
|
|
|
|
namespace Animations {
|
|
|
|
class Manager;
|
|
|
|
} // namespace Animations
|
2020-06-22 23:01:19 +04:00
|
|
|
namespace Emoji {
|
|
|
|
class UniversalImages;
|
|
|
|
} // namespace Emoji
|
2019-09-18 14:19:05 +03:00
|
|
|
class BoxContent;
|
2019-02-04 16:34:50 +03:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-02-23 13:59:19 +03:00
|
|
|
namespace MTP {
|
2020-06-17 13:36:25 +04:00
|
|
|
class Config;
|
2017-02-24 20:15:41 +03:00
|
|
|
class Instance;
|
2017-06-26 20:38:16 +03:00
|
|
|
class AuthKey;
|
|
|
|
using AuthKeyPtr = std::shared_ptr<AuthKey>;
|
|
|
|
using AuthKeysList = std::vector<AuthKeyPtr>;
|
2017-02-23 13:59:19 +03:00
|
|
|
} // namespace MTP
|
|
|
|
|
2017-05-03 14:36:39 +03:00
|
|
|
namespace Media {
|
|
|
|
namespace Audio {
|
|
|
|
class Instance;
|
|
|
|
} // namespace Audio
|
2019-02-12 14:00:47 +03:00
|
|
|
namespace View {
|
|
|
|
class OverlayWidget;
|
2022-06-08 10:04:35 +03:00
|
|
|
struct OpenRequest;
|
2019-02-12 14:00:47 +03:00
|
|
|
} // namespace View
|
2020-06-25 18:17:37 +04:00
|
|
|
namespace Player {
|
|
|
|
class FloatController;
|
|
|
|
class FloatDelegate;
|
|
|
|
} // namespace Player
|
2023-01-19 09:38:52 +04:00
|
|
|
class SystemMediaControlsManager;
|
2017-05-03 14:36:39 +03:00
|
|
|
} // namespace Media
|
|
|
|
|
2017-04-13 11:45:58 +03:00
|
|
|
namespace Lang {
|
2017-04-13 20:59:05 +03:00
|
|
|
class Instance;
|
2017-04-13 11:45:58 +03:00
|
|
|
class Translator;
|
2017-04-18 18:21:03 +03:00
|
|
|
class CloudManager;
|
2017-04-13 11:45:58 +03:00
|
|
|
} // namespace Lang
|
|
|
|
|
2019-09-06 18:31:01 +03:00
|
|
|
namespace Data {
|
|
|
|
struct CloudTheme;
|
2022-02-21 18:40:20 +03:00
|
|
|
class DownloadManager;
|
2019-09-06 18:31:01 +03:00
|
|
|
} // namespace Data
|
|
|
|
|
2020-06-22 23:01:19 +04:00
|
|
|
namespace Stickers {
|
|
|
|
class EmojiImageLoader;
|
|
|
|
} // namespace Stickers
|
|
|
|
|
2020-06-25 11:14:05 +04:00
|
|
|
namespace Export {
|
|
|
|
class Manager;
|
|
|
|
} // namespace Export
|
|
|
|
|
2020-06-25 21:57:36 +04:00
|
|
|
namespace Calls {
|
|
|
|
class Instance;
|
|
|
|
} // namespace Calls
|
|
|
|
|
2019-01-21 17:42:21 +04:00
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
class Launcher;
|
|
|
|
struct LocalUrlHandler;
|
2022-06-11 03:07:22 +03:00
|
|
|
class Settings;
|
2022-03-23 18:59:53 +03:00
|
|
|
class Tray;
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2022-01-27 15:48:51 +03:00
|
|
|
enum class LaunchState {
|
|
|
|
Running,
|
|
|
|
QuitRequested,
|
|
|
|
QuitProcessed,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class QuitReason {
|
|
|
|
Default,
|
|
|
|
QtQuitEvent,
|
|
|
|
};
|
|
|
|
|
2021-05-25 13:19:17 +03:00
|
|
|
class Application final : public QObject {
|
2017-02-23 13:59:19 +03:00
|
|
|
public:
|
2020-06-17 13:36:25 +04:00
|
|
|
struct ProxyChange {
|
|
|
|
MTP::ProxyData was;
|
|
|
|
MTP::ProxyData now;
|
|
|
|
};
|
|
|
|
|
2019-01-21 17:42:21 +04:00
|
|
|
Application(not_null<Launcher*> launcher);
|
|
|
|
Application(const Application &other) = delete;
|
|
|
|
Application &operator=(const Application &other) = delete;
|
2019-03-28 12:48:32 +04:00
|
|
|
~Application();
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2022-01-04 15:29:40 +03:00
|
|
|
[[nodiscard]] Launcher &launcher() const {
|
|
|
|
return *_launcher;
|
|
|
|
}
|
|
|
|
[[nodiscard]] Platform::Integration &platformIntegration() const {
|
|
|
|
return *_platformIntegration;
|
2017-12-11 18:45:29 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 17:42:21 +04:00
|
|
|
void run();
|
|
|
|
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] Ui::Animations::Manager &animationManager() const {
|
2019-02-04 16:34:50 +03:00
|
|
|
return *_animationsManager;
|
|
|
|
}
|
2020-06-19 16:59:31 +04:00
|
|
|
[[nodiscard]] Window::Notifications::System ¬ifications() const {
|
2020-06-19 21:13:43 +04:00
|
|
|
Expects(_notifications != nullptr);
|
|
|
|
|
2020-06-19 16:59:31 +04:00
|
|
|
return *_notifications;
|
|
|
|
}
|
2022-02-21 18:40:20 +03:00
|
|
|
[[nodiscard]] Data::DownloadManager &downloadManager() const {
|
|
|
|
return *_downloadManager;
|
|
|
|
}
|
2022-04-21 01:39:01 +03:00
|
|
|
[[nodiscard]] Tray &tray() const {
|
|
|
|
return *_tray;
|
|
|
|
}
|
2019-02-04 16:34:50 +03:00
|
|
|
|
2017-08-08 11:31:48 +02:00
|
|
|
// Windows interface.
|
2020-06-11 13:41:03 +04:00
|
|
|
bool hasActiveWindow(not_null<Main::Session*> session) const;
|
2023-01-17 19:47:58 +04:00
|
|
|
|
|
|
|
// Don't auto-switch.
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] Window::Controller *activeWindow() const;
|
2023-01-17 19:47:58 +04:00
|
|
|
[[nodiscard]] Window::Controller *activePrimaryWindow() const;
|
|
|
|
[[nodiscard]] Window::Controller *separateWindowForAccount(
|
|
|
|
not_null<Main::Account*> account) const;
|
2022-01-04 14:18:13 +03:00
|
|
|
[[nodiscard]] Window::Controller *separateWindowForPeer(
|
|
|
|
not_null<PeerData*> peer) const;
|
|
|
|
Window::Controller *ensureSeparateWindowForPeer(
|
2022-01-04 19:36:33 +03:00
|
|
|
not_null<PeerData*> peer,
|
|
|
|
MsgId showAtMsgId);
|
2023-01-17 19:47:58 +04:00
|
|
|
Window::Controller *ensureSeparateWindowForAccount(
|
|
|
|
not_null<Main::Account*> account);
|
|
|
|
[[nodiscard]] Window::Controller *windowFor( // Doesn't auto-switch.
|
|
|
|
not_null<PeerData*> peer) const;
|
|
|
|
[[nodiscard]] Window::Controller *windowFor( // Doesn't auto-switch.
|
|
|
|
not_null<Main::Account*> account) const;
|
|
|
|
[[nodiscard]] bool closeNonLastAsync(
|
|
|
|
not_null<Window::Controller*> window);
|
2022-06-07 22:05:37 +04:00
|
|
|
void closeWindow(not_null<Window::Controller*> window);
|
|
|
|
void windowActivated(not_null<Window::Controller*> window);
|
2017-08-08 11:56:10 +02:00
|
|
|
bool closeActiveWindow();
|
|
|
|
bool minimizeActiveWindow();
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] QWidget *getFileDialogParent();
|
2019-10-07 14:34:40 +03:00
|
|
|
void notifyFileDialogShown(bool shown);
|
2020-07-22 16:10:17 +04:00
|
|
|
void checkSystemDarkMode();
|
2022-03-23 20:22:47 +03:00
|
|
|
[[nodiscard]] bool isActiveForTrayMenu() const;
|
2022-06-09 03:46:54 +03:00
|
|
|
void closeChatFromWindows(not_null<PeerData*> peer);
|
2023-01-19 09:38:52 +04:00
|
|
|
void activate();
|
2017-08-08 11:31:48 +02:00
|
|
|
|
2019-02-12 14:00:47 +03:00
|
|
|
// Media view interface.
|
2017-08-08 11:31:48 +02:00
|
|
|
bool hideMediaView();
|
|
|
|
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] QPoint getPointForCallPanelCenter() const;
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2020-07-22 16:10:17 +04:00
|
|
|
void startSettingsAndBackground();
|
2022-01-04 14:18:13 +03:00
|
|
|
[[nodiscard]] Settings &settings();
|
2019-08-23 16:52:59 +03:00
|
|
|
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
|
2020-06-18 22:04:16 +04:00
|
|
|
void saveSettings();
|
2022-12-29 12:49:03 +04:00
|
|
|
|
|
|
|
[[nodiscard]] bool canReadDefaultDownloadPath(bool always = false) const;
|
2022-11-08 18:24:08 +04:00
|
|
|
[[nodiscard]] bool canSaveFileWithoutAskingForPath() const;
|
2019-08-23 16:52:59 +03:00
|
|
|
|
2020-06-17 13:36:25 +04:00
|
|
|
// Fallback config and proxy.
|
|
|
|
[[nodiscard]] MTP::Config &fallbackProductionConfig() const;
|
|
|
|
void refreshFallbackProductionConfig(const MTP::Config &config);
|
|
|
|
void constructFallbackProductionConfig(const QByteArray &serialized);
|
2018-11-05 17:58:24 +04:00
|
|
|
void setCurrentProxy(
|
2019-11-13 17:12:04 +03:00
|
|
|
const MTP::ProxyData &proxy,
|
|
|
|
MTP::ProxyData::Settings settings);
|
2019-07-24 10:46:23 +02:00
|
|
|
[[nodiscard]] rpl::producer<ProxyChange> proxyChanges() const;
|
2018-05-24 16:40:19 +03:00
|
|
|
void badMtprotoConfigurationError();
|
2017-02-24 20:15:41 +03:00
|
|
|
|
2019-04-30 15:12:30 +04:00
|
|
|
// Databases.
|
2019-07-24 16:00:30 +02:00
|
|
|
[[nodiscard]] Storage::Databases &databases() {
|
2018-08-29 16:23:16 +03:00
|
|
|
return *_databases;
|
|
|
|
}
|
|
|
|
|
2020-06-18 22:04:16 +04:00
|
|
|
// Domain component.
|
|
|
|
[[nodiscard]] Main::Domain &domain() const {
|
|
|
|
return *_domain;
|
2019-04-30 15:12:30 +04:00
|
|
|
}
|
2020-06-15 20:25:02 +04:00
|
|
|
[[nodiscard]] Main::Account &activeAccount() const;
|
|
|
|
[[nodiscard]] bool someSessionExists() const;
|
2020-06-25 11:14:05 +04:00
|
|
|
[[nodiscard]] Export::Manager &exportManager() const {
|
|
|
|
return *_exportManager;
|
|
|
|
}
|
2019-07-24 16:00:30 +02:00
|
|
|
[[nodiscard]] bool exportPreventsQuit();
|
2019-04-30 15:12:30 +04:00
|
|
|
|
2019-07-24 13:45:24 +02:00
|
|
|
// Main::Session component.
|
2022-06-12 02:24:50 +03:00
|
|
|
Main::Session *maybePrimarySession() const;
|
2019-07-24 16:00:30 +02:00
|
|
|
[[nodiscard]] int unreadBadge() const;
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] bool unreadBadgeMuted() const;
|
2020-06-18 15:17:58 +04:00
|
|
|
[[nodiscard]] rpl::producer<> unreadBadgeChanges() const;
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2017-05-03 14:36:39 +03:00
|
|
|
// Media component.
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] Media::Audio::Instance &audio() {
|
2017-05-03 14:36:39 +03:00
|
|
|
return *_audio;
|
|
|
|
}
|
|
|
|
|
2019-03-28 12:48:32 +04:00
|
|
|
// Langpack and emoji keywords.
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] Lang::Instance &langpack() {
|
2019-03-28 12:48:32 +04:00
|
|
|
return *_langpack;
|
|
|
|
}
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] Lang::CloudManager *langCloudManager() {
|
2019-03-28 12:48:32 +04:00
|
|
|
return _langCloudManager.get();
|
|
|
|
}
|
2020-06-10 18:52:44 +04:00
|
|
|
[[nodiscard]] bool offerLegacyLangPackSwitch() const;
|
2020-06-10 17:24:41 +04:00
|
|
|
[[nodiscard]] bool canApplyLangPackWithoutRestart() const;
|
|
|
|
[[nodiscard]] ChatHelpers::EmojiKeywords &emojiKeywords() {
|
2019-03-28 12:48:32 +04:00
|
|
|
return *_emojiKeywords;
|
|
|
|
}
|
2020-06-22 23:01:19 +04:00
|
|
|
[[nodiscard]] auto emojiImageLoader() const
|
|
|
|
-> const crl::object_on_queue<Stickers::EmojiImageLoader> & {
|
|
|
|
return _emojiImageLoader;
|
|
|
|
}
|
2019-03-28 12:48:32 +04:00
|
|
|
|
2017-06-27 23:11:38 +03:00
|
|
|
// Internal links.
|
|
|
|
void checkStartUrl();
|
2022-11-30 17:28:09 +04:00
|
|
|
void checkSendPaths();
|
2018-07-09 21:13:48 +03:00
|
|
|
bool openLocalUrl(const QString &url, QVariant context);
|
2019-12-25 18:20:02 +03:00
|
|
|
bool openInternalUrl(const QString &url, QVariant context);
|
2021-02-04 20:42:32 +04:00
|
|
|
[[nodiscard]] QString changelogLink() const;
|
2017-03-10 20:25:43 +03:00
|
|
|
|
2020-06-25 18:17:37 +04:00
|
|
|
// Float player.
|
2023-01-19 11:40:39 +04:00
|
|
|
void floatPlayerToggleGifsPaused(bool paused);
|
2020-06-25 18:17:37 +04:00
|
|
|
[[nodiscard]] rpl::producer<FullMsgId> floatPlayerClosed() const;
|
|
|
|
|
2020-06-25 21:57:36 +04:00
|
|
|
// Calls.
|
|
|
|
Calls::Instance &calls() const {
|
|
|
|
return *_calls;
|
|
|
|
}
|
|
|
|
|
2020-06-16 13:40:43 +04:00
|
|
|
void logout(Main::Account *account = nullptr);
|
2022-01-26 12:41:27 +03:00
|
|
|
void logoutWithChecks(Main::Account *account);
|
2020-06-16 13:40:43 +04:00
|
|
|
void forceLogOut(
|
|
|
|
not_null<Main::Account*> account,
|
|
|
|
const TextWithEntities &explanation);
|
2022-01-26 12:41:27 +03:00
|
|
|
[[nodiscard]] bool uploadPreventsQuit();
|
2022-03-09 15:30:22 +04:00
|
|
|
[[nodiscard]] bool downloadPreventsQuit();
|
2017-02-23 13:59:19 +03:00
|
|
|
void checkLocalTime();
|
2018-06-03 16:30:40 +03:00
|
|
|
void lockByPasscode();
|
2022-10-12 16:57:17 +04:00
|
|
|
void maybeLockByPasscode();
|
2018-06-03 16:30:40 +03:00
|
|
|
void unlockPasscode();
|
|
|
|
[[nodiscard]] bool passcodeLocked() const;
|
|
|
|
rpl::producer<bool> passcodeLockChanges() const;
|
|
|
|
rpl::producer<bool> passcodeLockValue() const;
|
|
|
|
|
2021-06-18 19:22:36 +04:00
|
|
|
void checkAutoLock(crl::time lastNonIdleTime = 0);
|
2020-06-08 19:56:52 +04:00
|
|
|
void checkAutoLockIn(crl::time time);
|
|
|
|
void localPasscodeChanged();
|
|
|
|
|
2022-01-27 15:48:51 +03:00
|
|
|
[[nodiscard]] bool preventsQuit(QuitReason reason);
|
2022-01-26 12:41:27 +03:00
|
|
|
|
2019-03-09 20:10:51 +03:00
|
|
|
[[nodiscard]] crl::time lastNonIdleTime() const;
|
|
|
|
void updateNonIdle();
|
|
|
|
|
2019-09-13 19:45:48 +03:00
|
|
|
void registerLeaveSubscription(not_null<QWidget*> widget);
|
|
|
|
void unregisterLeaveSubscription(not_null<QWidget*> widget);
|
2017-11-21 14:27:37 +04:00
|
|
|
|
2019-01-21 17:42:21 +04:00
|
|
|
// Sandbox interface.
|
|
|
|
void postponeCall(FnMut<void()> &&callable);
|
|
|
|
void refreshGlobalProxy();
|
|
|
|
|
2017-04-29 23:06:32 +03:00
|
|
|
void quitPreventFinished();
|
|
|
|
|
2017-02-23 13:59:19 +03:00
|
|
|
void handleAppActivated();
|
|
|
|
void handleAppDeactivated();
|
2020-12-06 18:01:37 +03:00
|
|
|
[[nodiscard]] rpl::producer<bool> appDeactivatedValue() const;
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2019-01-18 15:26:43 +04:00
|
|
|
void switchDebugMode();
|
2020-05-09 02:37:43 +04:00
|
|
|
void switchFreeType();
|
2019-01-21 17:42:21 +04:00
|
|
|
void writeInstallBetaVersionsSetting();
|
2019-01-18 15:26:43 +04:00
|
|
|
|
2020-12-13 16:08:16 +03:00
|
|
|
void preventOrInvoke(Fn<void()> &&callback);
|
|
|
|
|
2021-05-27 17:47:51 +03:00
|
|
|
// Global runtime variables.
|
|
|
|
void setScreenIsLocked(bool locked);
|
|
|
|
bool screenIsLocked() const;
|
|
|
|
|
2021-07-18 07:25:01 +04:00
|
|
|
static void RegisterUrlScheme();
|
|
|
|
|
2017-08-08 11:31:48 +02:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *object, QEvent *event) override;
|
|
|
|
|
2017-02-23 13:59:19 +03:00
|
|
|
private:
|
2019-08-23 16:52:59 +03:00
|
|
|
static constexpr auto kDefaultSaveDelay = crl::time(1000);
|
|
|
|
|
2019-02-04 16:34:50 +03:00
|
|
|
friend bool IsAppLaunched();
|
|
|
|
friend Application &App();
|
|
|
|
|
2020-06-22 23:01:19 +04:00
|
|
|
void clearEmojiSourceImages();
|
|
|
|
[[nodiscard]] auto prepareEmojiSourceImages()
|
|
|
|
-> std::shared_ptr<Ui::Emoji::UniversalImages>;
|
2017-02-23 13:59:19 +03:00
|
|
|
void startLocalStorage();
|
2018-11-16 16:15:14 +04:00
|
|
|
void startShortcuts();
|
2020-07-22 16:10:17 +04:00
|
|
|
void startDomain();
|
2020-06-22 23:01:19 +04:00
|
|
|
void startEmojiImageLoader();
|
2020-07-22 16:10:17 +04:00
|
|
|
void startSystemDarkModeViewer();
|
2022-03-23 18:59:53 +03:00
|
|
|
void startTray();
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2023-01-19 11:40:39 +04:00
|
|
|
void setLastActiveWindow(Window::Controller *window);
|
2023-01-17 19:47:58 +04:00
|
|
|
void showAccount(not_null<Main::Account*> account);
|
2022-06-08 09:36:50 +03:00
|
|
|
void enumerateWindows(
|
|
|
|
Fn<void(not_null<Window::Controller*>)> callback) const;
|
2023-01-17 19:47:58 +04:00
|
|
|
void processCreatedWindow(not_null<Window::Controller*> window);
|
2022-06-08 09:36:50 +03:00
|
|
|
|
2022-01-27 15:48:51 +03:00
|
|
|
friend void QuitAttempt();
|
2017-04-29 23:06:32 +03:00
|
|
|
void quitDelayed();
|
2020-06-26 11:22:53 +04:00
|
|
|
[[nodiscard]] bool readyToQuit();
|
2017-04-29 23:06:32 +03:00
|
|
|
|
2021-06-11 23:01:07 +04:00
|
|
|
void showOpenGLCrashNotification();
|
2018-06-07 10:44:38 +03:00
|
|
|
void clearPasscodeLock();
|
2017-08-08 11:31:48 +02:00
|
|
|
|
2019-12-25 18:20:02 +03:00
|
|
|
bool openCustomUrl(
|
|
|
|
const QString &protocol,
|
|
|
|
const std::vector<LocalUrlHandler> &handlers,
|
|
|
|
const QString &url,
|
|
|
|
const QVariant &context);
|
|
|
|
|
2019-02-04 16:34:50 +03:00
|
|
|
static Application *Instance;
|
2019-07-24 10:46:23 +02:00
|
|
|
struct InstanceSetter {
|
|
|
|
InstanceSetter(not_null<Application*> instance) {
|
|
|
|
Expects(Instance == nullptr);
|
|
|
|
|
|
|
|
Instance = instance;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
InstanceSetter _setter = { this };
|
2019-02-04 16:34:50 +03:00
|
|
|
|
2022-01-04 15:29:40 +03:00
|
|
|
const not_null<Launcher*> _launcher;
|
2019-07-24 10:46:23 +02:00
|
|
|
rpl::event_stream<ProxyChange> _proxyChanges;
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2017-02-24 20:15:41 +03:00
|
|
|
// Some fields are just moved from the declaration.
|
|
|
|
struct Private;
|
|
|
|
const std::unique_ptr<Private> _private;
|
2022-01-04 15:29:40 +03:00
|
|
|
const std::unique_ptr<Platform::Integration> _platformIntegration;
|
2017-08-08 11:31:48 +02:00
|
|
|
|
2019-02-04 16:34:50 +03:00
|
|
|
const std::unique_ptr<Storage::Databases> _databases;
|
|
|
|
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
2020-06-22 23:01:19 +04:00
|
|
|
crl::object_on_queue<Stickers::EmojiImageLoader> _emojiImageLoader;
|
|
|
|
base::Timer _clearEmojiImageLoaderTimer;
|
2020-06-25 21:57:36 +04:00
|
|
|
const std::unique_ptr<Media::Audio::Instance> _audio;
|
2020-06-17 13:36:25 +04:00
|
|
|
mutable std::unique_ptr<MTP::Config> _fallbackProductionConfig;
|
2020-06-30 19:33:22 +04:00
|
|
|
|
|
|
|
// Notifications should be destroyed before _audio, after _domain.
|
|
|
|
// Mutable because is created in run() after OpenSSL is inited.
|
|
|
|
std::unique_ptr<Window::Notifications::System> _notifications;
|
|
|
|
|
2023-01-19 09:38:52 +04:00
|
|
|
using MediaControlsManager = Media::SystemMediaControlsManager;
|
2023-01-19 09:53:59 +04:00
|
|
|
std::unique_ptr<MediaControlsManager> _mediaControlsManager;
|
2022-02-21 18:40:20 +03:00
|
|
|
const std::unique_ptr<Data::DownloadManager> _downloadManager;
|
2020-06-18 22:04:16 +04:00
|
|
|
const std::unique_ptr<Main::Domain> _domain;
|
2020-06-25 11:14:05 +04:00
|
|
|
const std::unique_ptr<Export::Manager> _exportManager;
|
2020-06-25 21:57:36 +04:00
|
|
|
const std::unique_ptr<Calls::Instance> _calls;
|
2023-01-17 19:47:58 +04:00
|
|
|
base::flat_map<
|
|
|
|
Main::Account*,
|
|
|
|
std::unique_ptr<Window::Controller>> _primaryWindows;
|
|
|
|
base::flat_set<not_null<Window::Controller*>> _closingAsyncWindows;
|
2022-01-04 14:18:13 +03:00
|
|
|
base::flat_map<
|
|
|
|
not_null<History*>,
|
2022-01-04 19:36:33 +03:00
|
|
|
std::unique_ptr<Window::Controller>> _secondaryWindows;
|
2022-01-04 14:18:13 +03:00
|
|
|
Window::Controller *_lastActiveWindow = nullptr;
|
2023-01-17 19:47:58 +04:00
|
|
|
Window::Controller *_lastActivePrimaryWindow = nullptr;
|
2022-01-04 14:18:13 +03:00
|
|
|
|
2019-02-12 14:00:47 +03:00
|
|
|
std::unique_ptr<Media::View::OverlayWidget> _mediaView;
|
2019-02-04 16:34:50 +03:00
|
|
|
const std::unique_ptr<Lang::Instance> _langpack;
|
2019-11-27 11:02:56 +03:00
|
|
|
const std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
2019-03-28 12:48:32 +04:00
|
|
|
const std::unique_ptr<ChatHelpers::EmojiKeywords> _emojiKeywords;
|
2017-04-13 11:45:58 +03:00
|
|
|
std::unique_ptr<Lang::Translator> _translator;
|
2019-09-18 14:19:05 +03:00
|
|
|
QPointer<Ui::BoxContent> _badProxyDisableBox;
|
2017-02-23 13:59:19 +03:00
|
|
|
|
2022-03-23 18:59:53 +03:00
|
|
|
const std::unique_ptr<Tray> _tray;
|
|
|
|
|
2020-06-25 18:17:37 +04:00
|
|
|
std::unique_ptr<Media::Player::FloatController> _floatPlayers;
|
2023-01-19 11:40:39 +04:00
|
|
|
rpl::lifetime _floatPlayerDelegateLifetime;
|
|
|
|
bool _floatPlayerGifsPaused = false;
|
2020-06-25 18:17:37 +04:00
|
|
|
|
2018-06-03 16:30:40 +03:00
|
|
|
rpl::variable<bool> _passcodeLock;
|
2021-05-27 17:47:51 +03:00
|
|
|
bool _screenIsLocked = false;
|
2018-06-03 16:30:40 +03:00
|
|
|
|
2020-06-08 19:56:52 +04:00
|
|
|
crl::time _shouldLockAt = 0;
|
|
|
|
base::Timer _autoLockTimer;
|
|
|
|
|
2021-02-17 19:19:00 +04:00
|
|
|
std::optional<base::Timer> _saveSettingsTimer;
|
2017-08-03 15:06:29 +02:00
|
|
|
|
2021-05-27 09:34:33 +04:00
|
|
|
struct LeaveFilter {
|
|
|
|
std::vector<QPointer<QWidget>> registered;
|
|
|
|
QPointer<QObject> filter;
|
2017-11-21 14:27:37 +04:00
|
|
|
};
|
2021-05-27 09:34:33 +04:00
|
|
|
base::flat_map<not_null<QWidget*>, LeaveFilter> _leaveFilters;
|
2017-11-21 14:27:37 +04:00
|
|
|
|
2022-06-08 10:04:35 +03:00
|
|
|
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
|
|
|
|
|
2018-11-16 16:15:14 +04:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
2019-03-09 20:10:51 +03:00
|
|
|
crl::time _lastNonIdleTime = 0;
|
|
|
|
|
2017-02-23 13:59:19 +03:00
|
|
|
};
|
2019-01-21 17:42:21 +04:00
|
|
|
|
2019-02-04 16:34:50 +03:00
|
|
|
[[nodiscard]] bool IsAppLaunched();
|
|
|
|
[[nodiscard]] Application &App();
|
2019-01-21 17:42:21 +04:00
|
|
|
|
2022-01-27 15:48:51 +03:00
|
|
|
[[nodiscard]] LaunchState CurrentLaunchState();
|
|
|
|
void SetLaunchState(LaunchState state);
|
|
|
|
|
|
|
|
void Quit(QuitReason reason = QuitReason::Default);
|
|
|
|
[[nodiscard]] bool Quitting();
|
|
|
|
|
|
|
|
void Restart();
|
|
|
|
|
2019-01-21 17:42:21 +04:00
|
|
|
} // namespace Core
|