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