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