mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-12-15 18:11:38 +01:00
chore: refactor wifi and bluetooth event handlers
This commit is contained in:
parent
0105956815
commit
0fe99fa3a6
8 changed files with 222 additions and 187 deletions
|
|
@ -66,12 +66,7 @@ impl SavedWifiEntry {
|
|||
fn delete_connection(path: Path<'static>) {
|
||||
gio::spawn_blocking(move || {
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
BASE,
|
||||
DBUS_PATH,
|
||||
Duration::from_millis(1000),
|
||||
);
|
||||
let _: Result<(), Error> =
|
||||
proxy.method_call(WIRELESS, "DeleteConnection", (path,));
|
||||
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(1000));
|
||||
let _: Result<(), Error> = proxy.method_call(WIRELESS, "DeleteConnection", (path,));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,13 +22,8 @@ type ResultType =
|
|||
|
||||
pub fn get_connection_settings(path: Path<'static>) -> ResetConnection {
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
BASE,
|
||||
DBUS_PATH,
|
||||
Duration::from_millis(1000),
|
||||
);
|
||||
let res: ResultType =
|
||||
proxy.method_call(WIRELESS, "GetConnectionSettings", (path,));
|
||||
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(1000));
|
||||
let res: ResultType = proxy.method_call(WIRELESS, "GetConnectionSettings", (path,));
|
||||
if res.is_err() {
|
||||
ResetConnection::default();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -389,15 +389,8 @@ fn setup_callbacks(wifi_options: &Arc<WifiOptions>, path: Path<'static>) {
|
|||
fn set_connection_settings(path: Path<'static>, prop: HashMap<String, PropMap>) {
|
||||
gio::spawn_blocking(move || {
|
||||
let conn = dbus::blocking::Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
BASE,
|
||||
DBUS_PATH,
|
||||
Duration::from_millis(1000),
|
||||
);
|
||||
let _: Result<(bool,), Error> = proxy.method_call(
|
||||
WIRELESS,
|
||||
"SetConnectionSettings",
|
||||
(path, prop),
|
||||
);
|
||||
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(1000));
|
||||
let _: Result<(bool,), Error> =
|
||||
proxy.method_call(WIRELESS, "SetConnectionSettings", (path, prop));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue