CMDeviceIntegration.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. {
  2. File: CMDeviceIntegration.p
  3. Contains: Color Management Device Interfaces - for MacOSX
  4. Version: Technology: ColorSync 3.1
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 2000-2002 by Apple Computer, Inc., all rights reserved.
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit CMDeviceIntegration;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,CFBase,CFDictionary,CMTypes,CMApplication,CMICCProfile,CFString;
  92. {$ALIGN MAC68K}
  93. {$ifc TARGET_API_MAC_OSX}
  94. {
  95. The current versions of the data structure
  96. containing information on registered devices.
  97. }
  98. const
  99. cmDeviceInfoVersion1 = $00010000;
  100. cmDeviceProfileInfoVersion1 = $00010000;
  101. cmCurrentDeviceInfoVersion = $00010000;
  102. cmCurrentProfileInfoVersion = $00010000;
  103. {
  104. Certain APIs require a device ID or profile ID.
  105. In some cases, a "default ID" can be used.
  106. }
  107. cmDefaultDeviceID = 0;
  108. cmDefaultProfileID = 0;
  109. {
  110. Possible values for device states accessible by the
  111. CMGetDeviceState() and CMSetDeviceState() APIs.
  112. }
  113. cmDeviceStateDefault = $00000000;
  114. cmDeviceStateOffline = $00000001;
  115. cmDeviceStateBusy = $00000002;
  116. cmDeviceStateForceNotify = $80000000;
  117. cmDeviceStateDeviceRsvdBits = $00FF0000;
  118. cmDeviceStateAppleRsvdBits = $FF00FFFF;
  119. {
  120. Possible values for flags passed to the
  121. CMIterateDeviceProfiles() API.
  122. "Factory" profiles are registered via the
  123. CMSetDeviceFactoryProfiles() API.
  124. "Custom" profiles are those which are meant to take
  125. the place of the factory profiles, as a result of
  126. customization or calibration. These profiles are
  127. registered via the CMSetDeviceProfiles() API.
  128. To retrieve all of the the former for all devices,
  129. use cmIterateFactoryDeviceProfiles as the flags
  130. value when calling CMIterateDeviceProfiles().
  131. To retrieve only the latter for all devices, use
  132. the cmIterateCustomDeviceProfiles, as the flags
  133. value when calling CMIterateDeviceProfiles().
  134. To get the profiles in use for all devices, use
  135. cmIterateCurrentDeviceProfiles as the flags value.
  136. This will replace the factory profiles with any
  137. overrides, yielding the currently used set.
  138. }
  139. cmIterateFactoryDeviceProfiles = $00000001;
  140. cmIterateCustomDeviceProfiles = $00000002;
  141. cmIterateCurrentDeviceProfiles = $00000003;
  142. cmIterateDeviceProfilesMask = $00000003;
  143. kMaxDeviceNameLength = 256;
  144. kMaxProfileNameLength = 256;
  145. {
  146. Errors returned by CMDeviceIntegration APIs
  147. }
  148. cmDeviceDBNotFoundErr = -4227; { Prefs not found/loaded }
  149. cmDeviceAlreadyRegistered = -4228; { Re-registration of device }
  150. cmDeviceNotRegistered = -4229; { Device not found }
  151. cmDeviceProfilesNotFound = -4230; { Profiles not found }
  152. cmInternalCFErr = -4231; { CoreFoundation failure }
  153. {
  154. Device state data.
  155. }
  156. type
  157. CMDeviceState = UInt32;
  158. {
  159. A CMDeviceID must be unique within a device's class.
  160. }
  161. CMDeviceID = UInt32;
  162. {
  163. A CMDeviceProfileID must only be unique per device.
  164. }
  165. CMDeviceProfileID = UInt32;
  166. {
  167. DeviceClass type.
  168. }
  169. const
  170. cmScannerDeviceClass = $73636E72 (* 'scnr' *);
  171. cmCameraDeviceClass = $636D7261 (* 'cmra' *);
  172. cmDisplayDeviceClass = $6D6E7472 (* 'mntr' *);
  173. cmPrinterDeviceClass = $70727472 (* 'prtr' *);
  174. cmProofDeviceClass = $70727566 (* 'pruf' *);
  175. type
  176. CMDeviceClass = OSType;
  177. {
  178. CMDeviceScope
  179. Structure specifying a device's or a device setting's scope.
  180. }
  181. CMDeviceScopePtr = ^CMDeviceScope;
  182. CMDeviceScope = record
  183. deviceUser: CFStringRef; { kCFPreferencesCurrentUser | _AnyUser }
  184. deviceHost: CFStringRef; { kCFPreferencesCurrentHost | _AnyHost }
  185. end;
  186. {
  187. CMDeviceInfo
  188. Structure containing information on a given device.
  189. }
  190. CMDeviceInfoPtr = ^CMDeviceInfo;
  191. CMDeviceInfo = record
  192. dataVersion: UInt32; { cmDeviceInfoVersion1 }
  193. deviceClass: CMDeviceClass; { device class }
  194. deviceID: CMDeviceID; { device ID }
  195. deviceScope: CMDeviceScope; { device's scope }
  196. deviceState: CMDeviceState; { Device State flags }
  197. defaultProfileID: CMDeviceProfileID; { Can change }
  198. deviceName: ^CFDictionaryRef; { Ptr to storage for CFDictionary of }
  199. { localized device names (could be nil) }
  200. profileCount: UInt32; { Count of registered profiles }
  201. reserved: UInt32; { Reserved for use by ColorSync }
  202. end;
  203. {
  204. CMDeviceProfileInfo
  205. Structure containing information on a device profile.
  206. }
  207. CMDeviceProfileInfoPtr = ^CMDeviceProfileInfo;
  208. CMDeviceProfileInfo = record
  209. dataVersion: UInt32; { cmProfileInfoVersion1 }
  210. profileID: CMDeviceProfileID; { The identifier for this profile }
  211. profileLoc: CMProfileLocation; { The profile's location }
  212. profileName: CFDictionaryRef; { CFDictionary of localized device names }
  213. reserved: UInt32; { Reserved for use by ColorSync }
  214. end;
  215. {
  216. CMDeviceProfileArray
  217. Structure containing the profiles for a device.
  218. }
  219. CMDeviceProfileArrayPtr = ^CMDeviceProfileArray;
  220. CMDeviceProfileArray = record
  221. profileCount: UInt32; { Count of profiles in array }
  222. profiles: array [0..0] of CMDeviceProfileInfo; { The profile info records }
  223. end;
  224. {
  225. Caller-supplied iterator functions
  226. }
  227. {$ifc TYPED_FUNCTION_POINTERS}
  228. CMIterateDeviceInfoProcPtr = function(const (*var*) deviceInfo: CMDeviceInfo; refCon: UnivPtr): OSErr;
  229. {$elsec}
  230. CMIterateDeviceInfoProcPtr = ProcPtr;
  231. {$endc}
  232. {$ifc TYPED_FUNCTION_POINTERS}
  233. CMIterateDeviceProfileProcPtr = function(const (*var*) deviceInfo: CMDeviceInfo; const (*var*) profileData: CMDeviceProfileInfo; refCon: UnivPtr): OSErr;
  234. {$elsec}
  235. CMIterateDeviceProfileProcPtr = ProcPtr;
  236. {$endc}
  237. {
  238. Device Registration
  239. }
  240. {
  241. * CMRegisterColorDevice()
  242. *
  243. * Availability:
  244. * Non-Carbon CFM: not available
  245. * CarbonLib: not available
  246. * Mac OS X: in 3.1 and later
  247. }
  248. function CMRegisterColorDevice(deviceClass: CMDeviceClass; deviceID: CMDeviceID; deviceName: CFDictionaryRef; const (*var*) deviceScope: CMDeviceScope): CMError; external name '_CMRegisterColorDevice';
  249. {
  250. * CMUnregisterColorDevice()
  251. *
  252. * Availability:
  253. * Non-Carbon CFM: not available
  254. * CarbonLib: not available
  255. * Mac OS X: in 3.1 and later
  256. }
  257. function CMUnregisterColorDevice(deviceClass: CMDeviceClass; deviceID: CMDeviceID): CMError; external name '_CMUnregisterColorDevice';
  258. {
  259. Default Device accessors
  260. }
  261. {
  262. * CMSetDefaultDevice()
  263. *
  264. * Availability:
  265. * Non-Carbon CFM: not available
  266. * CarbonLib: not available
  267. * Mac OS X: in 3.1 and later
  268. }
  269. function CMSetDefaultDevice(deviceClass: CMDeviceClass; deviceID: CMDeviceID): CMError; external name '_CMSetDefaultDevice';
  270. {
  271. * CMGetDefaultDevice()
  272. *
  273. * Availability:
  274. * Non-Carbon CFM: not available
  275. * CarbonLib: not available
  276. * Mac OS X: in 3.1 and later
  277. }
  278. function CMGetDefaultDevice(deviceClass: CMDeviceClass; var deviceID: CMDeviceID): CMError; external name '_CMGetDefaultDevice';
  279. {
  280. Device Profile Registration & Access
  281. }
  282. {
  283. * CMSetDeviceFactoryProfiles()
  284. *
  285. * Availability:
  286. * Non-Carbon CFM: not available
  287. * CarbonLib: not available
  288. * Mac OS X: in 3.1 and later
  289. }
  290. function CMSetDeviceFactoryProfiles(deviceClass: CMDeviceClass; deviceID: CMDeviceID; defaultProfID: CMDeviceProfileID; const (*var*) deviceProfiles: CMDeviceProfileArray): CMError; external name '_CMSetDeviceFactoryProfiles';
  291. {
  292. * CMGetDeviceFactoryProfiles()
  293. *
  294. * Availability:
  295. * Non-Carbon CFM: not available
  296. * CarbonLib: not available
  297. * Mac OS X: in 3.1 and later
  298. }
  299. function CMGetDeviceFactoryProfiles(deviceClass: CMDeviceClass; deviceID: CMDeviceID; var defaultProfID: CMDeviceProfileID; var arraySize: UInt32; var deviceProfiles: CMDeviceProfileArray): CMError; external name '_CMGetDeviceFactoryProfiles';
  300. {
  301. * CMSetDeviceProfiles()
  302. *
  303. * Availability:
  304. * Non-Carbon CFM: not available
  305. * CarbonLib: not available
  306. * Mac OS X: in 3.1 and later
  307. }
  308. function CMSetDeviceProfiles(deviceClass: CMDeviceClass; deviceID: CMDeviceID; const (*var*) profileScope: CMDeviceScope; const (*var*) deviceProfiles: CMDeviceProfileArray): CMError; external name '_CMSetDeviceProfiles';
  309. {
  310. * CMGetDeviceProfiles()
  311. *
  312. * Availability:
  313. * Non-Carbon CFM: not available
  314. * CarbonLib: not available
  315. * Mac OS X: in 3.1 and later
  316. }
  317. function CMGetDeviceProfiles(deviceClass: CMDeviceClass; deviceID: CMDeviceID; var arraySize: UInt32; var deviceProfiles: CMDeviceProfileArray): CMError; external name '_CMGetDeviceProfiles';
  318. {
  319. * CMSetDeviceDefaultProfileID()
  320. *
  321. * Availability:
  322. * Non-Carbon CFM: not available
  323. * CarbonLib: not available
  324. * Mac OS X: in 3.1 and later
  325. }
  326. function CMSetDeviceDefaultProfileID(deviceClass: CMDeviceClass; deviceID: CMDeviceID; defaultProfID: CMDeviceProfileID): CMError; external name '_CMSetDeviceDefaultProfileID';
  327. {
  328. * CMGetDeviceDefaultProfileID()
  329. *
  330. * Availability:
  331. * Non-Carbon CFM: not available
  332. * CarbonLib: not available
  333. * Mac OS X: in 3.1 and later
  334. }
  335. function CMGetDeviceDefaultProfileID(deviceClass: CMDeviceClass; deviceID: CMDeviceID; var defaultProfID: CMDeviceProfileID): CMError; external name '_CMGetDeviceDefaultProfileID';
  336. {
  337. * CMGetDeviceProfile()
  338. *
  339. * Availability:
  340. * Non-Carbon CFM: not available
  341. * CarbonLib: not available
  342. * Mac OS X: in 3.1 and later
  343. }
  344. function CMGetDeviceProfile(deviceClass: CMDeviceClass; deviceID: CMDeviceID; profileID: CMDeviceProfileID; var deviceProfLoc: CMProfileLocation): CMError; external name '_CMGetDeviceProfile';
  345. {
  346. * CMSetDeviceProfile()
  347. *
  348. * Availability:
  349. * Non-Carbon CFM: not available
  350. * CarbonLib: not available
  351. * Mac OS X: in 3.1 and later
  352. }
  353. function CMSetDeviceProfile(deviceClass: CMDeviceClass; deviceID: CMDeviceID; const (*var*) profileScope: CMDeviceScope; profileID: CMDeviceProfileID; const (*var*) deviceProfLoc: CMProfileLocation): CMError; external name '_CMSetDeviceProfile';
  354. {
  355. Other Device State/Info accessors
  356. }
  357. {
  358. * CMSetDeviceState()
  359. *
  360. * Availability:
  361. * Non-Carbon CFM: not available
  362. * CarbonLib: not available
  363. * Mac OS X: in 3.1 and later
  364. }
  365. function CMSetDeviceState(deviceClass: CMDeviceClass; deviceID: CMDeviceID; deviceState: CMDeviceState): CMError; external name '_CMSetDeviceState';
  366. {
  367. * CMGetDeviceState()
  368. *
  369. * Availability:
  370. * Non-Carbon CFM: not available
  371. * CarbonLib: not available
  372. * Mac OS X: in 3.1 and later
  373. }
  374. function CMGetDeviceState(deviceClass: CMDeviceClass; deviceID: CMDeviceID; var deviceState: CMDeviceState): CMError; external name '_CMGetDeviceState';
  375. {
  376. * CMGetDeviceInfo()
  377. *
  378. * Availability:
  379. * Non-Carbon CFM: not available
  380. * CarbonLib: not available
  381. * Mac OS X: in 3.1 and later
  382. }
  383. function CMGetDeviceInfo(deviceClass: CMDeviceClass; deviceID: CMDeviceID; var deviceInfo: CMDeviceInfo): CMError; external name '_CMGetDeviceInfo';
  384. {
  385. Device Data & Profile Iterators
  386. }
  387. {
  388. * CMIterateColorDevices()
  389. *
  390. * Availability:
  391. * Non-Carbon CFM: not available
  392. * CarbonLib: not available
  393. * Mac OS X: in 3.1 and later
  394. }
  395. function CMIterateColorDevices(proc: CMIterateDeviceInfoProcPtr; var seed: UInt32; var count: UInt32; refCon: UnivPtr): CMError; external name '_CMIterateColorDevices';
  396. {
  397. * CMIterateDeviceProfiles()
  398. *
  399. * Availability:
  400. * Non-Carbon CFM: not available
  401. * CarbonLib: not available
  402. * Mac OS X: in 3.1 and later
  403. }
  404. function CMIterateDeviceProfiles(proc: CMIterateDeviceProfileProcPtr; var seed: UInt32; var count: UInt32; flags: UInt32; refCon: UnivPtr): CMError; external name '_CMIterateDeviceProfiles';
  405. {$endc} {TARGET_API_MAC_OSX}
  406. {$ALIGN MAC68K}
  407. end.