aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-01-31 19:08:17 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-01-31 19:08:17 +0100
commit2a2db70bedf0c4a96282e417be433d2f23f6c465 (patch)
treefebd31ea544a376d1fd04c0e830463d31d028dd9 /src
parentd8debd706fe92de09e5c654c4ea2cc5dd5ce0529 (diff)
parent30b2de458752ad0855b508eb2f8ffeee85628cea (diff)
downloadayatana-indicator-datetime-2a2db70bedf0c4a96282e417be433d2f23f6c465.tar.gz
ayatana-indicator-datetime-2a2db70bedf0c4a96282e417be433d2f23f6c465.tar.bz2
ayatana-indicator-datetime-2a2db70bedf0c4a96282e417be433d2f23f6c465.zip
Merge branch 'personal/peat-psuwit/bring-back-lomiri-hints'
Attributes GH PR #115: https://github.com/AyatanaIndicators/ayatana-indicator-datetime/pull/115
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp6
-rw-r--r--src/notifications.cpp19
-rw-r--r--src/snap.cpp19
3 files changed, 36 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4590e84..29e4472 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -32,9 +32,7 @@
#include <datetime/planner-snooze.h>
#include <datetime/planner-range.h>
#include <datetime/settings-live.h>
-#ifdef LOMIRI_FEATURES_ENABLED
#include <datetime/snap.h>
-#endif
#include <datetime/state.h>
#include <datetime/timezones-live.h>
#include <datetime/timezone-timedated.h>
@@ -95,7 +93,6 @@ namespace
return state;
}
-#ifdef LOMIRI_FEATURES_ENABLED
std::shared_ptr<AlarmQueue> create_simple_alarm_queue(const std::shared_ptr<Clock>& clock,
const std::shared_ptr<Planner>& snooze_planner,
const std::shared_ptr<Engine>& engine,
@@ -119,7 +116,6 @@ namespace
auto wakeup_timer = std::make_shared<PowerdWakeupTimer>(clock);
return std::make_shared<SimpleAlarmQueue>(clock, planner, wakeup_timer);
}
-#endif
}
int
@@ -149,7 +145,6 @@ main(int /*argc*/, char** /*argv*/)
auto actions = std::make_shared<LiveActions>(state);
MenuFactory factory(actions, state);
-#ifdef LOMIRI_FEATURES_ENABLED
// set up the snap decisions
auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock);
auto notification_engine = std::make_shared<ain::Engine>("ayatana-indicator-datetime-service");
@@ -173,7 +168,6 @@ main(int /*argc*/, char** /*argv*/)
engine->disable_alarm(appointment);
};
alarm_queue->alarm_reached().connect(on_alarm_reached);
-#endif
// create the menus
std::vector<std::shared_ptr<Menu>> menus;
diff --git a/src/notifications.cpp b/src/notifications.cpp
index b962e68..4049851 100644
--- a/src/notifications.cpp
+++ b/src/notifications.cpp
@@ -199,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
@@ -249,6 +256,14 @@ public:
const auto& d= info.m_duration;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(d);
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)
@@ -509,6 +524,10 @@ private:
// server capabilities.
// as the name indicates, don't use this directly: use server_caps() instead
mutable std::set<std::string> m_lazy_caps;
+
+#ifdef LOMIRI_FEATURES_ENABLED
+ static constexpr char const * HINT_LOMIRI_TIMEOUT {"x-lomiri-snap-decisions-timeout"};
+#endif
};
/***
diff --git a/src/snap.cpp b/src/snap.cpp
index 46f1d7b..c18f955 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -21,6 +21,7 @@
#ifdef LOMIRI_FEATURES_ENABLED
#include "dbus-accounts-sound.h"
+#endif
#include <datetime/snap.h>
#include <datetime/utils.h> // is_locale_12h()
@@ -64,6 +65,7 @@ public:
m_cancellable(g_cancellable_new()),
m_system_bus{G_DBUS_CONNECTION(g_object_ref(system_bus))}
{
+ #ifdef LOMIRI_FEATURES_ENABLED
auto object_path = g_strdup_printf("/org/freedesktop/Accounts/User%lu", (gulong)getuid());
@@ -75,13 +77,16 @@ public:
on_sound_proxy_ready,
this);
g_free(object_path);
+ #endif
}
~Impl()
{
g_cancellable_cancel(m_cancellable);
g_clear_object(&m_cancellable);
+ #ifdef LOMIRI_FEATURES_ENABLED
g_clear_object(&m_accounts_service_sound_proxy);
+ #endif
g_clear_object(&m_system_bus);
for (const auto& key : m_notifications)
@@ -235,6 +240,7 @@ private:
return m_settings->vibrate_silent_mode.get();
}
+#ifdef LOMIRI_FEATURES_ENABLED
static void on_sound_proxy_ready(GObject* /*source_object*/, GAsyncResult* res, gpointer gself)
{
GError * error;
@@ -253,17 +259,26 @@ private:
static_cast<Impl*>(gself)->m_accounts_service_sound_proxy = proxy;
}
}
+#endif
bool silent_mode() const
{
+#ifdef LOMIRI_FEATURES_ENABLED
return (m_accounts_service_sound_proxy != nullptr)
&& (accounts_service_sound_get_silent_mode(m_accounts_service_sound_proxy));
+#else
+ return false;
+#endif
}
bool should_vibrate() const
{
+#ifdef LOMIRI_FEATURES_ENABLED
return (m_accounts_service_sound_proxy != nullptr)
&& (accounts_service_sound_get_other_vibrate(m_accounts_service_sound_proxy));
+#else
+ return true;
+#endif
}
std::string get_alarm_uri(const Appointment& appointment,
@@ -306,7 +321,9 @@ private:
const std::shared_ptr<const Settings> m_settings;
std::set<int> m_notifications;
GCancellable * m_cancellable {nullptr};
+#ifdef LOMIRI_FEATURES_ENABLED
AccountsServiceSound * m_accounts_service_sound_proxy {nullptr};
+#endif
GDBusConnection * m_system_bus {nullptr};
static constexpr char const * ACTION_NONE {"none"};
@@ -345,5 +362,3 @@ Snap::operator()(const Appointment& appointment,
} // namespace datetime
} // namespace indicator
} // namespace ayatana
-
-#endif