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