// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ../../girs
// from ../../gtk-girs
// DO NOT EDIT

use crate::{ffi, nm};
use glib::{
    prelude::*,
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `bandwidth`
    ///  Readable
    ///
    ///
    /// #### `bssid`
    ///  Readable
    ///
    ///
    /// #### `frequency`
    ///  Readable
    ///
    ///
    /// #### `last-seen`
    ///  Readable
    ///
    ///
    /// #### `max-bitrate`
    ///  Readable
    ///
    ///
    /// #### `strength`
    ///  Readable
    ///
    ///
    /// #### `icon-name`
    ///  Readable | Writeable
    ///
    ///
    /// #### `mode`
    ///  Readable
    ///
    ///
    /// #### `flags`
    ///  Readable
    ///
    ///
    /// #### `rsn-flags`
    ///  Readable
    ///
    ///
    /// #### `wpa-flags`
    ///  Readable
    ///
    ///
    /// #### `requires-password`
    ///  Readable
    ///
    ///
    /// #### `ssid`
    ///  Readable
    ///
    /// # Implements
    ///
    /// [`AccessPointExt`][trait@crate::prelude::AccessPointExt]
    #[doc(alias = "AstalNetworkAccessPoint")]
    pub struct AccessPoint(Object<ffi::AstalNetworkAccessPoint, ffi::AstalNetworkAccessPointClass>);

    match fn {
        type_ => || ffi::astal_network_access_point_get_type(),
    }
}

impl AccessPoint {
    pub const NONE: Option<&'static AccessPoint> = None;

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`AccessPoint`] objects.
    ///
    /// This method returns an instance of [`AccessPointBuilder`](crate::builders::AccessPointBuilder) which can be used to create [`AccessPoint`] objects.
    pub fn builder() -> AccessPointBuilder {
        AccessPointBuilder::new()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`AccessPoint`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct AccessPointBuilder {
    builder: glib::object::ObjectBuilder<'static, AccessPoint>,
}

impl AccessPointBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
        Self {
            builder: self.builder.property("icon-name", icon_name.into()),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`AccessPoint`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> AccessPoint {
        assert_initialized_main_thread!();
        self.builder.build()
    }
}

/// Trait containing all [`struct@AccessPoint`] methods.
///
/// # Implementors
///
/// [`AccessPoint`][struct@crate::AccessPoint]
pub trait AccessPointExt: IsA<AccessPoint> + 'static {
    #[doc(alias = "astal_network_access_point_get_connections")]
    #[doc(alias = "get_connections")]
    fn connections(&self) -> Vec<nm::RemoteConnection> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::astal_network_access_point_get_connections(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_path")]
    #[doc(alias = "get_path")]
    fn path(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::astal_network_access_point_get_path(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_bandwidth")]
    #[doc(alias = "get_bandwidth")]
    fn bandwidth(&self) -> u32 {
        unsafe { ffi::astal_network_access_point_get_bandwidth(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "astal_network_access_point_get_bssid")]
    #[doc(alias = "get_bssid")]
    fn bssid(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::astal_network_access_point_get_bssid(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_frequency")]
    #[doc(alias = "get_frequency")]
    fn frequency(&self) -> u32 {
        unsafe { ffi::astal_network_access_point_get_frequency(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "astal_network_access_point_get_last_seen")]
    #[doc(alias = "get_last_seen")]
    fn last_seen(&self) -> i32 {
        unsafe { ffi::astal_network_access_point_get_last_seen(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "astal_network_access_point_get_max_bitrate")]
    #[doc(alias = "get_max_bitrate")]
    fn max_bitrate(&self) -> u32 {
        unsafe { ffi::astal_network_access_point_get_max_bitrate(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "astal_network_access_point_get_strength")]
    #[doc(alias = "get_strength")]
    fn strength(&self) -> u8 {
        unsafe { ffi::astal_network_access_point_get_strength(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "astal_network_access_point_get_icon_name")]
    #[doc(alias = "get_icon_name")]
    fn icon_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::astal_network_access_point_get_icon_name(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_mode")]
    #[doc(alias = "get_mode")]
    fn mode(&self) -> nm::NM80211Mode {
        unsafe {
            from_glib(ffi::astal_network_access_point_get_mode(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_flags")]
    #[doc(alias = "get_flags")]
    fn flags(&self) -> nm::NM80211ApFlags {
        unsafe {
            from_glib(ffi::astal_network_access_point_get_flags(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_rsn_flags")]
    #[doc(alias = "get_rsn_flags")]
    fn rsn_flags(&self) -> nm::NM80211ApSecurityFlags {
        unsafe {
            from_glib(ffi::astal_network_access_point_get_rsn_flags(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_wpa_flags")]
    #[doc(alias = "get_wpa_flags")]
    fn wpa_flags(&self) -> nm::NM80211ApSecurityFlags {
        unsafe {
            from_glib(ffi::astal_network_access_point_get_wpa_flags(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_requires_password")]
    #[doc(alias = "get_requires_password")]
    fn requires_password(&self) -> bool {
        unsafe {
            from_glib(ffi::astal_network_access_point_get_requires_password(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "astal_network_access_point_get_ssid")]
    #[doc(alias = "get_ssid")]
    fn ssid(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::astal_network_access_point_get_ssid(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "icon-name")]
    fn set_icon_name(&self, icon_name: Option<&str>) {
        ObjectExt::set_property(self.as_ref(), "icon-name", icon_name)
    }

    #[doc(alias = "bandwidth")]
    fn connect_bandwidth_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_bandwidth_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::bandwidth".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_bandwidth_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "bssid")]
    fn connect_bssid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_bssid_trampoline<P: IsA<AccessPoint>, F: Fn(&P) + 'static>(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::bssid".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_bssid_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "frequency")]
    fn connect_frequency_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_frequency_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::frequency".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_frequency_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "last-seen")]
    fn connect_last_seen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_last_seen_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::last-seen".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_last_seen_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "max-bitrate")]
    fn connect_max_bitrate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_bitrate_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::max-bitrate".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_max_bitrate_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "strength")]
    fn connect_strength_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_strength_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::strength".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_strength_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "icon-name")]
    fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_icon_name_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::icon-name".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_icon_name_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "mode")]
    fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_mode_trampoline<P: IsA<AccessPoint>, F: Fn(&P) + 'static>(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::mode".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_mode_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "flags")]
    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_flags_trampoline<P: IsA<AccessPoint>, F: Fn(&P) + 'static>(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::flags".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_flags_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "rsn-flags")]
    fn connect_rsn_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_rsn_flags_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::rsn-flags".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_rsn_flags_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "wpa-flags")]
    fn connect_wpa_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_wpa_flags_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::wpa-flags".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_wpa_flags_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "requires-password")]
    fn connect_requires_password_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_requires_password_trampoline<
            P: IsA<AccessPoint>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::requires-password".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_requires_password_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "ssid")]
    fn connect_ssid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_ssid_trampoline<P: IsA<AccessPoint>, F: Fn(&P) + 'static>(
            this: *mut ffi::AstalNetworkAccessPoint,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AccessPoint::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::ssid".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_ssid_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<AccessPoint>> AccessPointExt for O {}
