2020-08-17 06:40:03 +00:00
|
|
|
#include <gtkmm.h>
|
2020-08-19 05:07:55 +00:00
|
|
|
#include <memory>
|
2020-08-19 05:13:36 +00:00
|
|
|
#include <mutex>
|
2020-08-19 05:07:55 +00:00
|
|
|
#include <string>
|
2020-08-20 07:19:16 +00:00
|
|
|
#include <unordered_set>
|
2020-08-17 06:40:03 +00:00
|
|
|
#include "discord/discord.hpp"
|
2020-08-19 05:07:55 +00:00
|
|
|
#include "windows/mainwindow.hpp"
|
|
|
|
#include "settings.hpp"
|
2020-09-12 07:17:34 +00:00
|
|
|
#include "imgmanager.hpp"
|
2020-10-24 23:42:06 +00:00
|
|
|
#include "emojis.hpp"
|
2020-08-17 06:40:03 +00:00
|
|
|
|
2020-09-03 06:32:28 +00:00
|
|
|
#define APP_TITLE "Abaddon"
|
|
|
|
|
2020-08-17 06:40:03 +00:00
|
|
|
class Abaddon {
|
2020-09-07 04:27:41 +00:00
|
|
|
private:
|
2020-08-19 05:07:55 +00:00
|
|
|
Abaddon();
|
|
|
|
~Abaddon();
|
2020-09-07 04:27:41 +00:00
|
|
|
Abaddon(const Abaddon &) = delete;
|
|
|
|
Abaddon &operator=(const Abaddon &) = delete;
|
|
|
|
Abaddon(Abaddon &&) = delete;
|
|
|
|
Abaddon &operator=(Abaddon &&) = delete;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static Abaddon &Get();
|
2020-08-19 05:07:55 +00:00
|
|
|
|
|
|
|
int StartGTK();
|
|
|
|
void StartDiscord();
|
|
|
|
void StopDiscord();
|
|
|
|
|
|
|
|
void LoadFromSettings();
|
2020-08-17 06:40:03 +00:00
|
|
|
|
|
|
|
void ActionConnect();
|
2020-08-19 05:07:55 +00:00
|
|
|
void ActionDisconnect();
|
|
|
|
void ActionSetToken();
|
2020-09-21 22:47:34 +00:00
|
|
|
void ActionJoinGuildDialog();
|
2020-11-01 04:13:52 +00:00
|
|
|
void ActionChannelOpened(Snowflake id);
|
2020-08-22 02:25:23 +00:00
|
|
|
void ActionChatInputSubmit(std::string msg, Snowflake channel);
|
2020-08-28 22:21:08 +00:00
|
|
|
void ActionChatLoadHistory(Snowflake id);
|
2020-08-30 06:00:56 +00:00
|
|
|
void ActionChatDeleteMessage(Snowflake channel_id, Snowflake id);
|
2020-08-31 02:55:36 +00:00
|
|
|
void ActionChatEditMessage(Snowflake channel_id, Snowflake id);
|
2020-09-06 06:25:19 +00:00
|
|
|
void ActionInsertMention(Snowflake id);
|
2020-09-21 22:47:34 +00:00
|
|
|
void ActionLeaveGuild(Snowflake id);
|
2020-10-12 22:17:53 +00:00
|
|
|
void ActionKickMember(Snowflake user_id, Snowflake guild_id);
|
|
|
|
void ActionBanMember(Snowflake user_id, Snowflake guild_id);
|
2020-11-01 07:53:37 +00:00
|
|
|
void ActionSetStatus();
|
2020-12-15 06:51:49 +00:00
|
|
|
void ActionReactionAdd(Snowflake id, const Glib::ustring ¶m);
|
|
|
|
void ActionReactionRemove(Snowflake id, const Glib::ustring ¶m);
|
2021-01-15 06:37:35 +00:00
|
|
|
void ActionGuildSettings(Snowflake id);
|
2021-02-18 19:38:40 +00:00
|
|
|
void ActionAddRecipient(Snowflake channel_id);
|
2020-08-19 05:07:55 +00:00
|
|
|
|
2020-12-18 07:05:24 +00:00
|
|
|
void ActionReloadSettings();
|
2020-09-03 04:47:49 +00:00
|
|
|
void ActionReloadCSS();
|
|
|
|
|
2020-09-12 07:17:34 +00:00
|
|
|
ImageManager &GetImageManager();
|
2020-10-24 23:42:06 +00:00
|
|
|
EmojiResource &GetEmojis();
|
2020-09-10 22:28:42 +00:00
|
|
|
|
2020-08-19 05:07:55 +00:00
|
|
|
std::string GetDiscordToken() const;
|
|
|
|
bool IsDiscordActive() const;
|
2020-08-17 06:40:03 +00:00
|
|
|
|
2020-09-21 22:47:34 +00:00
|
|
|
DiscordClient &GetDiscordClient();
|
2020-08-19 05:13:36 +00:00
|
|
|
const DiscordClient &GetDiscordClient() const;
|
2020-09-07 03:34:29 +00:00
|
|
|
void DiscordOnReady();
|
|
|
|
void DiscordOnMessageCreate(Snowflake id);
|
|
|
|
void DiscordOnMessageDelete(Snowflake id, Snowflake channel_id);
|
|
|
|
void DiscordOnMessageUpdate(Snowflake id, Snowflake channel_id);
|
|
|
|
void DiscordOnGuildMemberListUpdate(Snowflake guild_id);
|
2020-09-21 22:47:34 +00:00
|
|
|
void DiscordOnGuildCreate(Snowflake guild_id);
|
|
|
|
void DiscordOnGuildDelete(Snowflake guild_id);
|
2020-10-20 00:35:10 +00:00
|
|
|
void DiscordOnChannelDelete(Snowflake channel_id);
|
|
|
|
void DiscordOnChannelUpdate(Snowflake channel_id);
|
|
|
|
void DiscordOnChannelCreate(Snowflake channel_id);
|
2020-11-01 04:01:48 +00:00
|
|
|
void DiscordOnGuildUpdate(Snowflake guild_id);
|
2020-12-15 06:51:49 +00:00
|
|
|
void DiscordOnReactionAdd(Snowflake message_id, const Glib::ustring ¶m);
|
|
|
|
void DiscordOnReactionRemove(Snowflake message_id, const Glib::ustring ¶m);
|
2021-01-25 05:47:48 +00:00
|
|
|
void DiscordOnDisconnect(bool is_reconnecting, GatewayCloseCode close_code);
|
2020-08-19 05:13:36 +00:00
|
|
|
|
2020-10-04 06:28:48 +00:00
|
|
|
const SettingsManager &GetSettings() const;
|
|
|
|
|
2021-01-15 06:37:35 +00:00
|
|
|
Glib::RefPtr<Gtk::CssProvider> GetStyleProvider();
|
|
|
|
|
2021-02-28 07:00:15 +00:00
|
|
|
void ShowUserMenu(const GdkEvent *event, Snowflake id, Snowflake guild_id);
|
|
|
|
|
2020-11-08 05:44:26 +00:00
|
|
|
protected:
|
|
|
|
Snowflake m_shown_user_menu_id;
|
|
|
|
Snowflake m_shown_user_menu_guild_id;
|
|
|
|
|
|
|
|
Gtk::Menu *m_user_menu;
|
2021-02-05 04:41:53 +00:00
|
|
|
Gtk::MenuItem *m_user_menu_info;
|
2020-11-08 05:44:26 +00:00
|
|
|
Gtk::MenuItem *m_user_menu_insert_mention;
|
|
|
|
Gtk::MenuItem *m_user_menu_ban;
|
|
|
|
Gtk::MenuItem *m_user_menu_kick;
|
|
|
|
Gtk::MenuItem *m_user_menu_copy_id;
|
2020-11-08 06:23:50 +00:00
|
|
|
Gtk::MenuItem *m_user_menu_open_dm;
|
2021-01-17 04:48:19 +00:00
|
|
|
Gtk::MenuItem *m_user_menu_roles;
|
2021-02-18 17:45:14 +00:00
|
|
|
Gtk::MenuItem *m_user_menu_remove_recipient;
|
2021-01-17 04:48:19 +00:00
|
|
|
Gtk::Menu *m_user_menu_roles_submenu;
|
2020-11-08 05:44:26 +00:00
|
|
|
|
|
|
|
void on_user_menu_insert_mention();
|
|
|
|
void on_user_menu_ban();
|
|
|
|
void on_user_menu_kick();
|
|
|
|
void on_user_menu_copy_id();
|
2020-11-08 06:23:50 +00:00
|
|
|
void on_user_menu_open_dm();
|
2021-02-18 17:45:14 +00:00
|
|
|
void on_user_menu_remove_recipient();
|
2020-11-08 05:44:26 +00:00
|
|
|
|
2020-08-17 06:40:03 +00:00
|
|
|
private:
|
2020-11-24 01:34:09 +00:00
|
|
|
SettingsManager m_settings;
|
|
|
|
|
2020-08-20 07:19:16 +00:00
|
|
|
DiscordClient m_discord;
|
2020-08-19 05:07:55 +00:00
|
|
|
std::string m_discord_token;
|
2020-08-28 22:21:08 +00:00
|
|
|
// todo make these map snowflake to attribs
|
2020-08-20 07:19:16 +00:00
|
|
|
std::unordered_set<Snowflake> m_channels_requested;
|
2020-08-28 22:21:08 +00:00
|
|
|
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;
|
2020-08-20 07:19:16 +00:00
|
|
|
|
2020-09-12 07:17:34 +00:00
|
|
|
ImageManager m_img_mgr;
|
2020-10-24 23:42:06 +00:00
|
|
|
EmojiResource m_emojis;
|
2020-09-10 22:28:42 +00:00
|
|
|
|
2020-08-19 05:13:36 +00:00
|
|
|
mutable std::mutex m_mutex;
|
2020-08-17 06:40:03 +00:00
|
|
|
Glib::RefPtr<Gtk::Application> m_gtk_app;
|
2020-09-03 04:47:49 +00:00
|
|
|
Glib::RefPtr<Gtk::CssProvider> m_css_provider;
|
2020-08-19 05:07:55 +00:00
|
|
|
std::unique_ptr<MainWindow> m_main_window; // wah wah cant create a gtkstylecontext fuck you
|
2020-08-19 05:13:36 +00:00
|
|
|
};
|