objc2-watch-kit 0.3.2

Bindings to the WatchKit framework
Documentation
//! 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::*;
#[cfg(feature = "objc2-cloud-kit")]
use objc2_cloud_kit::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-health-kit")]
use objc2_health_kit::*;
#[cfg(feature = "objc2-intents")]
use objc2_intents::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct WKApplicationState(pub NSInteger);
impl WKApplicationState {
    #[doc(alias = "WKApplicationStateActive")]
    pub const Active: Self = Self(0);
    #[doc(alias = "WKApplicationStateInactive")]
    pub const Inactive: Self = Self(1);
    #[doc(alias = "WKApplicationStateBackground")]
    pub const Background: Self = Self(2);
}

unsafe impl Encode for WKApplicationState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkbackgroundfetchresult?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct WKBackgroundFetchResult(pub NSUInteger);
impl WKBackgroundFetchResult {
    #[doc(alias = "WKBackgroundFetchResultNewData")]
    pub const NewData: Self = Self(0);
    #[doc(alias = "WKBackgroundFetchResultNoData")]
    pub const NoData: Self = Self(1);
    #[doc(alias = "WKBackgroundFetchResultFailed")]
    pub const Failed: Self = Self(2);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkextension?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct WKExtension;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for WKExtension {}
);

impl WKExtension {
    extern_methods!(
        #[unsafe(method(sharedExtension))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedExtension(mtm: MainThreadMarker) -> Retained<WKExtension>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

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

        #[unsafe(method(openSystemURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn openSystemURL(&self, url: &NSURL);

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn WKExtensionDelegate>>>;

        #[cfg(feature = "WKInterfaceController")]
        #[unsafe(method(rootInterfaceController))]
        #[unsafe(method_family = none)]
        pub unsafe fn rootInterfaceController(&self) -> Option<Retained<WKInterfaceController>>;

        #[cfg(feature = "WKInterfaceController")]
        #[unsafe(method(visibleInterfaceController))]
        #[unsafe(method_family = none)]
        pub unsafe fn visibleInterfaceController(&self) -> Option<Retained<WKInterfaceController>>;

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

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

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

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

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

        #[deprecated = "No longer supported"]
        #[unsafe(method(isFrontmostTimeoutExtended))]
        #[unsafe(method_family = none)]
        pub unsafe fn isFrontmostTimeoutExtended(&self) -> bool;

        /// Setter for [`isFrontmostTimeoutExtended`][Self::isFrontmostTimeoutExtended].
        #[deprecated = "No longer supported"]
        #[unsafe(method(setFrontmostTimeoutExtended:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFrontmostTimeoutExtended(&self, frontmost_timeout_extended: bool);

        #[deprecated]
        #[unsafe(method(enableWaterLock))]
        #[unsafe(method_family = none)]
        pub unsafe fn enableWaterLock(&self);

        #[unsafe(method(registerForRemoteNotifications))]
        #[unsafe(method_family = none)]
        pub unsafe fn registerForRemoteNotifications(&self);

        #[unsafe(method(unregisterForRemoteNotifications))]
        #[unsafe(method_family = none)]
        pub unsafe fn unregisterForRemoteNotifications(&self);

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

        #[cfg(feature = "objc2-ui-kit")]
        #[unsafe(method(globalTintColor))]
        #[unsafe(method_family = none)]
        pub unsafe fn globalTintColor(&self) -> Retained<UIColor>;
    );
}

