Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

460 lines
18 KiB

  1. /*
  2. File: PMPrinterModule.h
  3. Contains: Mac OS X Printing Manager Printer Module Interfaces.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1999-2001 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __CFSTRING__
  11. #include <CFString.h>
  12. #endif
  13. #ifndef __PMTICKET__
  14. #include <PMTicket.h>
  15. #endif
  16. #ifndef __PMPLUGINHEADER__
  17. #include <PMPluginHeader.h>
  18. #endif
  19. #ifndef __PMERRORS__
  20. #include <PMErrors.h>
  21. #endif
  22. #ifndef __PMRASTER__
  23. #include <PMRaster.h>
  24. #endif
  25. /* context ID for PM Modules */
  26. #if PRAGMA_ONCE
  27. #pragma once
  28. #endif
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #if PRAGMA_IMPORT
  33. #pragma import on
  34. #endif
  35. #if PRAGMA_STRUCT_ALIGN
  36. #pragma options align=mac68k
  37. #elif PRAGMA_STRUCT_PACKPUSH
  38. #pragma pack(push, 2)
  39. #elif PRAGMA_STRUCT_PACK
  40. #pragma pack(2)
  41. #endif
  42. typedef struct OpaquePMContext* PMContext;
  43. /* Opaque types for image access: */
  44. typedef struct OpaquePMDrawingCtx* PMDrawingCtx;
  45. typedef struct OpaquePMImageRef* PMImageRef;
  46. /* Type ID, interface ID for the IOM CFPlugin */
  47. #define kPModuleTypeIDStr "5D69ED5E-D5B5-11D3-9EFF-00050209D9C1"
  48. #define kPModuleIntfIDStr "5EDEC4FA-D5B5-11D3-AAF2-00050209D9C1"
  49. /* PM API version numbers (see PMPluginHeader.h for the meaning of these defintions) */
  50. enum {
  51. kPMBuildVersionMajor = 1,
  52. kPMBuildVersionMinor = 0,
  53. kPMBaseVersionMajor = 1,
  54. kPMBaseVersionMinor = 0
  55. };
  56. /*
  57. Keys for the printer browser specification dictionary. This CFDictionary,
  58. created by the printer module, provides a printer browser module with the
  59. information it needs to browse for a given type of printer over its
  60. connection type, and to display it in PrintCenter's Browser Window.
  61. kPMPrinterBrowserKindKey corresponds to a CFStringRef to a human-readable
  62. printer type string that can be displayed in the browser view. For a printer
  63. driven by Apple's PostScript printer module over an AppleTalk connection,
  64. this would be the string "PostScript printer".
  65. kPMPrinterBrowserInfoKey corresponds to a CFTypeRef to connection-specific
  66. information used to look up a particular kind of printer over a given IO
  67. connection. A PostScript printer module supporting AppleTalk might specify
  68. the NBP lookup string "LaserWriter".
  69. kPMPrinterBrowserIconKey corresponds to a CFDataRef to the icon family data
  70. for the printer icon to be displayed in the browser view. The family data
  71. are entirely contained within the CFDataRef; i.e., it is *not* a handle.
  72. kPMPrinterBrowserDeviceIDKey corresponds to a CFStringRef to a USB/Firewire
  73. IEEE-1284 DeviceID string. e.g., "COMMAND SET: PostScript;" or
  74. "MFG: Hewlett-Packard; MDL: DeskJet 935C;"
  75. */
  76. #define kPMPrinterBrowserKindKey CFSTR("Printer Browser Kind")
  77. #define kPMPrinterBrowserInfoKey CFSTR("Printer Browser Info")
  78. #define kPMPrinterBrowserIconsKey CFSTR("Printer Browser Icons")
  79. #define kPMPrinterBrowserDeviceIDKey CFSTR("Printer Browser DeviceID")
  80. enum {
  81. kPMBrowserInfoNumValues = 4
  82. };
  83. /* Status and Error notification: */
  84. /*
  85. * PMNotificationProcPtr
  86. *
  87. * Discussion:
  88. * A callback routine used for reporting printing status and errors
  89. * during a print job Event is constructed with known keys defined
  90. * below and passed to the printing manager in notificationDict
  91. * notificationReplyDict is used for blocking recoverable errors to
  92. * indicate user action
  93. */
  94. typedef CALLBACK_API_C( OSStatus , PMNotificationProcPtr )(const void *jobContext, CFDictionaryRef notificationDict, CFDictionaryRef *notificationReplyDict);
  95. /*
  96. * Discussion:
  97. * Status and error event codes and keys reported by the printer
  98. * module (used in PMNotificationProc)
  99. */
  100. enum {
  101. /*
  102. * non-error printer status
  103. */
  104. kPMEventPrinterStatus = 4000,
  105. /*
  106. * a fatal printing error has occurred. The Printer Module MUST stop
  107. * printing and return immediately after sending this event.
  108. */
  109. kPMEventErrorOccurred = 4001,
  110. /*
  111. * an auto-recoverable error occurred. The PM SHOULD keep trying to
  112. * print the job without waiting for any user action. If the PM
  113. * detects that the condition is cleared, it MUST send a
  114. * kPMEventRecoverableErrorCleared event, otherwise the condition
  115. * alert will not get cleared
  116. */
  117. kPMEventRecoverableErrorOccurred = 4002,
  118. /*
  119. * auto-recoverable error has been cleared, the job is continued
  120. * automatically and without user intervention. This event causes
  121. * the condition alert to close and the job state to change to
  122. * "printing".
  123. */
  124. kPMEventRecoverableErrorCleared = 4003
  125. };
  126. /* Event keys used in notification dictionaries */
  127. #define kPMEventCodeKey CFSTR("com.apple.printing.EventCode")
  128. /* CFNumber (SInt32) containing the event code (above) */
  129. #define kPMErrorCodeKey CFSTR("com.apple.printing.ErrorCode")
  130. /* CFNumber (SInt32) containing the error code (i.e., OSStatus) */
  131. #define kPMErrorExplanationKey CFSTR("com.apple.printing.ErrorExplanation")
  132. /* CFString containing the text that shows up as bold text in the error/status alert */
  133. #define kPMErrorTextKey CFSTR("com.apple.printing.ErrorText")
  134. /* CFString containing the text that shows up as regular text in the error/status alert */
  135. #define kPMEventContextKey CFSTR("com.apple.printing.EventContext")
  136. /* CFNumber (SInt32) containing a context value. Used primarily to match a "cleared error" event with a prior "recoverable error" event */
  137. /* prototypes for callback routines used for accessing print data */
  138. typedef CALLBACK_API_C( OSStatus , PMJobStreamOpenProcPtr )(const void * jobContext);
  139. typedef CALLBACK_API_C( OSStatus , PMJobStreamReadWriteProcPtr )(const void *jobContext, void *buffPtr, UInt32 *size);
  140. typedef CALLBACK_API_C( OSStatus , PMJobStreamGetPosProcPtr )(const void *jobContext, UInt32 *markerPos);
  141. typedef CALLBACK_API_C( OSStatus , PMJobStreamSetPosProcPtr )(const void *jobContext, SInt16 posMode, UInt32 markerPos);
  142. typedef CALLBACK_API_C( OSStatus , PMJobStreamGetNextBandProcPtr )(const void *jobContext, PMRasterBand *pmRasterBand);
  143. /* the printing manager maintains this struct of callback procs for printer module data access */
  144. struct PMJobStreamProcs {
  145. CFIndex version;
  146. PMJobStreamOpenProcPtr PMJobStreamOpenProc;
  147. PMJobStreamReadWriteProcPtr PMJobStreamReadProc;
  148. PMJobStreamReadWriteProcPtr PMJobStreamWriteProc;
  149. PMJobStreamGetPosProcPtr PMJobStreamGetPosProc;
  150. PMJobStreamSetPosProcPtr PMJobStreamSetPosProc;
  151. PMJobStreamGetPosProcPtr PMJobStreamGetEOFProc;
  152. };
  153. typedef struct PMJobStreamProcs PMJobStreamProcs;
  154. /* prototypes for callback routines used for communication with the device/connection */
  155. typedef CALLBACK_API_C( OSStatus , GetConnInfoProcPtr )(const void *jobContext, CFStringRef *connectionType, CFStringRef *pbmPath);
  156. typedef CALLBACK_API_C( OSStatus , PMIOOpenProcPtr )(const void * jobContext);
  157. typedef CALLBACK_API_C( OSStatus , PMIOReadProcPtr )(const void *jobContext, Ptr buffer, UInt32 *size, Boolean *eoj);
  158. typedef CALLBACK_API_C( OSStatus , PMIOWriteProcPtr )(const void *jobContext, Ptr buffer, UInt32 *size, Boolean eoj);
  159. typedef CALLBACK_API_C( OSStatus , PMIOStatusProcPtr )(const void *jobContext, CFStringRef *status);
  160. typedef CALLBACK_API_C( OSStatus , PMIOGetAttributeProcPtr )(const void *jobContext, CFStringRef attribute, CFTypeRef *result);
  161. typedef CALLBACK_API_C( OSStatus , PMIOSetAttributeProcPtr )(const void *jobContext, CFStringRef attribute, CFTypeRef data);
  162. typedef CALLBACK_API_C( OSStatus , PMIOCloseProcPtr )(const void * jobContext);
  163. /*
  164. * PMIOProcs
  165. *
  166. * Discussion:
  167. * The printing manager maintains this struct of callback procs for
  168. * printer module communication with the device
  169. */
  170. struct PMIOProcs {
  171. CFIndex version;
  172. /*
  173. * Get connection type string and Printer Browser Module path
  174. */
  175. GetConnInfoProcPtr GetConnInfoProc;
  176. /*
  177. * Open connection with target printer
  178. */
  179. PMIOOpenProcPtr PMIOOpenProc;
  180. /*
  181. * Read data from printer
  182. */
  183. PMIOReadProcPtr PMIOReadProc;
  184. /*
  185. * Write data to printer. Data is not buffered no matter how small
  186. * the buffer is. Therefore, it is recommended that the PM do its own
  187. * buffering before this call is made.
  188. */
  189. PMIOWriteProcPtr PMIOWriteProc;
  190. /*
  191. * Get status from the printer if any
  192. */
  193. PMIOStatusProcPtr PMIOStatusProc;
  194. /*
  195. * Get the value for a particular IOM attribute (see PMIOModule.h for
  196. * a list of attributes)
  197. */
  198. PMIOGetAttributeProcPtr PMIOGetAttributeProc;
  199. /*
  200. * Set a value for a particular IOM attribute (see PMIOModule.h for a
  201. * list of attributes)
  202. */
  203. PMIOSetAttributeProcPtr PMIOSetAttributeProc;
  204. /*
  205. * Close connection with printer.
  206. */
  207. PMIOCloseProcPtr PMIOCloseProc;
  208. };
  209. typedef struct PMIOProcs PMIOProcs;
  210. typedef CALLBACK_API_C( OSStatus , PMCreatePrinterBrowserModuleInfoProcPtr )(CFStringRef connectionType, CFArrayRef *printerBrowserInfo);
  211. typedef CALLBACK_API_C( OSStatus , PMInitializeProcPtr )(CFDataRef printerAddress, const void *jobContext, const PMIOProcs *pmIOProcs, PMNotificationProcPtr pmNotificationProc, PMContext *printerModuleContext);
  212. typedef CALLBACK_API_C( OSStatus , PMCreatePrintingDialogExtensionsPathsProcPtr )(PMContext printerModuleContext, CFArrayRef *pdePaths);
  213. typedef CALLBACK_API_C( OSStatus , PMCreatePrinterTicketsProcPtr )(PMContext printerModuleContext, PMTicketRef *printerInfo, PMTemplateRef *jobTemplate);
  214. typedef CALLBACK_API_C( OSStatus , PMBeginJobProcPtr )(PMContext printerModuleContext, const void *jobContext, PMTicketRef jobTicket, PMTicketRef *converterSetup);
  215. typedef CALLBACK_API_C( OSStatus , PMPrintJobProcPtr )(PMContext printerModuleContext, const void *jobContext, PMTicketRef jobTicket, const PMJobStreamProcs *inDataProcs);
  216. typedef CALLBACK_API_C( OSStatus , PMPrintPageProcPtr )(PMContext printerModuleContext, const void *jobContext, PMTicketRef jobTicket, PMJobStreamGetNextBandProcPtr pmJobStreamGetNextBandProc);
  217. typedef CALLBACK_API_C( OSStatus , PMImageAccessProcPtr )(PMContext printerModuleContext, const void *jobContext, CFStringRef grafBase, PMDrawingCtx drawingCtx, PMImageRef imageRef, PMImageRef *outImageRefPtr);
  218. typedef CALLBACK_API_C( OSStatus , PMCancelJobProcPtr )(PMContext printerModuleContext, const void *jobContext);
  219. typedef CALLBACK_API_C( OSStatus , PMEndJobProcPtr )(PMContext printerModuleContext, const void *jobContext);
  220. typedef CALLBACK_API_C( OSStatus , PMTerminateProcPtr )(PMContext *printerModuleContext, const void *jobContext);
  221. /*
  222. * PMProcs
  223. *
  224. * Discussion:
  225. * Contains the function pointers required to be exported by a
  226. * Printer Module.
  227. */
  228. struct PMProcs {
  229. /*
  230. * The plugin header is required with all plugins and must proceed
  231. * object's layout.
  232. */
  233. PMPlugInHeader pluginHeader;
  234. /*
  235. * For a given connection type in 'connectionType', returns a ticket
  236. * containing printer browser information about the supported
  237. * printers that can be browsed for on that connection. If the
  238. * connection is not supported by the Printer Module,
  239. * kPMUnsupportedConnection error is returned.
  240. */
  241. PMCreatePrinterBrowserModuleInfoProcPtr CreatePrinterBrowserModuleInfo;
  242. /*
  243. * Create a new instance of the Printer Module and place it's
  244. * reference in 'printerModuleContext'. Few input parameters are
  245. * passed via this API that the PM should store in its local context
  246. * block for use during the session; such as: printerAddress,
  247. * jobContext (used in callbacks), pmIOProcs (used for communicating
  248. * with the device, and pmNotificationProc (used for reporting status
  249. * and errors).
  250. */
  251. PMInitializeProcPtr Initialize;
  252. /*
  253. * Return one or more paths of this Printer Module's Print Dialog
  254. * Extension(s) relative to base path /Library/Printers/
  255. */
  256. PMCreatePrintingDialogExtensionsPathsProcPtr CreatePrintingDialogExtensionsPaths;
  257. /*
  258. * Returns printer module's template and printerinfo tickets to the
  259. * caller. A PrinterInfo ticket holds capability and product ID
  260. * information whereas a Template holds range and default information
  261. * about various print settings
  262. */
  263. PMCreatePrinterTicketsProcPtr CreatePrinterTickets;
  264. /*
  265. * Called by the Printing Manager to initiate a job. This function is
  266. * intended as a "setup" function, so all the information needed to
  267. * set up for printing is supplied: jobTicket has the control
  268. * parameters for this job, as defined by the application and user;
  269. * converterSetp allows the PM to setup a converter via standard
  270. * ticket tags.
  271. */
  272. PMBeginJobProcPtr BeginJob;
  273. /*
  274. * Begin sending print data to the printer. The Printing Manager
  275. * calls this API when page boundaries in the job can not be
  276. * determined (i.e PM specific format). inDataProcs contains
  277. * callbacks to access the print data; see PMJobStreamProcs
  278. * definitions above for more info on the callback routines.
  279. */
  280. PMPrintJobProcPtr PrintJob;
  281. /*
  282. * Send only a specific page to the printer. The PM needs to process
  283. * the data and make it ready for the printer hardware.
  284. * PMJobStreamGetNextBandProc is a callback to get the next available
  285. * band data.
  286. */
  287. PMPrintPageProcPtr PrintPage;
  288. /*
  289. * This API is called when an image is encountered during conversion.
  290. * This allows the Printer Module to access and modify the image
  291. * data (imageRef) and drawing context before the image is rasterized
  292. * into the page bands. Modified image should be returned in
  293. * outImageRefPtr.
  294. */
  295. PMImageAccessProcPtr ImageAccess;
  296. /*
  297. * Cancel the currently printing job. This function may be called
  298. * while the PM is executing code in PrintJob or PrintPage.
  299. */
  300. PMCancelJobProcPtr CancelJob;
  301. /*
  302. * Finish up the previously printed job.
  303. */
  304. PMEndJobProcPtr EndJob;
  305. /*
  306. * Dispose of the current PM session data allocated in Initialize.
  307. */
  308. PMTerminateProcPtr Terminate;
  309. };
  310. typedef struct PMProcs PMProcs;
  311. /* PM interface is an object containing addresses to the module's entry points: */
  312. struct PMInterface {
  313. const PMProcs * vtable;
  314. };
  315. typedef struct PMInterface PMInterface;
  316. typedef const PMInterface * PMInterfaceRef;
  317. /*
  318. Paper names must all be ISO or PPD standard names, so we've defined constants here for
  319. developers to use in their code, mostly to make things more readable.
  320. */
  321. #define USExecutiveEnvelope CFSTR("Executive")
  322. #define Envelope9 CFSTR("na-number-9-envelope")
  323. #define Envelope10 CFSTR("na-number-10-envelope")
  324. #define Envelope10x15 CFSTR("na-10x15-envelope")
  325. #define EnvelopeB4 CFSTR("iso-b4-envelope")
  326. #define EnvelopeB5 CFSTR("iso-b5-envelope")
  327. #define EnvelopeC3 CFSTR("iso-c3-envelope")
  328. #define EnvelopeC4 CFSTR("iso-c4-envelope")
  329. #define EnvelopeC5 CFSTR("iso-c5-envelope")
  330. #define EnvelopeC6 CFSTR("iso-c6-envelope")
  331. #define Envelope6x9 CFSTR("na-6x9-envelope")
  332. #define Envelope7x9 CFSTR("na-7x9-envelope")
  333. #define Envelope9x11 CFSTR("na-9x11-envelope")
  334. #define Envelope9x12 CFSTR("na-9x12-envelope")
  335. #define Envelope10x13 CFSTR("na-10x13-envelope")
  336. #define Envelope10x14 CFSTR("na-10x14-envelope")
  337. #define EnvelopeMonarch CFSTR("monarch-envelope")
  338. #define EnvelopeLong CFSTR("iso-designated-long-envelope")
  339. #define Invoice CFSTR("invoice")
  340. #define USLetter CFSTR("na-letter")
  341. #define USLegal CFSTR("na-legal")
  342. #define Ledger CFSTR("ledger")
  343. #define Folio CFSTR("folio")
  344. #define Quarto CFSTR("quarto")
  345. #define A0 CFSTR("iso-a0")
  346. #define A1 CFSTR("iso-a1")
  347. #define A2 CFSTR("iso-a2")
  348. #define A3 CFSTR("iso-a3")
  349. #define A4 CFSTR("iso-a4")
  350. #define A5 CFSTR("iso-a5")
  351. #define A6 CFSTR("iso-a6")
  352. #define A7 CFSTR("iso-a7")
  353. #define A8 CFSTR("iso-a8")
  354. #define A9 CFSTR("iso-a9")
  355. #define B0 CFSTR("iso-b0")
  356. #define B1 CFSTR("iso-b1")
  357. #define B2 CFSTR("iso-b2")
  358. #define B3 CFSTR("iso-b3")
  359. #define B4 CFSTR("iso-b4")
  360. #define B5 CFSTR("iso-b5")
  361. #define B6 CFSTR("iso-b6")
  362. #define B7 CFSTR("iso-b7")
  363. #define B8 CFSTR("iso-b8")
  364. #define B9 CFSTR("iso-b9")
  365. #define B10 CFSTR("iso-b10")
  366. #define JISB0 CFSTR("jis-b0")
  367. #define JISB1 CFSTR("jis-b1")
  368. #define JISB2 CFSTR("jis-b2")
  369. #define JISB3 CFSTR("jis-b3")
  370. #define JISB4 CFSTR("jis-b4")
  371. #define JISB5 CFSTR("jis-b5")
  372. #define JISB7 CFSTR("jis-b7")
  373. #define JISB8 CFSTR("jis-b8")
  374. #define JISB9 CFSTR("jis-b9")
  375. #define JISB10 CFSTR("jis-b10")
  376. #define ASize CFSTR("a")
  377. #define BSize CFSTR("b")
  378. #define CSize CFSTR("c")
  379. #define DSize CFSTR("d")
  380. #define ESize CFSTR("e")
  381. #define iso10 CFSTR("iso-10")
  382. /* A string to define the default paper name. See sample code for usage.*/
  383. #define DefaultPaper CFSTR("DefaultPaperSize")
  384. #if PRAGMA_STRUCT_ALIGN
  385. #pragma options align=reset
  386. #elif PRAGMA_STRUCT_PACKPUSH
  387. #pragma pack(pop)
  388. #elif PRAGMA_STRUCT_PACK
  389. #pragma pack()
  390. #endif
  391. #ifdef PRAGMA_IMPORT_OFF
  392. #pragma import off
  393. #elif PRAGMA_IMPORT
  394. #pragma import reset
  395. #endif
  396. #ifdef __cplusplus
  397. }
  398. #endif