2
Copyright (c) 2000-2005, Apple, Inc. All rights reserved.
4
{ Pascal Translation: Peter N Lewis, <peter@stairways.com.au>, 2004 }
5
{ Pascal Translation Updated: Peter N Lewis, <peter@stairways.com.au>, November 2005 }
7
Modified for use with Free Pascal
9
Please report any bugs to <gpc@microbizz.nl>
18
unit CFUserNotification;
20
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
21
{$setc GAP_INTERFACES_VERSION := $0200}
23
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
24
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
27
{$ifc defined CPUPOWERPC and defined CPUI386}
28
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
30
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
31
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
34
{$ifc not defined __ppc__ and defined CPUPOWERPC}
39
{$ifc not defined __i386__ and defined CPUI386}
45
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
46
{$error Conflicting definitions for __ppc__ and __i386__}
49
{$ifc defined __ppc__ and __ppc__}
50
{$setc TARGET_CPU_PPC := TRUE}
51
{$setc TARGET_CPU_X86 := FALSE}
52
{$elifc defined __i386__ and __i386__}
53
{$setc TARGET_CPU_PPC := FALSE}
54
{$setc TARGET_CPU_X86 := TRUE}
56
{$error Neither __ppc__ nor __i386__ is defined.}
58
{$setc TARGET_CPU_PPC_64 := FALSE}
60
{$ifc defined FPC_BIG_ENDIAN}
61
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
62
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
63
{$elifc defined FPC_LITTLE_ENDIAN}
64
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
65
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
67
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
69
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
70
{$setc CALL_NOT_IN_CARBON := FALSE}
71
{$setc OLDROUTINENAMES := FALSE}
72
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
73
{$setc OPAQUE_UPP_TYPES := TRUE}
74
{$setc OTCARBONAPPLICATION := TRUE}
75
{$setc OTKERNEL := FALSE}
76
{$setc PM_USE_SESSION_APIS := TRUE}
77
{$setc TARGET_API_MAC_CARBON := TRUE}
78
{$setc TARGET_API_MAC_OS8 := FALSE}
79
{$setc TARGET_API_MAC_OSX := TRUE}
80
{$setc TARGET_CARBON := TRUE}
81
{$setc TARGET_CPU_68K := FALSE}
82
{$setc TARGET_CPU_MIPS := FALSE}
83
{$setc TARGET_CPU_SPARC := FALSE}
84
{$setc TARGET_OS_MAC := TRUE}
85
{$setc TARGET_OS_UNIX := FALSE}
86
{$setc TARGET_OS_WIN32 := FALSE}
87
{$setc TARGET_RT_MAC_68881 := FALSE}
88
{$setc TARGET_RT_MAC_CFM := FALSE}
89
{$setc TARGET_RT_MAC_MACHO := TRUE}
90
{$setc TYPED_FUNCTION_POINTERS := TRUE}
91
{$setc TYPE_BOOL := FALSE}
92
{$setc TYPE_EXTENDED := FALSE}
93
{$setc TYPE_LONGLONG := TRUE}
94
uses MacTypes,CFBase,CFDate,CFDictionary,CFString,CFURL,CFRunLoop;
99
CFUserNotificationRef = ^SInt32; { an opaque 32-bit type }
101
{ A CFUserNotification is a notification intended to be presented to a
102
user at the console (if one is present). This is for the use of processes
103
that do not otherwise have user interfaces, but may need occasional
104
interaction with a user. There is a parallel API for this functionality
105
at the System framework level, described in UNCUserNotification.h.
107
The contents of the notification can include a header, a message, textfields,
108
a popup button, radio buttons or checkboxes, a progress indicator, and up to
109
three ordinary buttons. All of these items are optional, but a default
110
button will be supplied even if not specified unless the
111
kCFUserNotificationNoDefaultButtonFlag is set.
113
The contents of the notification are specified in the dictionary used to
114
create the notification, whose keys should be taken from the list of constants
115
below, and whose values should be either strings or arrays of strings
116
(except for kCFUserNotificationProgressIndicatorValueKey, in which case the
117
value should be a number between 0 and 1, for a "definite" progress indicator,
118
or a boolean, for an "indefinite" progress indicator). Additionally, URLs can
119
optionally be supplied for an icon, a sound, and a bundle whose Localizable.strings
120
files will be used to localize strings.
122
Certain request flags are specified when a notification is created.
123
These specify an alert level for the notification, determine whether
124
radio buttons or check boxes are to be used, specify which if any of these
125
are checked by default, specify whether any of the textfields are to
126
be secure textfields, and determine which popup item should be selected
127
by default. A timeout is also specified, which determines how long the
128
notification should be supplied to the user (if zero, it will not timeout).
130
A CFUserNotification is dispatched for presentation when it is created.
131
If any reply is required, it may be awaited in one of two ways: either
132
synchronously, using CFUserNotificationReceiveResponse, or asynchronously,
133
using a run loop source. CFUserNotificationReceiveResponse has a timeout
134
parameter that determines how long it will block (zero meaning indefinitely)
135
and it may be called as many times as necessary until a response arrives.
136
If a notification has not yet received a response, it may be updated with
137
new information, or it may be cancelled. Notifications may not be reused.
139
When a response arrives, it carries with it response flags that describe
140
which button was used to dismiss the notification, which checkboxes or
141
radio buttons were checked, and what the selection of the popup was.
142
It also carries a response dictionary, which describes the contents
146
CFUserNotificationCallBack = procedure( userNotification: CFUserNotificationRef; responseFlags: CFOptionFlags );
148
function CFUserNotificationGetTypeID: CFTypeID; external name '_CFUserNotificationGetTypeID';
150
function CFUserNotificationCreate( allocator: CFAllocatorRef; timeout: CFTimeInterval; flags: CFOptionFlags; var error: SInt32; dictionary: CFDictionaryRef ): CFUserNotificationRef; external name '_CFUserNotificationCreate';
152
function CFUserNotificationReceiveResponse( userNotification: CFUserNotificationRef; timeout: CFTimeInterval; var responseFlags: CFOptionFlags ): SInt32; external name '_CFUserNotificationReceiveResponse';
154
function CFUserNotificationGetResponseValue( userNotification: CFUserNotificationRef; key: CFStringRef; idx: CFIndex ): CFStringRef; external name '_CFUserNotificationGetResponseValue';
156
function CFUserNotificationGetResponseDictionary( userNotification: CFUserNotificationRef ): CFDictionaryRef; external name '_CFUserNotificationGetResponseDictionary';
158
function CFUserNotificationUpdate( userNotification: CFUserNotificationRef; timeout: CFTimeInterval; flags: CFOptionFlags; dictionary: CFDictionaryRef ): SInt32; external name '_CFUserNotificationUpdate';
160
function CFUserNotificationCancel( userNotification: CFUserNotificationRef ): SInt32; external name '_CFUserNotificationCancel';
162
function CFUserNotificationCreateRunLoopSource( allocator: CFAllocatorRef; userNotification: CFUserNotificationRef; callout: CFUserNotificationCallBack; order: CFIndex ): CFRunLoopSourceRef; external name '_CFUserNotificationCreateRunLoopSource';
164
{ Convenience functions for handling the simplest and most common cases:
165
a one-way notification, and a notification with up to three buttons. }
167
function CFUserNotificationDisplayNotice( timeout: CFTimeInterval; flags: CFOptionFlags; iconURL: CFURLRef; soundURL: CFURLRef; localizationURL: CFURLRef; alertHeader: CFStringRef; alertMessage: CFStringRef; defaultButtonTitle: CFStringRef ): SInt32; external name '_CFUserNotificationDisplayNotice';
169
function CFUserNotificationDisplayAlert( timeout: CFTimeInterval; flags: CFOptionFlags; iconURL: CFURLRef; soundURL: CFURLRef; localizationURL: CFURLRef; alertHeader: CFStringRef; alertMessage: CFStringRef; defaultButtonTitle: CFStringRef; alternateButtonTitle: CFStringRef; otherButtonTitle: CFStringRef; var responseFlags: CFOptionFlags ): SInt32; external name '_CFUserNotificationDisplayAlert';
175
kCFUserNotificationStopAlertLevel = 0;
176
kCFUserNotificationNoteAlertLevel = 1;
177
kCFUserNotificationCautionAlertLevel = 2;
178
kCFUserNotificationPlainAlertLevel = 3;
181
kCFUserNotificationDefaultResponse = 0;
182
kCFUserNotificationAlternateResponse = 1;
183
kCFUserNotificationOtherResponse = 2;
184
kCFUserNotificationCancelResponse = 3;
187
kCFUserNotificationNoDefaultButtonFlag = 1 shl 5;
188
kCFUserNotificationUseRadioButtonsFlag = 1 shl 6;
190
function CFUserNotificationCheckBoxChecked( i: CFIndex ): CFOptionFlags; inline;
191
function CFUserNotificationSecureTextField( i: CFIndex ): CFOptionFlags; inline;
192
function CFUserNotificationPopUpSelection( n: CFIndex ): CFOptionFlags; inline;
197
var kCFUserNotificationIconURLKey: CFStringRef; external name '_kCFUserNotificationIconURLKey'; (* attribute const *)
199
var kCFUserNotificationSoundURLKey: CFStringRef; external name '_kCFUserNotificationSoundURLKey'; (* attribute const *)
201
var kCFUserNotificationLocalizationURLKey: CFStringRef; external name '_kCFUserNotificationLocalizationURLKey'; (* attribute const *)
203
var kCFUserNotificationAlertHeaderKey: CFStringRef; external name '_kCFUserNotificationAlertHeaderKey'; (* attribute const *)
205
var kCFUserNotificationAlertMessageKey: CFStringRef; external name '_kCFUserNotificationAlertMessageKey'; (* attribute const *)
207
var kCFUserNotificationDefaultButtonTitleKey: CFStringRef; external name '_kCFUserNotificationDefaultButtonTitleKey'; (* attribute const *)
209
var kCFUserNotificationAlternateButtonTitleKey: CFStringRef; external name '_kCFUserNotificationAlternateButtonTitleKey'; (* attribute const *)
211
var kCFUserNotificationOtherButtonTitleKey: CFStringRef; external name '_kCFUserNotificationOtherButtonTitleKey'; (* attribute const *)
213
var kCFUserNotificationProgressIndicatorValueKey: CFStringRef; external name '_kCFUserNotificationProgressIndicatorValueKey'; (* attribute const *)
215
var kCFUserNotificationPopUpTitlesKey: CFStringRef; external name '_kCFUserNotificationPopUpTitlesKey'; (* attribute const *)
217
var kCFUserNotificationTextFieldTitlesKey: CFStringRef; external name '_kCFUserNotificationTextFieldTitlesKey'; (* attribute const *)
219
var kCFUserNotificationCheckBoxTitlesKey: CFStringRef; external name '_kCFUserNotificationCheckBoxTitlesKey'; (* attribute const *)
221
var kCFUserNotificationTextFieldValuesKey: CFStringRef; external name '_kCFUserNotificationTextFieldValuesKey'; (* attribute const *)
223
{#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED}
224
var kCFUserNotificationPopUpSelectionKey: CFStringRef; external name '_kCFUserNotificationPopUpSelectionKey'; (* attribute const *)
225
(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
233
function CFUserNotificationCheckBoxChecked( i: CFIndex ): CFOptionFlags; inline;
235
CFUserNotificationCheckBoxChecked := CFOptionFlags(1 shl (8+i));
238
function CFUserNotificationSecureTextField( i: CFIndex ): CFOptionFlags; inline;
240
CFUserNotificationSecureTextField := CFOptionFlags(1 shl (16+i));
243
function CFUserNotificationPopUpSelection( n: CFIndex ): CFOptionFlags; inline;
245
CFUserNotificationPopUpSelection := CFOptionFlags(n shl 24);