azalea_shell/service/dbus/network_manager/
proxy.rs1use std::collections::HashMap;
2
3use zbus::proxy;
4use zbus::zvariant::{OwnedObjectPath, OwnedValue};
5
6#[proxy(
12 default_service = "org.freedesktop.NetworkManager",
13 default_path = "/org/freedesktop/NetworkManager",
14 interface = "org.freedesktop.NetworkManager"
15)]
16pub trait NetworkManager {
17 async fn get_devices(&self) -> zbus::Result<Vec<OwnedObjectPath>>;
18 async fn get_all_devices(&self) -> zbus::Result<Vec<OwnedObjectPath>>;
19 fn sleep(&self, sleep: bool) -> zbus::Result<()>;
20 fn enable(&self, enable: bool) -> zbus::Result<()>;
21 fn deactivate_connection(
22 &self,
23 active_connection: OwnedObjectPath,
24 ) -> zbus::Result<Vec<OwnedObjectPath>>;
25 fn activate_connection(
26 &self,
27 connection: OwnedObjectPath,
28 device: OwnedObjectPath,
29 specific_object: OwnedObjectPath,
30 ) -> zbus::Result<OwnedObjectPath>;
31
32 #[zbus(property)]
33 fn active_connections(&self) -> zbus::Result<Vec<OwnedObjectPath>>;
34
35 #[zbus(property)]
36 fn networking_enabled(&self) -> zbus::Result<bool>;
37
38 #[zbus(property)]
39 fn wireless_enabled(&self) -> zbus::Result<bool>;
40
41 #[zbus(property)]
42 fn wwan_enabled(&self) -> zbus::Result<bool>;
43
44 #[zbus(property)]
45 fn version(&self) -> zbus::Result<String>;
46
47 #[zbus(property)]
48 fn state(&self) -> zbus::Result<NMState>;
49
50 #[zbus(property)]
51 fn connectivity(&self) -> zbus::Result<NMConnectivityState>;
52
53 #[zbus(signal)]
54 fn properties_changed(&self, properties: HashMap<String, OwnedValue>) -> zbus::Result<()>;
55}
56
57#[derive(
61 Default,
62 Clone,
63 Debug,
64 serde_repr::Serialize_repr,
65 serde_repr::Deserialize_repr,
66 OwnedValue,
67 zbus::zvariant::Type,
68)]
69#[repr(u32)]
70#[zvariant(signature = "u")]
71pub enum NMState {
72 #[default]
73 NMStateUnknown = 0,
75
76 NMStateAsleep = 10,
78
79 NMStateDisconnected = 20,
81
82 NMStateDisconnecting = 30,
84
85 NMStateConnecting = 40,
87
88 NMStateConnectedLocal = 50,
90
91 NMStateConnectedSite = 60,
93
94 NMStateConnectedGlobal = 70,
96}
97
98#[derive(
102 Default, Clone, Debug, serde_repr::Serialize_repr, serde_repr::Deserialize_repr, OwnedValue,
103)]
104#[repr(u32)]
105#[zvariant(signature = "u")]
106pub enum NMConnectivityState {
107 #[default]
108 NMConnectivityUnknown = 1,
110
111 NMConnectivityNone = 2,
113
114 NMConnectivityPortal = 3,
116
117 NMConnectivityLimited = 4,
119
120 NMConnectivityFull = 5,
122}
123
124#[derive(
128 PartialEq,
129 Default,
130 Clone,
131 Debug,
132 serde_repr::Serialize_repr,
133 serde_repr::Deserialize_repr,
134 OwnedValue,
135)]
136#[repr(u32)]
137#[zvariant(signature = "u")]
138pub enum NMDeviceState {
139 #[default]
140 NMDeviceStateUnknown = 0,
142
143 NMDeviceStateUnmanaged = 10,
145
146 NMDeviceStateUnavailable = 20,
150
151 NMDeviceStateDisconnected = 30,
153
154 NMDeviceStatePrepare = 40,
158
159 NMDeviceStateConfig = 50,
163
164 NMDeviceStateNeedAuth = 60,
167
168 NMDeviceStateIpConfig = 70,
171
172 NMDeviceStateIpCheck = 80,
176
177 NMDeviceStateSecondaries = 90,
180
181 NMDeviceStateActivated = 100,
183
184 NMDeviceStateDeactivating = 110,
187
188 NMDeviceStateFailed = 120,
191}
192
193#[derive(
197 Default, Clone, Debug, serde_repr::Serialize_repr, serde_repr::Deserialize_repr, OwnedValue,
198)]
199#[repr(u32)]
200#[zvariant(signature = "u")]
201pub enum NMDeviceType {
202 #[default]
203 NMDeviceTypeUnknown = 0,
204
205 NMDeviceTypeGeneric = 14,
206
207 NMDeviceTypeEthernet = 1,
208
209 NMDeviceTypeWifi = 2,
210
211 NMDeviceTypeUnused1 = 3,
212
213 NMDeviceTypeUnused2 = 4,
214
215 NMDeviceTypeBt = 5,
216
217 NMDeviceTypeOlpcMesh = 6,
218
219 NMDeviceTypeWimax = 7,
220
221 NMDeviceTypeModem = 8,
222
223 NMDeviceTypeInfiniband = 9,
224
225 NMDeviceTypeBond = 10,
226
227 NMDeviceTypeVlan = 11,
228
229 NMDeviceTypeAdsl = 12,
230
231 NMDeviceTypeBridge = 13,
232
233 NMDeviceTypeTeam = 15,
234
235 NMDeviceTypeTun = 16,
236
237 NMDeviceTypeIpTunnel = 17,
238
239 NMDeviceTypeMacvlan = 18,
240
241 NMDeviceTypeVxlan = 19,
242
243 NMDeviceTypeVeth = 20,
244}
245
246#[proxy(
250 default_service = "org.freedesktop.NetworkManager",
251 interface = "org.freedesktop.NetworkManager.Device"
252)]
253pub trait NetworkManagerDevice {
254 fn disconnect(&self) -> zbus::Result<()>;
255
256 #[zbus(property)]
257 fn state(&self) -> zbus::Result<NMDeviceState>;
258
259 #[zbus(property)]
260 fn device_type(&self) -> zbus::Result<NMDeviceType>;
261
262 #[zbus(property)]
263 fn interface(&self) -> zbus::Result<String>;
264
265 #[zbus(property)]
266 fn active_connection(&self) -> zbus::Result<OwnedObjectPath>;
267}
268
269#[proxy(
273 default_service = "org.freedesktop.NetworkManager",
274 default_path = "/org/freedesktop/NetworkManager/Settings",
275 interface = "org.freedesktop.NetworkManager.Settings"
276)]
277pub trait NetworkManagerSettings {
278 fn list_connections(&self) -> zbus::Result<Vec<OwnedObjectPath>>;
279
280 #[zbus(property)]
281 fn connections(&self) -> zbus::Result<Vec<OwnedObjectPath>>;
282}
283
284#[proxy(
288 default_service = "org.freedesktop.NetworkManager",
289 interface = "org.freedesktop.NetworkManager.Settings.Connection"
290)]
291pub trait NetworkManagerSettingsConnection {
292 fn get_settings(
296 &self,
297 ) -> zbus::Result<HashMap<String, HashMap<String, zbus::zvariant::OwnedValue>>>;
298}
299
300#[proxy(
304 default_service = "org.freedesktop.NetworkManager",
305 interface = "org.freedesktop.NetworkManager.Connection.Active"
306)]
307pub trait NetworkManagerConnectionActive {
308 #[zbus(property)]
310 fn connection(&self) -> zbus::Result<OwnedObjectPath>;
311}