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.

224 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. w32drprn
  5. Abstract:
  6. This module defines the parent for the Win32 client-side RDP
  7. printer redirection "device" class hierarchy, W32DrPRN.
  8. Author:
  9. Tad Brockway 3/23/99
  10. Revision History:
  11. --*/
  12. #ifndef __W32DRPRN_H__
  13. #define __W32DRPRN_H__
  14. #include "drprn.h"
  15. #include "drdevasc.h"
  16. ///////////////////////////////////////////////////////////////
  17. //
  18. // Defines
  19. //
  20. #define REG_RDPDR_PRINTER_CACHE_DATA _T("PrinterCacheData")
  21. #define REG_RDPDR_AUTO_PRN_CACHE_DATA _T("AutoPrinterCacheData")
  22. #define REG_RDPDR_CACHED_PRINTERS \
  23. _T("Software\\Microsoft\\Terminal Server Client\\Default\\AddIns\\RDPDR")
  24. #define REG_TERMINALSERVERCLIENT \
  25. _T("Software\\Microsoft\\Terminal Server Client")
  26. #define REG_RDPDR_PRINTER_MAXCACHELEN _T("MaxPrinterCacheLength")
  27. #define DEFAULT_MAXCACHELEN 500 //500K bytes
  28. #ifdef OS_WINCE
  29. #define REG_RDPDR_WINCE_DEFAULT_PRN _T("WBT\\Printers\\Default")
  30. #endif
  31. ///////////////////////////////////////////////////////////////
  32. //
  33. // W32DrPRN
  34. //
  35. //
  36. class W32DrPRN : public W32DrDeviceAsync, public DrPRN
  37. {
  38. protected:
  39. //
  40. // Port Name
  41. //
  42. TCHAR _portName[MAX_PATH];
  43. //
  44. // Maximum cache data length.
  45. // This will be the same for all printers
  46. //
  47. static DWORD _maxCacheDataSize;
  48. //
  49. // IO Processing Functions
  50. //
  51. // This subclass of DrDevice handles the following IO requests. These
  52. // functions may be overridden in a subclass.
  53. //
  54. // pIoRequestPacket - Request packet received from server.
  55. // packetLen - Length of the packet
  56. //
  57. virtual VOID MsgIrpDeviceControl(
  58. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  59. IN UINT32 packetLen
  60. ){
  61. // We just fail IOCTL's. That's okay for now because the
  62. // server-side print drivers don't expect us to succeed them
  63. // anyway.
  64. DefaultIORequestMsgHandle(pIoRequestPacket, STATUS_UNSUCCESSFUL);
  65. };
  66. //
  67. // Printer Caching Functions. These are currently static
  68. // because printer caching wasn't designed around a device
  69. // object in the original design for RDPDR client-side device
  70. // redirection.
  71. //
  72. static W32DrPRN *ResolveCachedPrinter(
  73. ProcObj *procObj,
  74. DrDeviceMgr *deviceMgr,
  75. HKEY hParentKey,
  76. LPTSTR printerName
  77. );
  78. static ULONG AddPrinterCacheInfo(
  79. PRDPDR_PRINTER_ADD_CACHEDATA pAddPrinterData,
  80. UINT32 maxDataLen
  81. );
  82. static ULONG DeletePrinterCacheInfo(
  83. PRDPDR_PRINTER_DELETE_CACHEDATA pDeletePrinterData,
  84. UINT32 maxDataLen
  85. );
  86. static ULONG UpdatePrinterCacheInfo(
  87. PRDPDR_PRINTER_UPDATE_CACHEDATA pUpdatePrinterData,
  88. UINT32 maxDataLen
  89. );
  90. static ULONG RenamePrinterCacheInfo(
  91. PRDPDR_PRINTER_RENAME_CACHEDATA pRenamePrinterData,
  92. UINT32 maxDataLen
  93. );
  94. static VOID RenamePrinter(LPTSTR pwszOldname, LPTSTR pwszNewname);
  95. static DWORD GetMaxCacheDataSize() {return _maxCacheDataSize;}
  96. #ifdef OS_WINCE
  97. static ULONG GetCachedDataSize(
  98. HKEY hPrinterKey
  99. );
  100. static ULONG ReadCachedData(
  101. HKEY hPrinterKey,
  102. UCHAR *pBuf,
  103. ULONG *pulSize
  104. );
  105. static ULONG WriteCachedData(
  106. HKEY hPrinterKey,
  107. UCHAR *pBuf,
  108. ULONG ulSize
  109. );
  110. #endif
  111. public:
  112. //
  113. // Constructor/Destructor
  114. //
  115. W32DrPRN(ProcObj *processObject, const DRSTRING printerName,
  116. const DRSTRING driverName, const DRSTRING portName,
  117. const DRSTRING pnpName, BOOL isDefaultPrinter, ULONG id,
  118. const TCHAR *devicePath=TEXT(""));
  119. //
  120. // Process device cache info packet.
  121. //
  122. static VOID ProcessPrinterCacheInfo(
  123. PRDPDR_PRINTER_CACHEDATA_PACKET pCachePacket,
  124. UINT32 maxDataLen
  125. );
  126. //
  127. // Return the object name.
  128. //
  129. virtual DRSTRING GetName() {
  130. DC_BEGIN_FN("W32DrPRN::GetName");
  131. ASSERT(IsValid());
  132. DC_END_FN();
  133. return GetPrinterName();
  134. }
  135. //
  136. // Return the size (in bytes) of a device announce packet for
  137. // this device.
  138. //
  139. virtual ULONG GetDevAnnounceDataSize();
  140. //
  141. // Add a device announce packet for this device to the input
  142. // buffer.
  143. //
  144. virtual VOID GetDevAnnounceData(IN PRDPDR_DEVICE_ANNOUNCE buf);
  145. //
  146. // Return whether this class instance is valid.
  147. //
  148. virtual BOOL IsValid()
  149. {
  150. return(W32DrDevice::IsValid() && DrPRN::IsValid());
  151. }
  152. //
  153. // Get/set the printer port name.
  154. //
  155. virtual BOOL SetPortName(const LPTSTR name);
  156. virtual const LPTSTR GetPortName();
  157. //
  158. // Return the class name.
  159. //
  160. virtual DRSTRING ClassName() { return TEXT("W32DrPRN"); }
  161. };
  162. ///////////////////////////////////////////////////////////////
  163. //
  164. // W32DrPRN Inline Members
  165. //
  166. inline BOOL W32DrPRN::SetPortName(const LPTSTR name)
  167. {
  168. memset(_portName, 0, sizeof(_portName));
  169. _tcsncpy(_portName, name, MAX_PATH-1);
  170. return TRUE;
  171. }
  172. inline const LPTSTR W32DrPRN::GetPortName()
  173. {
  174. return _portName;
  175. }
  176. #endif