From 3027e00905b19282a4f501a26f7a4f71bc6940ea Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 25 Sep 2022 01:44:09 -0400 Subject: [PATCH 1/9] open browser on mouse release (fixes #108) --- src/components/chatmessage.cpp | 8 ++++---- src/windows/guildsettings/infopane.cpp | 7 +++---- src/windows/profile/userinfopane.cpp | 4 ++-- src/windows/profilewindow.cpp | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index 89c924e..3afdf9f 100644 --- a/src/components/chatmessage.cpp +++ b/src/components/chatmessage.cpp @@ -150,8 +150,8 @@ void ChatMessageItemContainer::UpdateAttributes() { void ChatMessageItemContainer::AddClickHandler(Gtk::Widget *widget, const std::string &url) { // clang-format off - widget->signal_button_press_event().connect([url](GdkEventButton *event) -> bool { - if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { + widget->signal_button_release_event().connect([url](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_RELEASE && event->button == GDK_BUTTON_PRIMARY) { LaunchBrowser(url); return true; } @@ -357,8 +357,8 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const EmbedData &emb if (embed.URL.has_value()) { AddPointerCursor(*title_ev); auto url = *embed.URL; - title_ev->signal_button_press_event().connect([url = std::move(url)](GdkEventButton *event) -> bool { - if (event->button == GDK_BUTTON_PRIMARY) { + title_ev->signal_button_release_event().connect([url = std::move(url)](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_RELEASE && event->button == GDK_BUTTON_PRIMARY) { LaunchBrowser(url); return true; } diff --git a/src/windows/guildsettings/infopane.cpp b/src/windows/guildsettings/infopane.cpp index 578aaac..a27c1a8 100644 --- a/src/windows/guildsettings/infopane.cpp +++ b/src/windows/guildsettings/infopane.cpp @@ -56,10 +56,9 @@ GuildSettingsInfoPane::GuildSettingsInfoPane(Snowflake id) guild_icon_url = guild.GetIconURL("gif", "512"); else guild_icon_url = guild.GetIconURL("png", "512"); - m_guild_icon_ev.signal_button_press_event().connect([guild_icon_url](GdkEventButton *event) -> bool { - if (event->type == GDK_BUTTON_PRESS) - if (event->button == GDK_BUTTON_PRIMARY) - LaunchBrowser(guild_icon_url); + m_guild_icon_ev.signal_button_release_event().connect([guild_icon_url](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_RELEASE && event->button == GDK_BUTTON_PRIMARY) + LaunchBrowser(guild_icon_url); return false; }); diff --git a/src/windows/profile/userinfopane.cpp b/src/windows/profile/userinfopane.cpp index a17dbff..b62da93 100644 --- a/src/windows/profile/userinfopane.cpp +++ b/src/windows/profile/userinfopane.cpp @@ -41,13 +41,13 @@ ConnectionItem::ConnectionItem(const ConnectionData &conn) m_box.add(m_name); if (!url.empty()) { auto cb = [url](GdkEventButton *event) -> bool { - if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { + if (event->type == GDK_BUTTON_RELEASE && event->button == GDK_BUTTON_PRIMARY) { LaunchBrowser(url); return true; } return false; }; - signal_button_press_event().connect(sigc::track_obj(cb, *this)); + signal_button_release_event().connect(sigc::track_obj(cb, *this)); AddPointerCursor(*this); } m_overlay.add(m_box); diff --git a/src/windows/profilewindow.cpp b/src/windows/profilewindow.cpp index aff98c5..d73731d 100644 --- a/src/windows/profilewindow.cpp +++ b/src/windows/profilewindow.cpp @@ -34,8 +34,8 @@ ProfileWindow::ProfileWindow(Snowflake user_id) if (user.HasAvatar()) AddPointerCursor(m_avatar_ev); - m_avatar_ev.signal_button_press_event().connect([user](GdkEventButton *event) -> bool { - if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { + m_avatar_ev.signal_button_release_event().connect([user](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_RELEASE && event->button == GDK_BUTTON_PRIMARY) { if (user.HasAnimatedAvatar()) LaunchBrowser(user.GetAvatarURL("gif", "512")); else From 7e851685768d26143e7464fc4acb2d2d5a621eac Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 6 Oct 2022 02:34:45 -0400 Subject: [PATCH 2/9] remove a bunch of unnecessary fields from user settings --- src/discord/usersettings.cpp | 28 ------------------ src/discord/usersettings.hpp | 57 ++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 56 deletions(-) diff --git a/src/discord/usersettings.cpp b/src/discord/usersettings.cpp index e4ab41a..8f57ee3 100644 --- a/src/discord/usersettings.cpp +++ b/src/discord/usersettings.cpp @@ -8,33 +8,5 @@ void from_json(const nlohmann::json &j, UserSettingsGuildFoldersEntry &m) { } void from_json(const nlohmann::json &j, UserSettings &m) { - JS_D("timezone_offset", m.TimezoneOffset); - JS_D("theme", m.Theme); - JS_D("stream_notifications_enabled", m.AreStreamNotificationsEnabled); - JS_D("status", m.Status); - JS_D("show_current_game", m.ShouldShowCurrentGame); - // JS_D("restricted_guilds", m.RestrictedGuilds); - JS_D("render_reactions", m.ShouldRenderReactions); - JS_D("render_embeds", m.ShouldRenderEmbeds); - JS_D("native_phone_integration_enabled", m.IsNativePhoneIntegrationEnabled); - JS_D("message_display_compact", m.ShouldMessageDisplayCompact); - JS_D("locale", m.Locale); - JS_D("inline_embed_media", m.ShouldInlineEmbedMedia); - JS_D("inline_attachment_media", m.ShouldInlineAttachmentMedia); - JS_D("guild_positions", m.GuildPositions); JS_D("guild_folders", m.GuildFolders); - JS_D("gif_auto_play", m.ShouldGIFAutoplay); - // JS_D("friend_source_flags", m.FriendSourceFlags); - JS_D("explicit_content_filter", m.ExplicitContentFilter); - JS_D("enable_tts_command", m.IsTTSCommandEnabled); - JS_D("disable_games_tab", m.ShouldDisableGamesTab); - JS_D("developer_mode", m.DeveloperMode); - JS_D("detect_platform_accounts", m.ShouldDetectPlatformAccounts); - JS_D("default_guilds_restricted", m.AreDefaultGuildsRestricted); - // JS_N("custom_status", m.CustomStatus); - JS_D("convert_emoticons", m.ShouldConvertEmoticons); - JS_D("contact_sync_enabled", m.IsContactSyncEnabled); - JS_D("animate_emoji", m.ShouldAnimateEmojis); - JS_D("allow_accessibility_detection", m.IsAccessibilityDetectionAllowed); - JS_D("afk_timeout", m.AFKTimeout); } diff --git a/src/discord/usersettings.hpp b/src/discord/usersettings.hpp index 2baf61e..2631c45 100644 --- a/src/discord/usersettings.hpp +++ b/src/discord/usersettings.hpp @@ -13,35 +13,36 @@ struct UserSettingsGuildFoldersEntry { }; struct UserSettings { - int TimezoneOffset; // - std::string Theme; // - bool AreStreamNotificationsEnabled; // - std::string Status; // - bool ShouldShowCurrentGame; // - // std::vector RestrictedGuilds; // - bool ShouldRenderReactions; // - bool ShouldRenderEmbeds; // - bool IsNativePhoneIntegrationEnabled; // - bool ShouldMessageDisplayCompact; // - std::string Locale; // - bool ShouldInlineEmbedMedia; // - bool ShouldInlineAttachmentMedia; // - std::vector GuildPositions; // deprecated? - std::vector GuildFolders; // - bool ShouldGIFAutoplay; // - // Unknown FriendSourceFlags; // - int ExplicitContentFilter; // - bool IsTTSCommandEnabled; // - bool ShouldDisableGamesTab; // - bool DeveloperMode; // - bool ShouldDetectPlatformAccounts; // - bool AreDefaultGuildsRestricted; // + std::vector GuildFolders; + /* + int TimezoneOffset; + std::string Theme; + bool AreStreamNotificationsEnabled; + std::string Status; + bool ShouldShowCurrentGame; + // std::vector RestrictedGuilds; + bool ShouldRenderReactions; + bool ShouldRenderEmbeds; + bool IsNativePhoneIntegrationEnabled; + bool ShouldMessageDisplayCompact; + std::string Locale; + bool ShouldInlineEmbedMedia; + bool ShouldInlineAttachmentMedia; + std::vector GuildPositions; // deprecated? + bool ShouldGIFAutoplay; + // Unknown FriendSourceFlags; + int ExplicitContentFilter; + bool IsTTSCommandEnabled; + bool ShouldDisableGamesTab; + bool DeveloperMode; + bool ShouldDetectPlatformAccounts; + bool AreDefaultGuildsRestricted; // Unknown CustomStatus; // null - bool ShouldConvertEmoticons; // - bool IsContactSyncEnabled; // - bool ShouldAnimateEmojis; // - bool IsAccessibilityDetectionAllowed; // - int AFKTimeout; + bool ShouldConvertEmoticons; + bool IsContactSyncEnabled; + bool ShouldAnimateEmojis; + bool IsAccessibilityDetectionAllowed; + int AFKTimeout;*/ friend void from_json(const nlohmann::json &j, UserSettings &m); }; From 0a34c04b44d3f500317a319d497ce2064fdd852f Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 6 Oct 2022 03:08:54 -0400 Subject: [PATCH 3/9] remove ability to join guilds because 1. joining a guild seems to often require captchas now which are never going to be supported and 2. joining guilds is one of the things that upsets discords spam filter the most, so it kinda makes sense to remove anyways just like open dm --- src/abaddon.cpp | 11 ----- src/dialogs/joinguild.cpp | 97 -------------------------------------- src/dialogs/joinguild.hpp | 31 ------------ src/discord/discord.cpp | 4 -- src/discord/discord.hpp | 1 - src/windows/mainwindow.cpp | 12 ----- src/windows/mainwindow.hpp | 4 -- 7 files changed, 160 deletions(-) delete mode 100644 src/dialogs/joinguild.cpp delete mode 100644 src/dialogs/joinguild.hpp diff --git a/src/abaddon.cpp b/src/abaddon.cpp index 02dcd08..ec567e7 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -6,7 +6,6 @@ #include "discord/discord.hpp" #include "dialogs/token.hpp" #include "dialogs/editmessage.hpp" -#include "dialogs/joinguild.hpp" #include "dialogs/confirm.hpp" #include "dialogs/setstatus.hpp" #include "dialogs/friendpicker.hpp" @@ -229,7 +228,6 @@ int Abaddon::StartGTK() { m_main_window->signal_action_disconnect().connect(sigc::mem_fun(*this, &Abaddon::ActionDisconnect)); m_main_window->signal_action_set_token().connect(sigc::mem_fun(*this, &Abaddon::ActionSetToken)); m_main_window->signal_action_reload_css().connect(sigc::mem_fun(*this, &Abaddon::ActionReloadCSS)); - m_main_window->signal_action_join_guild().connect(sigc::mem_fun(*this, &Abaddon::ActionJoinGuildDialog)); m_main_window->signal_action_set_status().connect(sigc::mem_fun(*this, &Abaddon::ActionSetStatus)); m_main_window->signal_action_add_recipient().connect(sigc::mem_fun(*this, &Abaddon::ActionAddRecipient)); m_main_window->signal_action_view_pins().connect(sigc::mem_fun(*this, &Abaddon::ActionViewPins)); @@ -693,15 +691,6 @@ void Abaddon::ActionSetToken() { m_main_window->UpdateMenus(); } -void Abaddon::ActionJoinGuildDialog() { - JoinGuildDialog dlg(*m_main_window); - auto response = dlg.run(); - if (response == Gtk::RESPONSE_OK) { - auto code = dlg.GetCode(); - m_discord.JoinGuild(code); - } -} - void Abaddon::ActionChannelOpened(Snowflake id, bool expand_to) { if (!id.IsValid()) { m_discord.SetReferringChannel(Snowflake::Invalid); diff --git a/src/dialogs/joinguild.cpp b/src/dialogs/joinguild.cpp deleted file mode 100644 index 14fab53..0000000 --- a/src/dialogs/joinguild.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "joinguild.hpp" -#include "abaddon.hpp" -#include -#include - -JoinGuildDialog::JoinGuildDialog(Gtk::Window &parent) - : Gtk::Dialog("Join Server", parent, true) - , m_layout(Gtk::ORIENTATION_VERTICAL) - , m_ok("OK") - , m_cancel("Cancel") - , m_info("Enter code") { - set_default_size(300, 50); - get_style_context()->add_class("app-window"); - get_style_context()->add_class("app-popup"); - - Glib::signal_idle().connect(sigc::mem_fun(*this, &JoinGuildDialog::on_idle_slot)); - - m_entry.signal_changed().connect(sigc::mem_fun(*this, &JoinGuildDialog::on_entry_changed)); - - m_ok.set_sensitive(false); - - m_ok.signal_clicked().connect([&]() { - response(Gtk::RESPONSE_OK); - }); - - m_cancel.signal_clicked().connect([&]() { - response(Gtk::RESPONSE_CANCEL); - }); - - m_entry.set_hexpand(true); - m_layout.add(m_entry); - m_lower.set_hexpand(true); - m_lower.pack_start(m_info); - m_info.set_halign(Gtk::ALIGN_START); - m_lower.pack_start(m_ok, Gtk::PACK_SHRINK); - m_lower.pack_start(m_cancel, Gtk::PACK_SHRINK); - m_ok.set_halign(Gtk::ALIGN_END); - m_cancel.set_halign(Gtk::ALIGN_END); - m_layout.add(m_lower); - get_content_area()->add(m_layout); - - show_all_children(); -} - -void JoinGuildDialog::on_entry_changed() { - std::string s = m_entry.get_text(); - std::regex invite_regex(R"((https?:\/\/)?discord\.(gg(\/invite)?\/|com\/invite\/)([A-Za-z0-9\-]+))", std::regex_constants::ECMAScript); - std::smatch match; - bool full_url = std::regex_search(s, match, invite_regex); - if (full_url || IsCode(s)) { - m_code = full_url ? match[4].str() : s; - m_needs_request = true; - m_ok.set_sensitive(false); - } else { - m_ok.set_sensitive(false); - } -} - -void JoinGuildDialog::CheckCode() { - auto cb = [this](const std::optional &invite) { - if (invite.has_value()) { - m_ok.set_sensitive(true); - if (invite->Guild.has_value()) { - if (invite->MemberCount.has_value()) - m_info.set_text(invite->Guild->Name + " (" + std::to_string(*invite->MemberCount) + " members)"); - else - m_info.set_text(invite->Guild->Name); - } else { - m_info.set_text("Group DM (" + std::to_string(*invite->MemberCount) + " members)"); - } - } else { - m_ok.set_sensitive(false); - m_info.set_text("Invalid invite"); - } - }; - Abaddon::Get().GetDiscordClient().FetchInvite(m_code, sigc::track_obj(cb, *this)); -} - -bool JoinGuildDialog::IsCode(std::string str) { - return str.length() >= 2 && std::all_of(str.begin(), str.end(), [](char c) -> bool { return std::isalnum(c) || c == '-'; }); -} - -std::string JoinGuildDialog::GetCode() { - return m_code; -} - -static const constexpr int RateLimitMS = 1500; -bool JoinGuildDialog::on_idle_slot() { - const auto now = std::chrono::steady_clock::now(); - if (m_needs_request && ((now - m_last_req_time) > std::chrono::milliseconds(RateLimitMS))) { - m_needs_request = false; - m_last_req_time = now; - CheckCode(); - } - - return true; -} diff --git a/src/dialogs/joinguild.hpp b/src/dialogs/joinguild.hpp deleted file mode 100644 index ba061f3..0000000 --- a/src/dialogs/joinguild.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include -#include -#include - -class JoinGuildDialog : public Gtk::Dialog { -public: - JoinGuildDialog(Gtk::Window &parent); - std::string GetCode(); - -protected: - void on_entry_changed(); - static bool IsCode(std::string str); - - Gtk::Box m_layout; - Gtk::Button m_ok; - Gtk::Button m_cancel; - Gtk::Box m_lower; - Gtk::Label m_info; - Gtk::Entry m_entry; - - void CheckCode(); - - // needs a rate limit cuz if u hit it u get ip banned from /invites for a long time :( - bool m_needs_request = false; - std::chrono::time_point m_last_req_time; - bool on_idle_slot(); - -private: - std::string m_code; -}; diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index e1b7a48..2808e17 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -573,10 +573,6 @@ void DiscordClient::SendThreadLazyLoad(Snowflake id) { m_websocket.Send(msg); } -void DiscordClient::JoinGuild(const std::string &code) { - m_http.MakePOST("/invites/" + code, "{}", [](auto) {}); -} - void DiscordClient::LeaveGuild(Snowflake id) { m_http.MakeDELETE("/users/@me/guilds/" + std::to_string(id), [](auto) {}); } diff --git a/src/discord/discord.hpp b/src/discord/discord.hpp index 70c2d82..c2bea7d 100644 --- a/src/discord/discord.hpp +++ b/src/discord/discord.hpp @@ -113,7 +113,6 @@ public: void EditMessage(Snowflake channel_id, Snowflake id, std::string content); void SendLazyLoad(Snowflake id); void SendThreadLazyLoad(Snowflake id); - void JoinGuild(const std::string &code); void LeaveGuild(Snowflake id); void KickUser(Snowflake user_id, Snowflake guild_id); void BanUser(Snowflake user_id, Snowflake guild_id); // todo: reason, delete messages diff --git a/src/windows/mainwindow.cpp b/src/windows/mainwindow.cpp index 7f4395c..07a7f17 100644 --- a/src/windows/mainwindow.cpp +++ b/src/windows/mainwindow.cpp @@ -195,7 +195,6 @@ void MainWindow::OnDiscordSubmenuPopup() { std::string token = Abaddon::Get().GetDiscordToken(); m_menu_discord_connect.set_sensitive(!token.empty() && !discord_active); m_menu_discord_disconnect.set_sensitive(discord_active); - m_menu_discord_join_guild.set_sensitive(discord_active); m_menu_discord_set_token.set_sensitive(!discord_active); m_menu_discord_set_status.set_sensitive(discord_active); } @@ -238,15 +237,12 @@ void MainWindow::SetupMenu() { m_menu_discord_disconnect.set_label("Disconnect"); m_menu_discord_disconnect.set_sensitive(false); m_menu_discord_set_token.set_label("Set Token"); - m_menu_discord_join_guild.set_label("Accept Invite"); - m_menu_discord_join_guild.set_sensitive(false); m_menu_discord_set_status.set_label("Set Status"); m_menu_discord_set_status.set_sensitive(false); m_menu_discord_add_recipient.set_label("Add user to DM"); m_menu_discord_sub.append(m_menu_discord_connect); m_menu_discord_sub.append(m_menu_discord_disconnect); m_menu_discord_sub.append(m_menu_discord_set_token); - m_menu_discord_sub.append(m_menu_discord_join_guild); m_menu_discord_sub.append(m_menu_discord_set_status); m_menu_discord_sub.append(m_menu_discord_add_recipient); m_menu_discord.set_submenu(m_menu_discord_sub); @@ -297,10 +293,6 @@ void MainWindow::SetupMenu() { m_signal_action_set_token.emit(); }); - m_menu_discord_join_guild.signal_activate().connect([this] { - m_signal_action_join_guild.emit(); - }); - m_menu_file_reload_css.signal_activate().connect([this] { m_signal_action_reload_css.emit(); }); @@ -383,10 +375,6 @@ MainWindow::type_signal_action_reload_css MainWindow::signal_action_reload_css() return m_signal_action_reload_css; } -MainWindow::type_signal_action_join_guild MainWindow::signal_action_join_guild() { - return m_signal_action_join_guild; -} - MainWindow::type_signal_action_set_status MainWindow::signal_action_set_status() { return m_signal_action_set_status; } diff --git a/src/windows/mainwindow.hpp b/src/windows/mainwindow.hpp index 534df1b..b013e32 100644 --- a/src/windows/mainwindow.hpp +++ b/src/windows/mainwindow.hpp @@ -63,7 +63,6 @@ private: Gtk::MenuItem m_menu_discord_connect; Gtk::MenuItem m_menu_discord_disconnect; Gtk::MenuItem m_menu_discord_set_token; - Gtk::MenuItem m_menu_discord_join_guild; Gtk::MenuItem m_menu_discord_set_status; Gtk::MenuItem m_menu_discord_add_recipient; // move me somewhere else some day void OnDiscordSubmenuPopup(); @@ -91,7 +90,6 @@ public: typedef sigc::signal type_signal_action_disconnect; typedef sigc::signal type_signal_action_set_token; typedef sigc::signal type_signal_action_reload_css; - typedef sigc::signal type_signal_action_join_guild; typedef sigc::signal type_signal_action_set_status; // this should probably be removed typedef sigc::signal type_signal_action_add_recipient; // channel id @@ -102,7 +100,6 @@ public: type_signal_action_disconnect signal_action_disconnect(); type_signal_action_set_token signal_action_set_token(); type_signal_action_reload_css signal_action_reload_css(); - type_signal_action_join_guild signal_action_join_guild(); type_signal_action_set_status signal_action_set_status(); type_signal_action_add_recipient signal_action_add_recipient(); type_signal_action_view_pins signal_action_view_pins(); @@ -113,7 +110,6 @@ private: type_signal_action_disconnect m_signal_action_disconnect; type_signal_action_set_token m_signal_action_set_token; type_signal_action_reload_css m_signal_action_reload_css; - type_signal_action_join_guild m_signal_action_join_guild; type_signal_action_set_status m_signal_action_set_status; type_signal_action_add_recipient m_signal_action_add_recipient; type_signal_action_view_pins m_signal_action_view_pins; From 1767575728b21d7825423f0a1e3854932ed80864 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:31:15 -0400 Subject: [PATCH 4/9] make CURLOPT_ACCEPT_ENCODING automatic --- src/discord/httpclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discord/httpclient.cpp b/src/discord/httpclient.cpp index cc0bb93..37436ee 100644 --- a/src/discord/httpclient.cpp +++ b/src/discord/httpclient.cpp @@ -143,7 +143,7 @@ void HTTPClient::AddHeaders(http::request &r) { r.set_header(name, val); } curl_easy_setopt(r.get_curl(), CURLOPT_COOKIE, m_cookie.c_str()); - curl_easy_setopt(r.get_curl(), CURLOPT_ACCEPT_ENCODING, "gzip, deflate, br"); + curl_easy_setopt(r.get_curl(), CURLOPT_ACCEPT_ENCODING, ""); } void HTTPClient::OnResponse(const http::response_type &r, const std::function &cb) { From cd900cdfee2014650d5b36981d0610fbe1dc06dd Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 13 Oct 2022 17:03:20 -0400 Subject: [PATCH 5/9] update msys dependencies --- ci/msys-deps.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/msys-deps.txt b/ci/msys-deps.txt index 864a5e5..c2e626e 100644 --- a/ci/msys-deps.txt +++ b/ci/msys-deps.txt @@ -14,6 +14,7 @@ /bin/libdeflate.dll /bin/libepoxy-0.dll /bin/libexpat-1.dll +/bin/libffi-8.dll /bin/libfontconfig-1.dll /bin/libfreetype-6.dll /bin/libfribidi-0.dll @@ -41,7 +42,7 @@ /bin/libpangoft2-1.0-0.dll /bin/libpangomm-1.4-1.dll /bin/libpangowin32-1.0-0.dll -/bin/libpcre-1.dll +/bin/libpcre2-8-0.dll /bin/libpixman-1-0.dll /bin/libpng16-16.dll /bin/libpsl-5.dll From ccb82c1676326107133e63b7822dfd0b87afd0f2 Mon Sep 17 00:00:00 2001 From: Addison Snelling Date: Tue, 18 Oct 2022 00:48:45 -0500 Subject: [PATCH 6/9] readme: list exact depedency package names for Ubuntu (#109) Co-authored-by: Addison Snelling --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5784a11..a059990 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,11 @@ the result of fundamental issues with Discord's thread implementation. #### Linux: -1. Install dependencies: `libgtkmm-3.0-dev`, `libcurl4-gnutls-dev`, - and [nlohmann-json](https://github.com/nlohmann/json) +1. Install dependencies + * On Ubuntu 20.04 (Focal) and newer: + ```Shell + $ sudo apt install g++ cmake libgtkmm-3.0-dev libcurl4-gnutls-dev libsqlite3-dev libssl-dev nlohmann-json3-dev + ``` 2. `git clone https://github.com/uowuo/abaddon --recurse-submodules="subprojects" && cd abaddon` 3. `mkdir build && cd build` 4. `cmake ..` From 772598996c24d570cb74686c4d888d6f1aa070ad Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 23 Oct 2022 02:56:07 +0000 Subject: [PATCH 7/9] Add option to hide the menu bar behind alt key (#115) --- README.md | 16 +++++++++++++--- src/abaddon.cpp | 20 +++++++++++++++----- src/settings.cpp | 2 ++ src/settings.hpp | 2 +- src/windows/mainwindow.cpp | 24 +++++++++++++++++++++++- src/windows/mainwindow.hpp | 1 + 6 files changed, 55 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a059990..555b129 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,15 @@ Current features: * Thread support3 * Animated avatars, server icons, emojis (can be turned off) -1 - Abaddon tries its best (though is not perfect) to make Discord think it's a legitimate web client. Some of the things done to do this +1 - Abaddon tries its best (though is not perfect) to make Discord think it's a legitimate web client. Some of the +things done to do this include: using a browser user agent, sending the same IDENTIFY message that the official web client does, using API v9 endpoints in all cases, and not using endpoints the web client does not normally use. There are still a few smaller inconsistencies, however. For example the web client sends lots of telemetry via the `/science` endpoint (uBlock origin stops this) as well as in the headers of all requests.
-**See [here](#the-spam-filter)** for things you might want to avoid if you are worried about being caught in the spam filter. +**See [here](#the-spam-filter)** for things you might want to avoid if you are worried about being caught in the spam +filter. 2 - Unicode emojis are substituted manually as opposed to rendered by GTK on non-Windows platforms. This can be changed with the `stock_emojis` setting as shown at the bottom of this README. A CBDT-based font using Twemoji is provided to @@ -99,7 +101,12 @@ no `abaddon.ini` in the working directory #### The Spam Filter -Discord likes disabling accounts/forcing them to reset their passwords if they think the user is a spam bot or potentially had their account compromised. While the official client still often gets users caught in the spam filter, third party clients tend to upset the spam filter more often. If you get caught by it, you can usually [appeal](https://support.discord.com/hc/en-us/requests/new?ticket_form_id=360000029731) it and get it restored. Here are some things you might want to do with the official client instead if you are particularly afraid of evoking the spam filter's wrath: +Discord likes disabling accounts/forcing them to reset their passwords if they think the user is a spam bot or +potentially had their account compromised. While the official client still often gets users caught in the spam filter, +third party clients tend to upset the spam filter more often. If you get caught by it, you can +usually [appeal](https://support.discord.com/hc/en-us/requests/new?ticket_form_id=360000029731) it and get it restored. +Here are some things you might want to do with the official client instead if you are particularly afraid of evoking the +spam filter's wrath: * Joining or leaving servers (usually main cause of getting caught) * Frequently disconnecting and reconnecting @@ -252,6 +259,9 @@ For example, memory_db would be set by adding `memory_db = true` under the line over * owner_crown (true or false, default true) - show a crown next to the owner * unreads (true or false, default true) - show unread indicators and mention badges +* save_state (true or false, default true) - save the state of the gui (active channels, tabs, expanded channels) +* alt_menu (true or false, default false) - keep the menu hidden unless revealed with alt key +* hide_to_tray (true or false, default false) - hide abaddon to the system tray on window close #### style diff --git a/src/abaddon.cpp b/src/abaddon.cpp index ec567e7..630e584 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -68,14 +68,13 @@ Abaddon &Abaddon::Get() { return instance; } -#ifdef WITH_LIBHANDY - #ifdef _WIN32 +#ifdef _WIN32 constexpr static guint BUTTON_BACK = 4; constexpr static guint BUTTON_FORWARD = 5; - #else +#else constexpr static guint BUTTON_BACK = 8; constexpr static guint BUTTON_FORWARD = 9; - #endif +#endif static bool HandleButtonEvents(GdkEvent *event, MainWindow *main_window) { if (event->type != GDK_BUTTON_PRESS) return false; @@ -85,6 +84,7 @@ static bool HandleButtonEvents(GdkEvent *event, MainWindow *main_window) { auto *window = gtk_widget_get_toplevel(widget); if (static_cast(window) != static_cast(main_window->gobj())) return false; // is this the right way??? +#ifdef WITH_LIBHANDY switch (event->button.button) { case BUTTON_BACK: main_window->GoBack(); @@ -93,6 +93,7 @@ static bool HandleButtonEvents(GdkEvent *event, MainWindow *main_window) { main_window->GoForward(); break; } +#endif return false; } @@ -108,6 +109,15 @@ static bool HandleKeyEvents(GdkEvent *event, MainWindow *main_window) { const bool ctrl = (event->key.state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK; const bool shft = (event->key.state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK; + constexpr static guint EXCLUDE_STATES = GDK_CONTROL_MASK | GDK_SHIFT_MASK; + + if (!(event->key.state & EXCLUDE_STATES) && event->key.keyval == GDK_KEY_Alt_L) { + if (Abaddon::Get().GetSettings().AltMenu) { + main_window->ToggleMenuVisibility(); + } + } + +#ifdef WITH_LIBHANDY if (ctrl) { switch (event->key.keyval) { case GDK_KEY_Tab: @@ -134,6 +144,7 @@ static bool HandleKeyEvents(GdkEvent *event, MainWindow *main_window) { return true; } } +#endif return false; } @@ -143,7 +154,6 @@ static void MainEventHandler(GdkEvent *event, void *main_window) { if (HandleKeyEvents(event, static_cast(main_window))) return; gtk_main_do_event(event); } -#endif int Abaddon::StartGTK() { m_gtk_app = Gtk::Application::create("com.github.uowuo.abaddon"); diff --git a/src/settings.cpp b/src/settings.cpp index dd1fe83..34b3dc0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -48,6 +48,7 @@ void SettingsManager::ReadSettings() { SMBOOL("gui", "save_state", SaveState); SMBOOL("gui", "stock_emojis", ShowStockEmojis); SMBOOL("gui", "unreads", Unreads); + SMBOOL("gui", "alt_menu", AltMenu); SMBOOL("gui", "hide_to_tray", HideToTray); SMINT("http", "concurrent", CacheHTTPConcurrency); SMSTR("http", "user_agent", UserAgent); @@ -102,6 +103,7 @@ void SettingsManager::Close() { SMBOOL("gui", "save_state", SaveState); SMBOOL("gui", "stock_emojis", ShowStockEmojis); SMBOOL("gui", "unreads", Unreads); + SMBOOL("gui", "alt_menu", AltMenu); SMBOOL("gui", "hide_to_tray", HideToTray); SMINT("http", "concurrent", CacheHTTPConcurrency); SMSTR("http", "user_agent", UserAgent); diff --git a/src/settings.hpp b/src/settings.hpp index 7f5e015..4ab512e 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -27,7 +27,7 @@ public: bool ShowStockEmojis { true }; #endif bool Unreads { true }; - + bool AltMenu { false }; bool HideToTray { false }; // [http] diff --git a/src/windows/mainwindow.cpp b/src/windows/mainwindow.cpp index 07a7f17..20da46b 100644 --- a/src/windows/mainwindow.cpp +++ b/src/windows/mainwindow.cpp @@ -158,6 +158,10 @@ void MainWindow::UpdateMenus() { OnViewSubmenuPopup(); } +void MainWindow::ToggleMenuVisibility() { + m_menu_bar.set_visible(!m_menu_bar.get_visible()); +} + #ifdef WITH_LIBHANDY void MainWindow::GoBack() { m_chat.GoBack(); @@ -279,7 +283,25 @@ void MainWindow::SetupMenu() { m_menu_bar.append(m_menu_file); m_menu_bar.append(m_menu_discord); m_menu_bar.append(m_menu_view); - m_menu_bar.show_all(); + + if (Abaddon::Get().GetSettings().AltMenu) { + auto set_hide_cb = [this](Gtk::Menu &menu) { + for (auto *child : menu.get_children()) { + auto *item = dynamic_cast(child); + if (item != nullptr) { + item->signal_activate().connect([this]() { + m_menu_bar.hide(); + }); + } + } + }; + set_hide_cb(m_menu_discord_sub); + set_hide_cb(m_menu_file_sub); + set_hide_cb(m_menu_view_sub); + m_menu_bar.show_all_children(); + } else { + m_menu_bar.show_all(); + } m_menu_discord_connect.signal_activate().connect([this] { m_signal_action_connect.emit(); diff --git a/src/windows/mainwindow.hpp b/src/windows/mainwindow.hpp index b013e32..6e95b72 100644 --- a/src/windows/mainwindow.hpp +++ b/src/windows/mainwindow.hpp @@ -24,6 +24,7 @@ public: void UpdateChatReactionAdd(Snowflake id, const Glib::ustring ¶m); void UpdateChatReactionRemove(Snowflake id, const Glib::ustring ¶m); void UpdateMenus(); + void ToggleMenuVisibility(); #ifdef WITH_LIBHANDY void GoBack(); From 64245bf7457a81eed063901ad8e5ce55fdc2ca0c Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 23 Oct 2022 18:23:11 -0400 Subject: [PATCH 8/9] add option to autoconnect (closes #114) --- src/abaddon.cpp | 5 +++++ src/settings.cpp | 2 ++ src/settings.hpp | 1 + 3 files changed, 8 insertions(+) diff --git a/src/abaddon.cpp b/src/abaddon.cpp index 630e584..d759426 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -495,6 +495,11 @@ void Abaddon::RunFirstTimeDiscordStartup() { confirm.SetAcceptOnly(true); confirm.run(); } + + // autoconnect + if (cookie.has_value() && build_number.has_value() && GetSettings().Autoconnect && !GetDiscordToken().empty()) { + ActionConnect(); + } }); } diff --git a/src/settings.cpp b/src/settings.cpp index 34b3dc0..0019a00 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -39,6 +39,7 @@ void SettingsManager::ReadSettings() { SMSTR("discord", "token", DiscordToken); SMBOOL("discord", "memory_db", UseMemoryDB); SMBOOL("discord", "prefetch", Prefetch); + SMBOOL("discord", "autoconnect", Autoconnect); SMSTR("gui", "css", MainCSS); SMBOOL("gui", "animated_guild_hover_only", AnimatedGuildHoverOnly); SMBOOL("gui", "animations", ShowAnimations); @@ -94,6 +95,7 @@ void SettingsManager::Close() { SMSTR("discord", "token", DiscordToken); SMBOOL("discord", "memory_db", UseMemoryDB); SMBOOL("discord", "prefetch", Prefetch); + SMBOOL("discord", "autoconnect", Autoconnect); SMSTR("gui", "css", MainCSS); SMBOOL("gui", "animated_guild_hover_only", AnimatedGuildHoverOnly); SMBOOL("gui", "animations", ShowAnimations); diff --git a/src/settings.hpp b/src/settings.hpp index 4ab512e..9d32d2e 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -12,6 +12,7 @@ public: std::string DiscordToken; bool UseMemoryDB { false }; bool Prefetch { false }; + bool Autoconnect { false }; // [gui] std::string MainCSS { "main.css" }; From 2a9f49a1485a145668923a550347af8890e88bf0 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 3 Nov 2022 00:45:31 -0400 Subject: [PATCH 9/9] add menu item + shortcuts to hide channel and member lists (closes #118) --- src/windows/mainwindow.cpp | 16 ++++++++++++++++ src/windows/mainwindow.hpp | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/windows/mainwindow.cpp b/src/windows/mainwindow.cpp index 20da46b..8a85d49 100644 --- a/src/windows/mainwindow.cpp +++ b/src/windows/mainwindow.cpp @@ -265,6 +265,12 @@ void MainWindow::SetupMenu() { m_menu_view_threads.set_label("Threads"); m_menu_view_mark_guild_as_read.set_label("Mark Server as Read"); m_menu_view_mark_guild_as_read.add_accelerator("activate", m_accels, GDK_KEY_Escape, Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE); + m_menu_view_channels.set_label("Channels"); + m_menu_view_channels.add_accelerator("activate", m_accels, GDK_KEY_L, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); + m_menu_view_channels.set_active(true); + m_menu_view_members.set_label("Members"); + m_menu_view_members.add_accelerator("activate", m_accels, GDK_KEY_M, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); + m_menu_view_members.set_active(true); #ifdef WITH_LIBHANDY m_menu_view_go_back.set_label("Go Back"); m_menu_view_go_forward.set_label("Go Forward"); @@ -275,6 +281,8 @@ void MainWindow::SetupMenu() { m_menu_view_sub.append(m_menu_view_pins); m_menu_view_sub.append(m_menu_view_threads); m_menu_view_sub.append(m_menu_view_mark_guild_as_read); + m_menu_view_sub.append(m_menu_view_channels); + m_menu_view_sub.append(m_menu_view_members); #ifdef WITH_LIBHANDY m_menu_view_sub.append(m_menu_view_go_back); m_menu_view_sub.append(m_menu_view_go_forward); @@ -354,6 +362,14 @@ void MainWindow::SetupMenu() { } }); + m_menu_view_channels.signal_activate().connect([this]() { + m_channel_list.set_visible(m_menu_view_channels.get_active()); + }); + + m_menu_view_members.signal_activate().connect([this]() { + m_members.GetRoot()->set_visible(m_menu_view_members.get_active()); + }); + #ifdef WITH_LIBHANDY m_menu_view_go_back.signal_activate().connect([this] { GoBack(); diff --git a/src/windows/mainwindow.hpp b/src/windows/mainwindow.hpp index 6e95b72..78e0115 100644 --- a/src/windows/mainwindow.hpp +++ b/src/windows/mainwindow.hpp @@ -79,6 +79,8 @@ private: Gtk::MenuItem m_menu_view_pins; Gtk::MenuItem m_menu_view_threads; Gtk::MenuItem m_menu_view_mark_guild_as_read; + Gtk::CheckMenuItem m_menu_view_channels; + Gtk::CheckMenuItem m_menu_view_members; #ifdef WITH_LIBHANDY Gtk::MenuItem m_menu_view_go_back; Gtk::MenuItem m_menu_view_go_forward;