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.

874 lines
4.9 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. // Class CNDSPrintQueue Methods
  17. //
  18. struct _propmap
  19. {
  20. LPTSTR pszADsProp;
  21. LPTSTR pszNDSProp;
  22. } aPrintPropMapping[] =
  23. { { TEXT("Description"), TEXT("Description") },
  24. { TEXT("Location"), TEXT("L") },
  25. { TEXT("HostComputer"), TEXT("Host Server") }
  26. };
  27. DEFINE_IDispatch_Implementation(CNDSPrintQueue)
  28. DEFINE_CONTAINED_IADs_Implementation(CNDSPrintQueue)
  29. DEFINE_CONTAINED_IADsPropertyList_Implementation(CNDSPrintQueue)
  30. DEFINE_CONTAINED_IADsPutGet_Implementation(CNDSPrintQueue, aPrintPropMapping)
  31. CNDSPrintQueue::CNDSPrintQueue():
  32. _pADs(NULL),
  33. _pADsPropList(NULL)
  34. {
  35. _pDispMgr = NULL;
  36. ENLIST_TRACKING(CNDSPrintQueue);
  37. return;
  38. }
  39. CNDSPrintQueue::~CNDSPrintQueue()
  40. {
  41. if (_pADs) {
  42. _pADs->Release();
  43. }
  44. if (_pADsPropList) {
  45. _pADsPropList->Release();
  46. }
  47. delete _pDispMgr;
  48. return;
  49. }
  50. HRESULT
  51. CNDSPrintQueue:: CreatePrintQueue(
  52. IADs * pADs,
  53. REFIID riid,
  54. LPVOID * ppvoid
  55. )
  56. {
  57. CNDSPrintQueue *pPrintQueue = NULL;
  58. HRESULT hr;
  59. //
  60. // Create the printer object
  61. //
  62. hr = AllocatePrintQueueObject(
  63. pADs,
  64. &pPrintQueue
  65. );
  66. BAIL_ON_FAILURE(hr);
  67. //
  68. // initialize the core object
  69. //
  70. BAIL_ON_FAILURE(hr);
  71. hr = pPrintQueue->QueryInterface(
  72. riid,
  73. (void **)ppvoid
  74. );
  75. BAIL_ON_FAILURE(hr);
  76. pPrintQueue->Release();
  77. RRETURN(hr);
  78. error:
  79. delete pPrintQueue;
  80. RRETURN (hr);
  81. }
  82. /* IUnknown methods for printer object */
  83. STDMETHODIMP
  84. CNDSPrintQueue::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  85. {
  86. if(!ppvObj)
  87. {
  88. RRETURN(E_POINTER);
  89. }
  90. if (IsEqualIID(riid, IID_IUnknown))
  91. {
  92. *ppvObj = (IADsPrintQueue *)this;
  93. }
  94. else if (IsEqualIID(riid, IID_IDispatch))
  95. {
  96. *ppvObj = (IADsPrintQueue *)this;
  97. }
  98. else if (IsEqualIID(riid, IID_IADs))
  99. {
  100. *ppvObj = (IADsPrintQueue FAR *) this;
  101. }
  102. else if (IsEqualIID(riid, IID_IADsPrintQueue))
  103. {
  104. *ppvObj = (IADsPrintQueue FAR *) this;
  105. }
  106. else if (IsEqualIID(riid, IID_IADsPrintQueueOperations))
  107. {
  108. *ppvObj = (IADsPrintQueueOperations FAR *) this;
  109. }
  110. else if (IsEqualIID(riid, IID_IADsPropertyList) && _pADsPropList)
  111. {
  112. *ppvObj = (IADsPropertyList FAR *) this;
  113. }
  114. else
  115. {
  116. *ppvObj = NULL;
  117. RRETURN(E_NOINTERFACE);
  118. }
  119. ((LPUNKNOWN)*ppvObj)->AddRef();
  120. RRETURN(S_OK);
  121. }
  122. HRESULT
  123. CNDSPrintQueue::AllocatePrintQueueObject(
  124. IADs * pADs,
  125. CNDSPrintQueue ** ppPrintQueue
  126. )
  127. {
  128. CNDSPrintQueue FAR * pPrintQueue = NULL;
  129. HRESULT hr = S_OK;
  130. pPrintQueue = new CNDSPrintQueue();
  131. if (pPrintQueue == NULL) {
  132. hr = E_OUTOFMEMORY;
  133. }
  134. BAIL_ON_FAILURE(hr);
  135. pPrintQueue->_pDispMgr = new CDispatchMgr;
  136. if (pPrintQueue->_pDispMgr == NULL) {
  137. hr = E_OUTOFMEMORY;
  138. }
  139. BAIL_ON_FAILURE(hr);
  140. hr = LoadTypeInfoEntry(
  141. pPrintQueue->_pDispMgr,
  142. LIBID_ADs,
  143. IID_IADsPrintQueue,
  144. (IADsPrintQueue *)pPrintQueue,
  145. DISPID_REGULAR
  146. );
  147. BAIL_ON_FAILURE(hr);
  148. hr = LoadTypeInfoEntry(
  149. pPrintQueue->_pDispMgr,
  150. LIBID_ADs,
  151. IID_IADsPrintQueueOperations,
  152. (IADsPrintQueueOperations *)pPrintQueue,
  153. DISPID_REGULAR
  154. );
  155. hr = LoadTypeInfoEntry(
  156. pPrintQueue->_pDispMgr,
  157. LIBID_ADs,
  158. IID_IADsPropertyList,
  159. (IADsPropertyList *)pPrintQueue,
  160. DISPID_VALUE
  161. );
  162. BAIL_ON_FAILURE(hr);
  163. //
  164. // Store the pointer to the internal generic object
  165. // AND add ref this pointer
  166. //
  167. pPrintQueue->_pADs = pADs;
  168. pADs->AddRef();
  169. *ppPrintQueue = pPrintQueue;
  170. RRETURN(hr);
  171. error:
  172. delete pPrintQueue;
  173. RRETURN(hr);
  174. }