]> git.saurik.com Git - apple/xnu.git/blob - osfmk/UserNotification/KUNCUserNotifications.h
cb256e6a29a0cc4773dd528d893cca6bfe33ce3f
[apple/xnu.git] / osfmk / UserNotification / KUNCUserNotifications.h
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30
31 #ifndef __USERNOTIFICATION_KUNCUSERNOTIFICATIONS_H
32 #define __USERNOTIFICATION_KUNCUSERNOTIFICATIONS_H
33
34 #include <sys/cdefs.h>
35
36
37 #include <mach/message.h>
38 #include <mach/kern_return.h>
39 #include <UserNotification/UNDTypes.h>
40
41 __BEGIN_DECLS
42
43 /*
44 * non blocking notice call.
45 */
46 kern_return_t
47 KUNCUserNotificationDisplayNotice(
48 int noticeTimeout,
49 unsigned flags,
50 char *iconPath,
51 char *soundPath,
52 char *localizationPath,
53 char *alertHeader,
54 char *alertMessage,
55 char *defaultButtonTitle);
56
57 /*
58 * ***BLOCKING*** alert call, returned int value corresponds to the
59 * pressed button, spin this off in a thread only, or expect your kext to block.
60 */
61 kern_return_t
62 KUNCUserNotificationDisplayAlert(
63 int alertTimeout,
64 unsigned flags,
65 char *iconPath,
66 char *soundPath,
67 char *localizationPath,
68 char *alertHeader,
69 char *alertMessage,
70 char *defaultButtonTitle,
71 char *alternateButtonTitle,
72 char *otherButtonTitle,
73 unsigned *responseFlags);
74
75 /*
76 * Execute a userland executable with the given path, user and type
77 */
78
79 #define kOpenApplicationPath 0 /* essentially executes the path */
80 #define kOpenPreferencePanel 1 /* runs the preferences with the foo.preference opened. foo.preference must exist in /System/Library/Preferences */
81 #define kOpenApplication 2 /* essentially runs /usr/bin/open on the passed in application name */
82
83
84 #define kOpenAppAsRoot 0
85 #define kOpenAppAsConsoleUser 1
86
87 kern_return_t
88 KUNCExecute(
89 char *executionPath,
90 int openAsUser,
91 int pathExecutionType);
92
93
94 /* KUNC User Notification XML Keys
95 *
96 * These are the keys used in the xml plist file passed in to the
97 * KUNCUserNotitificationDisplayFrom* calls
98 *
99 * KUNC Notifications are completely dependent on CFUserNotifications in
100 * user land. The same restrictions apply, including the number of text fields,
101 * types of information displayable, etc.
102 *
103 * Key Type
104 * Header string (header displayed on dialog)
105 * corresponds to kCFUserNotificationAlertHeaderKey
106 *
107 * Icon URL string (url of the icon to display)
108 * corresponds to kCFUserNotificationIconURLKey
109 *
110 * Sound URL string (url of the sound to play on display)
111 * corresponds to kCFUserNotificationSoundURLKey
112 *
113 * Localization URL string (url of bundle to retrieve localization
114 * info from, using Localizable.strings files)
115 * corresponds to kCFUserNotificationLocalizationURLKey
116 *
117 * Message string (text of the message, can contain %@'s
118 * which are filled from tokenString passed in)
119 * corresponds to kCFUserNotificationAlertMessageKey
120 *
121 * OK Button Title string (title of the "main" button)
122 * corresponds to kCFUserNotificationDefaultButtonTitleKey
123 *
124 * Alternate Button Title string (title of the "alternate" button, usually cancel)
125 * corresponds to kCFUserNotificationAlternateButtonTitleKey
126 *
127 * Other Button Title string (title of the "other" button)
128 * corresponds to kCFUserNotificationOtherButtonTitleKey
129 *
130 * Timeout string (numeric, int - seconds until the dialog
131 * goes away on it's own)
132 *
133 * Alert Level string (Stop, Notice, Alert)
134 *
135 * Blocking Message string (numeric, 1 or 0 - if 1, the dialog will
136 * have no buttons)
137 *
138 * Text Field Strings array of strings (each becomes a text field)
139 * corresponds to kCFUserNotificationTextFieldTitlesKey
140 *
141 * Password Fields array of strings (numeric - each indicates a
142 * pwd field)
143 *
144 * Popup Button Strings array of strings (each entry becomes a popup
145 * button string)
146 *
147 * Radio Button Strings array of strings (each becomes a radio button)
148 *
149 * Check Box Strings array of strings (each becomes a check box)
150 * corresponds to kCFUserNotificationCheckBoxTitlesKey
151 *
152 * Selected Radio string (numeric - which radio is selected)
153 *
154 * Checked Boxes array of strings (numeric - each indicates a
155 * checked field)
156 *
157 * Selected Popup string (numeric - which popup entry is selected)
158 *
159 */
160
161 /*
162 * Bundle Calls
163 *
164 * Arguments
165 *
166 * bundleIdentifier
167 * path to the actual bundle (not inside of it)
168 * (i.e. "/System/Library/Extensions/Foo.kext")
169 * ***NOTE***
170 * This WILL change soon to expect the CFBundleIdentifier instead of a bundle path
171 * fileName
172 * filename in bundle to retrive the xml from (i.e. "Messages")
173 * fileExtension
174 * if fileName has an extension, it goes here (i.e., "dict");
175 * messageKey
176 * name of the xml key in the dictionary in the file to retrieve
177 * the info from (i.e., "Error Message")
178 * tokenString
179 * a string in the form of "foo@bar" where each element is
180 * seperated by the @ character. This string can be used to
181 * replace values of the form %@ in the message key in the provided
182 * dictionary in the xml plist
183 * specialKey
184 * user specified key for notification, use this to match return
185 * values with your requested notification, this value is passed
186 * back to the client in the callback pararmeter contextKey
187 */
188
189 typedef int KUNCUserNotificationID;
190
191 /*
192 * Reponse value checking & default setting
193 *
194 * The reponse value returned in the response Flags of the
195 * KUNCUserNotificationCallBack can be tested against the following
196 * enum and 2 defines to determine the state.
197 */
198
199 enum {
200 kKUNCDefaultResponse = 0,
201 kKUNCAlternateResponse = 1,
202 kKUNCOtherResponse = 2,
203 kKUNCCancelResponse = 3
204 };
205
206 #define KUNCCheckBoxChecked(i) (1 << (8 + i)) /* can be used for radio's too */
207 #define KUNCPopUpSelection(n) (n << 24)
208
209 /*
210 * Callback function for KUNCNotifications
211 */
212 typedef void
213 (*KUNCUserNotificationCallBack)(
214 int contextKey,
215 int responseFlags,
216 void *xmlData);
217
218 /*
219 * Get a notification ID
220 */
221 KUNCUserNotificationID KUNCGetNotificationID(void);
222
223
224 /* This function currently requires a bundle path, which kexts cannot currently get. In the future, the CFBundleIdentiofier of the kext will be pass in in place of the bundlePath. */
225
226 kern_return_t
227 KUNCUserNotificationDisplayFromBundle(
228 KUNCUserNotificationID notificationID,
229 char *bundleIdentifier,
230 char *fileName,
231 char *fileExtension,
232 char *messageKey,
233 char *tokenString,
234 KUNCUserNotificationCallBack callback,
235 int contextKey);
236
237
238 kern_return_t
239 KUNCUserNotificationCancel(
240 KUNCUserNotificationID notification);
241
242
243 __END_DECLS
244
245 #endif /* __USERNOTIFICATION_KUNCUSERNOTIFICATIONS_H */