Source code of Windows XP (NT5)
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.

472 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. cprinter.cxx
  5. Abstract:
  6. Contains methods for PrintQueue object, GeneralInfo property set
  7. and Operation property set for the Print Queue object for the Windows NT
  8. provider
  9. Author:
  10. Ram Viswanathan (ramv) 11-09-95
  11. Revision History:
  12. --*/
  13. #include "nds.hxx"
  14. #pragma hdrstop
  15. //
  16. // CNDSPrintQueue
  17. //
  18. STDMETHODIMP
  19. CNDSPrintQueue::put_Model(THIS_ BSTR bstrModel)
  20. {
  21. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, Model);
  22. }
  23. STDMETHODIMP
  24. CNDSPrintQueue::get_Model(THIS_ BSTR FAR* retval)
  25. {
  26. GET_PROPERTY_BSTR((IADsPrintQueue *)this, Model);
  27. }
  28. STDMETHODIMP
  29. CNDSPrintQueue::put_Datatype(THIS_ BSTR bstrDatatype)
  30. {
  31. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, Datatype);
  32. }
  33. STDMETHODIMP
  34. CNDSPrintQueue::get_Datatype(THIS_ BSTR *retval)
  35. {
  36. GET_PROPERTY_BSTR((IADsPrintQueue *)this, Datatype);
  37. }
  38. STDMETHODIMP
  39. CNDSPrintQueue::put_Description(THIS_ BSTR bstrDescription)
  40. {
  41. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, Description);
  42. }
  43. STDMETHODIMP
  44. CNDSPrintQueue::get_Description(THIS_ BSTR FAR* retval)
  45. {
  46. GET_PROPERTY_BSTR((IADsPrintQueue *)this, Description);
  47. }
  48. STDMETHODIMP CNDSPrintQueue::put_Location(THIS_ BSTR bstrLocation)
  49. {
  50. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, Location);
  51. }
  52. STDMETHODIMP CNDSPrintQueue::get_Location(THIS_ BSTR FAR* retval)
  53. {
  54. GET_PROPERTY_BSTR((IADsPrintQueue *)this, Location);
  55. }
  56. STDMETHODIMP
  57. CNDSPrintQueue::put_Priority(THIS_ LONG lPriority)
  58. {
  59. PUT_PROPERTY_LONG((IADsPrintQueue *)this, Priority);
  60. }
  61. STDMETHODIMP
  62. CNDSPrintQueue::get_Priority(THIS_ LONG FAR* retval)
  63. {
  64. GET_PROPERTY_LONG((IADsPrintQueue *)this, Priority);
  65. }
  66. STDMETHODIMP
  67. CNDSPrintQueue::put_StartTime(THIS_ DATE daStartTime)
  68. {
  69. PUT_PROPERTY_DATE((IADsPrintQueue *)this, StartTime);
  70. }
  71. STDMETHODIMP
  72. CNDSPrintQueue::get_StartTime(THIS_ DATE FAR* retval)
  73. {
  74. GET_PROPERTY_DATE((IADsPrintQueue *)this, StartTime);
  75. }
  76. STDMETHODIMP
  77. CNDSPrintQueue::put_UntilTime(THIS_ DATE daUntilTime)
  78. {
  79. PUT_PROPERTY_DATE((IADsPrintQueue *)this, UntilTime);
  80. }
  81. STDMETHODIMP
  82. CNDSPrintQueue::get_UntilTime(THIS_ DATE FAR* retval)
  83. {
  84. GET_PROPERTY_DATE((IADsPrintQueue *)this, UntilTime);
  85. }
  86. STDMETHODIMP
  87. CNDSPrintQueue::put_DefaultJobPriority(THIS_ LONG lDefaultJobPriority)
  88. {
  89. PUT_PROPERTY_LONG((IADsPrintQueue *)this, DefaultJobPriority);
  90. }
  91. STDMETHODIMP
  92. CNDSPrintQueue::get_DefaultJobPriority(THIS_ LONG FAR* retval)
  93. {
  94. GET_PROPERTY_LONG((IADsPrintQueue *)this, DefaultJobPriority);
  95. }
  96. STDMETHODIMP
  97. CNDSPrintQueue::put_BannerPage(THIS_ BSTR bstrBannerPage)
  98. {
  99. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, BannerPage);
  100. }
  101. STDMETHODIMP
  102. CNDSPrintQueue::get_BannerPage(THIS_ BSTR FAR* retval)
  103. {
  104. GET_PROPERTY_BSTR((IADsPrintQueue *)this, BannerPage);
  105. }
  106. STDMETHODIMP
  107. CNDSPrintQueue::get_PrinterPath(THIS_ BSTR FAR* retval)
  108. {
  109. HRESULT hr = E_FAIL;
  110. RRETURN_EXP_IF_ERR(hr);
  111. }
  112. STDMETHODIMP
  113. CNDSPrintQueue::put_PrinterPath(THIS_ BSTR bstrPrinterPath)
  114. {
  115. //
  116. // Cannot change this in Windows NT!
  117. //
  118. RRETURN_EXP_IF_ERR(E_ADS_PROPERTY_NOT_SUPPORTED);
  119. }
  120. STDMETHODIMP
  121. CNDSPrintQueue::get_PrintProcessor(THIS_ BSTR FAR* retval)
  122. {
  123. GET_PROPERTY_BSTR((IADsPrintQueue *)this, PrintProcessor);
  124. }
  125. STDMETHODIMP
  126. CNDSPrintQueue::put_PrintProcessor(THIS_ BSTR bstrPrintProcessor)
  127. {
  128. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, PrintProcessor);
  129. }
  130. STDMETHODIMP
  131. CNDSPrintQueue::get_PrintDevices(THIS_ VARIANT FAR* retval)
  132. {
  133. GET_PROPERTY_VARIANT((IADsPrintQueue *)this, Ports);
  134. }
  135. STDMETHODIMP
  136. CNDSPrintQueue::put_PrintDevices(THIS_ VARIANT vPorts)
  137. {
  138. PUT_PROPERTY_VARIANT((IADsPrintQueue *)this, Ports);
  139. }
  140. STDMETHODIMP
  141. CNDSPrintQueue::get_NetAddresses(THIS_ VARIANT FAR* retval)
  142. {
  143. GET_PROPERTY_VARIANT((IADsPrintQueue *)this, NetAddresses);
  144. }
  145. STDMETHODIMP
  146. CNDSPrintQueue::put_NetAddresses(THIS_ VARIANT vNetAddresses)
  147. {
  148. PUT_PROPERTY_VARIANT((IADsPrintQueue *)this, NetAddresses);
  149. }
  150. //
  151. // Class CNDSPrintQueue
  152. //
  153. /* IADsFSPrintQueueOperation methods */
  154. STDMETHODIMP
  155. CNDSPrintQueue::PrintJobs(
  156. THIS_ IADsCollection * FAR* ppCollection
  157. )
  158. {
  159. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  160. }
  161. //+------------------------------------------------------------------------
  162. //
  163. // Function: CNDSPrintQueue::Pause
  164. //
  165. // Synopsis: Binds to real printer as specified in _bstrPrinterName
  166. // and attempts to pause the real printer.
  167. //
  168. // Arguments: none
  169. //
  170. // Returns: HRESULT.
  171. //
  172. // Modifies: nothing
  173. //
  174. // History: 11-07-95 RamV Created
  175. // Appropriated from Old NetOle Code.
  176. //
  177. //---------------------------------------------------------------------------
  178. STDMETHODIMP
  179. CNDSPrintQueue::Pause(THIS)
  180. {
  181. HANDLE hPrinter = NULL;
  182. HRESULT hr = S_OK;
  183. BSTR bstrADsPath = NULL;
  184. LPWSTR pszNDSPath = NULL;
  185. //
  186. // Make NDS Path
  187. //
  188. hr = _pADs->get_ADsPath(
  189. &bstrADsPath
  190. );
  191. BAIL_ON_FAILURE(hr);
  192. hr = BuildNDSPathFromADsPath(
  193. bstrADsPath,
  194. &pszNDSPath
  195. );
  196. BAIL_ON_FAILURE(hr);
  197. //
  198. // Open a handle to the printer with Administer access.
  199. //
  200. hr = NWApiOpenPrinter(
  201. pszNDSPath,
  202. &hPrinter,
  203. PRINTER_ACCESS_ADMINISTER
  204. );
  205. BAIL_ON_FAILURE(hr);
  206. //
  207. // Pause printer.
  208. //
  209. hr = NWApiSetPrinter(
  210. hPrinter,
  211. 0,
  212. NULL,
  213. PRINTER_CONTROL_PAUSE
  214. );
  215. error:
  216. if (hPrinter) {
  217. NWApiClosePrinter(hPrinter);
  218. }
  219. if (bstrADsPath) {
  220. ADsFreeString(bstrADsPath);
  221. }
  222. if (pszNDSPath) {
  223. FreeADsStr(pszNDSPath);
  224. }
  225. RRETURN_EXP_IF_ERR(hr);
  226. }
  227. //+---------------------------------------------------------------------------
  228. //
  229. // Function: CNDSPrintQueue::Resume
  230. //
  231. // Synopsis: Binds to real printer as specified in _bstrPrinterName and
  232. // attempts to resume the real printer.
  233. //
  234. // Arguments: void
  235. //
  236. // Returns: HRESULT.
  237. //
  238. // Modifies:
  239. //
  240. // History: 11-07-95 RamV Created
  241. // Appropriated from old NetOle Project
  242. //----------------------------------------------------------------------------
  243. STDMETHODIMP
  244. CNDSPrintQueue::Resume(THIS)
  245. {
  246. HANDLE hPrinter = NULL;
  247. HRESULT hr = S_OK;
  248. LPWSTR pszNDSPath = NULL;
  249. BSTR bstrADsPath = NULL;
  250. //
  251. // Make NDS Path
  252. //
  253. hr = _pADs->get_ADsPath(
  254. &bstrADsPath
  255. );
  256. BAIL_ON_FAILURE(hr);
  257. hr = BuildNDSPathFromADsPath(
  258. bstrADsPath,
  259. &pszNDSPath
  260. );
  261. BAIL_ON_FAILURE(hr);
  262. //
  263. // Open a handle to the printer with Administer access.
  264. //
  265. hr = NWApiOpenPrinter(
  266. pszNDSPath,
  267. &hPrinter,
  268. PRINTER_ACCESS_ADMINISTER
  269. );
  270. BAIL_ON_FAILURE(hr);
  271. //
  272. // Resume printer.
  273. //
  274. hr = NWApiSetPrinter(
  275. hPrinter,
  276. 0,
  277. NULL,
  278. PRINTER_CONTROL_RESUME
  279. );
  280. error:
  281. if (hPrinter) {
  282. NWApiClosePrinter(hPrinter);
  283. }
  284. if (bstrADsPath) {
  285. ADsFreeString(bstrADsPath);
  286. }
  287. if (pszNDSPath) {
  288. FreeADsStr(pszNDSPath);
  289. }
  290. RRETURN_EXP_IF_ERR(hr);
  291. }
  292. //+---------------------------------------------------------------------------
  293. //
  294. // Function: CNDSPrintQueue::Purge
  295. //
  296. // Synopsis: Binds to real printer as specified in _PrinterName and attempts
  297. // to purge the real printer.
  298. //
  299. // Arguments: void
  300. //
  301. // Returns: HRESULT.
  302. //
  303. // Modifies:
  304. //
  305. // History: 11-07-95 RamV Created
  306. // Appropriated from old NetOle Code
  307. //----------------------------------------------------------------------------
  308. STDMETHODIMP
  309. CNDSPrintQueue::Purge(THIS)
  310. {
  311. HANDLE hPrinter = NULL;
  312. HRESULT hr = S_OK;
  313. LPWSTR pszNDSPath = NULL;
  314. BSTR bstrADsPath = NULL;
  315. //
  316. // Make NDS Path
  317. //
  318. hr = _pADs->get_ADsPath(
  319. &bstrADsPath
  320. );
  321. BAIL_ON_FAILURE(hr);
  322. hr = BuildNDSPathFromADsPath(
  323. bstrADsPath,
  324. &pszNDSPath
  325. );
  326. BAIL_ON_FAILURE(hr);
  327. //
  328. // Open a handle to the printer with Administer access.
  329. //
  330. hr = NWApiOpenPrinter(
  331. pszNDSPath,
  332. &hPrinter,
  333. PRINTER_ACCESS_ADMINISTER
  334. );
  335. BAIL_ON_FAILURE(hr);
  336. //
  337. // Purge printer.
  338. //
  339. hr = NWApiSetPrinter(
  340. hPrinter,
  341. 0,
  342. NULL,
  343. PRINTER_CONTROL_PURGE
  344. );
  345. error:
  346. if (hPrinter) {
  347. NWApiClosePrinter(hPrinter);
  348. }
  349. if (bstrADsPath) {
  350. ADsFreeString(bstrADsPath);
  351. }
  352. if (pszNDSPath) {
  353. FreeADsStr(pszNDSPath);
  354. }
  355. RRETURN_EXP_IF_ERR(hr);
  356. }
  357. STDMETHODIMP
  358. CNDSPrintQueue::get_Status(THIS_ long FAR* retval)
  359. {
  360. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  361. }