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