mirror-chatterino2/src/Application.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

234 lines
7 KiB
C++
Raw Normal View History

#pragma once
2019-09-22 10:53:39 +02:00
#include "singletons/NativeMessaging.hpp"
#include <QApplication>
#include <cassert>
#include <memory>
namespace chatterino {
class Args;
class TwitchIrcServer;
class ITwitchIrcServer;
class PubSub;
class Updates;
class CommandController;
class AccountController;
class NotificationController;
class HighlightController;
class HotkeyController;
class IUserDataController;
class UserDataController;
class ISoundController;
class SoundController;
class ITwitchLiveController;
class TwitchLiveController;
class TwitchBadges;
#ifdef CHATTERINO_HAVE_PLUGINS
class PluginController;
#endif
2018-06-28 20:03:04 +02:00
class Theme;
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;
class IChatterinoBadges;
class ChatterinoBadges;
class FfzBadges;
class SeventvBadges;
class ImageUploader;
class SeventvAPI;
class CrashHandler;
class BttvEmotes;
class BttvLiveUpdates;
class FfzEmotes;
class SeventvEmotes;
class SeventvEventAPI;
class ILinkResolver;
class IStreamerMode;
2022-05-22 15:00:18 +02:00
class IApplication
{
public:
IApplication();
virtual ~IApplication();
2022-05-22 15:00:18 +02:00
IApplication(const IApplication &) = delete;
IApplication(IApplication &&) = delete;
IApplication &operator=(const IApplication &) = delete;
IApplication &operator=(IApplication &&) = delete;
2022-05-22 15:00:18 +02:00
2024-06-16 12:22:51 +02:00
virtual bool isTest() const = 0;
virtual const Paths &getPaths() = 0;
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;
virtual CrashHandler *getCrashHandler() = 0;
2022-05-22 15:00:18 +02:00
virtual CommandController *getCommands() = 0;
virtual HighlightController *getHighlights() = 0;
2022-05-22 15:00:18 +02:00
virtual NotificationController *getNotifications() = 0;
virtual ITwitchIrcServer *getTwitch() = 0;
virtual PubSub *getTwitchPubSub() = 0;
2024-06-16 12:22:51 +02:00
virtual ILogging *getChatLogger() = 0;
virtual IChatterinoBadges *getChatterinoBadges() = 0;
2022-05-22 15:00:18 +02:00
virtual FfzBadges *getFfzBadges() = 0;
virtual SeventvBadges *getSeventvBadges() = 0;
virtual IUserDataController *getUserData() = 0;
virtual ISoundController *getSound() = 0;
virtual ITwitchLiveController *getTwitchLiveController() = 0;
virtual TwitchBadges *getTwitchBadges() = 0;
virtual ImageUploader *getImageUploader() = 0;
virtual SeventvAPI *getSeventvAPI() = 0;
#ifdef CHATTERINO_HAVE_PLUGINS
virtual PluginController *getPlugins() = 0;
#endif
virtual Updates &getUpdates() = 0;
virtual BttvEmotes *getBttvEmotes() = 0;
virtual BttvLiveUpdates *getBttvLiveUpdates() = 0;
virtual FfzEmotes *getFfzEmotes() = 0;
virtual SeventvEmotes *getSeventvEmotes() = 0;
virtual SeventvEventAPI *getSeventvEventAPI() = 0;
virtual ILinkResolver *getLinkResolver() = 0;
virtual IStreamerMode *getStreamerMode() = 0;
2022-05-22 15:00:18 +02:00
};
class Application : public IApplication
{
const Paths &paths_;
const Args &args_;
int argc_{};
char **argv_{};
public:
Application(Settings &_settings, const Paths &paths, const Args &_args,
Updates &_updates);
~Application() override;
Application(const Application &) = delete;
Application(Application &&) = delete;
Application &operator=(const Application &) = delete;
Application &operator=(Application &&) = delete;
2024-06-16 12:22:51 +02:00
bool isTest() const override
{
return false;
}
void initialize(Settings &settings, const Paths &paths);
void load();
2018-08-02 14:23:27 +02:00
void save();
int run(QApplication &qtApp);
friend void test();
private:
std::unique_ptr<Theme> themes;
std::unique_ptr<Fonts> fonts;
std::unique_ptr<Emotes> emotes;
std::unique_ptr<AccountController> accounts;
std::unique_ptr<HotkeyController> hotkeys;
std::unique_ptr<WindowManager> windows;
std::unique_ptr<Toasts> toasts;
std::unique_ptr<ImageUploader> imageUploader;
std::unique_ptr<SeventvAPI> seventvAPI;
std::unique_ptr<CrashHandler> crashHandler;
std::unique_ptr<CommandController> commands;
std::unique_ptr<NotificationController> notifications;
std::unique_ptr<HighlightController> highlights;
std::unique_ptr<TwitchIrcServer> twitch;
std::unique_ptr<FfzBadges> ffzBadges;
std::unique_ptr<SeventvBadges> seventvBadges;
std::unique_ptr<UserDataController> userData;
std::unique_ptr<ISoundController> sound;
std::unique_ptr<TwitchLiveController> twitchLiveController;
std::unique_ptr<PubSub> twitchPubSub;
std::unique_ptr<TwitchBadges> twitchBadges;
std::unique_ptr<ChatterinoBadges> chatterinoBadges;
std::unique_ptr<BttvEmotes> bttvEmotes;
std::unique_ptr<BttvLiveUpdates> bttvLiveUpdates;
std::unique_ptr<FfzEmotes> ffzEmotes;
std::unique_ptr<SeventvEmotes> seventvEmotes;
std::unique_ptr<SeventvEventAPI> seventvEventAPI;
const std::unique_ptr<Logging> logging;
std::unique_ptr<ILinkResolver> linkResolver;
std::unique_ptr<IStreamerMode> streamerMode;
#ifdef CHATTERINO_HAVE_PLUGINS
std::unique_ptr<PluginController> plugins;
#endif
public:
const Paths &getPaths() override
{
return this->paths_;
}
const Args &getArgs() override
{
return this->args_;
}
Theme *getThemes() override;
Fonts *getFonts() override;
2022-11-05 11:04:35 +01:00
IEmotes *getEmotes() override;
AccountController *getAccounts() override;
HotkeyController *getHotkeys() override;
WindowManager *getWindows() override;
Toasts *getToasts() override;
CrashHandler *getCrashHandler() override;
CommandController *getCommands() override;
NotificationController *getNotifications() override;
HighlightController *getHighlights() override;
ITwitchIrcServer *getTwitch() override;
PubSub *getTwitchPubSub() override;
2024-06-16 12:22:51 +02:00
ILogging *getChatLogger() override;
FfzBadges *getFfzBadges() override;
SeventvBadges *getSeventvBadges() override;
IUserDataController *getUserData() override;
ISoundController *getSound() override;
ITwitchLiveController *getTwitchLiveController() override;
TwitchBadges *getTwitchBadges() override;
IChatterinoBadges *getChatterinoBadges() override;
ImageUploader *getImageUploader() override;
SeventvAPI *getSeventvAPI() override;
#ifdef CHATTERINO_HAVE_PLUGINS
PluginController *getPlugins() override;
#endif
Updates &getUpdates() override;
2022-05-22 15:00:18 +02:00
BttvEmotes *getBttvEmotes() override;
BttvLiveUpdates *getBttvLiveUpdates() override;
FfzEmotes *getFfzEmotes() override;
SeventvEmotes *getSeventvEmotes() override;
SeventvEventAPI *getSeventvEventAPI() override;
ILinkResolver *getLinkResolver() override;
IStreamerMode *getStreamerMode() override;
private:
void initPubSub();
void initBttvLiveUpdates();
void initSeventvEventAPI();
void initNm(const Paths &paths);
2018-08-02 14:23:27 +02:00
NativeMessagingServer nmServer;
Updates &updates;
};
IApplication *getApp();
2022-05-22 15:00:18 +02:00
} // namespace chatterino