From a85e2f61309321207a6243e12792879b1bcf6b3a Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 16 Jan 2022 22:28:53 +1300 Subject: [PATCH] Finalise zbus3 conversion --- Cargo.lock | 829 ++++++++++++++++--------- asus-notify/Cargo.toml | 3 +- asus-notify/src/main.rs | 143 ++++- asusctl/src/main.rs | 34 +- daemon-user/src/ctrl_anime.rs | 16 +- daemon-user/src/daemon.rs | 8 +- daemon/Cargo.toml | 16 +- daemon/src/config.rs | 5 +- daemon/src/ctrl_anime/mod.rs | 73 +-- daemon/src/ctrl_anime/zbus.rs | 33 +- daemon/src/ctrl_aura/controller.rs | 65 +- daemon/src/ctrl_aura/zbus.rs | 122 ++-- daemon/src/ctrl_charge.rs | 28 +- daemon/src/ctrl_profiles/controller.rs | 4 +- daemon/src/ctrl_profiles/zbus.rs | 38 +- daemon/src/ctrl_rog_bios.rs | 47 +- daemon/src/ctrl_supported.rs | 9 +- daemon/src/daemon.rs | 74 +-- daemon/src/lib.rs | 9 +- rog-anime/Cargo.toml | 6 +- rog-anime/src/data.rs | 3 +- rog-aura/Cargo.toml | 5 +- rog-aura/src/builtin_modes.rs | 2 +- rog-dbus/Cargo.toml | 6 +- rog-dbus/src/lib.rs | 194 +++--- rog-dbus/src/zbus_anime.rs | 70 +-- rog-dbus/src/zbus_charge.rs | 41 +- rog-dbus/src/zbus_led.rs | 117 +--- rog-dbus/src/zbus_profile.rs | 76 +-- rog-dbus/src/zbus_rogbios.rs | 63 +- rog-dbus/src/zbus_supported.rs | 23 +- rog-profiles/Cargo.toml | 4 +- rog-supported/Cargo.toml | 4 +- 33 files changed, 1093 insertions(+), 1077 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16b3d067..56cf71fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,29 +17,18 @@ dependencies = [ "memchr", ] -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "asus-notify" version = "3.0.2" dependencies = [ + "futures", "notify-rust", "rog_aura", "rog_dbus", "rog_profiles", "rog_supported", "serde_json", - "zbus", + "zbus 2.2.0", ] [[package]] @@ -58,14 +47,51 @@ dependencies = [ "sysfs-class", "tinybmp", "toml", - "zbus", + "zbus 1.9.2", +] + +[[package]] +name = "async-broadcast" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bbd92a9bd0e9c1298118ecf8a2f825e86b12c3ec9e411573e34aaf3a0c03cdd" +dependencies = [ + "easy-parallel", + "event-listener", + "futures-core", + "parking_lot", +] + +[[package]] +name = "async-channel" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", + "slab", ] [[package]] name = "async-io" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +checksum = "e5e18f61464ae81cde0a23e713ae8fd299580c54d697a35820cfd0625b8b0e07" dependencies = [ "concurrent-queue", "futures-lite", @@ -80,6 +106,43 @@ dependencies = [ "winapi", ] +[[package]] +name = "async-lock" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-recursion" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-task" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" + +[[package]] +name = "async-trait" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -93,15 +156,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" @@ -109,17 +166,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "blake2b_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] - [[package]] name = "block" version = "0.1.6" @@ -140,9 +186,9 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -150,19 +196,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi", -] - [[package]] name = "color_quant" version = "1.1.0" @@ -178,27 +211,14 @@ dependencies = [ "cache-padded", ] -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crossbeam-utils" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" -dependencies = [ - "cfg-if", - "lazy_static", -] - [[package]] name = "daemon" version = "4.0.7" dependencies = [ + "async-executor", + "async-trait", "env_logger", + "futures", "log", "logind-zbus", "rog_anime", @@ -213,25 +233,24 @@ dependencies = [ "sysfs-class", "toml", "udev", - "zbus", - "zvariant", - "zvariant_derive", + "zbus 2.2.0", + "zvariant 3.2.1", ] [[package]] name = "daemon-user" version = "1.2.0" dependencies = [ - "dirs 3.0.2", + "dirs", "rog_anime", "rog_dbus", "rog_supported", "serde", "serde_derive", "serde_json", - "zbus", - "zvariant", - "zvariant_derive", + "zbus 1.9.2", + "zvariant 2.10.0", + "zvariant_derive 2.10.0", ] [[package]] @@ -245,17 +264,6 @@ dependencies = [ "syn", ] -[[package]] -name = "dirs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -dependencies = [ - "libc", - "redox_users 0.3.5", - "winapi", -] - [[package]] name = "dirs" version = "3.0.2" @@ -266,23 +274,60 @@ dependencies = [ ] [[package]] -name = "dirs-sys" -version = "0.3.6" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", - "redox_users 0.4.0", + "redox_users", "winapi", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "easy-parallel" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6907e25393cdcc1f4f3f513d9aac1e840eb1cc341a0fccb01171f7d14d10b946" + [[package]] name = "enumflags2" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0" dependencies = [ - "enumflags2_derive", + "enumflags2_derive 0.6.4", + "serde", +] + +[[package]] +name = "enumflags2" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +dependencies = [ + "enumflags2_derive 0.7.4", "serde", ] @@ -297,6 +342,17 @@ dependencies = [ "syn", ] +[[package]] +name = "enumflags2_derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env_logger" version = "0.8.4" @@ -311,19 +367,25 @@ dependencies = [ ] [[package]] -name = "fastrand" -version = "1.6.0" +name = "event-listener" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2" +checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" + +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" dependencies = [ "instant", ] [[package]] name = "futures" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", @@ -336,9 +398,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", "futures-sink", @@ -346,26 +408,27 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-executor" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", "futures-util", + "num_cpus", ] [[package]] name = "futures-io" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-lite" @@ -384,9 +447,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ "proc-macro2", "quote", @@ -395,21 +458,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-channel", "futures-core", @@ -425,24 +488,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.16" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if", "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -466,18 +518,18 @@ dependencies = [ [[package]] name = "gumdrop" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46571f5d540478cf70d2a42dd0d6d8e9f4b9cc7531544b93311e657b86568a0b" +checksum = "5bc700f989d2f6f0248546222d9b4258f5b02a171a431f8285a81c08142629e3" dependencies = [ "gumdrop_derive", ] [[package]] name = "gumdrop_derive" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915ef07c710d84733522461de2a734d4d62a3fd39a4d4f404c2f385ef8618d05" +checksum = "729f9bd3449d77e7831a18abfb7ba2f99ee813dfd15b8c2167c9a54ba20aa99d" dependencies = [ "proc-macro2", "quote", @@ -502,6 +554,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "humantime" version = "2.1.0" @@ -519,9 +577,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "lazy_static" @@ -531,9 +589,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libudev-sys" @@ -558,38 +616,49 @@ dependencies = [ ] [[package]] -name = "log" -version = "0.4.14" +name = "lock_api" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] [[package]] name = "logind-zbus" -version = "0.7.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca64bea11e365933e0c4a1a9342f0122d1d2822a09c87dab0e1d314adb353a2" +checksum = "6aa2833a7dee801395cc0b5fdc9f42b8777952d339437e6905b19860962f004d" dependencies = [ "serde", "serde_json", - "zbus", - "zbus_macros", - "zvariant", - "zvariant_derive", + "zbus 2.2.0", + "zbus_macros 2.2.0", + "zvariant 3.2.1", + "zvariant_derive 3.2.1", ] [[package]] name = "mac-notification-sys" -version = "0.3.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb6b71a9a89cd38b395d994214297447e8e63b1ba5708a9a2b0b1048ceda76" +checksum = "297c13fc8ff9fa8b2d0e53850f80e0aa962628e865d447031ce58cdb062e5b29" dependencies = [ "cc", - "chrono", - "dirs 1.0.5", + "dirs-next", "objc-foundation", + "objc_id", + "time", ] [[package]] @@ -603,9 +672,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" @@ -649,6 +718,19 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + [[package]] name = "nom" version = "5.1.2" @@ -661,35 +743,35 @@ dependencies = [ [[package]] name = "notify-rust" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ebab865e67efdd7182a88d76cadbdd2a8d02d1c7a4e16bb7c234016a12cac" +checksum = "a995a3d2834cefa389218e7a35156e8ce544bc95f836900da01ee0b26a07e9d4" dependencies = [ "mac-notification-sys", "serde", "winrt-notification", - "zbus", - "zvariant", - "zvariant_derive", + "zbus 2.2.0", + "zvariant 3.2.1", + "zvariant_derive 3.2.1", ] [[package]] -name = "num-integer" -version = "0.1.44" +name = "num_cpus" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ - "autocfg", - "num-traits", + "hermit-abi", + "libc", ] [[package]] -name = "num-traits" -version = "0.2.14" +name = "num_threads" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" dependencies = [ - "autocfg", + "libc", ] [[package]] @@ -729,9 +811,19 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.9.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" + +[[package]] +name = "ordered-stream" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44630c059eacfd6e08bdaa51b1db2ce33119caa4ddc1235e923109aa5f25ccb1" +dependencies = [ + "futures-core", + "pin-project-lite", +] [[package]] name = "parking" @@ -740,10 +832,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] -name = "pin-project-lite" -version = "0.2.7" +name = "parking_lot" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -753,15 +870,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pix" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea9d5c668f13b4a1b97d848780e00cfabf76eb83538129c264c0c6d6a968047" +checksum = "0c2b6992b377680150280d4708bda8207ba9e71f70507b5504f2e28d8e8e48c1" [[package]] name = "pkg-config" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "png_pong" @@ -786,6 +903,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -797,9 +920,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ "thiserror", "toml", @@ -807,63 +930,77 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.34" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ "proc-macro2", ] [[package]] -name = "redox_syscall" -version = "0.1.57" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.3.5" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.1.16", - "redox_syscall 0.1.57", - "rust-argon2", -] - -[[package]] -name = "redox_users" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" -dependencies = [ - "getrandom 0.2.3", - "redox_syscall 0.2.10", + "getrandom", + "redox_syscall", + "thiserror", ] [[package]] name = "regex" -version = "1.5.4" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" dependencies = [ "aho-corasick", "memchr", @@ -872,9 +1009,18 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] [[package]] name = "rog_anime" @@ -886,8 +1032,7 @@ dependencies = [ "png_pong", "serde", "serde_derive", - "zvariant", - "zvariant_derive", + "zvariant 3.2.1", ] [[package]] @@ -896,8 +1041,7 @@ version = "1.1.0" dependencies = [ "serde", "serde_derive", - "zvariant", - "zvariant_derive", + "zvariant 3.2.1", ] [[package]] @@ -908,9 +1052,9 @@ dependencies = [ "rog_aura", "rog_profiles", "rog_supported", - "zbus", - "zbus_macros", - "zvariant", + "zbus 2.2.0", + "zbus_macros 2.2.0", + "zvariant 3.2.1", ] [[package]] @@ -920,8 +1064,8 @@ dependencies = [ "serde", "serde_derive", "udev", - "zvariant", - "zvariant_derive", + "zvariant 3.2.1", + "zvariant_derive 3.2.1", ] [[package]] @@ -931,8 +1075,8 @@ dependencies = [ "rog_aura", "serde", "serde_derive", - "zvariant", - "zvariant_derive", + "zvariant 3.2.1", + "zvariant_derive 3.2.1", ] [[package]] @@ -945,23 +1089,11 @@ dependencies = [ "libusb1-sys", ] -[[package]] -name = "rust-argon2" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" -dependencies = [ - "base64", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] - [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] name = "scoped-tls" @@ -970,19 +1102,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" [[package]] -name = "serde" -version = "1.0.132" +name = "scopeguard" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.132" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", @@ -991,9 +1129,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.73" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" dependencies = [ "itoa", "ryu", @@ -1002,9 +1140,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" +checksum = "a2ad84e47328a31223de7fed7a4f5087f2d6ddfe586cf3ca25b7a165bc0a5aed" dependencies = [ "proc-macro2", "quote", @@ -1012,16 +1150,37 @@ dependencies = [ ] [[package]] -name = "slab" -version = "0.4.5" +name = "sha1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" +dependencies = [ + "sha1_smol", +] + +[[package]] +name = "sha1_smol" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" + +[[package]] +name = "slab" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -1056,13 +1215,13 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.82" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1075,28 +1234,42 @@ dependencies = [ ] [[package]] -name = "termcolor" -version = "1.1.2" +name = "tempfile" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", @@ -1105,12 +1278,12 @@ dependencies = [ [[package]] name = "time" -version = "0.1.43" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ "libc", - "winapi", + "num_threads", ] [[package]] @@ -1124,18 +1297,18 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ "serde", ] [[package]] name = "udev" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3193363f52bb34c6708ac2ffedcb5f7e5874f0329ef68e1315f27d8d768eb568" +checksum = "1c960764f7e816eed851a96c364745d37f9fe71a2e7dba79fbd40104530b5dd0" dependencies = [ "libc", "libudev-sys", @@ -1143,16 +1316,26 @@ dependencies = [ ] [[package]] -name = "unicode-segmentation" -version = "1.8.0" +name = "uds_windows" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" +checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +dependencies = [ + "tempfile", + "winapi", +] [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-ident" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" [[package]] name = "vcpkg" @@ -1162,9 +1345,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "waker-fn" @@ -1172,12 +1355,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -1186,9 +1363,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "weezl" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e" +checksum = "9c97e489d8f836838d497091de568cf16b117486d529ec5579233521065bd5e4" [[package]] name = "wepoll-ffi" @@ -1268,9 +1445,9 @@ checksum = "9bd8f062d8ca5446358159d79a90be12c543b3a965c847c8f3eedf14b321d399" [[package]] name = "winrt-notification" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda101fb8e034a25f3d50a0714d7ca4f234a4fc7bc57427f6d81040db0ccbe6a" +checksum = "007a0353840b23e0c6dc73e5b962ff58ed7f6bc9ceff3ce7fe6fbad8d496edf4" dependencies = [ "strum", "windows", @@ -1292,18 +1469,56 @@ dependencies = [ "async-io", "byteorder", "derivative", - "enumflags2", + "enumflags2 0.6.4", "fastrand", "futures", "nb-connect", - "nix", + "nix 0.20.2", "once_cell", "polling", "scoped-tls", "serde", "serde_repr", - "zbus_macros", - "zvariant", + "zbus_macros 1.9.2", + "zvariant 2.10.0", +] + +[[package]] +name = "zbus" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53819092b9db813b2c6168b097b4b13ad284d81c9f2b0165a0a1b190e505a1f3" +dependencies = [ + "async-broadcast", + "async-channel", + "async-executor", + "async-io", + "async-lock", + "async-recursion", + "async-task", + "async-trait", + "byteorder", + "derivative", + "enumflags2 0.7.5", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "lazy_static", + "nix 0.23.1", + "once_cell", + "ordered-stream", + "rand", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "uds_windows", + "winapi", + "zbus_macros 2.2.0", + "zbus_names", + "zvariant 3.2.1", ] [[package]] @@ -1318,6 +1533,30 @@ dependencies = [ "syn", ] +[[package]] +name = "zbus_macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7174ebe6722c280d6d132d694bb5664ce50a788cb70eeb518e7fc1ca095a114" +dependencies = [ + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "regex", + "syn", +] + +[[package]] +name = "zbus_names" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45dfcdcf87b71dad505d30cc27b1b7b88a64b6d1c435648f48f9dbc1fdc4b7e1" +dependencies = [ + "serde", + "static_assertions", + "zvariant 3.2.1", +] + [[package]] name = "zvariant" version = "2.10.0" @@ -1325,11 +1564,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a68c7b55f2074489b7e8e07d2d0a6ee6b4f233867a653c664d8020ba53692525" dependencies = [ "byteorder", - "enumflags2", + "enumflags2 0.6.4", "libc", "serde", "static_assertions", - "zvariant_derive", + "zvariant_derive 2.10.0", +] + +[[package]] +name = "zvariant" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd1abd8bc2c855412b9c8af9fc11c0d695c73c732ad5a1a1be10f3fd4bf19b2" +dependencies = [ + "byteorder", + "enumflags2 0.7.5", + "libc", + "serde", + "static_assertions", + "zvariant_derive 3.2.1", ] [[package]] @@ -1338,7 +1591,19 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4ca5e22593eb4212382d60d26350065bf2a02c34b85bc850474a74b589a3de9" dependencies = [ - "proc-macro-crate 1.1.0", + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zvariant_derive" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abebd57382dfacf3e7bbdd7b7c3d162d6ed0687a78f046263ddef4ddabc275ae" +dependencies = [ + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", diff --git a/asus-notify/Cargo.toml b/asus-notify/Cargo.toml index a4b48a18..0c507ac9 100644 --- a/asus-notify/Cargo.toml +++ b/asus-notify/Cargo.toml @@ -7,13 +7,14 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -zbus = "^1.9" +zbus = "^2.2" # serialisation serde_json = "^1.0" rog_dbus = { path = "../rog-dbus" } rog_aura = { path = "../rog-aura" } rog_supported = { path = "../rog-supported" } rog_profiles = { path = "../rog-profiles" } +futures = { version = "0.3.19", features = ["executor", "thread-pool"] } [dependencies.notify-rust] version = "^4.3" diff --git a/asus-notify/src/main.rs b/asus-notify/src/main.rs index a9ef55c1..65b1c214 100644 --- a/asus-notify/src/main.rs +++ b/asus-notify/src/main.rs @@ -1,10 +1,16 @@ +use futures::{executor::ThreadPool, StreamExt}; use notify_rust::{Hint, Notification, NotificationHandle}; use rog_aura::AuraEffect; -use rog_dbus::{DbusProxies, Signals}; +use rog_dbus::{ + zbus_charge::ChargeProxy, zbus_led::LedProxy, zbus_profile::ProfileProxy, + zbus_rogbios::RogBiosProxy, +}; use rog_profiles::Profile; -use std::error::Error; -use std::thread::sleep; -use std::time::Duration; +use std::{ + error::Error, + future, + sync::{Arc, Mutex}, +}; const NOTIF_HEADER: &str = "ROG Control"; @@ -14,7 +20,7 @@ macro_rules! notify { notif.close(); } if let Ok(x) = $notifier($data) { - $last_notif = Some(x); + $last_notif.replace(x); } }; } @@ -29,43 +35,110 @@ macro_rules! base_notification { }; } +type SharedHandle = Arc>>; + fn main() -> Result<(), Box> { println!("asus-notify version {}", env!("CARGO_PKG_VERSION")); println!(" rog-dbus version {}", rog_dbus::VERSION); - let (proxies, conn) = DbusProxies::new()?; - let signals = Signals::new(&proxies)?; + let last_notification: SharedHandle = Arc::new(Mutex::new(None)); - let mut last_notification: Option = None; + let thread_pool = ThreadPool::new()?; + // BIOS notif + let x = last_notification.clone(); + thread_pool.spawn_ok(async move { + let conn = zbus::Connection::system().await.unwrap(); + let proxy = RogBiosProxy::new(&conn).await.unwrap(); + if let Ok(p) = proxy.receive_notify_post_boot_sound().await { + p.for_each(|e| { + if let Ok(out) = e.args() { + if let Ok(ref mut lock) = x.try_lock() { + notify!(do_post_sound_notif, lock, &out.sound()); + } + } + future::ready(()) + }) + .await; + }; + }); - let recv = proxies.setup_recv(conn); - let mut err_count = 0; + // Charge notif + let x = last_notification.clone(); + thread_pool.spawn_ok(async move { + let conn = zbus::Connection::system().await.unwrap(); + let proxy = ChargeProxy::new(&conn).await.unwrap(); + if let Ok(p) = proxy.receive_notify_charge().await { + p.for_each(|e| { + if let Ok(out) = e.args() { + if let Ok(ref mut lock) = x.try_lock() { + notify!(do_charge_notif, lock, &out.limit); + } + } + future::ready(()) + }) + .await; + }; + }); + + // Profile notif + let x = last_notification.clone(); + thread_pool.spawn_ok(async move { + let conn = zbus::Connection::system().await.unwrap(); + let proxy = ProfileProxy::new(&conn).await.unwrap(); + if let Ok(p) = proxy.receive_notify_profile().await { + p.for_each(|e| { + if let Ok(out) = e.args() { + if let Ok(ref mut lock) = x.try_lock() { + notify!(do_thermal_notif, lock, &out.profile); + } + } + future::ready(()) + }) + .await; + }; + }); + + // LED notif + thread_pool.spawn_ok(async move { + let conn = zbus::Connection::system().await.unwrap(); + let proxy = LedProxy::new(&conn).await.unwrap(); + if let Ok(p) = proxy.receive_notify_led().await { + p.for_each(|e| { + if let Ok(out) = e.args() { + if let Ok(ref mut lock) = last_notification.try_lock() { + notify!(do_led_notif, lock, &out.data); + } + } + future::ready(()) + }) + .await; + }; + }); loop { - sleep(Duration::from_millis(100)); - if let Err(err) = recv.next_signal() { - if err_count < 3 { - err_count += 1; - println!("{}", err); - } - if err_count == 3 { - err_count += 1; - println!("Max error count reached. Spooling silently."); - } - sleep(Duration::from_millis(2000)); - continue; - } - err_count = 0; + std::thread::sleep(std::time::Duration::from_millis(1000)); + // if err_count < 3 { + // err_count += 1; + // println!("{}", err); + // } + // if err_count == 3 { + // err_count += 1; + // println!("Max error count reached. Spooling silently."); + // } + // sleep(Duration::from_millis(2000)); + // continue; + // } + // err_count = 0; - if let Ok(data) = signals.led_mode.try_recv() { - notify!(do_led_notif, last_notification, &data); - } - if let Ok(data) = signals.profile.try_recv() { - notify!(do_thermal_notif, last_notification, &data); - } - if let Ok(data) = signals.charge.try_recv() { - notify!(do_charge_notif, last_notification, &data); - } + // if let Ok(data) = signals.led_mode.try_recv() { + // notify!(do_led_notif, last_notification, &data); + // } + // if let Ok(data) = signals.profile.try_recv() { + // notify!(do_thermal_notif, last_notification, &data); + // } + // if let Ok(data) = signals.charge.try_recv() { + // notify!(do_charge_notif, last_notification, &data); + // } } } @@ -101,3 +174,7 @@ fn do_led_notif(ledmode: &AuraEffect) -> Result Result { base_notification!(&format!("Battery charge limit changed to {}", limit)) } + +fn do_post_sound_notif(on: &bool) -> Result { + base_notification!(&format!("BIOS Post sound {}", on)) +} diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index b0ab38d7..b5e8cd2e 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -8,7 +8,7 @@ use anime_cli::{AnimeActions, AnimeCommand}; use profiles_cli::{FanCurveCommand, ProfileCommand}; use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, Vec2}; use rog_aura::{self, AuraEffect}; -use rog_dbus::RogDbusClient; +use rog_dbus::RogDbusClientBlocking; use rog_profiles::error::ProfileError; use rog_supported::SupportedFunctions; use rog_supported::{ @@ -47,7 +47,7 @@ fn main() -> Result<(), Box> { } } - let (dbus, _) = RogDbusClient::new() + let (dbus, _) = RogDbusClientBlocking::new() .map_err(|e| { print_error_help(Box::new(e), None); std::process::exit(3); @@ -57,7 +57,7 @@ fn main() -> Result<(), Box> { let supported = dbus .proxies() .supported() - .get_supported_functions() + .supported_functions() .map_err(|e| { print_error_help(Box::new(e), None); std::process::exit(4); @@ -139,7 +139,7 @@ fn do_diagnose(name: &str) -> bool { fn do_parsed( parsed: &CliStart, supported: &SupportedFunctions, - dbus: &RogDbusClient, + dbus: &RogDbusClientBlocking, ) -> Result<(), Box> { match &parsed.command { Some(CliCommand::LedMode(mode)) => handle_led_mode(dbus, &supported.keyboard_led, mode)?, @@ -170,13 +170,13 @@ fn do_parsed( if let Some(brightness) = &parsed.kbd_bright { match brightness.level() { None => { - let level = dbus.proxies().led().get_led_brightness()?; + let level = dbus.proxies().led().led_brightness()?; println!("Current keyboard led brightness: {}", level); } Some(level) => dbus .proxies() .led() - .set_led_brightness(::from(level))?, + .set_brightness(::from(level))?, } } @@ -193,7 +193,7 @@ fn do_parsed( } if let Some(chg_limit) = parsed.chg_limit { - dbus.proxies().charge().write_limit(chg_limit)?; + dbus.proxies().charge().set_limit(chg_limit)?; } Ok(()) @@ -206,7 +206,7 @@ fn do_gfx() -> Result<(), Box> { } fn handle_anime( - dbus: &RogDbusClient, + dbus: &RogDbusClientBlocking, _supported: &AnimeSupportedFunctions, cmd: &AnimeCommand, ) -> Result<(), Box> { @@ -335,7 +335,7 @@ fn handle_anime( } fn handle_led_mode( - dbus: &RogDbusClient, + dbus: &RogDbusClientBlocking, supported: &LedSupportedFunctions, mode: &LedModeCommand, ) -> Result<(), Box> { @@ -416,7 +416,7 @@ fn handle_led_mode( } fn handle_profile( - dbus: &RogDbusClient, + dbus: &RogDbusClientBlocking, supported: &PlatformProfileFunctions, cmd: &ProfileCommand, ) -> Result<(), Box> { @@ -457,7 +457,7 @@ fn handle_profile( } fn handle_fan_curve( - dbus: &RogDbusClient, + dbus: &RogDbusClientBlocking, supported: &PlatformProfileFunctions, cmd: &FanCurveCommand, ) -> Result<(), Box> { @@ -513,7 +513,7 @@ fn handle_fan_curve( if let Some(mut curve) = cmd.data.clone() { let fan = cmd.fan.unwrap_or_default(); curve.set_fan(fan); - dbus.proxies().profile().set_fan_curve(curve, profile)?; + dbus.proxies().profile().set_fan_curve(profile, curve)?; } } @@ -521,7 +521,7 @@ fn handle_fan_curve( } fn handle_bios_option( - dbus: &RogDbusClient, + dbus: &RogDbusClientBlocking, supported: &RogBiosSupportedFunctions, cmd: &BiosCommand, ) -> Result<(), Box> { @@ -548,15 +548,15 @@ fn handle_bios_option( } if let Some(opt) = cmd.post_sound_set { - dbus.proxies().rog_bios().set_post_sound(opt)?; + dbus.proxies().rog_bios().set_post_boot_sound(opt)?; } if cmd.post_sound_get { - let res = dbus.proxies().rog_bios().get_post_sound()? == 1; + let res = dbus.proxies().rog_bios().post_boot_sound()? == 1; println!("Bios POST sound on: {}", res); } if let Some(opt) = cmd.dedicated_gfx_set { println!("Rebuilding initrd to include drivers"); - dbus.proxies().rog_bios().set_dedicated_gfx(opt)?; + dbus.proxies().rog_bios().set_dedicated_graphic_mode(opt)?; println!("The mode change is not active until you reboot, on boot the bios will make the required change"); if opt { println!( @@ -567,7 +567,7 @@ fn handle_bios_option( } } if cmd.dedicated_gfx_get { - let res = dbus.proxies().rog_bios().get_dedicated_gfx()? == 1; + let res = dbus.proxies().rog_bios().dedicated_graphic_mode()? == 1; println!("Bios dedicated GPU on: {}", res); } } diff --git a/daemon-user/src/ctrl_anime.rs b/daemon-user/src/ctrl_anime.rs index a096f9a5..1804ca4f 100644 --- a/daemon-user/src/ctrl_anime.rs +++ b/daemon-user/src/ctrl_anime.rs @@ -1,6 +1,6 @@ use rog_anime::error::AnimeError; use rog_anime::{ActionData, ActionLoader, AnimTime, Fade, Sequences, Vec2}; -use rog_dbus::RogDbusClient; +use rog_dbus::RogDbusClientBlocking; use serde_derive::{Deserialize, Serialize}; use std::time::Duration; use std::{ @@ -66,14 +66,14 @@ pub enum TimeType { /// and a zbus server behind `Arc>` pub struct CtrlAnimeInner<'a> { sequences: Sequences, - client: RogDbusClient<'a>, + client: RogDbusClientBlocking<'a>, do_early_return: Arc, } impl<'a> CtrlAnimeInner<'static> { pub fn new( sequences: Sequences, - client: RogDbusClient<'static>, + client: RogDbusClientBlocking<'static>, do_early_return: Arc, ) -> Result { Ok(Self { @@ -131,7 +131,7 @@ impl<'a> CtrlAnimeInner<'static> { pub struct CtrlAnime<'a> { config: Arc>, - client: RogDbusClient<'a>, + client: RogDbusClientBlocking<'a>, inner: Arc>>, /// Must be the same Atomic as in CtrlAnimeInner inner_early_return: Arc, @@ -141,7 +141,7 @@ impl<'a> CtrlAnime<'static> { pub fn new( config: Arc>, inner: Arc>>, - client: RogDbusClient<'static>, + client: RogDbusClientBlocking<'static>, inner_early_return: Arc, ) -> Result { Ok(CtrlAnime { @@ -350,16 +350,16 @@ impl CtrlAnime<'static> { Err(zbus::fdo::Error::Failed("UserConfig lock fail".into())) } - pub fn set_state(&mut self, on: bool) -> zbus::fdo::Result<()> { + pub fn set_state(&mut self, on: bool) -> zbus::Result<()> { // Operations here need to be in specific order if on { - self.client.proxies().anime().set_on_off(on)?; + self.client.proxies().anime().set_on_off(on).ok(); // Let the inner loop run self.inner_early_return.store(false, Ordering::SeqCst); } else { // Must make the inner run loop return early self.inner_early_return.store(true, Ordering::SeqCst); - self.client.proxies().anime().set_on_off(on)?; + self.client.proxies().anime().set_on_off(on).ok(); } Ok(()) } diff --git a/daemon-user/src/daemon.rs b/daemon-user/src/daemon.rs index e194c24a..8d975892 100644 --- a/daemon-user/src/daemon.rs +++ b/daemon-user/src/daemon.rs @@ -1,4 +1,4 @@ -use rog_dbus::RogDbusClient; +use rog_dbus::RogDbusClientBlocking; use rog_user::{ ctrl_anime::{CtrlAnime, CtrlAnimeInner}, user_config::*, @@ -17,8 +17,8 @@ fn main() -> Result<(), Box> { println!(" rog-dbus v{}", rog_dbus::VERSION); println!("rog-supported v{}", rog_supported::VERSION); - let (client, _) = RogDbusClient::new()?; - let supported = client.proxies().supported().get_supported_functions()?; + let (client, _) = RogDbusClientBlocking::new()?; + let supported = client.proxies().supported().supported_functions()?; let mut config = UserConfig::new(); config.load_config()?; @@ -44,7 +44,7 @@ fn main() -> Result<(), Box> { early_return.clone(), )?)); // Need new client object for dbus control part - let (client, _) = RogDbusClient::new()?; + let (client, _) = RogDbusClientBlocking::new()?; let anime_control = CtrlAnime::new(anime_config, inner.clone(), client, early_return)?; anime_control.add_to_server(&mut server); // Thread using inner diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 4fcc29a9..fdfce7d1 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -18,11 +18,16 @@ name = "asusd" path = "src/daemon.rs" [dependencies] -rog_anime = { path = "../rog-anime" } -rog_aura = { path = "../rog-aura" } +rog_anime = { path = "../rog-anime", features = ["dbus"] } +rog_aura = { path = "../rog-aura", features = ["dbus"] } rog_supported = { path = "../rog-supported" } rog_profiles = { path = "../rog-profiles" } rog_dbus = { path = "../rog-dbus" } + +async-executor = "1.4.1" +async-trait = "^0.1" +futures = { version = "0.3.19", features = ["executor", "thread-pool"] } + rusb = "^0.8" udev = "^0.6" @@ -30,10 +35,9 @@ udev = "^0.6" log = "^0.4" env_logger = "^0.8" -zbus = "^1.9.1" -zvariant = "^2.6" -zvariant_derive = { version = "^2.6" } -logind-zbus = "^0.7.1" +zbus = "^2.0" +zvariant = "^3.0" +logind-zbus = { version = "^2.0" } #, default-features = false, features = ["non_blocking"] } # serialisation serde = "^1.0" diff --git a/daemon/src/config.rs b/daemon/src/config.rs index 8c891191..0ebf6b1a 100644 --- a/daemon/src/config.rs +++ b/daemon/src/config.rs @@ -2,6 +2,7 @@ use log::{error, warn}; use serde_derive::{Deserialize, Serialize}; use std::fs::{File, OpenOptions}; use std::io::{Read, Write}; +use std::path::PathBuf; pub static CONFIG_PATH: &str = "/etc/asusd/asusd.conf"; @@ -24,8 +25,8 @@ impl Config { .read(true) .write(true) .create(true) - .open(&CONFIG_PATH) - .unwrap_or_else(|_| panic!("The directory /etc/asusd/ is missing")); // okay to cause panic here + .open(&PathBuf::from(CONFIG_PATH)) + .unwrap_or_else(|e| panic!("Error opening {}, {}", CONFIG_PATH, e)); // okay to cause panic here let mut buf = String::new(); let config; if let Ok(read_len) = file.read_to_string(&mut buf) { diff --git a/daemon/src/ctrl_anime/mod.rs b/daemon/src/ctrl_anime/mod.rs index 4025ca6f..90d55fb9 100644 --- a/daemon/src/ctrl_anime/mod.rs +++ b/daemon/src/ctrl_anime/mod.rs @@ -1,7 +1,8 @@ pub mod config; pub mod zbus; -use ::zbus::Connection; +use ::zbus::blocking::Connection; +use async_trait::async_trait; use log::{error, info, warn}; use logind_zbus::ManagerProxy; use rog_anime::{ @@ -298,7 +299,7 @@ impl CtrlAnime { } pub struct CtrlAnimeTask<'a> { - inner: Arc>, + _inner: Arc>, _c: Connection, manager: ManagerProxy<'a>, } @@ -306,80 +307,24 @@ pub struct CtrlAnimeTask<'a> { impl<'a> CtrlAnimeTask<'a> { pub fn new(inner: Arc>) -> Self { let connection = - Connection::new_system().expect("CtrlAnimeTask could not create dbus connection"); + Connection::system().expect("CtrlAnimeTask could not create dbus connection"); let manager = ManagerProxy::new(&connection).expect("CtrlAnimeTask could not create ManagerProxy"); - let c1 = inner.clone(); - // Run this action when the system starts shutting down - manager - .connect_prepare_for_shutdown(move |shutdown| { - if shutdown { - 'outer: loop { - if let Ok(lock) = c1.try_lock() { - lock.thread_exit.store(true, Ordering::SeqCst); - CtrlAnime::run_thread(c1.clone(), lock.cache.shutdown.clone(), false); - break 'outer; - } - } - } - Ok(()) - }) - .map_err(|err| { - warn!("CtrlAnimeTask: new() {}", err); - err - }) - .ok(); - - let c1 = inner.clone(); - // Run this action when the system wakes up from sleep - manager - .connect_prepare_for_sleep(move |sleep| { - if !sleep { - // wait a fraction for things to wake up properly - std::thread::sleep(Duration::from_millis(100)); - 'outer: loop { - if let Ok(lock) = c1.try_lock() { - lock.thread_exit.store(true, Ordering::SeqCst); - CtrlAnime::run_thread(c1.clone(), lock.cache.wake.clone(), true); - break 'outer; - } - } - } - Ok(()) - }) - .map_err(|err| { - warn!("CtrlAnimeTask: new() {}", err); - err - }) - .ok(); - Self { - inner, + _inner: inner, _c: connection, manager, } } } +#[async_trait] impl<'a> crate::CtrlTask for CtrlAnimeTask<'a> { - fn do_task(&self) -> Result<(), RogError> { - if let Ok(mut lock) = self.inner.try_lock() { - // Refresh the config and cache incase the user has edited it - let config = AnimeConfig::load(); - lock.cache - .init_from_config(&config) - .map_err(|err| { - warn!("CtrlAnimeTask: do_task {}", err); - err - }) - .ok(); - } - - // Check for signals on each task iteration, this will run the callbacks - // if any signal is recieved - self.manager.next_signal()?; + async fn do_task(&self) -> Result<(), RogError> { + self.manager.receive_prepare_for_shutdown()?.next(); + self.manager.receive_prepare_for_sleep()?.next(); Ok(()) } } diff --git a/daemon/src/ctrl_anime/zbus.rs b/daemon/src/ctrl_anime/zbus.rs index f5e28758..86daf24b 100644 --- a/daemon/src/ctrl_anime/zbus.rs +++ b/daemon/src/ctrl_anime/zbus.rs @@ -1,11 +1,12 @@ use std::sync::{Arc, Mutex}; +use async_trait::async_trait; use log::warn; use rog_anime::{ usb::{pkt_for_apply, pkt_for_set_boot, pkt_for_set_on}, AnimeDataBuffer, AnimePowerStates, }; -use zbus::dbus_interface; +use zbus::{dbus_interface, Connection, SignalContext}; use zvariant::ObjectPath; use std::sync::atomic::Ordering; @@ -15,13 +16,16 @@ use super::CtrlAnime; pub struct CtrlAnimeZbus(pub Arc>); /// The struct with the main dbus methods requires this trait +#[async_trait] impl crate::ZbusAdd for CtrlAnimeZbus { - fn add_to_server(self, server: &mut zbus::ObjectServer) { + async fn add_to_server(self, server: &mut Connection) { server + .object_server() .at( &ObjectPath::from_str_unchecked("/org/asuslinux/Anime"), self, ) + .await .map_err(|err| { warn!("CtrlAnimeDisplay: add_to_server {}", err); err @@ -71,12 +75,10 @@ impl CtrlAnimeZbus { lock.config.awake_enabled = status; lock.config.write(); - let states = AnimePowerStates { - enabled: lock.config.awake_enabled, - boot_anim_enabled: lock.config.boot_anim_enabled, - }; - self.notify_power_states(&states) - .unwrap_or_else(|err| warn!("{}", err)); + // let states = AnimePowerStates { + // enabled: lock.config.awake_enabled, + // boot_anim_enabled: lock.config.boot_anim_enabled, + // }; break 'outer; } } @@ -91,12 +93,10 @@ impl CtrlAnimeZbus { lock.config.boot_anim_enabled = on; lock.config.write(); - let states = AnimePowerStates { - enabled: lock.config.awake_enabled, - boot_anim_enabled: lock.config.boot_anim_enabled, - }; - self.notify_power_states(&states) - .unwrap_or_else(|err| warn!("{}", err)); + // let states = AnimePowerStates { + // enabled: lock.config.awake_enabled, + // boot_anim_enabled: lock.config.boot_anim_enabled, + // }; break 'outer; } } @@ -136,5 +136,8 @@ impl CtrlAnimeZbus { /// Notify listeners of the status of AniMe LED power and factory system-status animations #[dbus_interface(signal)] - fn notify_power_states(&self, data: &AnimePowerStates) -> zbus::Result<()>; + async fn notify_power_states( + ctxt: &SignalContext<'_>, + data: AnimePowerStates, + ) -> zbus::Result<()>; } diff --git a/daemon/src/ctrl_aura/controller.rs b/daemon/src/ctrl_aura/controller.rs index e9c3ea91..7aabff83 100644 --- a/daemon/src/ctrl_aura/controller.rs +++ b/daemon/src/ctrl_aura/controller.rs @@ -6,6 +6,7 @@ use crate::{ laptops::{LaptopLedData, ASUS_KEYBOARD_DEVICES}, CtrlTask, }; +use async_trait::async_trait; use log::{info, warn}; use logind_zbus::ManagerProxy; use rog_aura::{ @@ -16,12 +17,12 @@ use rog_aura::{ AuraEffect, LedBrightness, LED_MSG_LEN, }; use rog_supported::LedSupportedFunctions; +use std::fs::OpenOptions; use std::io::{Read, Write}; use std::path::Path; use std::sync::Arc; use std::sync::Mutex; -use std::{fs::OpenOptions, thread::spawn}; -use zbus::Connection; +use zbus::blocking::Connection; use crate::GetSupported; @@ -57,46 +58,46 @@ pub struct CtrlKbdLed { pub struct CtrlKbdLedTask<'a> { inner: Arc>, _c: Connection, - manager: ManagerProxy<'a>, + _manager: ManagerProxy<'a>, } impl<'a> CtrlKbdLedTask<'a> { pub fn new(inner: Arc>) -> Self { let connection = - Connection::new_system().expect("CtrlKbdLedTask could not create dbus connection"); + Connection::system().expect("CtrlKbdLedTask could not create dbus connection"); let manager = ManagerProxy::new(&connection).expect("CtrlKbdLedTask could not create ManagerProxy"); - let c1 = inner.clone(); - // Run this action when the system wakes up from sleep - manager - .connect_prepare_for_sleep(move |sleep| { - if !sleep { - let c1 = c1.clone(); - spawn(move || { - // wait a fraction for things to wake up properly - //std::thread::sleep(Duration::from_millis(100)); - loop { - if let Ok(ref mut lock) = c1.try_lock() { - lock.set_brightness(lock.config.brightness).ok(); - break; - } - } - }); - } - Ok(()) - }) - .map_err(|err| { - warn!("CtrlAnimeTask: new() {}", err); - err - }) - .ok(); + // let c1 = inner.clone(); + // // Run this action when the system wakes up from sleep + // manager + // .connect_prepare_for_sleep(move |sleep| { + // if !sleep { + // let c1 = c1.clone(); + // spawn(move || { + // // wait a fraction for things to wake up properly + // //std::thread::sleep(Duration::from_millis(100)); + // loop { + // if let Ok(ref mut lock) = c1.try_lock() { + // lock.set_brightness(lock.config.brightness).ok(); + // break; + // } + // } + // }); + // } + // Ok(()) + // }) + // .map_err(|err| { + // warn!("CtrlAnimeTask: new() {}", err); + // err + // }) + // .ok(); Self { inner, _c: connection, - manager, + _manager: manager, } } @@ -125,9 +126,11 @@ impl<'a> CtrlKbdLedTask<'a> { } } +#[async_trait] impl<'a> CtrlTask for CtrlKbdLedTask<'a> { - fn do_task(&self) -> Result<(), RogError> { - self.manager.next_signal()?; + async fn do_task(&self) -> Result<(), RogError> { + self._manager.receive_prepare_for_sleep()?.next(); + if let Ok(ref mut lock) = self.inner.try_lock() { return Self::update_config(lock); } diff --git a/daemon/src/ctrl_aura/zbus.rs b/daemon/src/ctrl_aura/zbus.rs index 3903c90b..debca4f6 100644 --- a/daemon/src/ctrl_aura/zbus.rs +++ b/daemon/src/ctrl_aura/zbus.rs @@ -1,14 +1,18 @@ +use async_trait::async_trait; use log::{error, warn}; use rog_aura::{AuraEffect, LedBrightness, LedPowerStates}; -use zbus::dbus_interface; +use zbus::{dbus_interface, Connection, SignalContext}; use zvariant::ObjectPath; use super::controller::CtrlKbdLedZbus; +#[async_trait] impl crate::ZbusAdd for CtrlKbdLedZbus { - fn add_to_server(self, server: &mut zbus::ObjectServer) { + async fn add_to_server(self, server: &mut Connection) { server + .object_server() .at(&ObjectPath::from_str_unchecked("/org/asuslinux/Led"), self) + .await .map_err(|err| { error!("DbusKbdLed: add_to_server {}", err); }) @@ -22,7 +26,7 @@ impl crate::ZbusAdd for CtrlKbdLedZbus { #[dbus_interface(name = "org.asuslinux.Daemon")] impl CtrlKbdLedZbus { /// Set the keyboard brightness level (0-3) - fn set_brightness(&mut self, brightness: LedBrightness) { + async fn set_brightness(&mut self, brightness: LedBrightness) { if let Ok(ctrl) = self.0.try_lock() { ctrl.set_brightness(brightness) .map_err(|err| warn!("{}", err)) @@ -31,7 +35,12 @@ impl CtrlKbdLedZbus { } /// Set the keyboard LED to enabled while the device is awake - fn set_awake_enabled(&mut self, enabled: bool) { + async fn set_awake_enabled( + &mut self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + enabled: bool, + ) { + let mut states = None; if let Ok(mut ctrl) = self.0.try_lock() { ctrl.set_states_enabled(enabled, ctrl.config.sleep_anim_enabled) .map_err(|err| warn!("{}", err)) @@ -39,52 +48,77 @@ impl CtrlKbdLedZbus { ctrl.config.awake_enabled = enabled; ctrl.config.write(); - let states = LedPowerStates { + states = Some(LedPowerStates { enabled: ctrl.config.awake_enabled, sleep_anim_enabled: ctrl.config.sleep_anim_enabled, - }; - self.notify_power_states(&states) + }); + } + // Need to pull state out like this due to MutexGuard + if let Some(states) = states { + Self::notify_power_states(&ctxt, &states) + .await .unwrap_or_else(|err| warn!("{}", err)); } } /// Set the keyboard LED suspend animation to enabled while the device is suspended - fn set_sleep_enabled(&mut self, enabled: bool) { + async fn set_sleep_enabled( + &mut self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + enabled: bool, + ) { + let mut states = None; if let Ok(mut ctrl) = self.0.try_lock() { ctrl.set_states_enabled(ctrl.config.awake_enabled, enabled) .map_err(|err| warn!("{}", err)) .ok(); ctrl.config.sleep_anim_enabled = enabled; ctrl.config.write(); - let states = LedPowerStates { + states = Some(LedPowerStates { enabled: ctrl.config.awake_enabled, sleep_anim_enabled: ctrl.config.sleep_anim_enabled, - }; - self.notify_power_states(&states) + }); + } + if let Some(states) = states { + Self::notify_power_states(&ctxt, &states) + .await .unwrap_or_else(|err| warn!("{}", err)); } } /// Set the keyboard side LEDs to enabled - fn set_side_leds_enabled(&mut self, enabled: bool) { + async fn set_side_leds_enabled( + &mut self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + enabled: bool, + ) { + let mut led = None; if let Ok(mut ctrl) = self.0.try_lock() { ctrl.set_side_leds_states(enabled) .map_err(|err| warn!("{}", err)) .ok(); ctrl.config.side_leds_enabled = enabled; ctrl.config.write(); - self.notify_side_leds(ctrl.config.side_leds_enabled) - .unwrap_or_else(|err| warn!("{}", err)) + led = Some(enabled); + } + if let Some(led) = led { + Self::notify_side_leds(&ctxt, led) + .await + .unwrap_or_else(|err| warn!("{}", err)); } } - fn set_led_mode(&mut self, effect: AuraEffect) { + async fn set_led_mode( + &mut self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + effect: AuraEffect, + ) { + let mut led = None; if let Ok(mut ctrl) = self.0.try_lock() { match ctrl.do_command(effect) { Ok(_) => { if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) { - self.notify_led(mode.clone()) - .unwrap_or_else(|err| warn!("{}", err)); + led = Some(mode.clone()); } } Err(err) => { @@ -92,40 +126,55 @@ impl CtrlKbdLedZbus { } } } + if let Some(led) = led { + Self::notify_led(&ctxt, led) + .await + .unwrap_or_else(|err| warn!("{}", err)); + } } - fn next_led_mode(&self) { - if let Ok(mut ctrl) = self.0.try_lock() { + async fn next_led_mode(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>) { + let mut led = None; + if let Ok(mut ctrl) = self.0.lock() { ctrl.toggle_mode(false) .unwrap_or_else(|err| warn!("{}", err)); if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) { - self.notify_led(mode.clone()) - .unwrap_or_else(|err| warn!("{}", err)); + led = Some(mode.clone()); } } + if let Some(led) = led { + Self::notify_led(&ctxt, led) + .await + .unwrap_or_else(|err| warn!("{}", err)); + } } - fn prev_led_mode(&self) { - if let Ok(mut ctrl) = self.0.try_lock() { + async fn prev_led_mode(&self, #[zbus(signal_context)] ctxt: SignalContext<'_>) { + let mut led = None; + if let Ok(mut ctrl) = self.0.lock() { ctrl.toggle_mode(true) .unwrap_or_else(|err| warn!("{}", err)); if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) { - self.notify_led(mode.clone()) - .unwrap_or_else(|err| warn!("{}", err)); + led = Some(mode.clone()); } } + if let Some(led) = led { + Self::notify_led(&ctxt, led) + .await + .unwrap_or_else(|err| warn!("{}", err)); + } } - fn next_led_brightness(&self) { + async fn next_led_brightness(&self) { if let Ok(mut ctrl) = self.0.try_lock() { ctrl.next_brightness() .unwrap_or_else(|err| warn!("{}", err)); } } - fn prev_led_brightness(&self) { + async fn prev_led_brightness(&self) { if let Ok(mut ctrl) = self.0.try_lock() { ctrl.prev_brightness() .unwrap_or_else(|err| warn!("{}", err)); @@ -133,7 +182,7 @@ impl CtrlKbdLedZbus { } #[dbus_interface(property)] - fn awake_enabled(&self) -> bool { + async fn awake_enabled(&self) -> bool { if let Ok(ctrl) = self.0.try_lock() { return ctrl.config.awake_enabled; } @@ -141,7 +190,7 @@ impl CtrlKbdLedZbus { } #[dbus_interface(property)] - fn sleep_enabled(&self) -> bool { + async fn sleep_enabled(&self) -> bool { if let Ok(ctrl) = self.0.try_lock() { return ctrl.config.sleep_anim_enabled; } @@ -158,7 +207,7 @@ impl CtrlKbdLedZbus { /// Return the current mode data #[dbus_interface(property)] - fn led_mode(&self) -> String { + async fn led_mode(&self) -> String { if let Ok(ctrl) = self.0.try_lock() { if let Some(mode) = ctrl.config.builtins.get(&ctrl.config.current_mode) { if let Ok(json) = serde_json::to_string(&mode) { @@ -172,7 +221,7 @@ impl CtrlKbdLedZbus { /// Return a list of available modes #[dbus_interface(property)] - fn led_modes(&self) -> String { + async fn led_modes(&self) -> String { if let Ok(ctrl) = self.0.try_lock() { if let Ok(json) = serde_json::to_string(&ctrl.config.builtins) { return json; @@ -184,7 +233,7 @@ impl CtrlKbdLedZbus { /// Return the current LED brightness #[dbus_interface(property)] - fn led_brightness(&self) -> i8 { + async fn led_brightness(&self) -> i8 { if let Ok(ctrl) = self.0.try_lock() { return ctrl.get_brightness().map(|n| n as i8).unwrap_or(-1); } @@ -193,11 +242,14 @@ impl CtrlKbdLedZbus { } #[dbus_interface(signal)] - fn notify_led(&self, data: AuraEffect) -> zbus::Result<()>; + async fn notify_led(signal_ctxt: &SignalContext<'_>, data: AuraEffect) -> zbus::Result<()>; #[dbus_interface(signal)] - fn notify_side_leds(&self, data: bool) -> zbus::Result<()>; + async fn notify_side_leds(signal_ctxt: &SignalContext<'_>, data: bool) -> zbus::Result<()>; #[dbus_interface(signal)] - fn notify_power_states(&self, data: &LedPowerStates) -> zbus::Result<()>; + async fn notify_power_states( + signal_ctxt: &SignalContext<'_>, + data: &LedPowerStates, + ) -> zbus::Result<()>; } diff --git a/daemon/src/ctrl_charge.rs b/daemon/src/ctrl_charge.rs index b266396a..1e1bc020 100644 --- a/daemon/src/ctrl_charge.rs +++ b/daemon/src/ctrl_charge.rs @@ -1,5 +1,5 @@ use crate::{config::Config, error::RogError, GetSupported}; -//use crate::dbus::DbusEvents; +use async_trait::async_trait; use log::{info, warn}; use rog_supported::ChargeSupportedFunctions; use std::fs::OpenOptions; @@ -8,6 +8,8 @@ use std::path::Path; use std::sync::Arc; use std::sync::Mutex; use zbus::dbus_interface; +use zbus::Connection; +use zbus::SignalContext; use zvariant::ObjectPath; static BAT_CHARGE_PATH0: &str = "/sys/class/power_supply/BAT0/charge_control_end_threshold"; @@ -30,9 +32,13 @@ pub struct CtrlCharge { #[dbus_interface(name = "org.asuslinux.Daemon")] impl CtrlCharge { - pub fn set_limit(&mut self, limit: u8) -> Result<(), RogError> { + async fn set_limit( + &mut self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + limit: u8, + ) -> zbus::fdo::Result<()> { if !(20..=100).contains(&limit) { - return Err(RogError::ChargeLimit(limit)); + return Err(RogError::ChargeLimit(limit))?; } if let Ok(mut config) = self.config.try_lock() { self.set(limit, &mut config) @@ -41,17 +47,12 @@ impl CtrlCharge { err }) .ok(); - self.notify_charge(limit) - .map_err(|err| { - warn!("CtrlCharge: set_limit {}", err); - err - }) - .ok(); } + Self::notify_charge(&ctxt, limit).await?; Ok(()) } - pub fn limit(&self) -> i8 { + fn limit(&self) -> i8 { if let Ok(config) = self.config.try_lock() { return config.bat_charge_limit as i8; } @@ -59,16 +60,19 @@ impl CtrlCharge { } #[dbus_interface(signal)] - pub fn notify_charge(&self, limit: u8) -> zbus::Result<()> {} + async fn notify_charge(ctxt: &SignalContext<'_>, limit: u8) -> zbus::Result<()>; } +#[async_trait] impl crate::ZbusAdd for CtrlCharge { - fn add_to_server(self, server: &mut zbus::ObjectServer) { + async fn add_to_server(self, server: &mut Connection) { server + .object_server() .at( &ObjectPath::from_str_unchecked("/org/asuslinux/Charge"), self, ) + .await .map_err(|err| { warn!("CtrlCharge: add_to_server {}", err); err diff --git a/daemon/src/ctrl_profiles/controller.rs b/daemon/src/ctrl_profiles/controller.rs index 18d90c0d..eb96e82a 100644 --- a/daemon/src/ctrl_profiles/controller.rs +++ b/daemon/src/ctrl_profiles/controller.rs @@ -2,6 +2,7 @@ use std::sync::{Arc, Mutex}; use crate::error::RogError; use crate::{CtrlTask, GetSupported}; +use async_trait::async_trait; use log::{info, warn}; use rog_profiles::error::ProfileError; use rog_profiles::{FanCurveProfiles, Profile}; @@ -135,8 +136,9 @@ impl CtrlProfileTask { } } +#[async_trait] impl CtrlTask for CtrlProfileTask { - fn do_task(&self) -> Result<(), RogError> { + async fn do_task(&self) -> Result<(), RogError> { if let Ok(ref mut lock) = self.ctrl.try_lock() { let new_profile = Profile::get_active_profile().unwrap(); if new_profile != lock.config.active_profile { diff --git a/daemon/src/ctrl_profiles/zbus.rs b/daemon/src/ctrl_profiles/zbus.rs index affcaae8..7cfe4eed 100644 --- a/daemon/src/ctrl_profiles/zbus.rs +++ b/daemon/src/ctrl_profiles/zbus.rs @@ -1,13 +1,19 @@ +use async_trait::async_trait; use log::warn; use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::FanCurveSet; use rog_profiles::Profile; +use zbus::Connection; +use zbus::SignalContext; use std::sync::Arc; use std::sync::Mutex; use zbus::{dbus_interface, fdo::Error}; use zvariant::ObjectPath; +use crate::error::RogError; +use crate::CtrlTask; + use super::controller::CtrlPlatformProfile; static UNSUPPORTED_MSG: &str = @@ -161,25 +167,32 @@ impl ProfileZbus { } #[dbus_interface(signal)] - fn notify_profile(&self, profile: &Profile) -> zbus::Result<()> {} + async fn notify_profile( + signal_ctxt: &SignalContext<'_>, + profile: &Profile, + ) -> zbus::Result<()> { + } } impl ProfileZbus { fn do_notification(&self) { - if let Ok(ctrl) = self.inner.try_lock() { - self.notify_profile(&ctrl.config.active_profile) - .unwrap_or_else(|err| warn!("{}", err)); + if let Ok(_ctrl) = self.inner.try_lock() { + // self.notify_profile(&ctrl.config.active_profile) + // .unwrap_or_else(|err| warn!("{}", err)); } } } +#[async_trait] impl crate::ZbusAdd for ProfileZbus { - fn add_to_server(self, server: &mut zbus::ObjectServer) { + async fn add_to_server(self, server: &mut Connection) { server + .object_server() .at( &ObjectPath::from_str_unchecked("/org/asuslinux/Profile"), self, ) + .await .map_err(|err| { warn!("DbusFanAndCpu: add_to_server {}", err); err @@ -187,3 +200,18 @@ impl crate::ZbusAdd for ProfileZbus { .ok(); } } + +#[async_trait] +impl CtrlTask for ProfileZbus { + async fn do_task(&self) -> Result<(), RogError> { + if let Ok(ref mut lock) = self.inner.try_lock() { + let new_profile = Profile::get_active_profile().unwrap(); + if new_profile != lock.config.active_profile { + lock.config.active_profile = new_profile; + lock.write_profile_curve_to_platform()?; + lock.save_config(); + } + } + Ok(()) + } +} diff --git a/daemon/src/ctrl_rog_bios.rs b/daemon/src/ctrl_rog_bios.rs index b95ac5c5..e739b1c5 100644 --- a/daemon/src/ctrl_rog_bios.rs +++ b/daemon/src/ctrl_rog_bios.rs @@ -1,4 +1,5 @@ use crate::{config::Config, error::RogError, GetSupported}; +use async_trait::async_trait; use log::{error, info, warn}; use rog_supported::RogBiosSupportedFunctions; use std::fs::OpenOptions; @@ -8,7 +9,8 @@ use std::path::Path; use std::process::Command; use std::sync::Arc; use std::sync::Mutex; -use zbus::dbus_interface; +use zbus::Connection; +use zbus::{dbus_interface, SignalContext}; use zvariant::ObjectPath; const INITRAMFS_PATH: &str = "/usr/sbin/update-initramfs"; @@ -36,22 +38,23 @@ impl GetSupported for CtrlRogBios { #[dbus_interface(name = "org.asuslinux.Daemon")] impl CtrlRogBios { - pub fn set_dedicated_graphic_mode(&mut self, dedicated: bool) { + async fn set_dedicated_graphic_mode( + &mut self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + dedicated: bool, + ) { self.set_gfx_mode(dedicated) .map_err(|err| { warn!("CtrlRogBios: set_asus_switch_graphic_mode {}", err); err }) .ok(); - self.notify_dedicated_graphic_mode(dedicated) - .map_err(|err| { - warn!("CtrlRogBios: notify_asus_switch_graphic_mode {}", err); - err - }) + Self::notify_dedicated_graphic_mode(&ctxt, dedicated) + .await .ok(); } - pub fn dedicated_graphic_mode(&self) -> i8 { + fn dedicated_graphic_mode(&self) -> i8 { Self::get_gfx_mode() .map_err(|err| { warn!("CtrlRogBios: get_gfx_mode {}", err); @@ -61,24 +64,27 @@ impl CtrlRogBios { } #[dbus_interface(signal)] - pub fn notify_dedicated_graphic_mode(&self, dedicated: bool) -> zbus::Result<()> {} + async fn notify_dedicated_graphic_mode( + signal_ctxt: &SignalContext<'_>, + dedicated: bool, + ) -> zbus::Result<()> { + } - pub fn set_post_boot_sound(&mut self, on: bool) { + async fn set_post_boot_sound( + &mut self, + #[zbus(signal_context)] ctxt: SignalContext<'_>, + on: bool, + ) { Self::set_boot_sound(on) .map_err(|err| { warn!("CtrlRogBios: set_post_boot_sound {}", err); err }) .ok(); - self.notify_post_boot_sound(on) - .map_err(|err| { - warn!("CtrlRogBios: notify_post_boot_sound {}", err); - err - }) - .ok(); + Self::notify_post_boot_sound(&ctxt, on).await.ok(); } - pub fn post_boot_sound(&self) -> i8 { + fn post_boot_sound(&self) -> i8 { Self::get_boot_sound() .map_err(|err| { warn!("CtrlRogBios: get_boot_sound {}", err); @@ -88,16 +94,19 @@ impl CtrlRogBios { } #[dbus_interface(signal)] - pub fn notify_post_boot_sound(&self, dedicated: bool) -> zbus::Result<()> {} + async fn notify_post_boot_sound(ctxt: &SignalContext<'_>, on: bool) -> zbus::Result<()> {} } +#[async_trait] impl crate::ZbusAdd for CtrlRogBios { - fn add_to_server(self, server: &mut zbus::ObjectServer) { + async fn add_to_server(self, server: &mut Connection) { server + .object_server() .at( &ObjectPath::from_str_unchecked("/org/asuslinux/RogBios"), self, ) + .await .map_err(|err| { warn!("CtrlRogBios: add_to_server {}", err); err diff --git a/daemon/src/ctrl_supported.rs b/daemon/src/ctrl_supported.rs index 6c1a04e6..ef339d64 100644 --- a/daemon/src/ctrl_supported.rs +++ b/daemon/src/ctrl_supported.rs @@ -1,8 +1,10 @@ +use async_trait::async_trait; use log::warn; use serde_derive::{Deserialize, Serialize}; use zbus::dbus_interface; +use zbus::Connection; use zvariant::ObjectPath; -use zvariant_derive::Type; +use zvariant::Type; use crate::{ ctrl_anime::CtrlAnime, ctrl_aura::controller::CtrlKbdLed, ctrl_charge::CtrlCharge, @@ -30,13 +32,16 @@ impl SupportedFunctions { } } +#[async_trait] impl crate::ZbusAdd for SupportedFunctions { - fn add_to_server(self, server: &mut zbus::ObjectServer) { + async fn add_to_server(self, server: &mut Connection) { server + .object_server() .at( &ObjectPath::from_str_unchecked("/org/asuslinux/Supported"), self, ) + .await .map_err(|err| { warn!("SupportedFunctions: add_to_server {}", err); err diff --git a/daemon/src/daemon.rs b/daemon/src/daemon.rs index 156a6171..08ea19c6 100644 --- a/daemon/src/daemon.rs +++ b/daemon/src/daemon.rs @@ -1,12 +1,11 @@ +use std::env; use std::error::Error; use std::io::Write; -use std::sync::Arc; -use std::sync::Mutex; -use std::thread::sleep; +use std::sync::{Arc, Mutex}; use std::time::Duration; -use std::{env, thread}; -use ::zbus::{fdo, Connection, ObjectServer}; +use ::zbus::Connection; +use futures::executor::ThreadPool; use log::LevelFilter; use log::{error, info, warn}; @@ -19,9 +18,7 @@ use daemon::ctrl_aura::controller::{ }; use daemon::ctrl_charge::CtrlCharge; use daemon::ctrl_profiles::config::ProfileConfig; -use daemon::ctrl_profiles::controller::CtrlProfileTask; use daemon::ctrl_rog_bios::CtrlRogBios; -use daemon::error::RogError; use daemon::{ config::Config, ctrl_supported::SupportedFunctions, laptops::print_board_info, GetSupported, }; @@ -64,25 +61,25 @@ pub fn main() -> Result<(), Box> { info!(" rog-profiles v{}", rog_profiles::VERSION); info!("rog-supported v{}", rog_supported::VERSION); - start_daemon()?; + let mut pool = ThreadPool::new()?; + + futures::executor::block_on(start_daemon(&mut pool))?; Ok(()) } /// The actual main loop for the daemon -fn start_daemon() -> Result<(), Box> { +async fn start_daemon(thread_pool: &mut ThreadPool) -> Result<(), Box> { let supported = SupportedFunctions::get_supported(); print_board_info(); println!("{}", serde_json::to_string_pretty(&supported)?); // Start zbus server - let connection = Connection::new_system()?; - let fdo_connection = fdo::DBusProxy::new(&connection)?; - let mut object_server = ObjectServer::new(&connection); + let mut connection = Connection::system().await?; let config = Config::load(); let config = Arc::new(Mutex::new(config)); - supported.add_to_server(&mut object_server); + supported.add_to_server(&mut connection).await; match CtrlRogBios::new(config.clone()) { Ok(mut ctrl) => { @@ -90,7 +87,7 @@ fn start_daemon() -> Result<(), Box> { ctrl.reload() .unwrap_or_else(|err| warn!("Battery charge limit: {}", err)); // Then register to dbus server - ctrl.add_to_server(&mut object_server); + ctrl.add_to_server(&mut connection).await; } Err(err) => { error!("rog_bios_control: {}", err); @@ -103,7 +100,7 @@ fn start_daemon() -> Result<(), Box> { ctrl.reload() .unwrap_or_else(|err| warn!("Battery charge limit: {}", err)); // Then register to dbus server - ctrl.add_to_server(&mut object_server); + ctrl.add_to_server(&mut connection).await; } Err(err) => { error!("charge_control: {}", err); @@ -118,17 +115,9 @@ fn start_daemon() -> Result<(), Box> { .unwrap_or_else(|err| warn!("Profile control: {}", err)); let tmp = Arc::new(Mutex::new(ctrl)); - ProfileZbus::new(tmp.clone()).add_to_server(&mut object_server); - - let task = CtrlProfileTask::new(tmp); - thread::Builder::new().name("profile tasks".into()).spawn( - move || -> Result<(), RogError> { - loop { - task.do_task()?; - sleep(Duration::from_millis(100)); - } - }, - )?; + ProfileZbus::new(tmp.clone()) + .add_to_server(&mut connection) + .await; } Err(err) => { error!("Profile control: {}", err); @@ -148,16 +137,12 @@ fn start_daemon() -> Result<(), Box> { .unwrap_or_else(|err| warn!("AniMe: {}", err)); let zbus = CtrlAnimeZbus(inner.clone()); - zbus.add_to_server(&mut object_server); + zbus.add_to_server(&mut connection).await; let task = CtrlAnimeTask::new(inner); - thread::Builder::new().name("anime tasks".into()).spawn( - move || -> Result<(), RogError> { - loop { - task.do_task()?; - } - }, - )?; + thread_pool.spawn_ok(async move { + task.do_task().await.ok(); + }); } Err(err) => { error!("AniMe control: {}", err); @@ -175,16 +160,14 @@ fn start_daemon() -> Result<(), Box> { .reload() .unwrap_or_else(|err| warn!("Keyboard LED control: {}", err)); - CtrlKbdLedZbus::new(inner.clone()).add_to_server(&mut object_server); + CtrlKbdLedZbus::new(inner.clone()) + .add_to_server(&mut connection) + .await; let task = CtrlKbdLedTask::new(inner); - thread::Builder::new().name("keyboard tasks".into()).spawn( - move || -> Result<(), RogError> { - loop { - task.do_task()?; - } - }, - )?; + thread_pool.spawn_ok(async move { + task.do_task().await.ok(); + }); } Err(err) => { error!("Keyboard control: {}", err); @@ -192,12 +175,11 @@ fn start_daemon() -> Result<(), Box> { } // Request dbus name after finishing initalizing all functions - fdo_connection.request_name(DBUS_NAME, fdo::RequestNameFlags::ReplaceExisting.into())?; + connection.request_name(DBUS_NAME).await?; // Loop to check errors and iterate zbus server loop { - if let Err(err) = object_server.try_handle_next() { - error!("{}", err); - } + // Nothing to do here really + std::thread::sleep(Duration::from_millis(1)); } } diff --git a/daemon/src/lib.rs b/daemon/src/lib.rs index 3ba9a8de..6311b03d 100644 --- a/daemon/src/lib.rs +++ b/daemon/src/lib.rs @@ -30,8 +30,9 @@ pub mod ctrl_supported; pub mod error; use crate::error::RogError; +use async_trait::async_trait; use config::Config; -use zbus::ObjectServer; +use zbus::Connection; pub static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -39,12 +40,14 @@ pub trait Reloadable { fn reload(&mut self) -> Result<(), RogError>; } +#[async_trait] pub trait ZbusAdd { - fn add_to_server(self, server: &mut ObjectServer); + async fn add_to_server(self, server: &mut Connection); } +#[async_trait] pub trait CtrlTask { - fn do_task(&self) -> Result<(), RogError>; + async fn do_task(&self) -> Result<(), RogError>; } pub trait CtrlTaskComplex { diff --git a/rog-anime/Cargo.toml b/rog-anime/Cargo.toml index 1962f26a..51357fb0 100644 --- a/rog-anime/Cargo.toml +++ b/rog-anime/Cargo.toml @@ -14,7 +14,7 @@ exclude = ["data"] [features] default = ["dbus"] -dbus = ["zvariant", "zvariant_derive"] +dbus = ["zvariant"] [dependencies] png_pong = "^0.8.0" @@ -26,5 +26,5 @@ serde_derive = "^1.0" glam = { version = "0.14.0", features = ["serde"] } -zvariant = { version = "^2.6", optional = true } -zvariant_derive = { version = "^2.6", optional = true } +zvariant = { version = "^3.0", optional = true } +#zvariant_derive = { version = "^3.0", optional = true } diff --git a/rog-anime/src/data.rs b/rog-anime/src/data.rs index 991115da..9c068d7d 100644 --- a/rog-anime/src/data.rs +++ b/rog-anime/src/data.rs @@ -9,7 +9,7 @@ use std::{ use serde_derive::{Deserialize, Serialize}; #[cfg(feature = "dbus")] -use zvariant_derive::Type; +use zvariant::Type; use crate::{error::AnimeError, AnimTime, AnimeGif}; @@ -27,7 +27,6 @@ const USB_PREFIX2: [u8; 7] = [0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02]; #[cfg_attr(feature = "dbus", derive(Type))] #[derive(Debug, PartialEq, Copy, Clone, Deserialize, Serialize)] - pub struct AnimePowerStates { pub enabled: bool, pub boot_anim_enabled: bool, diff --git a/rog-aura/Cargo.toml b/rog-aura/Cargo.toml index 051af929..315a6e47 100644 --- a/rog-aura/Cargo.toml +++ b/rog-aura/Cargo.toml @@ -14,11 +14,10 @@ exclude = ["data"] [features] default = ["dbus"] -dbus = ["zvariant", "zvariant_derive"] +dbus = ["zvariant"] [dependencies] serde = "^1.0" serde_derive = "^1.0" -zvariant = { version = "^2.6", optional = true } -zvariant_derive = { version = "^2.6", optional = true } +zvariant = { version = "^3.0", optional = true } diff --git a/rog-aura/src/builtin_modes.rs b/rog-aura/src/builtin_modes.rs index 1a578d35..eb3afb70 100644 --- a/rog-aura/src/builtin_modes.rs +++ b/rog-aura/src/builtin_modes.rs @@ -7,7 +7,7 @@ pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08]; use serde_derive::{Deserialize, Serialize}; use std::str::FromStr; #[cfg(feature = "dbus")] -use zvariant_derive::Type; +use zvariant::Type; use crate::{error::Error, LED_MSG_LEN}; diff --git a/rog-dbus/Cargo.toml b/rog-dbus/Cargo.toml index 8b76e2dd..bf628961 100644 --- a/rog-dbus/Cargo.toml +++ b/rog-dbus/Cargo.toml @@ -14,6 +14,6 @@ rog_anime = { path = "../rog-anime" } rog_aura = { path = "../rog-aura" } rog_profiles = { path = "../rog-profiles" } rog_supported = { path = "../rog-supported" } -zbus = "^1.9" -zbus_macros = "^1.9" -zvariant = "^2.8" +zbus = "^2.0" +zbus_macros = "^2.0" +zvariant = "^3.0" diff --git a/rog-dbus/src/lib.rs b/rog-dbus/src/lib.rs index 48aa54f2..d858ea86 100644 --- a/rog-dbus/src/lib.rs +++ b/rog-dbus/src/lib.rs @@ -9,51 +9,109 @@ pub mod zbus_profile; pub mod zbus_rogbios; pub mod zbus_supported; -use rog_anime::AnimePowerStates; -use rog_aura::{AuraEffect, LedPowerStates}; -use rog_profiles::Profile; -use std::sync::mpsc::{channel, Receiver}; -use zbus::{Connection, Result, SignalReceiver}; +// use rog_anime::AnimePowerStates; +// use rog_aura::{AuraEffect, LedPowerStates}; +// use rog_profiles::Profile; +// use std::sync::mpsc::{channel, Receiver}; +use zbus::{blocking, Connection, Result}; pub static VERSION: &str = env!("CARGO_PKG_VERSION"); +pub struct DbusProxiesBlocking<'a> { + anime: zbus_anime::AnimeProxyBlocking<'a>, + charge: zbus_charge::ChargeProxyBlocking<'a>, + led: zbus_led::LedProxyBlocking<'a>, + profile: zbus_profile::ProfileProxyBlocking<'a>, + rog_bios: zbus_rogbios::RogBiosProxyBlocking<'a>, + supported: zbus_supported::SupportedProxyBlocking<'a>, +} + +impl<'a> DbusProxiesBlocking<'a> { + #[inline] + pub fn new() -> Result<(Self, blocking::Connection)> { + let conn = blocking::Connection::system()?; + + Ok(( + DbusProxiesBlocking { + anime: zbus_anime::AnimeProxyBlocking::new(&conn)?, + led: zbus_led::LedProxyBlocking::new(&conn)?, + charge: zbus_charge::ChargeProxyBlocking::new(&conn)?, + profile: zbus_profile::ProfileProxyBlocking::new(&conn)?, + rog_bios: zbus_rogbios::RogBiosProxyBlocking::new(&conn)?, + supported: zbus_supported::SupportedProxyBlocking::new(&conn)?, + }, + conn, + )) + } + + pub fn anime(&self) -> &zbus_anime::AnimeProxyBlocking<'a> { + &self.anime + } + + pub fn charge(&self) -> &zbus_charge::ChargeProxyBlocking<'a> { + &self.charge + } + + pub fn led(&self) -> &zbus_led::LedProxyBlocking<'a> { + &self.led + } + + pub fn profile(&self) -> &zbus_profile::ProfileProxyBlocking<'a> { + &self.profile + } + + pub fn rog_bios(&self) -> &zbus_rogbios::RogBiosProxyBlocking<'a> { + &self.rog_bios + } + + pub fn supported(&self) -> &zbus_supported::SupportedProxyBlocking<'a> { + &self.supported + } +} + +/// This is the main way to communicate with the DBUS interface +pub struct RogDbusClientBlocking<'a> { + proxies: DbusProxiesBlocking<'a>, +} + +impl<'a> RogDbusClientBlocking<'a> { + #[inline] + pub fn new() -> Result<(Self, blocking::Connection)> { + let (proxies, conn) = DbusProxiesBlocking::new()?; + Ok((RogDbusClientBlocking { proxies }, conn)) + } + + pub fn proxies(&self) -> &DbusProxiesBlocking { + &self.proxies + } +} + pub struct DbusProxies<'a> { anime: zbus_anime::AnimeProxy<'a>, charge: zbus_charge::ChargeProxy<'a>, led: zbus_led::LedProxy<'a>, profile: zbus_profile::ProfileProxy<'a>, rog_bios: zbus_rogbios::RogBiosProxy<'a>, - supported: zbus_supported::SupportProxy<'a>, + supported: zbus_supported::SupportedProxy<'a>, } impl<'a> DbusProxies<'a> { #[inline] - pub fn new() -> Result<(Self, Connection)> { - let conn = Connection::new_system()?; + pub async fn new() -> Result<(DbusProxies<'a>, Connection)> { + let conn = Connection::system().await?; Ok(( DbusProxies { - anime: zbus_anime::AnimeProxy::new(&conn)?, - led: zbus_led::LedProxy::new(&conn)?, - charge: zbus_charge::ChargeProxy::new(&conn)?, - profile: zbus_profile::ProfileProxy::new(&conn)?, - rog_bios: zbus_rogbios::RogBiosProxy::new(&conn)?, - supported: zbus_supported::SupportProxy::new(&conn)?, + anime: zbus_anime::AnimeProxy::new(&conn).await?, + led: zbus_led::LedProxy::new(&conn).await?, + charge: zbus_charge::ChargeProxy::new(&conn).await?, + profile: zbus_profile::ProfileProxy::new(&conn).await?, + rog_bios: zbus_rogbios::RogBiosProxy::new(&conn).await?, + supported: zbus_supported::SupportedProxy::new(&conn).await?, }, conn, )) } - pub fn setup_recv(&'a self, conn: Connection) -> SignalReceiver<'a, 'a> { - let mut recv = SignalReceiver::new(conn); - recv.receive_for(self.anime.proxy()); - recv.receive_for(self.led.proxy()); - recv.receive_for(self.charge.proxy()); - recv.receive_for(self.profile.proxy()); - recv.receive_for(self.rog_bios.proxy()); - recv.receive_for(self.supported.proxy()); - recv - } - pub fn anime(&self) -> &zbus_anime::AnimeProxy<'a> { &self.anime } @@ -74,102 +132,24 @@ impl<'a> DbusProxies<'a> { &self.rog_bios } - pub fn supported(&self) -> &zbus_supported::SupportProxy<'a> { + pub fn supported(&self) -> &zbus_supported::SupportedProxy<'a> { &self.supported } } -// Signals separated out -pub struct Signals { - pub profile: Receiver, - pub led_mode: Receiver, - pub side_leds: Receiver, - pub led_power_state: Receiver, - pub anime_power_state: Receiver, - pub charge: Receiver, - pub bios_gsync: Receiver, - pub bios_sound: Receiver, -} - -impl Signals { - #[inline] - pub fn new(proxies: &DbusProxies) -> Result { - Ok(Signals { - profile: { - let (tx, rx) = channel(); - proxies.profile.connect_notify_profile(tx)?; - rx - }, - charge: { - let (tx, rx) = channel(); - proxies.charge.connect_notify_charge(tx)?; - rx - }, - led_mode: { - let (tx, rx) = channel(); - proxies.led.connect_notify_led(tx)?; - rx - }, - side_leds: { - let (tx, rx) = channel(); - proxies.led.connect_notify_side_leds(tx)?; - rx - }, - led_power_state: { - let (tx, rx) = channel(); - proxies.led.connect_notify_power_states(tx)?; - rx - }, - anime_power_state: { - let (tx, rx) = channel(); - proxies.anime.connect_notify_power_states(tx)?; - rx - }, - bios_gsync: { - let (tx, rx) = channel(); - proxies.rog_bios.connect_notify_dedicated_graphic_mode(tx)?; - rx - }, - bios_sound: { - let (tx, rx) = channel(); - proxies.rog_bios.connect_notify_post_boot_sound(tx)?; - rx - }, - }) - } -} - /// This is the main way to communicate with the DBUS interface pub struct RogDbusClient<'a> { proxies: DbusProxies<'a>, - signals: Signals, } impl<'a> RogDbusClient<'a> { #[inline] - pub fn new() -> Result<(Self, Connection)> { - let (proxies, conn) = DbusProxies::new()?; - let signals = Signals::new(&proxies)?; - - Ok((RogDbusClient { proxies, signals }, conn)) + pub async fn new() -> Result<(RogDbusClient<'a>, Connection)> { + let (proxies, conn) = DbusProxies::new().await?; + Ok((RogDbusClient { proxies }, conn)) } pub fn proxies(&self) -> &DbusProxies { &self.proxies } - - pub fn signals(&self) -> &Signals { - &self.signals - } - - pub fn setup_recv(&'a self, conn: Connection) -> SignalReceiver<'a, 'a> { - let mut recv = SignalReceiver::new(conn); - recv.receive_for(self.proxies.anime.proxy()); - recv.receive_for(self.proxies.led.proxy()); - recv.receive_for(self.proxies.charge.proxy()); - recv.receive_for(self.proxies.profile.proxy()); - recv.receive_for(self.proxies.rog_bios.proxy()); - recv.receive_for(self.proxies.supported.proxy()); - recv - } } diff --git a/rog-dbus/src/zbus_anime.rs b/rog-dbus/src/zbus_anime.rs index da681ca5..6d4ec238 100644 --- a/rog-dbus/src/zbus_anime.rs +++ b/rog-dbus/src/zbus_anime.rs @@ -1,12 +1,11 @@ use rog_anime::{AnimeDataBuffer, AnimePowerStates}; -use std::sync::mpsc::Sender; -use zbus::{dbus_proxy, Connection, Result}; +use zbus_macros::dbus_proxy; #[dbus_proxy( interface = "org.asuslinux.Daemon", default_path = "/org/asuslinux/Anime" )] -trait Daemon { +trait Anime { /// Set whether the AniMe will show boot, suspend, or off animations fn set_boot_on_off(&self, status: bool) -> zbus::Result<()>; @@ -17,7 +16,7 @@ trait Daemon { fn set_on_off(&self, status: bool) -> zbus::Result<()>; /// Writes a data stream of length. Will force system thread to exit until it is restarted - fn write(&self, input: &[u8]) -> zbus::Result<()>; + fn write(&self, input: AnimeDataBuffer) -> zbus::Result<()>; /// Get status of if the AniMe LEDs are on #[dbus_proxy(property)] @@ -29,66 +28,5 @@ trait Daemon { /// Notify listeners of the status of AniMe LED power and factory system-status animations #[dbus_proxy(signal)] - fn notify_power_states(&self, data: AnimePowerStates) -> zbus::Result<()>; -} - -pub struct AnimeProxy<'a>(DaemonProxy<'a>); - -impl<'a> AnimeProxy<'a> { - #[inline] - pub fn new(conn: &Connection) -> Result { - Ok(AnimeProxy(DaemonProxy::new(conn)?)) - } - - #[inline] - pub fn proxy(&self) -> &DaemonProxy<'a> { - &self.0 - } - - /// Set whether the AniMe is displaying images/data - #[inline] - pub fn set_on_off(&self, on: bool) -> Result<()> { - self.0.set_on_off(on) - } - - /// Set the global AniMe brightness - pub fn set_brightness(&self, bright: f32) -> Result<()> { - self.0.set_brightness(bright) - } - - /// Set whether the AniMe will show boot, suspend, or off animations - #[inline] - pub fn set_boot_on_off(&self, on: bool) -> Result<()> { - self.0.set_boot_on_off(on) - } - - /// Writes a data stream of length. Will force system thread to exit until it is restarted - #[inline] - pub fn write(&self, input: AnimeDataBuffer) -> Result<()> { - self.0.write(input.get()) - } - - /// Get status of if the AniMe LEDs are on - #[inline] - pub fn awake_enabled(&self) -> Result { - self.0.awake_enabled() - } - - /// Get the status of if factory system-status animations are enabled - #[inline] - pub fn boot_enabled(&self) -> Result { - self.0.boot_enabled() - } - - #[inline] - pub fn connect_notify_power_states( - &self, - send: Sender, - ) -> zbus::fdo::Result<()> { - self.0.connect_notify_power_states(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } + fn power_states(&self, data: AnimePowerStates) -> zbus::Result<()>; } diff --git a/rog-dbus/src/zbus_charge.rs b/rog-dbus/src/zbus_charge.rs index 9a0ce373..eba1c1d2 100644 --- a/rog-dbus/src/zbus_charge.rs +++ b/rog-dbus/src/zbus_charge.rs @@ -19,15 +19,13 @@ //! //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. -use std::sync::mpsc::Sender; - -use zbus::{dbus_proxy, Connection, Result}; +use zbus_macros::dbus_proxy; #[dbus_proxy( interface = "org.asuslinux.Daemon", default_path = "/org/asuslinux/Charge" )] -trait Daemon { +trait Charge { /// Limit method fn limit(&self) -> zbus::Result; @@ -36,38 +34,5 @@ trait Daemon { /// NotifyCharge signal #[dbus_proxy(signal)] - fn notify_charge(&self, limit: u8) -> zbus::Result<()>; -} - -pub struct ChargeProxy<'a>(DaemonProxy<'a>); - -impl<'a> ChargeProxy<'a> { - #[inline] - pub fn new(conn: &Connection) -> Result { - Ok(ChargeProxy(DaemonProxy::new(conn)?)) - } - - #[inline] - pub fn proxy(&self) -> &DaemonProxy<'a> { - &self.0 - } - - #[inline] - pub fn write_limit(&self, level: u8) -> Result<()> { - self.0.set_limit(level) - } - - #[inline] - pub fn get_limit(&self) -> Result { - self.0.limit() - } - - #[inline] - pub fn connect_notify_charge(&self, send: Sender) -> zbus::fdo::Result<()> { - self.0.connect_notify_charge(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } + fn notify_charge(&self, limit: u8) -> zbus::Result; } diff --git a/rog-dbus/src/zbus_led.rs b/rog-dbus/src/zbus_led.rs index a01547d6..e79bacb6 100644 --- a/rog-dbus/src/zbus_led.rs +++ b/rog-dbus/src/zbus_led.rs @@ -19,9 +19,8 @@ //! //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. -use std::sync::mpsc::Sender; - -use zbus::{dbus_proxy, Connection, Result}; +use zbus::{blocking::Connection, Result}; +use zbus_macros::dbus_proxy; use rog_aura::{AuraEffect, KeyColourArray, LedBrightness, LedPowerStates}; @@ -31,7 +30,7 @@ const BLOCKING_TIME: u64 = 40; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 F interface = "org.asuslinux.Daemon", default_path = "/org/asuslinux/Led" )] -trait Daemon { +trait Led { /// NextLedMode method fn next_led_mode(&self) -> zbus::Result<()>; @@ -91,91 +90,19 @@ trait Daemon { fn side_leds_enabled(&self) -> zbus::Result; } -pub struct LedProxy<'a>(DaemonProxy<'a>); +pub struct LedProxyPerkey<'a>(LedProxyBlocking<'a>); -impl<'a> LedProxy<'a> { +impl<'a> LedProxyPerkey<'a> { #[inline] pub fn new(conn: &Connection) -> Result { - Ok(LedProxy(DaemonProxy::new(conn)?)) + Ok(LedProxyPerkey(LedProxyBlocking::new(conn)?)) } #[inline] - pub fn proxy(&self) -> &DaemonProxy<'a> { + pub fn proxy(&self) -> &LedProxyBlocking<'a> { &self.0 } - #[inline] - pub fn get_led_brightness(&self) -> Result { - self.0.led_brightness() - } - - #[inline] - pub fn set_led_brightness(&self, level: LedBrightness) -> Result<()> { - self.0.set_brightness(level)?; - Ok(()) - } - - /// Set the keyboard LED to enabled while the device is awake - #[inline] - pub fn set_awake_enabled(&self, enabled: bool) -> Result<()> { - self.0.set_awake_enabled(enabled)?; - Ok(()) - } - - /// Set the keyboard LED suspend animation to enabled while the device is suspended - #[inline] - pub fn set_sleep_enabled(&self, enabled: bool) -> Result<()> { - self.0.set_sleep_enabled(enabled)?; - Ok(()) - } - - /// Set the keyboard side LEDs to enabled - #[inline] - pub fn set_side_leds_enabled(&self, enabled: bool) -> Result<()> { - self.0.set_side_leds_enabled(enabled)?; - Ok(()) - } - - #[inline] - pub fn next_led_mode(&self) -> Result<()> { - self.0.next_led_mode() - } - - #[inline] - pub fn prev_led_mode(&self) -> Result<()> { - self.0.prev_led_mode() - } - - #[inline] - pub fn next_led_brightness(&self) -> Result<()> { - self.0.next_led_brightness() - } - - #[inline] - pub fn prev_led_brightness(&self) -> Result<()> { - self.0.prev_led_brightness() - } - - #[inline] - pub fn set_led_mode(&self, mode: &AuraEffect) -> Result<()> { - self.0.set_led_mode(mode) - } - - #[inline] - pub fn awake_enabled(&self) -> Result { - self.0.awake_enabled() - } - - #[inline] - pub fn sleep_enabled(&self) -> Result { - self.0.sleep_enabled() - } - - #[inline] - pub fn side_leds_enabled(&self) -> Result { - self.0.side_leds_enabled() - } - /// Write a single colour block. /// /// Intentionally blocks for 10ms after sending to allow the block to @@ -207,34 +134,4 @@ impl<'a> LedProxy<'a> { // self.0.set_led_mode(&serde_json::to_string(&mode).unwrap()) Ok(()) } - - #[inline] - pub fn connect_notify_led(&self, send: Sender) -> zbus::fdo::Result<()> { - self.0.connect_notify_led(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } - - #[inline] - pub fn connect_notify_side_leds(&self, send: Sender) -> zbus::fdo::Result<()> { - self.0.connect_notify_side_leds(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } - - #[inline] - pub fn connect_notify_power_states( - &self, - send: Sender, - ) -> zbus::fdo::Result<()> { - self.0.connect_notify_power_states(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } } diff --git a/rog-dbus/src/zbus_profile.rs b/rog-dbus/src/zbus_profile.rs index 3842c47c..613592b3 100644 --- a/rog-dbus/src/zbus_profile.rs +++ b/rog-dbus/src/zbus_profile.rs @@ -19,19 +19,17 @@ //! //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. -use std::sync::mpsc::Sender; - use rog_profiles::{ fan_curve_set::{CurveData, FanCurveSet}, Profile, }; -use zbus::{dbus_proxy, Connection, Result}; +use zbus_macros::dbus_proxy; #[dbus_proxy( interface = "org.asuslinux.Daemon", default_path = "/org/asuslinux/Profile" )] -trait Daemon { +trait Profile { /// Get the fan-curve data for the currently active Profile fn fan_curve_data(&self, profile: Profile) -> zbus::Result; @@ -66,73 +64,5 @@ trait Daemon { /// NotifyProfile signal #[dbus_proxy(signal)] - fn notify_profile(&self, profile: Profile) -> zbus::Result<()>; -} - -pub struct ProfileProxy<'a>(DaemonProxy<'a>); - -impl<'a> ProfileProxy<'a> { - #[inline] - pub fn new(conn: &Connection) -> Result { - Ok(ProfileProxy(DaemonProxy::new(conn)?)) - } - - #[inline] - pub fn proxy(&self) -> &DaemonProxy<'a> { - &self.0 - } - - #[inline] - pub fn active_profile(&self) -> zbus::Result { - self.0.active_profile() - } - - #[inline] - pub fn enabled_fan_profiles(&self) -> zbus::Result> { - self.0.enabled_fan_profiles() - } - - #[inline] - pub fn fan_curve_data(&self, profile: Profile) -> zbus::Result { - self.0.fan_curve_data(profile) - } - - #[inline] - pub fn next_profile(&self) -> Result<()> { - self.0.next_profile() - } - - #[inline] - pub fn profiles(&self) -> Result> { - self.0.profiles() - } - - #[inline] - pub fn set_active_profile(&self, profile: Profile) -> zbus::Result<()> { - self.0.set_active_profile(profile) - } - - #[inline] - pub fn set_fan_curve_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()> { - self.0.set_fan_curve_enabled(profile, enabled) - } - - #[inline] - pub fn set_fan_curve(&self, curve: CurveData, profile: Profile) -> zbus::Result<()> { - self.0.set_fan_curve(profile, curve) - } - - #[inline] - pub fn set_active_curve_to_defaults(&self) -> zbus::Result<()> { - self.0.set_active_curve_to_defaults() - } - - #[inline] - pub fn connect_notify_profile(&self, send: Sender) -> zbus::fdo::Result<()> { - self.0.connect_notify_profile(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } + fn notify_profile(&self, profile: Profile) -> zbus::Result; } diff --git a/rog-dbus/src/zbus_rogbios.rs b/rog-dbus/src/zbus_rogbios.rs index d785e180..437a1766 100644 --- a/rog-dbus/src/zbus_rogbios.rs +++ b/rog-dbus/src/zbus_rogbios.rs @@ -19,15 +19,13 @@ //! //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. -use std::sync::mpsc::Sender; - -use zbus::{dbus_proxy, Connection, Result}; +use zbus_macros::dbus_proxy; #[dbus_proxy( interface = "org.asuslinux.Daemon", default_path = "/org/asuslinux/RogBios" )] -trait Daemon { +trait RogBios { /// DedicatedGraphicMode method fn dedicated_graphic_mode(&self) -> zbus::Result; @@ -46,60 +44,5 @@ trait Daemon { /// NotifyPostBootSound signal #[dbus_proxy(signal)] - fn notify_post_boot_sound(&self, dedicated: bool) -> zbus::Result<()>; -} - -pub struct RogBiosProxy<'a>(DaemonProxy<'a>); - -impl<'a> RogBiosProxy<'a> { - #[inline] - pub fn new(conn: &Connection) -> Result { - Ok(RogBiosProxy(DaemonProxy::new(conn)?)) - } - - #[inline] - pub fn proxy(&self) -> &DaemonProxy<'a> { - &self.0 - } - - #[inline] - pub fn get_dedicated_gfx(&self) -> Result { - self.0.dedicated_graphic_mode() - } - - #[inline] - pub fn set_dedicated_gfx(&self, on: bool) -> Result<()> { - self.0.set_dedicated_graphic_mode(on) - } - - #[inline] - pub fn get_post_sound(&self) -> Result { - self.0.post_boot_sound() - } - - #[inline] - pub fn set_post_sound(&self, on: bool) -> Result<()> { - self.0.set_post_boot_sound(on) - } - - #[inline] - pub fn connect_notify_dedicated_graphic_mode( - &self, - send: Sender, - ) -> zbus::fdo::Result<()> { - self.0.connect_notify_dedicated_graphic_mode(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } - - #[inline] - pub fn connect_notify_post_boot_sound(&self, send: Sender) -> zbus::fdo::Result<()> { - self.0.connect_notify_post_boot_sound(move |data| { - send.send(data) - .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; - Ok(()) - }) - } + fn notify_post_boot_sound(&self, sound: bool) -> zbus::Result<()>; } diff --git a/rog-dbus/src/zbus_supported.rs b/rog-dbus/src/zbus_supported.rs index 54c06fb8..3426a493 100644 --- a/rog-dbus/src/zbus_supported.rs +++ b/rog-dbus/src/zbus_supported.rs @@ -20,32 +20,13 @@ //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. use rog_supported::SupportedFunctions; -use zbus::{dbus_proxy, Connection, Result}; +use zbus_macros::dbus_proxy; #[dbus_proxy( interface = "org.asuslinux.Daemon", default_path = "/org/asuslinux/Supported" )] -trait Daemon { +trait Supported { /// SupportedFunctions method fn supported_functions(&self) -> zbus::Result; } - -pub struct SupportProxy<'a>(DaemonProxy<'a>); - -impl<'a> SupportProxy<'a> { - #[inline] - pub fn new(conn: &Connection) -> Result { - Ok(SupportProxy(DaemonProxy::new(conn)?)) - } - - #[inline] - pub fn proxy(&self) -> &DaemonProxy<'a> { - &self.0 - } - - #[inline] - pub fn get_supported_functions(&self) -> Result { - self.0.supported_functions() - } -} diff --git a/rog-profiles/Cargo.toml b/rog-profiles/Cargo.toml index 1091ebf8..d26f2d2d 100644 --- a/rog-profiles/Cargo.toml +++ b/rog-profiles/Cargo.toml @@ -13,5 +13,5 @@ udev = "^0.6" serde = "^1.0" serde_derive = "^1.0" -zvariant = { version = "^2.6", optional = true } -zvariant_derive = { version = "^2.6", optional = true } \ No newline at end of file +zvariant = { version = "^3.0", optional = true } +zvariant_derive = { version = "^3.0", optional = true } \ No newline at end of file diff --git a/rog-supported/Cargo.toml b/rog-supported/Cargo.toml index 461bc729..dba59c44 100644 --- a/rog-supported/Cargo.toml +++ b/rog-supported/Cargo.toml @@ -13,5 +13,5 @@ edition = "2018" rog_aura = { path = "../rog-aura" } serde = "^1.0" serde_derive = "^1.0" -zvariant = "^2.6" -zvariant_derive = "^2.6" \ No newline at end of file +zvariant = "^3.0" +zvariant_derive = "^3.0" \ No newline at end of file