From 35d2174136d165f6abacc1b40467951a0f88b6c3 Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Wed, 29 Nov 2023 01:33:00 +0100 Subject: [PATCH] feat: Implement new event API --- Cargo.toml | 4 +- src/components/base/cardEntry.rs | 6 +-- src/components/base/utils.rs | 42 +++++++++---------- src/components/bluetooth/bluetoothBox.rs | 21 ++++++---- src/components/bluetooth/bluetoothEntry.rs | 18 ++++---- src/components/input/outputStreamEntry.rs | 18 ++++---- src/components/input/sourceBox.rs | 48 +++++++++++----------- src/components/input/sourceEntry.rs | 18 ++++---- src/components/output/inputStreamEntry.rs | 18 ++++---- src/components/output/sinkBox.rs | 48 +++++++++++----------- src/components/output/sinkEntry.rs | 18 ++++---- src/components/utils.rs | 17 ++++++-- src/components/wifi/savedWifiEntry.rs | 6 +-- src/components/wifi/utils.rs | 6 +-- src/components/wifi/wifiBox.rs | 30 +++++++------- src/components/wifi/wifiEntry.rs | 18 ++++---- src/main.rs | 6 +-- 17 files changed, 178 insertions(+), 164 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2a8cbf1..c7f6200 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" description = "A wip universal Linux settings application." [dependencies] -reset_daemon = "0.2.5" -ReSet-Lib = "0.4.6" +reset_daemon = "0.3.3" +ReSet-Lib = "0.4.9" adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] } dbus = "0.9.7" gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] } diff --git a/src/components/base/cardEntry.rs b/src/components/base/cardEntry.rs index 804acac..0f671dd 100644 --- a/src/components/base/cardEntry.rs +++ b/src/components/base/cardEntry.rs @@ -68,12 +68,12 @@ fn set_card_profile_of_device(device_index: u32, profile_name: String) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetCardProfileOfDevice", (device_index, profile_name), ); diff --git a/src/components/base/utils.rs b/src/components/base/utils.rs index c9cb5ff..2fdf939 100644 --- a/src/components/base/utils.rs +++ b/src/components/base/utils.rs @@ -39,12 +39,12 @@ impl Listeners { thread::spawn(|| { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "StopNetworkListener", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "StopNetworkListener", ()); }); } @@ -76,7 +76,7 @@ impl arg::ReadAll for SinkAdded { impl dbus::message::SignalArgs for SinkAdded { const NAME: &'static str = "SinkAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Sink,)> for SinkAdded { @@ -104,7 +104,7 @@ impl arg::ReadAll for SinkChanged { impl dbus::message::SignalArgs for SinkChanged { const NAME: &'static str = "SinkChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Sink,)> for SinkChanged { @@ -132,7 +132,7 @@ impl arg::ReadAll for SinkRemoved { impl dbus::message::SignalArgs for SinkRemoved { const NAME: &'static str = "SinkRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for SinkRemoved { @@ -160,7 +160,7 @@ impl arg::ReadAll for InputStreamAdded { impl dbus::message::SignalArgs for InputStreamAdded { const NAME: &'static str = "InputStreamAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(InputStream,)> for InputStreamAdded { @@ -188,7 +188,7 @@ impl arg::ReadAll for InputStreamChanged { impl dbus::message::SignalArgs for InputStreamChanged { const NAME: &'static str = "InputStreamChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } #[derive(Debug)] @@ -210,7 +210,7 @@ impl arg::ReadAll for InputStreamRemoved { impl dbus::message::SignalArgs for InputStreamRemoved { const NAME: &'static str = "InputStreamRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for InputStreamRemoved { @@ -238,7 +238,7 @@ impl arg::ReadAll for SourceAdded { impl dbus::message::SignalArgs for SourceAdded { const NAME: &'static str = "SourceAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Source,)> for SourceAdded { @@ -266,7 +266,7 @@ impl arg::ReadAll for SourceChanged { impl dbus::message::SignalArgs for SourceChanged { const NAME: &'static str = "SourceChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(Source,)> for SourceChanged { @@ -294,7 +294,7 @@ impl arg::ReadAll for SourceRemoved { impl dbus::message::SignalArgs for SourceRemoved { const NAME: &'static str = "SourceRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for SourceRemoved { @@ -322,7 +322,7 @@ impl arg::ReadAll for OutputStreamAdded { impl dbus::message::SignalArgs for OutputStreamAdded { const NAME: &'static str = "OutputStreamAdded"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(OutputStream,)> for OutputStreamAdded { @@ -350,7 +350,7 @@ impl arg::ReadAll for OutputStreamChanged { impl dbus::message::SignalArgs for OutputStreamChanged { const NAME: &'static str = "OutputStreamChanged"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } #[derive(Debug)] @@ -372,7 +372,7 @@ impl arg::ReadAll for OutputStreamRemoved { impl dbus::message::SignalArgs for OutputStreamRemoved { const NAME: &'static str = "OutputStreamRemoved"; - const INTERFACE: &'static str = "org.xetibo.ReSet"; + const INTERFACE: &'static str = "org.Xetibo.ReSetAudio"; } impl GetVal<(u32,)> for OutputStreamRemoved { @@ -419,20 +419,20 @@ pub fn start_audio_listener( fn start_dbus_audio_listener(conn: Connection) -> Connection { let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StartAudioListener", ()); + let _: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "StartAudioListener", ()); conn } fn stop_dbus_audio_listener(conn: Connection) { let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StopAudioListener", ()); + let _: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "StopAudioListener", ()); } diff --git a/src/components/bluetooth/bluetoothBox.rs b/src/components/bluetooth/bluetoothBox.rs index c03037d..d493847 100644 --- a/src/components/bluetooth/bluetoothBox.rs +++ b/src/components/bluetooth/bluetoothBox.rs @@ -102,20 +102,25 @@ pub fn start_bluetooth_listener(listeners: Arc, bluetooth_box: Arc = - proxy.method_call("org.xetibo.ReSet", "StartBluetoothSearch", (10000,)); + let _: Result<(), Error> = proxy.method_call( + "org.Xetibo.ReSetBluetooth", + "StartBluetoothListener", + #[allow(clippy::unnecessary_cast)] + (10000 as u32,), + // leave me alone clippy, I am dealing with C code + ); let device_added = BluetoothDeviceAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let device_removed = BluetoothDeviceRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let device_added_box = bluetooth_box.clone(); diff --git a/src/components/bluetooth/bluetoothEntry.rs b/src/components/bluetooth/bluetoothEntry.rs index f917555..924f126 100644 --- a/src/components/bluetooth/bluetoothEntry.rs +++ b/src/components/bluetooth/bluetoothEntry.rs @@ -60,12 +60,12 @@ fn connect_to_device(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "ConnectToBluetoothDevice", (path,)); + proxy.method_call("org.Xetibo.ReSetBluetooth", "ConnectToBluetoothDevice", (path,)); }); } @@ -73,12 +73,12 @@ fn pair_with_device(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "PairWithBluetoothDevice", (path,)); + proxy.method_call("org.Xetibo.ReSetBluetooth", "PairWithBluetoothDevice", (path,)); }); } @@ -86,11 +86,11 @@ fn disconnect_from_device(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "DisconnectFromBluetoothDevice", (path,)); + proxy.method_call("org.Xetibo.ReSetBluetooth", "DisconnectFromBluetoothDevice", (path,)); }); } diff --git a/src/components/input/outputStreamEntry.rs b/src/components/input/outputStreamEntry.rs index 9e1e231..175204e 100644 --- a/src/components/input/outputStreamEntry.rs +++ b/src/components/input/outputStreamEntry.rs @@ -141,12 +141,12 @@ fn set_outputstream_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetOutputStreamVolume", (index, channels, value as u32), ); @@ -162,12 +162,12 @@ fn toggle_output_stream_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetOutputStreamMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetOutputStreamMute", (index, muted)); // if res.is_err() { // return false; // } @@ -180,12 +180,12 @@ fn set_source_of_output_stream(stream: u32, source: u32) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(bool,), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetSourceOfOutputStream", (stream, source), ); diff --git a/src/components/input/sourceBox.rs b/src/components/input/sourceBox.rs index 3a97d87..f943a2e 100644 --- a/src/components/input/sourceBox.rs +++ b/src/components/input/sourceBox.rs @@ -248,12 +248,12 @@ pub fn populate_cards(input_box: Arc) { fn get_output_streams() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListOutputStreams", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "ListOutputStreams", ()); if res.is_err() { return Vec::new(); } @@ -263,12 +263,12 @@ fn get_output_streams() -> Vec { fn get_sources() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListSources", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "ListSources", ()); if res.is_err() { return Vec::new(); } @@ -278,11 +278,11 @@ fn get_sources() -> Vec { fn get_cards() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Vec,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ()); + let res: Result<(Vec,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ()); if res.is_err() { return Vec::new(); } @@ -292,12 +292,12 @@ fn get_cards() -> Vec { fn get_default_source() -> Source { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Source,), Error> = - proxy.method_call("org.xetibo.ReSet", "GetDefaultSource", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "GetDefaultSource", ()); if res.is_err() { return Source::default(); } @@ -306,33 +306,33 @@ fn get_default_source() -> Source { pub fn start_input_box_listener(conn: Connection, source_box: Arc) -> Connection { let source_added = SourceAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let source_removed = SourceRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let source_changed = SourceChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let output_stream_added = OutputStreamAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let output_stream_removed = OutputStreamRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let output_stream_changed = OutputStreamChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); diff --git a/src/components/input/sourceEntry.rs b/src/components/input/sourceEntry.rs index 423f20d..0d4202b 100644 --- a/src/components/input/sourceEntry.rs +++ b/src/components/input/sourceEntry.rs @@ -94,12 +94,12 @@ pub fn set_source_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetSourceVolume", (index, channels, value as u32), ); @@ -115,12 +115,12 @@ pub fn toggle_source_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetSourceMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetSourceMute", (index, muted)); // if res.is_err() { // return false; // } @@ -133,12 +133,12 @@ pub fn set_default_source(name: Arc) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetDefaultSink", (name.as_str(),)); // if res.is_err() { // return; // } diff --git a/src/components/output/inputStreamEntry.rs b/src/components/output/inputStreamEntry.rs index 24f79fd..ba09b87 100644 --- a/src/components/output/inputStreamEntry.rs +++ b/src/components/output/inputStreamEntry.rs @@ -157,12 +157,12 @@ fn set_inputstream_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetInputStreamVolume", (index, channels, value as u32), ); @@ -178,12 +178,12 @@ fn toggle_input_stream_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetInputStreamMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetInputStreamMute", (index, muted)); // if res.is_err() { // return false; // } @@ -196,12 +196,12 @@ fn set_sink_of_input_stream(stream: u32, sink: u32) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetSinkOfInputStream", (stream, sink)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetSinkOfInputStream", (stream, sink)); // if res.is_err() { // return false; // } diff --git a/src/components/output/sinkBox.rs b/src/components/output/sinkBox.rs index 117e124..a9cc7a1 100644 --- a/src/components/output/sinkBox.rs +++ b/src/components/output/sinkBox.rs @@ -254,12 +254,12 @@ pub fn populate_cards(output_box: Arc) { fn get_input_streams() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListInputStreams", ()); + proxy.method_call("org.Xetibo.ReSetAudio", "ListInputStreams", ()); if res.is_err() { return Vec::new(); } @@ -269,11 +269,11 @@ fn get_input_streams() -> Vec { fn get_sinks() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Vec,), Error> = proxy.method_call("org.xetibo.ReSet", "ListSinks", ()); + let res: Result<(Vec,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListSinks", ()); if res.is_err() { return Vec::new(); } @@ -283,11 +283,11 @@ fn get_sinks() -> Vec { fn get_default_sink() -> Sink { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Sink,), Error> = proxy.method_call("org.xetibo.ReSet", "GetDefaultSink", ()); + let res: Result<(Sink,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "GetDefaultSink", ()); if res.is_err() { return Sink::default(); } @@ -297,11 +297,11 @@ fn get_default_sink() -> Sink { fn get_cards() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let res: Result<(Vec,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ()); + let res: Result<(Vec,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ()); if res.is_err() { return Vec::new(); } @@ -310,33 +310,33 @@ fn get_cards() -> Vec { pub fn start_output_box_listener(conn: Connection, sink_box: Arc) -> Connection { let sink_added = SinkAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let sink_removed = SinkRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let sink_changed = SinkChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let input_stream_added = InputStreamAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let input_stream_removed = InputStreamRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let input_stream_changed = InputStreamChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); diff --git a/src/components/output/sinkEntry.rs b/src/components/output/sinkEntry.rs index 06fb6c0..31c0e2d 100644 --- a/src/components/output/sinkEntry.rs +++ b/src/components/output/sinkEntry.rs @@ -89,12 +89,12 @@ pub fn set_sink_volume(value: f64, index: u32, channels: u16) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetAudio", "SetSinkVolume", (index, channels, value as u32), ); @@ -110,12 +110,12 @@ pub fn toggle_sink_mute(index: u32, muted: bool) -> bool { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetSinkMute", (index, muted)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetSinkMute", (index, muted)); // if res.is_err() { // return false; // } @@ -128,12 +128,12 @@ pub fn set_default_sink(name: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),)); + proxy.method_call("org.Xetibo.ReSetAudio", "SetDefaultSink", (name.as_str(),)); // if res.is_err() { // return; // } diff --git a/src/components/utils.rs b/src/components/utils.rs index e218519..2162c9f 100644 --- a/src/components/utils.rs +++ b/src/components/utils.rs @@ -1,9 +1,12 @@ -use adw::ComboRow; +use std::time::Duration; + use adw::gdk::pango::EllipsizeMode; use adw::prelude::ListModelExtManual; +use adw::ComboRow; +use dbus::blocking::{Connection, Proxy}; use glib::{Cast, Object}; -use gtk::{Align, SignalListItemFactory, StringObject}; use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt}; +use gtk::{Align, SignalListItemFactory, StringObject}; pub fn createDropdownLabelFactory() -> SignalListItemFactory { let factory = SignalListItemFactory::new(); @@ -20,7 +23,13 @@ pub fn createDropdownLabelFactory() -> SignalListItemFactory { } pub fn setComboRowEllipsis(element: ComboRow) { - for (i, child) in element.child().unwrap().observe_children().iter::().enumerate() { + for (i, child) in element + .child() + .unwrap() + .observe_children() + .iter::() + .enumerate() + { if i == 2 { if let Ok(object) = child { if let Some(item) = object.downcast_ref::() { @@ -34,4 +43,4 @@ pub fn setComboRowEllipsis(element: ComboRow) { } } } -} \ No newline at end of file +} diff --git a/src/components/wifi/savedWifiEntry.rs b/src/components/wifi/savedWifiEntry.rs index 5546ebb..8c2137d 100644 --- a/src/components/wifi/savedWifiEntry.rs +++ b/src/components/wifi/savedWifiEntry.rs @@ -49,11 +49,11 @@ fn delete_connection(path: Path<'static>) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let _: Result<(), Error> = - proxy.method_call("org.xetibo.ReSet", "DeleteConnection", (path,)); + proxy.method_call("org.Xetibo.ReSetWireless", "DeleteConnection", (path,)); }); } diff --git a/src/components/wifi/utils.rs b/src/components/wifi/utils.rs index 3b0898e..a956e70 100644 --- a/src/components/wifi/utils.rs +++ b/src/components/wifi/utils.rs @@ -9,14 +9,14 @@ use ReSet_Lib::network::connection::Connection as ResetConnection; pub fn getConnectionSettings(path: Path<'static>) -> ResetConnection { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result< (HashMap>>>,), Error, - > = proxy.method_call("org.xetibo.ReSet", "GetConnectionSettings", (path,)); + > = proxy.method_call("org.xetibo.ReSetWireless", "GetConnectionSettings", (path,)); if res.is_err() { ResetConnection::default(); } diff --git a/src/components/wifi/wifiBox.rs b/src/components/wifi/wifiBox.rs index 4f0bfd7..ef13542 100644 --- a/src/components/wifi/wifiBox.rs +++ b/src/components/wifi/wifiBox.rs @@ -112,22 +112,22 @@ pub fn show_stored_connections(wifiBox: Arc) { pub fn dbus_start_network_events() { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); - let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StartNetworkListener", ()); + let _: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetWireless", "StartNetworkListener", ()); } pub fn get_access_points() -> Vec { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListAccessPoints", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "ListAccessPoints", ()); if res.is_err() { return Vec::new(); } @@ -138,12 +138,12 @@ pub fn get_access_points() -> Vec { pub fn get_stored_connections() -> Vec<(Path<'static>, Vec)> { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(1000), ); let res: Result<(Vec<(Path<'static>, Vec)>,), Error> = - proxy.method_call("org.xetibo.ReSet", "ListStoredConnections", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "ListStoredConnections", ()); if res.is_err() { println!("we got error..."); return Vec::new(); @@ -164,18 +164,18 @@ pub fn start_event_listener(listeners: Arc, wifi_box: Arc) { let removed_ref = wifi_box.clone(); let changed_ref = wifi_box.clone(); // TODO implement changed let access_point_added = AccessPointAdded::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let access_point_removed = AccessPointRemoved::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let access_point_changed = AccessPointChanged::match_rule( - Some(&"org.xetibo.ReSet".into()), - Some(&Path::from("/org/xetibo/ReSet")), + Some(&"org.Xetibo.ReSetDaemon".into()), + Some(&Path::from("/org/Xetibo/ReSetDaemon")), ) .static_clone(); let res = conn.add_match(access_point_added, move |ir: AccessPointAdded, _, _| { diff --git a/src/components/wifi/wifiEntry.rs b/src/components/wifi/wifiEntry.rs index ace6dec..b9228ad 100644 --- a/src/components/wifi/wifiEntry.rs +++ b/src/components/wifi/wifiEntry.rs @@ -95,12 +95,12 @@ pub fn click_disconnect(entry: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(10000), ); let res: Result<(bool,), Error> = - proxy.method_call("org.xetibo.ReSet", "DisconnectFromCurrentAccessPoint", ()); + proxy.method_call("org.Xetibo.ReSetWireless", "DisconnectFromCurrentAccessPoint", ()); if res.is_err() { println!("res of disconnect was error bro"); return; @@ -120,12 +120,12 @@ pub fn click_stored_network(entry: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(10000), ); let res: Result<(bool,), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetWireless", "ConnectToKnownAccessPoint", (access_point,), ); @@ -170,12 +170,12 @@ pub fn click_new_network(entry: Arc) { gio::spawn_blocking(move || { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(10000), ); let res: Result<(bool,), Error> = proxy.method_call( - "org.xetibo.ReSet", + "org.Xetibo.ReSetWireless", "ConnectToNewAccessPoint", (access_point, password), ); diff --git a/src/main.rs b/src/main.rs index 4054993..f5c6c4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,11 +58,11 @@ async fn daemon_check() { let handle = thread::spawn(|| { let conn = Connection::new_session().unwrap(); let proxy = conn.with_proxy( - "org.xetibo.ReSet", - "/org/xetibo/ReSet", + "org.Xetibo.ReSetDaemon", + "/org/Xetibo/ReSetDaemon", Duration::from_millis(100), ); - let res: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "Check", ()); + let res: Result<(), Error> = proxy.method_call("org.Xetibo.ReSetDaemon", "Check", ()); res }); let res = handle.join();