diff options
-rw-r--r-- | src/CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/accounts-service-system-sound-settings.vala | 8 | ||||
-rw-r--r-- | src/accounts-service-user.vala | 10 | ||||
-rw-r--r-- | tests/accounts-service-mock.h | 170 |
4 files changed, 102 insertions, 96 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc618d9..d157b58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,12 +18,12 @@ else() set (HAVE_UT_ACCTSERVICE_PRIVACY_SETTINGS OFF) endif() -if(EXISTS "/usr/share/accountsservice/interfaces/com.ubuntu.touch.AccountsService.Sound.xml") - set (HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS ON) +if(EXISTS "/usr/share/accountsservice/interfaces/com.lomiri.touch.AccountsService.Sound.xml") + set (HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS ON) set (VALA_FILE_ACCTSERVICE_SYSTEMSOUND_SETTINGS "accounts-service-system-sound-settings") - set (VALA_DEFINE_ACCTSERVICE_SYSTEMSOUND_SETTINGS "--define=HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS") + set (VALA_DEFINE_ACCTSERVICE_SYSTEMSOUND_SETTINGS "--define=HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS") else() - set (HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS OFF) + set (HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS OFF) endif() if(EXISTS "/usr/share/accountsservice/interfaces/com.ubuntu.AccountsService.Sound.xml") @@ -226,7 +226,7 @@ if(${HAVE_UT_ACCTSERVICE_PRIVACY_SETTINGS}) ) endif() -if(${HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS}) +if(${HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS}) vala_add(ayatana-indicator-sound-service accounts-service-privacy-settings.vala ) diff --git a/src/accounts-service-system-sound-settings.vala b/src/accounts-service-system-sound-settings.vala index 9eb91c4..0fa3d0c 100644 --- a/src/accounts-service-system-sound-settings.vala +++ b/src/accounts-service-system-sound-settings.vala @@ -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 as published by @@ -15,10 +16,11 @@ * * Authors: * Ted Gould <ted@canonical.com> + * Robert Tari <robert@tari.in> */ -[DBus (name = "com.ubuntu.touch.AccountsService.Sound")] +[DBus (name = "com.lomiri.touch.AccountsService.Sound")] public interface AccountsServiceSystemSoundSettings : Object { - // properties - public abstract bool silent_mode {owned get; set;} + // properties + public abstract bool silent_mode {owned get; set;} } diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index e7e2299..caffab9 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -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 as published by @@ -15,6 +16,7 @@ * * Authors: * Ted Gould <ted@canonical.com> + * Robert Tari <robert@tari.in> */ public class AccountsServiceUser : Object { @@ -24,7 +26,7 @@ public class AccountsServiceUser : Object { #if HAS_UT_ACCTSERVICE_PRIVACY_SETTINGS AccountsServicePrivacySettings? privacyproxy = null; #endif -#if HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS +#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS AccountsServiceSystemSoundSettings? syssoundproxy = null; #endif uint timer = 0; @@ -40,7 +42,7 @@ public class AccountsServiceUser : Object { } set { _silentMode = value; -#if HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS +#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS if (syssoundproxy != null) syssoundproxy.silent_mode = value; #endif @@ -157,7 +159,7 @@ public class AccountsServiceUser : Object { new_privacy_proxy); #endif -#if HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS +#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS Bus.get_proxy.begin<AccountsServiceSystemSoundSettings> ( BusType.SYSTEM, "org.freedesktop.Accounts", @@ -214,7 +216,7 @@ public class AccountsServiceUser : Object { } #endif -#if HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS +#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS void new_system_sound_proxy (GLib.Object? obj, AsyncResult res) { try { this.syssoundproxy = Bus.get_proxy.end (res); diff --git a/tests/accounts-service-mock.h b/tests/accounts-service-mock.h index 5617593..2fa7760 100644 --- a/tests/accounts-service-mock.h +++ b/tests/accounts-service-mock.h @@ -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 as published by @@ -15,6 +16,7 @@ * * Authors: * Ted Gould <ted@canonical.com> + * Robert Tari <robert@tari.in> */ #include <memory> @@ -22,101 +24,101 @@ class AccountsServiceMock { - DbusTestDbusMock * mock = nullptr; - DbusTestDbusMockObject * soundobj = nullptr; - DbusTestDbusMockObject * userobj = nullptr; - DbusTestDbusMockObject * syssoundobj = nullptr; + DbusTestDbusMock * mock = nullptr; + DbusTestDbusMockObject * soundobj = nullptr; + DbusTestDbusMockObject * userobj = nullptr; + DbusTestDbusMockObject * syssoundobj = nullptr; - public: - AccountsServiceMock () { - mock = dbus_test_dbus_mock_new("org.freedesktop.Accounts"); + public: + AccountsServiceMock () { + mock = dbus_test_dbus_mock_new("org.freedesktop.Accounts"); - dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SYSTEM); + dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SYSTEM); - DbusTestDbusMockObject * baseobj = dbus_test_dbus_mock_get_object(mock, "/org/freedesktop/Accounts", "org.freedesktop.Accounts", NULL); + DbusTestDbusMockObject * baseobj = dbus_test_dbus_mock_get_object(mock, "/org/freedesktop/Accounts", "org.freedesktop.Accounts", NULL); - dbus_test_dbus_mock_object_add_method(mock, baseobj, - "CacheUser", G_VARIANT_TYPE_STRING, G_VARIANT_TYPE_OBJECT_PATH, - "ret = dbus.ObjectPath('/user')\n", NULL); - dbus_test_dbus_mock_object_add_method(mock, baseobj, - "FindUserById", G_VARIANT_TYPE_INT64, G_VARIANT_TYPE_OBJECT_PATH, - "ret = dbus.ObjectPath('/user')\n", NULL); - dbus_test_dbus_mock_object_add_method(mock, baseobj, - "FindUserByName", G_VARIANT_TYPE_STRING, G_VARIANT_TYPE_OBJECT_PATH, - "ret = dbus.ObjectPath('/user')\n", NULL); - dbus_test_dbus_mock_object_add_method(mock, baseobj, - "ListCachedUsers", NULL, G_VARIANT_TYPE_OBJECT_PATH_ARRAY, - "ret = [ dbus.ObjectPath('/user') ]\n", NULL); - dbus_test_dbus_mock_object_add_method(mock, baseobj, - "UncacheUser", G_VARIANT_TYPE_STRING, NULL, - "", NULL); + dbus_test_dbus_mock_object_add_method(mock, baseobj, + "CacheUser", G_VARIANT_TYPE_STRING, G_VARIANT_TYPE_OBJECT_PATH, + "ret = dbus.ObjectPath('/user')\n", NULL); + dbus_test_dbus_mock_object_add_method(mock, baseobj, + "FindUserById", G_VARIANT_TYPE_INT64, G_VARIANT_TYPE_OBJECT_PATH, + "ret = dbus.ObjectPath('/user')\n", NULL); + dbus_test_dbus_mock_object_add_method(mock, baseobj, + "FindUserByName", G_VARIANT_TYPE_STRING, G_VARIANT_TYPE_OBJECT_PATH, + "ret = dbus.ObjectPath('/user')\n", NULL); + dbus_test_dbus_mock_object_add_method(mock, baseobj, + "ListCachedUsers", NULL, G_VARIANT_TYPE_OBJECT_PATH_ARRAY, + "ret = [ dbus.ObjectPath('/user') ]\n", NULL); + dbus_test_dbus_mock_object_add_method(mock, baseobj, + "UncacheUser", G_VARIANT_TYPE_STRING, NULL, + "", NULL); - userobj = dbus_test_dbus_mock_get_object(mock, "/user", "org.freedesktop.Accounts.User", NULL); - dbus_test_dbus_mock_object_add_property(mock, userobj, - "UserName", G_VARIANT_TYPE_STRING, - g_variant_new_string(g_get_user_name()), NULL); + userobj = dbus_test_dbus_mock_get_object(mock, "/user", "org.freedesktop.Accounts.User", NULL); + dbus_test_dbus_mock_object_add_property(mock, userobj, + "UserName", G_VARIANT_TYPE_STRING, + g_variant_new_string(g_get_user_name()), NULL); - soundobj = dbus_test_dbus_mock_get_object(mock, "/user", "org.ayatana.indicator.sound.AccountsService", NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "Timestamp", G_VARIANT_TYPE_UINT64, - g_variant_new_uint64(0), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "PlayerName", G_VARIANT_TYPE_STRING, - g_variant_new_string(""), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "PlayerIcon", G_VARIANT_TYPE_VARIANT, - g_variant_new_variant(g_variant_new_string("")), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "Running", G_VARIANT_TYPE_BOOLEAN, - g_variant_new_boolean(FALSE), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "State", G_VARIANT_TYPE_STRING, - g_variant_new_string(""), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "Title", G_VARIANT_TYPE_STRING, - g_variant_new_string(""), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "Artist", G_VARIANT_TYPE_STRING, - g_variant_new_string(""), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "Album", G_VARIANT_TYPE_STRING, - g_variant_new_string(""), NULL); - dbus_test_dbus_mock_object_add_property(mock, soundobj, - "ArtUrl", G_VARIANT_TYPE_STRING, - g_variant_new_string(""), NULL); + soundobj = dbus_test_dbus_mock_get_object(mock, "/user", "org.ayatana.indicator.sound.AccountsService", NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "Timestamp", G_VARIANT_TYPE_UINT64, + g_variant_new_uint64(0), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "PlayerName", G_VARIANT_TYPE_STRING, + g_variant_new_string(""), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "PlayerIcon", G_VARIANT_TYPE_VARIANT, + g_variant_new_variant(g_variant_new_string("")), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "Running", G_VARIANT_TYPE_BOOLEAN, + g_variant_new_boolean(FALSE), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "State", G_VARIANT_TYPE_STRING, + g_variant_new_string(""), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "Title", G_VARIANT_TYPE_STRING, + g_variant_new_string(""), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "Artist", G_VARIANT_TYPE_STRING, + g_variant_new_string(""), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "Album", G_VARIANT_TYPE_STRING, + g_variant_new_string(""), NULL); + dbus_test_dbus_mock_object_add_property(mock, soundobj, + "ArtUrl", G_VARIANT_TYPE_STRING, + g_variant_new_string(""), NULL); - syssoundobj = dbus_test_dbus_mock_get_object(mock, "/user", "com.ubuntu.touch.AccountsService.Sound", NULL); - dbus_test_dbus_mock_object_add_property(mock, syssoundobj, - "SilentMode", G_VARIANT_TYPE_BOOLEAN, - g_variant_new_boolean(FALSE), NULL); - } + syssoundobj = dbus_test_dbus_mock_get_object(mock, "/user", "com.lomiri.touch.AccountsService.Sound", NULL); + dbus_test_dbus_mock_object_add_property(mock, syssoundobj, + "SilentMode", G_VARIANT_TYPE_BOOLEAN, + g_variant_new_boolean(FALSE), NULL); + } - ~AccountsServiceMock () { - g_debug("Destroying the Accounts Service Mock"); - g_clear_object(&mock); - } + ~AccountsServiceMock () { + g_debug("Destroying the Accounts Service Mock"); + g_clear_object(&mock); + } - void setSilentMode (bool modeValue) { - dbus_test_dbus_mock_object_update_property(mock, syssoundobj, - "SilentMode", g_variant_new_boolean(modeValue ? TRUE : FALSE), - NULL); - } + void setSilentMode (bool modeValue) { + dbus_test_dbus_mock_object_update_property(mock, syssoundobj, + "SilentMode", g_variant_new_boolean(modeValue ? TRUE : FALSE), + NULL); + } - operator std::shared_ptr<DbusTestTask> () { - return std::shared_ptr<DbusTestTask>( - DBUS_TEST_TASK(g_object_ref(mock)), - [](DbusTestTask * task) { g_clear_object(&task); }); - } + operator std::shared_ptr<DbusTestTask> () { + return std::shared_ptr<DbusTestTask>( + DBUS_TEST_TASK(g_object_ref(mock)), + [](DbusTestTask * task) { g_clear_object(&task); }); + } - operator DbusTestTask* () { - return DBUS_TEST_TASK(mock); - } + operator DbusTestTask* () { + return DBUS_TEST_TASK(mock); + } - operator DbusTestDbusMock* () { - return mock; - } + operator DbusTestDbusMock* () { + return mock; + } - DbusTestDbusMockObject * get_sound () { - return soundobj; - } + DbusTestDbusMockObject * get_sound () { + return soundobj; + } }; |