Leaked source code of windows server 2003
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.

221 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. w32draut
  5. Abstract:
  6. This module defines a special subclass of the Win32 client-side RDP
  7. printer redirection "device" class. The subclass, W32DrAutoPrn manages
  8. a queue that is automatically discovered by the client via enumerating
  9. client-side printer queues.
  10. Author:
  11. Tad Brockway 3/23/99
  12. Revision History:
  13. --*/
  14. #ifndef __W32DRAUT_H__
  15. #define __W32DRAUT_H__
  16. #include "w32drprn.h"
  17. ///////////////////////////////////////////////////////////////
  18. //
  19. // Defines
  20. //
  21. #define REG_RDPDR_AUTO_PORT _T("AutoPrinterPort")
  22. #define REG_RDPDR_FILTER_QUEUE_TYPE _T("FilterQueueType")
  23. #define FILTER_LPT_QUEUES 0x00000001
  24. #define FILTER_COM_QUEUES 0x00000002
  25. #define FILTER_USB_QUEUES 0x00000004
  26. #define FILTER_NET_QUEUES 0x00000008
  27. #define FILTER_RDP_QUEUES 0x00000010
  28. #define FILTER_ALL_QUEUES 0xFFFFFFFF
  29. ///////////////////////////////////////////////////////////////
  30. //
  31. // W32DrAutoPrn
  32. //
  33. //
  34. #define LOCAL_PRINTING_DOCNAME_LEN MAX_PATH
  35. class W32DrAutoPrn : public W32DrPRN
  36. {
  37. private:
  38. typedef struct _PrinterInfo {
  39. LPTSTR pPrinterName;
  40. LPTSTR pPortName;
  41. LPTSTR pDriverName;
  42. DWORD Attributes;
  43. } PRINTERINFO, *PPRINTERINFO;
  44. HANDLE _printerHandle;
  45. protected:
  46. ULONG _jobID;
  47. BOOL _bRunningOn9x;
  48. TCHAR _szLocalPrintingDocName[LOCAL_PRINTING_DOCNAME_LEN];
  49. // Get the name of the printing document to use for server print jobs.
  50. LPTSTR GetLocalPrintingDocName();
  51. // End any jobs in progress and close the printer.
  52. VOID ClosePrinter();
  53. //
  54. // IO Processing Functions
  55. //
  56. // This subclass of DrDevice handles the following IO requests. These
  57. // functions may be overridden in a subclass.
  58. //
  59. // pIoRequestPacket - Request packet received from server.
  60. // packetLen - Length of the packet
  61. //
  62. //
  63. virtual VOID MsgIrpCreate(
  64. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  65. IN UINT32 packetLen
  66. );
  67. virtual VOID MsgIrpCleanup(
  68. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  69. IN UINT32 packetLen
  70. ) {
  71. // Use the default handler.
  72. DefaultIORequestMsgHandle(pIoRequestPacket, STATUS_SUCCESS);
  73. }
  74. virtual VOID MsgIrpClose(
  75. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  76. IN UINT32 packetLen
  77. );
  78. virtual VOID MsgIrpRead(
  79. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  80. IN UINT32 packetLen
  81. ) {
  82. // Use the default handler and fail the read.
  83. DefaultIORequestMsgHandle(pIoRequestPacket, STATUS_UNSUCCESSFUL);
  84. }
  85. virtual VOID MsgIrpFlushBuffers(
  86. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  87. IN UINT32 packetLen
  88. ) {
  89. // Use the default handler.
  90. DefaultIORequestMsgHandle(pIoRequestPacket, STATUS_SUCCESS);
  91. }
  92. //
  93. // Async IO Management Functions
  94. //
  95. DWORD AsyncWriteIOFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  96. DWORD AsyncMsgIrpCloseFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  97. DWORD AsyncMsgIrpCreateFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  98. //
  99. // Open a printer with highest access possible.
  100. //
  101. BOOL W32DrOpenPrinter(LPTSTR pPrinterName, LPHANDLE phPrinter) ;
  102. //
  103. // Disable annoying printer pop up for the specified printer
  104. // and print job.
  105. //
  106. VOID DisablePrinterPopup(HANDLE hPrinterHandle, ULONG ulJobID);
  107. //
  108. // Create a "friendly" printer name from the printer name of a
  109. // network printer.
  110. //
  111. static LPTSTR CreateFriendlyNameFromNetworkName(LPTSTR printerName,
  112. BOOL serverIsWin2K);
  113. //
  114. // Create a printer name from the names stored in the registry.
  115. //
  116. static LPTSTR CreateNestedName(LPTSTR printerName, BOOL* pfNetwork);
  117. //
  118. // Get the printer name of the default printer.
  119. //
  120. // This function allocates memory and returns a pointer
  121. // to the allocated string, if successful. Otherwise, it returns
  122. // NULL.
  123. //
  124. static LPTSTR GetRDPDefaultPrinter();
  125. //
  126. // Check if printer is visible in our session
  127. //
  128. static BOOL ShouldAddThisPrinter(
  129. DWORD queueFilter,
  130. DWORD userSessionID,
  131. PPRINTERINFO pPrinterInfo,
  132. DWORD printerSessionID
  133. );
  134. // Returns the configurable print redirection filter mask.
  135. static DWORD GetPrinterFilterMask(ProcObj *procObj);
  136. //
  137. // Get printer info for a printer and its corresponding TS session ID, if it
  138. // exists.
  139. //
  140. static DWORD GetPrinterInfoAndSessionID(
  141. IN ProcObj *procObj,
  142. IN LPTSTR printerName,
  143. IN DWORD printerAttribs,
  144. IN OUT BYTE **pPrinterInfoBuf,
  145. IN OUT DWORD *pPrinterInfoBufSize,
  146. OUT DWORD *sessionID,
  147. OUT PPRINTERINFO printerInfo
  148. );
  149. public:
  150. //
  151. // Constructor/Destructor
  152. //
  153. W32DrAutoPrn(ProcObj *processObject,
  154. const DRSTRING printerName, const DRSTRING driverName,
  155. const DRSTRING portName, BOOL isDefault, ULONG deviceID,
  156. const TCHAR *devicePath);
  157. virtual ~W32DrAutoPrn();
  158. //
  159. // Enumerate devices of this type.
  160. //
  161. static DWORD Enumerate(ProcObj *procObj, DrDeviceMgr *deviceMgr);
  162. //
  163. // Get the device type. See "Device Types" section of rdpdr.h
  164. //
  165. virtual ULONG GetDeviceType() { return RDPDR_DTYP_PRINT; }
  166. //
  167. // Return the class name.
  168. //
  169. virtual DRSTRING ClassName() { return TEXT("W32DrAutoPrn"); }
  170. };
  171. #endif