/// Methods declared on superclass `NSObject`.
impl WKExtension {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationdidfinishlaunchingnotification?language=objc)
    pub static WKApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationdidbecomeactivenotification?language=objc)
    pub static WKApplicationDidBecomeActiveNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationwillresignactivenotification?language=objc)
    pub static WKApplicationWillResignActiveNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationwillenterforegroundnotification?language=objc)
    pub static WKApplicationWillEnterForegroundNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationdidenterbackgroundnotification?language=objc)
    pub static WKApplicationDidEnterBackgroundNotification: &'static NSNotificationName;
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkextensiondelegate?language=objc)
    pub unsafe trait WKExtensionDelegate: NSObjectProtocol + MainThreadOnly {
        #[optional]
        #[unsafe(method(applicationDidFinishLaunching))]
        #[unsafe(method_family = none)]
        unsafe fn applicationDidFinishLaunching(&self);

        #[optional]
        #[unsafe(method(applicationDidBecomeActive))]
        #[unsafe(method_family = none)]
        unsafe fn applicationDidBecomeActive(&self);

        #[optional]
        #[unsafe(method(applicationWillResignActive))]
        #[unsafe(method_family = none)]
        unsafe fn applicationWillResignActive(&self);

        #[optional]
        #[unsafe(method(applicationWillEnterForeground))]
        #[unsafe(method_family = none)]
        unsafe fn applicationWillEnterForeground(&self);

        #[optional]
        #[unsafe(method(applicationDidEnterBackground))]
        #[unsafe(method_family = none)]
        unsafe fn applicationDidEnterBackground(&self);

        #[cfg(feature = "objc2-health-kit")]
        #[optional]
        #[unsafe(method(handleWorkoutConfiguration:))]
        #[unsafe(method_family = none)]
        unsafe fn handleWorkoutConfiguration(&self, workout_configuration: &HKWorkoutConfiguration);

        #[optional]
        #[unsafe(method(handleActiveWorkoutRecovery))]
        #[unsafe(method_family = none)]
        unsafe fn handleActiveWorkoutRecovery(&self);

        #[cfg(feature = "WKExtendedRuntimeSession")]
        #[optional]
        #[unsafe(method(handleExtendedRuntimeSession:))]
        #[unsafe(method_family = none)]
        unsafe fn handleExtendedRuntimeSession(
            &self,
            extended_runtime_session: &WKExtendedRuntimeSession,
        );

        #[optional]
        #[unsafe(method(handleRemoteNowPlayingActivity))]
        #[unsafe(method_family = none)]
        unsafe fn handleRemoteNowPlayingActivity(&self);

        /// # Safety
        ///
        /// `user_info` generic should be of the correct type.
        #[optional]
        #[unsafe(method(handleUserActivity:))]
        #[unsafe(method_family = none)]
        unsafe fn handleUserActivity(&self, user_info: Option<&NSDictionary>);

        #[optional]
        #[unsafe(method(handleActivity:))]
        #[unsafe(method_family = none)]
        unsafe fn handleActivity(&self, user_activity: &NSUserActivity);

        #[cfg(all(feature = "block2", feature = "objc2-intents"))]
        #[optional]
        #[unsafe(method(handleIntent:completionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn handleIntent_completionHandler(
            &self,
            intent: &INIntent,
            completion_handler: &block2::DynBlock<dyn Fn(NonNull<INIntentResponse>)>,
        );

        #[cfg(feature = "WKBackgroundTask")]
        #[optional]
        #[unsafe(method(handleBackgroundTasks:))]
        #[unsafe(method_family = none)]
        unsafe fn handleBackgroundTasks(&self, background_tasks: &NSSet<WKRefreshBackgroundTask>);

        #[optional]
        #[unsafe(method(deviceOrientationDidChange))]
        #[unsafe(method_family = none)]
        unsafe fn deviceOrientationDidChange(&self);

        #[optional]
        #[unsafe(method(didRegisterForRemoteNotificationsWithDeviceToken:))]
        #[unsafe(method_family = none)]
        unsafe fn didRegisterForRemoteNotificationsWithDeviceToken(&self, device_token: &NSData);

        #[optional]
        #[unsafe(method(didFailToRegisterForRemoteNotificationsWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn didFailToRegisterForRemoteNotificationsWithError(&self, error: &NSError);

        #[cfg(feature = "block2")]
        /// This delegate method offers an opportunity for applications with the "remote-notification" background mode to fetch appropriate new data in response to an incoming remote notification. You should call the fetchCompletionHandler as soon as you're finished performing that operation, so the system can accurately estimate its power and data cost.
        ///
        /// This method will be invoked even if the application was launched or resumed because of the remote background notification.!
        ///
        /// # Safety
        ///
        /// `user_info` generic should be of the correct type.
        #[optional]
        #[unsafe(method(didReceiveRemoteNotification:fetchCompletionHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn didReceiveRemoteNotification_fetchCompletionHandler(
            &self,
            user_info: &NSDictionary,
            completion_handler: &block2::DynBlock<dyn Fn(WKBackgroundFetchResult)>,
        );

        #[cfg(feature = "objc2-cloud-kit")]
        #[optional]
        #[unsafe(method(userDidAcceptCloudKitShareWithMetadata:))]
        #[unsafe(method_family = none)]
        unsafe fn userDidAcceptCloudKitShareWithMetadata(
            &self,
            cloud_kit_share_metadata: &CKShareMetadata,
        );

        /// # Safety
        ///
        /// `remote_notification` generic should be of the correct type.
        #[deprecated = "use UNUserNotificationCenterDelegate"]
        #[optional]
        #[unsafe(method(handleActionWithIdentifier:forRemoteNotification:))]
        #[unsafe(method_family = none)]
        unsafe fn handleActionWithIdentifier_forRemoteNotification(
            &self,
            identifier: Option<&NSString>,
            remote_notification: &NSDictionary,
        );

        #[cfg(feature = "objc2-ui-kit")]
        #[deprecated = "use UNUserNotificationCenterDelegate"]
        #[optional]
        #[unsafe(method(handleActionWithIdentifier:forLocalNotification:))]
        #[unsafe(method_family = none)]
        unsafe fn handleActionWithIdentifier_forLocalNotification(
            &self,
            identifier: Option<&NSString>,
            local_notification: &UILocalNotification,
        );

        /// # Safety
        ///
        /// - `remote_notification` generic should be of the correct type.
        /// - `response_info` generic should be of the correct type.
        #[deprecated = "use UNUserNotificationCenterDelegate"]
        #[optional]
        #[unsafe(method(handleActionWithIdentifier:forRemoteNotification:withResponseInfo:))]
        #[unsafe(method_family = none)]
        unsafe fn handleActionWithIdentifier_forRemoteNotification_withResponseInfo(
            &self,
            identifier: Option<&NSString>,
            remote_notification: &NSDictionary,
            response_info: &NSDictionary,
        );

        #[cfg(feature = "objc2-ui-kit")]
        /// # Safety
        ///
        /// `response_info` generic should be of the correct type.
        #[deprecated = "use UNUserNotificationCenterDelegate"]
        #[optional]
        #[unsafe(method(handleActionWithIdentifier:forLocalNotification:withResponseInfo:))]
        #[unsafe(method_family = none)]
        unsafe fn handleActionWithIdentifier_forLocalNotification_withResponseInfo(
            &self,
            identifier: Option<&NSString>,
            local_notification: &UILocalNotification,
            response_info: &NSDictionary,
        );

        /// # Safety
        ///
        /// `user_info` generic should be of the correct type.
        #[deprecated = "use UNUserNotificationCenterDelegate"]
        #[optional]
        #[unsafe(method(didReceiveRemoteNotification:))]
        #[unsafe(method_family = none)]
        unsafe fn didReceiveRemoteNotification(&self, user_info: &NSDictionary);

        #[cfg(feature = "objc2-ui-kit")]
        #[deprecated = "use UNUserNotificationCenterDelegate"]
        #[optional]
        #[unsafe(method(didReceiveLocalNotification:))]
        #[unsafe(method_family = none)]
        unsafe fn didReceiveLocalNotification(&self, notification: &UILocalNotification);
    }
);