mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-08 22:52:01 +02:00
feat: Implement new event API
This commit is contained in:
parent
9b93d22085
commit
35d2174136
|
@ -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"] }
|
||||
|
|
|
@ -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),
|
||||
);
|
||||
|
|
|
@ -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", ());
|
||||
}
|
||||
|
||||
|
|
|
@ -102,20 +102,25 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
|||
|
||||
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", "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();
|
||||
|
|
|
@ -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,));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
);
|
||||
|
|
|
@ -248,12 +248,12 @@ pub fn populate_cards(input_box: Arc<SourceBox>) {
|
|||
fn get_output_streams() -> Vec<OutputStream> {
|
||||
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<OutputStream>,), 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<OutputStream> {
|
|||
fn get_sources() -> Vec<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<(Vec<Source>,), 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<Source> {
|
|||
fn get_cards() -> Vec<Card> {
|
||||
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<Card>,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ());
|
||||
let res: Result<(Vec<Card>,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ());
|
||||
if res.is_err() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
@ -292,12 +292,12 @@ fn get_cards() -> Vec<Card> {
|
|||
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<SourceBox>) -> 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();
|
||||
|
||||
|
|
|
@ -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<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", "SetDefaultSink", (name.as_str(),));
|
||||
proxy.method_call("org.Xetibo.ReSetAudio", "SetDefaultSink", (name.as_str(),));
|
||||
// if res.is_err() {
|
||||
// return;
|
||||
// }
|
||||
|
|
|
@ -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;
|
||||
// }
|
||||
|
|
|
@ -254,12 +254,12 @@ pub fn populate_cards(output_box: Arc<SinkBox>) {
|
|||
fn get_input_streams() -> Vec<InputStream> {
|
||||
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<InputStream>,), 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<InputStream> {
|
|||
fn get_sinks() -> Vec<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<(Vec<Sink>,), Error> = proxy.method_call("org.xetibo.ReSet", "ListSinks", ());
|
||||
let res: Result<(Vec<Sink>,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListSinks", ());
|
||||
if res.is_err() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
@ -283,11 +283,11 @@ fn get_sinks() -> Vec<Sink> {
|
|||
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<Card> {
|
||||
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<Card>,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ());
|
||||
let res: Result<(Vec<Card>,), Error> = proxy.method_call("org.Xetibo.ReSetAudio", "ListCards", ());
|
||||
if res.is_err() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
@ -310,33 +310,33 @@ fn get_cards() -> Vec<Card> {
|
|||
|
||||
pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> 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();
|
||||
|
||||
|
|
|
@ -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<String>) {
|
|||
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;
|
||||
// }
|
||||
|
|
|
@ -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::<Object>().enumerate() {
|
||||
for (i, child) in element
|
||||
.child()
|
||||
.unwrap()
|
||||
.observe_children()
|
||||
.iter::<Object>()
|
||||
.enumerate()
|
||||
{
|
||||
if i == 2 {
|
||||
if let Ok(object) = child {
|
||||
if let Some(item) = object.downcast_ref::<gtk::Box>() {
|
||||
|
@ -34,4 +43,4 @@ pub fn setComboRowEllipsis(element: ComboRow) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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<String, HashMap<String, dbus::arg::Variant<Box<dyn RefArg>>>>,),
|
||||
Error,
|
||||
> = proxy.method_call("org.xetibo.ReSet", "GetConnectionSettings", (path,));
|
||||
> = proxy.method_call("org.xetibo.ReSetWireless", "GetConnectionSettings", (path,));
|
||||
if res.is_err() {
|
||||
ResetConnection::default();
|
||||
}
|
||||
|
|
|
@ -112,22 +112,22 @@ pub fn show_stored_connections(wifiBox: Arc<WifiBox>) {
|
|||
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<AccessPoint> {
|
||||
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<AccessPoint>,), 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<AccessPoint> {
|
|||
pub fn get_stored_connections() -> Vec<(Path<'static>, Vec<u8>)> {
|
||||
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<u8>)>,), 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<Listeners>, wifi_box: Arc<WifiBox>) {
|
|||
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, _, _| {
|
||||
|
|
|
@ -95,12 +95,12 @@ pub fn click_disconnect(entry: Arc<WifiEntry>) {
|
|||
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<WifiEntry>) {
|
|||
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<WifiEntry>) {
|
|||
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),
|
||||
);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue