diff options
Diffstat (limited to 'src/notifications.cpp')
-rw-r--r-- | src/notifications.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/notifications.cpp b/src/notifications.cpp index f21b5e8..4049851 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -1,5 +1,6 @@ /* * Copyright 2014 Canonical Ltd. + * Copyright 2021-2023 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <notifications/notifications.h> @@ -24,7 +26,7 @@ #include <messaging-menu/messaging-menu-app.h> #include <messaging-menu/messaging-menu-message.h> -#ifdef HAS_URLDISPATCHER +#ifdef LOMIRI_FEATURES_ENABLED #include <lomiri-url-dispatcher.h> #endif @@ -163,7 +165,7 @@ class Engine::Impl public: - Impl(const std::string& app_name): + explicit Impl(const std::string& app_name): m_app_name(app_name) { if (!notify_init(app_name.c_str())) @@ -197,6 +199,13 @@ public: return server_caps().count("actions") != 0; } +#ifdef LOMIRI_FEATURES_ENABLED + bool requires_hint_lomiri_timeout() const + { + return server_caps().count(HINT_LOMIRI_TIMEOUT) != 0; + } +#endif + void close_all () { // call close() on all our keys @@ -246,10 +255,15 @@ public: { const auto& d= info.m_duration; auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(d); - - notify_notification_set_hint (nn.get(), - HINT_TIMEOUT, - g_variant_new_int32(ms.count())); + notify_notification_set_timeout (nn.get (), ms.count ()); +#ifdef LOMIRI_FEATURES_ENABLED + if (requires_hint_lomiri_timeout()) { + // Lomiri has its own logic regarding timeout. + notify_notification_set_hint (nn.get(), + HINT_LOMIRI_TIMEOUT, + g_variant_new_int32(ms.count())); + } +#endif } for (const auto& hint : info.m_string_hints) @@ -462,7 +476,7 @@ private: static std::string calendar_app_id() { -#ifdef HAS_URLDISPATCHER +#ifdef LOMIRI_FEATURES_ENABLED auto urls = g_strsplit("calendar://", ",", 0); auto appids = lomiri_url_dispatch_url_appid(const_cast<const gchar**>(urls)); g_strfreev(urls); @@ -511,7 +525,9 @@ private: // as the name indicates, don't use this directly: use server_caps() instead mutable std::set<std::string> m_lazy_caps; - static constexpr char const * HINT_TIMEOUT {"x-lomiri-snap-decisions-timeout"}; +#ifdef LOMIRI_FEATURES_ENABLED + static constexpr char const * HINT_LOMIRI_TIMEOUT {"x-lomiri-snap-decisions-timeout"}; +#endif }; /*** |