Skip to content

Commit

Permalink
feat: Add DeleteConnection Command
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Nov 12, 2023
1 parent 8082b00 commit 905ab91
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
50 changes: 37 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod audio;
mod network;
mod bluetooth;
mod network;

use std::{
collections::HashMap,
Expand All @@ -17,18 +17,25 @@ use ReSet_Lib::{
audio::audio::{InputStream, OutputStream, Sink, Source},
bluetooth::bluetooth::BluetoothDevice,
network::network::{AccessPoint, Error},
utils::call_system_dbus_method,
};

// use crate::network::network::{
// get_connection_settings, list_connections, set_connection_settings, start_listener,
// stop_listener,
// get_connection_settings, list_connections, set_connection_settings, start_listener,
// stop_listener,
// };

// use bluetooth::bluetooth::BluetoothInterface;
use std::sync::mpsc::{self, Receiver, Sender};

use crate::{network::network::{Device, get_wifi_devices, list_connections, get_connection_settings, set_connection_settings, start_listener, stop_listener}, bluetooth::bluetooth::BluetoothInterface, audio::audio::PulseServer};

use crate::{
audio::audio::PulseServer,
bluetooth::bluetooth::BluetoothInterface,
network::network::{
get_connection_settings, get_stored_connections, get_wifi_devices, list_connections,
set_connection_settings, start_listener, stop_listener, Device,
},
};

pub enum AudioRequest {
ListSources,
Expand Down Expand Up @@ -149,14 +156,7 @@ pub async fn run_daemon() {
let access_point_removed = c
.signal::<(Path<'static>,), _>("AccessPointRemoved", ("access_point",))
.msg_fn();
c.method(
"Check",
(),
("result",),
move |_, _ , ()| {
Ok((true,))
},
);
c.method("Check", (), ("result",), move |_, _, ()| Ok((true,)));
c.method(
"ListAccessPoints",
(),
Expand Down Expand Up @@ -208,6 +208,10 @@ pub async fn run_daemon() {
let res = list_connections();
Ok((res,))
});
c.method("ListStoredConnections", (), ("result",), move |_, _, ()| {
let res = get_stored_connections();
Ok((res,))
});
c.method(
"GetConnectionSettings",
("path",),
Expand All @@ -230,6 +234,26 @@ pub async fn run_daemon() {
Ok((set_connection_settings(path, settings),))
},
);
c.method(
"DeleteConnection",
("path",),
("result",),
move |_, _, (path,): (Path<'static>,)| {
println!("called delete");
let res = call_system_dbus_method::<(), ()>(
"org.freedesktop.NetworkManager",
path,
"Delete",
"org.freedesktop.NetworkManager.Settings.Connection",
(),
1000,
);
if res.is_err() {
return Ok((false,));
}
Ok((true,))
},
);
c.method_with_cr_async(
"StartNetworkListener",
(),
Expand Down
1 change: 1 addition & 0 deletions src/network/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ pub fn get_stored_connections() -> Vec<(Path<'static>, Vec<u8>)> {
wifi_connections.push((connection, ssid));
}
}
dbg!(wifi_connections.clone());
wifi_connections
}

Expand Down

0 comments on commit 905ab91

Please sign in to comment.