From e212b364b969b7918fbe9152dc4b7c04da303d12 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 28 Feb 2023 20:23:34 -0500 Subject: rudimentary dm notifications --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index cf44f0a..3d6f73f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,8 @@ file(GLOB_RECURSE ABADDON_SOURCES "src/*.cpp" ) +list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_gio\\.cpp$") + add_executable(abaddon ${ABADDON_SOURCES}) target_include_directories(abaddon PUBLIC ${PROJECT_SOURCE_DIR}/src) target_include_directories(abaddon PUBLIC ${PROJECT_BINARY_DIR}) @@ -64,6 +66,10 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR target_link_libraries(abaddon stdc++fs) endif () +if (NOT WIN32) + target_sources(abaddon PRIVATE src/notifications/notifier_gio.cpp) +endif () + if (IXWebSocket_LIBRARIES) target_link_libraries(abaddon ${IXWebSocket_LIBRARIES}) find_library(MBEDTLS_X509_LIBRARY mbedx509) -- cgit v1.2.3 From ca5f343ac1067eb34b524572c3f4ca609abbce1b Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 28 Feb 2023 23:04:40 -0500 Subject: add null implementation for non-gio notifier --- CMakeLists.txt | 2 ++ src/notifications/notifier_null.cpp | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 src/notifications/notifier_null.cpp (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d6f73f..0eef4d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,8 @@ endif () if (NOT WIN32) target_sources(abaddon PRIVATE src/notifications/notifier_gio.cpp) +else () + target_sources(abaddon PRIVATE src/notifications/notifier_null.cpp) endif () if (IXWebSocket_LIBRARIES) diff --git a/src/notifications/notifier_null.cpp b/src/notifications/notifier_null.cpp new file mode 100644 index 0000000..98a7e16 --- /dev/null +++ b/src/notifications/notifier_null.cpp @@ -0,0 +1,5 @@ +#include "notifier.hpp" + +Notifier::Notifier() {} + +void Notifier::Notify(const Glib::ustring &title, const Glib::ustring &text, const Glib::ustring &default_action) {} -- cgit v1.2.3 From e37901bbbbc88ad62ee9f74e3217f656945f1afb Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 1 Mar 2023 00:34:55 -0500 Subject: goofball moment --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eef4d5..4122d10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ file(GLOB_RECURSE ABADDON_SOURCES ) list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_gio\\.cpp$") +list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_null\\.cpp$") add_executable(abaddon ${ABADDON_SOURCES}) target_include_directories(abaddon PUBLIC ${PROJECT_SOURCE_DIR}/src) -- cgit v1.2.3 From fbbfdc9606b9105a5559147c70a0bb0a8a7b1039 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:45:10 -0500 Subject: notification sounds with miniaudio --- .github/workflows/ci.yml | 2 +- .gitmodules | 3 +++ CMakeLists.txt | 6 ++++++ src/notifications/notifier.hpp | 10 ++++++++++ src/notifications/notifier_gio.cpp | 21 ++++++++++++++++++++- subprojects/miniaudio | 1 + 6 files changed, 41 insertions(+), 2 deletions(-) create mode 160000 subprojects/miniaudio (limited to 'CMakeLists.txt') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 893248e..745a6e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: with: cond: ${{ matrix.mindeps == true }} if_true: | - cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF + cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DUSE_MINIAUDIO=OFF cmake --build build if_false: | cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} diff --git a/.gitmodules b/.gitmodules index d091843..eec24ee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "subprojects/keychain"] path = subprojects/keychain url = https://github.com/hrantzsch/keychain +[submodule "subprojects/miniaudio"] + path = subprojects/miniaudio + url = https://github.com/mackron/miniaudio diff --git a/CMakeLists.txt b/CMakeLists.txt index 4122d10..dc08b6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") option(USE_LIBHANDY "Enable features that require libhandy (default)" ON) option(USE_KEYCHAIN "Store the token in the keychain (default)" ON) +option(USE_MINIAUDIO "Enable features that require miniaudio (default)" ON) find_package(nlohmann_json REQUIRED) find_package(CURL) @@ -123,3 +124,8 @@ if (USE_KEYCHAIN) target_compile_definitions(abaddon PRIVATE WITH_KEYCHAIN) endif () endif () + +if (USE_MINIAUDIO) + target_include_directories(abaddon PUBLIC subprojects/miniaudio) + target_compile_definitions(abaddon PRIVATE WITH_MINIAUDIO) +endif () diff --git a/src/notifications/notifier.hpp b/src/notifications/notifier.hpp index 48e881f..9007dc8 100644 --- a/src/notifications/notifier.hpp +++ b/src/notifications/notifier.hpp @@ -2,9 +2,19 @@ #include #include +#ifdef WITH_MINIAUDIO +#include +#endif + class Notifier { public: Notifier(); + ~Notifier(); void Notify(const Glib::ustring &title, const Glib::ustring &text, const Glib::ustring &default_action); + +private: +#ifdef WITH_MINIAUDIO + ma_engine m_engine; +#endif }; diff --git a/src/notifications/notifier_gio.cpp b/src/notifications/notifier_gio.cpp index 6106114..f28735c 100644 --- a/src/notifications/notifier_gio.cpp +++ b/src/notifications/notifier_gio.cpp @@ -1,11 +1,30 @@ #include "notifier.hpp" #include -Notifier::Notifier() {} +#define MINIAUDIO_IMPLEMENTATION +#include + +Notifier::Notifier() { +#ifdef WITH_MINIAUDIO + if (ma_engine_init(nullptr, &m_engine) != MA_SUCCESS) { + printf("failed to initialize miniaudio engine\n"); + } +#endif +} + +Notifier::~Notifier() { +#ifdef WITH_MINIAUDIO + ma_engine_uninit(&m_engine); +#endif +} void Notifier::Notify(const Glib::ustring &title, const Glib::ustring &text, const Glib::ustring &default_action) { auto n = Gio::Notification::create(title); n->set_body(text); n->set_default_action(default_action); Abaddon::Get().GetApp()->send_notification(n); + +#ifdef WITH_MINIAUDIO + ma_engine_play_sound(&m_engine, Abaddon::Get().GetResPath("/sound/message.mp3").c_str(), nullptr); +#endif } diff --git a/subprojects/miniaudio b/subprojects/miniaudio new file mode 160000 index 0000000..c153a94 --- /dev/null +++ b/subprojects/miniaudio @@ -0,0 +1 @@ +Subproject commit c153a947919808419b0bf3f56b6f2ee606d6c5f4 -- cgit v1.2.3 From 3f4ccefc78e31a306c48149253c592be3e663a26 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:15:03 -0500 Subject: refactor notification sounds cmake option --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 10 ++++++++-- src/notifications/notifier.hpp | 4 ++-- src/notifications/notifier_gio.cpp | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) (limited to 'CMakeLists.txt') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 745a6e6..9b20f04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: with: cond: ${{ matrix.mindeps == true }} if_true: | - cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DUSE_MINIAUDIO=OFF + cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DENABLE_NOTIFICATION_SOUNDS=OFF cmake --build build if_false: | cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} diff --git a/CMakeLists.txt b/CMakeLists.txt index dc08b6c..a3af60f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") option(USE_LIBHANDY "Enable features that require libhandy (default)" ON) option(USE_KEYCHAIN "Store the token in the keychain (default)" ON) -option(USE_MINIAUDIO "Enable features that require miniaudio (default)" ON) +option(ENABLE_NOTIFICATION_SOUNDS "Enable notification sounds (default)" ON) find_package(nlohmann_json REQUIRED) find_package(CURL) @@ -125,7 +125,13 @@ if (USE_KEYCHAIN) endif () endif () +if (${ENABLE_NOTIFICATION_SOUNDS}) + set(USE_MINIAUDIO TRUE) + target_compile_definitions(abaddon PRIVATE ENABLE_NOTIFICATION_SOUNDS) +else () + set(USE_MINIAUDIO FALSE) +endif () + if (USE_MINIAUDIO) target_include_directories(abaddon PUBLIC subprojects/miniaudio) - target_compile_definitions(abaddon PRIVATE WITH_MINIAUDIO) endif () diff --git a/src/notifications/notifier.hpp b/src/notifications/notifier.hpp index 869b918..987b123 100644 --- a/src/notifications/notifier.hpp +++ b/src/notifications/notifier.hpp @@ -2,8 +2,8 @@ #include #include -#ifdef WITH_MINIAUDIO -#include +#ifdef ENABLE_NOTIFICATION_SOUNDS + #include #endif class Notifier { diff --git a/src/notifications/notifier_gio.cpp b/src/notifications/notifier_gio.cpp index f09b002..e5335d0 100644 --- a/src/notifications/notifier_gio.cpp +++ b/src/notifications/notifier_gio.cpp @@ -5,7 +5,7 @@ #include Notifier::Notifier() { -#ifdef WITH_MINIAUDIO +#ifdef ENABLE_NOTIFICATION_SOUNDS if (ma_engine_init(nullptr, &m_engine) != MA_SUCCESS) { printf("failed to initialize miniaudio engine\n"); } @@ -13,7 +13,7 @@ Notifier::Notifier() { } Notifier::~Notifier() { -#ifdef WITH_MINIAUDIO +#ifdef ENABLE_NOTIFICATION_SOUNDS ma_engine_uninit(&m_engine); #endif } @@ -34,7 +34,7 @@ void Notifier::Notify(const Glib::ustring &title, const Glib::ustring &text, con g_object_unref(icon); g_object_unref(file); -#ifdef WITH_MINIAUDIO +#ifdef ENABLE_NOTIFICATION_SOUNDS ma_engine_play_sound(&m_engine, Abaddon::Get().GetResPath("/sound/message.mp3").c_str(), nullptr); #endif } -- cgit v1.2.3