2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef __USERNOTIFICATION_KUNCUSERNOTIFICATIONS_H
25 #define __USERNOTIFICATION_KUNCUSERNOTIFICATIONS_H
27 #include <sys/cdefs.h>
30 #include <mach/message.h>
31 #include <mach/kern_return.h>
32 #include <UserNotification/UNDTypes.h>
37 * non blocking notice call.
40 KUNCUserNotificationDisplayNotice(
45 char *localizationPath
,
48 char *defaultButtonTitle
);
51 * ***BLOCKING*** alert call, returned int value corresponds to the
52 * pressed button, spin this off in a thread only, or expect your kext to block.
55 KUNCUserNotificationDisplayAlert(
60 char *localizationPath
,
63 char *defaultButtonTitle
,
64 char *alternateButtonTitle
,
65 char *otherButtonTitle
,
66 unsigned *responseFlags
);
69 * Execute a userland executable with the given path, user and type
72 #define kOpenApplicationPath 0 /* essentially executes the path */
73 #define kOpenPreferencePanel 1 /* runs the preferences with the foo.preference opened. foo.preference must exist in /System/Library/Preferences */
74 #define kOpenApplication 2 /* essentially runs /usr/bin/open on the passed in application name */
77 #define kOpenAppAsRoot 0
78 #define kOpenAppAsConsoleUser 1
84 int pathExecutionType
);
87 /* KUNC User Notification XML Keys
89 * These are the keys used in the xml plist file passed in to the
90 * KUNCUserNotitificationDisplayFrom* calls
92 * KUNC Notifications are completely dependent on CFUserNotifications in
93 * user land. The same restrictions apply, including the number of text fields,
94 * types of information displayable, etc.
97 * Header string (header displayed on dialog)
98 * corresponds to kCFUserNotificationAlertHeaderKey
100 * Icon URL string (url of the icon to display)
101 * corresponds to kCFUserNotificationIconURLKey
103 * Sound URL string (url of the sound to play on display)
104 * corresponds to kCFUserNotificationSoundURLKey
106 * Localization URL string (url of bundle to retrieve localization
107 * info from, using Localizable.strings files)
108 * corresponds to kCFUserNotificationLocalizationURLKey
110 * Message string (text of the message, can contain %@'s
111 * which are filled from tokenString passed in)
112 * corresponds to kCFUserNotificationAlertMessageKey
114 * OK Button Title string (title of the "main" button)
115 * corresponds to kCFUserNotificationDefaultButtonTitleKey
117 * Alternate Button Title string (title of the "alternate" button, usually cancel)
118 * corresponds to kCFUserNotificationAlternateButtonTitleKey
120 * Other Button Title string (title of the "other" button)
121 * corresponds to kCFUserNotificationOtherButtonTitleKey
123 * Timeout string (numeric, int - seconds until the dialog
124 * goes away on it's own)
126 * Alert Level string (Stop, Notice, Alert)
128 * Blocking Message string (numeric, 1 or 0 - if 1, the dialog will
131 * Text Field Strings array of strings (each becomes a text field)
132 * corresponds to kCFUserNotificationTextFieldTitlesKey
134 * Password Fields array of strings (numeric - each indicates a
137 * Popup Button Strings array of strings (each entry becomes a popup
140 * Radio Button Strings array of strings (each becomes a radio button)
142 * Check Box Strings array of strings (each becomes a check box)
143 * corresponds to kCFUserNotificationCheckBoxTitlesKey
145 * Selected Radio string (numeric - which radio is selected)
147 * Checked Boxes array of strings (numeric - each indicates a
150 * Selected Popup string (numeric - which popup entry is selected)
160 * path to the actual bundle (not inside of it)
161 * (i.e. "/System/Library/Extensions/Foo.kext")
163 * This WILL change soon to expect the CFBundleIdentifier instead of a bundle path
165 * filename in bundle to retrive the xml from (i.e. "Messages")
167 * if fileName has an extension, it goes here (i.e., "dict");
169 * name of the xml key in the dictionary in the file to retrieve
170 * the info from (i.e., "Error Message")
172 * a string in the form of "foo@bar" where each element is
173 * seperated by the @ character. This string can be used to
174 * replace values of the form %@ in the message key in the provided
175 * dictionary in the xml plist
177 * user specified key for notification, use this to match return
178 * values with your requested notification, this value is passed
179 * back to the client in the callback pararmeter contextKey
182 typedef int KUNCUserNotificationID
;
185 * Reponse value checking & default setting
187 * The reponse value returned in the response Flags of the
188 * KUNCUserNotificationCallBack can be tested against the following
189 * enum and 2 defines to determine the state.
193 kKUNCDefaultResponse
= 0,
194 kKUNCAlternateResponse
= 1,
195 kKUNCOtherResponse
= 2,
196 kKUNCCancelResponse
= 3
199 #define KUNCCheckBoxChecked(i) (1 << (8 + i)) /* can be used for radio's too */
200 #define KUNCPopUpSelection(n) (n << 24)
203 * Callback function for KUNCNotifications
206 (*KUNCUserNotificationCallBack
)(
212 * Get a notification ID
214 KUNCUserNotificationID
KUNCGetNotificationID(void);
217 /* 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. */
220 KUNCUserNotificationDisplayFromBundle(
221 KUNCUserNotificationID notificationID
,
222 char *bundleIdentifier
,
227 KUNCUserNotificationCallBack callback
,
232 KUNCUserNotificationCancel(
233 KUNCUserNotificationID notification
);
238 #endif /* __USERNOTIFICATION_KUNCUSERNOTIFICATIONS_H */