feat(bluetooth): PIN confirmation support

This commit is contained in:
Michael Aaron Murphy 2024-10-02 10:17:02 +02:00
parent a742d3829c
commit 894cf9fc3f
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
6 changed files with 503 additions and 271 deletions

270
Cargo.lock generated
View file

@ -267,7 +267,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -524,7 +524,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -553,13 +553,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
[[package]] [[package]]
name = "async-trait" name = "async-trait"
version = "0.1.82" version = "0.1.83"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -628,9 +628,9 @@ dependencies = [
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.3.0" version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]] [[package]]
name = "av1-grain" name = "av1-grain"
@ -709,7 +709,7 @@ dependencies = [
"regex", "regex",
"rustc-hash", "rustc-hash",
"shlex", "shlex",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -816,9 +816,11 @@ dependencies = [
[[package]] [[package]]
name = "bluez-zbus" name = "bluez-zbus"
version = "0.1.0" 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 = [ dependencies = [
"futures", "futures-channel",
"futures-util",
"tracing",
"zbus 4.4.0", "zbus 4.4.0",
] ]
@ -842,7 +844,7 @@ dependencies = [
"proc-macro-crate 3.2.0", "proc-macro-crate 3.2.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
"syn_derive", "syn_derive",
] ]
@ -914,7 +916,7 @@ checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -999,9 +1001,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.21" version = "1.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" checksum = "3bbb537bb4a30b90362caddba8f360c0a56bc13d3a5570028e7197204cb54a17"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@ -1119,7 +1121,7 @@ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -1455,7 +1457,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config" name = "cosmic-config"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"atomicwrites", "atomicwrites",
"cosmic-config-derive", "cosmic-config-derive",
@ -1477,7 +1479,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config-derive" name = "cosmic-config-derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -1486,7 +1488,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-dbus-networkmanager" name = "cosmic-dbus-networkmanager"
version = "0.1.0" 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 = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"derive_builder", "derive_builder",
@ -1500,7 +1502,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-panel-config" name = "cosmic-panel-config"
version = "0.1.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"cosmic-config", "cosmic-config",
@ -1610,7 +1612,7 @@ dependencies = [
"tokio", "tokio",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"udev 0.9.0", "udev",
"upower_dbus", "upower_dbus",
"url", "url",
"xkb-data", "xkb-data",
@ -1620,7 +1622,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-settings-config" name = "cosmic-settings-config"
version = "0.1.0" 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 = [ dependencies = [
"cosmic-config", "cosmic-config",
"serde", "serde",
@ -1633,7 +1635,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-settings-daemon" name = "cosmic-settings-daemon"
version = "0.1.0" 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 = [ dependencies = [
"zbus 4.4.0", "zbus 4.4.0",
] ]
@ -1730,7 +1732,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-theme" name = "cosmic-theme"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"almost", "almost",
"cosmic-config", "cosmic-config",
@ -1895,7 +1897,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"strsim 0.11.1", "strsim 0.11.1",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -1917,7 +1919,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
dependencies = [ dependencies = [
"darling_core 0.20.10", "darling_core 0.20.10",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -2001,7 +2003,7 @@ dependencies = [
"darling 0.20.10", "darling 0.20.10",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -2059,7 +2061,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -2178,7 +2180,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -2309,9 +2311,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
[[package]] [[package]]
name = "fdeflate" name = "fdeflate"
version = "0.3.4" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" checksum = "d8090f921a24b04994d9929e204f50b498a33ea6ba559ffaa05e04f7ee7fb5ab"
dependencies = [ dependencies = [
"simd-adler32", "simd-adler32",
] ]
@ -2350,9 +2352,9 @@ dependencies = [
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.33" version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide 0.8.0", "miniz_oxide 0.8.0",
@ -2482,7 +2484,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -2639,7 +2641,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -2974,7 +2976,7 @@ checksum = "f558a64ac9af88b5ba400d99b579451af0d39c6d360980045b91aac966d705e2"
[[package]] [[package]]
name = "hostname1-zbus" name = "hostname1-zbus"
version = "0.1.0" 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 = [ dependencies = [
"zbus 4.4.0", "zbus 4.4.0",
] ]
@ -3032,7 +3034,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"strsim 0.11.1", "strsim 0.11.1",
"syn 2.0.77", "syn 2.0.79",
"unic-langid", "unic-langid",
] ]
@ -3046,7 +3048,7 @@ dependencies = [
"i18n-config", "i18n-config",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -3075,7 +3077,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_accessibility", "iced_accessibility",
@ -3094,7 +3096,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_accessibility" name = "iced_accessibility"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"accesskit_unix", "accesskit_unix",
@ -3103,7 +3105,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"dnd", "dnd",
@ -3125,7 +3127,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
@ -3138,7 +3140,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"bytemuck", "bytemuck",
@ -3162,7 +3164,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -3174,7 +3176,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_accessibility", "iced_accessibility",
@ -3188,7 +3190,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_sctk" name = "iced_sctk"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"enum-repr", "enum-repr",
"float-cmp", "float-cmp",
@ -3214,7 +3216,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"once_cell", "once_cell",
@ -3224,7 +3226,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -3241,7 +3243,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"as-raw-xcb-connection", "as-raw-xcb-connection",
"bitflags 2.6.0", "bitflags 2.6.0",
@ -3270,7 +3272,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_renderer", "iced_renderer",
@ -3287,7 +3289,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_winit" name = "iced_winit"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_graphics", "iced_graphics",
@ -3661,7 +3663,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -3845,16 +3847,15 @@ dependencies = [
[[package]] [[package]]
name = "input" name = "input"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7911ce3db9c10c5ab4a35c49af778a5f9a827bd0f7371d9be56175d8dd2740d0" checksum = "fbdc09524a91f9cacd26f16734ff63d7dc650daffadd2b6f84d17a285bd875a9"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"input-sys", "input-sys",
"io-lifetimes 1.0.11",
"libc", "libc",
"log", "log",
"udev 0.8.0", "udev",
] ]
[[package]] [[package]]
@ -3880,7 +3881,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -4093,14 +4094,14 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.158" version = "0.2.159"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#701638009df09a254b7d077ddc4d1076cd87a147" source = "git+https://github.com/pop-os/libcosmic#228eb4d70d581be88bacb1e261106a58603d847b"
dependencies = [ dependencies = [
"apply", "apply",
"ashpd 0.9.1", "ashpd 0.9.1",
@ -4166,7 +4167,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-targets 0.52.6", "windows-targets 0.48.5",
] ]
[[package]] [[package]]
@ -4221,7 +4222,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"libc", "libc",
"redox_syscall 0.5.4", "redox_syscall 0.5.7",
] ]
[[package]] [[package]]
@ -4502,7 +4503,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -4526,7 +4527,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
dependencies = [ dependencies = [
"adler", "adler",
"simd-adler32",
] ]
[[package]] [[package]]
@ -4536,6 +4536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [ dependencies = [
"adler2", "adler2",
"simd-adler32",
] ]
[[package]] [[package]]
@ -4772,7 +4773,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -4841,10 +4842,10 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [ dependencies = [
"proc-macro-crate 3.2.0", "proc-macro-crate 1.3.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -4919,9 +4920,12 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.19.0" version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1"
dependencies = [
"portable-atomic",
]
[[package]] [[package]]
name = "option-ext" name = "option-ext"
@ -4979,7 +4983,7 @@ dependencies = [
"proc-macro-error", "proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -5025,7 +5029,7 @@ dependencies = [
"by_address", "by_address",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -5077,7 +5081,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"redox_syscall 0.5.4", "redox_syscall 0.5.7",
"smallvec", "smallvec",
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
@ -5124,7 +5128,7 @@ dependencies = [
"phf_shared", "phf_shared",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -5201,15 +5205,15 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]] [[package]]
name = "png" name = "png"
version = "0.17.13" version = "0.17.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"crc32fast", "crc32fast",
"fdeflate", "fdeflate",
"flate2", "flate2",
"miniz_oxide 0.7.4", "miniz_oxide 0.8.0",
] ]
[[package]] [[package]]
@ -5249,6 +5253,12 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
[[package]]
name = "portable-atomic"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
[[package]] [[package]]
name = "powerfmt" name = "powerfmt"
version = "0.2.0" version = "0.2.0"
@ -5286,7 +5296,7 @@ version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b"
dependencies = [ dependencies = [
"toml_edit 0.22.21", "toml_edit 0.22.22",
] ]
[[package]] [[package]]
@ -5361,7 +5371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -5585,9 +5595,9 @@ dependencies = [
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.4" version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
] ]
@ -5605,14 +5615,14 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.10.6" version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
"regex-automata 0.4.7", "regex-automata 0.4.8",
"regex-syntax 0.8.4", "regex-syntax 0.8.5",
] ]
[[package]] [[package]]
@ -5635,13 +5645,13 @@ dependencies = [
[[package]] [[package]]
name = "regex-automata" name = "regex-automata"
version = "0.4.7" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
"regex-syntax 0.8.4", "regex-syntax 0.8.5",
] ]
[[package]] [[package]]
@ -5652,9 +5662,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.8.4" version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]] [[package]]
name = "rend" name = "rend"
@ -5793,7 +5803,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"rust-embed-utils", "rust-embed-utils",
"syn 2.0.77", "syn 2.0.79",
"walkdir", "walkdir",
] ]
@ -6011,7 +6021,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -6035,14 +6045,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.7" version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -6074,7 +6084,7 @@ dependencies = [
"darling 0.20.10", "darling 0.20.10",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -6444,9 +6454,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.77" version = "2.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -6462,7 +6472,7 @@ dependencies = [
"proc-macro-error", "proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -6473,7 +6483,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -6556,9 +6566,9 @@ checksum = "1f227968ec00f0e5322f9b8173c7a0cbcff6181a0a5b28e9892491c286277231"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.12.0" version = "3.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"fastrand 2.1.1", "fastrand 2.1.1",
@ -6599,7 +6609,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -6657,7 +6667,7 @@ dependencies = [
[[package]] [[package]]
name = "timedate-zbus" name = "timedate-zbus"
version = "0.1.0" 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 = [ dependencies = [
"zbus 4.4.0", "zbus 4.4.0",
] ]
@ -6761,7 +6771,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -6793,7 +6803,7 @@ dependencies = [
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"toml_edit 0.22.21", "toml_edit 0.22.22",
] ]
[[package]] [[package]]
@ -6818,15 +6828,15 @@ dependencies = [
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.22.21" version = "0.22.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
dependencies = [ dependencies = [
"indexmap 2.5.0", "indexmap 2.5.0",
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"winnow 0.6.18", "winnow 0.6.20",
] ]
[[package]] [[package]]
@ -6848,7 +6858,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -6933,18 +6943,6 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" 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]] [[package]]
name = "udev" name = "udev"
version = "0.9.0" version = "0.9.0"
@ -7077,7 +7075,7 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]] [[package]]
name = "upower_dbus" name = "upower_dbus"
version = "0.3.2" 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 = [ dependencies = [
"serde", "serde",
"serde_repr", "serde_repr",
@ -7266,7 +7264,7 @@ dependencies = [
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -7300,7 +7298,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -7632,7 +7630,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [ dependencies = [
"windows-sys 0.59.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -7714,7 +7712,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -7725,7 +7723,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -8009,9 +8007,9 @@ dependencies = [
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.6.18" version = "0.6.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -8097,7 +8095,7 @@ dependencies = [
[[package]] [[package]]
name = "xdg-shell-wrapper-config" name = "xdg-shell-wrapper-config"
version = "0.1.0" 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 = [ dependencies = [
"serde", "serde",
"wayland-protocols-wlr 0.3.4", "wayland-protocols-wlr 0.3.4",
@ -8199,7 +8197,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
"synstructure", "synstructure",
] ]
@ -8301,7 +8299,7 @@ dependencies = [
"proc-macro-crate 3.2.0", "proc-macro-crate 3.2.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
"zvariant_utils 2.1.0", "zvariant_utils 2.1.0",
] ]
@ -8351,7 +8349,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -8371,7 +8369,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
"synstructure", "synstructure",
] ]
@ -8411,7 +8409,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]
[[package]] [[package]]
@ -8488,7 +8486,7 @@ dependencies = [
"proc-macro-crate 3.2.0", "proc-macro-crate 3.2.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
"zvariant_utils 2.1.0", "zvariant_utils 2.1.0",
] ]
@ -8511,5 +8509,5 @@ checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.77", "syn 2.0.79",
] ]

