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.

307 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 client-side proxy for IPCHTaxonomyDatabase
  7. Revision History:
  8. Davide Massarenti (Dmassare) 07/17/2000
  9. created
  10. ******************************************************************************/
  11. #include "stdafx.h"
  12. ////////////////////////////////////////////////////////////////////////////////
  13. CPCHProxy_IPCHTaxonomyDatabase::CPCHProxy_IPCHTaxonomyDatabase() : m_AsyncCachingEngine(this)
  14. {
  15. // CPCHSecurityHandle m_SecurityHandle;
  16. m_parent = NULL; // CPCHProxy_IPCHUtility* m_parent;
  17. //
  18. // MPC::CComPtrThreadNeutral<IPCHTaxonomyDatabase> m_Direct_TaxonomyDatabase;
  19. // AsynchronousTaxonomyDatabase::Engine m_AsyncCachingEngine;
  20. }
  21. CPCHProxy_IPCHTaxonomyDatabase::~CPCHProxy_IPCHTaxonomyDatabase()
  22. {
  23. Passivate();
  24. }
  25. ////////////////////
  26. HRESULT CPCHProxy_IPCHTaxonomyDatabase::ConnectToParent( /*[in]*/ CPCHProxy_IPCHUtility* parent, /*[in]*/ CPCHHelpCenterExternal* ext )
  27. {
  28. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHTaxonomyDatabase::ConnectToParent" );
  29. HRESULT hr;
  30. __MPC_PARAMCHECK_BEGIN(hr)
  31. __MPC_PARAMCHECK_NOTNULL(parent);
  32. __MPC_PARAMCHECK_END();
  33. m_parent = parent;
  34. m_SecurityHandle.Initialize( ext, (IPCHTaxonomyDatabase*)this );
  35. hr = S_OK;
  36. __HCP_FUNC_CLEANUP;
  37. __HCP_FUNC_EXIT(hr);
  38. }
  39. void CPCHProxy_IPCHTaxonomyDatabase::Passivate()
  40. {
  41. m_AsyncCachingEngine.Passivate();
  42. m_Direct_TaxonomyDatabase.Release();
  43. m_SecurityHandle.Passivate();
  44. m_parent = NULL;
  45. }
  46. HRESULT CPCHProxy_IPCHTaxonomyDatabase::EnsureDirectConnection( /*[out]*/ CComPtr<IPCHTaxonomyDatabase>& db, /*[in]*/ bool fRefresh )
  47. {
  48. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHTaxonomyDatabase::EnsureDirectConnection" );
  49. HRESULT hr;
  50. ProxySmartLock lock( &m_DirectLock );
  51. bool fNotifyEngine = false;
  52. if(fRefresh) m_Direct_TaxonomyDatabase.Release();
  53. db.Release(); __MPC_EXIT_IF_METHOD_FAILS(hr, m_Direct_TaxonomyDatabase.Access( &db ));
  54. if(!db)
  55. {
  56. DEBUG_AppendPerf( DEBUG_PERF_PROXIES, "CPCHProxy_IPCHTaxonomyDatabase::EnsureDirectConnection - IN" );
  57. if(m_parent)
  58. {
  59. CComPtr<IPCHUtility> util;
  60. lock = NULL;
  61. __MPC_EXIT_IF_METHOD_FAILS(hr, m_parent->EnsureDirectConnection( util ));
  62. lock = &m_DirectLock;
  63. __MPC_EXIT_IF_METHOD_FAILS(hr, util->get_Database( &db ));
  64. m_Direct_TaxonomyDatabase = db;
  65. }
  66. DEBUG_AppendPerf( DEBUG_PERF_PROXIES, "CPCHProxy_IPCHTaxonomyDatabase::EnsureDirectConnection - OUT" );
  67. if(!db)
  68. {
  69. __MPC_SET_ERROR_AND_EXIT(hr, E_HANDLE);
  70. }
  71. fNotifyEngine = true;
  72. }
  73. if(fNotifyEngine)
  74. {
  75. lock = NULL; // Unlock before calling into the engine.
  76. m_AsyncCachingEngine.RefreshConnection();
  77. }
  78. hr = S_OK;
  79. __HCP_FUNC_CLEANUP;
  80. __HCP_FUNC_EXIT(hr);
  81. }
  82. ////////////////////////////////////////////////////////////////////////////////
  83. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::get_InstalledSKUs( /*[out, retval]*/ IPCHCollection* *pVal )
  84. {
  85. __HCP_BEGIN_PROPERTY_GET__NOLOCK("CPCHProxy_IPCHTaxonomyDatabase::get_InstalledSKUs",hr,pVal);
  86. CComPtr<IPCHTaxonomyDatabase> db;
  87. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( db ));
  88. __MPC_EXIT_IF_METHOD_FAILS(hr, db->get_InstalledSKUs( pVal ));
  89. __HCP_END_PROPERTY(hr);
  90. }
  91. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::get_HasWritePermissions( /*[out, retval]*/ VARIANT_BOOL *pVal )
  92. {
  93. __HCP_BEGIN_PROPERTY_GET2__NOLOCK("CPCHProxy_IPCHTaxonomyDatabase::get_InstalledSKUs",hr,pVal,VARIANT_FALSE);
  94. CComPtr<IPCHTaxonomyDatabase> db;
  95. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( db ));
  96. __MPC_EXIT_IF_METHOD_FAILS(hr, db->get_HasWritePermissions( pVal ));
  97. __HCP_END_PROPERTY(hr);
  98. }
  99. ////////////////////////////////////////////////////////////////////////////////
  100. HRESULT CPCHProxy_IPCHTaxonomyDatabase::ExecuteQuery( /*[in]*/ int iType ,
  101. /*[in]*/ LPCWSTR szID ,
  102. /*[out, retval]*/ CPCHQueryResultCollection* *ppC ,
  103. /*[in]*/ VARIANT* option )
  104. {
  105. return m_AsyncCachingEngine.ExecuteQuery( iType, szID, option, ppC );
  106. }
  107. HRESULT CPCHProxy_IPCHTaxonomyDatabase::ExecuteQuery( /*[in]*/ int iType ,
  108. /*[in]*/ LPCWSTR szID ,
  109. /*[out, retval]*/ IPCHCollection* *ppC ,
  110. /*[in]*/ VARIANT* option )
  111. {
  112. HRESULT hr;
  113. if(ppC == NULL)
  114. {
  115. hr = E_POINTER;
  116. }
  117. else
  118. {
  119. CPCHQueryResultCollection* pColl = NULL;
  120. hr = ExecuteQuery( iType, szID, &pColl, option ); *ppC = pColl;
  121. }
  122. return hr;
  123. }
  124. ////////////////////
  125. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::LookupNode( /*[in]*/ BSTR bstrNode ,
  126. /*[out, retval]*/ IPCHCollection* *ppC )
  127. {
  128. int iType = OfflineCache::ET_NODE;
  129. return ExecuteQuery( iType, bstrNode, ppC );
  130. }
  131. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::LookupSubNodes( /*[in]*/ BSTR bstrNode ,
  132. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  133. /*[out, retval]*/ IPCHCollection* *ppC )
  134. {
  135. int iType = (fVisibleOnly == VARIANT_TRUE) ? OfflineCache::ET_SUBNODES_VISIBLE : OfflineCache::ET_SUBNODES;
  136. return ExecuteQuery( iType, bstrNode, ppC );
  137. }
  138. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::LookupNodesAndTopics( /*[in]*/ BSTR bstrNode ,
  139. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  140. /*[out, retval]*/ IPCHCollection* *ppC )
  141. {
  142. int iType = (fVisibleOnly == VARIANT_TRUE) ? OfflineCache::ET_NODESANDTOPICS_VISIBLE : OfflineCache::ET_NODESANDTOPICS;
  143. return ExecuteQuery( iType, bstrNode, ppC );
  144. }
  145. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::LookupTopics( /*[in]*/ BSTR bstrNode ,
  146. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  147. /*[out, retval]*/ IPCHCollection* *ppC )
  148. {
  149. int iType = (fVisibleOnly == VARIANT_TRUE) ? OfflineCache::ET_TOPICS_VISIBLE : OfflineCache::ET_TOPICS;
  150. return ExecuteQuery( iType, bstrNode, ppC );
  151. }
  152. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::LocateContext( /*[in]*/ BSTR bstrURL ,
  153. /*[in,optional]*/ VARIANT vSubSite ,
  154. /*[out, retval]*/ IPCHCollection* *ppC )
  155. {
  156. int iType = OfflineCache::ET_LOCATECONTEXT;
  157. return ExecuteQuery( iType, bstrURL, ppC, &vSubSite );
  158. }
  159. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::KeywordSearch( /*[in]*/ BSTR bstrQuery ,
  160. /*[in,optional]*/ VARIANT vSubSite ,
  161. /*[out, retval]*/ IPCHCollection* *ppC )
  162. {
  163. int iType = OfflineCache::ET_SEARCH;
  164. return ExecuteQuery( iType, bstrQuery, ppC, &vSubSite );
  165. }
  166. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::GatherNodes( /*[in]*/ BSTR bstrNode ,
  167. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  168. /*[out, retval]*/ IPCHCollection* *ppC )
  169. {
  170. int iType = (fVisibleOnly == VARIANT_TRUE) ? OfflineCache::ET_NODES_RECURSIVE : OfflineCache::ET_NODES_RECURSIVE;
  171. return ExecuteQuery( iType, bstrNode, ppC );
  172. }
  173. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::GatherTopics( /*[in]*/ BSTR bstrNode ,
  174. /*[in]*/ VARIANT_BOOL fVisibleOnly ,
  175. /*[out, retval]*/ IPCHCollection* *ppC )
  176. {
  177. int iType = (fVisibleOnly == VARIANT_TRUE) ? OfflineCache::ET_TOPICS_RECURSIVE : OfflineCache::ET_TOPICS_RECURSIVE;
  178. return ExecuteQuery( iType, bstrNode, ppC );
  179. }
  180. ////////////////////////////////////////////////////////////////////////////////
  181. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::ConnectToDisk( /*[in]*/ BSTR bstrDirectory ,
  182. /*[in]*/ IDispatch* notify ,
  183. /*[out, retval]*/ IPCHCollection* *ppC )
  184. {
  185. __HCP_BEGIN_PROPERTY_GET__NOLOCK("CPCHProxy_IPCHTaxonomyDatabase::ConnectToDisk",hr,ppC);
  186. CComPtr<IPCHTaxonomyDatabase> db;
  187. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( db ));
  188. __MPC_EXIT_IF_METHOD_FAILS(hr, db->ConnectToDisk( bstrDirectory, notify, ppC ));
  189. __HCP_END_PROPERTY(hr);
  190. }
  191. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::ConnectToServer( /*[in]*/ BSTR bstrServerName ,
  192. /*[in]*/ IDispatch* notify ,
  193. /*[out, retval]*/ IPCHCollection* *ppC )
  194. {
  195. __HCP_BEGIN_PROPERTY_GET__NOLOCK("CPCHProxy_IPCHTaxonomyDatabase::ConnectToServer",hr,ppC);
  196. CComPtr<IPCHTaxonomyDatabase> db;
  197. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( db ));
  198. __MPC_EXIT_IF_METHOD_FAILS(hr, db->ConnectToServer( bstrServerName, notify, ppC ));
  199. __HCP_END_PROPERTY(hr);
  200. }
  201. STDMETHODIMP CPCHProxy_IPCHTaxonomyDatabase::Abort()
  202. {
  203. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHTaxonomyDatabase::Abort" );
  204. HRESULT hr;
  205. CComPtr<IPCHTaxonomyDatabase> db;
  206. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( db ));
  207. __MPC_EXIT_IF_METHOD_FAILS(hr, db->Abort());
  208. hr = S_OK;
  209. __HCP_FUNC_CLEANUP;
  210. __HCP_FUNC_EXIT(hr);
  211. }