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