From 08da84b6bca7b43e430e790ef4d075bf7297a7f1 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:31:01 -0400 Subject: dont deserialize groups in GUILD_MEMBER_LIST_UPDATE --- src/discord/objects.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/discord/objects.cpp b/src/discord/objects.cpp index cb0a685..4ad17c3 100644 --- a/src/discord/objects.cpp +++ b/src/discord/objects.cpp @@ -27,7 +27,7 @@ void from_json(const nlohmann::json &j, MessageDeleteBulkData &m) { void from_json(const nlohmann::json &j, GuildMemberListUpdateMessage::GroupItem &m) { m.Type = "group"; JS_D("id", m.ID); - JS_D("count", m.Count); + JS_ON("count", m.Count); } GuildMember GuildMemberListUpdateMessage::MemberItem::GetAsMemberData() const { @@ -54,16 +54,16 @@ void from_json(const nlohmann::json &j, GuildMemberListUpdateMessage::OpObject & m.Items.emplace(); JS_D("range", m.Range); for (const auto &ij : j.at("items")) { - if (ij.contains("group")) - m.Items->push_back(std::make_unique(ij.at("group"))); - else if (ij.contains("member")) + if (ij.contains("member")) { m.Items->push_back(std::make_unique(ij.at("member"))); + } } } else if (m.Op == "UPDATE") { JS_D("index", m.Index); const auto &ij = j.at("item"); - if (ij.contains("member")) + if (ij.contains("member")) { m.OpItem = std::make_unique(ij.at("member")); + } } } -- cgit v1.2.3 From f40393eb128129130f154b5dec16deb0e16cbbd8 Mon Sep 17 00:00:00 2001 From: TheMorc Date: Wed, 23 Aug 2023 03:28:17 +0200 Subject: move CoreFoundation to a more reasonable place --- CMakeLists.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a55057..b7fe511 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,12 +161,6 @@ if (ENABLE_VOICE) target_link_libraries(abaddon ${CMAKE_DL_LIBS}) - if (APPLE) - target_link_libraries(abaddon "-framework CoreFoundation") - target_link_libraries(abaddon "-framework CoreAudio") - target_link_libraries(abaddon "-framework AudioToolbox") - endif () - endif () if (${ENABLE_NOTIFICATION_SOUNDS}) @@ -180,6 +174,13 @@ if (USE_MINIAUDIO) HINTS subprojects PATH_SUFFIXES miniaudio REQUIRED) + + if (APPLE) + target_link_libraries(abaddon "-framework CoreFoundation") + target_link_libraries(abaddon "-framework CoreAudio") + target_link_libraries(abaddon "-framework AudioToolbox") + endif () + target_include_directories(abaddon PUBLIC ${MINIAUDIO_INCLUDE_DIR}) target_compile_definitions(abaddon PRIVATE WITH_MINIAUDIO) endif () -- cgit v1.2.3 From c56a109a21056c4fb7dbe4c3371a88347b14b7d5 Mon Sep 17 00:00:00 2001 From: TheMorc Date: Wed, 23 Aug 2023 10:49:06 +0200 Subject: fix ImageComponent embeds due to extensions being mixedcase --- src/util.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index 8d21ff4..ae948ea 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -160,7 +160,10 @@ std::string GetExtension(std::string url) { } bool IsURLViewableImage(const std::string &url) { - const auto ext = GetExtension(url); + std::string lw_url = url; + std::transform(lw_url.begin(), lw_url.end(), lw_url.begin(), ::tolower); + + const auto ext = GetExtension(lw_url); static const char *exts[] = { ".jpeg", ".jpg", ".png", nullptr }; -- cgit v1.2.3 From 0e5bccaad10325877c39c3721a8c0c2199fbc43f Mon Sep 17 00:00:00 2001 From: TheMorc Date: Thu, 24 Aug 2023 02:37:55 +0200 Subject: suggest installing adwaita-icon-theme to get icons in the client --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70996b2..8625ce1 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ the result of fundamental issues with Discord's thread implementation. #### Mac: 1. `git clone https://github.com/uowuo/abaddon --recurse-submodules="subprojects" && cd abaddon` -2. `brew install gtkmm3 nlohmann-json libhandy opus libsodium spdlog` +2. `brew install gtkmm3 nlohmann-json libhandy opus libsodium spdlog adwaita-icon-theme` 3. `mkdir build && cd build` 4. `cmake ..` 5. `make` -- cgit v1.2.3 From 9f9617eb37d29a4a7ffe222814bdebe89c291005 Mon Sep 17 00:00:00 2001 From: TheMorc Date: Thu, 24 Aug 2023 03:02:06 +0200 Subject: disable file picker filters macOS's file picker had issues with them being enabled and it works just fine without the filter being added. Probably applies to other file picker interfaces too --- src/components/chatinput.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index 1133302..24fc22b 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -149,11 +149,6 @@ void ChatInputTextContainer::ShowFileChooser() { } }); - auto filter_all = Gtk::FileFilter::create(); - filter_all->set_name("All files (*.*)"); - filter_all->add_pattern("*.*"); - dlg->add_filter(filter_all); - dlg->run(); } -- cgit v1.2.3 From c166831955517d6999e6b4f48bf3085b05b06a76 Mon Sep 17 00:00:00 2001 From: TheMorc Date: Thu, 24 Aug 2023 08:37:48 +0200 Subject: platform.cpp switch logging to spdlog --- src/platform.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/platform.cpp b/src/platform.cpp index 0117e17..70e1c20 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -103,7 +103,7 @@ std::string Platform::FindResourceFolder() { } } - puts("cant find a resources folder, will try to load from cwd"); + spdlog::get("discord")->warn("cant find a resources folder, will try to load from cwd"); found_path = "."; found = true; return found_path; @@ -133,7 +133,7 @@ std::string Platform::FindConfigFile() { } // fallback to cwd if cant find + cant make in ~/.config - puts("can't find configuration file!"); + spdlog::get("discord")->warn("can't find configuration file!"); return "./abaddon.ini"; } @@ -147,13 +147,13 @@ std::string Platform::FindStateCacheFolder() { if (util::IsFolder(home_path)) return home_path; } - puts("can't find cache folder!"); + spdlog::get("discord")->warn("can't find cache folder!"); return "."; } #else std::string Platform::FindResourceFolder() { - puts("unknown OS, trying to load resources from cwd"); + spdlog::get("discord")->warn("unknown OS, trying to load resources from cwd"); return "."; } @@ -161,12 +161,12 @@ std::string Platform::FindConfigFile() { const auto x = std::getenv("ABADDON_CONFIG"); if (x != nullptr) return x; - puts("unknown OS, trying to load config from cwd"); + spdlog::get("discord")->warn("unknown OS, trying to load config from cwd"); return "./abaddon.ini"; } std::string Platform::FindStateCacheFolder() { - puts("unknown OS, setting state cache folder to cwd"); + spdlog::get("discord")->warn("unknown OS, setting state cache folder to cwd"); return "."; } #endif -- cgit v1.2.3 From 52e6167b9a8585edc0d938b32239623300398f01 Mon Sep 17 00:00:00 2001 From: TheMorc Date: Wed, 23 Aug 2023 03:32:22 +0200 Subject: add hackish macOS detection for home folder, resources and cache --- src/platform.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/platform.cpp b/src/platform.cpp index 70e1c20..0a69721 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -151,6 +151,71 @@ std::string Platform::FindStateCacheFolder() { return "."; } +#elif defined(__APPLE__) +#include +#include +#include +#include +std::string Platform::FindResourceFolder() { + static std::string found_path; + static bool found = false; + if (found) return found_path; + + CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + char resourcePath[PATH_MAX]; + if (CFURLGetFileSystemRepresentation(resourceURL, true, (UInt8 *)resourcePath, PATH_MAX)) { + if (resourceURL != NULL) { + CFRelease(resourceURL); + } + found_path = resourcePath; + found = true; + return found_path; + } + + spdlog::get("discord")->warn("cant find a resources folder, will try to load from cwd"); + found_path = "."; + found = true; + return found_path; +} + +std::string Platform::FindConfigFile() { + const auto cfg = std::getenv("ABADDON_CONFIG"); + if (cfg != nullptr) return cfg; + + passwd *home = getpwuid(getuid()); + const char *homeDir = home->pw_dir; + + char appSupportPath[PATH_MAX]; + snprintf(appSupportPath, sizeof(appSupportPath), "%s/Library/Application Support", homeDir); + + char homefolder_path[PATH_MAX]; + snprintf(homefolder_path, sizeof(homefolder_path), "%s/%s", appSupportPath, "com.github.uowuo.abaddon"); + + if (mkdir(homefolder_path, 0755) == 0) { + spdlog::get("discord")->warn("created Application Support dir"); + } + + char home_path[PATH_MAX]; + snprintf(home_path, sizeof(home_path), "%s/%s", homefolder_path, "/abaddon.ini"); + + return home_path; +} + +std::string Platform::FindStateCacheFolder() { + + passwd *home = getpwuid(getuid()); + const char *homeDir = home->pw_dir; + + char appSupportPath[PATH_MAX]; + snprintf(appSupportPath, sizeof(appSupportPath), "%s/Library/Application Support", homeDir); + + char home_path[PATH_MAX]; + snprintf(home_path, sizeof(home_path), "%s/%s", appSupportPath, "com.github.uowuo.abaddon"); + + return home_path; +} + + #else std::string Platform::FindResourceFolder() { spdlog::get("discord")->warn("unknown OS, trying to load resources from cwd"); -- cgit v1.2.3 From 84bb27b272e3fc930af839fca946a43436a9c9c6 Mon Sep 17 00:00:00 2001 From: TheMorc Date: Fri, 25 Aug 2023 11:17:04 +0200 Subject: .gitignore: ignore macOS resource forks --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index be20737..e47837d 100644 --- a/.gitignore +++ b/.gitignore @@ -362,3 +362,6 @@ fonts/fonts.conf *.zip *.tar.* *.rar + +#macOS resource forks +.DS_Store -- cgit v1.2.3 From eea5987f379cd76786ace382da09dd687ecca28a Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:13:37 -0400 Subject: add workaround for compiling with spdlog and incompatible libfmt (fixes #214) --- src/audio/manager.cpp | 3 ++- src/discord/voiceclient.cpp | 16 ++++++++++------ src/discord/websocket.cpp | 3 ++- src/remoteauth/remoteauthclient.cpp | 8 +++++--- src/windows/voicesettingswindow.cpp | 2 -- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/audio/manager.cpp b/src/audio/manager.cpp index 67fbcd9..a2fd4df 100644 --- a/src/audio/manager.cpp +++ b/src/audio/manager.cpp @@ -79,7 +79,8 @@ AudioManager::AudioManager() { return; } - spdlog::get("audio")->info("Audio backend: {}", ma_get_backend_name(m_context.backend)); + const auto backend_name = ma_get_backend_name(m_context.backend); + spdlog::get("audio")->info("Audio backend: {}", backend_name); Enumerate(); diff --git a/src/discord/voiceclient.cpp b/src/discord/voiceclient.cpp index e9814b6..e4b56bd 100644 --- a/src/discord/voiceclient.cpp +++ b/src/discord/voiceclient.cpp @@ -182,7 +182,8 @@ void DiscordVoiceClient::Start() { void DiscordVoiceClient::Stop() { if (!IsConnected() && !IsConnecting()) { - m_log->warn("Requested stop while not connected (from {})", GetStateName(m_state)); + const auto state_name = GetStateName(m_state); + m_log->warn("Requested stop while not connected (from {})", state_name); return; } @@ -264,7 +265,8 @@ void DiscordVoiceClient::OnGatewayMessage(const std::string &str) { HandleGatewaySpeaking(msg); break; default: - m_log->warn("Unhandled opcode: {}", static_cast(msg.Opcode)); + const auto opcode_int = static_cast(msg.Opcode); + m_log->warn("Unhandled opcode: {}", opcode_int); } } @@ -318,7 +320,8 @@ void DiscordVoiceClient::HandleGatewayReady(const VoiceGatewayMessage &m) { void DiscordVoiceClient::HandleGatewaySessionDescription(const VoiceGatewayMessage &m) { VoiceSessionDescriptionData d = m.Data; - m_log->debug("Received session description (mode: {}) (key: {:ns}) ", d.Mode, spdlog::to_hex(d.SecretKey.begin(), d.SecretKey.end())); + const auto key_hex = spdlog::to_hex(d.SecretKey.begin(), d.SecretKey.end()); + m_log->debug("Received session description (mode: {}) (key: {:ns}) ", d.Mode, key_hex); VoiceSpeakingMessage msg; msg.Delay = 0; @@ -379,7 +382,7 @@ void DiscordVoiceClient::Discovery() { m_udp.Send(payload.data(), payload.size()); constexpr int MAX_TRIES = 100; - for (int i = 0; i < MAX_TRIES; i++) { + for (int i = 1; i <= MAX_TRIES; i++) { const auto response = m_udp.Receive(); if (response.size() >= 74 && response[0] == 0x00 && response[1] == 0x02) { const char *ip = reinterpret_cast(response.data() + 8); @@ -388,7 +391,7 @@ void DiscordVoiceClient::Discovery() { SelectProtocol(ip, port); break; } else { - m_log->error("Received non-discovery packet after sending request (try {}/{})", i + 1, MAX_TRIES); + m_log->error("Received non-discovery packet after sending request (try {}/{})", i, MAX_TRIES); } } } @@ -451,7 +454,8 @@ void DiscordVoiceClient::KeepaliveThread() { } void DiscordVoiceClient::SetState(State state) { - m_log->debug("Changing state to {}", GetStateName(state)); + const auto state_name = GetStateName(state); + m_log->debug("Changing state to {}", state_name); m_state = state; m_signal_state_update.emit(state); } diff --git a/src/discord/websocket.cpp b/src/discord/websocket.cpp index cdc4db1..0c79f25 100644 --- a/src/discord/websocket.cpp +++ b/src/discord/websocket.cpp @@ -74,7 +74,8 @@ void Websocket::OnMessage(const ix::WebSocketMessagePtr &msg) { m_open_dispatcher.emit(); } break; case ix::WebSocketMessageType::Close: { - m_log->debug("Received close frame, dispatching. {} ({}){}", msg->closeInfo.code, msg->closeInfo.reason, msg->closeInfo.remote ? " Remote" : ""); + const auto remote = msg->closeInfo.remote ? " Remote" : ""; + m_log->debug("Received close frame, dispatching. {} ({}){}", msg->closeInfo.code, msg->closeInfo.reason, remote); m_close_info = msg->closeInfo; m_close_dispatcher.emit(); } break; diff --git a/src/remoteauth/remoteauthclient.cpp b/src/remoteauth/remoteauthclient.cpp index 7653b78..5103c8d 100644 --- a/src/remoteauth/remoteauthclient.cpp +++ b/src/remoteauth/remoteauthclient.cpp @@ -111,9 +111,10 @@ void RemoteAuthClient::HandleGatewayPendingTicket(const nlohmann::json &j) { const auto encrypted_payload = Glib::Base64::decode(j.at("encrypted_user_payload").get()); const auto payload = Decrypt(reinterpret_cast(encrypted_payload.data()), encrypted_payload.size()); - m_log->trace("User payload: {}", std::string(payload.begin(), payload.end())); + const auto payload_str = std::string(payload.begin(), payload.end()); + m_log->trace("User payload: {}", payload_str); - const std::vector user_info = Glib::Regex::split_simple(":", std::string(payload.begin(), payload.end())); + const std::vector user_info = Glib::Regex::split_simple(":", payload_str); Snowflake user_id; std::string discriminator; std::string avatar_hash; @@ -140,7 +141,8 @@ void RemoteAuthClient::HandleGatewayCancel(const nlohmann::json &j) { void RemoteAuthClient::OnRemoteAuthLoginResponse(const std::optional &encrypted_token, DiscordError err) { if (!encrypted_token.has_value()) { - m_log->error("Remote auth login failed: {}", static_cast(err)); + const auto err_int = static_cast(err); + m_log->error("Remote auth login failed: {}", err_int); if (err == DiscordError::CAPTCHA_REQUIRED) { m_signal_error.emit("Discord is requiring a captcha. You must use a web browser to log in."); } else { diff --git a/src/windows/voicesettingswindow.cpp b/src/windows/voicesettingswindow.cpp index 3749986..97f77b5 100644 --- a/src/windows/voicesettingswindow.cpp +++ b/src/windows/voicesettingswindow.cpp @@ -35,7 +35,6 @@ VoiceSettingsWindow::VoiceSettingsWindow() m_encoding_mode.signal_changed().connect([this]() { const auto mode = m_encoding_mode.get_active_text(); auto &audio = Abaddon::Get().GetAudio(); - spdlog::get("audio")->debug("Chose encoding mode: {}", mode.c_str()); if (mode == "Voice") { audio.SetEncodingApplication(OPUS_APPLICATION_VOIP); } else if (mode == "Music") { @@ -67,7 +66,6 @@ VoiceSettingsWindow::VoiceSettingsWindow() m_signal.signal_changed().connect([this]() { const auto signal = m_signal.get_active_text(); auto &audio = Abaddon::Get().GetAudio(); - spdlog::get("audio")->debug("Chose signal hint: {}", signal.c_str()); if (signal == "Auto") { audio.SetSignalHint(OPUS_AUTO); } else if (signal == "Voice") { -- cgit v1.2.3