aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt17
-rw-r--r--src/actions.cpp19
-rw-r--r--src/engine-eds.cpp65
-rw-r--r--src/exporter.cpp10
-rw-r--r--src/haptic.cpp16
-rw-r--r--src/locations-settings.cpp16
-rw-r--r--src/main.cpp6
-rw-r--r--src/menu.cpp99
-rw-r--r--src/notifications.cpp32
-rw-r--r--src/planner-aggregate.cpp4
-rw-r--r--src/settings-live.cpp13
-rw-r--r--src/snap.cpp21
-rw-r--r--src/wakeup-timer-mainloop.cpp4
-rw-r--r--src/wakeup-timer-powerd.cpp6
14 files changed, 213 insertions, 115 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9cde5fe..69a2dfc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,28 +47,21 @@ set(SERVICE_GENERATED_SOURCES)
add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-alarm-properties
org.ayatana.indicator
${CMAKE_SOURCE_DIR}/data/org.ayatana.indicator.datetime.AlarmProperties.xml)
-if(HAS_LOMIRI_ACCTSERVICE_SOUND)
+
+if (ENABLE_LOMIRI_FEATURES)
add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-accounts-sound
com.lomiri.touch
/usr/share/accountsservice/interfaces/com.lomiri.touch.AccountsService.Sound.xml)
- add_definitions (-DHAS_LOMIRI_ACCTSERVICE_SOUND)
endif()
-# add warnings/coverage info on handwritten files
-# but not the autogenerated ones...
-set_source_files_properties(${SERVICE_CXX_SOURCES}
- PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
-set_source_files_properties(${SERVICE_C_SOURCES}
- PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
-
# add the bin dir to our include path so our code can find the generated header files
include_directories (${CMAKE_CURRENT_BINARY_DIR})
+set_source_files_properties (engine-eds.cpp PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -Wno-enum-constexpr-conversion")
add_library (${SERVICE_LIB} STATIC ${SERVICE_C_SOURCES} ${SERVICE_CXX_SOURCES} ${SERVICE_GENERATED_SOURCES})
include_directories (${CMAKE_SOURCE_DIR})
link_directories (${SERVICE_DEPS_LIBRARY_DIRS})
add_executable (${SERVICE_EXEC} main.cpp)
-set_source_files_properties(${SERVICE_SOURCES} main.cpp PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
-target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${URLDISPATCHER_LIBRARIES})
-install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR})
+target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES})
+install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}")
diff --git a/src/actions.cpp b/src/actions.cpp
index 315340a..18b99e8 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Canonical Ltd.
+ * Copyright 2021 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,11 +16,12 @@
*
* Authors:
* Charles Kerr <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include <datetime/actions.h>
#include <datetime/utils.h> // split_settings_location()
-
+#include <algorithm>
#include <glib.h>
#include <gio/gio.h>
@@ -50,16 +52,18 @@ DateTime datetime_from_timet_variant(GVariant* v)
bool lookup_appointment_by_uid(const std::shared_ptr<State>& state, const gchar* uid, Appointment& setme)
{
- for(const auto& appt : state->calendar_upcoming->appointments().get())
+ bool bRet = false;
+
+ std::for_each(state->calendar_upcoming->appointments().get().begin(), state->calendar_upcoming->appointments().get().end(), [uid, &setme, &bRet](const Appointment& appt)
{
if (appt.uid == uid)
{
setme = appt;
- return true;
+ bRet = true;
}
- }
+ });
- return false;
+ return bRet;
}
void on_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer gself)
@@ -138,7 +142,10 @@ GVariant* create_calendar_state(const std::shared_ptr<State>& state)
{
gboolean days[32] = { 0 };
for (const auto& appt : state->calendar_month->appointments().get())
- days[appt.begin.day_of_month()] = true;
+ if (!appt.is_alarm() || state->settings->show_alarms.get())
+ {
+ days[appt.begin.day_of_month()] = true;
+ }
GVariantBuilder day_builder;
g_variant_builder_init(&day_builder, G_VARIANT_TYPE("ai"));
diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp
index 4396d45..7a61fc0 100644
--- a/src/engine-eds.cpp
+++ b/src/engine-eds.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
- * Copyright 2021 Robert Tari
+ * Copyright 2021-2024 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
@@ -19,6 +19,10 @@
* Robert Tari <robert@tari.in>
*/
+#ifndef ALARM_DEFAULT_SOUND
+#define ALARM_DEFAULT_SOUND "dummy"
+#endif
+
#include <datetime/engine-eds.h>
#include <datetime/myself.h>
#include <libical/ical.h>
@@ -48,7 +52,7 @@ class EdsEngine::Impl
{
public:
- Impl(const std::shared_ptr<Myself> &myself)
+ explicit Impl(const std::shared_ptr<Myself> &myself)
: m_myself(myself)
{
auto cancellable_deleter = [](GCancellable * c) {
@@ -473,14 +477,14 @@ private:
// for each component..
for (auto l=components; l!=nullptr; l=l->next)
{
- bool changed = false;
+ bool bChanged = false;
// for each alarm...
auto component = E_CAL_COMPONENT(l->data);
auto auids = e_cal_component_get_alarm_uids(component);
- for(auto l=auids; l!=nullptr; l=l->next)
+ for(auto lAlarms=auids; lAlarms!=nullptr; lAlarms=lAlarms->next)
{
- auto auid = static_cast<const char*>(l->data);
+ auto auid = static_cast<const char*>(lAlarms->data);
auto alarm = e_cal_component_get_alarm(component, auid);
if (alarm == nullptr)
continue;
@@ -490,13 +494,13 @@ private:
{
e_cal_component_remove_alarm (component, auid);
e_cal_component_add_alarm (component, new_alarm);
- changed = true;
+ bChanged = true;
g_clear_pointer (&new_alarm, e_cal_component_alarm_free);
}
}
g_slist_free_full (auids, g_free);
- if (changed)
+ if (bChanged)
{
auto icc = e_cal_component_get_icalcomponent(component); // icc owned by ecc
modify_slist = g_slist_prepend(modify_slist, icc);
@@ -631,19 +635,18 @@ private:
auto action = e_cal_component_alarm_get_action(alarm);
if (action == E_CAL_COMPONENT_ALARM_AUDIO)
{
- ICalAttach *attach = nullptr;
auto attachments = e_cal_component_alarm_get_attachments(alarm);
- if (attachments != nullptr && attachments->next != nullptr)
- attach = I_CAL_ATTACH (attachments->data);
+ for (; attachments != nullptr; attachments = attachments->next) {
+ ICalAttach *attach = I_CAL_ATTACH (attachments->data);
- if (attach != nullptr)
- {
- if (i_cal_attach_get_is_url (attach))
+ if (attach != nullptr && i_cal_attach_get_is_url (attach))
{
const char* url = i_cal_attach_get_url(attach);
- if (url != nullptr)
+ if (url != nullptr) {
ret = url;
+ break;
+ }
}
}
if (ret.empty())
@@ -1071,6 +1074,34 @@ private:
}
g_slist_free_full(categ_list, g_free);
+ // Get the colour - we might need this override in the future
+
+ /*if (icc)
+ {
+ ECalComponentPropertyBag *pBag = e_cal_component_property_bag_new_from_component (icc, NULL, NULL);
+
+ if (pBag)
+ {
+ guint nProperties = e_cal_component_property_bag_get_count (pBag);
+
+ for (guint nProperty = 0; nProperty < nProperties; nProperty++)
+ {
+ ICalProperty *pProperty = e_cal_component_property_bag_get (pBag, nProperty);
+ gchar *sName = i_cal_property_get_property_name (pProperty);
+ gboolean bColour = !g_strcmp0 (sName, "COLOR");
+
+ if (bColour)
+ {
+ baseline.color = i_cal_property_get_value_as_string (pProperty);
+
+ break;
+ }
+ }
+
+ e_cal_component_property_bag_free (pBag);
+ }
+ }*/
+
g_debug("%s got appointment from %s to %s: %s", G_STRLOC,
baseline.begin.format("%F %T %z").c_str(),
baseline.end.format("%F %T %z").c_str(),
@@ -1127,9 +1158,9 @@ private:
alarm.text = get_alarm_text(a);
if (alarm.audio_url.empty())
- alarm.audio_url = get_alarm_sound_url(a, (baseline.is_alarm() ?
- "file://" ALARM_DEFAULT_SOUND :
- "file://" CALENDAR_DEFAULT_SOUND));
+ {
+ alarm.audio_url = get_alarm_sound_url(a, (baseline.is_alarm() ? "file://" ALARM_DEFAULT_SOUND : "file://" CALENDAR_DEFAULT_SOUND));
+ }
if (!alarm.time.is_set())
alarm.time = trigger_time;
diff --git a/src/exporter.cpp b/src/exporter.cpp
index ea514c0..41a1583 100644
--- a/src/exporter.cpp
+++ b/src/exporter.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Canonical Ltd.
+ * Copyright 2021 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 <datetime/dbus-shared.h>
@@ -37,7 +39,7 @@ class Exporter::Impl
{
public:
- Impl(const std::shared_ptr<Settings>& settings):
+ explicit Impl(const std::shared_ptr<Settings>& settings):
m_settings(settings),
m_alarm_props(datetime_alarm_properties_skeleton_new())
{
@@ -190,10 +192,10 @@ private:
for(auto& menu : m_menus)
{
const auto path = std::string(BUS_DATETIME_PATH) + "/" + menu->name();
- const auto id = g_dbus_connection_export_menu_model(m_bus, path.c_str(), menu->menu_model(), &error);
- if (id)
+ const auto nId = g_dbus_connection_export_menu_model(m_bus, path.c_str(), menu->menu_model(), &error);
+ if (nId)
{
- m_exported_menu_ids.insert(id);
+ m_exported_menu_ids.insert(nId);
}
else
{
diff --git a/src/haptic.cpp b/src/haptic.cpp
index 7e09c24..2b0af4c 100644
--- a/src/haptic.cpp
+++ b/src/haptic.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
- * Copyright 2021 Robert Tari
+ * Copyright 2021-2022 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
@@ -39,11 +39,11 @@ class Haptic::Impl
{
public:
- Impl(bool repeat):
+ explicit Impl(bool repeat):
m_cancellable(g_cancellable_new()),
m_repeat(repeat)
{
- g_bus_get (G_BUS_TYPE_SESSION, m_cancellable, on_bus_ready, this);
+ g_bus_get (G_BUS_TYPE_SYSTEM, m_cancellable, on_bus_ready, this);
}
~Impl()
@@ -105,20 +105,14 @@ private:
void call_vibrate()
{
- GVariantBuilder builder;
- auto duration = g_variant_new_int32 (1000);
-
- g_variant_builder_init (&builder, G_VARIANT_TYPE_INT32);
- g_variant_builder_add_value (&builder, duration);
-
- auto vibrate_arg = g_variant_builder_end (&builder);
+ auto duration = g_variant_new ("(i)", 1000);
g_dbus_connection_call (m_bus,
BUS_HAPTIC_NAME,
BUS_HAPTIC_PATH,
BUS_HAPTIC_INTERFACE,
"vibrate",
- vibrate_arg,
+ duration,
nullptr,
G_DBUS_CALL_FLAGS_NONE,
-1,
diff --git a/src/locations-settings.cpp b/src/locations-settings.cpp
index f1e2b42..2673e66 100644
--- a/src/locations-settings.cpp
+++ b/src/locations-settings.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Canonical Ltd.
+ * Copyright 2021 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 <datetime/locations-settings.h>
@@ -59,10 +61,10 @@ SettingsLocations::reload()
}
// add the other detected timezones
- for(const auto& zone : m_timezones->timezones.get())
+ for(const auto& sZone : m_timezones->timezones.get())
{
- gchar * name = get_beautified_timezone_name(zone.c_str(), timezone_name.c_str());
- Location l(zone, name);
+ gchar * name = get_beautified_timezone_name(sZone.c_str(), timezone_name.c_str());
+ Location l(sZone, name);
if (std::find(v.begin(), v.end(), l) == v.end())
v.push_back(l);
g_free(name);
@@ -73,14 +75,14 @@ SettingsLocations::reload()
{
for(const auto& locstr : m_settings->locations.get())
{
- gchar* zone;
+ gchar* sZone;
gchar* name;
- split_settings_location(locstr.c_str(), &zone, &name);
- Location loc(zone, name);
+ split_settings_location(locstr.c_str(), &sZone, &name);
+ Location loc(sZone, name);
if (std::find(v.begin(), v.end(), loc) == v.end())
v.push_back(loc);
g_free(name);
- g_free(zone);
+ g_free(sZone);
}
}
diff --git a/src/main.cpp b/src/main.cpp
index 613f700..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 HAS_LOMIRI_ACCTSERVICE_SOUND
#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 HAS_LOMIRI_ACCTSERVICE_SOUND
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 HAS_LOMIRI_ACCTSERVICE_SOUND
// 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/menu.cpp b/src/menu.cpp
index ab0bd71..b8ef1b6 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -72,13 +72,14 @@ GMenuModel* Menu::menu_model()
std::vector<Appointment>
Menu::get_display_appointments(const std::vector<Appointment>& appointments_in,
const DateTime& now,
- unsigned int max_items)
+ unsigned int max_items,
+ const bool include_alarms)
{
std::vector<Appointment> appointments;
std::copy_if(appointments_in.begin(),
appointments_in.end(),
std::back_inserter(appointments),
- [now](const Appointment& a){return a.end >= now;});
+ [now, include_alarms](const Appointment& a){return a.end >= now && (!a.is_alarm() || include_alarms);});
if (appointments.size() > max_items)
{
@@ -107,10 +108,6 @@ Menu::get_display_appointments(const std::vector<Appointment>& appointments_in,
if (a_full_day_today != b_full_day_today)
return a_full_day_today;
- const bool a_after_today = (a.begin > end_of_day) || (a.end > end_of_day);
- const bool b_after_today = (a.begin > end_of_day) || (a.end > end_of_day);
- if (a_after_today != b_after_today)
- return a_after_today;
if (a.begin != b.begin)
return a.begin < b.begin;
if (b.end != b.end)
@@ -190,6 +187,9 @@ protected:
m_state->settings->show_events.changed().connect([this](bool){
update_section(Appointments); // showing events got toggled
});
+ m_state->settings->show_alarms.changed().connect([this](bool){
+ update_section(Appointments); // showing alarms got toggled
+ });
m_state->calendar_upcoming->date().changed().connect([this](const DateTime&){
update_upcoming(); // our m_upcoming is planner->upcoming() filtered by time
});
@@ -244,7 +244,9 @@ protected:
auto upcoming = get_display_appointments(
m_state->calendar_upcoming->appointments().get(),
- begin
+ begin,
+ 5,
+ m_state->settings->show_alarms.get()
);
if (m_upcoming != upcoming)
@@ -272,10 +274,6 @@ protected:
return m_serialized_alarm_icon;
}
- std::vector<Appointment> m_upcoming;
-
-private:
-
GVariant* get_serialized_calendar_icon()
{
if (G_UNLIKELY(m_serialized_calendar_icon == nullptr))
@@ -288,6 +286,10 @@ private:
return m_serialized_calendar_icon;
}
+ std::vector<Appointment> m_upcoming;
+
+private:
+
void create_gmenu()
{
g_assert(m_submenu == nullptr);
@@ -432,29 +434,32 @@ private:
{
auto menu = g_menu_new();
- if ((profile==Desktop) && m_state->settings->show_events.get())
+ if (m_state->settings->show_events.get())
{
- add_appointments (menu, profile);
-
- if (m_actions->desktop_has_calendar_app())
+ if (profile==Desktop)
{
- // add the 'Add Event…' menuitem
- auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);
- const gchar* action_name = "indicator.desktop.open-calendar-app";
- auto v = g_variant_new_int64(0);
- g_menu_item_set_action_and_target_value(menu_item, action_name, v);
- g_menu_append_item(menu, menu_item);
- g_object_unref(menu_item);
+ add_appointments (menu, profile);
+
+ if (m_actions->desktop_has_calendar_app())
+ {
+ // add the 'Add Event…' menuitem
+ auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);
+ const gchar* action_name = "indicator.desktop.open-calendar-app";
+ auto v = g_variant_new_int64(0);
+ g_menu_item_set_action_and_target_value(menu_item, action_name, v);
+ g_menu_append_item(menu, menu_item);
+ g_object_unref(menu_item);
+ }
}
- }
- else if (profile==Phone)
- {
- auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app");
- g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
- g_menu_append_item (menu, menu_item);
- g_object_unref (menu_item);
+ else if (profile==Phone)
+ {
+ auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app");
+ g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
+ g_menu_append_item (menu, menu_item);
+ g_object_unref (menu_item);
- add_appointments (menu, profile);
+ add_appointments (menu, profile);
+ }
}
return G_MENU_MODEL(menu);
@@ -554,7 +559,7 @@ protected:
update_header();
}
- GVariant* create_header_state()
+ GVariant* create_header_state() override
{
const auto title = _("Date and Time");
auto label = g_variant_new_string(m_formatter->header.get().c_str());
@@ -565,6 +570,7 @@ protected:
g_variant_builder_add(&b, "{sv}", "label", label);
g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string(title));
g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(TRUE));
+ g_variant_builder_add(&b, "{sv}", "tooltip", g_variant_new_string (_("Time & date settings, quick calendar access")));
return g_variant_builder_end(&b);
}
};
@@ -597,25 +603,46 @@ protected:
update_header();
}
- GVariant* create_header_state()
+ GVariant* create_header_state() override
{
// are there alarms?
bool has_alarms = false;
+ bool has_non_alarm_events = false;
for(const auto& appointment : m_upcoming)
- if((has_alarms = appointment.is_alarm()))
+ {
+ has_alarms = appointment.is_alarm();
+
+ if (has_alarms)
+ {
break;
+ }
+ else
+ {
+ has_non_alarm_events = true;
+ }
+ }
+
GVariantBuilder b;
g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string (_("Time and Date")));
g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean (TRUE));
- if (has_alarms)
+ if (has_alarms || has_non_alarm_events)
+
{
auto label = m_formatter->header.get();
- auto a11y = g_strdup_printf(_("%s (has alarms)"), label.c_str());
+ auto a11y = g_strdup_printf(_("%s (has events)"), label.c_str());
g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string(label.c_str()));
g_variant_builder_add(&b, "{sv}", "accessible-desc", g_variant_new_take_string(a11y));
- g_variant_builder_add(&b, "{sv}", "icon", get_serialized_alarm_icon());
+
+ if (has_alarms && m_state->settings->show_alarms.get())
+ {
+ g_variant_builder_add(&b, "{sv}", "icon", get_serialized_alarm_icon());
+ }
+ else
+ {
+ g_variant_builder_add(&b, "{sv}", "icon", get_serialized_calendar_icon());
+ }
}
else
{
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
};
/***
diff --git a/src/planner-aggregate.cpp b/src/planner-aggregate.cpp
index 23a1230..3b05ea1 100644
--- a/src/planner-aggregate.cpp
+++ b/src/planner-aggregate.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
+ * Copyright 2021 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 <datetime/planner-aggregate.h>
@@ -30,7 +32,7 @@ namespace datetime {
class AggregatePlanner::Impl
{
public:
- Impl(AggregatePlanner* owner):
+ explicit Impl(AggregatePlanner* owner):
m_owner(owner)
{
}
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index cf18739..9cbc23c 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -47,6 +47,7 @@ LiveSettings::LiveSettings():
update_show_day();
update_show_detected_locations();
update_show_events();
+ update_show_alarms();
update_show_locations();
update_show_seconds();
update_show_week_numbers();
@@ -117,6 +118,10 @@ LiveSettings::LiveSettings():
g_settings_set_boolean(m_settings, SETTINGS_SHOW_EVENTS_S, value);
});
+ show_alarms.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings, SETTINGS_SHOW_ALARMS_S, value);
+ });
+
show_locations.changed().connect([this](bool value){
g_settings_set_boolean(m_settings, SETTINGS_SHOW_LOCATIONS_S, value);
});
@@ -239,6 +244,12 @@ void LiveSettings::update_show_events()
show_events.set(val);
}
+void LiveSettings::update_show_alarms()
+{
+ const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_ALARMS_S);
+ show_alarms.set(val);
+}
+
void LiveSettings::update_show_locations()
{
const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_LOCATIONS_S);
@@ -415,6 +426,8 @@ void LiveSettings::update_key_ccid(const std::string& key)
update_show_week_numbers();
else if (key == SETTINGS_SHOW_EVENTS_S)
update_show_events();
+ else if (key == SETTINGS_SHOW_ALARMS_S)
+ update_show_alarms();
else if (key == SETTINGS_SHOW_LOCATIONS_S)
update_show_locations();
else if (key == SETTINGS_SHOW_DETECTED_S)
diff --git a/src/snap.cpp b/src/snap.cpp
index 45cd299..c18f955 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -19,8 +19,9 @@
* Robert Tari <robert@tari.in>
*/
-#ifdef HAS_LOMIRI_ACCTSERVICE_SOUND
+#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
diff --git a/src/wakeup-timer-mainloop.cpp b/src/wakeup-timer-mainloop.cpp
index 56961f2..738306c 100644
--- a/src/wakeup-timer-mainloop.cpp
+++ b/src/wakeup-timer-mainloop.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
+ * Copyright 2021 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 <datetime/wakeup-timer-mainloop.h>
@@ -36,7 +38,7 @@ class MainloopWakeupTimer::Impl
public:
- Impl(const std::shared_ptr<Clock>& clock):
+ explicit Impl(const std::shared_ptr<Clock>& clock):
m_clock(clock)
{
}
diff --git a/src/wakeup-timer-powerd.cpp b/src/wakeup-timer-powerd.cpp
index e66c94c..77893c8 100644
--- a/src/wakeup-timer-powerd.cpp
+++ b/src/wakeup-timer-powerd.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
+ * Copyright 2021-2022 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 <datetime/clock.h>
@@ -38,8 +40,7 @@ class PowerdWakeupTimer::Impl
{
public:
- Impl(const std::shared_ptr<Clock>& clock):
- m_clock(clock),
+ explicit Impl(const std::shared_ptr<Clock>& clock):
m_cancellable(g_cancellable_new())
{
g_bus_get(G_BUS_TYPE_SYSTEM, m_cancellable, on_bus_ready, this);
@@ -269,7 +270,6 @@ private:
***/
core::Signal<> m_timeout;
- const std::shared_ptr<Clock>& m_clock;
DateTime m_wakeup_time;
std::shared_ptr<GDBusConnection> m_bus;