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::*;
#[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);
}
#[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!(
#[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;
#[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;
#[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>;
);
}
impl WKExtension {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
);
}
extern "C" {
pub static WKApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
}
extern "C" {
pub static WKApplicationDidBecomeActiveNotification: &'static NSNotificationName;
}
extern "C" {
pub static WKApplicationWillResignActiveNotification: &'static NSNotificationName;
}
extern "C" {
pub static WKApplicationWillEnterForegroundNotification: &'static NSNotificationName;
}
extern "C" {
pub static WKApplicationDidEnterBackgroundNotification: &'static NSNotificationName;
}
extern_protocol!(
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);
#[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")]
#[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,
);
#[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,
);
#[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")]
#[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,
);
#[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);
}
);