nm_rs/auto/setting_wifi_p2p.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Setting,SettingWirelessSecurityWpsMethod};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11 /// Wi-Fi P2P Settings
12 ///
13 /// ## Properties
14 ///
15 ///
16 /// #### `peer`
17 /// The P2P device that should be connected to. Currently, this is the only
18 /// way to create or join a group.
19 ///
20 /// Readable | Writeable
21 ///
22 ///
23 /// #### `wfd-ies`
24 /// The Wi-Fi Display (WFD) Information Elements (IEs) to set.
25 ///
26 /// Wi-Fi Display requires a protocol specific information element to be
27 /// set in certain Wi-Fi frames. These can be specified here for the
28 /// purpose of establishing a connection.
29 /// This setting is only useful when implementing a Wi-Fi Display client.
30 ///
31 /// Readable | Writeable
32 ///
33 ///
34 /// #### `wps-method`
35 /// Flags indicating which mode of WPS is to be used.
36 ///
37 /// There's little point in changing the default setting as NetworkManager will
38 /// automatically determine the best method to use.
39 ///
40 /// Readable | Writeable
41 /// <details><summary><h4>Setting</h4></summary>
42 ///
43 ///
44 /// #### `name`
45 /// The setting's name, which uniquely identifies the setting within the
46 /// connection. Each setting type has a name unique to that type, for
47 /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
48 ///
49 /// Readable
50 /// </details>
51 ///
52 /// # Implements
53 ///
54 /// [`SettingExt`][trait@crate::prelude::SettingExt]
55 #[doc(alias = "NMSettingWifiP2P")]
56 pub struct SettingWifiP2P(Object<ffi::NMSettingWifiP2P, ffi::NMSettingWifiP2PClass>) @extends Setting;
57
58 match fn {
59 type_ => || ffi::nm_setting_wifi_p2p_get_type(),
60 }
61}
62
63impl SettingWifiP2P {
64 /// Creates a new #NMSettingWifiP2P object with default values.
65 ///
66 /// # Returns
67 ///
68 /// the new empty #NMSettingWifiP2P object
69 #[doc(alias = "nm_setting_wifi_p2p_new")]
70 pub fn new() -> SettingWifiP2P {
71 assert_initialized_main_thread!();
72 unsafe {
73 Setting::from_glib_full(ffi::nm_setting_wifi_p2p_new()).unsafe_cast()
74 }
75 }
76
77 // rustdoc-stripper-ignore-next
78 /// Creates a new builder-pattern struct instance to construct [`SettingWifiP2P`] objects.
79 ///
80 /// This method returns an instance of [`SettingWifiP2PBuilder`](crate::builders::SettingWifiP2PBuilder) which can be used to create [`SettingWifiP2P`] objects.
81 pub fn builder() -> SettingWifiP2PBuilder {
82 SettingWifiP2PBuilder::new()
83 }
84
85
86 ///
87 /// # Returns
88 ///
89 /// the #NMSettingWifiP2P:peer property of the setting
90 #[doc(alias = "nm_setting_wifi_p2p_get_peer")]
91 #[doc(alias = "get_peer")]
92 pub fn peer(&self) -> glib::GString {
93 unsafe {
94 from_glib_none(ffi::nm_setting_wifi_p2p_get_peer(self.to_glib_none().0))
95 }
96 }
97
98 //#[doc(alias = "nm_setting_wifi_p2p_get_wfd_ies")]
99 //#[doc(alias = "get_wfd_ies")]
100 //#[doc(alias = "wfd-ies")]
101 //pub fn wfd_ies(&self) -> /*Ignored*/glib::Bytes {
102 // unsafe { TODO: call ffi:nm_setting_wifi_p2p_get_wfd_ies() }
103 //}
104
105 ///
106 /// # Returns
107 ///
108 /// the #NMSettingWifiP2P:wps-method property of the setting
109 #[doc(alias = "nm_setting_wifi_p2p_get_wps_method")]
110 #[doc(alias = "get_wps_method")]
111 #[doc(alias = "wps-method")]
112 pub fn wps_method(&self) -> SettingWirelessSecurityWpsMethod {
113 unsafe {
114 from_glib(ffi::nm_setting_wifi_p2p_get_wps_method(self.to_glib_none().0))
115 }
116 }
117
118 /// The P2P device that should be connected to. Currently, this is the only
119 /// way to create or join a group.
120 #[cfg(feature = "v1_16")]
121 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
122 pub fn set_peer(&self, peer: Option<&str>) {
123 ObjectExt::set_property(self,"peer", peer)
124 }
125
126 //#[cfg(feature = "v1_16")]
127 //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
128 //#[doc(alias = "wfd-ies")]
129 //pub fn set_wfd_ies(&self, wfd_ies: /*Ignored*/Option<&glib::Bytes>) {
130 // ObjectExt::set_property(self,"wfd-ies", wfd_ies)
131 //}
132
133 /// Flags indicating which mode of WPS is to be used.
134 ///
135 /// There's little point in changing the default setting as NetworkManager will
136 /// automatically determine the best method to use.
137 #[cfg(feature = "v1_16")]
138 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
139 #[doc(alias = "wps-method")]
140 pub fn set_wps_method(&self, wps_method: u32) {
141 ObjectExt::set_property(self,"wps-method", wps_method)
142 }
143
144 #[cfg(feature = "v1_16")]
145 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
146 #[doc(alias = "peer")]
147 pub fn connect_peer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
148 unsafe extern "C" fn notify_peer_trampoline<F: Fn(&SettingWifiP2P) + 'static>(this: *mut ffi::NMSettingWifiP2P, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
149 let f: &F = &*(f as *const F);
150 f(&from_glib_borrow(this))
151 }
152 unsafe {
153 let f: Box_<F> = Box_::new(f);
154 connect_raw(self.as_ptr() as *mut _, c"notify::peer".as_ptr() as *const _,
155 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_peer_trampoline::<F> as *const ())), Box_::into_raw(f))
156 }
157 }
158
159 #[cfg(feature = "v1_16")]
160 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
161 #[doc(alias = "wfd-ies")]
162 pub fn connect_wfd_ies_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
163 unsafe extern "C" fn notify_wfd_ies_trampoline<F: Fn(&SettingWifiP2P) + 'static>(this: *mut ffi::NMSettingWifiP2P, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
164 let f: &F = &*(f as *const F);
165 f(&from_glib_borrow(this))
166 }
167 unsafe {
168 let f: Box_<F> = Box_::new(f);
169 connect_raw(self.as_ptr() as *mut _, c"notify::wfd-ies".as_ptr() as *const _,
170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_wfd_ies_trampoline::<F> as *const ())), Box_::into_raw(f))
171 }
172 }
173
174 #[cfg(feature = "v1_16")]
175 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
176 #[doc(alias = "wps-method")]
177 pub fn connect_wps_method_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
178 unsafe extern "C" fn notify_wps_method_trampoline<F: Fn(&SettingWifiP2P) + 'static>(this: *mut ffi::NMSettingWifiP2P, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
179 let f: &F = &*(f as *const F);
180 f(&from_glib_borrow(this))
181 }
182 unsafe {
183 let f: Box_<F> = Box_::new(f);
184 connect_raw(self.as_ptr() as *mut _, c"notify::wps-method".as_ptr() as *const _,
185 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_wps_method_trampoline::<F> as *const ())), Box_::into_raw(f))
186 }
187 }
188}
189
190#[cfg(feature = "v1_16")]
191#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
192impl Default for SettingWifiP2P {
193 fn default() -> Self {
194 Self::new()
195 }
196 }
197
198// rustdoc-stripper-ignore-next
199 /// A [builder-pattern] type to construct [`SettingWifiP2P`] objects.
200 ///
201 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
202#[must_use = "The builder must be built to be used"]
203pub struct SettingWifiP2PBuilder {
204 builder: glib::object::ObjectBuilder<'static, SettingWifiP2P>,
205 }
206
207 impl SettingWifiP2PBuilder {
208 fn new() -> Self {
209 Self { builder: glib::object::Object::builder() }
210 }
211
212 /// The P2P device that should be connected to. Currently, this is the only
213 /// way to create or join a group.
214 #[cfg(feature = "v1_16")]
215 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
216 pub fn peer(self, peer: impl Into<glib::GString>) -> Self {
217 Self { builder: self.builder.property("peer", peer.into()), }
218 }
219
220 // #[cfg(feature = "v1_16")]
221 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
222 //pub fn wfd_ies(self, wfd_ies: /*Ignored*/&glib::Bytes) -> Self {
223 // Self { builder: self.builder.property("wfd-ies", wfd_ies), }
224 //}
225
226 /// Flags indicating which mode of WPS is to be used.
227 ///
228 /// There's little point in changing the default setting as NetworkManager will
229 /// automatically determine the best method to use.
230 #[cfg(feature = "v1_16")]
231 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
232 pub fn wps_method(self, wps_method: u32) -> Self {
233 Self { builder: self.builder.property("wps-method", wps_method), }
234 }
235
236 // rustdoc-stripper-ignore-next
237 /// Build the [`SettingWifiP2P`].
238 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
239 pub fn build(self) -> SettingWifiP2P {
240assert_initialized_main_thread!();
241 self.builder.build() }
242}