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