2017-06-13 21:13:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-22 10:53:39 +02:00
|
|
|
#include "common/Singleton.hpp"
|
2024-01-18 20:50:57 +01:00
|
|
|
#include "debug/AssertInGuiThread.hpp"
|
2019-09-22 10:53:39 +02:00
|
|
|
#include "singletons/NativeMessaging.hpp"
|
|
|
|
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include <QApplication>
|
|
|
|
|
2024-01-18 20:50:57 +01:00
|
|
|
#include <cassert>
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
2023-12-29 15:40:31 +01:00
|
|
|
class Args;
|
2019-09-15 13:02:02 +02:00
|
|
|
class TwitchIrcServer;
|
2023-05-21 12:10:49 +02:00
|
|
|
class ITwitchIrcServer;
|
2018-04-28 15:48:40 +02:00
|
|
|
class PubSub;
|
2024-01-16 21:56:43 +01:00
|
|
|
class Updates;
|
2018-04-28 15:20:18 +02:00
|
|
|
|
2018-04-30 23:30:05 +02:00
|
|
|
class CommandController;
|
2018-05-26 20:25:00 +02:00
|
|
|
class AccountController;
|
2018-08-09 15:41:03 +02:00
|
|
|
class NotificationController;
|
2022-06-05 17:40:57 +02:00
|
|
|
class HighlightController;
|
2021-11-21 18:46:21 +01:00
|
|
|
class HotkeyController;
|
2022-11-13 18:21:21 +01:00
|
|
|
class IUserDataController;
|
|
|
|
class UserDataController;
|
2023-11-26 22:06:12 +01:00
|
|
|
class ISoundController;
|
2023-01-29 10:36:25 +01:00
|
|
|
class SoundController;
|
2023-07-02 15:52:15 +02:00
|
|
|
class ITwitchLiveController;
|
|
|
|
class TwitchLiveController;
|
2024-01-17 23:53:10 +01:00
|
|
|
class TwitchBadges;
|
2023-04-02 15:31:53 +02:00
|
|
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
|
|
|
class PluginController;
|
|
|
|
#endif
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-06-28 20:03:04 +02:00
|
|
|
class Theme;
|
2018-04-27 22:11:19 +02:00
|
|
|
class WindowManager;
|
2024-06-16 12:22:51 +02:00
|
|
|
class ILogging;
|
2018-06-28 19:51:07 +02:00
|
|
|
class Logging;
|
|
|
|
class Paths;
|
|
|
|
class Emotes;
|
2022-11-05 11:04:35 +01:00
|
|
|
class IEmotes;
|
2018-06-28 19:51:07 +02:00
|
|
|
class Settings;
|
|
|
|
class Fonts;
|
2018-08-11 12:47:03 +02:00
|
|
|
class Toasts;
|
2024-01-19 17:25:52 +01:00
|
|
|
class IChatterinoBadges;
|
2018-09-16 17:27:51 +02:00
|
|
|
class ChatterinoBadges;
|
2020-10-25 10:36:00 +01:00
|
|
|
class FfzBadges;
|
2022-10-16 13:22:17 +02:00
|
|
|
class SeventvBadges;
|
2023-11-19 12:05:30 +01:00
|
|
|
class ImageUploader;
|
2023-11-26 16:54:19 +01:00
|
|
|
class SeventvAPI;
|
2023-12-24 15:38:58 +01:00
|
|
|
class CrashHandler;
|
2024-01-21 14:20:21 +01:00
|
|
|
class BttvEmotes;
|
|
|
|
class FfzEmotes;
|
|
|
|
class SeventvEmotes;
|
2024-02-18 13:34:00 +01:00
|
|
|
class ILinkResolver;
|
2024-03-01 21:12:02 +01:00
|
|
|
class IStreamerMode;
|
2024-06-01 14:56:40 +02:00
|
|
|
class IAbstractIrcServer;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2022-05-22 15:00:18 +02:00
|
|
|
class IApplication
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IApplication();
|
|
|
|
virtual ~IApplication() = default;
|
|
|
|
|
|
|
|
static IApplication *instance;
|
|
|
|
|
2024-06-16 12:22:51 +02:00
|
|
|
virtual bool isTest() const = 0;
|
|
|
|
|
2024-01-16 21:56:43 +01:00
|
|
|
virtual const Paths &getPaths() = 0;
|
2023-12-29 15:40:31 +01:00
|
|
|
virtual const Args &getArgs() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
virtual Theme *getThemes() = 0;
|
|
|
|
virtual Fonts *getFonts() = 0;
|
2022-11-05 11:04:35 +01:00
|
|
|
virtual IEmotes *getEmotes() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
virtual AccountController *getAccounts() = 0;
|
|
|
|
virtual HotkeyController *getHotkeys() = 0;
|
|
|
|
virtual WindowManager *getWindows() = 0;
|
|
|
|
virtual Toasts *getToasts() = 0;
|
2023-12-24 15:38:58 +01:00
|
|
|
virtual CrashHandler *getCrashHandler() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
virtual CommandController *getCommands() = 0;
|
2022-06-09 16:37:52 +02:00
|
|
|
virtual HighlightController *getHighlights() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
virtual NotificationController *getNotifications() = 0;
|
2023-05-21 12:10:49 +02:00
|
|
|
virtual ITwitchIrcServer *getTwitch() = 0;
|
2024-06-01 14:56:40 +02:00
|
|
|
virtual IAbstractIrcServer *getTwitchAbstract() = 0;
|
2024-01-06 13:18:37 +01:00
|
|
|
virtual PubSub *getTwitchPubSub() = 0;
|
2024-06-16 12:22:51 +02:00
|
|
|
virtual ILogging *getChatLogger() = 0;
|
2024-01-19 17:25:52 +01:00
|
|
|
virtual IChatterinoBadges *getChatterinoBadges() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
virtual FfzBadges *getFfzBadges() = 0;
|
2023-10-13 17:41:23 +02:00
|
|
|
virtual SeventvBadges *getSeventvBadges() = 0;
|
2022-11-13 18:21:21 +01:00
|
|
|
virtual IUserDataController *getUserData() = 0;
|
2023-11-26 22:06:12 +01:00
|
|
|
virtual ISoundController *getSound() = 0;
|
2023-07-02 15:52:15 +02:00
|
|
|
virtual ITwitchLiveController *getTwitchLiveController() = 0;
|
2024-01-17 23:53:10 +01:00
|
|
|
virtual TwitchBadges *getTwitchBadges() = 0;
|
2023-11-19 12:05:30 +01:00
|
|
|
virtual ImageUploader *getImageUploader() = 0;
|
2023-11-26 16:54:19 +01:00
|
|
|
virtual SeventvAPI *getSeventvAPI() = 0;
|
2024-01-19 17:59:55 +01:00
|
|
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
|
|
|
virtual PluginController *getPlugins() = 0;
|
|
|
|
#endif
|
2024-01-16 21:56:43 +01:00
|
|
|
virtual Updates &getUpdates() = 0;
|
2024-01-21 14:20:21 +01:00
|
|
|
virtual BttvEmotes *getBttvEmotes() = 0;
|
|
|
|
virtual FfzEmotes *getFfzEmotes() = 0;
|
|
|
|
virtual SeventvEmotes *getSeventvEmotes() = 0;
|
2024-02-18 13:34:00 +01:00
|
|
|
virtual ILinkResolver *getLinkResolver() = 0;
|
2024-03-01 21:12:02 +01:00
|
|
|
virtual IStreamerMode *getStreamerMode() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Application : public IApplication
|
2017-06-13 21:13:58 +02:00
|
|
|
{
|
2024-01-16 21:56:43 +01:00
|
|
|
const Paths &paths_;
|
2023-12-29 15:40:31 +01:00
|
|
|
const Args &args_;
|
2018-08-02 14:23:27 +02:00
|
|
|
std::vector<std::unique_ptr<Singleton>> singletons_;
|
2023-09-09 13:11:19 +02:00
|
|
|
int argc_{};
|
|
|
|
char **argv_{};
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
public:
|
2018-08-02 14:23:27 +02:00
|
|
|
static Application *instance;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2024-01-16 21:56:43 +01:00
|
|
|
Application(Settings &_settings, const Paths &paths, const Args &_args,
|
|
|
|
Updates &_updates);
|
2023-12-31 13:51:40 +01:00
|
|
|
~Application() override;
|
|
|
|
|
|
|
|
Application(const Application &) = delete;
|
|
|
|
Application(Application &&) = delete;
|
|
|
|
Application &operator=(const Application &) = delete;
|
|
|
|
Application &operator=(Application &&) = delete;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2024-06-16 12:22:51 +02:00
|
|
|
bool isTest() const override
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-01-06 13:18:37 +01:00
|
|
|
/**
|
|
|
|
* In the interim, before we remove _exit(0); from RunGui.cpp,
|
|
|
|
* this will destroy things we know can be destroyed
|
|
|
|
*/
|
|
|
|
void fakeDtor();
|
|
|
|
|
2024-01-16 21:56:43 +01:00
|
|
|
void initialize(Settings &settings, const Paths &paths);
|
2018-04-27 22:11:19 +02:00
|
|
|
void load();
|
2018-08-02 14:23:27 +02:00
|
|
|
void save();
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
int run(QApplication &qtApp);
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
friend void test();
|
|
|
|
|
2024-01-19 17:59:55 +01:00
|
|
|
private:
|
2018-08-07 01:35:24 +02:00
|
|
|
Theme *const themes{};
|
2024-03-10 14:27:08 +01:00
|
|
|
std::unique_ptr<Fonts> fonts{};
|
2018-08-07 01:35:24 +02:00
|
|
|
Emotes *const emotes{};
|
2020-12-06 14:07:33 +01:00
|
|
|
AccountController *const accounts{};
|
2021-11-21 18:46:21 +01:00
|
|
|
HotkeyController *const hotkeys{};
|
2018-08-07 01:35:24 +02:00
|
|
|
WindowManager *const windows{};
|
2018-08-11 12:47:03 +02:00
|
|
|
Toasts *const toasts{};
|
2023-11-19 12:05:30 +01:00
|
|
|
ImageUploader *const imageUploader{};
|
2023-11-26 16:54:19 +01:00
|
|
|
SeventvAPI *const seventvAPI{};
|
2023-12-24 15:38:58 +01:00
|
|
|
CrashHandler *const crashHandler{};
|
2018-08-07 01:35:24 +02:00
|
|
|
CommandController *const commands{};
|
2018-08-09 15:41:03 +02:00
|
|
|
NotificationController *const notifications{};
|
2022-06-05 17:40:57 +02:00
|
|
|
HighlightController *const highlights{};
|
2024-06-01 14:56:40 +02:00
|
|
|
std::unique_ptr<TwitchIrcServer> twitch;
|
2020-10-25 10:36:00 +01:00
|
|
|
FfzBadges *const ffzBadges{};
|
2022-10-16 13:22:17 +02:00
|
|
|
SeventvBadges *const seventvBadges{};
|
2024-06-16 13:59:12 +02:00
|
|
|
std::unique_ptr<UserDataController> userData;
|
2023-11-26 22:06:12 +01:00
|
|
|
ISoundController *const sound{};
|
2023-07-02 15:52:15 +02:00
|
|
|
TwitchLiveController *const twitchLiveController{};
|
2024-01-06 13:18:37 +01:00
|
|
|
std::unique_ptr<PubSub> twitchPubSub;
|
2024-01-17 23:53:10 +01:00
|
|
|
std::unique_ptr<TwitchBadges> twitchBadges;
|
2024-01-19 17:25:52 +01:00
|
|
|
std::unique_ptr<ChatterinoBadges> chatterinoBadges;
|
2024-01-21 14:20:21 +01:00
|
|
|
std::unique_ptr<BttvEmotes> bttvEmotes;
|
|
|
|
std::unique_ptr<FfzEmotes> ffzEmotes;
|
|
|
|
std::unique_ptr<SeventvEmotes> seventvEmotes;
|
2023-12-31 13:51:40 +01:00
|
|
|
const std::unique_ptr<Logging> logging;
|
2024-02-18 13:34:00 +01:00
|
|
|
std::unique_ptr<ILinkResolver> linkResolver;
|
2024-03-01 21:12:02 +01:00
|
|
|
std::unique_ptr<IStreamerMode> streamerMode;
|
2023-04-02 15:31:53 +02:00
|
|
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
|
|
|
PluginController *const plugins{};
|
|
|
|
#endif
|
|
|
|
|
2024-01-19 17:59:55 +01:00
|
|
|
public:
|
2024-01-16 21:56:43 +01:00
|
|
|
const Paths &getPaths() override
|
|
|
|
{
|
|
|
|
return this->paths_;
|
|
|
|
}
|
2023-12-29 15:40:31 +01:00
|
|
|
const Args &getArgs() override
|
|
|
|
{
|
|
|
|
return this->args_;
|
|
|
|
}
|
2024-01-19 17:59:55 +01:00
|
|
|
Theme *getThemes() override;
|
|
|
|
Fonts *getFonts() override;
|
2022-11-05 11:04:35 +01:00
|
|
|
IEmotes *getEmotes() override;
|
2024-01-19 17:59:55 +01:00
|
|
|
AccountController *getAccounts() override;
|
|
|
|
HotkeyController *getHotkeys() override;
|
|
|
|
WindowManager *getWindows() override;
|
|
|
|
Toasts *getToasts() override;
|
|
|
|
CrashHandler *getCrashHandler() override;
|
|
|
|
CommandController *getCommands() override;
|
|
|
|
NotificationController *getNotifications() override;
|
|
|
|
HighlightController *getHighlights() override;
|
2023-05-21 12:10:49 +02:00
|
|
|
ITwitchIrcServer *getTwitch() override;
|
2024-06-01 14:56:40 +02:00
|
|
|
IAbstractIrcServer *getTwitchAbstract() override;
|
2024-01-06 13:18:37 +01:00
|
|
|
PubSub *getTwitchPubSub() override;
|
2024-06-16 12:22:51 +02:00
|
|
|
ILogging *getChatLogger() override;
|
2024-01-19 17:59:55 +01:00
|
|
|
FfzBadges *getFfzBadges() override;
|
|
|
|
SeventvBadges *getSeventvBadges() override;
|
2022-11-13 18:21:21 +01:00
|
|
|
IUserDataController *getUserData() override;
|
2023-11-26 22:06:12 +01:00
|
|
|
ISoundController *getSound() override;
|
2023-07-02 15:52:15 +02:00
|
|
|
ITwitchLiveController *getTwitchLiveController() override;
|
2024-01-17 23:53:10 +01:00
|
|
|
TwitchBadges *getTwitchBadges() override;
|
2024-01-19 17:25:52 +01:00
|
|
|
IChatterinoBadges *getChatterinoBadges() override;
|
2024-01-19 17:59:55 +01:00
|
|
|
ImageUploader *getImageUploader() override;
|
|
|
|
SeventvAPI *getSeventvAPI() override;
|
|
|
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
|
|
|
PluginController *getPlugins() override;
|
|
|
|
#endif
|
2024-01-16 21:56:43 +01:00
|
|
|
Updates &getUpdates() override
|
|
|
|
{
|
2024-01-18 20:50:57 +01:00
|
|
|
assertInGuiThread();
|
|
|
|
|
2024-01-16 21:56:43 +01:00
|
|
|
return this->updates;
|
|
|
|
}
|
2022-05-22 15:00:18 +02:00
|
|
|
|
2024-01-21 14:20:21 +01:00
|
|
|
BttvEmotes *getBttvEmotes() override;
|
|
|
|
FfzEmotes *getFfzEmotes() override;
|
|
|
|
SeventvEmotes *getSeventvEmotes() override;
|
|
|
|
|
2024-02-18 13:34:00 +01:00
|
|
|
ILinkResolver *getLinkResolver() override;
|
2024-03-01 21:12:02 +01:00
|
|
|
IStreamerMode *getStreamerMode() override;
|
2023-05-27 12:38:25 +02:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
private:
|
2018-07-07 11:41:01 +02:00
|
|
|
void addSingleton(Singleton *singleton);
|
2022-05-07 17:22:39 +02:00
|
|
|
void initPubSub();
|
2023-01-21 15:06:55 +01:00
|
|
|
void initBttvLiveUpdates();
|
2022-11-13 12:07:41 +01:00
|
|
|
void initSeventvEventAPI();
|
2024-01-16 21:56:43 +01:00
|
|
|
void initNm(const Paths &paths);
|
2018-08-02 14:23:27 +02:00
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
template <typename T,
|
|
|
|
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
|
2018-08-02 14:23:27 +02:00
|
|
|
T &emplace()
|
|
|
|
{
|
|
|
|
auto t = new T;
|
|
|
|
this->singletons_.push_back(std::unique_ptr<T>(t));
|
|
|
|
return *t;
|
|
|
|
}
|
2018-09-17 12:51:16 +02:00
|
|
|
|
2023-11-26 22:06:12 +01:00
|
|
|
template <typename T,
|
|
|
|
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
|
|
|
|
T &emplace(T *t)
|
|
|
|
{
|
|
|
|
this->singletons_.push_back(std::unique_ptr<T>(t));
|
|
|
|
return *t;
|
|
|
|
}
|
|
|
|
|
2018-09-17 12:51:16 +02:00
|
|
|
NativeMessagingServer nmServer{};
|
2024-01-16 21:56:43 +01:00
|
|
|
Updates &updates;
|
2017-06-13 21:13:58 +02:00
|
|
|
};
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
Application *getApp();
|
|
|
|
|
2022-05-22 15:00:18 +02:00
|
|
|
// Get an interface version of the Application class - should be preferred when possible for new code
|
|
|
|
IApplication *getIApp();
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
} // namespace chatterino
|