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.

335 lines
11 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. UserSettings.cpp
  5. Abstract:
  6. This file contains the implementation of the client-side proxy for
  7. IPCHUserSettings2 and IPCHUserSettings.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 07/17/2000
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. #include <TaxonomyDatabase.h>
  14. #define PROXY_METHOD(func,meth) \
  15. __HCP_FUNC_ENTRY( func ); \
  16. \
  17. HRESULT hr; \
  18. CComPtr<IPCHSetOfHelpTopics> sht; \
  19. \
  20. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht )); \
  21. \
  22. __MPC_EXIT_IF_METHOD_FAILS(hr, sht->##meth()); \
  23. \
  24. hr = S_OK; \
  25. \
  26. __HCP_FUNC_CLEANUP; \
  27. \
  28. __HCP_FUNC_EXIT(hr)
  29. #define PROXY_PROPERTY_PUT(func,meth,newVal) \
  30. __HCP_BEGIN_PROPERTY_PUT__NOLOCK(func,hr); \
  31. \
  32. CComPtr<IPCHSetOfHelpTopics> sht; \
  33. \
  34. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht )); \
  35. \
  36. __MPC_EXIT_IF_METHOD_FAILS(hr, sht->##meth( newVal )); \
  37. \
  38. __HCP_END_PROPERTY(hr)
  39. #define PROXY_PROPERTY_GET(func,meth,pVal) \
  40. __HCP_BEGIN_PROPERTY_GET__NOLOCK(func,hr,pVal); \
  41. \
  42. CComPtr<IPCHSetOfHelpTopics> sht; \
  43. \
  44. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht )); \
  45. \
  46. __MPC_EXIT_IF_METHOD_FAILS(hr, sht->##meth( pVal )); \
  47. \
  48. __HCP_END_PROPERTY(hr)
  49. #define PROXY_PROPERTY_GET2(func,meth,pVal,value) \
  50. __HCP_BEGIN_PROPERTY_GET2__NOLOCK(func,hr,pVal,value); \
  51. \
  52. CComPtr<IPCHSetOfHelpTopics> sht; \
  53. \
  54. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht )); \
  55. \
  56. __MPC_EXIT_IF_METHOD_FAILS(hr, sht->##meth( pVal )); \
  57. \
  58. __HCP_END_PROPERTY(hr)
  59. ////////////////////////////////////////////////////////////////////////////////
  60. CPCHProxy_IPCHSetOfHelpTopics::CPCHProxy_IPCHSetOfHelpTopics()
  61. {
  62. m_parent = NULL; // CPCHProxy_IPCHUserSettings2* m_parent;
  63. //
  64. // MPC::CComPtrThreadNeutral<IPCHSetOfHelpTopics> m_Direct_SKU;
  65. m_fMachine = false; // bool m_fMachine;
  66. }
  67. CPCHProxy_IPCHSetOfHelpTopics::~CPCHProxy_IPCHSetOfHelpTopics()
  68. {
  69. Passivate();
  70. }
  71. ////////////////////
  72. HRESULT CPCHProxy_IPCHSetOfHelpTopics::ConnectToParent( /*[in]*/ CPCHProxy_IPCHUserSettings2* parent, /*[in]*/ bool fMachine )
  73. {
  74. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHSetOfHelpTopics::ConnectToParent" );
  75. HRESULT hr;
  76. __MPC_PARAMCHECK_BEGIN(hr)
  77. __MPC_PARAMCHECK_NOTNULL(parent);
  78. __MPC_PARAMCHECK_END();
  79. m_parent = parent;
  80. m_fMachine = fMachine;
  81. //
  82. // If the parent is connected directly, let's do the same.
  83. //
  84. if(parent->IsConnected())
  85. {
  86. CComPtr<IPCHSetOfHelpTopics> sht;
  87. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht ));
  88. }
  89. hr = S_OK;
  90. __HCP_FUNC_CLEANUP;
  91. __HCP_FUNC_EXIT(hr);
  92. }
  93. void CPCHProxy_IPCHSetOfHelpTopics::Passivate()
  94. {
  95. m_Direct_SKU.Release();
  96. m_parent = NULL;
  97. }
  98. HRESULT CPCHProxy_IPCHSetOfHelpTopics::EnsureDirectConnection( /*[out]*/ CComPtr<IPCHSetOfHelpTopics>& sht, /*[in]*/ bool fRefresh )
  99. {
  100. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHSetOfHelpTopics::EnsureDirectConnection" );
  101. HRESULT hr;
  102. ProxySmartLock lock( &m_DirectLock );
  103. if(fRefresh) m_Direct_SKU.Release();
  104. sht.Release(); __MPC_EXIT_IF_METHOD_FAILS(hr, m_Direct_SKU.Access( &sht ));
  105. if(!sht)
  106. {
  107. DEBUG_AppendPerf( DEBUG_PERF_PROXIES, "CPCHProxy_IPCHSetOfHelpTopics::EnsureDirectConnection - IN" );
  108. if(m_parent)
  109. {
  110. CComPtr<IPCHUserSettings> us;
  111. lock = NULL;
  112. __MPC_EXIT_IF_METHOD_FAILS(hr, m_parent->EnsureDirectConnection( us ));
  113. lock = &m_DirectLock;
  114. if(m_fMachine)
  115. {
  116. __MPC_EXIT_IF_METHOD_FAILS(hr, us->get_MachineSKU( &sht ));
  117. }
  118. else
  119. {
  120. __MPC_EXIT_IF_METHOD_FAILS(hr, us->get_CurrentSKU( &sht ));
  121. }
  122. m_Direct_SKU = sht;
  123. }
  124. DEBUG_AppendPerf( DEBUG_PERF_PROXIES, "CPCHProxy_IPCHSetOfHelpTopics::EnsureDirectConnection - OUT" );
  125. if(!sht)
  126. {
  127. __MPC_SET_ERROR_AND_EXIT(hr, E_HANDLE);
  128. }
  129. }
  130. hr = S_OK;
  131. __HCP_FUNC_CLEANUP;
  132. __HCP_FUNC_EXIT(hr);
  133. }
  134. ////////////////////////////////////////////////////////////////////////////////
  135. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_SKU( /*[out, retval]*/ BSTR *pVal )
  136. {
  137. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHSetOfHelpTopics::get_SKU",hr,pVal);
  138. if(IsConnected())
  139. {
  140. CComPtr<IPCHSetOfHelpTopics> sht;
  141. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht ));
  142. __MPC_EXIT_IF_METHOD_FAILS(hr, sht->get_SKU( pVal ));
  143. }
  144. else if(m_parent)
  145. {
  146. Taxonomy::HelpSet& ths = m_parent->THS();
  147. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::GetBSTR( (m_fMachine ? ths.m_strSKU_Machine : ths.m_strSKU).c_str(), pVal ));
  148. }
  149. __HCP_END_PROPERTY(hr);
  150. }
  151. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_Language( /*[out, retval]*/ long *pVal )
  152. {
  153. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHSetOfHelpTopics::get_SKU",hr,pVal);
  154. if(IsConnected())
  155. {
  156. CComPtr<IPCHSetOfHelpTopics> sht;
  157. lock = NULL;
  158. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht ));
  159. lock = this;
  160. __MPC_EXIT_IF_METHOD_FAILS(hr, sht->get_Language( pVal ));
  161. }
  162. else if(m_parent)
  163. {
  164. Taxonomy::HelpSet& ths = m_parent->THS();
  165. *pVal = (m_fMachine ? ths.m_lLCID_Machine : ths.m_lLCID);
  166. }
  167. __HCP_END_PROPERTY(hr);
  168. }
  169. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_DisplayName( /*[out, retval]*/ BSTR *pVal )
  170. {
  171. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHSetOfHelpTopics::get_DisplayName",hr,pVal);
  172. if(IsConnected())
  173. {
  174. CComPtr<IPCHSetOfHelpTopics> sht;
  175. lock = NULL;
  176. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( sht ));
  177. lock = this;
  178. __MPC_EXIT_IF_METHOD_FAILS(hr, sht->get_DisplayName( pVal ));
  179. }
  180. else if(m_parent)
  181. {
  182. Taxonomy::Instance& inst = (m_fMachine ? m_parent->MachineInstance() : m_parent->CurrentInstance());
  183. __MPC_EXIT_IF_METHOD_FAILS(hr, m_parent->EnsureInSync());
  184. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::GetBSTR( inst.m_strDisplayName.c_str(), pVal ));
  185. }
  186. __HCP_END_PROPERTY(hr);
  187. }
  188. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_ProductID( /*[out, retval]*/ BSTR *pVal )
  189. {
  190. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_ProductID", get_ProductID, pVal );
  191. }
  192. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_Version( /*[out, retval]*/ BSTR *pVal )
  193. {
  194. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_Location", get_Location, pVal );
  195. }
  196. ////////////////////////////////////////
  197. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_Location( /*[out, retval]*/ BSTR *pVal )
  198. {
  199. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_Location", get_Location, pVal );
  200. }
  201. ////////////////////////////////////////
  202. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_Exported( /*[out, retval]*/ VARIANT_BOOL *pVal )
  203. {
  204. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_Exported", get_Exported, pVal );
  205. }
  206. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::put_Exported( /*[in]*/ VARIANT_BOOL newVal )
  207. {
  208. PROXY_PROPERTY_PUT( "CPCHProxy_IPCHSetOfHelpTopics::put_Exported", put_Exported, newVal );
  209. }
  210. ////////////////////////////////////////
  211. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::put_onStatusChange( /*[in]*/ IDispatch* function )
  212. {
  213. PROXY_PROPERTY_PUT( "CPCHProxy_IPCHSetOfHelpTopics::put_onStatusChange", put_onStatusChange, function );
  214. }
  215. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_Status( /*[out, retval]*/ SHT_STATUS *pVal )
  216. {
  217. PROXY_PROPERTY_GET2( "CPCHProxy_IPCHSetOfHelpTopics::get_Status", get_Status, pVal, SHT_NOTACTIVE );
  218. }
  219. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_ErrorCode( /*[out, retval]*/ long *pVal )
  220. {
  221. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_ErrorCode", get_ErrorCode, pVal );
  222. }
  223. ////////////////////////////////////////
  224. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_IsMachineHelp( /*[out, retval]*/ VARIANT_BOOL *pVal )
  225. {
  226. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_IsMachineHelp", get_IsMachineHelp, pVal );
  227. }
  228. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_IsInstalled( /*[out, retval]*/ VARIANT_BOOL *pVal )
  229. {
  230. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_IsInstalled", get_IsInstalled, pVal );
  231. }
  232. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_CanInstall( /*[out, retval]*/ VARIANT_BOOL *pVal )
  233. {
  234. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_CanInstall", get_CanInstall, pVal );
  235. }
  236. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::get_CanUninstall( /*[out, retval]*/ VARIANT_BOOL *pVal )
  237. {
  238. PROXY_PROPERTY_GET( "CPCHProxy_IPCHSetOfHelpTopics::get_CanUninstall", get_CanUninstall, pVal );
  239. }
  240. ////////////////////////////////////////
  241. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::Install()
  242. {
  243. PROXY_METHOD( "CPCHProxy_IPCHSetOfHelpTopics::Install", Install );
  244. }
  245. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::Uninstall()
  246. {
  247. PROXY_METHOD( "CPCHProxy_IPCHSetOfHelpTopics::Uninstall", Uninstall );
  248. }
  249. STDMETHODIMP CPCHProxy_IPCHSetOfHelpTopics::Abort()
  250. {
  251. PROXY_METHOD( "CPCHProxy_IPCHSetOfHelpTopics::Abort", Abort );
  252. }