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.

312 lines
11 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. TaxonomyDatabase.cpp
  5. Abstract:
  6. This file contains the implementation of the class CPCHTaxonomyDatabase.
  7. Revision History:
  8. Davide Massarenti (dmassare) 05/21/2000
  9. created
  10. ******************************************************************************/
  11. #include "stdafx.h"
  12. /////////////////////////////////////////////////////////////////////////////
  13. #define LOCAL_FUNC_PROLOGUE(func,hr,coll,val) \
  14. \
  15. __HCP_FUNC_ENTRY( func ); \
  16. \
  17. HRESULT hr; \
  18. CComPtr<CPCHQueryResultCollection> coll; \
  19. \
  20. __MPC_PARAMCHECK_BEGIN(hr) \
  21. __MPC_PARAMCHECK_POINTER_AND_SET(val,NULL); \
  22. __MPC_PARAMCHECK_END(); \
  23. \
  24. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &coll ));
  25. #define LOCAL_FUNC_EPILOGUE(hr,coll,val) \
  26. \
  27. __MPC_EXIT_IF_METHOD_FAILS(hr, coll.QueryInterface( val )); \
  28. \
  29. hr = S_OK; \
  30. \
  31. __HCP_FUNC_CLEANUP; \
  32. \
  33. __HCP_FUNC_EXIT(hr)
  34. /////////////////////////////////////////////////////////////////////////////
  35. HRESULT CPCHTaxonomyDatabase::SelectInstalledSKUs( /*[in]*/ bool fOnlyExported, /*[out, retval]*/ IPCHCollection* *pVal )
  36. {
  37. __HCP_FUNC_ENTRY( "CPCHTaxonomyDatabase::get_InstalledSKUs" );
  38. HRESULT hr;
  39. CComPtr<CPCHCollection> pColl;
  40. CPCHSetOfHelpTopics_Object* pObj = NULL;
  41. Taxonomy::LockingHandle handle;
  42. Taxonomy::InstalledInstanceIterConst itBegin;
  43. Taxonomy::InstalledInstanceIterConst itEnd;
  44. Taxonomy::InstalledInstanceIterConst it;
  45. __MPC_PARAMCHECK_BEGIN(hr)
  46. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  47. __MPC_PARAMCHECK_END();
  48. //
  49. // Get the list of SKU installed on the machine.
  50. //
  51. __MPC_EXIT_IF_METHOD_FAILS(hr, Taxonomy::InstalledInstanceStore::s_GLOBAL->GrabControl( handle ));
  52. __MPC_EXIT_IF_METHOD_FAILS(hr, Taxonomy::InstalledInstanceStore::s_GLOBAL->SKU_GetList( itBegin, itEnd ));
  53. //
  54. // Create a new collection.
  55. //
  56. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &pColl ));
  57. for(it = itBegin; it != itEnd; it++)
  58. {
  59. const Taxonomy::Instance& data = it->m_inst;
  60. if(fOnlyExported && !data.m_fExported) continue;
  61. __MPC_EXIT_IF_METHOD_FAILS(hr, pObj->CreateInstance( &pObj )); pObj->AddRef();
  62. __MPC_EXIT_IF_METHOD_FAILS(hr, pObj->Init( data ));
  63. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl->AddItem( pObj ));
  64. pObj->Release(); pObj = NULL;
  65. }
  66. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl.QueryInterface( pVal ));
  67. hr = S_OK;
  68. __HCP_FUNC_CLEANUP;
  69. MPC::Release( pObj );
  70. __HCP_FUNC_EXIT(hr);
  71. }
  72. /////////////////////////////////////////////////////////////////////////////
  73. STDMETHODIMP CPCHTaxonomyDatabase::get_InstalledSKUs( /*[out, retval]*/ IPCHCollection* *pVal )
  74. {
  75. return SelectInstalledSKUs( false, pVal );
  76. }
  77. STDMETHODIMP CPCHTaxonomyDatabase::get_HasWritePermissions( /*[out, retval]*/ VARIANT_BOOL *pVal )
  78. {
  79. __HCP_BEGIN_PROPERTY_GET2("CPCHTaxonomyDatabase::get_HasWritePermissions",hr,pVal,VARIANT_FALSE);
  80. if(SUCCEEDED(CPCHSetOfHelpTopics::VerifyWritePermissions()))
  81. {
  82. *pVal = VARIANT_TRUE;
  83. }
  84. __HCP_END_PROPERTY(hr);
  85. }
  86. /////////////////////////////////////////////////////////////////////////////
  87. STDMETHODIMP CPCHTaxonomyDatabase::LookupNode( /*[in]*/ BSTR bstrNode, /*[out, retval]*/ IPCHCollection* *ppC )
  88. {
  89. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::LookupNode", hr, pColl, ppC );
  90. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.LookupNode( bstrNode, pColl ));
  91. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  92. }
  93. STDMETHODIMP CPCHTaxonomyDatabase::LookupSubNodes( /*[in]*/ BSTR bstrNode ,
  94. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  95. /*[out, retval]*/ IPCHCollection* *ppC )
  96. {
  97. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::LookupSubNodes", hr, pColl, ppC );
  98. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.LookupSubNodes( bstrNode, fVisibleOnly == VARIANT_TRUE, pColl ));
  99. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  100. }
  101. STDMETHODIMP CPCHTaxonomyDatabase::LookupNodesAndTopics( /*[in]*/ BSTR bstrNode ,
  102. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  103. /*[out, retval]*/ IPCHCollection* *ppC )
  104. {
  105. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::LookupTopics", hr, pColl, ppC );
  106. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.LookupNodesAndTopics( bstrNode, fVisibleOnly == VARIANT_TRUE, pColl ));
  107. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  108. }
  109. STDMETHODIMP CPCHTaxonomyDatabase::LookupTopics( /*[in]*/ BSTR bstrNode ,
  110. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  111. /*[out, retval]*/ IPCHCollection* *ppC )
  112. {
  113. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::LookupTopics", hr, pColl, ppC );
  114. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.LookupTopics( bstrNode, fVisibleOnly == VARIANT_TRUE, pColl ));
  115. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  116. }
  117. STDMETHODIMP CPCHTaxonomyDatabase::LocateContext( /*[in]*/ BSTR bstrURL ,
  118. /*[in,optional]*/ VARIANT vSubSite ,
  119. /*[out, retval]*/ IPCHCollection* *ppC )
  120. {
  121. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::KeywordSearch", hr, pColl, ppC );
  122. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.LocateContext( bstrURL, vSubSite.vt == VT_BSTR ? vSubSite.bstrVal : NULL, pColl ));
  123. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  124. }
  125. STDMETHODIMP CPCHTaxonomyDatabase::KeywordSearch( /*[in]*/ BSTR bstrQuery ,
  126. /*[in,optional]*/ VARIANT vSubSite ,
  127. /*[out, retval]*/ IPCHCollection* *ppC )
  128. {
  129. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::KeywordSearch", hr, pColl, ppC );
  130. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.KeywordSearch( bstrQuery, vSubSite.vt == VT_BSTR ? vSubSite.bstrVal : NULL, pColl, NULL ));
  131. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  132. }
  133. STDMETHODIMP CPCHTaxonomyDatabase::GatherNodes( /*[in]*/ BSTR bstrNode ,
  134. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  135. /*[out, retval]*/ IPCHCollection* *ppC )
  136. {
  137. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::GatherNodes", hr, pColl, ppC );
  138. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.GatherNodes( bstrNode, fVisibleOnly == VARIANT_TRUE, pColl ));
  139. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  140. }
  141. STDMETHODIMP CPCHTaxonomyDatabase::GatherTopics( /*[in]*/ BSTR bstrNode ,
  142. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  143. /*[out, retval]*/ IPCHCollection* *ppC )
  144. {
  145. LOCAL_FUNC_PROLOGUE( "CPCHTaxonomyDatabase::GatherTopics", hr, pColl, ppC );
  146. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ts.GatherTopics( bstrNode, fVisibleOnly == VARIANT_TRUE, pColl ));
  147. LOCAL_FUNC_EPILOGUE( hr, pColl, ppC );
  148. }
  149. /////////////////////////////////////////////////////////////////////////////
  150. STDMETHODIMP CPCHTaxonomyDatabase::ConnectToDisk( /*[in]*/ BSTR bstrDirectory,
  151. /*[in]*/ IDispatch* notify ,
  152. /*[out, retval]*/ IPCHCollection* *pVal )
  153. {
  154. __HCP_FUNC_ENTRY( "CPCHTaxonomyDatabase::ConnectToDisk" );
  155. HRESULT hr;
  156. CComPtr<CPCHCollection> pColl;
  157. CComPtr<CPCHSetOfHelpTopics> pObj;
  158. __MPC_PARAMCHECK_BEGIN(hr)
  159. __MPC_PARAMCHECK_STRING_NOT_EMPTY(bstrDirectory);
  160. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  161. __MPC_PARAMCHECK_END();
  162. (void)Abort();
  163. //
  164. // Kickstart the asynchronous query to the server.
  165. //
  166. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &pColl ));
  167. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &pObj ));
  168. __MPC_EXIT_IF_METHOD_FAILS(hr, pObj->put_onStatusChange( notify ));
  169. __MPC_EXIT_IF_METHOD_FAILS(hr, pObj->InitFromDisk ( bstrDirectory, pColl ));
  170. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl.QueryInterface( pVal ));
  171. m_ActiveObject = pObj;
  172. hr = S_OK;
  173. __HCP_FUNC_CLEANUP;
  174. __HCP_FUNC_EXIT(hr);
  175. }
  176. STDMETHODIMP CPCHTaxonomyDatabase::ConnectToServer( /*[in]*/ BSTR bstrServerName,
  177. /*[in]*/ IDispatch* notify ,
  178. /*[out, retval]*/ IPCHCollection* *pVal )
  179. {
  180. __HCP_FUNC_ENTRY( "CPCHTaxonomyDatabase::ConnectToServer" );
  181. HRESULT hr;
  182. CComPtr<CPCHCollection> pColl;
  183. CComPtr<CPCHSetOfHelpTopics> pObj;
  184. __MPC_PARAMCHECK_BEGIN(hr)
  185. __MPC_PARAMCHECK_STRING_NOT_EMPTY(bstrServerName);
  186. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  187. __MPC_PARAMCHECK_END();
  188. (void)Abort();
  189. //
  190. // Kickstart the asynchronous query to the disk.
  191. //
  192. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &pColl ));
  193. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &pObj ));
  194. __MPC_EXIT_IF_METHOD_FAILS(hr, pObj->put_onStatusChange( notify ));
  195. __MPC_EXIT_IF_METHOD_FAILS(hr, pObj->InitFromServer ( bstrServerName, pColl ));
  196. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl.QueryInterface( pVal ));
  197. m_ActiveObject = pObj;
  198. hr = S_OK;
  199. __HCP_FUNC_CLEANUP;
  200. __HCP_FUNC_EXIT(hr);
  201. }
  202. STDMETHODIMP CPCHTaxonomyDatabase::Abort()
  203. {
  204. __HCP_FUNC_ENTRY( "CPCHTaxonomyDatabase::Abort" );
  205. HRESULT hr;
  206. if(m_ActiveObject)
  207. {
  208. __MPC_EXIT_IF_METHOD_FAILS(hr, m_ActiveObject->Abort());
  209. m_ActiveObject.Release();
  210. }
  211. hr = S_OK;
  212. __HCP_FUNC_CLEANUP;
  213. __HCP_FUNC_EXIT(hr);
  214. }