1
{ CFNotificationCenter.h
2
Copyright (c) 1998-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>, September 2005 }
7
Modified for use with Free Pascal
9
Please report any bugs to <gpc@microbizz.nl>
18
unit CFNotificationCenter;
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,CFDictionary;
99
CFNotificationCenterRef = ^SInt32; { an opaque 32-bit type }
102
CFNotificationCallback = procedure( center: CFNotificationCenterRef; observer: UnivPtr; name: CFStringRef; objct: {const} UnivPtr; userInfo: CFDictionaryRef );
105
CFNotificationSuspensionBehavior = SInt32;
107
CFNotificationSuspensionBehaviorDrop = 1;
108
// The server will not queue any notifications with this name and object while the process/app is in the background.
109
CFNotificationSuspensionBehaviorCoalesce = 2;
110
// The server will only queue the last notification of the specified name and object; earlier notifications are dropped.
111
CFNotificationSuspensionBehaviorHold = 3;
112
// The server will hold all matching notifications until the queue has been filled (queue size determined by the server) at which point the server may flush queued notifications.
113
CFNotificationSuspensionBehaviorDeliverImmediately = 4;
114
// The server will deliver notifications matching this registration whether or not the process is in the background. When a notification with this suspension behavior is matched, it has the effect of first flushing any queued notifications.
116
function CFNotificationCenterGetTypeID: CFTypeID; external name '_CFNotificationCenterGetTypeID';
118
function CFNotificationCenterGetLocalCenter: CFNotificationCenterRef; external name '_CFNotificationCenterGetLocalCenter';
119
(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
121
function CFNotificationCenterGetDistributedCenter: CFNotificationCenterRef; external name '_CFNotificationCenterGetDistributedCenter';
123
function CFNotificationCenterGetDarwinNotifyCenter: CFNotificationCenterRef; external name '_CFNotificationCenterGetDarwinNotifyCenter';
124
(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
125
// The Darwin Notify Center is based on the <notify.h> API.
126
// For this center, there are limitations in the API. There are no notification "objects",
127
// "userInfo" cannot be passed in the notification, and there are no suspension behaviors
128
// (always "deliver immediately"). Other limitations in the <notify.h> API as described in
129
// that header will also apply.
130
// - In the CFNotificationCallback, the 'object' and 'userInfo' parameters must be ignored.
131
// - CFNotificationCenterAddObserver(): the 'object' and 'suspensionBehavior' arguments are ignored.
132
// - CFNotificationCenterAddObserver(): the 'name' argument may not be NULL (for this center).
133
// - CFNotificationCenterRemoveObserver(): the 'object' argument is ignored.
134
// - CFNotificationCenterPostNotification(): the 'object', 'userInfo', and 'deliverImmediately' arguments are ignored.
135
// - CFNotificationCenterPostNotificationWithOptions(): the 'object', 'userInfo', and 'options' arguments are ignored.
136
// The Darwin Notify Center has no notion of per-user sessions, all notifications are system-wide.
137
// As with distributed notifications, the main thread's run loop must be running in one of the
138
// common modes (usually kCFRunLoopDefaultMode) for Darwin-style notifications to be delivered.
139
// NOTE: NULL or 0 should be passed for all ignored arguments to ensure future compatibility.
142
procedure CFNotificationCenterAddObserver( center: CFNotificationCenterRef; observer: {const} UnivPtr; callBack: CFNotificationCallback; name: CFStringRef; objct: {const} UnivPtr; suspensionBehavior: CFNotificationSuspensionBehavior ); external name '_CFNotificationCenterAddObserver';
144
procedure CFNotificationCenterRemoveObserver( center: CFNotificationCenterRef; observer: {const} UnivPtr; name: CFStringRef; objct: {const} UnivPtr ); external name '_CFNotificationCenterRemoveObserver';
145
procedure CFNotificationCenterRemoveEveryObserver( center: CFNotificationCenterRef; observer: {const} UnivPtr ); external name '_CFNotificationCenterRemoveEveryObserver';
147
procedure CFNotificationCenterPostNotification( center: CFNotificationCenterRef; name: CFStringRef; objct: {const} UnivPtr; userInfo: CFDictionaryRef; deliverImmediately: Boolean ); external name '_CFNotificationCenterPostNotification';
149
{#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED}
152
kCFNotificationDeliverImmediately = 1 shl 0;
153
kCFNotificationPostToAllSessions = 1 shl 1;
155
procedure CFNotificationCenterPostNotificationWithOptions( center: CFNotificationCenterRef; name: CFStringRef; objct: {const} UnivPtr; userInfo: CFDictionaryRef; options: CFOptionFlags ); external name '_CFNotificationCenterPostNotificationWithOptions';
156
(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)