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