diff --git a/Cargo.lock b/Cargo.lock index 4198326..9af2ce5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,7 +267,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -524,7 +524,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -553,13 +553,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -628,9 +628,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "av1-grain" @@ -709,7 +709,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -816,9 +816,11 @@ dependencies = [ [[package]] name = "bluez-zbus" version = "0.1.0" -source = "git+https://github.com/pop-os/dbus-settings-bindings#8059e6bdaa35fecd70d228a999ca342fb00d313b" +source = "git+https://github.com/pop-os/dbus-settings-bindings#931f5db558bf3fcb572ff4e18f7f1618a7430046" dependencies = [ - "futures", + "futures-channel", + "futures-util", + "tracing", "zbus 4.4.0", ] @@ -842,7 +844,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "syn_derive", ] @@ -914,7 +916,7 @@ checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -999,9 +1001,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.21" +version = "1.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "3bbb537bb4a30b90362caddba8f360c0a56bc13d3a5570028e7197204cb54a17" dependencies = [ "jobserver", "libc", @@ -1119,7 +1121,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1455,7 +1457,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -1477,7 +1479,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "quote", "syn 1.0.109", @@ -1486,7 +1488,7 @@ dependencies = [ [[package]] name = "cosmic-dbus-networkmanager" version = "0.1.0" -source = "git+https://github.com/pop-os/dbus-settings-bindings#8059e6bdaa35fecd70d228a999ca342fb00d313b" +source = "git+https://github.com/pop-os/dbus-settings-bindings#931f5db558bf3fcb572ff4e18f7f1618a7430046" dependencies = [ "bitflags 2.6.0", "derive_builder", @@ -1500,7 +1502,7 @@ dependencies = [ [[package]] name = "cosmic-panel-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-panel#4fedcbfc3574600b58de6da6c2401c92264537bd" +source = "git+https://github.com/pop-os/cosmic-panel#0ce85da198f02f94ad75441e64c0e165c41eb4ae" dependencies = [ "anyhow", "cosmic-config", @@ -1610,7 +1612,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "udev 0.9.0", + "udev", "upower_dbus", "url", "xkb-data", @@ -1620,7 +1622,7 @@ dependencies = [ [[package]] name = "cosmic-settings-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-settings-daemon#a41d1991fdfdac58f0b788e43087ad6ee01d00ca" +source = "git+https://github.com/pop-os/cosmic-settings-daemon#2f17f33875315a4cf463f82c5dceca4d83a75bfd" dependencies = [ "cosmic-config", "serde", @@ -1633,7 +1635,7 @@ dependencies = [ [[package]] name = "cosmic-settings-daemon" version = "0.1.0" -source = "git+https://github.com/pop-os/dbus-settings-bindings#8059e6bdaa35fecd70d228a999ca342fb00d313b" +source = "git+https://github.com/pop-os/dbus-settings-bindings#931f5db558bf3fcb572ff4e18f7f1618a7430046" dependencies = [ "zbus 4.4.0", ] @@ -1730,7 +1732,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "almost", "cosmic-config", @@ -1895,7 +1897,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1917,7 +1919,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2001,7 +2003,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2059,7 +2061,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2178,7 +2180,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2309,9 +2311,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fdeflate" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +checksum = "d8090f921a24b04994d9929e204f50b498a33ea6ba559ffaa05e04f7ee7fb5ab" dependencies = [ "simd-adler32", ] @@ -2350,9 +2352,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -2482,7 +2484,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2639,7 +2641,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2974,7 +2976,7 @@ checksum = "f558a64ac9af88b5ba400d99b579451af0d39c6d360980045b91aac966d705e2" [[package]] name = "hostname1-zbus" version = "0.1.0" -source = "git+https://github.com/pop-os/dbus-settings-bindings#8059e6bdaa35fecd70d228a999ca342fb00d313b" +source = "git+https://github.com/pop-os/dbus-settings-bindings#931f5db558bf3fcb572ff4e18f7f1618a7430046" dependencies = [ "zbus 4.4.0", ] @@ -3032,7 +3034,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.77", + "syn 2.0.79", "unic-langid", ] @@ -3046,7 +3048,7 @@ dependencies = [ "i18n-config", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3075,7 +3077,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "dnd", "iced_accessibility", @@ -3094,7 +3096,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "accesskit", "accesskit_unix", @@ -3103,7 +3105,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "bitflags 2.6.0", "dnd", @@ -3125,7 +3127,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "futures", "iced_core", @@ -3138,7 +3140,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -3162,7 +3164,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -3174,7 +3176,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "dnd", "iced_accessibility", @@ -3188,7 +3190,7 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "enum-repr", "float-cmp", @@ -3214,7 +3216,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "iced_core", "once_cell", @@ -3224,7 +3226,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "bytemuck", "cosmic-text", @@ -3241,7 +3243,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "as-raw-xcb-connection", "bitflags 2.6.0", @@ -3270,7 +3272,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "dnd", "iced_renderer", @@ -3287,7 +3289,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "dnd", "iced_graphics", @@ -3661,7 +3663,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3845,16 +3847,15 @@ dependencies = [ [[package]] name = "input" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7911ce3db9c10c5ab4a35c49af778a5f9a827bd0f7371d9be56175d8dd2740d0" +checksum = "fbdc09524a91f9cacd26f16734ff63d7dc650daffadd2b6f84d17a285bd875a9" dependencies = [ "bitflags 2.6.0", "input-sys", - "io-lifetimes 1.0.11", "libc", "log", - "udev 0.8.0", + "udev", ] [[package]] @@ -3880,7 +3881,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4093,14 +4094,14 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" +source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b" dependencies = [ "apply", "ashpd 0.9.1", @@ -4166,7 +4167,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -4221,7 +4222,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", - "redox_syscall 0.5.4", + "redox_syscall 0.5.7", ] [[package]] @@ -4502,7 +4503,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4526,7 +4527,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", - "simd-adler32", ] [[package]] @@ -4536,6 +4536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -4772,7 +4773,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4841,10 +4842,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4919,9 +4920,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "option-ext" @@ -4979,7 +4983,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5025,7 +5029,7 @@ dependencies = [ "by_address", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5077,7 +5081,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.4", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -5124,7 +5128,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5201,15 +5205,15 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "png" -version = "0.17.13" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0" dependencies = [ "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.4", + "miniz_oxide 0.8.0", ] [[package]] @@ -5249,6 +5253,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -5286,7 +5296,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.22.21", + "toml_edit 0.22.22", ] [[package]] @@ -5361,7 +5371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -5585,9 +5595,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -5605,14 +5615,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -5635,13 +5645,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -5652,9 +5662,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rend" @@ -5793,7 +5803,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.77", + "syn 2.0.79", "walkdir", ] @@ -6011,7 +6021,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6035,14 +6045,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -6074,7 +6084,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6444,9 +6454,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -6462,7 +6472,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6473,7 +6483,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6556,9 +6566,9 @@ checksum = "1f227968ec00f0e5322f9b8173c7a0cbcff6181a0a5b28e9892491c286277231" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand 2.1.1", @@ -6599,7 +6609,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6657,7 +6667,7 @@ dependencies = [ [[package]] name = "timedate-zbus" version = "0.1.0" -source = "git+https://github.com/pop-os/dbus-settings-bindings#8059e6bdaa35fecd70d228a999ca342fb00d313b" +source = "git+https://github.com/pop-os/dbus-settings-bindings#931f5db558bf3fcb572ff4e18f7f1618a7430046" dependencies = [ "zbus 4.4.0", ] @@ -6761,7 +6771,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6793,7 +6803,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.21", + "toml_edit 0.22.22", ] [[package]] @@ -6818,15 +6828,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.18", + "winnow 0.6.20", ] [[package]] @@ -6848,7 +6858,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -6933,18 +6943,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "udev" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50051c6e22be28ee6f217d50014f3bc29e81c20dc66ff7ca0d5c5226e1dcc5a1" -dependencies = [ - "io-lifetimes 1.0.11", - "libc", - "libudev-sys", - "pkg-config", -] - [[package]] name = "udev" version = "0.9.0" @@ -7077,7 +7075,7 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "upower_dbus" version = "0.3.2" -source = "git+https://github.com/pop-os/dbus-settings-bindings#8059e6bdaa35fecd70d228a999ca342fb00d313b" +source = "git+https://github.com/pop-os/dbus-settings-bindings#931f5db558bf3fcb572ff4e18f7f1618a7430046" dependencies = [ "serde", "serde_repr", @@ -7266,7 +7264,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -7300,7 +7298,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7632,7 +7630,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -7714,7 +7712,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -7725,7 +7723,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8009,9 +8007,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -8097,7 +8095,7 @@ dependencies = [ [[package]] name = "xdg-shell-wrapper-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-panel#4fedcbfc3574600b58de6da6c2401c92264537bd" +source = "git+https://github.com/pop-os/cosmic-panel#0ce85da198f02f94ad75441e64c0e165c41eb4ae" dependencies = [ "serde", "wayland-protocols-wlr 0.3.4", @@ -8199,7 +8197,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "synstructure", ] @@ -8301,7 +8299,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "zvariant_utils 2.1.0", ] @@ -8351,7 +8349,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8371,7 +8369,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "synstructure", ] @@ -8411,7 +8409,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -8488,7 +8486,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "zvariant_utils 2.1.0", ] @@ -8511,5 +8509,5 @@ checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] diff --git a/cosmic-settings/src/pages/bluetooth/agent.rs b/cosmic-settings/src/pages/bluetooth/agent.rs new file mode 100644 index 0000000..65ebd80 --- /dev/null +++ b/cosmic-settings/src/pages/bluetooth/agent.rs @@ -0,0 +1,64 @@ +use std::sync::Arc; + +use futures::{SinkExt, StreamExt}; +use zbus::zvariant::ObjectPath; + +const AGENT_PATH: &str = "/org/bluez/agent/cosmic_settings"; + +pub async fn unregister(connection: zbus::Connection) -> zbus::Result<()> { + let agent_path = ObjectPath::from_static_str_unchecked(AGENT_PATH); + let bluez = bluez_zbus::agent_manager1::AgentManager1Proxy::new(&connection).await?; + bluez.unregister_agent(&agent_path).await +} + +pub async fn watch( + connection: zbus::Connection, + mut tx: futures::channel::mpsc::Sender, +) -> zbus::Result<()> { + let span = tracing::span!(tracing::Level::INFO, "bluetooth::agent::watch"); + let _span = span.enter(); + + let (agent, mut receiver) = bluez_zbus::agent1::create(); + + let agent_path = ObjectPath::from_static_str_unchecked(AGENT_PATH); + + tracing::debug!("connecting agent"); + + connection.object_server().at(&agent_path, agent).await?; + + tracing::debug!("connecting to bluez agent manager"); + + let bluez = bluez_zbus::agent_manager1::AgentManager1Proxy::new(&connection).await?; + + tracing::debug!("registering agent"); + + bluez + .register_agent( + &agent_path, + <&'static str>::from(bluez_zbus::agent1::Capability::DisplayYesNo), + ) + .await?; + + if let Err(why) = bluez.request_default_agent(&agent_path).await { + _ = bluez.unregister_agent(&agent_path).await; + Err(why)?; + } + + tracing::debug!("registered"); + + while let Some(msg) = receiver.next().await { + tracing::debug!(?msg, "agent message received"); + + if tx.send(super::Message::Agent(Arc::new(msg))).await.is_err() { + break; + } + } + + _ = bluez.unregister_agent(&agent_path).await; + + tracing::debug!("exiting"); + + Ok(()) +} + +pub enum Message {} diff --git a/cosmic-settings/src/pages/bluetooth/backend.rs b/cosmic-settings/src/pages/bluetooth/backend.rs index 5961a2c..f020f38 100644 --- a/cosmic-settings/src/pages/bluetooth/backend.rs +++ b/cosmic-settings/src/pages/bluetooth/backend.rs @@ -60,7 +60,10 @@ impl DeviceUpdate { )))) } // Battery - _ => None, + (message, value) => { + tracing::debug!(message, ?value, "device update"); + None + } } }) .collect() @@ -108,7 +111,10 @@ impl AdapterUpdate { Some(Self::Address(value.into())) } // Battery - _ => None, + (message, value) => { + tracing::error!(message, ?value, "adapter update"); + None + } } }) .collect() @@ -269,18 +275,26 @@ impl Adapter { pub async fn from_device( proxy: &bluez_zbus::adapter1::Adapter1Proxy<'_>, ) -> zbus::Result { - let address = proxy.address().await?; - let alias = proxy.alias().await?; - let scanning = if proxy.discoverable().await? && proxy.discovering().await? { - Active::Enabled - } else { - Active::Disabled - }; - let enabled = if proxy.powered().await? { - Active::Enabled - } else { - Active::Disabled - }; + let (address, alias, scanning, enabled) = futures::try_join!( + proxy.address(), + proxy.alias(), + async { + Ok( + if proxy.discoverable().await? && proxy.discovering().await? { + Active::Enabled + } else { + Active::Disabled + }, + ) + }, + async { + Ok(if proxy.powered().await? { + Active::Enabled + } else { + Active::Disabled + }) + } + )?; Ok(Self { alias, @@ -320,38 +334,42 @@ pub async fn start_discovery( adapter_path: OwnedObjectPath, ) -> Message { let result: zbus::Result<()> = Ok(()); - match bluez_zbus::get_adapter(&connection, adapter_path).await { + + let adapter = match bluez_zbus::get_adapter(&connection, adapter_path).await { Err(why) => { tracing::error!("Unable to get the adapter: {why}"); return Message::DBusError(why.to_string()); } - Ok(adapter) => { - for attempt in 1..5 { - let result = async { - tracing::debug!("Starting discovery"); - // We don't seem to be able to use join here as it seem to lead to some kind of race condition and not start scanning occasionally - adapter.set_pairable(true).await?; - adapter.set_discoverable(true).await?; - if adapter.discovering().await? { - return Ok(()); - } - adapter.start_discovery().await - } - .await; - if let Err(why) = result { - tracing::warn!("Unable to start bluetooth scanning: {why}"); - tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; - } else { - tracing::debug!("Discovery started"); - return Message::Nop; - } + Ok(adapter) => adapter, + }; + + for attempt in 1..5 { + let result = async { + tracing::debug!("Starting discovery"); + // We don't seem to be able to use join here as it seem to lead to some kind of race condition and not start scanning occasionally + adapter.set_pairable(true).await?; + adapter.set_discoverable(true).await?; + if adapter.discovering().await? { + return Ok(()); } + adapter.start_discovery().await + } + .await; + + if let Err(why) = result { + tracing::warn!("Unable to start bluetooth scanning: {why}"); + tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; + } else { + tracing::debug!("Discovery started"); + return Message::Nop; } } - if let Err(why) = result { - return Message::DBusError(why.to_string()); - } - Message::Nop + + return if let Err(why) = result { + Message::DBusError(why.to_string()) + } else { + Message::Nop + }; } pub async fn stop_discovery( @@ -359,36 +377,36 @@ pub async fn stop_discovery( adapter_path: OwnedObjectPath, ) -> Message { let result: zbus::Result<()> = Ok(()); - match bluez_zbus::get_adapter(&connection, adapter_path).await { - Err(why) => { - tracing::error!("Unable to get the adapter: {why}"); - return Message::DBusError(why.to_string()); - } - Ok(adapter) => { - for attempt in 1..5 { - let result = async { - tracing::debug!("Stopping discovery"); - // We don't seem to be able to use join here as it seem to lead to some kind of race condition and not stop scanning occasionally - adapter.set_pairable(false).await?; - adapter.set_discoverable(false).await?; - if adapter.discovering().await? { - adapter.stop_discovery().await - } else { - Ok(()) - } - } - .await; - if let Err(why) = result { - tracing::warn!("Unable to stop bluetooth scanning: {why}"); - tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; - } else { - tracing::debug!("Discovery stopped"); - return Message::Nop; - } + let adapter = match bluez_zbus::get_adapter(&connection, adapter_path).await { + Err(why) => return Message::DBusError(format!("Unable to get the adapter: {why}")), + Ok(adapter) => adapter, + }; + + for attempt in 1..5 { + let result = async { + tracing::debug!("Stopping discovery"); + + // We don't seem to be able to use join here as it seem to lead to some kind of race condition and not stop scanning occasionally + adapter.set_pairable(false).await?; + adapter.set_discoverable(false).await?; + if adapter.discovering().await? { + adapter.stop_discovery().await + } else { + Ok(()) } } + .await; + + if let Err(why) = result { + tracing::warn!("Unable to stop bluetooth scanning: {why}"); + tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; + } else { + tracing::debug!("Discovery stopped"); + return Message::Nop; + } } + if let Err(why) = result { return Message::DBusError(why.to_string()); } @@ -399,103 +417,115 @@ pub async fn disconnect_device( connection: zbus::Connection, device_path: OwnedObjectPath, ) -> Message { - match bluez_zbus::get_device(&connection, device_path.clone()).await { + let proxy = match bluez_zbus::get_device(&connection, device_path.clone()).await { Err(why) => { tracing::error!("Unable to get the device: {why}"); return Message::DeviceFailed(device_path); } - Ok(proxy) => { - for attempt in 1..5 { - let result = async { - if !proxy.device.connected().await? { - return Ok(()); - } + Ok(proxy) => proxy, + }; - proxy.device.disconnect().await - } - .await; - if let Err(why) = result { - tracing::warn!("Unable to disconnect to device: {why}"); - tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; - } else { - return Message::Nop; - } + for attempt in 1..5 { + let result = async { + if !proxy.device.connected().await? { + return Ok(()); } + + proxy.device.disconnect().await + } + .await; + + if let Err(why) = result { + tracing::warn!("Unable to disconnect to device: {why}"); + tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; + } else { + return Message::Nop; } } + Message::DeviceFailed(device_path) } pub async fn connect_device(connection: zbus::Connection, device_path: OwnedObjectPath) -> Message { - match bluez_zbus::get_device(&connection, device_path.clone()).await { + let proxy = match bluez_zbus::get_device(&connection, device_path.clone()).await { Err(why) => { tracing::error!("Unable to get the device: {why}"); return Message::DeviceFailed(device_path); } - Ok(proxy) => { - for attempt in 1..5 { - let result = async { - if proxy.device.connected().await? { - Ok(()) - } else { - proxy.device.connect().await - } - } - .await; - if let Err(why) = result { - tracing::warn!("Unable to connect to device: {why}"); - tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; - } else { - return Message::Nop; - } + Ok(proxy) => proxy, + }; + + for attempt in 1..5 { + let result = async { + if proxy.device.connected().await? { + Ok(()) + } else { + proxy.device.connect().await } } + .await; + + if let Err(why) = result { + tracing::warn!("Unable to connect to device: {why}"); + tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; + } else { + return Message::Nop; + } } + Message::DeviceFailed(device_path) } pub async fn forget_device(connection: zbus::Connection, device_path: OwnedObjectPath) -> Message { let mut result: zbus::Result<()> = Ok(()); - match bluez_zbus::get_device(&connection, device_path.clone()).await { + + let proxy = match bluez_zbus::get_device(&connection, device_path.clone()).await { Err(why) => { tracing::error!("Unable to get the device: {why}"); return Message::DeviceFailed(device_path); } - Ok(proxy) => match proxy.device.adapter().await { - Err(why) => { - tracing::error!("Unable to get the adapter: {why}"); - return Message::DeviceFailed(device_path); - } - Ok(adapter) => match bluez_zbus::get_adapter(&connection, adapter).await { - Err(why) => { - tracing::error!("Unable to get the adapter: {why}"); - return Message::DeviceFailed(device_path); - } - Ok(adapter) => { - for attempt in 1..5 { - result = async { - if proxy.device.connected().await? { - proxy.device.disconnect().await?; - } + Ok(proxy) => proxy, + }; - adapter.remove_device(&proxy.path()).await - } - .await; - if let Err(why) = &result { - tracing::warn!("Unable to connect to device: {why}"); - tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; - } else { - return Message::Nop; - } - } - } - }, - }, + let adapter_path = match proxy.device.adapter().await { + Err(why) => { + tracing::error!("Unable to get the adapter: {why}"); + return Message::DeviceFailed(device_path); + } + Ok(adapter_path) => adapter_path, + }; + + let adapter = match bluez_zbus::get_adapter(&connection, adapter_path).await { + Err(why) => { + tracing::error!("Unable to get the adapter: {why}"); + return Message::DeviceFailed(device_path); + } + Ok(adapter) => adapter, + }; + + for attempt in 1..5 { + result = async { + if proxy.device.connected().await? { + proxy.device.disconnect().await?; + } + + adapter.remove_device(&proxy.path()).await + } + .await; + + if let Err(why) = &result { + tracing::warn!("Unable to connect to device: {why}"); + tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; + } else { + return Message::Nop; + } } - if result.is_err() { - return Message::DeviceFailed(device_path); - } - Message::Nop + + return if result.is_err() { + Message::DeviceFailed(device_path) + } else { + Message::Nop + }; } pub async fn change_adapter_status( diff --git a/cosmic-settings/src/pages/bluetooth/mod.rs b/cosmic-settings/src/pages/bluetooth/mod.rs index f872978..4196d7a 100644 --- a/cosmic-settings/src/pages/bluetooth/mod.rs +++ b/cosmic-settings/src/pages/bluetooth/mod.rs @@ -8,19 +8,43 @@ use cosmic::widget::{self, settings, text}; use cosmic::Command; use cosmic::{Apply, Element}; use cosmic_settings_page::{self as page, section, Section}; +use futures::channel::oneshot; use slab::Slab; use slotmap::SlotMap; use std::collections::{HashMap, HashSet}; +use std::sync::Arc; use zbus::zvariant::OwnedObjectPath; +mod agent; mod backend; pub use backend::*; mod subscription; +enum Dialog { + // RequestAuthorization { + // device: OwnedObjectPath, + // response: oneshot::Sender, + // }, + RequestConfirmation { + device: String, + passkey: u32, + response: oneshot::Sender, + }, + // RequestPasskey { + // device: OwnedObjectPath, + // response: oneshot::Sender>, + // }, + // RequestPinCode { + // device: OwnedObjectPath, + // response: oneshot::Sender>, + // }, +} + #[derive(Default)] pub struct Page { active: Active, connection: Option, + dialog: Option, adapters: HashMap, selected_adapter: Option, heading: String, @@ -69,7 +93,12 @@ impl page::Page for Page { _ = cancel.send(()); } - self.connection = None; + if let Some(connection) = self.connection.take() { + tokio::spawn(async move { + _ = agent::unregister(connection).await; + }); + } + self.adapters.clear(); self.selected_adapter = None; self.devices.clear(); @@ -79,12 +108,55 @@ impl page::Page for Page { Command::none() } + + fn dialog(&self) -> Option> { + match self.dialog.as_ref()? { + Dialog::RequestConfirmation { + device, passkey, .. + } => { + let description = widget::text::body(fl!( + "bluetooth-confirm-pin", + "description", + device = device + )) + .wrap(Wrap::Word); + + let pin = widget::text::title1(itoa::Buffer::new().format(*passkey).to_owned()) + .width(Length::Fill) + .horizontal_alignment(alignment::Horizontal::Center) + .wrap(Wrap::None); + + let control = widget::column::with_capacity(2) + .push(description) + .push(pin) + .spacing(cosmic::theme::active().cosmic().spacing.space_xxs); + + let confirm_button = + widget::button::suggested(fl!("confirm")).on_press(Message::PinConfirm); + + let cancel_button = + widget::button::standard(fl!("cancel")).on_press(Message::PinCancel); + + let dialog = widget::dialog(fl!("bluetooth-confirm-pin")) + .control(control) + .primary_action(confirm_button) + .secondary_action(cancel_button) + .apply(Element::from) + .map(Into::into); + + Some(dialog) + } + + _ => None, + } + } } #[derive(Clone, Debug)] pub enum Message { AddedAdapter(OwnedObjectPath, Adapter), AddedDevice(OwnedObjectPath, Device), + Agent(Arc), ConnectDevice(OwnedObjectPath), DBusConnect( zbus::Connection, @@ -94,6 +166,8 @@ pub enum Message { DeviceFailed(OwnedObjectPath), DisconnectDevice(OwnedObjectPath), ForgetDevice(OwnedObjectPath), + PinCancel, + PinConfirm, PopupDevice(Option), PopupSetting(bool), Nop, @@ -126,6 +200,61 @@ impl Page { let _span = span.enter(); match message { + Message::Agent(message) => { + let Some(message) = Arc::into_inner(message) else { + return Command::none(); + }; + + match message { + bluez_zbus::agent1::Message::RequestAuthorization { response, .. } => { + _ = response.send(true); + } + + bluez_zbus::agent1::Message::RequestConfirmation { + device, + passkey, + response, + } => { + let device = self.devices.get(&device).map_or_else( + || device.to_string(), + |device| device.alias_or_addr().to_owned(), + ); + + self.dialog = Some(Dialog::RequestConfirmation { + device, + passkey, + response, + }); + } + + bluez_zbus::agent1::Message::RequestPasskey { response, .. } => { + _ = response.send(None); + } + + bluez_zbus::agent1::Message::RequestPinCode { response, .. } => { + _ = response.send(None); + } + + bluez_zbus::agent1::Message::Cancel => { + self.dialog = None; + } + + _ => (), + } + } + + Message::PinCancel => { + if let Some(Dialog::RequestConfirmation { response, .. }) = self.dialog.take() { + _ = response.send(false); + } + } + + Message::PinConfirm => { + if let Some(Dialog::RequestConfirmation { response, .. }) = self.dialog.take() { + _ = response.send(true); + } + } + Message::SetActive(active) => { if let Some(connection) = self.connection.clone() { if let Some((path, adapter)) = self.get_selected_adapter_mut() { @@ -162,6 +291,7 @@ impl Page { } tracing::warn!("No DBus connection ready"); } + Message::DBusConnect(connection, sender) => { self.connection = Some(connection.clone()); @@ -170,7 +300,12 @@ impl Page { self.subscription = Some(crate::utils::forward_event_loop( sender, crate::pages::Message::Bluetooth, - move |tx| async move { subscription::watch(connection, tx).await }, + move |tx| async move { + _ = futures::join!( + subscription::watch(connection.clone(), tx.clone()), + agent::watch(connection, tx), + ); + }, )); } diff --git a/cosmic-settings/src/pages/bluetooth/subscription.rs b/cosmic-settings/src/pages/bluetooth/subscription.rs index dcdb2a2..2e9992a 100644 --- a/cosmic-settings/src/pages/bluetooth/subscription.rs +++ b/cosmic-settings/src/pages/bluetooth/subscription.rs @@ -76,7 +76,7 @@ pub async fn watch( connection: zbus::Connection, mut tx: futures::channel::mpsc::Sender, ) { - let span = tracing::span!(tracing::Level::INFO, "bluetooth::watch"); + let span = tracing::span!(tracing::Level::INFO, "bluetooth::subscription::watch"); let _span = span.enter(); loop { diff --git a/i18n/en/cosmic_settings.ftl b/i18n/en/cosmic_settings.ftl index f009e7b..637e619 100644 --- a/i18n/en/cosmic_settings.ftl +++ b/i18n/en/cosmic_settings.ftl @@ -82,6 +82,8 @@ online-accounts = Online Accounts # Bluetooth +confirm = Confirm + bluetooth = Bluetooth .desc = Manage Bluetooth devices .status = This system is visible as { $aliases } while Bluetooth settings are open. @@ -98,6 +100,9 @@ bluetooth-paired = Previously Connected Devices .connect = Connect .battery = { $percentage }% battery +bluetooth-confirm-pin = Confirm Bluetooth PIN + .description = Please confirm that the following PIN matches the one displayed on { $device } + bluetooth-available = Nearby Devices bluetooth-adapters = Bluetooth Adapters