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.

960 lines
25 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. #include <shlobj.h>
  15. #include <shlobjp.h>
  16. #include <shldisp.h>
  17. /////////////////////////////////////////////////////////////////////////////
  18. static HRESULT local_GetInstance( /*[in]*/ CComPtr<IPCHSetOfHelpTopics>& sht ,
  19. /*[in]*/ Taxonomy::Instance& inst )
  20. {
  21. __HCP_FUNC_ENTRY( "local_GetInstance" );
  22. HRESULT hr;
  23. LARGE_INTEGER liFilePos = { 0, 0 };
  24. CComPtr<IStream> stream;
  25. CComPtr<IPersistStream> persist;
  26. __MPC_EXIT_IF_METHOD_FAILS(hr, sht.QueryInterface( &persist ));
  27. __MPC_EXIT_IF_METHOD_FAILS(hr, ::CreateStreamOnHGlobal( NULL, TRUE, &stream ));
  28. __MPC_EXIT_IF_METHOD_FAILS(hr, persist->Save( stream, FALSE ));
  29. __MPC_EXIT_IF_METHOD_FAILS(hr, stream->Seek( liFilePos, STREAM_SEEK_SET, NULL ));
  30. __MPC_EXIT_IF_METHOD_FAILS(hr, inst.LoadFromStream( stream ));
  31. hr = S_OK;
  32. __HCP_FUNC_CLEANUP;
  33. __HCP_FUNC_EXIT(hr);
  34. }
  35. ////////////////////////////////////////////////////////////////////////////////
  36. CPCHProxy_IPCHUserSettings2::CPCHProxy_IPCHUserSettings2()
  37. {
  38. // CPCHSecurityHandle m_SecurityHandle;
  39. m_parent = NULL; // CPCHProxy_IPCHUtility* m_parent;
  40. //
  41. // MPC::CComPtrThreadNeutral<IPCHUserSettings> m_Direct_UserSettings;
  42. //
  43. m_MachineSKU = NULL; // CPCHProxy_IPCHSetOfHelpTopics* m_MachineSKU;
  44. m_CurrentSKU = NULL; // CPCHProxy_IPCHSetOfHelpTopics* m_CurrentSKU;
  45. // Taxonomy::HelpSet m_ths;
  46. // CComBSTR m_bstrScope;
  47. //
  48. m_fReady = false; // bool m_fReady;
  49. // Taxonomy::Instance m_instMachine;
  50. // Taxonomy::Instance m_instCurrent;
  51. //
  52. m_News_fDone = false; // bool m_News_fDone;
  53. m_News_fEnabled = false; // bool m_News_fEnabled;
  54. // MPC::CComPtrThreadNeutral<IUnknown> m_News_xmlData;
  55. }
  56. CPCHProxy_IPCHUserSettings2::~CPCHProxy_IPCHUserSettings2()
  57. {
  58. Thread_Wait();
  59. Passivate();
  60. }
  61. ////////////////////
  62. HRESULT CPCHProxy_IPCHUserSettings2::ConnectToParent( /*[in]*/ CPCHProxy_IPCHUtility* parent, /*[in]*/ CPCHHelpCenterExternal* ext )
  63. {
  64. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::ConnectToParent" );
  65. HRESULT hr;
  66. __MPC_PARAMCHECK_BEGIN(hr)
  67. __MPC_PARAMCHECK_NOTNULL(parent);
  68. __MPC_PARAMCHECK_END();
  69. m_parent = parent;
  70. m_SecurityHandle.Initialize( ext, (IPCHUserSettings2*)this );
  71. hr = S_OK;
  72. __HCP_FUNC_CLEANUP;
  73. __HCP_FUNC_EXIT(hr);
  74. }
  75. void CPCHProxy_IPCHUserSettings2::Passivate()
  76. {
  77. m_Direct_UserSettings.Release();
  78. MPC::Release( m_CurrentSKU );
  79. MPC::Release( m_MachineSKU );
  80. m_SecurityHandle.Passivate();
  81. m_parent = NULL;
  82. }
  83. HRESULT CPCHProxy_IPCHUserSettings2::EnsureDirectConnection( /*[out]*/ CComPtr<IPCHUserSettings>& us, /*[in]*/ bool fRefresh )
  84. {
  85. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::EnsureDirectConnection" );
  86. HRESULT hr;
  87. ProxySmartLock lock( &m_DirectLock );
  88. if(fRefresh) m_Direct_UserSettings.Release();
  89. us.Release(); __MPC_EXIT_IF_METHOD_FAILS(hr, m_Direct_UserSettings.Access( &us ));
  90. if(!us)
  91. {
  92. DEBUG_AppendPerf( DEBUG_PERF_PROXIES, "CPCHProxy_IPCHUserSettings2::EnsureDirectConnection - IN" );
  93. if(m_parent)
  94. {
  95. CComPtr<IPCHUtility> util;
  96. CComPtr<IPCHSetOfHelpTopics> sht;
  97. MPC::Release( m_MachineSKU );
  98. lock = NULL;
  99. __MPC_EXIT_IF_METHOD_FAILS(hr, m_parent->EnsureDirectConnection( util ));
  100. lock = &m_DirectLock;
  101. __MPC_EXIT_IF_METHOD_FAILS(hr, util->get_UserSettings( &us ));
  102. m_Direct_UserSettings = us;
  103. //
  104. // Initialize Machine data.
  105. //
  106. __MPC_EXIT_IF_METHOD_FAILS(hr, us->get_MachineSKU( &sht ));
  107. __MPC_EXIT_IF_METHOD_FAILS(hr, local_GetInstance ( sht, m_instMachine ));
  108. __MPC_EXIT_IF_METHOD_FAILS(hr, Taxonomy::HelpSet::SetMachineInfo( m_instMachine ));
  109. }
  110. DEBUG_AppendPerf( DEBUG_PERF_PROXIES, "CPCHProxy_IPCHUserSettings2::EnsureDirectConnection - OUT" );
  111. if(!us)
  112. {
  113. __MPC_SET_ERROR_AND_EXIT(hr, E_HANDLE);
  114. }
  115. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  116. }
  117. hr = S_OK;
  118. __HCP_FUNC_CLEANUP;
  119. __HCP_FUNC_EXIT(hr);
  120. }
  121. HRESULT CPCHProxy_IPCHUserSettings2::EnsureInSync()
  122. {
  123. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::EnsureInSync" );
  124. HRESULT hr;
  125. if(m_fReady == false)
  126. {
  127. CComPtr<IPCHUserSettings> us;
  128. CComPtr<IPCHSetOfHelpTopics> sht;
  129. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( us ));
  130. MPC::Release( m_CurrentSKU );
  131. __MPC_EXIT_IF_METHOD_FAILS(hr, us->get_CurrentSKU( &sht ));
  132. __MPC_EXIT_IF_METHOD_FAILS(hr, local_GetInstance ( sht, m_instCurrent ));
  133. CHCPProtocolEnvironment::s_GLOBAL->SetHelpLocation( m_instCurrent );
  134. m_fReady = true;
  135. }
  136. hr = S_OK;
  137. __HCP_FUNC_CLEANUP;
  138. __HCP_FUNC_EXIT(hr);
  139. }
  140. HRESULT CPCHProxy_IPCHUserSettings2::GetCurrentSKU( /*[out]*/ CPCHProxy_IPCHSetOfHelpTopics* *pVal )
  141. {
  142. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::GetUserSettings2" );
  143. HRESULT hr;
  144. MPC::SmartLock<_ThreadModel> lock( this );
  145. if(m_CurrentSKU == NULL)
  146. {
  147. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &m_CurrentSKU ));
  148. __MPC_EXIT_IF_METHOD_FAILS(hr, m_CurrentSKU->ConnectToParent( this, /*fMachine*/false ));
  149. }
  150. hr = S_OK;
  151. __HCP_FUNC_CLEANUP;
  152. if(FAILED(hr)) MPC::Release( m_CurrentSKU );
  153. (void)MPC::CopyTo( m_CurrentSKU, pVal );
  154. __HCP_FUNC_EXIT(hr);
  155. }
  156. HRESULT CPCHProxy_IPCHUserSettings2::GetMachineSKU( /*[out]*/ CPCHProxy_IPCHSetOfHelpTopics* *pVal )
  157. {
  158. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::GetUserSettings2" );
  159. HRESULT hr;
  160. MPC::SmartLock<_ThreadModel> lock( this );
  161. if(m_MachineSKU == NULL)
  162. {
  163. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &m_MachineSKU ));
  164. __MPC_EXIT_IF_METHOD_FAILS(hr, m_MachineSKU->ConnectToParent( this, /*fMachine*/true ));
  165. }
  166. hr = S_OK;
  167. __HCP_FUNC_CLEANUP;
  168. if(FAILED(hr)) MPC::Release( m_MachineSKU );
  169. (void)MPC::CopyTo( m_MachineSKU, pVal );
  170. __HCP_FUNC_EXIT(hr);
  171. }
  172. ////////////////////////////////////////////////////////////////////////////////
  173. bool CPCHProxy_IPCHUserSettings2::CanUseUserSettings()
  174. {
  175. CPCHHelpCenterExternal* parent3;
  176. CPCHProxy_IPCHService* parent2;
  177. CPCHProxy_IPCHUtility* parent1;
  178. //
  179. // Only if we are from Start->Help we consider user settings.
  180. //
  181. if((parent1 = Parent()) &&
  182. (parent2 = parent1->Parent()) &&
  183. (parent3 = parent2->Parent()) )
  184. {
  185. if(parent3->IsFromStartHelp() && parent3->DoesPersistSettings()) return true;
  186. }
  187. return false;
  188. }
  189. HRESULT CPCHProxy_IPCHUserSettings2::LoadUserSettings()
  190. {
  191. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::LoadUserSettings" );
  192. HRESULT hr;
  193. MPC::SmartLock<_ThreadModel> lock( this );
  194. //
  195. // Reload machine SKU.
  196. //
  197. (void)m_ths.Initialize( NULL, (long)0 );
  198. if(CanUseUserSettings())
  199. {
  200. //
  201. // If we are on a terminal server session, look for global default settings...
  202. //
  203. {
  204. Taxonomy::HelpSet& ths = CPCHOptions::s_GLOBAL->TerminalServerHelpSet();
  205. (void)m_ths.Initialize( ths.m_strSKU.size() ? ths.GetSKU() : NULL, ths.GetLanguage() );
  206. }
  207. //
  208. // ... then try anyway the user settings.
  209. //
  210. {
  211. Taxonomy::HelpSet& ths = CPCHOptions::s_GLOBAL->CurrentHelpSet();
  212. (void)m_ths.Initialize( ths.m_strSKU.size() ? ths.GetSKU() : NULL, ths.GetLanguage() );
  213. }
  214. }
  215. hr = S_OK;
  216. __HCP_FUNC_EXIT(hr);
  217. }
  218. HRESULT CPCHProxy_IPCHUserSettings2::SaveUserSettings()
  219. {
  220. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::SaveUserSettings" );
  221. HRESULT hr;
  222. MPC::SmartLock<_ThreadModel> lock( this );
  223. if(CanUseUserSettings())
  224. {
  225. if(CPCHOptions::s_GLOBAL)
  226. {
  227. (void)CPCHOptions::s_GLOBAL->put_CurrentHelpSet( m_ths );
  228. }
  229. }
  230. hr = S_OK;
  231. __HCP_FUNC_EXIT(hr);
  232. }
  233. HRESULT CPCHProxy_IPCHUserSettings2::Initialize()
  234. {
  235. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::Initialize" );
  236. HRESULT hr;
  237. //
  238. // Read user configuration.
  239. //
  240. __MPC_EXIT_IF_METHOD_FAILS(hr, LoadUserSettings());
  241. //
  242. // If the parent is connected directly or the cache is not ready, connect directly
  243. //
  244. if(Parent() && Parent()->IsConnected() || OfflineCache::Root::s_GLOBAL->IsReady() == false)
  245. {
  246. CComPtr<IPCHUserSettings> us;
  247. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( us ));
  248. }
  249. //
  250. // Wait a little for the cache to become ready.
  251. //
  252. {
  253. const int iMaxWait = 1000; // 1 second.
  254. int iCount = 0;
  255. while(OfflineCache::Root::s_GLOBAL->IsReady() == false && iCount < iMaxWait)
  256. {
  257. ::Sleep( 10 ); iCount += 10;
  258. }
  259. }
  260. //
  261. // Do we have a valid cache for this SKU?
  262. //
  263. if(OfflineCache::Root::s_GLOBAL->IsReady())
  264. {
  265. {
  266. OfflineCache::Handle handle;
  267. m_instMachine = OfflineCache::Root::s_GLOBAL->MachineInstance();
  268. if(FAILED(OfflineCache::Root::s_GLOBAL->Locate( m_ths, handle )))
  269. {
  270. m_ths = m_instMachine.m_ths;
  271. }
  272. if(SUCCEEDED(OfflineCache::Root::s_GLOBAL->Locate( m_ths, handle )))
  273. {
  274. //
  275. // Yes, then populate from it...
  276. //
  277. m_fReady = true;
  278. m_instCurrent = handle->Instance();
  279. }
  280. }
  281. if(m_fReady)
  282. {
  283. //
  284. // System Help, let's see if we have a version matching the user Default UI Language.
  285. //
  286. if(m_instCurrent.m_fSystem || m_instCurrent.m_fMUI)
  287. {
  288. long lUser = Taxonomy::HelpSet::GetUserLCID();
  289. if(lUser != m_ths.GetLanguage())
  290. {
  291. OfflineCache::Handle handle;
  292. Taxonomy::HelpSet ths; ths.Initialize( m_ths.GetSKU(), lUser );
  293. if(SUCCEEDED(OfflineCache::Root::s_GLOBAL->Locate( ths, handle )))
  294. {
  295. m_ths = ths;
  296. m_instCurrent = handle->Instance();
  297. }
  298. }
  299. }
  300. CHCPProtocolEnvironment::s_GLOBAL->SetHelpLocation( m_instCurrent );
  301. }
  302. }
  303. hr = S_OK;
  304. __HCP_FUNC_CLEANUP;
  305. __HCP_FUNC_EXIT(hr);
  306. }
  307. ////////////////////////////////////////////////////////////////////////////////
  308. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_CurrentSKU( /*[out, retval]*/ IPCHSetOfHelpTopics* *pVal )
  309. {
  310. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_CurrentSKU",hr,pVal);
  311. __MPC_EXIT_IF_METHOD_FAILS(hr, GetCurrentSKU());
  312. __MPC_EXIT_IF_METHOD_FAILS(hr, m_CurrentSKU->QueryInterface( IID_IPCHSetOfHelpTopics, (void**)pVal ));
  313. __HCP_END_PROPERTY(hr);
  314. }
  315. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_MachineSKU( /*[out, retval]*/ IPCHSetOfHelpTopics* *pVal )
  316. {
  317. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_MachineSKU",hr,pVal);
  318. __MPC_EXIT_IF_METHOD_FAILS(hr, GetMachineSKU());
  319. __MPC_EXIT_IF_METHOD_FAILS(hr, m_MachineSKU->QueryInterface( IID_IPCHSetOfHelpTopics, (void**)pVal ));
  320. __HCP_END_PROPERTY(hr);
  321. }
  322. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_HelpLocation( /*[out, retval]*/ BSTR *pVal )
  323. {
  324. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_HelpLocation",hr,pVal);
  325. INTERNETSECURITY__CHECK_TRUST();
  326. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  327. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::GetBSTR( m_instCurrent.m_strHelpFiles.c_str(), pVal ));
  328. __HCP_END_PROPERTY(hr);
  329. }
  330. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_DatabaseDir( /*[out, retval]*/ BSTR *pVal )
  331. {
  332. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_DatabaseDir",hr,pVal);
  333. INTERNETSECURITY__CHECK_TRUST();
  334. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  335. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::GetBSTR( m_instCurrent.m_strDatabaseDir.c_str(), pVal ));
  336. __HCP_END_PROPERTY(hr);
  337. }
  338. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_DatabaseFile( /*[out, retval]*/ BSTR *pVal )
  339. {
  340. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_DatabaseFile",hr,pVal);
  341. __MPC_EXIT_IF_METHOD_FAILS(hr, GetInstanceValue( &m_instCurrent.m_strDatabaseFile, pVal ));
  342. __HCP_END_PROPERTY(hr);
  343. }
  344. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IndexFile( /*[in,optional]*/ VARIANT vScope, /*[out, retval]*/ BSTR *pVal )
  345. {
  346. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_IndexFile",hr,pVal);
  347. INTERNETSECURITY__CHECK_TRUST();
  348. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  349. if(vScope.vt == VT_BSTR)
  350. {
  351. CComPtr<IPCHUserSettings> us;
  352. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( us ));
  353. __MPC_EXIT_IF_METHOD_FAILS(hr, us->get_IndexFile( vScope, pVal ));
  354. }
  355. else
  356. {
  357. __MPC_EXIT_IF_METHOD_FAILS(hr, GetInstanceValue( &m_instCurrent.m_strIndexFile, pVal ));
  358. }
  359. __HCP_END_PROPERTY(hr);
  360. }
  361. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IndexDisplayName( /*[in,optional]*/ VARIANT vScope, /*[out, retval]*/ BSTR *pVal )
  362. {
  363. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_IndexDisplayName",hr,pVal);
  364. INTERNETSECURITY__CHECK_TRUST();
  365. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  366. if(vScope.vt == VT_BSTR)
  367. {
  368. CComPtr<IPCHUserSettings> us;
  369. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( us ));
  370. __MPC_EXIT_IF_METHOD_FAILS(hr, us->get_IndexDisplayName( vScope, pVal ));
  371. }
  372. else
  373. {
  374. __MPC_EXIT_IF_METHOD_FAILS(hr, GetInstanceValue( &m_instCurrent.m_strIndexDisplayName, pVal ));
  375. }
  376. __HCP_END_PROPERTY(hr);
  377. }
  378. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_LastUpdated( /*[out, retval]*/ DATE *pVal )
  379. {
  380. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_LastUpdated",hr,pVal);
  381. INTERNETSECURITY__CHECK_TRUST();
  382. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  383. *pVal = m_instCurrent.m_dLastUpdated;
  384. __HCP_END_PROPERTY(hr);
  385. }
  386. ////////////////////////////////////////
  387. HRESULT CPCHProxy_IPCHUserSettings2::PollNews()
  388. {
  389. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::PollNews" );
  390. HRESULT hr;
  391. MPC::SmartLock<_ThreadModel> lock( NULL );
  392. CComPtr<IPCHUserSettings> us;
  393. CComPtr<IUnknown> unk;
  394. VARIANT_BOOL fRes = VARIANT_FALSE;
  395. ::SetThreadPriority( ::GetCurrentThread(), THREAD_PRIORITY_LOWEST ); ::Sleep( 0 ); // Yield processor...
  396. __MPC_TRY_BEGIN();
  397. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( us ));
  398. lock = this;
  399. (void)us->get_AreHeadlinesEnabled( &fRes );
  400. if(fRes == VARIANT_TRUE)
  401. {
  402. m_News_fEnabled = true;
  403. lock = NULL;
  404. (void)us->get_News( &unk );
  405. lock = this;
  406. m_News_xmlData = unk;
  407. }
  408. hr = S_OK;
  409. __HCP_FUNC_CLEANUP;
  410. __MPC_TRY_CATCHALL(hr);
  411. m_News_fDone = true;
  412. Thread_Abort (); // To tell the MPC:Thread object to close the worker thread...
  413. Thread_Release(); // To tell the MPC:Thread object to clean up...
  414. __HCP_FUNC_EXIT(hr);
  415. }
  416. HRESULT CPCHProxy_IPCHUserSettings2::PrepareNews()
  417. {
  418. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::PrepareNews" );
  419. HRESULT hr;
  420. if(m_News_fDone == false)
  421. {
  422. if(Thread_IsRunning() == false)
  423. {
  424. __MPC_EXIT_IF_METHOD_FAILS(hr, Thread_Start( this, PollNews, NULL ));
  425. }
  426. }
  427. hr = S_OK;
  428. __HCP_FUNC_CLEANUP;
  429. __HCP_FUNC_EXIT(hr);
  430. }
  431. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_AreHeadlinesEnabled( /*[out, retval]*/ VARIANT_BOOL *pVal )
  432. {
  433. __HCP_BEGIN_PROPERTY_GET2("CPCHProxy_IPCHUserSettings2::get_AreHeadlinesEnabled",hr,pVal,VARIANT_FALSE);
  434. DWORD dwValue;
  435. bool fFound;
  436. INTERNETSECURITY__CHECK_TRUST();
  437. // Get the RegKey Value
  438. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::RegKey_Value_Read( dwValue, fFound, HC_REGISTRY_HELPSVC, L"Headlines" ));
  439. // If the Key was found and is disabled
  440. if(fFound && !dwValue)
  441. {
  442. m_News_fEnabled = false;
  443. }
  444. else
  445. {
  446. m_News_fEnabled = true;
  447. }
  448. // __MPC_EXIT_IF_METHOD_FAILS(hr, PrepareNews());
  449. //
  450. // if(m_News_fDone == false)
  451. // {
  452. // __MPC_SET_WIN32_ERROR_AND_EXIT(hr, ERROR_BUSY);
  453. // }
  454. if(m_News_fEnabled)
  455. {
  456. *pVal = VARIANT_TRUE;
  457. }
  458. __HCP_END_PROPERTY(hr);
  459. }
  460. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_News( /*[out, retval]*/ IUnknown* *pVal )
  461. {
  462. __HCP_BEGIN_PROPERTY_GET("CPCHProxy_IPCHUserSettings2::get_News",hr,pVal);
  463. INTERNETSECURITY__CHECK_TRUST();
  464. __MPC_EXIT_IF_METHOD_FAILS(hr, PrepareNews());
  465. if(m_News_fDone == false)
  466. {
  467. __MPC_SET_WIN32_ERROR_AND_EXIT(hr, ERROR_BUSY);
  468. }
  469. if(m_News_fEnabled)
  470. {
  471. CComPtr<IUnknown> unk = m_News_xmlData; m_News_xmlData.Release(); m_News_fDone = false;
  472. *pVal = unk.Detach();
  473. }
  474. __HCP_END_PROPERTY(hr);
  475. }
  476. ////////////////////////////////////////
  477. HRESULT CPCHProxy_IPCHUserSettings2::GetInstanceValue( /*[in]*/ const MPC::wstring* str, /*[out, retval]*/ BSTR *pVal )
  478. {
  479. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::GetInstanceValue" );
  480. HRESULT hr;
  481. INTERNETSECURITY__CHECK_TRUST();
  482. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  483. {
  484. MPC::wstring strTmp( *str ); MPC::SubstituteEnvVariables( strTmp );
  485. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::GetBSTR( strTmp.c_str(), pVal ));
  486. }
  487. hr = S_OK;
  488. __HCP_FUNC_CLEANUP;
  489. __HCP_FUNC_EXIT(hr);
  490. }
  491. STDMETHODIMP CPCHProxy_IPCHUserSettings2::Select( /*[in]*/ BSTR bstrSKU, /*[in]*/ long lLCID )
  492. {
  493. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::Select" );
  494. HRESULT hr;
  495. CComBSTR bstr;
  496. CComPtr<IPCHUserSettings> us;
  497. INTERNETSECURITY__CHECK_TRUST();
  498. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureDirectConnection( us ));
  499. __MPC_EXIT_IF_METHOD_FAILS(hr, us->Select( bstrSKU, lLCID ));
  500. (void)m_ths.Initialize( bstrSKU, lLCID );
  501. //
  502. // Refresh the cached info.
  503. //
  504. m_fReady = false;
  505. __MPC_EXIT_IF_METHOD_FAILS(hr, EnsureInSync());
  506. //
  507. // Get a new taxonomy database object.
  508. //
  509. {
  510. CComPtr<CPCHProxy_IPCHTaxonomyDatabase> db;
  511. CComPtr<IPCHTaxonomyDatabase> db2;
  512. __MPC_EXIT_IF_METHOD_FAILS(hr, m_parent->GetDatabase( &db ));
  513. __MPC_EXIT_IF_METHOD_FAILS(hr, db->EnsureDirectConnection( db2, true ));
  514. }
  515. //
  516. // Refresh the favorites.
  517. //
  518. __MPC_EXIT_IF_METHOD_FAILS(hr, CPCHFavorites::s_GLOBAL->Synchronize( true ));
  519. __MPC_EXIT_IF_METHOD_FAILS(hr, CPCHHelpCenterExternal::s_GLOBAL->Events().FireEvent_SwitchedHelpFiles());
  520. hr = S_OK;
  521. __HCP_FUNC_CLEANUP;
  522. __HCP_FUNC_EXIT(hr);
  523. }
  524. ////////////////////////////////////////////////////////////////////////////////
  525. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_Favorites( /*[out, retval]*/ IPCHFavorites* *pVal )
  526. {
  527. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::get_Favorites" );
  528. HRESULT hr;
  529. __MPC_PARAMCHECK_BEGIN(hr)
  530. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  531. __MPC_PARAMCHECK_END();
  532. INTERNETSECURITY__CHECK_TRUST();
  533. __MPC_EXIT_IF_METHOD_FAILS(hr, CPCHFavorites::s_GLOBAL->Synchronize( false ));
  534. __MPC_EXIT_IF_METHOD_FAILS(hr, CPCHFavorites::s_GLOBAL->QueryInterface( IID_IPCHFavorites, (void**)pVal ));
  535. hr = S_OK;
  536. __HCP_FUNC_CLEANUP;
  537. __HCP_FUNC_EXIT(hr);
  538. }
  539. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_Options( /*[out, retval]*/ IPCHOptions* *pVal )
  540. {
  541. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::get_Options" );
  542. HRESULT hr;
  543. __MPC_PARAMCHECK_BEGIN(hr)
  544. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  545. __MPC_PARAMCHECK_END();
  546. INTERNETSECURITY__CHECK_TRUST();
  547. if(!CPCHOptions::s_GLOBAL) __MPC_SET_ERROR_AND_EXIT(hr, E_ACCESSDENIED);
  548. __MPC_EXIT_IF_METHOD_FAILS(hr, CPCHOptions::s_GLOBAL->QueryInterface( IID_IPCHOptions, (void**)pVal ));
  549. hr = S_OK;
  550. __HCP_FUNC_CLEANUP;
  551. __HCP_FUNC_EXIT(hr);
  552. }
  553. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_Scope( /*[out, retval]*/ BSTR *pVal )
  554. {
  555. __HCP_FUNC_ENTRY( "CPCHProxy_IPCHUserSettings2::get_Scope" );
  556. HRESULT hr;
  557. __MPC_PARAMCHECK_BEGIN(hr)
  558. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  559. __MPC_PARAMCHECK_END();
  560. INTERNETSECURITY__CHECK_TRUST();
  561. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::GetBSTR( m_bstrScope, pVal ));
  562. hr = S_OK;
  563. __HCP_FUNC_CLEANUP;
  564. __HCP_FUNC_EXIT(hr);
  565. }
  566. HRESULT CPCHProxy_IPCHUserSettings2::put_Scope( /*[in]*/ BSTR newVal )
  567. {
  568. return MPC::PutBSTR( m_bstrScope, newVal );
  569. }
  570. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IsRemoteSession( /*[out, retval]*/ VARIANT_BOOL *pVal )
  571. {
  572. __HCP_BEGIN_PROPERTY_GET2__NOLOCK("CPCHProxy_IPCHUserSettings2::get_IsRemoteSession",hr,pVal,VARIANT_FALSE);
  573. if(::GetSystemMetrics( SM_REMOTESESSION ))
  574. {
  575. *pVal = VARIANT_TRUE;
  576. }
  577. __HCP_END_PROPERTY(hr);
  578. }
  579. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IsTerminalServer( /*[out, retval]*/ VARIANT_BOOL *pVal )
  580. {
  581. __HCP_BEGIN_PROPERTY_GET2__NOLOCK("CPCHProxy_IPCHUserSettings2::get_IsTerminalServer",hr,pVal,VARIANT_FALSE);
  582. OSVERSIONINFOEXW ex; ex.dwOSVersionInfoSize = sizeof(ex);
  583. if(::GetVersionExW( (LPOSVERSIONINFOW)&ex ) && (ex.wSuiteMask & VER_SUITE_TERMINAL))
  584. {
  585. *pVal = VARIANT_TRUE;
  586. }
  587. __HCP_END_PROPERTY(hr);
  588. }
  589. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IsDesktopVersion( /*[out, retval]*/ VARIANT_BOOL *pVal )
  590. {
  591. __HCP_BEGIN_PROPERTY_GET2("CPCHProxy_IPCHUserSettings2::get_IsDesktopVersion",hr,pVal,VARIANT_FALSE);
  592. if(IsDesktopSKU())
  593. {
  594. *pVal = VARIANT_TRUE;
  595. }
  596. __HCP_END_PROPERTY(hr);
  597. }
  598. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IsAdmin( /*[out, retval]*/ VARIANT_BOOL *pVal )
  599. {
  600. __HCP_BEGIN_PROPERTY_GET2("CPCHProxy_IPCHUserSettings2::get_IsAdmin",hr,pVal,VARIANT_FALSE);
  601. if(SUCCEEDED(MPC::CheckCallerAgainstPrincipal( /*fImpersonate*/false, NULL, MPC::IDENTITY_ADMIN | MPC::IDENTITY_ADMINS )))
  602. {
  603. *pVal = VARIANT_TRUE;
  604. }
  605. __HCP_END_PROPERTY(hr);
  606. }
  607. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IsPowerUser( /*[out, retval]*/ VARIANT_BOOL *pVal )
  608. {
  609. __HCP_BEGIN_PROPERTY_GET2("CPCHProxy_IPCHUserSettings2::get_IsPowerUser",hr,pVal,VARIANT_FALSE);
  610. if(SUCCEEDED(MPC::CheckCallerAgainstPrincipal( /*fImpersonate*/false, NULL, MPC::IDENTITY_ADMIN | MPC::IDENTITY_ADMINS | MPC::IDENTITY_POWERUSERS )))
  611. {
  612. *pVal = VARIANT_TRUE;
  613. }
  614. __HCP_END_PROPERTY(hr);
  615. }
  616. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IsStartPanelOn( /*[out, retval]*/ VARIANT_BOOL *pVal )
  617. {
  618. __HCP_BEGIN_PROPERTY_GET2("CPCHProxy_IPCHUserSettings2::get_IsStartPanelOn",hr,pVal,VARIANT_FALSE);
  619. // var shell = new ActiveXObject("Shell.Application");
  620. // var bOn = shell.GetSetting( SSF_STARTPANELON );
  621. CComPtr<IShellDispatch4> sd4;
  622. if(SUCCEEDED(sd4.CoCreateInstance( CLSID_Shell )))
  623. {
  624. (void)sd4->GetSetting( SSF_STARTPANELON, pVal );
  625. }
  626. __HCP_END_PROPERTY(hr);
  627. }
  628. STDMETHODIMP CPCHProxy_IPCHUserSettings2::get_IsWebViewBarricadeOn( /*[out, retval]*/ VARIANT_BOOL *pVal )
  629. {
  630. __HCP_BEGIN_PROPERTY_GET2("CPCHProxy_IPCHUserSettings2::get_IsWebViewBarricadeOn",hr,pVal,VARIANT_FALSE);
  631. // var shell = new ActiveXObject("Shell.Application");
  632. // var CSIDL_CONTROL = 3;
  633. // var control = shell.Namespace(CSIDL_CONTROL );
  634. // var bOn = control.ShowWebViewBarricade;
  635. CComPtr<IShellDispatch> sd;
  636. if(SUCCEEDED(sd.CoCreateInstance( CLSID_Shell )))
  637. {
  638. CComVariant v1( CSIDL_CONTROLS );
  639. CComPtr<Folder> fld;
  640. if(SUCCEEDED(sd->NameSpace( v1, &fld )))
  641. {
  642. CComQIPtr<Folder3> fld3 = fld;
  643. if(fld3)
  644. {
  645. (void)fld3->get_ShowWebViewBarricade( pVal );
  646. }
  647. }
  648. }
  649. __HCP_END_PROPERTY(hr);
  650. }