objc2_core_foundation/generated/
CFUserNotification.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfusernotification?language=objc)
13#[doc(alias = "CFUserNotificationRef")]
14#[repr(C)]
15pub struct CFUserNotification {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    unsafe impl CFUserNotification {}
22);
23#[cfg(feature = "objc2")]
24cf_objc2_type!(
25    unsafe impl RefEncode<"__CFUserNotification"> for CFUserNotification {}
26);
27
28/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfusernotificationcallback?language=objc)
29pub type CFUserNotificationCallBack =
30    Option<unsafe extern "C-unwind" fn(*mut CFUserNotification, CFOptionFlags)>;
31
32unsafe impl ConcreteType for CFUserNotification {
33    #[doc(alias = "CFUserNotificationGetTypeID")]
34    #[inline]
35    fn type_id() -> CFTypeID {
36        extern "C-unwind" {
37            fn CFUserNotificationGetTypeID() -> CFTypeID;
38        }
39        unsafe { CFUserNotificationGetTypeID() }
40    }
41}
42
43impl CFUserNotification {
44    /// # Safety
45    ///
46    /// - `allocator` might not allow `None`.
47    /// - `error` must be a valid pointer.
48    /// - `dictionary` generics must be of the correct type.
49    /// - `dictionary` might not allow `None`.
50    #[doc(alias = "CFUserNotificationCreate")]
51    #[cfg(all(feature = "CFDate", feature = "CFDictionary"))]
52    #[inline]
53    pub unsafe fn new(
54        allocator: Option<&CFAllocator>,
55        timeout: CFTimeInterval,
56        flags: CFOptionFlags,
57        error: *mut i32,
58        dictionary: Option<&CFDictionary>,
59    ) -> Option<CFRetained<CFUserNotification>> {
60        extern "C-unwind" {
61            fn CFUserNotificationCreate(
62                allocator: Option<&CFAllocator>,
63                timeout: CFTimeInterval,
64                flags: CFOptionFlags,
65                error: *mut i32,
66                dictionary: Option<&CFDictionary>,
67            ) -> Option<NonNull<CFUserNotification>>;
68        }
69        let ret = unsafe { CFUserNotificationCreate(allocator, timeout, flags, error, dictionary) };
70        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
71    }
72
73    /// # Safety
74    ///
75    /// `response_flags` must be a valid pointer.
76    #[doc(alias = "CFUserNotificationReceiveResponse")]
77    #[cfg(feature = "CFDate")]
78    #[inline]
79    pub unsafe fn receive_response(
80        &self,
81        timeout: CFTimeInterval,
82        response_flags: *mut CFOptionFlags,
83    ) -> i32 {
84        extern "C-unwind" {
85            fn CFUserNotificationReceiveResponse(
86                user_notification: &CFUserNotification,
87                timeout: CFTimeInterval,
88                response_flags: *mut CFOptionFlags,
89            ) -> i32;
90        }
91        unsafe { CFUserNotificationReceiveResponse(self, timeout, response_flags) }
92    }
93
94    /// # Safety
95    ///
96    /// `key` might not allow `None`.
97    #[doc(alias = "CFUserNotificationGetResponseValue")]
98    #[inline]
99    pub unsafe fn response_value(
100        &self,
101        key: Option<&CFString>,
102        idx: CFIndex,
103    ) -> Option<CFRetained<CFString>> {
104        extern "C-unwind" {
105            fn CFUserNotificationGetResponseValue(
106                user_notification: &CFUserNotification,
107                key: Option<&CFString>,
108                idx: CFIndex,
109            ) -> Option<NonNull<CFString>>;
110        }
111        let ret = unsafe { CFUserNotificationGetResponseValue(self, key, idx) };
112        ret.map(|ret| unsafe { CFRetained::retain(ret) })
113    }
114
115    #[doc(alias = "CFUserNotificationGetResponseDictionary")]
116    #[cfg(feature = "CFDictionary")]
117    #[inline]
118    pub fn response_dictionary(&self) -> Option<CFRetained<CFDictionary>> {
119        extern "C-unwind" {
120            fn CFUserNotificationGetResponseDictionary(
121                user_notification: &CFUserNotification,
122            ) -> Option<NonNull<CFDictionary>>;
123        }
124        let ret = unsafe { CFUserNotificationGetResponseDictionary(self) };
125        ret.map(|ret| unsafe { CFRetained::retain(ret) })
126    }
127
128    /// # Safety
129    ///
130    /// - `dictionary` generics must be of the correct type.
131    /// - `dictionary` might not allow `None`.
132    #[doc(alias = "CFUserNotificationUpdate")]
133    #[cfg(all(feature = "CFDate", feature = "CFDictionary"))]
134    #[inline]
135    pub unsafe fn update(
136        &self,
137        timeout: CFTimeInterval,
138        flags: CFOptionFlags,
139        dictionary: Option<&CFDictionary>,
140    ) -> i32 {
141        extern "C-unwind" {
142            fn CFUserNotificationUpdate(
143                user_notification: &CFUserNotification,
144                timeout: CFTimeInterval,
145                flags: CFOptionFlags,
146                dictionary: Option<&CFDictionary>,
147            ) -> i32;
148        }
149        unsafe { CFUserNotificationUpdate(self, timeout, flags, dictionary) }
150    }
151
152    #[doc(alias = "CFUserNotificationCancel")]
153    #[inline]
154    pub fn cancel(&self) -> i32 {
155        extern "C-unwind" {
156            fn CFUserNotificationCancel(user_notification: &CFUserNotification) -> i32;
157        }
158        unsafe { CFUserNotificationCancel(self) }
159    }
160
161    /// # Safety
162    ///
163    /// - `allocator` might not allow `None`.
164    /// - `user_notification` might not allow `None`.
165    /// - `callout` must be implemented correctly.
166    #[doc(alias = "CFUserNotificationCreateRunLoopSource")]
167    #[cfg(feature = "CFRunLoop")]
168    #[inline]
169    pub unsafe fn new_run_loop_source(
170        allocator: Option<&CFAllocator>,
171        user_notification: Option<&CFUserNotification>,
172        callout: CFUserNotificationCallBack,
173        order: CFIndex,
174    ) -> Option<CFRetained<CFRunLoopSource>> {
175        extern "C-unwind" {
176            fn CFUserNotificationCreateRunLoopSource(
177                allocator: Option<&CFAllocator>,
178                user_notification: Option<&CFUserNotification>,
179                callout: CFUserNotificationCallBack,
180                order: CFIndex,
181            ) -> Option<NonNull<CFRunLoopSource>>;
182        }
183        let ret = unsafe {
184            CFUserNotificationCreateRunLoopSource(allocator, user_notification, callout, order)
185        };
186        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
187    }
188
189    #[doc(alias = "CFUserNotificationDisplayNotice")]
190    #[cfg(all(feature = "CFDate", feature = "CFURL"))]
191    #[inline]
192    pub fn display_notice(
193        timeout: CFTimeInterval,
194        flags: CFOptionFlags,
195        icon_url: Option<&CFURL>,
196        sound_url: Option<&CFURL>,
197        localization_url: Option<&CFURL>,
198        alert_header: Option<&CFString>,
199        alert_message: Option<&CFString>,
200        default_button_title: Option<&CFString>,
201    ) -> i32 {
202        extern "C-unwind" {
203            fn CFUserNotificationDisplayNotice(
204                timeout: CFTimeInterval,
205                flags: CFOptionFlags,
206                icon_url: Option<&CFURL>,
207                sound_url: Option<&CFURL>,
208                localization_url: Option<&CFURL>,
209                alert_header: Option<&CFString>,
210                alert_message: Option<&CFString>,
211                default_button_title: Option<&CFString>,
212            ) -> i32;
213        }
214        unsafe {
215            CFUserNotificationDisplayNotice(
216                timeout,
217                flags,
218                icon_url,
219                sound_url,
220                localization_url,
221                alert_header,
222                alert_message,
223                default_button_title,
224            )
225        }
226    }
227
228    /// # Safety
229    ///
230    /// - `icon_url` might not allow `None`.
231    /// - `sound_url` might not allow `None`.
232    /// - `localization_url` might not allow `None`.
233    /// - `alert_header` might not allow `None`.
234    /// - `alert_message` might not allow `None`.
235    /// - `default_button_title` might not allow `None`.
236    /// - `alternate_button_title` might not allow `None`.
237    /// - `other_button_title` might not allow `None`.
238    /// - `response_flags` must be a valid pointer.
239    #[doc(alias = "CFUserNotificationDisplayAlert")]
240    #[cfg(all(feature = "CFDate", feature = "CFURL"))]
241    #[inline]
242    pub unsafe fn display_alert(
243        timeout: CFTimeInterval,
244        flags: CFOptionFlags,
245        icon_url: Option<&CFURL>,
246        sound_url: Option<&CFURL>,
247        localization_url: Option<&CFURL>,
248        alert_header: Option<&CFString>,
249        alert_message: Option<&CFString>,
250        default_button_title: Option<&CFString>,
251        alternate_button_title: Option<&CFString>,
252        other_button_title: Option<&CFString>,
253        response_flags: *mut CFOptionFlags,
254    ) -> i32 {
255        extern "C-unwind" {
256            fn CFUserNotificationDisplayAlert(
257                timeout: CFTimeInterval,
258                flags: CFOptionFlags,
259                icon_url: Option<&CFURL>,
260                sound_url: Option<&CFURL>,
261                localization_url: Option<&CFURL>,
262                alert_header: Option<&CFString>,
263                alert_message: Option<&CFString>,
264                default_button_title: Option<&CFString>,
265                alternate_button_title: Option<&CFString>,
266                other_button_title: Option<&CFString>,
267                response_flags: *mut CFOptionFlags,
268            ) -> i32;
269        }
270        unsafe {
271            CFUserNotificationDisplayAlert(
272                timeout,
273                flags,
274                icon_url,
275                sound_url,
276                localization_url,
277                alert_header,
278                alert_message,
279                default_button_title,
280                alternate_button_title,
281                other_button_title,
282                response_flags,
283            )
284        }
285    }
286}
287
288/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationstopalertlevel?language=objc)
289pub const kCFUserNotificationStopAlertLevel: CFOptionFlags = 0;
290/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationnotealertlevel?language=objc)
291pub const kCFUserNotificationNoteAlertLevel: CFOptionFlags = 1;
292/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationcautionalertlevel?language=objc)
293pub const kCFUserNotificationCautionAlertLevel: CFOptionFlags = 2;
294/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationplainalertlevel?language=objc)
295pub const kCFUserNotificationPlainAlertLevel: CFOptionFlags = 3;
296
297/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationdefaultresponse?language=objc)
298pub const kCFUserNotificationDefaultResponse: CFOptionFlags = 0;
299/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationalternateresponse?language=objc)
300pub const kCFUserNotificationAlternateResponse: CFOptionFlags = 1;
301/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationotherresponse?language=objc)
302pub const kCFUserNotificationOtherResponse: CFOptionFlags = 2;
303/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationcancelresponse?language=objc)
304pub const kCFUserNotificationCancelResponse: CFOptionFlags = 3;
305
306/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationnodefaultbuttonflag?language=objc)
307pub const kCFUserNotificationNoDefaultButtonFlag: CFOptionFlags = 1 << 5;
308/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationuseradiobuttonsflag?language=objc)
309pub const kCFUserNotificationUseRadioButtonsFlag: CFOptionFlags = 1 << 6;
310
311extern "C" {
312    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationiconurlkey?language=objc)
313    pub static kCFUserNotificationIconURLKey: Option<&'static CFString>;
314}
315
316extern "C" {
317    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationsoundurlkey?language=objc)
318    pub static kCFUserNotificationSoundURLKey: Option<&'static CFString>;
319}
320
321extern "C" {
322    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationlocalizationurlkey?language=objc)
323    pub static kCFUserNotificationLocalizationURLKey: Option<&'static CFString>;
324}
325
326extern "C" {
327    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationalertheaderkey?language=objc)
328    pub static kCFUserNotificationAlertHeaderKey: Option<&'static CFString>;
329}
330
331extern "C" {
332    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationalertmessagekey?language=objc)
333    pub static kCFUserNotificationAlertMessageKey: Option<&'static CFString>;
334}
335
336extern "C" {
337    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationdefaultbuttontitlekey?language=objc)
338    pub static kCFUserNotificationDefaultButtonTitleKey: Option<&'static CFString>;
339}
340
341extern "C" {
342    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationalternatebuttontitlekey?language=objc)
343    pub static kCFUserNotificationAlternateButtonTitleKey: Option<&'static CFString>;
344}
345
346extern "C" {
347    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationotherbuttontitlekey?language=objc)
348    pub static kCFUserNotificationOtherButtonTitleKey: Option<&'static CFString>;
349}
350
351extern "C" {
352    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationprogressindicatorvaluekey?language=objc)
353    pub static kCFUserNotificationProgressIndicatorValueKey: Option<&'static CFString>;
354}
355
356extern "C" {
357    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationpopuptitleskey?language=objc)
358    pub static kCFUserNotificationPopUpTitlesKey: Option<&'static CFString>;
359}
360
361extern "C" {
362    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationtextfieldtitleskey?language=objc)
363    pub static kCFUserNotificationTextFieldTitlesKey: Option<&'static CFString>;
364}
365
366extern "C" {
367    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationcheckboxtitleskey?language=objc)
368    pub static kCFUserNotificationCheckBoxTitlesKey: Option<&'static CFString>;
369}
370
371extern "C" {
372    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationtextfieldvalueskey?language=objc)
373    pub static kCFUserNotificationTextFieldValuesKey: Option<&'static CFString>;
374}
375
376extern "C" {
377    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationpopupselectionkey?language=objc)
378    pub static kCFUserNotificationPopUpSelectionKey: Option<&'static CFString>;
379}
380
381extern "C" {
382    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationalerttopmostkey?language=objc)
383    pub static kCFUserNotificationAlertTopMostKey: Option<&'static CFString>;
384}
385
386extern "C" {
387    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfusernotificationkeyboardtypeskey?language=objc)
388    pub static kCFUserNotificationKeyboardTypesKey: Option<&'static CFString>;
389}
390
391#[cfg(all(feature = "CFDate", feature = "CFDictionary"))]
392#[deprecated = "renamed to `CFUserNotification::new`"]
393#[inline]
394pub unsafe extern "C-unwind" fn CFUserNotificationCreate(
395    allocator: Option<&CFAllocator>,
396    timeout: CFTimeInterval,
397    flags: CFOptionFlags,
398    error: *mut i32,
399    dictionary: Option<&CFDictionary>,
400) -> Option<CFRetained<CFUserNotification>> {
401    extern "C-unwind" {
402        fn CFUserNotificationCreate(
403            allocator: Option<&CFAllocator>,
404            timeout: CFTimeInterval,
405            flags: CFOptionFlags,
406            error: *mut i32,
407            dictionary: Option<&CFDictionary>,
408        ) -> Option<NonNull<CFUserNotification>>;
409    }
410    let ret = unsafe { CFUserNotificationCreate(allocator, timeout, flags, error, dictionary) };
411    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
412}
413
414extern "C-unwind" {
415    #[cfg(feature = "CFDate")]
416    #[deprecated = "renamed to `CFUserNotification::receive_response`"]
417    pub fn CFUserNotificationReceiveResponse(
418        user_notification: &CFUserNotification,
419        timeout: CFTimeInterval,
420        response_flags: *mut CFOptionFlags,
421    ) -> i32;
422}
423
424#[deprecated = "renamed to `CFUserNotification::response_value`"]
425#[inline]
426pub unsafe extern "C-unwind" fn CFUserNotificationGetResponseValue(
427    user_notification: &CFUserNotification,
428    key: Option<&CFString>,
429    idx: CFIndex,
430) -> Option<CFRetained<CFString>> {
431    extern "C-unwind" {
432        fn CFUserNotificationGetResponseValue(
433            user_notification: &CFUserNotification,
434            key: Option<&CFString>,
435            idx: CFIndex,
436        ) -> Option<NonNull<CFString>>;
437    }
438    let ret = unsafe { CFUserNotificationGetResponseValue(user_notification, key, idx) };
439    ret.map(|ret| unsafe { CFRetained::retain(ret) })
440}
441
442#[cfg(feature = "CFDictionary")]
443#[deprecated = "renamed to `CFUserNotification::response_dictionary`"]
444#[inline]
445pub extern "C-unwind" fn CFUserNotificationGetResponseDictionary(
446    user_notification: &CFUserNotification,
447) -> Option<CFRetained<CFDictionary>> {
448    extern "C-unwind" {
449        fn CFUserNotificationGetResponseDictionary(
450            user_notification: &CFUserNotification,
451        ) -> Option<NonNull<CFDictionary>>;
452    }
453    let ret = unsafe { CFUserNotificationGetResponseDictionary(user_notification) };
454    ret.map(|ret| unsafe { CFRetained::retain(ret) })
455}
456
457extern "C-unwind" {
458    #[cfg(all(feature = "CFDate", feature = "CFDictionary"))]
459    #[deprecated = "renamed to `CFUserNotification::update`"]
460    pub fn CFUserNotificationUpdate(
461        user_notification: &CFUserNotification,
462        timeout: CFTimeInterval,
463        flags: CFOptionFlags,
464        dictionary: Option<&CFDictionary>,
465    ) -> i32;
466}
467
468#[deprecated = "renamed to `CFUserNotification::cancel`"]
469#[inline]
470pub extern "C-unwind" fn CFUserNotificationCancel(user_notification: &CFUserNotification) -> i32 {
471    extern "C-unwind" {
472        fn CFUserNotificationCancel(user_notification: &CFUserNotification) -> i32;
473    }
474    unsafe { CFUserNotificationCancel(user_notification) }
475}
476
477#[cfg(feature = "CFRunLoop")]
478#[deprecated = "renamed to `CFUserNotification::new_run_loop_source`"]
479#[inline]
480pub unsafe extern "C-unwind" fn CFUserNotificationCreateRunLoopSource(
481    allocator: Option<&CFAllocator>,
482    user_notification: Option<&CFUserNotification>,
483    callout: CFUserNotificationCallBack,
484    order: CFIndex,
485) -> Option<CFRetained<CFRunLoopSource>> {
486    extern "C-unwind" {
487        fn CFUserNotificationCreateRunLoopSource(
488            allocator: Option<&CFAllocator>,
489            user_notification: Option<&CFUserNotification>,
490            callout: CFUserNotificationCallBack,
491            order: CFIndex,
492        ) -> Option<NonNull<CFRunLoopSource>>;
493    }
494    let ret = unsafe {
495        CFUserNotificationCreateRunLoopSource(allocator, user_notification, callout, order)
496    };
497    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
498}
499
500#[cfg(all(feature = "CFDate", feature = "CFURL"))]
501#[deprecated = "renamed to `CFUserNotification::display_notice`"]
502#[inline]
503pub extern "C-unwind" fn CFUserNotificationDisplayNotice(
504    timeout: CFTimeInterval,
505    flags: CFOptionFlags,
506    icon_url: Option<&CFURL>,
507    sound_url: Option<&CFURL>,
508    localization_url: Option<&CFURL>,
509    alert_header: Option<&CFString>,
510    alert_message: Option<&CFString>,
511    default_button_title: Option<&CFString>,
512) -> i32 {
513    extern "C-unwind" {
514        fn CFUserNotificationDisplayNotice(
515            timeout: CFTimeInterval,
516            flags: CFOptionFlags,
517            icon_url: Option<&CFURL>,
518            sound_url: Option<&CFURL>,
519            localization_url: Option<&CFURL>,
520            alert_header: Option<&CFString>,
521            alert_message: Option<&CFString>,
522            default_button_title: Option<&CFString>,
523        ) -> i32;
524    }
525    unsafe {
526        CFUserNotificationDisplayNotice(
527            timeout,
528            flags,
529            icon_url,
530            sound_url,
531            localization_url,
532            alert_header,
533            alert_message,
534            default_button_title,
535        )
536    }
537}
538
539extern "C-unwind" {
540    #[cfg(all(feature = "CFDate", feature = "CFURL"))]
541    #[deprecated = "renamed to `CFUserNotification::display_alert`"]
542    pub fn CFUserNotificationDisplayAlert(
543        timeout: CFTimeInterval,
544        flags: CFOptionFlags,
545        icon_url: Option<&CFURL>,
546        sound_url: Option<&CFURL>,
547        localization_url: Option<&CFURL>,
548        alert_header: Option<&CFString>,
549        alert_message: Option<&CFString>,
550        default_button_title: Option<&CFString>,
551        alternate_button_title: Option<&CFString>,
552        other_button_title: Option<&CFString>,
553        response_flags: *mut CFOptionFlags,
554    ) -> i32;
555}