//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistributednotificationcentertype?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "NSString")]
pub type NSDistributedNotificationCenterType = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nslocalnotificationcentertype?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSLocalNotificationCenterType: &'static NSDistributedNotificationCenterType;
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationsuspensionbehavior?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSNotificationSuspensionBehavior(pub NSUInteger);
impl NSNotificationSuspensionBehavior {
    #[doc(alias = "NSNotificationSuspensionBehaviorDrop")]
    pub const Drop: Self = Self(1);
    #[doc(alias = "NSNotificationSuspensionBehaviorCoalesce")]
    pub const Coalesce: Self = Self(2);
    #[doc(alias = "NSNotificationSuspensionBehaviorHold")]
    pub const Hold: Self = Self(3);
    #[doc(alias = "NSNotificationSuspensionBehaviorDeliverImmediately")]
    pub const DeliverImmediately: Self = Self(4);
}

unsafe impl Encode for NSNotificationSuspensionBehavior {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSNotificationSuspensionBehavior {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistributednotificationoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDistributedNotificationOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSDistributedNotificationOptions: NSUInteger {
        #[doc(alias = "NSDistributedNotificationDeliverImmediately")]
        const DeliverImmediately = 1<<0;
        #[doc(alias = "NSDistributedNotificationPostToAllSessions")]
        const PostToAllSessions = 1<<1;
    }
}

unsafe impl Encode for NSDistributedNotificationOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSDistributedNotificationOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationdeliverimmediately?language=objc)
pub static NSNotificationDeliverImmediately: NSDistributedNotificationOptions =
    NSDistributedNotificationOptions(NSDistributedNotificationOptions::DeliverImmediately.0);

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationposttoallsessions?language=objc)
pub static NSNotificationPostToAllSessions: NSDistributedNotificationOptions =
    NSDistributedNotificationOptions(NSDistributedNotificationOptions::PostToAllSessions.0);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistributednotificationcenter?language=objc)
    #[unsafe(super(NSNotificationCenter, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSNotification")]
    pub struct NSDistributedNotificationCenter;
);

#[cfg(feature = "NSNotification")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSDistributedNotificationCenter {}
);

#[cfg(feature = "NSNotification")]
impl NSDistributedNotificationCenter {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(notificationCenterForType:))]
        #[unsafe(method_family = none)]
        pub fn notificationCenterForType(
            notification_center_type: &NSDistributedNotificationCenterType,
        ) -> Retained<NSDistributedNotificationCenter>;

        #[unsafe(method(defaultCenter))]
        #[unsafe(method_family = none)]
        pub fn defaultCenter() -> Retained<NSDistributedNotificationCenter>;

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// - `observer` should be of the correct type.
        /// - `selector` must be a valid selector.
        #[unsafe(method(addObserver:selector:name:object:suspensionBehavior:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addObserver_selector_name_object_suspensionBehavior(
            &self,
            observer: &AnyObject,
            selector: Sel,
            name: Option<&NSNotificationName>,
            object: Option<&NSString>,
            suspension_behavior: NSNotificationSuspensionBehavior,
        );

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        /// # Safety
        ///
        /// `user_info` generic should be of the correct type.
        #[unsafe(method(postNotificationName:object:userInfo:deliverImmediately:))]
        #[unsafe(method_family = none)]
        pub unsafe fn postNotificationName_object_userInfo_deliverImmediately(
            &self,
            name: &NSNotificationName,
            object: Option<&NSString>,
            user_info: Option<&NSDictionary>,
            deliver_immediately: bool,
        );

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        /// # Safety
        ///
        /// `user_info` generic should be of the correct type.
        #[unsafe(method(postNotificationName:object:userInfo:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn postNotificationName_object_userInfo_options(
            &self,
            name: &NSNotificationName,
            object: Option<&NSString>,
            user_info: Option<&NSDictionary>,
            options: NSDistributedNotificationOptions,
        );

        #[unsafe(method(suspended))]
        #[unsafe(method_family = none)]
        pub fn suspended(&self) -> bool;

        /// Setter for [`suspended`][Self::suspended].
        #[unsafe(method(setSuspended:))]
        #[unsafe(method_family = none)]
        pub fn setSuspended(&self, suspended: bool);

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// - `observer` should be of the correct type.
        /// - `a_selector` must be a valid selector.
        #[unsafe(method(addObserver:selector:name:object:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addObserver_selector_name_object(
            &self,
            observer: &AnyObject,
            a_selector: Sel,
            a_name: Option<&NSNotificationName>,
            an_object: Option<&NSString>,
        );

        #[cfg(feature = "NSString")]
        #[unsafe(method(postNotificationName:object:))]
        #[unsafe(method_family = none)]
        pub unsafe fn postNotificationName_object(
            &self,
            a_name: &NSNotificationName,
            an_object: Option<&NSString>,
        );

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        /// # Safety
        ///
        /// `a_user_info` generic should be of the correct type.
        #[unsafe(method(postNotificationName:object:userInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn postNotificationName_object_userInfo(
            &self,
            a_name: &NSNotificationName,
            an_object: Option<&NSString>,
            a_user_info: Option<&NSDictionary>,
        );

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `observer` should be of the correct type.
        #[unsafe(method(removeObserver:name:object:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeObserver_name_object(
            &self,
            observer: &AnyObject,
            a_name: Option<&NSNotificationName>,
            an_object: Option<&NSString>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSNotification")]
impl NSDistributedNotificationCenter {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

#[cfg(feature = "NSNotification")]
impl DefaultRetained for NSDistributedNotificationCenter {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
