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.

244 lines
5.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. // 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_EXP_IF_ERR(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 FAR *)this;
  93. }
  94. else if (IsEqualIID(riid, IID_IDispatch))
  95. {
  96. *ppvObj = (IADsPrintQueue FAR *)this;
  97. }
  98. else if (IsEqualIID(riid, IID_ISupportErrorInfo))
  99. {
  100. *ppvObj = (ISupportErrorInfo FAR *) this;
  101. }
  102. else if (IsEqualIID(riid, IID_IADs))
  103. {
  104. *ppvObj = (IADsPrintQueue FAR *) this;
  105. }
  106. else if (IsEqualIID(riid, IID_IADsPrintQueue))
  107. {
  108. *ppvObj = (IADsPrintQueue FAR *) this;
  109. }
  110. else if (IsEqualIID(riid, IID_IADsPrintQueueOperations))
  111. {
  112. *ppvObj = (IADsPrintQueueOperations FAR *) this;
  113. }
  114. else if (IsEqualIID(riid, IID_IADsPropertyList) && _pADsPropList)
  115. {
  116. *ppvObj = (IADsPropertyList FAR *) this;
  117. }
  118. else
  119. {
  120. *ppvObj = NULL;
  121. RRETURN(E_NOINTERFACE);
  122. }
  123. ((LPUNKNOWN)*ppvObj)->AddRef();
  124. RRETURN(S_OK);
  125. }
  126. HRESULT
  127. CNDSPrintQueue::AllocatePrintQueueObject(
  128. IADs * pADs,
  129. CNDSPrintQueue ** ppPrintQueue
  130. )
  131. {
  132. CNDSPrintQueue FAR * pPrintQueue = NULL;
  133. HRESULT hr = S_OK;
  134. pPrintQueue = new CNDSPrintQueue();
  135. if (pPrintQueue == NULL) {
  136. hr = E_OUTOFMEMORY;
  137. }
  138. BAIL_ON_FAILURE(hr);
  139. pPrintQueue->_pDispMgr = new CDispatchMgr;
  140. if (pPrintQueue->_pDispMgr == NULL) {
  141. hr = E_OUTOFMEMORY;
  142. }
  143. BAIL_ON_FAILURE(hr);
  144. hr = LoadTypeInfoEntry(
  145. pPrintQueue->_pDispMgr,
  146. LIBID_ADs,
  147. IID_IADsPrintQueue,
  148. (IADsPrintQueue *)pPrintQueue,
  149. DISPID_REGULAR
  150. );
  151. BAIL_ON_FAILURE(hr);
  152. hr = LoadTypeInfoEntry(
  153. pPrintQueue->_pDispMgr,
  154. LIBID_ADs,
  155. IID_IADsPrintQueueOperations,
  156. (IADsPrintQueueOperations *)pPrintQueue,
  157. DISPID_REGULAR
  158. );
  159. hr = LoadTypeInfoEntry(
  160. pPrintQueue->_pDispMgr,
  161. LIBID_ADs,
  162. IID_IADsPropertyList,
  163. (IADsPropertyList *)pPrintQueue,
  164. DISPID_VALUE
  165. );
  166. BAIL_ON_FAILURE(hr);
  167. //
  168. // Store the pointer to the internal generic object
  169. // AND add ref this pointer
  170. //
  171. pPrintQueue->_pADs = pADs;
  172. pADs->AddRef();
  173. *ppPrintQueue = pPrintQueue;
  174. RRETURN(hr);
  175. error:
  176. delete pPrintQueue;
  177. RRETURN(hr);
  178. }
  179. /* ISupportErrorInfo method */
  180. STDMETHODIMP
  181. CNDSPrintQueue::InterfaceSupportsErrorInfo(
  182. THIS_ REFIID riid
  183. )
  184. {
  185. if (IsEqualIID(riid, IID_IADs) ||
  186. IsEqualIID(riid, IID_IADsPrintQueue) ||
  187. IsEqualIID(riid, IID_IADsPrintQueueOperations) ||
  188. IsEqualIID(riid, IID_IADsPropertyList)) {
  189. RRETURN(S_OK);
  190. } else {
  191. RRETURN(S_FALSE);
  192. }
  193. }