mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-03 08:47:45 +02:00
feat: Implement new event API
This commit is contained in:
parent
9b93d22085
commit
35d2174136
17 changed files with 178 additions and 164 deletions
|
@ -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,));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue