core_foundation_sys/
user_notification.rs1use std::os::raw::c_void;
11
12use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32};
13use crate::date::CFTimeInterval;
14use crate::dictionary::CFDictionaryRef;
15use crate::runloop::CFRunLoopSourceRef;
16use crate::string::CFStringRef;
17use crate::url::CFURLRef;
18
19#[repr(C)]
20pub struct __CFUserNotification(c_void);
21
22pub type CFUserNotificationCallBack =
23 extern "C" fn(userNotification: CFUserNotificationRef, responseFlags: CFOptionFlags);
24pub type CFUserNotificationRef = *mut __CFUserNotification;
25
26pub const kCFUserNotificationStopAlertLevel: CFOptionFlags = 0;
28pub const kCFUserNotificationNoteAlertLevel: CFOptionFlags = 1;
29pub const kCFUserNotificationCautionAlertLevel: CFOptionFlags = 2;
30pub const kCFUserNotificationPlainAlertLevel: CFOptionFlags = 3;
31
32pub const kCFUserNotificationDefaultResponse: CFOptionFlags = 0;
34pub const kCFUserNotificationAlternateResponse: CFOptionFlags = 1;
35pub const kCFUserNotificationOtherResponse: CFOptionFlags = 2;
36pub const kCFUserNotificationCancelResponse: CFOptionFlags = 3;
37
38pub const kCFUserNotificationNoDefaultButtonFlag: CFOptionFlags = 1usize << 5;
40pub const kCFUserNotificationUseRadioButtonsFlag: CFOptionFlags = 1usize << 6;
41
42#[inline(always)]
43pub fn CFUserNotificationCheckBoxChecked(i: CFIndex) -> CFOptionFlags {
44 (1u32 << (8 + i)) as CFOptionFlags
45}
46
47#[inline(always)]
48pub fn CFUserNotificationSecureTextField(i: CFIndex) -> CFOptionFlags {
49 (1u32 << (16 + i)) as CFOptionFlags
50}
51
52#[inline(always)]
53pub fn CFUserNotificationPopUpSelection(n: CFIndex) -> CFOptionFlags {
54 (n << 24) as CFOptionFlags
55}
56
57extern "C" {
58 pub static kCFUserNotificationIconURLKey: CFStringRef;
64 pub static kCFUserNotificationSoundURLKey: CFStringRef;
65 pub static kCFUserNotificationLocalizationURLKey: CFStringRef;
66 pub static kCFUserNotificationAlertHeaderKey: CFStringRef;
67 pub static kCFUserNotificationAlertMessageKey: CFStringRef;
68 pub static kCFUserNotificationDefaultButtonTitleKey: CFStringRef;
69 pub static kCFUserNotificationAlternateButtonTitleKey: CFStringRef;
70 pub static kCFUserNotificationOtherButtonTitleKey: CFStringRef;
71 pub static kCFUserNotificationProgressIndicatorValueKey: CFStringRef;
72 pub static kCFUserNotificationPopUpTitlesKey: CFStringRef;
73 pub static kCFUserNotificationTextFieldTitlesKey: CFStringRef;
74 pub static kCFUserNotificationCheckBoxTitlesKey: CFStringRef;
75 pub static kCFUserNotificationTextFieldValuesKey: CFStringRef;
76 pub static kCFUserNotificationPopUpSelectionKey: CFStringRef;
77 pub static kCFUserNotificationAlertTopMostKey: CFStringRef;
78 pub static kCFUserNotificationKeyboardTypesKey: CFStringRef;
79
80 pub fn CFUserNotificationCancel(userNotification: CFUserNotificationRef) -> SInt32;
82 pub fn CFUserNotificationCreate(
83 allocator: CFAllocatorRef,
84 timeout: CFTimeInterval,
85 flags: CFOptionFlags,
86 error: *mut SInt32,
87 dictionary: CFDictionaryRef,
88 ) -> CFUserNotificationRef;
89 pub fn CFUserNotificationCreateRunLoopSource(
90 allocator: CFAllocatorRef,
91 userNotification: CFUserNotificationRef,
92 callout: CFUserNotificationCallBack,
93 order: CFIndex,
94 ) -> CFRunLoopSourceRef;
95 pub fn CFUserNotificationDisplayAlert(
96 timeout: CFTimeInterval,
97 flags: CFOptionFlags,
98 iconURL: CFURLRef,
99 soundURL: CFURLRef,
100 localizationURL: CFURLRef,
101 alertHeader: CFStringRef,
102 alertMessage: CFStringRef,
103 defaultButtonTitle: CFStringRef,
104 alternateButtonTitle: CFStringRef,
105 otherButtonTitle: CFStringRef,
106 responseFlags: *mut CFOptionFlags,
107 ) -> SInt32;
108 pub fn CFUserNotificationDisplayNotice(
109 timeout: CFTimeInterval,
110 flags: CFOptionFlags,
111 iconURL: CFURLRef,
112 soundURL: CFURLRef,
113 localizationURL: CFURLRef,
114 alertHeader: CFStringRef,
115 alertMessage: CFStringRef,
116 defaultButtonTitle: CFStringRef,
117 ) -> SInt32;
118 pub fn CFUserNotificationGetTypeID() -> CFTypeID;
119 pub fn CFUserNotificationGetResponseDictionary(
120 userNotification: CFUserNotificationRef,
121 ) -> CFDictionaryRef;
122 pub fn CFUserNotificationGetResponseValue(
123 userNotification: CFUserNotificationRef,
124 key: CFStringRef,
125 idx: CFIndex,
126 ) -> CFStringRef;
127 pub fn CFUserNotificationReceiveResponse(
128 userNotification: CFUserNotificationRef,
129 timeout: CFTimeInterval,
130 responseFlags: *mut CFOptionFlags,
131 ) -> SInt32;
132 pub fn CFUserNotificationUpdate(
133 userNotification: CFUserNotificationRef,
134 timeout: CFTimeInterval,
135 flags: CFOptionFlags,
136 dictionary: CFDictionaryRef,
137 ) -> SInt32;
138}