From a8aca57ea16c7c564b1bb0e59ff030ca05c4de57 Mon Sep 17 00:00:00 2001 From: dashie Date: Thu, 4 Apr 2024 10:54:20 +0200 Subject: [PATCH] feat: Add ability to show bluetooth devices immediately --- Cargo.toml | 2 +- flatpak/cargo-sources.json | 103 +++++++++------------ src/components/audio/audio_box_handlers.rs | 2 +- src/components/audio/output/sink_box.rs | 10 +- src/components/bluetooth/bluetooth_box.rs | 33 ++++++- src/components/utils.rs | 2 +- src/components/wifi/wifi_box.rs | 3 +- 7 files changed, 85 insertions(+), 70 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3ad810d..091af7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-or-later" # reset_daemon = "1.1.0" re_set-lib = { git = "https://github.com/Xetibo/ReSet-Lib" , branch = "audioobject"} # re_set-lib = "3.1.7" -reset_daemon = { git = "https://github.com/Xetibo/ReSet-Daemon", branch = "dashie" } +reset_daemon = { git = "https://github.com/Xetibo/ReSet-Daemon", branch = "main" } adw = { version = "0.6.0", package = "libadwaita", features = ["v1_4"] } dbus = "0.9.7" gtk = { version = "0.8.1", package = "gtk4", features = ["v4_12"] } diff --git a/flatpak/cargo-sources.json b/flatpak/cargo-sources.json index d7831be..3d8ac93 100644 --- a/flatpak/cargo-sources.json +++ b/flatpak/cargo-sources.json @@ -535,14 +535,14 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/glib/glib-0.18.4.crate", - "sha256": "951bbd7fdc5c044ede9f05170f05a3ae9479239c3afdfe2d22d537a3add15c4e", - "dest": "cargo/vendor/glib-0.18.4" + "url": "https://static.crates.io/crates/glib/glib-0.18.3.crate", + "sha256": "58cf801b6f7829fa76db37449ab67c9c98a2b1bf21076d9113225621e61a0fa6", + "dest": "cargo/vendor/glib-0.18.3" }, { "type": "inline", - "contents": "{\"package\": \"951bbd7fdc5c044ede9f05170f05a3ae9479239c3afdfe2d22d537a3add15c4e\", \"files\": {}}", - "dest": "cargo/vendor/glib-0.18.4", + "contents": "{\"package\": \"58cf801b6f7829fa76db37449ab67c9c98a2b1bf21076d9113225621e61a0fa6\", \"files\": {}}", + "dest": "cargo/vendor/glib-0.18.3", "dest-filename": ".cargo-checksum.json" }, { @@ -886,14 +886,14 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/mio/mio-0.8.9.crate", - "sha256": "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0", - "dest": "cargo/vendor/mio-0.8.9" + "url": "https://static.crates.io/crates/mio/mio-0.8.10.crate", + "sha256": "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09", + "dest": "cargo/vendor/mio-0.8.10" }, { "type": "inline", - "contents": "{\"package\": \"3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0\", \"files\": {}}", - "dest": "cargo/vendor/mio-0.8.9", + "contents": "{\"package\": \"8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09\", \"files\": {}}", + "dest": "cargo/vendor/mio-0.8.10", "dest-filename": ".cargo-checksum.json" }, { @@ -951,14 +951,14 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/once_cell/once_cell-1.18.0.crate", - "sha256": "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d", - "dest": "cargo/vendor/once_cell-1.18.0" + "url": "https://static.crates.io/crates/once_cell/once_cell-1.19.0.crate", + "sha256": "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92", + "dest": "cargo/vendor/once_cell-1.19.0" }, { "type": "inline", - "contents": "{\"package\": \"dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d\", \"files\": {}}", - "dest": "cargo/vendor/once_cell-1.18.0", + "contents": "{\"package\": \"3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92\", \"files\": {}}", + "dest": "cargo/vendor/once_cell-1.19.0", "dest-filename": ".cargo-checksum.json" }, { @@ -1042,14 +1042,14 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/proc-macro-crate/proc-macro-crate-2.0.0.crate", - "sha256": "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8", - "dest": "cargo/vendor/proc-macro-crate-2.0.0" + "url": "https://static.crates.io/crates/proc-macro-crate/proc-macro-crate-2.0.1.crate", + "sha256": "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a", + "dest": "cargo/vendor/proc-macro-crate-2.0.1" }, { "type": "inline", - "contents": "{\"package\": \"7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8\", \"files\": {}}", - "dest": "cargo/vendor/proc-macro-crate-2.0.0", + "contents": "{\"package\": \"97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a\", \"files\": {}}", + "dest": "cargo/vendor/proc-macro-crate-2.0.1", "dest-filename": ".cargo-checksum.json" }, { @@ -1146,14 +1146,14 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/reset_daemon/reset_daemon-1.0.0.crate", - "sha256": "4ac44390e711dd73b2a2c365890d28f0ceec5c3e9f760deafbab2ad7410e90ed", - "dest": "cargo/vendor/reset_daemon-1.0.0" + "url": "https://static.crates.io/crates/reset_daemon/reset_daemon-1.0.1.crate", + "sha256": "eedc50550fb0c1b1a6d09c0c9e8025678d50833805ddf09e3aa39a66ff391cc4", + "dest": "cargo/vendor/reset_daemon-1.0.1" }, { "type": "inline", - "contents": "{\"package\": \"4ac44390e711dd73b2a2c365890d28f0ceec5c3e9f760deafbab2ad7410e90ed\", \"files\": {}}", - "dest": "cargo/vendor/reset_daemon-1.0.0", + "contents": "{\"package\": \"eedc50550fb0c1b1a6d09c0c9e8025678d50833805ddf09e3aa39a66ff391cc4\", \"files\": {}}", + "dest": "cargo/vendor/reset_daemon-1.0.1", "dest-filename": ".cargo-checksum.json" }, { @@ -1380,27 +1380,27 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/toml/toml-0.8.8.crate", - "sha256": "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35", - "dest": "cargo/vendor/toml-0.8.8" + "url": "https://static.crates.io/crates/toml/toml-0.8.2.crate", + "sha256": "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d", + "dest": "cargo/vendor/toml-0.8.2" }, { "type": "inline", - "contents": "{\"package\": \"a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35\", \"files\": {}}", - "dest": "cargo/vendor/toml-0.8.8", + "contents": "{\"package\": \"185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d\", \"files\": {}}", + "dest": "cargo/vendor/toml-0.8.2", "dest-filename": ".cargo-checksum.json" }, { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/toml_datetime/toml_datetime-0.6.5.crate", - "sha256": "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1", - "dest": "cargo/vendor/toml_datetime-0.6.5" + "url": "https://static.crates.io/crates/toml_datetime/toml_datetime-0.6.3.crate", + "sha256": "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b", + "dest": "cargo/vendor/toml_datetime-0.6.3" }, { "type": "inline", - "contents": "{\"package\": \"3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1\", \"files\": {}}", - "dest": "cargo/vendor/toml_datetime-0.6.5", + "contents": "{\"package\": \"7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b\", \"files\": {}}", + "dest": "cargo/vendor/toml_datetime-0.6.3", "dest-filename": ".cargo-checksum.json" }, { @@ -1419,27 +1419,14 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/toml_edit/toml_edit-0.20.7.crate", - "sha256": "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81", - "dest": "cargo/vendor/toml_edit-0.20.7" + "url": "https://static.crates.io/crates/toml_edit/toml_edit-0.20.2.crate", + "sha256": "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338", + "dest": "cargo/vendor/toml_edit-0.20.2" }, { "type": "inline", - "contents": "{\"package\": \"70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81\", \"files\": {}}", - "dest": "cargo/vendor/toml_edit-0.20.7", - "dest-filename": ".cargo-checksum.json" - }, - { - "type": "archive", - "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/toml_edit/toml_edit-0.21.0.crate", - "sha256": "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03", - "dest": "cargo/vendor/toml_edit-0.21.0" - }, - { - "type": "inline", - "contents": "{\"package\": \"d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03\", \"files\": {}}", - "dest": "cargo/vendor/toml_edit-0.21.0", + "contents": "{\"package\": \"396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338\", \"files\": {}}", + "dest": "cargo/vendor/toml_edit-0.20.2", "dest-filename": ".cargo-checksum.json" }, { @@ -1653,14 +1640,14 @@ { "type": "archive", "archive-type": "tar-gzip", - "url": "https://static.crates.io/crates/winnow/winnow-0.5.19.crate", - "sha256": "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b", - "dest": "cargo/vendor/winnow-0.5.19" + "url": "https://static.crates.io/crates/winnow/winnow-0.5.26.crate", + "sha256": "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff", + "dest": "cargo/vendor/winnow-0.5.26" }, { "type": "inline", - "contents": "{\"package\": \"829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b\", \"files\": {}}", - "dest": "cargo/vendor/winnow-0.5.19", + "contents": "{\"package\": \"b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff\", \"files\": {}}", + "dest": "cargo/vendor/winnow-0.5.26", "dest-filename": ".cargo-checksum.json" }, { diff --git a/src/components/audio/audio_box_handlers.rs b/src/components/audio/audio_box_handlers.rs index 43f5855..01b610c 100644 --- a/src/components/audio/audio_box_handlers.rs +++ b/src/components/audio/audio_box_handlers.rs @@ -171,8 +171,8 @@ pub fn populate_audio_objects< default_audio_object_function: &'static DBusFunction, set_default_audio_object_function: &'static DBusFunction, get_audio_streams_function: &'static DBusFunction, - set_audio_object_mute_function: &'static DBusFunction, set_audio_object_volume_function: &'static DBusFunction, + set_audio_object_mute_function: &'static DBusFunction, ) { gio::spawn_blocking(move || { let sources = audio_dbus_call::,), ()>( diff --git a/src/components/audio/output/sink_box.rs b/src/components/audio/output/sink_box.rs index d3cd556..25a351d 100644 --- a/src/components/audio/output/sink_box.rs +++ b/src/components/audio/output/sink_box.rs @@ -20,13 +20,9 @@ use crate::components::base::error_impl::ReSetErrorImpl; use super::input_stream_entry::InputStreamEntry; use super::sink_box_impl; -use super::sink_const::GETDEFAULT; -use super::sink_const::GETDEFAULTNAME; -use super::sink_const::GETOBJECTS; -use super::sink_const::GETSTREAMS; -use super::sink_const::SETDEFAULT; -use super::sink_const::SETMUTE; -use super::sink_const::SETVOLUME; +use super::sink_const::{ + GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME, +}; use super::sink_entry::SinkEntry; glib::wrapper! { diff --git a/src/components/bluetooth/bluetooth_box.rs b/src/components/bluetooth/bluetooth_box.rs index fa27cb7..c405bc7 100644 --- a/src/components/bluetooth/bluetooth_box.rs +++ b/src/components/bluetooth/bluetooth_box.rs @@ -179,7 +179,9 @@ pub fn populate_connected_bluetooth_devices(bluetooth_box: Arc) { // TODO handle saved devices -> they also exist gio::spawn_blocking(move || { let ref_box = bluetooth_box.clone(); - let devices = get_connected_devices(ref_box.clone()); + let devices = get_bluetooth_devices(ref_box.clone()); + dbg!(&devices); + let connected_devices = get_connected_devices(ref_box.clone()); let adapters = get_bluetooth_adapters(ref_box.clone()); { let imp = bluetooth_box.imp(); @@ -228,6 +230,7 @@ pub fn populate_connected_bluetooth_devices(bluetooth_box: Arc) { }); for device in devices { + dbg!(&device); let path = device.path.clone(); let connected = device.connected; let bluetooth_entry = BluetoothEntry::new(device, ref_box.clone()); @@ -240,6 +243,19 @@ pub fn populate_connected_bluetooth_devices(bluetooth_box: Arc) { imp.reset_bluetooth_available_devices.add(&*bluetooth_entry); } } + for device in connected_devices { + let path = device.path.clone(); + let connected = device.connected; + let bluetooth_entry = BluetoothEntry::new(device, ref_box.clone()); + imp.connected_devices + .borrow_mut() + .insert(path, bluetooth_entry.clone()); + if connected { + imp.reset_bluetooth_connected_devices.add(&*bluetooth_entry); + } else { + imp.reset_bluetooth_available_devices.add(&*bluetooth_entry); + } + } }); }); }); @@ -425,6 +441,21 @@ fn get_connected_devices(bluetooth_box: Arc) -> Vec) -> Vec { + let conn = Connection::new_session().unwrap(); + let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(1000)); + let res: Result<(Vec,), Error> = + proxy.method_call(BLUETOOTH, "GetBluetoothDevices", ()); + if res.is_err() { + show_error::( + bluetooth_box.clone(), + "Failed to get bluetooth devices", + ); + return Vec::new(); + } + res.unwrap().0 +} + fn get_bluetooth_adapters(bluetooth_box: Arc) -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(1000)); diff --git a/src/components/utils.rs b/src/components/utils.rs index d73e8a9..5a9f398 100644 --- a/src/components/utils.rs +++ b/src/components/utils.rs @@ -7,7 +7,7 @@ use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, Wid use gtk::{Align, SignalListItemFactory, StringObject}; pub const DBUS_PATH: &str = "/org/Xetibo/ReSet/Daemon"; -pub const WIRELESS: &str = "org.Xetibo.ReSet.Wireless"; +pub const WIRELESS: &str = "org.Xetibo.ReSet.Network"; pub const BLUETOOTH: &str = "org.Xetibo.ReSet.Bluetooth"; pub const AUDIO: &str = "org.Xetibo.ReSet.Audio"; pub const BASE: &str = "org.Xetibo.ReSet.Daemon"; diff --git a/src/components/wifi/wifi_box.rs b/src/components/wifi/wifi_box.rs index 673aab9..bb3e62e 100644 --- a/src/components/wifi/wifi_box.rs +++ b/src/components/wifi/wifi_box.rs @@ -116,7 +116,7 @@ pub fn scan_for_wifi(wifi_box: Arc) { if devices.is_empty() { return; } - let access_points = get_access_points(wifibox_ref.clone()); + let access_points = get_access_points(wifi_box.clone()); { let imp = wifibox_ref.imp(); let list = imp.reset_model_list.write().unwrap(); @@ -251,6 +251,7 @@ pub fn get_wifi_devices(wifi_box: Arc) -> Vec { let res: Result<(Vec,), Error> = proxy.method_call(WIRELESS, "GetAllWifiDevices", ()); if res.is_err() { + dbg!(&res); show_error::(wifi_box.clone(), "Failed to get WiFi devices"); return Vec::new(); }