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.

276 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. sink.cxx
  5. Abstract:
  6. IIS MetaBase connection point container code for sinks
  7. Author:
  8. Michael W. Thomas 02-Oct-96
  9. Revision History:
  10. --*/
  11. #include "precomp.hxx"
  12. /*---------------------------------------------------------------------------
  13. CMDCOM's nested implementation of the COM standard
  14. IConnectionPointContainer interface including Constructor, Destructor,
  15. QueryInterface, AddRef, Release, FindConnectionPoint, and
  16. EnumConnectionPoints.
  17. ---------------------------------------------------------------------------*/
  18. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  19. Method: CMDCOM::CImpIConnectionPointContainer
  20. ::CImpIConnectionPointContainer
  21. Summary: Constructor for the CImpIConnectionPointContainer interface
  22. instantiation.
  23. Args: CMDCOM* pBackObj,
  24. Back pointer to the parent outer object.
  25. IUnknown* pUnkOuter
  26. Pointer to the outer Unknown. For delegation.
  27. Modifies: m_pBackObj, m_pUnkOuter.
  28. Returns: void
  29. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  30. CMDCOM::CImpIConnectionPointContainer::CImpIConnectionPointContainer()
  31. {
  32. // Init the Back Object Pointer to point to the parent object.
  33. //m_pBackObj = pBackObj;
  34. //m_pUnkOuter = pBackObj;
  35. return;
  36. }
  37. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  38. Method: CMDCOM::CImpIConnectionPointContainer
  39. ::~CImpIConnectionPointContainer
  40. Summary: Destructor for the CImpIConnectionPointContainer interface
  41. instantiation.
  42. Args: void
  43. Modifies: .
  44. Returns: void
  45. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  46. CMDCOM::CImpIConnectionPointContainer::~CImpIConnectionPointContainer(void)
  47. {
  48. return;
  49. }
  50. VOID CMDCOM::CImpIConnectionPointContainer::Init(CMDCOM *pBackObj)
  51. {
  52. // Init the Back Object Pointer to point to the parent object.
  53. m_pBackObj = pBackObj;
  54. m_pUnkOuter = (IUnknown*)pBackObj;
  55. return;
  56. }
  57. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  58. Method: CMDCOM::CImpIConnectionPointContainer::QueryInterface
  59. Summary: The QueryInterface IUnknown member of this IPaper interface
  60. implementation that delegates to m_pUnkOuter, whatever it is.
  61. Args: REFIID riid,
  62. [in] GUID of the Interface being requested.
  63. PPVOID ppv)
  64. [out] Address of the caller's pointer variable that will
  65. receive the requested interface pointer.
  66. Modifies: .
  67. Returns: HRESULT
  68. Standard OLE result code. NOERROR for success.
  69. Returned by the delegated outer QueryInterface call.
  70. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  71. STDMETHODIMP CMDCOM::CImpIConnectionPointContainer::QueryInterface(
  72. REFIID riid,
  73. PPVOID ppv)
  74. {
  75. // Delegate this call to the outer object's QueryInterface.
  76. return m_pUnkOuter->QueryInterface(riid, ppv);
  77. }
  78. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  79. Method: CMDCOM::CImpIConnectionPointContainer::AddRef
  80. Summary: The AddRef IUnknown member of this IPaper interface
  81. implementation that delegates to m_pUnkOuter, whatever it is.
  82. Args: void
  83. Modifies: .
  84. Returns: ULONG
  85. Returned by the delegated outer AddRef call.
  86. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  87. STDMETHODIMP_(ULONG) CMDCOM::CImpIConnectionPointContainer::AddRef(void)
  88. {
  89. // Delegate this call to the outer object's AddRef.
  90. return m_pUnkOuter->AddRef();
  91. }
  92. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  93. Method: CMDCOM::CImpIConnectionPointContainer::Release
  94. Summary: The Release IUnknown member of this IPaper interface
  95. implementation that delegates to m_pUnkOuter, whatever it is.
  96. Args: void
  97. Modifies: .
  98. Returns: ULONG
  99. Returned by the delegated outer Release call.
  100. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  101. STDMETHODIMP_(ULONG) CMDCOM::CImpIConnectionPointContainer::Release(void)
  102. {
  103. // Delegate this call to the outer object's Release.
  104. return m_pUnkOuter->Release();
  105. }
  106. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  107. Method: CMDCOM::CImpIConnectionPointContainer::FindConnectionPoint
  108. Summary: Given an IID for a connection point sink find and return the
  109. interface pointer for that connection point sink.
  110. Args: REFIID riid
  111. Reference to an IID
  112. IConnectionPoint** ppConnPt
  113. Address of the caller's IConnectionPoint interface pointer
  114. variable that will receive the requested interface pointer.
  115. Modifies: .
  116. Returns: HRESULT
  117. Standard OLE result code. NOERROR for success.
  118. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  119. STDMETHODIMP CMDCOM::CImpIConnectionPointContainer::FindConnectionPoint(
  120. REFIID riid,
  121. IConnectionPoint** ppConnPt)
  122. {
  123. HRESULT hr = E_NOINTERFACE;
  124. IConnectionPoint* pIConnPt;
  125. g_rSinkResource->Lock(TSRES_LOCK_READ);
  126. // NULL the output variable.
  127. *ppConnPt = NULL;
  128. if (riid == IID_IMDCOMSINK_A) {
  129. pIConnPt = m_pBackObj->m_aConnectionPoints[MD_CONNPOINT_WRITESINK_A];
  130. if (NULL != pIConnPt)
  131. {
  132. // This connectable CMDCOM object currently has only the Paper Sink
  133. // connection point. If the associated interface is requested,
  134. // use QI to get the Connection Point interface and perform the
  135. // needed AddRef.
  136. hr = pIConnPt->QueryInterface(IID_IConnectionPoint,
  137. (PPVOID)ppConnPt);
  138. }
  139. }
  140. else if (riid == IID_IMDCOMSINK_W) {
  141. pIConnPt = m_pBackObj->m_aConnectionPoints[MD_CONNPOINT_WRITESINK_W];
  142. if (NULL != pIConnPt)
  143. {
  144. // This connectable CMDCOM object currently has only the Paper Sink
  145. // connection point. If the associated interface is requested,
  146. // use QI to get the Connection Point interface and perform the
  147. // needed AddRef.
  148. hr = pIConnPt->QueryInterface(IID_IConnectionPoint,
  149. (PPVOID)ppConnPt);
  150. }
  151. }
  152. g_rSinkResource->Unlock();
  153. return hr;
  154. }
  155. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  156. Method: CMDCOM::CImpIConnectionPointContainer::EnumConnectionPoints
  157. Summary: Return Enumerator for the connectable object's contained
  158. connection points.
  159. Args: IEnumConnectionPoints** ppIEnum
  160. Address of the caller's Enumerator interface pointer
  161. variable. An output variable that will receive a pointer to
  162. the connection point enumerator COM object.
  163. Modifies: .
  164. Returns: HRESULT
  165. Standard OLE result code. NOERROR for success.
  166. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
  167. STDMETHODIMP CMDCOM::CImpIConnectionPointContainer::EnumConnectionPoints(
  168. IEnumConnectionPoints** ppIEnum)
  169. {
  170. HRESULT hr = NOERROR;
  171. IConnectionPoint* aConnPts[MAX_CONNECTION_POINTS];
  172. COEnumConnectionPoints* pCOEnum;
  173. UINT i;
  174. g_rSinkResource->Lock(TSRES_LOCK_READ);
  175. // Zero the output interface pointer.
  176. *ppIEnum = NULL;
  177. // Make a copy on the stack of the array of connection point
  178. // interfaces. The copy is used below in the creation of the new
  179. // Enumerator object.
  180. for (i=0; i<MAX_CONNECTION_POINTS; i++)
  181. aConnPts[i] = (IConnectionPoint*)m_pBackObj->m_aConnectionPoints[i];
  182. // Create a Connection Point enumerator COM object for the connection
  183. // points offered by this CMDCOM object. Pass 'this' to be used to
  184. // hook the lifetime of the host object to the life time of this
  185. // enumerator object.
  186. pCOEnum = new COEnumConnectionPoints(this);
  187. if (NULL != pCOEnum)
  188. {
  189. // Use the array copy to Init the new Enumerator COM object.
  190. // Set the initial Enumerator index to 0.
  191. hr = pCOEnum->Init(MAX_CONNECTION_POINTS, aConnPts, 0);
  192. if ( SUCCEEDED(hr) )
  193. {
  194. // QueryInterface to return the requested interface pointer.
  195. // An AddRef will be conveniently done by the QI.
  196. hr = pCOEnum->QueryInterface(
  197. IID_IEnumConnectionPoints,
  198. (PPVOID)ppIEnum);
  199. }
  200. if( FAILED( hr ) )
  201. {
  202. delete pCOEnum;
  203. pCOEnum = NULL;
  204. }
  205. }
  206. else
  207. hr = E_OUTOFMEMORY;
  208. g_rSinkResource->Unlock();
  209. return hr;
  210. }
  211.