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.

1550 lines
44 KiB

  1. /*++
  2. Copyright (c) 1996-1997 Microsoft Corporation
  3. Module Name:
  4. intfui.cpp
  5. Abstract:
  6. Interface implementation of Windows NT driver UI OEM plugins
  7. Environment:
  8. Windows NT driver UI
  9. Revision History:
  10. --*/
  11. #define INITGUID
  12. #include "precomp.h"
  13. //
  14. // List all of the supported OEM UI plugin interface IIDs from the
  15. // latest to the oldest, that's the order our driver will QI OEM
  16. // plugin for its supported interface.
  17. //
  18. // DON"T remove the last NULL terminator.
  19. //
  20. static const GUID *PrintOemUI_IIDs[] = {
  21. &IID_IPrintOemUI2,
  22. &IID_IPrintOemUI,
  23. NULL
  24. };
  25. #define CALL_INTERFACE(pOemEntry, MethodName, args) \
  26. if (IsEqualGUID(&(pOemEntry)->iidIntfOem, &IID_IPrintOemUI)) \
  27. { \
  28. return ((IPrintOemUI *)(pOemEntry)->pIntfOem)->MethodName args; \
  29. } \
  30. else if (IsEqualGUID(&(pOemEntry)->iidIntfOem, &IID_IPrintOemUI2)) \
  31. { \
  32. return ((IPrintOemUI2 *)(pOemEntry)->pIntfOem)->MethodName args; \
  33. } \
  34. return E_NOINTERFACE;
  35. #define CALL_INTERFACE2(pOemEntry, MethodName, args) \
  36. if (IsEqualGUID(&(pOemEntry)->iidIntfOem, &IID_IPrintOemUI2)) \
  37. { \
  38. return ((IPrintOemUI2 *)(pOemEntry)->pIntfOem)->MethodName args; \
  39. } \
  40. return E_NOINTERFACE;
  41. #ifdef PSCRIPT
  42. #define VERIFY_OEMUIOBJ(poemuiobj) \
  43. if (!poemuiobj || (((PCOMMONINFO)poemuiobj)->pvStartSign != poemuiobj)) \
  44. return E_INVALIDARG;
  45. #define VERIFY_UIDATA(poemuiobj) \
  46. if (!VALIDUIDATA((PUIDATA)poemuiobj)) \
  47. return E_INVALIDARG;
  48. #endif // PSCRIPT
  49. //
  50. // Core driver helper function interfaces
  51. //
  52. //
  53. // The first driver UI herlper interface has version number 1. Any new
  54. // helper interface version number is 1 plus the previous version number.
  55. // So we need to increase MAX_UI_HELPER_INTF_VER by 1 every time we introduce
  56. // a new UI plugin helper interface.
  57. //
  58. #ifdef PSCRIPT
  59. #define MAX_UI_HELPER_INTF_VER 2
  60. #else
  61. #define MAX_UI_HELPER_INTF_VER 1
  62. #endif // PSCRIPT
  63. //
  64. // CPrintOemDriverUI is the object containing the UI helper functions
  65. //
  66. class CPrintOemDriverUI : public IPrintOemDriverUI
  67. {
  68. //
  69. // IUnknown implementation
  70. //
  71. virtual STDMETHODIMP QueryInterface(const IID& iid, void** ppv);
  72. virtual STDMETHODIMP_(ULONG) AddRef();
  73. virtual STDMETHODIMP_(ULONG) Release();
  74. //
  75. // Interface IPrintOemDriverUI implementation
  76. //
  77. virtual STDMETHODIMP DrvGetDriverSetting( PVOID pci,
  78. PCSTR pFeature,
  79. PVOID pOutput,
  80. DWORD cbSize,
  81. PDWORD pcbNeeded,
  82. PDWORD pdwOptionsReturned);
  83. virtual STDMETHODIMP DrvUpgradeRegistrySetting( HANDLE hPrinter,
  84. PCSTR pFeature,
  85. PCSTR pOption);
  86. virtual STDMETHODIMP DrvUpdateUISetting ( PVOID pci,
  87. PVOID pOptItem,
  88. DWORD dwPreviousSelection,
  89. DWORD dwMode);
  90. public:
  91. //
  92. // Constructor
  93. //
  94. CPrintOemDriverUI() : m_cRef(0) {}
  95. private:
  96. long m_cRef;
  97. };
  98. STDMETHODIMP CPrintOemDriverUI::QueryInterface(const IID& iid, void** ppv)
  99. {
  100. if (iid == IID_IUnknown || iid == IID_IPrintOemDriverUI)
  101. {
  102. *ppv = static_cast<IPrintOemDriverUI *>(this);
  103. }
  104. else
  105. {
  106. *ppv = NULL;
  107. return E_NOINTERFACE;
  108. }
  109. reinterpret_cast<IUnknown*>(*ppv)->AddRef();
  110. return S_OK;
  111. }
  112. STDMETHODIMP_(ULONG) CPrintOemDriverUI::AddRef()
  113. {
  114. return InterlockedIncrement(&m_cRef);
  115. }
  116. STDMETHODIMP_(ULONG) CPrintOemDriverUI::Release()
  117. {
  118. if (InterlockedDecrement(&m_cRef) == 0)
  119. {
  120. delete this;
  121. return 0;
  122. }
  123. return m_cRef;
  124. }
  125. STDMETHODIMP CPrintOemDriverUI::DrvGetDriverSetting(PVOID pci,
  126. PCSTR pFeature,
  127. PVOID pOutput,
  128. DWORD cbSize,
  129. PDWORD pcbNeeded,
  130. PDWORD pdwOptionsReturned)
  131. {
  132. if (BGetDriverSettingForOEM((PCOMMONINFO)pci,
  133. pFeature,
  134. pOutput,
  135. cbSize,
  136. pcbNeeded,
  137. pdwOptionsReturned))
  138. return S_OK;
  139. return E_FAIL;
  140. }
  141. STDMETHODIMP CPrintOemDriverUI::DrvUpgradeRegistrySetting(HANDLE hPrinter,
  142. PCSTR pFeature,
  143. PCSTR pOption)
  144. {
  145. if (BUpgradeRegistrySettingForOEM(hPrinter,
  146. pFeature,
  147. pOption))
  148. return S_OK;
  149. return E_FAIL;
  150. }
  151. STDMETHODIMP CPrintOemDriverUI::DrvUpdateUISetting(PVOID pci,
  152. PVOID pOptItem,
  153. DWORD dwPreviousSelection,
  154. DWORD dwMode)
  155. {
  156. if (BUpdateUISettingForOEM((PCOMMONINFO)pci,
  157. pOptItem,
  158. dwPreviousSelection,
  159. dwMode))
  160. return S_OK;
  161. return E_FAIL;
  162. }
  163. #ifdef PSCRIPT
  164. //
  165. // CPrintCoreUI2 is the object containing the new UI helper functions
  166. //
  167. class CPrintCoreUI2 : public IPrintCoreUI2
  168. {
  169. //
  170. // IUnknown implementation
  171. //
  172. virtual STDMETHODIMP QueryInterface(const IID& iid, void** ppv);
  173. virtual STDMETHODIMP_(ULONG) AddRef();
  174. virtual STDMETHODIMP_(ULONG) Release();
  175. //
  176. // IPrintOemDriverUI methods implementation
  177. //
  178. virtual STDMETHODIMP DrvGetDriverSetting(PVOID pci,
  179. PCSTR pFeature,
  180. PVOID pOutput,
  181. DWORD cbSize,
  182. PDWORD pcbNeeded,
  183. PDWORD pdwOptionsReturned);
  184. virtual STDMETHODIMP DrvUpgradeRegistrySetting(HANDLE hPrinter,
  185. PCSTR pFeature,
  186. PCSTR pOption);
  187. virtual STDMETHODIMP DrvUpdateUISetting(PVOID pci,
  188. PVOID pOptItem,
  189. DWORD dwPreviousSelection,
  190. DWORD dwMode);
  191. //
  192. // IPrintCoreUI2 methods implementation
  193. //
  194. virtual STDMETHODIMP GetOptions(
  195. IN POEMUIOBJ poemuiobj,
  196. IN DWORD dwFlags,
  197. IN PCSTR pmszFeaturesRequested,
  198. IN DWORD cbIn,
  199. OUT PSTR pmszFeatureOptionBuf,
  200. IN DWORD cbSize,
  201. OUT PDWORD pcbNeeded);
  202. virtual STDMETHODIMP SetOptions(
  203. IN POEMUIOBJ poemuiobj,
  204. IN DWORD dwFlags,
  205. IN PCSTR pmszFeatureOptionBuf,
  206. IN DWORD cbIn,
  207. OUT PDWORD pdwResult);
  208. virtual STDMETHODIMP EnumConstrainedOptions(
  209. IN POEMUIOBJ poemuiobj,
  210. IN DWORD dwFlags,
  211. IN PCSTR pszFeatureKeyword,
  212. OUT PSTR pmszConstrainedOptionList,
  213. IN DWORD cbSize,
  214. OUT PDWORD pcbNeeded);
  215. virtual STDMETHODIMP WhyConstrained(
  216. IN POEMUIOBJ poemuiobj,
  217. IN DWORD dwFlags,
  218. IN PCSTR pszFeatureKeyword,
  219. IN PCSTR pszOptionKeyword,
  220. OUT PSTR pmszReasonList,
  221. IN DWORD cbSize,
  222. OUT PDWORD pcbNeeded);
  223. virtual STDMETHODIMP GetGlobalAttribute(
  224. IN POEMUIOBJ poemuiobj,
  225. IN DWORD dwFlags,
  226. IN PCSTR pszAttribute,
  227. OUT PDWORD pdwDataType,
  228. OUT PBYTE pbData,
  229. IN DWORD cbSize,
  230. OUT PDWORD pcbNeeded);
  231. virtual STDMETHODIMP GetFeatureAttribute(
  232. IN POEMUIOBJ poemuiobj,
  233. IN DWORD dwFlags,
  234. IN PCSTR pszFeatureKeyword,
  235. IN PCSTR pszAttribute,
  236. OUT PDWORD pdwDataType,
  237. OUT PBYTE pbData,
  238. IN DWORD cbSize,
  239. OUT PDWORD pcbNeeded);
  240. virtual STDMETHODIMP GetOptionAttribute(
  241. IN POEMUIOBJ poemuiobj,
  242. IN DWORD dwFlags,
  243. IN PCSTR pszFeatureKeyword,
  244. IN PCSTR pszOptionKeyword,
  245. IN PCSTR pszAttribute,
  246. OUT PDWORD pdwDataType,
  247. OUT PBYTE pbData,
  248. IN DWORD cbSize,
  249. OUT PDWORD pcbNeeded);
  250. virtual STDMETHODIMP EnumFeatures(
  251. IN POEMUIOBJ poemuiobj,
  252. IN DWORD dwFlags,
  253. OUT PSTR pmszFeatureList,
  254. IN DWORD cbSize,
  255. OUT PDWORD pcbNeeded);
  256. virtual STDMETHODIMP EnumOptions(
  257. IN POEMUIOBJ poemuiobj,
  258. IN DWORD dwFlags,
  259. IN PCSTR pszFeatureKeyword,
  260. OUT PSTR pmszOptionList,
  261. IN DWORD cbSize,
  262. OUT PDWORD pcbNeeded);
  263. virtual STDMETHODIMP QuerySimulationSupport(
  264. IN HANDLE hPrinter,
  265. IN DWORD dwLevel,
  266. OUT PBYTE pCaps,
  267. IN DWORD cbSize,
  268. OUT PDWORD pcbNeeded);
  269. public:
  270. //
  271. // Constructor
  272. //
  273. CPrintCoreUI2() : m_cRef(0) {}
  274. private:
  275. long m_cRef;
  276. };
  277. STDMETHODIMP CPrintCoreUI2::QueryInterface(const IID& iid, void** ppv)
  278. {
  279. if (iid == IID_IUnknown || iid == IID_IPrintCoreUI2)
  280. {
  281. *ppv = static_cast<IPrintCoreUI2 *>(this);
  282. }
  283. else
  284. {
  285. *ppv = NULL;
  286. return E_NOINTERFACE;
  287. }
  288. reinterpret_cast<IUnknown*>(*ppv)->AddRef();
  289. return S_OK;
  290. }
  291. STDMETHODIMP_(ULONG) CPrintCoreUI2::AddRef()
  292. {
  293. return InterlockedIncrement(&m_cRef);
  294. }
  295. STDMETHODIMP_(ULONG) CPrintCoreUI2::Release()
  296. {
  297. if (InterlockedDecrement(&m_cRef) == 0)
  298. {
  299. delete this;
  300. return 0;
  301. }
  302. return m_cRef;
  303. }
  304. STDMETHODIMP CPrintCoreUI2::DrvGetDriverSetting(PVOID pci,
  305. PCSTR pFeature,
  306. PVOID pOutput,
  307. DWORD cbSize,
  308. PDWORD pcbNeeded,
  309. PDWORD pdwOptionsReturned)
  310. {
  311. VERIFY_OEMUIOBJ((POEMUIOBJ)pci)
  312. //
  313. // This function is only supported for UI plugins that DON'T fully replace
  314. // core driver's standard UI. It should only be called by the UI plugin's
  315. // DocumentPropertySheets, DevicePropertySheets and their property sheet
  316. // callback functions.
  317. //
  318. if (!IS_WITHIN_PROPSHEET_SESSION((PCOMMONINFO)pci))
  319. {
  320. ERR(("DrvGetDriverSetting called outside of property sheet session. E_NOTIMPL returned.\n"));
  321. return E_NOTIMPL;
  322. }
  323. VERIFY_UIDATA((POEMUIOBJ)pci)
  324. if (IS_HIDING_STD_UI((PUIDATA)pci))
  325. {
  326. ERR(("DrvGetDriverSetting called by full UI replacing plugin. E_NOTIMPL returned.\n"));
  327. return E_NOTIMPL;
  328. }
  329. if (BGetDriverSettingForOEM((PCOMMONINFO)pci,
  330. pFeature,
  331. pOutput,
  332. cbSize,
  333. pcbNeeded,
  334. pdwOptionsReturned))
  335. {
  336. return S_OK;
  337. }
  338. return E_FAIL;
  339. }
  340. STDMETHODIMP CPrintCoreUI2::DrvUpgradeRegistrySetting(HANDLE hPrinter,
  341. PCSTR pFeature,
  342. PCSTR pOption)
  343. {
  344. if (BUpgradeRegistrySettingForOEM(hPrinter,
  345. pFeature,
  346. pOption))
  347. {
  348. return S_OK;
  349. }
  350. return E_FAIL;
  351. }
  352. STDMETHODIMP CPrintCoreUI2::DrvUpdateUISetting(PVOID pci,
  353. PVOID pOptItem,
  354. DWORD dwPreviousSelection,
  355. DWORD dwMode)
  356. {
  357. VERIFY_OEMUIOBJ((POEMUIOBJ)pci)
  358. //
  359. // This function is only supported for UI plugins that DON'T fully replace
  360. // core driver's standard UI. It should only be called by the UI plugin's
  361. // DocumentPropertySheets, DevicePropertySheets and their property sheet
  362. // callback functions.
  363. //
  364. if (!IS_WITHIN_PROPSHEET_SESSION((PCOMMONINFO)pci))
  365. {
  366. ERR(("DrvUpdateUISetting called outside of property sheet session. E_NOTIMPL returned.\n"));
  367. return E_NOTIMPL;
  368. }
  369. VERIFY_UIDATA((POEMUIOBJ)pci)
  370. if (IS_HIDING_STD_UI((PUIDATA)pci))
  371. {
  372. ERR(("DrvUpdateUISetting called by full UI replacing plugin. E_NOTIMPL returned.\n"));
  373. return E_NOTIMPL;
  374. }
  375. if (BUpdateUISettingForOEM((PCOMMONINFO)pci,
  376. pOptItem,
  377. dwPreviousSelection,
  378. dwMode))
  379. {
  380. return S_OK;
  381. }
  382. return E_FAIL;
  383. }
  384. /*++
  385. Routine Name:
  386. GetOptions
  387. Routine Description:
  388. get current driver settings for PPD features and driver synthesized features
  389. Arguments:
  390. poemuiobj - pointer to driver context object
  391. dwFlags - flags for the get operation
  392. pmszFeaturesRequested - MULTI_SZ ASCII string containing feature keyword names
  393. cbin - size in bytes of the pmszFeaturesRequested string
  394. pmszFeatureOptionBuf - pointer to output data buffer to store feature settings
  395. cbSize - size in bytes of pmszFeatureOptionBuf buffer
  396. pcbNeeded - buffer size in bytes needed to output the feature settings
  397. Return Value:
  398. E_NOTIMPL if called when not supported
  399. E_INVALIDARG if poemuiobj is invalid, or see HGetOptions
  400. S_OK
  401. E_OUTOFMEMORY
  402. E_FAIL see HGetOptions
  403. Last Error:
  404. None
  405. --*/
  406. STDMETHODIMP CPrintCoreUI2::GetOptions(
  407. IN POEMUIOBJ poemuiobj,
  408. IN DWORD dwFlags,
  409. IN PCSTR pmszFeaturesRequested,
  410. IN DWORD cbIn,
  411. OUT PSTR pmszFeatureOptionBuf,
  412. IN DWORD cbSize,
  413. OUT PDWORD pcbNeeded)
  414. {
  415. PCOMMONINFO pci;
  416. VERIFY_OEMUIOBJ(poemuiobj)
  417. //
  418. // This function is only supported for UI plugins that fully replace
  419. // core driver's standard UI. It should only be called by the UI plugin's
  420. // DocumentPropertySheets, DevicePropertySheets and their property sheet
  421. // callback functions.
  422. //
  423. pci = (PCOMMONINFO)poemuiobj;
  424. if (!IS_WITHIN_PROPSHEET_SESSION(pci))
  425. {
  426. ERR(("GetOptions called outside of property sheet session. E_NOTIMPL returned.\n"));
  427. return E_NOTIMPL;
  428. }
  429. VERIFY_UIDATA(poemuiobj)
  430. if (!IS_HIDING_STD_UI((PUIDATA)pci))
  431. {
  432. ERR(("GetOptions called by non-full UI replacing plugin. E_NOTIMPL returned.\n"));
  433. return E_NOTIMPL;
  434. }
  435. #ifdef PSCRIPT
  436. return HGetOptions(pci->hPrinter,
  437. pci->pInfoHeader,
  438. pci->pCombinedOptions,
  439. pci->pdm,
  440. pci->pPrinterData,
  441. dwFlags,
  442. pmszFeaturesRequested,
  443. cbIn,
  444. pmszFeatureOptionBuf,
  445. cbSize,
  446. pcbNeeded,
  447. ((PUIDATA)pci)->iMode == MODE_PRINTER_STICKY ? TRUE : FALSE);
  448. #else
  449. return E_NOTIMPL;
  450. #endif // PSCRIPT
  451. }
  452. /*++
  453. Routine Name:
  454. SetOptions
  455. Routine Description:
  456. set new driver settings for PPD features and driver synthesized features
  457. Arguments:
  458. poemuiobj - pointer to driver context object
  459. dwFlags - flags for the set operation. This should be one of following:
  460. SETOPTIONS_FLAG_RESOLVE_CONFLICT
  461. SETOPTIONS_FLAG_KEEP_CONFLICT
  462. pmszFeatureOptionBuf - MULTI_SZ ASCII string containing new settings'
  463. feature/option keyword pairs
  464. cbin - size in bytes of the pmszFeatureOptionBuf string
  465. pdwResult - pointer to the DWORD that will store the result of set operation.
  466. The result will be one of following:
  467. SETOPTIONS_RESULT_NO_CONFLICT
  468. SETOPTIONS_RESULT_CONFLICT_RESOLVED
  469. SETOPTIONS_RESULT_CONFLICT_REMAINED
  470. Return Value:
  471. S_OK if the set operation succeeds
  472. E_NOTIMPL if called when not supported
  473. E_INVALIDARG if poemuiobj is invalid, or see HSetOptions
  474. E_FAIL see HSetOptions
  475. Last Error:
  476. None
  477. --*/
  478. STDMETHODIMP CPrintCoreUI2::SetOptions(
  479. IN POEMUIOBJ poemuiobj,
  480. IN DWORD dwFlags,
  481. IN PCSTR pmszFeatureOptionBuf,
  482. IN DWORD cbIn,
  483. OUT PDWORD pdwResult)
  484. {
  485. VERIFY_OEMUIOBJ(poemuiobj)
  486. //
  487. // This function is only supported for UI plugins that fully replace
  488. // core driver's standard UI. It should only be called by the UI plugin's
  489. // DocumentPropertySheets, DevicePropertySheets and their property sheet
  490. // callback functions.
  491. //
  492. if (!IS_WITHIN_PROPSHEET_SESSION((PCOMMONINFO)poemuiobj))
  493. {
  494. ERR(("SetOptions called outside of property sheet session. E_NOTIMPL returned.\n"));
  495. return E_NOTIMPL;
  496. }
  497. VERIFY_UIDATA(poemuiobj)
  498. if (!IS_HIDING_STD_UI((PUIDATA)poemuiobj))
  499. {
  500. ERR(("SetOptions called by non-full UI replacing plugin. E_NOTIMPL returned.\n"));
  501. return E_NOTIMPL;
  502. }
  503. #ifdef PSCRIPT
  504. return HSetOptions(poemuiobj,
  505. dwFlags,
  506. pmszFeatureOptionBuf,
  507. cbIn,
  508. pdwResult);
  509. #else
  510. return E_NOTIMPL;
  511. #endif // PSCRIPT
  512. }
  513. /*++
  514. Routine Name:
  515. EnumConstrainedOptions
  516. Routine Description:
  517. enumerate the constrained option keyword name list in the specified feature
  518. Arguments:
  519. poemuiobj - pointer to driver context object
  520. dwFlags - flags for the enumeration operation
  521. pszFeatureKeyword - feature keyword name
  522. pmszConstrainedOptionList - pointer to output data buffer
  523. cbSize - output data buffer size in bytes
  524. pcbNeeded - buffer size in bytes needed to store the output data
  525. Return Value:
  526. E_NOTIMPL if called when not supported
  527. E_INVALIDARG if poemuiobj is invalid, or see HEnumConstrainedOptions
  528. S_OK
  529. E_OUTOFMEMORY
  530. E_FAIL see HEnumConstrainedOptions
  531. Last Error:
  532. None
  533. --*/
  534. STDMETHODIMP CPrintCoreUI2::EnumConstrainedOptions(
  535. IN POEMUIOBJ poemuiobj,
  536. IN DWORD dwFlags,
  537. IN PCSTR pszFeatureKeyword,
  538. OUT PSTR pmszConstrainedOptionList,
  539. IN DWORD cbSize,
  540. OUT PDWORD pcbNeeded)
  541. {
  542. VERIFY_OEMUIOBJ(poemuiobj)
  543. //
  544. // This function is only supported for UI plugins that fully replace
  545. // core driver's standard UI. It should only be called by the UI plugin's
  546. // DocumentPropertySheets, DevicePropertySheets and their property sheet
  547. // callback functions.
  548. //
  549. if (!IS_WITHIN_PROPSHEET_SESSION((PCOMMONINFO)poemuiobj))
  550. {
  551. ERR(("EnumConstrainedOptions called outside of property sheet session. E_NOTIMPL returned.\n"));
  552. return E_NOTIMPL;
  553. }
  554. VERIFY_UIDATA(poemuiobj)
  555. if (!IS_HIDING_STD_UI((PUIDATA)poemuiobj))
  556. {
  557. ERR(("EnumConstrainedOptions called by non-full UI replacing plugin. E_NOTIMPL returned.\n"));
  558. return E_NOTIMPL;
  559. }
  560. #ifdef PSCRIPT
  561. return HEnumConstrainedOptions(poemuiobj,
  562. dwFlags,
  563. pszFeatureKeyword,
  564. pmszConstrainedOptionList,
  565. cbSize,
  566. pcbNeeded);
  567. #else
  568. return E_NOTIMPL;
  569. #endif // PSCRIPT
  570. }
  571. /*++
  572. Routine Name:
  573. WhyConstrained
  574. Routine Description:
  575. get feature/option keyword pair that constrains the given
  576. feature/option pair
  577. Arguments:
  578. poemuiobj - pointer to driver context object
  579. dwFlags - flags for this operation
  580. pszFeatureKeyword - feature keyword name
  581. pszOptionKeyword - option keyword name
  582. pmszReasonList - pointer to output data buffer
  583. cbSize - output data buffer size in bytes
  584. pcbNeeded - buffer size in bytes needed to store the output data
  585. Return Value:
  586. E_NOTIMPL if called when not supported
  587. E_INVALIDARG if poemuiobj is invalid, or see HWhyConstrained
  588. S_OK
  589. E_OUTOFMEMORY see HWhyConstrained
  590. Last Error:
  591. None
  592. --*/
  593. STDMETHODIMP CPrintCoreUI2::WhyConstrained(
  594. IN POEMUIOBJ poemuiobj,
  595. IN DWORD dwFlags,
  596. IN PCSTR pszFeatureKeyword,
  597. IN PCSTR pszOptionKeyword,
  598. OUT PSTR pmszReasonList,
  599. IN DWORD cbSize,
  600. OUT PDWORD pcbNeeded)
  601. {
  602. VERIFY_OEMUIOBJ(poemuiobj)
  603. //
  604. // This function is only supported for UI plugins that fully replace
  605. // core driver's standard UI. It should only be called by the UI plugin's
  606. // DocumentPropertySheets, DevicePropertySheets and their property sheet
  607. // callback functions.
  608. //
  609. if (!IS_WITHIN_PROPSHEET_SESSION((PCOMMONINFO)poemuiobj))
  610. {
  611. ERR(("WhyConstrained called outside of property sheet session. E_NOTIMPL returned.\n"));
  612. return E_NOTIMPL;
  613. }
  614. VERIFY_UIDATA(poemuiobj)
  615. if (!IS_HIDING_STD_UI((PUIDATA)poemuiobj))
  616. {
  617. ERR(("WhyConstrained called by non-full UI replacing plugin. E_NOTIMPL returned.\n"));
  618. return E_NOTIMPL;
  619. }
  620. #ifdef PSCRIPT
  621. return HWhyConstrained(poemuiobj,
  622. dwFlags,
  623. pszFeatureKeyword,
  624. pszOptionKeyword,
  625. pmszReasonList,
  626. cbSize,
  627. pcbNeeded);
  628. #else
  629. return E_NOTIMPL;
  630. #endif // PSCRIPT
  631. }
  632. /*++
  633. Routine Name:
  634. GetGlobalAttribute
  635. Routine Description:
  636. get PPD global attribute
  637. Arguments:
  638. poemuiobj - pointer to driver context object
  639. dwFlags - flags for the attribute get operation
  640. pszAttribute - name of the global attribute
  641. pdwDataType - pointer to DWORD to store output data type
  642. pbData - pointer to output data buffer
  643. cbSize - output data buffer size in bytes
  644. pcbNeeded - buffer size in bytes needed to store the output data
  645. Return Value:
  646. E_INVALIDARG if poemuiobj is invalid, or see HGetGlobalAttribute
  647. S_OK
  648. E_OUTOFMEMORY see HGetGlobalAttribute
  649. Last Error:
  650. None
  651. --*/
  652. STDMETHODIMP CPrintCoreUI2::GetGlobalAttribute(
  653. IN POEMUIOBJ poemuiobj,
  654. IN DWORD dwFlags,
  655. IN PCSTR pszAttribute,
  656. OUT PDWORD pdwDataType,
  657. OUT PBYTE pbData,
  658. IN DWORD cbSize,
  659. OUT PDWORD pcbNeeded)
  660. {
  661. VERIFY_OEMUIOBJ(poemuiobj)
  662. #ifdef PSCRIPT
  663. return HGetGlobalAttribute(((PCOMMONINFO)poemuiobj)->pInfoHeader,
  664. dwFlags,
  665. pszAttribute,
  666. pdwDataType,
  667. pbData,
  668. cbSize,
  669. pcbNeeded);
  670. #else
  671. return E_NOTIMPL;
  672. #endif // PSCRIPT
  673. }
  674. /*++
  675. Routine Name:
  676. GetFeatureAttribute
  677. Routine Description:
  678. get PPD feature attribute
  679. Arguments:
  680. poemuiobj - pointer to driver context object
  681. dwFlags - flags for the attribute get operation
  682. pszFeatureKeyword - PPD feature keyword name
  683. pszAttribute - name of the feature attribute
  684. pdwDataType - pointer to DWORD to store output data type
  685. pbData - pointer to output data buffer
  686. cbSize - output data buffer size in bytes
  687. pcbNeeded - buffer size in bytes needed to store the output data
  688. Return Value:
  689. E_INVALIDARG if poemuiobj is invalid, or see HGetFeatureAttribute
  690. S_OK
  691. E_OUTOFMEMORY see HGetFeatureAttribute
  692. Last Error:
  693. None
  694. --*/
  695. STDMETHODIMP CPrintCoreUI2::GetFeatureAttribute(
  696. IN POEMUIOBJ poemuiobj,
  697. IN DWORD dwFlags,
  698. IN PCSTR pszFeatureKeyword,
  699. IN PCSTR pszAttribute,
  700. OUT PDWORD pdwDataType,
  701. OUT PBYTE pbData,
  702. IN DWORD cbSize,
  703. OUT PDWORD pcbNeeded)
  704. {
  705. VERIFY_OEMUIOBJ(poemuiobj)
  706. #ifdef PSCRIPT
  707. return HGetFeatureAttribute(((PCOMMONINFO)poemuiobj)->pInfoHeader,
  708. dwFlags,
  709. pszFeatureKeyword,
  710. pszAttribute,
  711. pdwDataType,
  712. pbData,
  713. cbSize,
  714. pcbNeeded);
  715. #else
  716. return E_NOTIMPL;
  717. #endif // PSCRIPT
  718. }
  719. /*++
  720. Routine Name:
  721. GetOptionAttribute
  722. Routine Description:
  723. get option attribute of a PPD feature
  724. Arguments:
  725. poemuiobj - pointer to driver context object
  726. dwFlags - flags for the attribute get operation
  727. pszFeatureKeyword - PPD feature keyword name
  728. pszOptionKeyword - option keyword name of the PPD feature
  729. pszAttribute - name of the feature attribute
  730. pdwDataType - pointer to DWORD to store output data type
  731. pbData - pointer to output data buffer
  732. cbSize - output data buffer size in bytes
  733. pcbNeeded - buffer size in bytes needed to store the output data
  734. Return Value:
  735. E_INVALIDARG if poemuiobj is invalid, or see HGetOptionAttribute
  736. S_OK
  737. E_OUTOFMEMORY see HGetOptionAttribute
  738. Last Error:
  739. None
  740. --*/
  741. STDMETHODIMP CPrintCoreUI2::GetOptionAttribute(
  742. IN POEMUIOBJ poemuiobj,
  743. IN DWORD dwFlags,
  744. IN PCSTR pszFeatureKeyword,
  745. IN PCSTR pszOptionKeyword,
  746. IN PCSTR pszAttribute,
  747. OUT PDWORD pdwDataType,
  748. OUT PBYTE pbData,
  749. IN DWORD cbSize,
  750. OUT PDWORD pcbNeeded)
  751. {
  752. VERIFY_OEMUIOBJ(poemuiobj)
  753. #ifdef PSCRIPT
  754. return HGetOptionAttribute(((PCOMMONINFO)poemuiobj)->pInfoHeader,
  755. dwFlags,
  756. pszFeatureKeyword,
  757. pszOptionKeyword,
  758. pszAttribute,
  759. pdwDataType,
  760. pbData,
  761. cbSize,
  762. pcbNeeded);
  763. #else
  764. return E_NOTIMPL;
  765. #endif // PSCRIPT
  766. }
  767. /*++
  768. Routine Name:
  769. EnumFeatures
  770. Routine Description:
  771. enumerate PPD feature and supported driver feature keyword name list
  772. Arguments:
  773. poemuiobj - pointer to driver context object
  774. dwFlags - flags for the enumeration operation
  775. pmszFeatureList - pointer to output data buffer
  776. cbSize - output data buffer size in bytes
  777. pcbNeeded - buffer size in bytes needed to store the output data
  778. Return Value:
  779. E_INVALIDARG if peomuiobj is invalid
  780. S_OK
  781. E_OUTOFMEMORY
  782. E_FAIL see HEnumFeaturesOrOptions
  783. Last Error:
  784. None
  785. --*/
  786. STDMETHODIMP CPrintCoreUI2::EnumFeatures(
  787. IN POEMUIOBJ poemuiobj,
  788. IN DWORD dwFlags,
  789. OUT PSTR pmszFeatureList,
  790. IN DWORD cbSize,
  791. OUT PDWORD pcbNeeded)
  792. {
  793. VERIFY_OEMUIOBJ(poemuiobj)
  794. #ifdef PSCRIPT
  795. return HEnumFeaturesOrOptions(((PCOMMONINFO)poemuiobj)->hPrinter,
  796. ((PCOMMONINFO)poemuiobj)->pInfoHeader,
  797. dwFlags,
  798. NULL,
  799. pmszFeatureList,
  800. cbSize,
  801. pcbNeeded);
  802. #else
  803. return E_NOTIMPL;
  804. #endif // PSCRIPT
  805. }
  806. /*++
  807. Routine Name:
  808. EnumOptions
  809. Routine Description:
  810. enumerate option keyword name list of the specified feature
  811. Arguments:
  812. poemuiobj - pointer to driver context object
  813. dwFlags - flags for the enumeration operation
  814. pszFeatureKeyword - feature keyword name
  815. pmszOptionList - pointer to output data buffer
  816. cbSize - output data buffer size in bytes
  817. pcbNeeded - buffer size in bytes needed to store the output data
  818. Return Value:
  819. E_INVALIDARG if poemuiobj is invalid, or feature keyword name is invalid
  820. S_OK
  821. E_OUTOFMEMORY
  822. E_NOTIMPL
  823. E_FAIL see HEnumFeaturesOrOptions
  824. Last Error:
  825. --*/
  826. STDMETHODIMP CPrintCoreUI2::EnumOptions(
  827. IN POEMUIOBJ poemuiobj,
  828. IN DWORD dwFlags,
  829. IN PCSTR pszFeatureKeyword,
  830. OUT PSTR pmszOptionList,
  831. IN DWORD cbSize,
  832. OUT PDWORD pcbNeeded)
  833. {
  834. VERIFY_OEMUIOBJ(poemuiobj)
  835. if (pszFeatureKeyword == NULL)
  836. {
  837. return E_INVALIDARG;
  838. }
  839. #ifdef PSCRIPT
  840. return HEnumFeaturesOrOptions(((PCOMMONINFO)poemuiobj)->hPrinter,
  841. ((PCOMMONINFO)poemuiobj)->pInfoHeader,
  842. dwFlags,
  843. pszFeatureKeyword,
  844. pmszOptionList,
  845. cbSize,
  846. pcbNeeded);
  847. #else
  848. return E_NOTIMPL;
  849. #endif // PSCRIPT
  850. }
  851. /*++
  852. Routine Name:
  853. QuerySimulationSupport
  854. Routine Description:
  855. get the spooler simulation capability info structure
  856. Arguments:
  857. hPrinter - printer handle
  858. dwLevel - interested level of spooler simulation capability info structure
  859. pCaps - pointer to output buffer
  860. cbSize - size in bytes of output buffer
  861. pcbNeeded - buffer size in bytes needed to store the interested info structure
  862. Return Value:
  863. E_NOTIMPL if called on NT4, or see HQuerySimulationSupport
  864. S_OK
  865. E_OUTOFMEMORY
  866. E_NOTIMPL
  867. E_FAIL see HQuerySimulationSupport
  868. Last Error:
  869. None
  870. --*/
  871. STDMETHODIMP CPrintCoreUI2::QuerySimulationSupport(
  872. IN HANDLE hPrinter,
  873. IN DWORD dwLevel,
  874. OUT PBYTE pCaps,
  875. IN DWORD cbSize,
  876. OUT PDWORD pcbNeeded)
  877. {
  878. #ifndef WINNT_40
  879. return HQuerySimulationSupport(hPrinter,
  880. dwLevel,
  881. pCaps,
  882. cbSize,
  883. pcbNeeded);
  884. #else
  885. return E_NOTIMPL;
  886. #endif // !WINNT_40
  887. }
  888. #endif // PSCRIPT
  889. //
  890. // Creation function
  891. //
  892. extern "C" IUnknown* DriverCreateInstance(INT iHelperIntfVer)
  893. {
  894. IUnknown *pI = NULL;
  895. switch (iHelperIntfVer)
  896. {
  897. case 1:
  898. pI = static_cast<IPrintOemDriverUI *>(new CPrintOemDriverUI);
  899. break;
  900. #ifdef PSCRIPT
  901. case 2:
  902. pI = static_cast<IPrintCoreUI2 *>(new CPrintCoreUI2);
  903. break;
  904. #endif // PSCRIPT
  905. default:
  906. ERR(("Unrecognized helper interface version: %d\n", iHelperIntfVer));
  907. break;
  908. }
  909. if (pI != NULL)
  910. pI->AddRef();
  911. return pI;
  912. }
  913. //
  914. // Get OEM plugin interface and publish driver helper interface
  915. //
  916. extern "C" BOOL BGetOemInterface(POEM_PLUGIN_ENTRY pOemEntry)
  917. {
  918. IUnknown *pIDriverHelper = NULL;
  919. HRESULT hr;
  920. INT iHelperVer;
  921. //
  922. // QI to retrieve the latest interface OEM plugin supports
  923. //
  924. if (!BQILatestOemInterface(pOemEntry->hInstance,
  925. CLSID_OEMUI,
  926. PrintOemUI_IIDs,
  927. &(pOemEntry->pIntfOem),
  928. &(pOemEntry->iidIntfOem)))
  929. {
  930. ERR(("BQILatestOemInterface failed\n"));
  931. return FALSE;
  932. }
  933. //
  934. // If QI succeeded, pOemEntry->pIntfOem will have the OEM plugin
  935. // interface pointer with ref count 1.
  936. //
  937. //
  938. // Now publish driver's helper function interface (from latest to oldest).
  939. //
  940. for (iHelperVer = MAX_UI_HELPER_INTF_VER; iHelperVer > 0; iHelperVer--)
  941. {
  942. if ((pIDriverHelper = DriverCreateInstance(iHelperVer)) == NULL)
  943. {
  944. ERR(("DriverCreateInstance failed for version %d\n", iHelperVer));
  945. goto fail_cleanup;
  946. }
  947. //
  948. // As long as we define new OEM UI plugin interface by inheriting old ones,
  949. // we can always cast pIntfOem into pointer of the oldest plugin interface
  950. // (the base class) and call PublishDriverInterface method.
  951. //
  952. // Otherwise, this code needs to be modified when new interface is added.
  953. //
  954. hr = ((IPrintOemUI *)(pOemEntry->pIntfOem))->PublishDriverInterface(pIDriverHelper);
  955. //
  956. // OEM plugin should do QI in their PublishDriverInterface, so we need to release
  957. // our ref count of pIDriverHelper.
  958. //
  959. pIDriverHelper->Release();
  960. if (SUCCEEDED(hr))
  961. {
  962. VERBOSE(("PublishDriverInterface succeeded for version %d\n", iHelperVer));
  963. break;
  964. }
  965. }
  966. if (iHelperVer == 0)
  967. {
  968. ERR(("PublishDriverInterface failed\n"));
  969. goto fail_cleanup;
  970. }
  971. return TRUE;
  972. fail_cleanup:
  973. //
  974. // If failed, we need to release the ref count we hold on pOemEntry->pIntfOem,
  975. // and set pIntfOem to NULL to indicate no COM interface is available.
  976. //
  977. ((IUnknown *)(pOemEntry->pIntfOem))->Release();
  978. pOemEntry->pIntfOem = NULL;
  979. return FALSE;
  980. }
  981. extern "C" ULONG ReleaseOemInterface(POEM_PLUGIN_ENTRY pOemEntry)
  982. {
  983. #ifdef WINNT_40
  984. if (IsEqualGUID(&pOemEntry->iidIntfOem, &IID_IPrintOemUI))
  985. {
  986. return ((IPrintOemUI *)(pOemEntry)->pIntfOem)->Release();
  987. }
  988. #else
  989. CALL_INTERFACE(pOemEntry, Release,
  990. ());
  991. #endif
  992. return 0;
  993. }
  994. extern "C" HRESULT HComOEMGetInfo(POEM_PLUGIN_ENTRY pOemEntry,
  995. DWORD dwMode,
  996. PVOID pBuffer,
  997. DWORD cbSize,
  998. PDWORD pcbNeeded)
  999. {
  1000. CALL_INTERFACE(pOemEntry, GetInfo,
  1001. (dwMode,
  1002. pBuffer,
  1003. cbSize,
  1004. pcbNeeded));
  1005. }
  1006. extern "C" HRESULT HComOEMDevMode(POEM_PLUGIN_ENTRY pOemEntry,
  1007. DWORD dwMode,
  1008. POEMDMPARAM pOemDMParam)
  1009. {
  1010. CALL_INTERFACE(pOemEntry, DevMode,
  1011. (dwMode,
  1012. pOemDMParam));
  1013. }
  1014. extern "C" HRESULT HComOEMCommonUIProp(POEM_PLUGIN_ENTRY pOemEntry,
  1015. DWORD dwMode,
  1016. POEMCUIPPARAM pOemCUIPParam)
  1017. {
  1018. CALL_INTERFACE(pOemEntry, CommonUIProp,
  1019. (dwMode, pOemCUIPParam));
  1020. }
  1021. extern "C" HRESULT HComOEMDocumentPropertySheets(POEM_PLUGIN_ENTRY pOemEntry,
  1022. PPROPSHEETUI_INFO pPSUIInfo,
  1023. LPARAM lParam)
  1024. {
  1025. CALL_INTERFACE(pOemEntry, DocumentPropertySheets,
  1026. (pPSUIInfo,
  1027. lParam));
  1028. }
  1029. extern "C" HRESULT HComOEMDevicePropertySheets(POEM_PLUGIN_ENTRY pOemEntry,
  1030. PPROPSHEETUI_INFO pPSUIInfo,
  1031. LPARAM lParam)
  1032. {
  1033. CALL_INTERFACE(pOemEntry,DevicePropertySheets,
  1034. (pPSUIInfo,
  1035. lParam));
  1036. }
  1037. extern "C" HRESULT HComOEMDevQueryPrintEx(POEM_PLUGIN_ENTRY pOemEntry,
  1038. POEMUIOBJ poemuiobj,
  1039. PDEVQUERYPRINT_INFO pDQPInfo,
  1040. PDEVMODE pPublicDM,
  1041. PVOID pOEMDM)
  1042. {
  1043. CALL_INTERFACE(pOemEntry, DevQueryPrintEx,
  1044. (poemuiobj,
  1045. pDQPInfo,
  1046. pPublicDM,
  1047. pOEMDM));
  1048. }
  1049. extern "C" HRESULT HComOEMDeviceCapabilities(POEM_PLUGIN_ENTRY pOemEntry,
  1050. POEMUIOBJ poemuiobj,
  1051. HANDLE hPrinter,
  1052. PWSTR pDeviceName,
  1053. WORD wCapability,
  1054. PVOID pOutput,
  1055. PDEVMODE pPublicDM,
  1056. PVOID pOEMDM,
  1057. DWORD dwOld,
  1058. DWORD *pdwResult)
  1059. {
  1060. CALL_INTERFACE(pOemEntry, DeviceCapabilities,
  1061. (poemuiobj,
  1062. hPrinter,
  1063. pDeviceName,
  1064. wCapability,
  1065. pOutput,
  1066. pPublicDM,
  1067. pOEMDM,
  1068. dwOld,
  1069. pdwResult));
  1070. }
  1071. extern "C" HRESULT HComOEMUpgradePrinter(POEM_PLUGIN_ENTRY pOemEntry,
  1072. DWORD dwLevel,
  1073. PBYTE pDriverUpgradeInfo)
  1074. {
  1075. CALL_INTERFACE(pOemEntry, UpgradePrinter,
  1076. (dwLevel,
  1077. pDriverUpgradeInfo));
  1078. }
  1079. extern "C" HRESULT HComOEMPrinterEvent(POEM_PLUGIN_ENTRY pOemEntry,
  1080. PWSTR pPrinterName,
  1081. INT iDriverEvent,
  1082. DWORD dwFlags,
  1083. LPARAM lParam)
  1084. {
  1085. CALL_INTERFACE(pOemEntry, PrinterEvent,
  1086. (pPrinterName,
  1087. iDriverEvent,
  1088. dwFlags,
  1089. lParam));
  1090. }
  1091. extern "C" HRESULT HComOEMDriverEvent(POEM_PLUGIN_ENTRY pOemEntry,
  1092. DWORD dwDriverEvent,
  1093. DWORD dwLevel,
  1094. LPBYTE pDriverInfo,
  1095. LPARAM lParam)
  1096. {
  1097. CALL_INTERFACE(pOemEntry, DriverEvent,
  1098. (dwDriverEvent,
  1099. dwLevel,
  1100. pDriverInfo,
  1101. lParam));
  1102. }
  1103. extern "C" HRESULT HComOEMQUeryColorProfile(POEM_PLUGIN_ENTRY pOemEntry,
  1104. HANDLE hPrinter,
  1105. POEMUIOBJ poemuiobj,
  1106. PDEVMODE pPublicDM,
  1107. PVOID pOEMDM,
  1108. ULONG ulQueryMode,
  1109. VOID *pvProfileData,
  1110. ULONG *pcbProfileData,
  1111. FLONG *pflProfileData)
  1112. {
  1113. CALL_INTERFACE(pOemEntry,QueryColorProfile,
  1114. (hPrinter,
  1115. poemuiobj,
  1116. pPublicDM,
  1117. pOEMDM,
  1118. ulQueryMode,
  1119. pvProfileData,
  1120. pcbProfileData,
  1121. pflProfileData));
  1122. }
  1123. extern "C" HRESULT HComOEMFontInstallerDlgProc(POEM_PLUGIN_ENTRY pOemEntry,
  1124. HWND hWnd,
  1125. UINT usMsg,
  1126. WPARAM wParam,
  1127. LPARAM lParam)
  1128. {
  1129. CALL_INTERFACE(pOemEntry, FontInstallerDlgProc,
  1130. (hWnd,
  1131. usMsg,
  1132. wParam,
  1133. lParam));
  1134. }
  1135. extern "C" HRESULT HComOEMUpdateExternalFonts(POEM_PLUGIN_ENTRY pOemEntry,
  1136. HANDLE hPrinter,
  1137. HANDLE hHeap,
  1138. PWSTR pwstrCartridges)
  1139. {
  1140. CALL_INTERFACE(pOemEntry, UpdateExternalFonts,
  1141. (hPrinter,
  1142. hHeap,
  1143. pwstrCartridges));
  1144. }
  1145. extern "C" HRESULT HComOEMQueryJobAttributes(POEM_PLUGIN_ENTRY pOemEntry,
  1146. HANDLE hPrinter,
  1147. PDEVMODE pDevMode,
  1148. DWORD dwLevel,
  1149. LPBYTE lpAttributeInfo)
  1150. {
  1151. CALL_INTERFACE2(pOemEntry, QueryJobAttributes,
  1152. (hPrinter,
  1153. pDevMode,
  1154. dwLevel,
  1155. lpAttributeInfo));
  1156. }
  1157. extern "C" HRESULT HComOEMHideStandardUI(POEM_PLUGIN_ENTRY pOemEntry,
  1158. DWORD dwMode)
  1159. {
  1160. CALL_INTERFACE2(pOemEntry, HideStandardUI,
  1161. (dwMode));
  1162. }
  1163. extern "C" HRESULT HComOEMDocumentEvent(POEM_PLUGIN_ENTRY pOemEntry,
  1164. HANDLE hPrinter,
  1165. HDC hdc,
  1166. INT iEsc,
  1167. ULONG cbIn,
  1168. PVOID pbIn,
  1169. ULONG cbOut,
  1170. PVOID pbOut,
  1171. PINT piResult)
  1172. {
  1173. CALL_INTERFACE2(pOemEntry, DocumentEvent,
  1174. (hPrinter,
  1175. hdc,
  1176. iEsc,
  1177. cbIn,
  1178. pbIn,
  1179. cbOut,
  1180. pbOut,
  1181. piResult));
  1182. }