3
// AddressBook Framework
5
// Copyright (c) 2002-2003 Apple Computer. All rights reserved.
8
{ Pascal Translation: Peter N Lewis, <peter@stairways.com.au>, 2004 }
12
Modified for use with Free Pascal
14
Please report any bugs to <gpc@microbizz.nl>
25
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
26
{$setc GAP_INTERFACES_VERSION := $0200}
28
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
29
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
32
{$ifc defined CPUPOWERPC and defined CPUI386}
33
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
35
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
36
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
39
{$ifc not defined __ppc__ and defined CPUPOWERPC}
44
{$ifc not defined __i386__ and defined CPUI386}
50
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
51
{$error Conflicting definitions for __ppc__ and __i386__}
54
{$ifc defined __ppc__ and __ppc__}
55
{$setc TARGET_CPU_PPC := TRUE}
56
{$setc TARGET_CPU_X86 := FALSE}
57
{$elifc defined __i386__ and __i386__}
58
{$setc TARGET_CPU_PPC := FALSE}
59
{$setc TARGET_CPU_X86 := TRUE}
61
{$error Neither __ppc__ nor __i386__ is defined.}
63
{$setc TARGET_CPU_PPC_64 := FALSE}
65
{$ifc defined FPC_BIG_ENDIAN}
66
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
67
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
68
{$elifc defined FPC_LITTLE_ENDIAN}
69
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
70
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
72
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
74
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
75
{$setc CALL_NOT_IN_CARBON := FALSE}
76
{$setc OLDROUTINENAMES := FALSE}
77
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
78
{$setc OPAQUE_UPP_TYPES := TRUE}
79
{$setc OTCARBONAPPLICATION := TRUE}
80
{$setc OTKERNEL := FALSE}
81
{$setc PM_USE_SESSION_APIS := TRUE}
82
{$setc TARGET_API_MAC_CARBON := TRUE}
83
{$setc TARGET_API_MAC_OS8 := FALSE}
84
{$setc TARGET_API_MAC_OSX := TRUE}
85
{$setc TARGET_CARBON := TRUE}
86
{$setc TARGET_CPU_68K := FALSE}
87
{$setc TARGET_CPU_MIPS := FALSE}
88
{$setc TARGET_CPU_SPARC := FALSE}
89
{$setc TARGET_OS_MAC := TRUE}
90
{$setc TARGET_OS_UNIX := FALSE}
91
{$setc TARGET_OS_WIN32 := FALSE}
92
{$setc TARGET_RT_MAC_68881 := FALSE}
93
{$setc TARGET_RT_MAC_CFM := FALSE}
94
{$setc TARGET_RT_MAC_MACHO := TRUE}
95
{$setc TYPED_FUNCTION_POINTERS := TRUE}
96
{$setc TYPE_BOOL := FALSE}
97
{$setc TYPE_EXTENDED := FALSE}
98
{$setc TYPE_LONGLONG := TRUE}
99
uses MacTypes,ABTypedefs,ABGlobals,CFBase,CFArray,CFDictionary,CFData;
103
ABRecordRef = ^SInt32; { an opaque 32-bit type }
104
ABPersonRef = ^SInt32; { an opaque 32-bit type }
105
ABGroupRef = ^SInt32; { an opaque 32-bit type }
106
ABSearchElementRef = ^SInt32; { an opaque 32-bit type }
107
ABAddressBookRef = ^SInt32; { an opaque 32-bit type }
108
ABMultiValueRef = ^SInt32; { an opaque 32-bit type }
109
ABMutableMultiValueRef = ^SInt32; { an opaque 32-bit type }
111
// --------------------------------------------------------------------------------
112
// LSOpenCFURLRef support
113
// --------------------------------------------------------------------------------
114
// An application can open the AddressBook app and select (and edit) a specific
115
// person by using the LSOpenCFURLRef API.
117
// To launch (or bring to front) the Address Book app and select a given person
119
// CFStringRef uniqueId = ABRecordCopyUniqueId(aPerson);
120
// CFStringRef urlString = CFStringCreateWithFormat(NULL, CFSTR(addressbook://%@), uniqueId);
121
// CFURLRef urlRef = CFURLCreateWithString(NULL, urlString, NULL);
122
// LSOpenCFURLRef(urlRef, NULL);
123
// CFRelease(uniqueId);
124
// CFRelease(urlRef);
125
// CFRelease(urlString);
127
// To launch (or bring to front) the Address Book app and edit a given person
129
// CFStringRef uniqueId = ABRecordCopyUniqueId(aPerson);
130
// CFStringRef urlString = CFStringCreateWithFormat(NULL, CFSTR(addressbook://%@?edit), uniqueId);
131
// CFURLRef urlRef = CFURLCreateWithString(NULL, urlString, NULL);
132
// LSOpenCFURLRef(urlRef, NULL);
133
// CFRelease(uniqueId);
134
// CFRelease(urlRef);
135
// CFRelease(urlString);
137
// --------------------------------------------------------------------------------
139
// --------------------------------------------------------------------------------
141
// --- There is only one Address Book
142
function ABGetSharedAddressBook: ABAddressBookRef; external name '_ABGetSharedAddressBook';
145
function ABCopyArrayOfMatchingRecords( addressBook: ABAddressBookRef; search: ABSearchElementRef ): CFArrayRef; external name '_ABCopyArrayOfMatchingRecords';
148
function ABSave( addressBook: ABAddressBookRef ): Boolean; external name '_ABSave';
149
function ABHasUnsavedChanges( addressBook: ABAddressBookRef ): Boolean; external name '_ABHasUnsavedChanges';
152
function ABGetMe( addressBook: ABAddressBookRef ): ABPersonRef; external name '_ABGetMe'; // Not retain???
153
procedure ABSetMe( addressBook: ABAddressBookRef; moi: ABPersonRef ); external name '_ABSetMe';
155
// Returns the record class Name for a particular uniqueId
156
// AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
157
function ABCopyRecordTypeFromUniqueId( addressBook: ABAddressBookRef; uniqueId: CFStringRef ): CFStringRef; external name '_ABCopyRecordTypeFromUniqueId';
160
// Property names must be unique for a record type
161
function ABAddPropertiesAndTypes( addressBook: ABAddressBookRef; recordType: CFStringRef; propertiesAnTypes: CFDictionaryRef ): SInt32; external name '_ABAddPropertiesAndTypes';
162
function ABRemoveProperties( addressBook: ABAddressBookRef; recordType: CFStringRef; properties: CFArrayRef ): SInt32; external name '_ABRemoveProperties';
163
function ABCopyArrayOfPropertiesForRecordType( addressBook: ABAddressBookRef; recordType: CFStringRef ): CFArrayRef; external name '_ABCopyArrayOfPropertiesForRecordType';
164
function ABTypeOfProperty( addressBook: ABAddressBookRef; recordType: CFStringRef; proprty: CFStringRef ): ABPropertyType; external name '_ABTypeOfProperty';
166
// --- Records (Person, Group)
167
function ABCopyRecordForUniqueId( addressBook: ABAddressBookRef; uniqueId: CFStringRef ): ABRecordRef; external name '_ABCopyRecordForUniqueId';
168
function ABAddRecord( addressBook: ABAddressBookRef; recrd: ABRecordRef ): Boolean; external name '_ABAddRecord';
169
function ABRemoveRecord( addressBook: ABAddressBookRef; recrd: ABRecordRef ): Boolean; external name '_ABRemoveRecord';
172
function ABCopyArrayOfAllPeople( addressBook: ABAddressBookRef ): CFArrayRef; external name '_ABCopyArrayOfAllPeople'; // Array of ABPerson
175
function ABCopyArrayOfAllGroups( addressBook: ABAddressBookRef ): CFArrayRef; external name '_ABCopyArrayOfAllGroups'; // Array of ABGroup
177
// --------------------------------------------------------------------------------
179
// --------------------------------------------------------------------------------
181
function ABRecordCopyRecordType( recrd: ABRecordRef ): CFStringRef; external name '_ABRecordCopyRecordType';
183
// --- Property value
184
function ABRecordCopyValue( recrd: ABRecordRef; proprty: CFStringRef ): CFTypeRef; external name '_ABRecordCopyValue';
185
// returns a CFDictionary for multi-value properties
186
function ABRecordSetValue( recrd: ABRecordRef; proprty: CFStringRef; value: CFTypeRef ): Boolean; external name '_ABRecordSetValue';
187
// takes a CFDictionary for multi-value properties
188
function ABRecordRemoveValue( recrd: ABRecordRef; proprty: CFStringRef ): Boolean; external name '_ABRecordRemoveValue';
190
// ---- Unique ID access convenience
191
function ABRecordCopyUniqueId( recrd: ABRecordRef ): CFStringRef; external name '_ABRecordCopyUniqueId';
193
// --------------------------------------------------------------------------------
195
// --------------------------------------------------------------------------------
197
function ABPersonCreate: ABPersonRef; external name '_ABPersonCreate';
199
function ABPersonCreateWithVCardRepresentation( vCard: CFDataRef ): ABPersonRef; external name '_ABPersonCreateWithVCardRepresentation';
200
function ABPersonCopyVCardRepresentation( person: ABPersonRef ): CFDataRef; external name '_ABPersonCopyVCardRepresentation';
202
function ABPersonCopyParentGroups( person: ABPersonRef ): CFArrayRef; external name '_ABPersonCopyParentGroups'; // Groups this person belongs to
204
// --- Search elements
205
function ABPersonCreateSearchElement( proprty: CFStringRef; labl: CFStringRef; key: CFStringRef; value: CFTypeRef; comparison: ABSearchComparison ): ABSearchElementRef; external name '_ABPersonCreateSearchElement';
207
// --------------------------------------------------------------------------------
209
// --------------------------------------------------------------------------------
211
function ABGroupCreate: ABGroupRef; external name '_ABGroupCreate';
213
// --- Dealing with Persons
214
function ABGroupCopyArrayOfAllMembers( group: ABGroupRef ): CFArrayRef; external name '_ABGroupCopyArrayOfAllMembers';
215
function ABGroupAddMember( group: ABGroupRef; personToAdd: ABPersonRef ): Boolean; external name '_ABGroupAddMember';
216
function ABGroupRemoveMember( group: ABGroupRef; personToRemove: ABPersonRef ): Boolean; external name '_ABGroupRemoveMember';
218
// --- Dealing with Groups
219
function ABGroupCopyArrayOfAllSubgroups( group: ABGroupRef ): CFArrayRef; external name '_ABGroupCopyArrayOfAllSubgroups';
220
function ABGroupAddGroup( group: ABGroupRef; groupToAdd: ABGroupRef ): Boolean; external name '_ABGroupAddGroup';
221
function ABGroupRemoveGroup( group: ABGroupRef; groupToRemove: ABGroupRef ): Boolean; external name '_ABGroupRemoveGroup';
223
// --- Dealong with Parents
224
function ABGroupCopyParentGroups( group: ABGroupRef ): CFArrayRef; external name '_ABGroupCopyParentGroups';
226
// --- Distribution list
227
function ABGroupSetDistributionIdentifier( group: ABGroupRef; person: ABPersonRef; proprty: CFStringRef; identifier: CFStringRef ): Boolean; external name '_ABGroupSetDistributionIdentifier';
228
function ABGroupCopyDistributionIdentifier( group: ABGroupRef; person: ABPersonRef; proprty: CFStringRef ): CFStringRef; external name '_ABGroupCopyDistributionIdentifier';
230
// --- Search elements
231
function ABGroupCreateSearchElement( proprty: CFStringRef; labl: CFStringRef; key: CFStringRef; value: CFTypeRef; comparison: ABSearchComparison ): ABSearchElementRef; external name '_ABGroupCreateSearchElement';
233
// --------------------------------------------------------------------------------
235
// --------------------------------------------------------------------------------
237
function ABSearchElementCreateWithConjunction( conjunction: ABSearchConjunction; childrenSearchElement: CFArrayRef ): ABSearchElementRef; external name '_ABSearchElementCreateWithConjunction';
239
function ABSearchElementMatchesRecord( searchElement: ABSearchElementRef; recrd: ABRecordRef ): Boolean; external name '_ABSearchElementMatchesRecord';
241
// --------------------------------------------------------------------------------
243
// --------------------------------------------------------------------------------
245
function ABMultiValueCreate: ABMultiValueRef; external name '_ABMultiValueCreate';
246
function ABMultiValueCount( multiValue: ABMultiValueRef ): UInt32; external name '_ABMultiValueCount';
247
function ABMultiValueCopyValueAtIndex( multiValue: ABMultiValueRef; index: SInt32 ): CFTypeRef; external name '_ABMultiValueCopyValueAtIndex';
248
function ABMultiValueCopyLabelAtIndex( multiValue: ABMultiValueRef; index: SInt32 ): CFStringRef; external name '_ABMultiValueCopyLabelAtIndex';
249
function ABMultiValueCopyPrimaryIdentifier( multiValue: ABMultiValueRef ): CFStringRef; external name '_ABMultiValueCopyPrimaryIdentifier';
250
function ABMultiValueIndexForIdentifier( multiValue: ABMultiValueRef; identifier: CFStringRef ): SInt32; external name '_ABMultiValueIndexForIdentifier';
251
function ABMultiValueCopyIdentifierAtIndex( multiValue: ABMultiValueRef; index: SInt32 ): CFStringRef; external name '_ABMultiValueCopyIdentifierAtIndex';
252
function ABMultiValuePropertyType( multiValue: ABMultiValueRef ): ABPropertyType; external name '_ABMultiValuePropertyType';
253
function ABMultiValueCreateCopy( multiValue: ABMultiValueRef ): ABMultiValueRef; external name '_ABMultiValueCreateCopy';
255
// --------------------------------------------------------------------------------
256
// ABMutableMultiValue
257
// --------------------------------------------------------------------------------
259
function ABMultiValueCreateMutable: ABMutableMultiValueRef; external name '_ABMultiValueCreateMutable';
260
function ABMultiValueAdd( multiValue: ABMutableMultiValueRef; value: CFTypeRef; labl: CFStringRef; var outIdentifier: CFStringRef ): Boolean; external name '_ABMultiValueAdd';
261
function ABMultiValueInsert( multiValue: ABMutableMultiValueRef; value: CFTypeRef; labl: CFStringRef; index: SInt32; var outIdentifier: CFStringRef ): Boolean; external name '_ABMultiValueInsert';
262
function ABMultiValueRemove( multiValue: ABMutableMultiValueRef; index: SInt32 ): Boolean; external name '_ABMultiValueRemove';
263
function ABMultiValueReplaceValue( multiValue: ABMutableMultiValueRef; value: CFTypeRef; index: SInt32 ): Boolean; external name '_ABMultiValueReplaceValue';
264
function ABMultiValueReplaceLabel( multiValue: ABMutableMultiValueRef; labl: CFStringRef; index: SInt32 ): Boolean; external name '_ABMultiValueReplaceLabel';
265
function ABMultiValueSetPrimaryIdentifier( multiValue: ABMutableMultiValueRef; identifier: CFStringRef ): Boolean; external name '_ABMultiValueSetPrimaryIdentifier';
266
function ABMultiValueCreateMutableCopy( multiValue: ABMultiValueRef ): ABMutableMultiValueRef; external name '_ABMultiValueCreateMutableCopy';
268
// --------------------------------------------------------------------------------
269
// Localization of properties or labels
270
// --------------------------------------------------------------------------------
272
function ABCopyLocalizedPropertyOrLabel( labelOrProperty: CFStringRef ): CFStringRef; external name '_ABCopyLocalizedPropertyOrLabel';
274
// --- Address formatting
275
// AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
276
function ABCreateFormattedAddressFromDictionary( addressBook: ABAddressBookRef; address: CFDictionaryRef ): CFStringRef; external name '_ABCreateFormattedAddressFromDictionary';
277
// AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
278
function ABCopyDefaultCountryCode( addressBook: ABAddressBookRef ): CFStringRef; external name '_ABCopyDefaultCountryCode';
280
// --------------------------------------------------------------------------------
281
// Person Image Loading
282
// --------------------------------------------------------------------------------
284
function ABPersonSetImageData( person: ABPersonRef; imageData: CFDataRef ): Boolean; external name '_ABPersonSetImageData';
285
function ABPersonCopyImageData( person: ABPersonRef ): CFDataRef; external name '_ABPersonCopyImageData';
287
type ABImageClientCallback = procedure ( imageData: CFDataRef; tag: SInt32; refcon: UnivPtr );
289
function ABBeginLoadingImageDataForClient( person: ABPersonRef; callback: ABImageClientCallback; refcon: UnivPtr ): SInt32; external name '_ABBeginLoadingImageDataForClient';
290
procedure ABCancelLoadingImageDataForTag( tag: SInt32 ); external name '_ABCancelLoadingImageDataForTag';