1use crate::{Connection, NM80211ApFlags, NM80211ApSecurityFlags, NM80211Mode, Object, ffi};
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "NMAccessPoint")]
122 pub struct AccessPoint(Object<ffi::NMAccessPoint, ffi::NMAccessPointClass>) @extends Object;
123
124 match fn {
125 type_ => || ffi::nm_access_point_get_type(),
126 }
127}
128
129impl AccessPoint {
130 #[doc(alias = "nm_access_point_connection_valid")]
142 pub fn connection_valid(&self, connection: &impl IsA<Connection>) -> bool {
143 unsafe {
144 from_glib(ffi::nm_access_point_connection_valid(
145 self.to_glib_none().0,
146 connection.as_ref().to_glib_none().0,
147 ))
148 }
149 }
150
151 #[doc(alias = "nm_access_point_filter_connections")]
174 pub fn filter_connections(&self, connections: &[Connection]) -> Vec<Connection> {
175 unsafe {
176 FromGlibPtrContainer::from_glib_full(ffi::nm_access_point_filter_connections(
177 self.to_glib_none().0,
178 connections.to_glib_none().0,
179 ))
180 }
181 }
182
183 #[cfg(feature = "v1_46")]
189 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
190 #[doc(alias = "nm_access_point_get_bandwidth")]
191 #[doc(alias = "get_bandwidth")]
192 pub fn bandwidth(&self) -> u32 {
193 unsafe { ffi::nm_access_point_get_bandwidth(self.to_glib_none().0) }
194 }
195
196 #[doc(alias = "nm_access_point_get_bssid")]
203 #[doc(alias = "get_bssid")]
204 pub fn bssid(&self) -> glib::GString {
205 unsafe { from_glib_none(ffi::nm_access_point_get_bssid(self.to_glib_none().0)) }
206 }
207
208 #[doc(alias = "nm_access_point_get_flags")]
214 #[doc(alias = "get_flags")]
215 pub fn flags(&self) -> NM80211ApFlags {
216 unsafe { from_glib(ffi::nm_access_point_get_flags(self.to_glib_none().0)) }
217 }
218
219 #[doc(alias = "nm_access_point_get_frequency")]
225 #[doc(alias = "get_frequency")]
226 pub fn frequency(&self) -> u32 {
227 unsafe { ffi::nm_access_point_get_frequency(self.to_glib_none().0) }
228 }
229
230 #[cfg(feature = "v1_2")]
238 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
239 #[doc(alias = "nm_access_point_get_last_seen")]
240 #[doc(alias = "get_last_seen")]
241 #[doc(alias = "last-seen")]
242 pub fn last_seen(&self) -> i32 {
243 unsafe { ffi::nm_access_point_get_last_seen(self.to_glib_none().0) }
244 }
245
246 #[doc(alias = "nm_access_point_get_max_bitrate")]
252 #[doc(alias = "get_max_bitrate")]
253 #[doc(alias = "max-bitrate")]
254 pub fn max_bitrate(&self) -> u32 {
255 unsafe { ffi::nm_access_point_get_max_bitrate(self.to_glib_none().0) }
256 }
257
258 #[doc(alias = "nm_access_point_get_mode")]
264 #[doc(alias = "get_mode")]
265 pub fn mode(&self) -> NM80211Mode {
266 unsafe { from_glib(ffi::nm_access_point_get_mode(self.to_glib_none().0)) }
267 }
268
269 #[doc(alias = "nm_access_point_get_rsn_flags")]
276 #[doc(alias = "get_rsn_flags")]
277 #[doc(alias = "rsn-flags")]
278 pub fn rsn_flags(&self) -> NM80211ApSecurityFlags {
279 unsafe { from_glib(ffi::nm_access_point_get_rsn_flags(self.to_glib_none().0)) }
280 }
281
282 #[doc(alias = "nm_access_point_get_strength")]
294 #[doc(alias = "get_strength")]
295 pub fn strength(&self) -> u8 {
296 unsafe { ffi::nm_access_point_get_strength(self.to_glib_none().0) }
297 }
298
299 #[doc(alias = "nm_access_point_get_wpa_flags")]
305 #[doc(alias = "get_wpa_flags")]
306 #[doc(alias = "wpa-flags")]
307 pub fn wpa_flags(&self) -> NM80211ApSecurityFlags {
308 unsafe { from_glib(ffi::nm_access_point_get_wpa_flags(self.to_glib_none().0)) }
309 }
310
311 #[cfg(feature = "v1_46")]
312 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
313 #[doc(alias = "bandwidth")]
314 pub fn connect_bandwidth_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
315 unsafe extern "C" fn notify_bandwidth_trampoline<F: Fn(&AccessPoint) + 'static>(
316 this: *mut ffi::NMAccessPoint,
317 _param_spec: glib::ffi::gpointer,
318 f: glib::ffi::gpointer,
319 ) {
320 let f: &F = &*(f as *const F);
321 f(&from_glib_borrow(this))
322 }
323 unsafe {
324 let f: Box_<F> = Box_::new(f);
325 connect_raw(
326 self.as_ptr() as *mut _,
327 c"notify::bandwidth".as_ptr() as *const _,
328 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
329 notify_bandwidth_trampoline::<F> as *const (),
330 )),
331 Box_::into_raw(f),
332 )
333 }
334 }
335
336 #[doc(alias = "bssid")]
337 pub fn connect_bssid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
338 unsafe extern "C" fn notify_bssid_trampoline<F: Fn(&AccessPoint) + 'static>(
339 this: *mut ffi::NMAccessPoint,
340 _param_spec: glib::ffi::gpointer,
341 f: glib::ffi::gpointer,
342 ) {
343 let f: &F = &*(f as *const F);
344 f(&from_glib_borrow(this))
345 }
346 unsafe {
347 let f: Box_<F> = Box_::new(f);
348 connect_raw(
349 self.as_ptr() as *mut _,
350 c"notify::bssid".as_ptr() as *const _,
351 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
352 notify_bssid_trampoline::<F> as *const (),
353 )),
354 Box_::into_raw(f),
355 )
356 }
357 }
358
359 #[doc(alias = "flags")]
360 pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
361 unsafe extern "C" fn notify_flags_trampoline<F: Fn(&AccessPoint) + 'static>(
362 this: *mut ffi::NMAccessPoint,
363 _param_spec: glib::ffi::gpointer,
364 f: glib::ffi::gpointer,
365 ) {
366 let f: &F = &*(f as *const F);
367 f(&from_glib_borrow(this))
368 }
369 unsafe {
370 let f: Box_<F> = Box_::new(f);
371 connect_raw(
372 self.as_ptr() as *mut _,
373 c"notify::flags".as_ptr() as *const _,
374 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
375 notify_flags_trampoline::<F> as *const (),
376 )),
377 Box_::into_raw(f),
378 )
379 }
380 }
381
382 #[doc(alias = "frequency")]
383 pub fn connect_frequency_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
384 unsafe extern "C" fn notify_frequency_trampoline<F: Fn(&AccessPoint) + 'static>(
385 this: *mut ffi::NMAccessPoint,
386 _param_spec: glib::ffi::gpointer,
387 f: glib::ffi::gpointer,
388 ) {
389 let f: &F = &*(f as *const F);
390 f(&from_glib_borrow(this))
391 }
392 unsafe {
393 let f: Box_<F> = Box_::new(f);
394 connect_raw(
395 self.as_ptr() as *mut _,
396 c"notify::frequency".as_ptr() as *const _,
397 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
398 notify_frequency_trampoline::<F> as *const (),
399 )),
400 Box_::into_raw(f),
401 )
402 }
403 }
404
405 #[cfg(feature = "v1_2")]
406 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
407 #[doc(alias = "last-seen")]
408 pub fn connect_last_seen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
409 unsafe extern "C" fn notify_last_seen_trampoline<F: Fn(&AccessPoint) + 'static>(
410 this: *mut ffi::NMAccessPoint,
411 _param_spec: glib::ffi::gpointer,
412 f: glib::ffi::gpointer,
413 ) {
414 let f: &F = &*(f as *const F);
415 f(&from_glib_borrow(this))
416 }
417 unsafe {
418 let f: Box_<F> = Box_::new(f);
419 connect_raw(
420 self.as_ptr() as *mut _,
421 c"notify::last-seen".as_ptr() as *const _,
422 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
423 notify_last_seen_trampoline::<F> as *const (),
424 )),
425 Box_::into_raw(f),
426 )
427 }
428 }
429
430 #[doc(alias = "max-bitrate")]
431 pub fn connect_max_bitrate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
432 unsafe extern "C" fn notify_max_bitrate_trampoline<F: Fn(&AccessPoint) + 'static>(
433 this: *mut ffi::NMAccessPoint,
434 _param_spec: glib::ffi::gpointer,
435 f: glib::ffi::gpointer,
436 ) {
437 let f: &F = &*(f as *const F);
438 f(&from_glib_borrow(this))
439 }
440 unsafe {
441 let f: Box_<F> = Box_::new(f);
442 connect_raw(
443 self.as_ptr() as *mut _,
444 c"notify::max-bitrate".as_ptr() as *const _,
445 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
446 notify_max_bitrate_trampoline::<F> as *const (),
447 )),
448 Box_::into_raw(f),
449 )
450 }
451 }
452
453 #[doc(alias = "mode")]
454 pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
455 unsafe extern "C" fn notify_mode_trampoline<F: Fn(&AccessPoint) + 'static>(
456 this: *mut ffi::NMAccessPoint,
457 _param_spec: glib::ffi::gpointer,
458 f: glib::ffi::gpointer,
459 ) {
460 let f: &F = &*(f as *const F);
461 f(&from_glib_borrow(this))
462 }
463 unsafe {
464 let f: Box_<F> = Box_::new(f);
465 connect_raw(
466 self.as_ptr() as *mut _,
467 c"notify::mode".as_ptr() as *const _,
468 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
469 notify_mode_trampoline::<F> as *const (),
470 )),
471 Box_::into_raw(f),
472 )
473 }
474 }
475
476 #[doc(alias = "rsn-flags")]
477 pub fn connect_rsn_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
478 unsafe extern "C" fn notify_rsn_flags_trampoline<F: Fn(&AccessPoint) + 'static>(
479 this: *mut ffi::NMAccessPoint,
480 _param_spec: glib::ffi::gpointer,
481 f: glib::ffi::gpointer,
482 ) {
483 let f: &F = &*(f as *const F);
484 f(&from_glib_borrow(this))
485 }
486 unsafe {
487 let f: Box_<F> = Box_::new(f);
488 connect_raw(
489 self.as_ptr() as *mut _,
490 c"notify::rsn-flags".as_ptr() as *const _,
491 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
492 notify_rsn_flags_trampoline::<F> as *const (),
493 )),
494 Box_::into_raw(f),
495 )
496 }
497 }
498
499 #[doc(alias = "ssid")]
500 pub fn connect_ssid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
501 unsafe extern "C" fn notify_ssid_trampoline<F: Fn(&AccessPoint) + 'static>(
502 this: *mut ffi::NMAccessPoint,
503 _param_spec: glib::ffi::gpointer,
504 f: glib::ffi::gpointer,
505 ) {
506 let f: &F = &*(f as *const F);
507 f(&from_glib_borrow(this))
508 }
509 unsafe {
510 let f: Box_<F> = Box_::new(f);
511 connect_raw(
512 self.as_ptr() as *mut _,
513 c"notify::ssid".as_ptr() as *const _,
514 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
515 notify_ssid_trampoline::<F> as *const (),
516 )),
517 Box_::into_raw(f),
518 )
519 }
520 }
521
522 #[doc(alias = "strength")]
523 pub fn connect_strength_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
524 unsafe extern "C" fn notify_strength_trampoline<F: Fn(&AccessPoint) + 'static>(
525 this: *mut ffi::NMAccessPoint,
526 _param_spec: glib::ffi::gpointer,
527 f: glib::ffi::gpointer,
528 ) {
529 let f: &F = &*(f as *const F);
530 f(&from_glib_borrow(this))
531 }
532 unsafe {
533 let f: Box_<F> = Box_::new(f);
534 connect_raw(
535 self.as_ptr() as *mut _,
536 c"notify::strength".as_ptr() as *const _,
537 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
538 notify_strength_trampoline::<F> as *const (),
539 )),
540 Box_::into_raw(f),
541 )
542 }
543 }
544
545 #[doc(alias = "wpa-flags")]
546 pub fn connect_wpa_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
547 unsafe extern "C" fn notify_wpa_flags_trampoline<F: Fn(&AccessPoint) + 'static>(
548 this: *mut ffi::NMAccessPoint,
549 _param_spec: glib::ffi::gpointer,
550 f: glib::ffi::gpointer,
551 ) {
552 let f: &F = &*(f as *const F);
553 f(&from_glib_borrow(this))
554 }
555 unsafe {
556 let f: Box_<F> = Box_::new(f);
557 connect_raw(
558 self.as_ptr() as *mut _,
559 c"notify::wpa-flags".as_ptr() as *const _,
560 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
561 notify_wpa_flags_trampoline::<F> as *const (),
562 )),
563 Box_::into_raw(f),
564 )
565 }
566 }
567}