View file

@ -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<super::Message>,
) -> 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 {}

View file

@ -60,7 +60,10 @@ impl DeviceUpdate {
)))) ))))
} }
// Battery // Battery
_ => None, (message, value) => {
tracing::debug!(message, ?value, "device update");
None
}
} }
}) })
.collect() .collect()
@ -108,7 +111,10 @@ impl AdapterUpdate {
Some(Self::Address(value.into())) Some(Self::Address(value.into()))
} }
// Battery // Battery
_ => None, (message, value) => {
tracing::error!(message, ?value, "adapter update");
None
}
} }
}) })
.collect() .collect()
@ -269,18 +275,26 @@ impl Adapter {
pub async fn from_device( pub async fn from_device(
proxy: &bluez_zbus::adapter1::Adapter1Proxy<'_>, proxy: &bluez_zbus::adapter1::Adapter1Proxy<'_>,
) -> zbus::Result<Self> { ) -> zbus::Result<Self> {
let address = proxy.address().await?; let (address, alias, scanning, enabled) = futures::try_join!(
let alias = proxy.alias().await?; proxy.address(),
let scanning = if proxy.discoverable().await? && proxy.discovering().await? { proxy.alias(),
Active::Enabled async {
} else { Ok(
Active::Disabled if proxy.discoverable().await? && proxy.discovering().await? {
}; Active::Enabled
let enabled = if proxy.powered().await? { } else {
Active::Enabled Active::Disabled
} else { },
Active::Disabled )
}; },
async {
Ok(if proxy.powered().await? {
Active::Enabled
} else {
Active::Disabled
})
}
)?;
Ok(Self { Ok(Self {
alias, alias,
@ -320,38 +334,42 @@ pub async fn start_discovery(
adapter_path: OwnedObjectPath, adapter_path: OwnedObjectPath,
) -> Message { ) -> Message {
let result: zbus::Result<()> = Ok(()); 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) => { Err(why) => {
tracing::error!("Unable to get the adapter: {why}"); tracing::error!("Unable to get the adapter: {why}");
return Message::DBusError(why.to_string()); return Message::DBusError(why.to_string());
} }
Ok(adapter) => { Ok(adapter) => adapter,
for attempt in 1..5 { };
let result = async {
tracing::debug!("Starting discovery"); for attempt in 1..5 {
// 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 let result = async {
adapter.set_pairable(true).await?; tracing::debug!("Starting discovery");
adapter.set_discoverable(true).await?; // 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
if adapter.discovering().await? { adapter.set_pairable(true).await?;
return Ok(()); adapter.set_discoverable(true).await?;
} if adapter.discovering().await? {
adapter.start_discovery().await return Ok(());
}
.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;
}
} }
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()); return if let Err(why) = result {
} Message::DBusError(why.to_string())
Message::Nop } else {
Message::Nop
};
} }
pub async fn stop_discovery( pub async fn stop_discovery(
@ -359,36 +377,36 @@ pub async fn stop_discovery(
adapter_path: OwnedObjectPath, adapter_path: OwnedObjectPath,
) -> Message { ) -> Message {
let result: zbus::Result<()> = Ok(()); 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 let adapter = match bluez_zbus::get_adapter(&connection, adapter_path).await {
adapter.set_pairable(false).await?; Err(why) => return Message::DBusError(format!("Unable to get the adapter: {why}")),
adapter.set_discoverable(false).await?; Ok(adapter) => adapter,
if adapter.discovering().await? { };
adapter.stop_discovery().await
} else { for attempt in 1..5 {
Ok(()) let result = async {
} tracing::debug!("Stopping discovery");
}
.await; // 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
if let Err(why) = result { adapter.set_pairable(false).await?;
tracing::warn!("Unable to stop bluetooth scanning: {why}"); adapter.set_discoverable(false).await?;
tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; if adapter.discovering().await? {
} else { adapter.stop_discovery().await
tracing::debug!("Discovery stopped"); } else {
return Message::Nop; 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 { if let Err(why) = result {
return Message::DBusError(why.to_string()); return Message::DBusError(why.to_string());
} }
@ -399,103 +417,115 @@ pub async fn disconnect_device(
connection: zbus::Connection, connection: zbus::Connection,
device_path: OwnedObjectPath, device_path: OwnedObjectPath,
) -> Message { ) -> 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) => { Err(why) => {
tracing::error!("Unable to get the device: {why}"); tracing::error!("Unable to get the device: {why}");
return Message::DeviceFailed(device_path); return Message::DeviceFailed(device_path);
} }
Ok(proxy) => { Ok(proxy) => proxy,
for attempt in 1..5 { };
let result = async {
if !proxy.device.connected().await? {
return Ok(());
}
proxy.device.disconnect().await for attempt in 1..5 {
} let result = async {
.await; if !proxy.device.connected().await? {
if let Err(why) = result { return Ok(());
tracing::warn!("Unable to disconnect to device: {why}");
tokio::time::sleep(Duration::from_millis(1000 * attempt)).await;
} else {
return Message::Nop;
}
} }
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) Message::DeviceFailed(device_path)
} }
pub async fn connect_device(connection: zbus::Connection, device_path: OwnedObjectPath) -> Message { 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) => { Err(why) => {
tracing::error!("Unable to get the device: {why}"); tracing::error!("Unable to get the device: {why}");
return Message::DeviceFailed(device_path); return Message::DeviceFailed(device_path);
} }
Ok(proxy) => { Ok(proxy) => proxy,
for attempt in 1..5 { };
let result = async {
if proxy.device.connected().await? { for attempt in 1..5 {
Ok(()) let result = async {
} else { if proxy.device.connected().await? {
proxy.device.connect().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;
}
} }
} }
.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) Message::DeviceFailed(device_path)
} }
pub async fn forget_device(connection: zbus::Connection, device_path: OwnedObjectPath) -> Message { pub async fn forget_device(connection: zbus::Connection, device_path: OwnedObjectPath) -> Message {
let mut result: zbus::Result<()> = Ok(()); 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) => { Err(why) => {
tracing::error!("Unable to get the device: {why}"); tracing::error!("Unable to get the device: {why}");
return Message::DeviceFailed(device_path); return Message::DeviceFailed(device_path);
} }
Ok(proxy) => match proxy.device.adapter().await { Ok(proxy) => proxy,
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?;
}
adapter.remove_device(&proxy.path()).await let adapter_path = match proxy.device.adapter().await {
} Err(why) => {
.await; tracing::error!("Unable to get the adapter: {why}");
if let Err(why) = &result { return Message::DeviceFailed(device_path);
tracing::warn!("Unable to connect to device: {why}"); }
tokio::time::sleep(Duration::from_millis(1000 * attempt)).await; Ok(adapter_path) => adapter_path,
} else { };
return Message::Nop;
} 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); return if result.is_err() {
} Message::DeviceFailed(device_path)
Message::Nop } else {
Message::Nop
};
} }
pub async fn change_adapter_status( pub async fn change_adapter_status(

View file

@ -8,19 +8,43 @@ use cosmic::widget::{self, settings, text};
use cosmic::Command; use cosmic::Command;
use cosmic::{Apply, Element}; use cosmic::{Apply, Element};
use cosmic_settings_page::{self as page, section, Section}; use cosmic_settings_page::{self as page, section, Section};
use futures::channel::oneshot;
use slab::Slab; use slab::Slab;
use slotmap::SlotMap; use slotmap::SlotMap;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use zbus::zvariant::OwnedObjectPath; use zbus::zvariant::OwnedObjectPath;
mod agent;
mod backend; mod backend;
pub use backend::*; pub use backend::*;
mod subscription; mod subscription;
enum Dialog {
// RequestAuthorization {
// device: OwnedObjectPath,
// response: oneshot::Sender<bool>,
// },
RequestConfirmation {
device: String,
passkey: u32,
response: oneshot::Sender<bool>,
},
// RequestPasskey {
// device: OwnedObjectPath,
// response: oneshot::Sender<Option<u32>>,
// },
// RequestPinCode {
// device: OwnedObjectPath,
// response: oneshot::Sender<Option<String>>,
// },
}
#[derive(Default)] #[derive(Default)]
pub struct Page { pub struct Page {
active: Active, active: Active,
connection: Option<zbus::Connection>, connection: Option<zbus::Connection>,
dialog: Option<Dialog>,
adapters: HashMap<OwnedObjectPath, Adapter>, adapters: HashMap<OwnedObjectPath, Adapter>,
selected_adapter: Option<OwnedObjectPath>, selected_adapter: Option<OwnedObjectPath>,
heading: String, heading: String,
@ -69,7 +93,12 @@ impl page::Page<crate::pages::Message> for Page {
_ = cancel.send(()); _ = cancel.send(());
} }
self.connection = None; if let Some(connection) = self.connection.take() {
tokio::spawn(async move {
_ = agent::unregister(connection).await;
});
}
self.adapters.clear(); self.adapters.clear();
self.selected_adapter = None; self.selected_adapter = None;
self.devices.clear(); self.devices.clear();
@ -79,12 +108,55 @@ impl page::Page<crate::pages::Message> for Page {
Command::none() Command::none()
} }
fn dialog(&self) -> Option<Element<'_, crate::pages::Message>> {
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)] #[derive(Clone, Debug)]
pub enum Message { pub enum Message {
AddedAdapter(OwnedObjectPath, Adapter), AddedAdapter(OwnedObjectPath, Adapter),
AddedDevice(OwnedObjectPath, Device), AddedDevice(OwnedObjectPath, Device),
Agent(Arc<bluez_zbus::agent1::Message>),
ConnectDevice(OwnedObjectPath), ConnectDevice(OwnedObjectPath),
DBusConnect( DBusConnect(
zbus::Connection, zbus::Connection,
@ -94,6 +166,8 @@ pub enum Message {
DeviceFailed(OwnedObjectPath), DeviceFailed(OwnedObjectPath),
DisconnectDevice(OwnedObjectPath), DisconnectDevice(OwnedObjectPath),
ForgetDevice(OwnedObjectPath), ForgetDevice(OwnedObjectPath),
PinCancel,
PinConfirm,
PopupDevice(Option<OwnedObjectPath>), PopupDevice(Option<OwnedObjectPath>),
PopupSetting(bool), PopupSetting(bool),
Nop, Nop,
@ -126,6 +200,61 @@ impl Page {
let _span = span.enter(); let _span = span.enter();
match message { 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) => { Message::SetActive(active) => {
if let Some(connection) = self.connection.clone() { if let Some(connection) = self.connection.clone() {
if let Some((path, adapter)) = self.get_selected_adapter_mut() { if let Some((path, adapter)) = self.get_selected_adapter_mut() {
@ -162,6 +291,7 @@ impl Page {
} }
tracing::warn!("No DBus connection ready"); tracing::warn!("No DBus connection ready");
} }
Message::DBusConnect(connection, sender) => { Message::DBusConnect(connection, sender) => {
self.connection = Some(connection.clone()); self.connection = Some(connection.clone());
@ -170,7 +300,12 @@ impl Page {
self.subscription = Some(crate::utils::forward_event_loop( self.subscription = Some(crate::utils::forward_event_loop(
sender, sender,
crate::pages::Message::Bluetooth, 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),
);
},
)); ));
} }

View file

@ -76,7 +76,7 @@ pub async fn watch(
connection: zbus::Connection, connection: zbus::Connection,
mut tx: futures::channel::mpsc::Sender<bluetooth::Message>, mut tx: futures::channel::mpsc::Sender<bluetooth::Message>,
) { ) {
let span = tracing::span!(tracing::Level::INFO, "bluetooth::watch"); let span = tracing::span!(tracing::Level::INFO, "bluetooth::subscription::watch");
let _span = span.enter(); let _span = span.enter();
loop { loop {

View file

@ -82,6 +82,8 @@ online-accounts = Online Accounts
# Bluetooth # Bluetooth
confirm = Confirm
bluetooth = Bluetooth bluetooth = Bluetooth
.desc = Manage Bluetooth devices .desc = Manage Bluetooth devices
.status = This system is visible as { $aliases } while Bluetooth settings are open. .status = This system is visible as { $aliases } while Bluetooth settings are open.
@ -98,6 +100,9 @@ bluetooth-paired = Previously Connected Devices
.connect = Connect .connect = Connect
.battery = { $percentage }% battery .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-available = Nearby Devices
bluetooth-adapters = Bluetooth Adapters bluetooth-adapters = Bluetooth Adapters