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.

481 lines
9.0 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. //
  70. // BUGBUG: long assigned a date(double) value. NT INFO structures
  71. // handle long only. ADS specs say double.
  72. //
  73. PUT_PROPERTY_DATE((IADsPrintQueue *)this, StartTime);
  74. }
  75. STDMETHODIMP
  76. CNDSPrintQueue::get_StartTime(THIS_ DATE FAR* retval)
  77. {
  78. GET_PROPERTY_DATE((IADsPrintQueue *)this, StartTime);
  79. }
  80. STDMETHODIMP
  81. CNDSPrintQueue::put_UntilTime(THIS_ DATE daUntilTime)
  82. {
  83. //
  84. // BUGBUG: long assigned a date(double) value. NT INFO structures
  85. // handle long only. ADS specs say double.
  86. //
  87. PUT_PROPERTY_DATE((IADsPrintQueue *)this, UntilTime);
  88. }
  89. STDMETHODIMP
  90. CNDSPrintQueue::get_UntilTime(THIS_ DATE FAR* retval)
  91. {
  92. GET_PROPERTY_DATE((IADsPrintQueue *)this, UntilTime);
  93. }
  94. STDMETHODIMP
  95. CNDSPrintQueue::put_DefaultJobPriority(THIS_ LONG lDefaultJobPriority)
  96. {
  97. PUT_PROPERTY_LONG((IADsPrintQueue *)this, DefaultJobPriority);
  98. }
  99. STDMETHODIMP
  100. CNDSPrintQueue::get_DefaultJobPriority(THIS_ LONG FAR* retval)
  101. {
  102. GET_PROPERTY_LONG((IADsPrintQueue *)this, DefaultJobPriority);
  103. }
  104. STDMETHODIMP
  105. CNDSPrintQueue::put_BannerPage(THIS_ BSTR bstrBannerPage)
  106. {
  107. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, BannerPage);
  108. }
  109. STDMETHODIMP
  110. CNDSPrintQueue::get_BannerPage(THIS_ BSTR FAR* retval)
  111. {
  112. GET_PROPERTY_BSTR((IADsPrintQueue *)this, BannerPage);
  113. }
  114. STDMETHODIMP
  115. CNDSPrintQueue::get_PrinterPath(THIS_ BSTR FAR* retval)
  116. {
  117. HRESULT hr = E_FAIL;
  118. // BugBug: RamV replace the get_HostComputer with
  119. // hr = ADsAllocString(_Parent, retval);
  120. RRETURN(hr);
  121. }
  122. STDMETHODIMP
  123. CNDSPrintQueue::put_PrinterPath(THIS_ BSTR bstrPrinterPath)
  124. {
  125. //
  126. // Cannot change this in Windows NT!
  127. //
  128. RRETURN(E_ADS_PROPERTY_NOT_SUPPORTED);
  129. }
  130. STDMETHODIMP
  131. CNDSPrintQueue::get_PrintProcessor(THIS_ BSTR FAR* retval)
  132. {
  133. GET_PROPERTY_BSTR((IADsPrintQueue *)this, PrintProcessor);
  134. }
  135. STDMETHODIMP
  136. CNDSPrintQueue::put_PrintProcessor(THIS_ BSTR bstrPrintProcessor)
  137. {
  138. PUT_PROPERTY_BSTR((IADsPrintQueue *)this, PrintProcessor);
  139. }
  140. STDMETHODIMP
  141. CNDSPrintQueue::get_PrintDevices(THIS_ VARIANT FAR* retval)
  142. {
  143. GET_PROPERTY_VARIANT((IADsPrintQueue *)this, Ports);
  144. }
  145. STDMETHODIMP
  146. CNDSPrintQueue::put_PrintDevices(THIS_ VARIANT vPorts)
  147. {
  148. PUT_PROPERTY_VARIANT((IADsPrintQueue *)this, Ports);
  149. }
  150. STDMETHODIMP
  151. CNDSPrintQueue::get_NetAddresses(THIS_ VARIANT FAR* retval)
  152. {
  153. GET_PROPERTY_VARIANT((IADsPrintQueue *)this, NetAddresses);
  154. }
  155. STDMETHODIMP
  156. CNDSPrintQueue::put_NetAddresses(THIS_ VARIANT vNetAddresses)
  157. {
  158. PUT_PROPERTY_VARIANT((IADsPrintQueue *)this, NetAddresses);
  159. }
  160. //
  161. // Class CNDSPrintQueue
  162. //
  163. /* IADsFSPrintQueueOperation methods */
  164. STDMETHODIMP
  165. CNDSPrintQueue::PrintJobs(
  166. THIS_ IADsCollection * FAR* ppCollection
  167. )
  168. {
  169. RRETURN(E_NOTIMPL);
  170. }
  171. //+------------------------------------------------------------------------
  172. //
  173. // Function: CNDSPrintQueue::Pause
  174. //
  175. // Synopsis: Binds to real printer as specified in _bstrPrinterName
  176. // and attempts to pause the real printer.
  177. //
  178. // Arguments: none
  179. //
  180. // Returns: HRESULT.
  181. //
  182. // Modifies: nothing
  183. //
  184. // History: 11-07-95 RamV Created
  185. // Appropriated from Old NetOle Code.
  186. //
  187. //---------------------------------------------------------------------------
  188. STDMETHODIMP
  189. CNDSPrintQueue::Pause(THIS)
  190. {
  191. HANDLE hPrinter = NULL;
  192. HRESULT hr = S_OK;
  193. BSTR bstrADsPath = NULL;
  194. LPWSTR pszNDSPath = NULL;
  195. //
  196. // Make NDS Path
  197. //
  198. hr = _pADs->get_ADsPath(
  199. &bstrADsPath
  200. );
  201. BAIL_ON_FAILURE(hr);
  202. hr = BuildNDSPathFromADsPath(
  203. bstrADsPath,
  204. &pszNDSPath
  205. );
  206. BAIL_ON_FAILURE(hr);
  207. //
  208. // Open a handle to the printer with Administer access.
  209. //
  210. hr = NWApiOpenPrinter(
  211. pszNDSPath,
  212. &hPrinter,
  213. PRINTER_ACCESS_ADMINISTER
  214. );
  215. BAIL_ON_FAILURE(hr);
  216. //
  217. // Pause printer.
  218. //
  219. hr = NWApiSetPrinter(
  220. hPrinter,
  221. 0,
  222. NULL,
  223. PRINTER_CONTROL_PAUSE
  224. );
  225. error:
  226. if (hPrinter) {
  227. NWApiClosePrinter(hPrinter);
  228. }
  229. if (bstrADsPath) {
  230. ADsFreeString(bstrADsPath);
  231. }
  232. if (pszNDSPath) {
  233. FreeADsStr(pszNDSPath);
  234. }
  235. RRETURN(hr);
  236. }
  237. //+---------------------------------------------------------------------------
  238. //
  239. // Function: CNDSPrintQueue::Resume
  240. //
  241. // Synopsis: Binds to real printer as specified in _bstrPrinterName and
  242. // attempts to resume the real printer.
  243. //
  244. // Arguments: void
  245. //
  246. // Returns: HRESULT.
  247. //
  248. // Modifies:
  249. //
  250. // History: 11-07-95 RamV Created
  251. // Appropriated from old NetOle Project
  252. //----------------------------------------------------------------------------
  253. STDMETHODIMP
  254. CNDSPrintQueue::Resume(THIS)
  255. {
  256. HANDLE hPrinter = NULL;
  257. HRESULT hr = S_OK;
  258. LPWSTR pszNDSPath = NULL;
  259. BSTR bstrADsPath = NULL;
  260. //
  261. // Make NDS Path
  262. //
  263. hr = _pADs->get_ADsPath(
  264. &bstrADsPath
  265. );
  266. BAIL_ON_FAILURE(hr);
  267. hr = BuildNDSPathFromADsPath(
  268. bstrADsPath,
  269. &pszNDSPath
  270. );
  271. BAIL_ON_FAILURE(hr);
  272. //
  273. // Open a handle to the printer with Administer access.
  274. //
  275. hr = NWApiOpenPrinter(
  276. pszNDSPath,
  277. &hPrinter,
  278. PRINTER_ACCESS_ADMINISTER
  279. );
  280. BAIL_ON_FAILURE(hr);
  281. //
  282. // Resume printer.
  283. //
  284. hr = NWApiSetPrinter(
  285. hPrinter,
  286. 0,
  287. NULL,
  288. PRINTER_CONTROL_RESUME
  289. );
  290. error:
  291. if (hPrinter) {
  292. NWApiClosePrinter(hPrinter);
  293. }
  294. if (bstrADsPath) {
  295. ADsFreeString(bstrADsPath);
  296. }
  297. if (pszNDSPath) {
  298. FreeADsStr(pszNDSPath);
  299. }
  300. RRETURN(hr);
  301. }
  302. //+---------------------------------------------------------------------------
  303. //
  304. // Function: CNDSPrintQueue::Purge
  305. //
  306. // Synopsis: Binds to real printer as specified in _PrinterName and attempts
  307. // to purge the real printer.
  308. //
  309. // Arguments: void
  310. //
  311. // Returns: HRESULT.
  312. //
  313. // Modifies:
  314. //
  315. // History: 11-07-95 RamV Created
  316. // Appropriated from old NetOle Code
  317. //----------------------------------------------------------------------------
  318. STDMETHODIMP
  319. CNDSPrintQueue::Purge(THIS)
  320. {
  321. HANDLE hPrinter = NULL;
  322. HRESULT hr = S_OK;
  323. LPWSTR pszNDSPath = NULL;
  324. BSTR bstrADsPath = NULL;
  325. //
  326. // Make NDS Path
  327. //
  328. hr = _pADs->get_ADsPath(
  329. &bstrADsPath
  330. );
  331. BAIL_ON_FAILURE(hr);
  332. hr = BuildNDSPathFromADsPath(
  333. bstrADsPath,
  334. &pszNDSPath
  335. );
  336. BAIL_ON_FAILURE(hr);
  337. //
  338. // Open a handle to the printer with Administer access.
  339. //
  340. hr = NWApiOpenPrinter(
  341. pszNDSPath,
  342. &hPrinter,
  343. PRINTER_ACCESS_ADMINISTER
  344. );
  345. BAIL_ON_FAILURE(hr);
  346. //
  347. // Purge printer.
  348. //
  349. hr = NWApiSetPrinter(
  350. hPrinter,
  351. 0,
  352. NULL,
  353. PRINTER_CONTROL_PURGE
  354. );
  355. error:
  356. if (hPrinter) {
  357. NWApiClosePrinter(hPrinter);
  358. }
  359. if (bstrADsPath) {
  360. ADsFreeString(bstrADsPath);
  361. }
  362. if (pszNDSPath) {
  363. FreeADsStr(pszNDSPath);
  364. }
  365. RRETURN(hr);
  366. }
  367. STDMETHODIMP
  368. CNDSPrintQueue::get_Status(THIS_ long FAR* retval)
  369. {
  370. RRETURN(E_NOTIMPL);
  371. }