summaryrefslogtreecommitdiff
path: root/abaddon.hpp
blob: 9b4bf8119eba79a8f1ebf3270d97b416392ebcbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <gtkmm.h>
#include <memory>
#include <mutex>
#include <string>
#include <unordered_set>
#include "discord/discord.hpp"
#include "windows/mainwindow.hpp"
#include "settings.hpp"
#include "imgmanager.hpp"

#define APP_TITLE "Abaddon"

class Abaddon {
private:
    Abaddon();
    ~Abaddon();
    Abaddon(const Abaddon &) = delete;
    Abaddon &operator=(const Abaddon &) = delete;
    Abaddon(Abaddon &&) = delete;
    Abaddon &operator=(Abaddon &&) = delete;

public:
    static Abaddon &Get();

    int StartGTK();
    void StartDiscord();
    void StopDiscord();

    void LoadFromSettings();

    void ActionConnect();
    void ActionDisconnect();
    void ActionSetToken();
    void ActionMoveGuildUp(Snowflake id);
    void ActionMoveGuildDown(Snowflake id);
    void ActionCopyGuildID(Snowflake id);
    void ActionListChannelItemClick(Snowflake id);
    void ActionChatInputSubmit(std::string msg, Snowflake channel);
    void ActionChatLoadHistory(Snowflake id);
    void ActionChatDeleteMessage(Snowflake channel_id, Snowflake id);
    void ActionChatEditMessage(Snowflake channel_id, Snowflake id);
    void ActionInsertMention(Snowflake id);

    void ActionReloadCSS();

    ImageManager &GetImageManager();

    std::string GetDiscordToken() const;
    bool IsDiscordActive() const;

    const DiscordClient &GetDiscordClient() const;
    void DiscordOnReady();
    void DiscordOnChannelListRefresh();
    void DiscordOnMessageCreate(Snowflake id);
    void DiscordOnMessageDelete(Snowflake id, Snowflake channel_id);
    void DiscordOnMessageUpdate(Snowflake id, Snowflake channel_id);
    void DiscordOnGuildMemberListUpdate(Snowflake guild_id);

private:
    DiscordClient m_discord;
    std::string m_discord_token;
    // todo make these map snowflake to attribs
    std::unordered_set<Snowflake> m_channels_requested;
    std::unordered_set<Snowflake> m_channels_history_loaded;
    std::unordered_map<Snowflake, Snowflake> m_oldest_listed_message;
    std::unordered_set<Snowflake> m_channels_history_loading;

    ImageManager m_img_mgr;

    mutable std::mutex m_mutex;
    Glib::RefPtr<Gtk::Application> m_gtk_app;
    Glib::RefPtr<Gtk::CssProvider> m_css_provider;
    SettingsManager m_settings;
    std::unique_ptr<MainWindow> m_main_window; // wah wah cant create a gtkstylecontext fuck you
};