diff --git a/data/org.ayatana.indicator.datetime.AlarmProperties.xml b/data/org.ayatana.indicator.datetime.AlarmProperties.xml deleted file mode 100644 index eb306a643..000000000 --- a/data/org.ayatana.indicator.datetime.AlarmProperties.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - The default alarm sound's filename. - - - - - - - - What kind of haptic feedback, if any, to trigger with an alarm. - Two modes are currently supported: 'pulse', 'none'. - - - - - - - - How loudly to play alarm sounds. [Range: 1-100] - - - - - - - - How long an alarm's sound should be looped. - - - - - - - - How many minutes to wait when the Snooze button is pressed. [Range: 1-15] - - - - - - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index faf434171..76e40066c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,9 +44,6 @@ set (SERVICE_CXX_SOURCES # generated sources include (GdbusCodegen) 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 (ENABLE_LOMIRI_FEATURES) add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-accounts-sound diff --git a/src/exporter.cpp b/src/exporter.cpp index 41a158379..05a488bf2 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -1,6 +1,6 @@ /* * Copyright 2013 Canonical Ltd. - * Copyright 2021 Robert Tari + * 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 @@ -22,8 +22,6 @@ #include #include -#include "dbus-alarm-properties.h" - #include #include @@ -40,10 +38,8 @@ class Exporter::Impl public: explicit Impl(const std::shared_ptr& settings): - m_settings(settings), - m_alarm_props(datetime_alarm_properties_skeleton_new()) + m_settings(settings) { - alarm_properties_init(); } ~Impl() @@ -57,9 +53,6 @@ class Exporter::Impl g_dbus_connection_unexport_action_group(m_bus, m_exported_actions_id); } - g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(m_alarm_props)); - g_clear_object(&m_alarm_props); - if (m_own_id) g_bus_unown_name(m_own_id); @@ -140,16 +133,6 @@ class Exporter::Impl }); } - - void alarm_properties_init() - { - bind_uint_property(m_alarm_props, "duration", m_settings->alarm_duration); - bind_uint_property(m_alarm_props, "default-volume", m_settings->alarm_volume); - bind_string_property(m_alarm_props, "default-sound", m_settings->alarm_sound); - bind_string_property(m_alarm_props, "haptic-feedback", m_settings->alarm_haptic); - bind_uint_property(m_alarm_props, "snooze-duration", m_settings->snooze_duration); - } - /*** **** ***/ @@ -168,10 +151,6 @@ class Exporter::Impl // export the alarm properties GError * error = nullptr; - g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(m_alarm_props), - m_bus, - BUS_DATETIME_PATH"/AlarmProperties", - &error); // export the actions const auto id = g_dbus_connection_export_action_group(m_bus, @@ -227,7 +206,6 @@ class Exporter::Impl GDBusConnection* m_bus = nullptr; std::shared_ptr m_actions; std::vector> m_menus; - DatetimeAlarmProperties* m_alarm_props = nullptr; }; diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp index 647d6ff91..774a451cb 100644 --- a/tests/test-exporter.cpp +++ b/tests/test-exporter.cpp @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 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,14 +16,13 @@ * * Authors: * Charles Kerr + * Robert Tari */ #include "actions-mock.h" #include "state-mock.h" #include "glib-fixture.h" -#include "dbus-alarm-properties.h" - #include #include #include @@ -142,112 +142,3 @@ TEST_F(ExporterFixture, Publish) g_clear_object(&exported); g_clear_object(&connection); } - -TEST_F(ExporterFixture, AlarmProperties) -{ - /*** - **** Set up the exporter - ***/ - - std::shared_ptr state(new MockState); - std::shared_ptr actions(new MockActions(state)); - std::shared_ptr settings(new Settings); - std::vector> menus; - - MenuFactory menu_factory (actions, state); - for(int i=0; i(gproxy) = datetime_alarm_properties_proxy_new_for_bus_finish(res, &error); - EXPECT_TRUE(error == nullptr); - }; - - DatetimeAlarmProperties* proxy = nullptr; - datetime_alarm_properties_proxy_new_for_bus(G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - BUS_DATETIME_NAME, - BUS_DATETIME_PATH"/AlarmProperties", - nullptr, - on_proxy_ready, - &proxy); - wait_msec(100); - ASSERT_TRUE(proxy != nullptr); - - /*** - **** Try changing the Settings -- do the DBus properties change to match it? - ***/ - - auto expected_volume = 1; - int expected_duration = 4; - int expected_snooze_duration = 5; - const char * expected_sound = "/tmp/foo.wav"; - const char * expected_haptic = "pulse"; - settings->alarm_volume.set(expected_volume); - settings->alarm_duration.set(expected_duration); - settings->snooze_duration.set(expected_snooze_duration); - settings->alarm_sound.set(expected_sound); - settings->alarm_haptic.set(expected_haptic); - wait_msec(); - - static constexpr const char* const SOUND_PROP {"default-sound"}; - static constexpr const char* const VOLUME_PROP {"default-volume"}; - static constexpr const char* const DURATION_PROP {"duration"}; - static constexpr const char* const HAPTIC_PROP {"haptic-feedback"}; - static constexpr const char* const SNOOZE_PROP {"snooze-duration"}; - - char* sound = nullptr; - char* haptic = nullptr; - int volume = -1; - int duration = -1; - int snooze = -1; - g_object_get(proxy, SOUND_PROP, &sound, - HAPTIC_PROP, &haptic, - VOLUME_PROP, &volume, - DURATION_PROP, &duration, - SNOOZE_PROP, &snooze, - nullptr); - EXPECT_STREQ(expected_sound, sound); - EXPECT_STREQ(expected_haptic, haptic); - EXPECT_EQ(expected_volume, volume); - EXPECT_EQ(expected_duration, duration); - EXPECT_EQ(expected_snooze_duration, snooze); - - g_clear_pointer (&sound, g_free); - g_clear_pointer (&haptic, g_free); - - /*** - **** Try changing the DBus properties -- do the Settings change to match it? - ***/ - - expected_volume = 100; - expected_duration = 30; - expected_sound = "/tmp/bar.wav"; - expected_haptic = "none"; - expected_snooze_duration = 5; - g_object_set(proxy, SOUND_PROP, expected_sound, - HAPTIC_PROP, expected_haptic, - VOLUME_PROP, expected_volume, - DURATION_PROP, expected_duration, - SNOOZE_PROP, expected_snooze_duration, - nullptr); - wait_msec(); - - EXPECT_STREQ(expected_sound, settings->alarm_sound.get().c_str()); - EXPECT_STREQ(expected_haptic, settings->alarm_haptic.get().c_str()); - EXPECT_EQ(expected_volume, settings->alarm_volume.get()); - EXPECT_EQ(expected_duration, settings->alarm_duration.get()); - EXPECT_EQ(expected_snooze_duration, settings->snooze_duration.get()); - - // cleanup - g_clear_object(&proxy); -}