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.

232 lines
6.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. ccdata.cpp
  7. base class for the IAbout interface for MMC
  8. FILE HISTORY:
  9. */
  10. #include <stdafx.h>
  11. #include "ccdata.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. CComponentData::CComponentData()
  18. {
  19. }
  20. CComponentData::~CComponentData()
  21. {
  22. }
  23. IMPLEMENT_ADDREF_RELEASE(CComponentData)
  24. STDMETHODIMP CComponentData::QueryInterface(REFIID riid, LPVOID *ppv)
  25. {
  26. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  27. // Is the pointer bad?
  28. if (ppv == NULL)
  29. return E_INVALIDARG;
  30. // Place NULL in *ppv in case of failure
  31. *ppv = NULL;
  32. // This is the non-delegating IUnknown implementation
  33. if (riid == IID_IUnknown)
  34. *ppv = (LPVOID) this;
  35. else if (riid == IID_IComponentData)
  36. *ppv = (IComponentData *) this;
  37. else if (riid == IID_IExtendPropertySheet)
  38. *ppv = (IExtendPropertySheet *) this;
  39. else if (riid == IID_IExtendPropertySheet2)
  40. *ppv = (IExtendPropertySheet2 *) this;
  41. else if (riid == IID_IExtendContextMenu)
  42. *ppv = (IExtendContextMenu *) this;
  43. else if (riid == IID_IPersistStreamInit)
  44. *ppv = (IPersistStreamInit *) this;
  45. // If we're going to return an interface, AddRef it first
  46. if (*ppv)
  47. {
  48. ((LPUNKNOWN) *ppv)->AddRef();
  49. return hrOK;
  50. }
  51. else
  52. return E_NOINTERFACE;
  53. }
  54. /*!--------------------------------------------------------------------------
  55. CComponentData::FinalConstruct()
  56. Initialize values
  57. Author:
  58. Modifide 12/12/97 WeiJiang, Check return value from
  59. CreateTFSComponentData and check the result
  60. ---------------------------------------------------------------------------*/
  61. HRESULT
  62. CComponentData::FinalConstruct()
  63. {
  64. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  65. HRESULT hr = S_OK;
  66. IComponentData * pComponentData = NULL;
  67. // Create the underlying TFSComponentData
  68. hr = CreateTFSComponentData(&pComponentData,
  69. (ITFSCompDataCallback *) &m_ITFSCompDataCallback);
  70. //
  71. if(S_OK == hr)
  72. {
  73. m_spTFSComponentData.Query(pComponentData);
  74. m_spComponentData = pComponentData;
  75. m_spExtendPropertySheet.Query(pComponentData);
  76. m_spExtendContextMenu.Query(pComponentData);
  77. m_spSnapinHelp.Query(pComponentData);
  78. }
  79. return hr;
  80. }
  81. /*!--------------------------------------------------------------------------
  82. CComponentData::FinalRelease()
  83. Called when the COM object is going away
  84. Author:
  85. ---------------------------------------------------------------------------*/
  86. void
  87. CComponentData::FinalRelease()
  88. {
  89. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  90. m_spTFSComponentData.Release();
  91. // Call destroy on our TFSComponentData if needed
  92. if (m_spComponentData)
  93. m_spComponentData->Destroy();
  94. m_spComponentData.Release();
  95. m_spExtendPropertySheet.Release();
  96. m_spExtendContextMenu.Release();
  97. m_spSnapinHelp.Release();
  98. }
  99. /*---------------------------------------------------------------------------
  100. Implementation of EITFSCompDataCallback
  101. ---------------------------------------------------------------------------*/
  102. STDMETHODIMP CComponentData::EITFSCompDataCallback::QueryInterface(REFIID iid,void **ppv)
  103. {
  104. *ppv = 0;
  105. if (iid == IID_IUnknown)
  106. *ppv = (IUnknown *) this;
  107. else if (iid == IID_ITFSCompDataCallback)
  108. *ppv = (ITFSCompDataCallback *) this;
  109. else
  110. return ResultFromScode(E_NOINTERFACE);
  111. ((IUnknown *) *ppv)->AddRef();
  112. return hrOK;
  113. }
  114. STDMETHODIMP_(ULONG) CComponentData::EITFSCompDataCallback::AddRef()
  115. {
  116. return 1;
  117. }
  118. STDMETHODIMP_(ULONG) CComponentData::EITFSCompDataCallback::Release()
  119. {
  120. return 1;
  121. }
  122. STDMETHODIMP CComponentData::EITFSCompDataCallback::GetClassID(LPCLSID pClassID)
  123. {
  124. EMPrologIsolated(CComponentData, ITFSCompDataCallback, GetClassID)
  125. return pThis->GetClassID(pClassID);
  126. }
  127. STDMETHODIMP CComponentData::EITFSCompDataCallback::IsDirty()
  128. {
  129. EMPrologIsolated(CComponentData, ITFSCompDataCallback, IsDirty())
  130. return pThis->IsDirty();
  131. }
  132. STDMETHODIMP CComponentData::EITFSCompDataCallback::Load(LPSTREAM pStm)
  133. {
  134. EMPrologIsolated(CComponentData, ITFSCompDataCallback, Load)
  135. return pThis->Load(pStm);
  136. }
  137. STDMETHODIMP CComponentData::EITFSCompDataCallback::Save(LPSTREAM pStm, BOOL fClearDirty)
  138. {
  139. EMPrologIsolated(CComponentData, ITFSCompDataCallback, Save)
  140. return pThis->Save(pStm, fClearDirty);
  141. }
  142. STDMETHODIMP CComponentData::EITFSCompDataCallback::GetSizeMax(ULARGE_INTEGER *pcbSize)
  143. {
  144. EMPrologIsolated(CComponentData, ITFSCompDataCallback, GetSizeMax)
  145. return pThis->GetSizeMax(pcbSize);
  146. }
  147. STDMETHODIMP CComponentData::EITFSCompDataCallback::InitNew()
  148. {
  149. EMPrologIsolated(CComponentData, ITFSCompDataCallback, InitNew)
  150. return pThis->InitNew();
  151. }
  152. STDMETHODIMP CComponentData::EITFSCompDataCallback::OnInitialize(LPIMAGELIST lpScopeImage)
  153. {
  154. EMPrologIsolated(CComponentData, ITFSCompDataCallback, OnInitialize);
  155. return pThis->OnInitialize(lpScopeImage);
  156. }
  157. STDMETHODIMP CComponentData::EITFSCompDataCallback::OnInitializeNodeMgr(ITFSComponentData *pTFSCompData, ITFSNodeMgr *pNodeMgr)
  158. {
  159. EMPrologIsolated(CComponentData, ITFSCompDataCallback, OnInitializeNodeMgr);
  160. return pThis->OnInitializeNodeMgr(pTFSCompData, pNodeMgr);
  161. }
  162. STDMETHODIMP CComponentData::EITFSCompDataCallback::OnCreateComponent(LPCOMPONENT *ppComponent)
  163. {
  164. EMPrologIsolated(CComponentData, ITFSCompDataCallback, OnCreateComponent);
  165. return pThis->OnCreateComponent(ppComponent);
  166. }
  167. STDMETHODIMP CComponentData::EITFSCompDataCallback::OnDestroy()
  168. {
  169. EMPrologIsolated(CComponentData, ITFSCompDataCallback, OnDestroy);
  170. return pThis->OnDestroy();
  171. }
  172. STDMETHODIMP CComponentData::EITFSCompDataCallback::OnNotifyPropertyChange(LPDATAOBJECT pDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM lParam)
  173. {
  174. EMPrologIsolated(CComponentData, ITFSCompDataCallback, OnNotifyPropertyChange);
  175. return pThis->OnNotifyPropertyChange(pDataObject, event, arg, lParam);
  176. }
  177. STDMETHODIMP_(const CLSID *) CComponentData::EITFSCompDataCallback::GetCoClassID()
  178. {
  179. EMPrologIsolated(CComponentData, ITFSCompDataCallback, GetCoClassID);
  180. return pThis->GetCoClassID();
  181. }
  182. STDMETHODIMP CComponentData::EITFSCompDataCallback::OnCreateDataObject(MMC_COOKIE cookie, DATA_OBJECT_TYPES type, IDataObject **ppDataObject)
  183. {
  184. EMPrologIsolated(CComponentData, ITFSCompDataCallback, OnCreateDataObject);
  185. return pThis->OnCreateDataObject(cookie, type, ppDataObject);
  186. }