]> git.saurik.com Git - apple/cf.git/blame - AppServices.subproj/CFUserNotification.h
CF-368.28.tar.gz
[apple/cf.git] / AppServices.subproj / CFUserNotification.h
CommitLineData
9ce05555 1/*
d8925383 2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
9ce05555
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
9ce05555
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/* CFUserNotification.h
d8925383 24 Copyright (c) 2000-2005, Apple, Inc. All rights reserved.
9ce05555
A
25*/
26
27#if !defined(__COREFOUNDATION_CFUSERNOTIFICATION__)
28#define __COREFOUNDATION_CFUSERNOTIFICATION__ 1
29
30#include <CoreFoundation/CFBase.h>
31#include <CoreFoundation/CFDate.h>
32#include <CoreFoundation/CFDictionary.h>
33#include <CoreFoundation/CFString.h>
34#include <CoreFoundation/CFURL.h>
35#include <CoreFoundation/CFRunLoop.h>
36
37#if defined(__cplusplus)
38extern "C" {
39#endif
40
41typedef struct __CFUserNotification * CFUserNotificationRef;
42
43/* A CFUserNotification is a notification intended to be presented to a
44user at the console (if one is present). This is for the use of processes
45that do not otherwise have user interfaces, but may need occasional
46interaction with a user. There is a parallel API for this functionality
47at the System framework level, described in UNCUserNotification.h.
48
49The contents of the notification can include a header, a message, textfields,
50a popup button, radio buttons or checkboxes, a progress indicator, and up to
51three ordinary buttons. All of these items are optional, but a default
52button will be supplied even if not specified unless the
53kCFUserNotificationNoDefaultButtonFlag is set.
54
55The contents of the notification are specified in the dictionary used to
56create the notification, whose keys should be taken from the list of constants
57below, and whose values should be either strings or arrays of strings
58(except for kCFUserNotificationProgressIndicatorValueKey, in which case the
59value should be a number between 0 and 1, for a "definite" progress indicator,
60or a boolean, for an "indefinite" progress indicator). Additionally, URLs can
61optionally be supplied for an icon, a sound, and a bundle whose Localizable.strings
62files will be used to localize strings.
63
64Certain request flags are specified when a notification is created.
65These specify an alert level for the notification, determine whether
66radio buttons or check boxes are to be used, specify which if any of these
67are checked by default, specify whether any of the textfields are to
68be secure textfields, and determine which popup item should be selected
69by default. A timeout is also specified, which determines how long the
70notification should be supplied to the user (if zero, it will not timeout).
71
72A CFUserNotification is dispatched for presentation when it is created.
73If any reply is required, it may be awaited in one of two ways: either
74synchronously, using CFUserNotificationReceiveResponse, or asynchronously,
75using a run loop source. CFUserNotificationReceiveResponse has a timeout
76parameter that determines how long it will block (zero meaning indefinitely)
77and it may be called as many times as necessary until a response arrives.
78If a notification has not yet received a response, it may be updated with
79new information, or it may be cancelled. Notifications may not be reused.
80
81When a response arrives, it carries with it response flags that describe
82which button was used to dismiss the notification, which checkboxes or
83radio buttons were checked, and what the selection of the popup was.
84It also carries a response dictionary, which describes the contents
85of the textfields. */
86
87typedef void (*CFUserNotificationCallBack)(CFUserNotificationRef userNotification, CFOptionFlags responseFlags);
88
89CF_EXPORT
90CFTypeID CFUserNotificationGetTypeID(void);
91
92CF_EXPORT
93CFUserNotificationRef CFUserNotificationCreate(CFAllocatorRef allocator, CFTimeInterval timeout, CFOptionFlags flags, SInt32 *error, CFDictionaryRef dictionary);
94
95CF_EXPORT
96SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags);
97
98CF_EXPORT
99CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotification, CFStringRef key, CFIndex idx);
100
101CF_EXPORT
102CFDictionaryRef CFUserNotificationGetResponseDictionary(CFUserNotificationRef userNotification);
103
104CF_EXPORT
105SInt32 CFUserNotificationUpdate(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags flags, CFDictionaryRef dictionary);
106
107CF_EXPORT
108SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification);
109
110CF_EXPORT
111CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource(CFAllocatorRef allocator, CFUserNotificationRef userNotification, CFUserNotificationCallBack callout, CFIndex order);
112
113/* Convenience functions for handling the simplest and most common cases:
114a one-way notification, and a notification with up to three buttons. */
115
116CF_EXPORT
117SInt32 CFUserNotificationDisplayNotice(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle);
118
119CF_EXPORT
120SInt32 CFUserNotificationDisplayAlert(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle, CFStringRef alternateButtonTitle, CFStringRef otherButtonTitle, CFOptionFlags *responseFlags);
121
122
123/* Flags */
124
125enum {
126 kCFUserNotificationStopAlertLevel = 0,
127 kCFUserNotificationNoteAlertLevel = 1,
128 kCFUserNotificationCautionAlertLevel = 2,
129 kCFUserNotificationPlainAlertLevel = 3
130};
131
132enum {
133 kCFUserNotificationDefaultResponse = 0,
134 kCFUserNotificationAlternateResponse = 1,
135 kCFUserNotificationOtherResponse = 2,
136 kCFUserNotificationCancelResponse = 3
137};
138
139enum {
140 kCFUserNotificationNoDefaultButtonFlag = (1 << 5),
141 kCFUserNotificationUseRadioButtonsFlag = (1 << 6)
142};
143
144CF_INLINE CFOptionFlags CFUserNotificationCheckBoxChecked(CFIndex i) {return ((CFOptionFlags)(1 << (8 + i)));}
145CF_INLINE CFOptionFlags CFUserNotificationSecureTextField(CFIndex i) {return ((CFOptionFlags)(1 << (16 + i)));}
146CF_INLINE CFOptionFlags CFUserNotificationPopUpSelection(CFIndex n) {return ((CFOptionFlags)(n << 24));}
147
148
149/* Keys */
150
151CF_EXPORT
152const CFStringRef kCFUserNotificationIconURLKey;
153
154CF_EXPORT
155const CFStringRef kCFUserNotificationSoundURLKey;
156
157CF_EXPORT
158const CFStringRef kCFUserNotificationLocalizationURLKey;
159
160CF_EXPORT
161const CFStringRef kCFUserNotificationAlertHeaderKey;
162
163CF_EXPORT
164const CFStringRef kCFUserNotificationAlertMessageKey;
165
166CF_EXPORT
167const CFStringRef kCFUserNotificationDefaultButtonTitleKey;
168
169CF_EXPORT
170const CFStringRef kCFUserNotificationAlternateButtonTitleKey;
171
172CF_EXPORT
173const CFStringRef kCFUserNotificationOtherButtonTitleKey;
174
175CF_EXPORT
176const CFStringRef kCFUserNotificationProgressIndicatorValueKey;
177
178CF_EXPORT
179const CFStringRef kCFUserNotificationPopUpTitlesKey;
180
181CF_EXPORT
182const CFStringRef kCFUserNotificationTextFieldTitlesKey;
183
184CF_EXPORT
185const CFStringRef kCFUserNotificationCheckBoxTitlesKey;
186
187CF_EXPORT
188const CFStringRef kCFUserNotificationTextFieldValuesKey;
189
190#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
191CF_EXPORT
192const CFStringRef kCFUserNotificationPopUpSelectionKey AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
193#endif
194
195#if defined(__cplusplus)
196}
197#endif
198
199#endif /* ! __COREFOUNDATION_CFUSERNOTIFICATION__ */
200