1 {
2 * ColorSync - ColorSyncDevice.h
3 * Copyright (c) 2008 Apple Inc.
4 * All rights reserved.
5 }
6 { Pascal Translation: Jonas Maebe, <jonas@freepascal.org>, October 2009 }
7 { Pascal Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2012 }
8 {
9 Modified for use with Free Pascal
10 Version 308
11 Please report any bugs to <gpc@microbizz.nl>
12 }
13
14 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
15 {$mode macpas}
16 {$modeswitch cblocks}
17 {$packenum 1}
18 {$macro on}
19 {$inline on}
20 {$calling mwpascal}
21
22 unit ColorSyncDevice;
23 interface
24 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
25 {$setc GAP_INTERFACES_VERSION := $0308}
26
27 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
28 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
29 {$endc}
30
31 {$ifc defined CPUPOWERPC and defined CPUI386}
32 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
33 {$endc}
34 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
35 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
36 {$endc}
37
38 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
39 {$setc __ppc__ := 1}
40 {$elsec}
41 {$setc __ppc__ := 0}
42 {$endc}
43 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
44 {$setc __ppc64__ := 1}
45 {$elsec}
46 {$setc __ppc64__ := 0}
47 {$endc}
48 {$ifc not defined __i386__ and defined CPUI386}
49 {$setc __i386__ := 1}
50 {$elsec}
51 {$setc __i386__ := 0}
52 {$endc}
53 {$ifc not defined __x86_64__ and defined CPUX86_64}
54 {$setc __x86_64__ := 1}
55 {$elsec}
56 {$setc __x86_64__ := 0}
57 {$endc}
58 {$ifc not defined __arm__ and defined CPUARM}
59 {$setc __arm__ := 1}
60 {$elsec}
61 {$setc __arm__ := 0}
62 {$endc}
63 {$ifc not defined __arm64__ and defined CPUAARCH64}
64 {$setc __arm64__ := 1}
65 {$elsec}
66 {$setc __arm64__ := 0}
67 {$endc}
68
69 {$ifc defined cpu64}
70 {$setc __LP64__ := 1}
71 {$elsec}
72 {$setc __LP64__ := 0}
73 {$endc}
74
75
76 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
77 {$error Conflicting definitions for __ppc__ and __i386__}
78 {$endc}
79
80 {$ifc defined __ppc__ and __ppc__}
81 {$setc TARGET_CPU_PPC := TRUE}
82 {$setc TARGET_CPU_PPC64 := FALSE}
83 {$setc TARGET_CPU_X86 := FALSE}
84 {$setc TARGET_CPU_X86_64 := FALSE}
85 {$setc TARGET_CPU_ARM := FALSE}
86 {$setc TARGET_CPU_ARM64 := FALSE}
87 {$setc TARGET_OS_MAC := TRUE}
88 {$setc TARGET_OS_IPHONE := FALSE}
89 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
90 {$setc TARGET_OS_EMBEDDED := FALSE}
91 {$elifc defined __ppc64__ and __ppc64__}
92 {$setc TARGET_CPU_PPC := FALSE}
93 {$setc TARGET_CPU_PPC64 := TRUE}
94 {$setc TARGET_CPU_X86 := FALSE}
95 {$setc TARGET_CPU_X86_64 := FALSE}
96 {$setc TARGET_CPU_ARM := FALSE}
97 {$setc TARGET_CPU_ARM64 := FALSE}
98 {$setc TARGET_OS_MAC := TRUE}
99 {$setc TARGET_OS_IPHONE := FALSE}
100 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
101 {$setc TARGET_OS_EMBEDDED := FALSE}
102 {$elifc defined __i386__ and __i386__}
103 {$setc TARGET_CPU_PPC := FALSE}
104 {$setc TARGET_CPU_PPC64 := FALSE}
105 {$setc TARGET_CPU_X86 := TRUE}
106 {$setc TARGET_CPU_X86_64 := FALSE}
107 {$setc TARGET_CPU_ARM := FALSE}
108 {$setc TARGET_CPU_ARM64 := FALSE}
109 {$ifc defined iphonesim}
110 {$setc TARGET_OS_MAC := FALSE}
111 {$setc TARGET_OS_IPHONE := TRUE}
112 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
113 {$elsec}
114 {$setc TARGET_OS_MAC := TRUE}
115 {$setc TARGET_OS_IPHONE := FALSE}
116 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
117 {$endc}
118 {$setc TARGET_OS_EMBEDDED := FALSE}
119 {$elifc defined __x86_64__ and __x86_64__}
120 {$setc TARGET_CPU_PPC := FALSE}
121 {$setc TARGET_CPU_PPC64 := FALSE}
122 {$setc TARGET_CPU_X86 := FALSE}
123 {$setc TARGET_CPU_X86_64 := TRUE}
124 {$setc TARGET_CPU_ARM := FALSE}
125 {$setc TARGET_CPU_ARM64 := FALSE}
126 {$ifc defined iphonesim}
127 {$setc TARGET_OS_MAC := FALSE}
128 {$setc TARGET_OS_IPHONE := TRUE}
129 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
130 {$elsec}
131 {$setc TARGET_OS_MAC := TRUE}
132 {$setc TARGET_OS_IPHONE := FALSE}
133 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
134 {$endc}
135 {$setc TARGET_OS_EMBEDDED := FALSE}
136 {$elifc defined __arm__ and __arm__}
137 {$setc TARGET_CPU_PPC := FALSE}
138 {$setc TARGET_CPU_PPC64 := FALSE}
139 {$setc TARGET_CPU_X86 := FALSE}
140 {$setc TARGET_CPU_X86_64 := FALSE}
141 {$setc TARGET_CPU_ARM := TRUE}
142 {$setc TARGET_CPU_ARM64 := FALSE}
143 {$setc TARGET_OS_MAC := FALSE}
144 {$setc TARGET_OS_IPHONE := TRUE}
145 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
146 {$setc TARGET_OS_EMBEDDED := TRUE}
147 {$elifc defined __arm64__ and __arm64__}
148 {$setc TARGET_CPU_PPC := FALSE}
149 {$setc TARGET_CPU_PPC64 := FALSE}
150 {$setc TARGET_CPU_X86 := FALSE}
151 {$setc TARGET_CPU_X86_64 := FALSE}
152 {$setc TARGET_CPU_ARM := FALSE}
153 {$setc TARGET_CPU_ARM64 := TRUE}
154 {$ifc defined ios}
155 {$setc TARGET_OS_MAC := FALSE}
156 {$setc TARGET_OS_IPHONE := TRUE}
157 {$setc TARGET_OS_EMBEDDED := TRUE}
158 {$elsec}
159 {$setc TARGET_OS_MAC := TRUE}
160 {$setc TARGET_OS_IPHONE := FALSE}
161 {$setc TARGET_OS_EMBEDDED := FALSE}
162 {$endc}
163 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
164 {$elsec}
165 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
166 {$endc}
167
168 {$ifc defined __LP64__ and __LP64__ }
169 {$setc TARGET_CPU_64 := TRUE}
170 {$elsec}
171 {$setc TARGET_CPU_64 := FALSE}
172 {$endc}
173
174 {$ifc defined FPC_BIG_ENDIAN}
175 {$setc TARGET_RT_BIG_ENDIAN := TRUE}
176 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
177 {$elifc defined FPC_LITTLE_ENDIAN}
178 {$setc TARGET_RT_BIG_ENDIAN := FALSE}
179 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
180 {$elsec}
181 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
182 {$endc}
183 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
184 {$setc CALL_NOT_IN_CARBON := FALSE}
185 {$setc OLDROUTINENAMES := FALSE}
186 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
187 {$setc OPAQUE_UPP_TYPES := TRUE}
188 {$setc OTCARBONAPPLICATION := TRUE}
189 {$setc OTKERNEL := FALSE}
190 {$setc PM_USE_SESSION_APIS := TRUE}
191 {$setc TARGET_API_MAC_CARBON := TRUE}
192 {$setc TARGET_API_MAC_OS8 := FALSE}
193 {$setc TARGET_API_MAC_OSX := TRUE}
194 {$setc TARGET_CARBON := TRUE}
195 {$setc TARGET_CPU_68K := FALSE}
196 {$setc TARGET_CPU_MIPS := FALSE}
197 {$setc TARGET_CPU_SPARC := FALSE}
198 {$setc TARGET_OS_UNIX := FALSE}
199 {$setc TARGET_OS_WIN32 := FALSE}
200 {$setc TARGET_RT_MAC_68881 := FALSE}
201 {$setc TARGET_RT_MAC_CFM := FALSE}
202 {$setc TARGET_RT_MAC_MACHO := TRUE}
203 {$setc TYPED_FUNCTION_POINTERS := TRUE}
204 {$setc TYPE_BOOL := FALSE}
205 {$setc TYPE_EXTENDED := FALSE}
206 {$setc TYPE_LONGLONG := TRUE}
207 uses MacTypes,ColorSyncProfile,CFBase,CFDictionary,CFUUID;
208 {$endc} {not MACOSALLINCLUDE}
209
210
211 {$ifc TARGET_OS_MAC}
212
213 {$ALIGN POWER}
214
215
216 var kColorSyncDeviceID: CFStringRef; external name '_kColorSyncDeviceID'; (* attribute const *) { CFUUIDRef }
217 var kColorSyncDeviceClass: CFStringRef; external name '_kColorSyncDeviceClass'; (* attribute const *) { one of the below : }
218 var kColorSyncCameraDeviceClass: CFStringRef; external name '_kColorSyncCameraDeviceClass'; (* attribute const *) { cmra }
219 var kColorSyncDisplayDeviceClass: CFStringRef; external name '_kColorSyncDisplayDeviceClass'; (* attribute const *) { mntr }
220 var kColorSyncPrinterDeviceClass: CFStringRef; external name '_kColorSyncPrinterDeviceClass'; (* attribute const *) { prtr }
221 var kColorSyncScannerDeviceClass: CFStringRef; external name '_kColorSyncScannerDeviceClass'; (* attribute const *) { scnr }
222
223 var kColorSyncDeviceProfileURL: CFStringRef; external name '_kColorSyncDeviceProfileURL'; (* attribute const *)
224
225 var kColorSyncDeviceDescription: CFStringRef; external name '_kColorSyncDeviceDescription'; (* attribute const *) { CFString with a name in current locale }
226 var kColorSyncDeviceDescriptions: CFStringRef; external name '_kColorSyncDeviceDescriptions'; (* attribute const *) { CFDictionary with localized names }
227
228 var kColorSyncFactoryProfiles: CFStringRef; external name '_kColorSyncFactoryProfiles'; (* attribute const *) { CFDictionary containing factory profile info }
229 var kColorSyncCustomProfiles: CFStringRef; external name '_kColorSyncCustomProfiles'; (* attribute const *) { CFDictionary containing custom profile info }
230
231 var kColorSyncDeviceModeDescription: CFStringRef; external name '_kColorSyncDeviceModeDescription'; (* attribute const *) { CFString, e.g. Glossy, Best Quality }
232 var kColorSyncDeviceModeDescriptions: CFStringRef; external name '_kColorSyncDeviceModeDescriptions'; (* attribute const *) { CFDictionary with localized mode names }
233 var kColorSyncDeviceDefaultProfileID: CFStringRef; external name '_kColorSyncDeviceDefaultProfileID'; (* attribute const *) { see below }
234 var kColorSyncDeviceHostScope: CFStringRef; external name '_kColorSyncDeviceHostScope'; (* attribute const *) { kCFPreferences(Current,Any)Host }
235 var kColorSyncDeviceUserScope: CFStringRef; external name '_kColorSyncDeviceUserScope'; (* attribute const *) { kCFPreferences(Current,Any)User }
236 var kColorSyncProfileHostScope: CFStringRef; external name '_kColorSyncProfileHostScope'; (* attribute const *) { kCFPreferences(Current,Any)Host }
237 var kColorSyncProfileUserScope: CFStringRef; external name '_kColorSyncProfileUserScope'; (* attribute const *) { kCFPreferences(Current,Any)User }
238
239 var kColorSyncDeviceProfileIsFactory: CFStringRef; external name '_kColorSyncDeviceProfileIsFactory'; (* attribute const *) { Present in ColorSyncDeviceProfileInfo dictionary.}
240 { See ColorSyncDeviceProfileIterateCallback below. }
241 var kColorSyncDeviceProfileIsDefault: CFStringRef; external name '_kColorSyncDeviceProfileIsDefault'; (* attribute const *) { ditto }
242 var kColorSyncDeviceProfileIsCurrent: CFStringRef; external name '_kColorSyncDeviceProfileIsCurrent'; (* attribute const *) { ditto }
243 var kColorSyncDeviceProfileID: CFStringRef; external name '_kColorSyncDeviceProfileID'; (* attribute const *) { ditto }
244
245 var kColorSyncDeviceRegisteredNotification: CFStringRef; external name '_kColorSyncDeviceRegisteredNotification'; (* attribute const *) { com.apple.ColorSync.DeviceRegisteredNotification }
246 var kColorSyncDeviceUnregisteredNotification: CFStringRef; external name '_kColorSyncDeviceUnregisteredNotification'; (* attribute const *) { com.apple.ColorSync.DeviceUnregisteredNotification }
247 var kColorSyncDeviceProfilesNotification: CFStringRef; external name '_kColorSyncDeviceProfilesNotification'; (* attribute const *) { com.apple.ColorSync.DeviceProfilesNotification }
248 var kColorSyncDisplayDeviceProfilesNotification: CFStringRef; external name '_kColorSyncDisplayDeviceProfilesNotification'; (* attribute const *) { com.apple.ColorSync.DisplayProfileNotification }
249
ColorSyncRegisterDevicenull250 function ColorSyncRegisterDevice( deviceClass: CFStringRef; deviceID: CFUUIDRef; deviceInfo: CFDictionaryRef ): CBool; external name '_ColorSyncRegisterDevice';
251 {
252 * deviceInfo -a dictionary containing information needed to register a device.
253 * ----------------------------------------------------------------------------
254 *
255 * Required keys:
256 * ==============
257 * kColorSyncDeviceDescriptions: CFDictionary with localized names of the device.
258 * Localization keys must be five character strings
259 * containing language code and region code in the
260 * lc_RG format and it must contain (at least) the "en_US" locale.
261 * kColorSyncFactoryProfiles : CFDictionary with factory profile info CFDictionaries
262 * The keys are the profile IDs and the values
263 * are the profile info dictionaries.
264 * Optional keys:
265 * ==============
266 * kColorSyncDeviceHostScope : host scope of the device;
267 * one of kCFPreferences(Current,Any)Host;
268 * if unspecified kCFPreferencesCurrentHost is
269 * assumed.
270 * kColorSyncDeviceUserScope : user scope of the device;
271 * one of kCFPreferences(Current,Any)User;
272 * if unspecified kCFPreferencesCurrentUser is
273 * assumed.
274 *
275 * factory profiles dictionary - value for the key kColorSyncFactoryProfiles in deviceInfo
276 * -------------------------------------------------------------------------------------
277 * Required keys and values:
278 * ========================
279 * Each profile is identified by a ProfileID (of CFStringRef type) which used as the key.
280 * Value associated with the key is a profile info dictionary
281 * that describes an individual device profile.
282 *
283 * kColorSyncDeviceDefaultProfileID: the associated value must be one of the ProfileID
284 * present in the dictionary. Presence of this
285 * key is not required if there is only one factory profile.
286 *
287 * profile info CFDictionary
288 * --------------------------------
289 * Required keys:
290 * ==============
291 * kColorSyncDeviceProfileURL :CFURLRef of the profile to be registered
292 * kColorSyncDeviceModeDescriptions:CFDictionary with localized device mode
293 * names for the profile. Localization keys
294 * must be five character strings containing
295 * language code and region code in the lc_RG
296 * format and it must contain (at least) the
297 * "en_US" locale.
298 * E.g. "en_US" "Glossy Paper with best quality"
299 *
300 * Example of deviceInfo dictionary:
301 *
302 * <<
303 * kColorSyncDeviceDescriptions <<
304 * en_US My Little Printer
305 * de_DE Mein Kleiner Drucker
306 * fr_FR Mon petit immprimeur
307 * ...
308 * >>
309 * kColorSyncFactoryProfiles <<
310 * CFSTR("Profile 1") <<
311 * kColorSyncDeviceProfileURL (CFURLRef)
312 *
313 * kColorSyncDeviceModeDescriptions <<
314 * en_US Glossy Paper
315 * de_DE Glanzpapier
316 * fr_FR Papier glace
317 * ...
318 * >>
319 * ...
320 *
321 * kColorSyncDeviceDefaultProfileID CFSTR("Profile 1")
322 * >>
323 * kColorSyncDeviceUserScope kCFPreferencesAnyUser
324 *
325 * kColorSyncDeviceHostScope kCFPreferencesCurrentHost
326 * <<
327 *
328 * Notes: 1. Scope for factory profiles is exactly the same as the device scope.
329 * 2. Pass kCFNull in lieu of the profile URL or no URl key/value pair at all if
330 * factory profile is not available. This will enable setting custom profile.
331 * 3. For the reasons of compatibility with legacy API, it is recommended that the
332 * profile keys are created as CFStrings from uint32_t numbers as follows:
333 * CFStringRef key = CFStringCreateWithFormat(NULL, NULL, CFSTR("%u"), (uint32_t) i);
334 *
335 * returns true on success and false in case of failure
336 }
337
ColorSyncUnregisterDevicenull338 function ColorSyncUnregisterDevice( deviceClass: CFStringRef; deviceID: CFUUIDRef ): CBool; external name '_ColorSyncUnregisterDevice';
339 {
340 * Unregister a device of given deviceClass and deviceID.
341 *
342 * returns true on success and false in case of failure
343 }
344
ColorSyncDeviceSetCustomProfilesnull345 function ColorSyncDeviceSetCustomProfiles( deviceClass: CFStringRef; deviceID: CFUUIDRef; profileInfo: CFDictionaryRef ): CBool; external name '_ColorSyncDeviceSetCustomProfiles';
346 {
347 * profileInfo is a CFDictionary containing the information about
348 * custom profiles to be set in lieu of factory profiles.
349 * Required keys:
350 * ==============
351 * ProfileIDs which must be the subset of the ProfileIDs that device was registered with
352 * or kColorSyncDeviceDefaultProfileID for setting custom default profile.
353 *
354 * Required values:
355 * ==============
356 * CFURLRef of the profile to be set as a custom profile.
357 *
358 * Optional keys:
359 * ==============
360 * kColorSyncProfileHostScope : host scope of the profile;
361 * one of kCFPreferences(Current,Any)Host;
362 * if unspecified kCFPreferencesCurrentHost
363 * is assumed.
364 * kColorSyncProfileUserScope : user scope of the profile;
365 * one of kCFPreferences(Current,Any)User;
366 * if unspecified kCFPreferencesCurrentUser
367 * is assumed.
368 *
369 *
370 * Notes: 1. Profile scope for custom profiles cannot exceed scope of the factory profiles.
371 * 2. There is only one host scope and user scope per dictionary (i.e. per call)
372 * 3. Pass kCFNull in lieu of the profile URL to unset the custom profile and
373 * reset the current profile to the factory profile.
374 *
375 * returns true on success and false in case of failure
376 }
377
ColorSyncDeviceCopyDeviceInfonull378 function ColorSyncDeviceCopyDeviceInfo( deviceClass: CFStringRef; devID: CFUUIDRef ): CFDictionaryRef; external name '_ColorSyncDeviceCopyDeviceInfo';
379 {
380 * Returns a dictionary with the following keys and values resolved for the current host and current user.
381 *
382 * <<
383 * kColorSyncDeviceClass (camera, display, printer, scanner)
384 * kColorSyncDeviceID (CFUUIDRef registered with ColorSync)
385 * kColorSyncDeviceDescription (localized device description)
386 * kColorSyncFactoryProfiles (dictionary) <<
387 * (ProfileID) (dictionary) <<
388 * kColorSyncDeviceProfileURL (CFURLRef or kCFNull)
389 * kColorSyncDeviceModeDescription (localized mode description)
390 * >>
391 * ...
392 * kColorSyncDeviceDefaultProfileID (ProfileID)
393 * >>
394 * kColorSyncCustomProfiles (dictionary) <<
395 * (ProfileID) (CFURLRef or kCFNull)
396 * ...
397 * <<
398 * kColorSyncDeviceUserScope (kCFPreferencesAnyUser or kCFPreferencesCurrentUser)
399 * kColorSyncDeviceHostScope (kCFPreferencesAnyHost or kCFPreferencesCurrentHost)
400 * >>
401 }
402
403 type
colorSyncDeviceProfileInfonull404 ColorSyncDeviceProfileIterateCallback = function( colorSyncDeviceProfileInfo: CFDictionaryRef; userInfo: UnivPtr ): CBool;
405 {
406 * colorSyncDeviceProfileInfo contains the following keys:
407 * <<
408 * kColorSyncDeviceClass (camera, display, printer, scanner)
409 * kColorSyncDeviceID (CFUUIDRef registered with ColorSync)
410 * kColorSyncDeviceDescription (localized device description)
411 * kColorSyncDeviceModeDescription (localized device mode description)
412 * kColorSyncDeviceProfileID (ProfileID registered with ColorSync)
413 * kColorSyncDeviceProfileURL (CFURLRef registered with ColorSync)
414 * kColorSyncDeviceProfileIsFactory (kCFBooleanTrue or kCFBooleanFalse)
415 * kColorSyncDeviceProfileIsDefault (kCFBooleanTrue or kCFBooleanFalse)
416 * kColorSyncDeviceProfileIsCurrent (kCFBooleanTrue or kCFBooleanFalse)
417 * >>
418 }
419
420 procedure ColorSyncIterateDeviceProfiles( callBack: ColorSyncDeviceProfileIterateCallback; userInfo: UnivPtr ); external name '_ColorSyncIterateDeviceProfiles';
421
422
423 {
424 * A utility function converting displayID to CFUUIDRef
425 }
CGDisplayCreateUUIDFromDisplayIDnull426 function CGDisplayCreateUUIDFromDisplayID( displayID: UInt32 ): CFUUIDRef; external name '_CGDisplayCreateUUIDFromDisplayID';
427 (* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)
428
429 {
430 * A utility function converting first 32 bits of CFUUIDRef to displayID
431 }
CGDisplayGetDisplayIDFromUUIDnull432 function CGDisplayGetDisplayIDFromUUID( uuid: CFUUIDRef ): UInt32; external name '_CGDisplayGetDisplayIDFromUUID';
433 (* AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER *)
434
435 {$endc} {TARGET_OS_MAC}
436 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
437
438 end.
439 {$endc} {not MACOSALLINCLUDE}
440