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.

1353 lines
45 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. HelpCenterExternal.cpp
  5. Abstract:
  6. This file contains the implementation of the class exposed as the "pchealth" object.
  7. Revision History:
  8. Ghim-Sim Chua (gschua) 07/23/99
  9. created
  10. Davide Massarenti (dmassare) 07/25/99
  11. modified
  12. ******************************************************************************/
  13. #include "stdafx.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. static const CComBSTR c_bstrPlace_Normal ( L"Normal" );
  16. static const CComBSTR c_bstrPlace_FullWindow ( L"FullWindow" );
  17. static const CComBSTR c_bstrPlace_ContentOnly ( L"ContentOnly" );
  18. static const CComBSTR c_bstrPlace_KioskMode ( L"KioskMode" );
  19. static const CComBSTR c_bstrSub_Channels ( L"hcp://system/panels/subpanels/Channels.htm" );
  20. static const CComBSTR c_bstrSub_Favorites ( L"hcp://system/panels/subpanels/Favorites.htm" );
  21. static const CComBSTR c_bstrSub_History ( L"hcp://system/panels/subpanels/History.htm" );
  22. static const CComBSTR c_bstrSub_Index ( L"hcp://system/panels/subpanels/Index.htm" );
  23. static const CComBSTR c_bstrSub_Options ( L"hcp://system/panels/subpanels/Options.htm" );
  24. static const CComBSTR c_bstrSub_Search ( L"hcp://system/panels/subpanels/Search.htm" );
  25. static const CComBSTR c_bstrSub_SubSite ( L"hcp://system/panels/subpanels/SubSite.htm" );
  26. static const CComBSTR c_bstrURL_Home ( L"hcp://system/HomePage.htm" );
  27. static const CComBSTR c_bstrURL_Channels ( L"hcp://system/blurbs/isupport.htm" );
  28. static const CComBSTR c_bstrURL_Options ( L"hcp://system/blurbs/options.htm" );
  29. static const CComBSTR c_bstrURL_Fav ( L"hcp://system/blurbs/favorites.htm");
  30. static const CComBSTR c_bstrURL_Search ( L"hcp://system/blurbs/searchblurb.htm");
  31. static const CComBSTR c_bstrURL_Index ( L"hcp://system/blurbs/index.htm" );
  32. static const CComBSTR c_bstrURL_History ( L"hcp://system/blurbs/history.htm" );
  33. static const CComBSTR c_bstrURL_Center_Update ( L"hcp://system/updatectr/updatecenter.htm" );
  34. static const CComBSTR c_bstrURL_Center_Compat ( L"hcp://system/compatctr/CompatOffline.htm" );
  35. static const CComBSTR c_bstrURL_Center_ErrMsg ( L"hcp://system/errmsg/errormessagesoffline.htm" );
  36. static const CComBSTR c_bstrTOC_Center_Tools ( L"_System_/Tools_Center" );
  37. static const CComBSTR c_bstrFunc_ChangeView ( L"onClick_ChangeView" );
  38. static const WCHAR c_szURL_Err_BadUrl [] = L"hcp://system/errors/badurl.htm";
  39. static const WCHAR c_szURL_Err_Redirect [] = L"hcp://system/errors/redirect.htm";
  40. static const WCHAR c_szURL_Err_NotFound [] = L"hcp://system/errors/notfound.htm";
  41. static const WCHAR c_szURL_Err_Offline [] = L"hcp://system/errors/offline.htm";
  42. static const WCHAR c_szURL_Err_Unreachable[] = L"hcp://system/errors/unreachable.htm";
  43. static const WCHAR c_szURL_BLANK [] = L"hcp://system/panels/blank.htm";
  44. ////////////////////////////////////////////////////////////////////////////////
  45. #define CTXFLG_EXPAND_CONDITIONAL (0x00000001)
  46. #define CTXFLG_EXPAND (0x00000002)
  47. #define CTXFLG_COLLAPSE (0x00000004)
  48. #define CTXFLG_URL_FROM_CONTEXT (0x00000008)
  49. #define CTXFLG_REGISTER_CONTEXT (0x00000010)
  50. #define CTXFLG_NOP (0x00000000)
  51. ///////
  52. #define CTXFLG_EXPAND_AND_REGISTER (CTXFLG_EXPAND | CTXFLG_REGISTER_CONTEXT)
  53. #define CTXFLG_EXPAND_AND_NAVIGATE (CTXFLG_EXPAND | CTXFLG_URL_FROM_CONTEXT)
  54. #define CTXFLG_COLLAPSE_AND_NAVIGATE (CTXFLG_COLLAPSE | CTXFLG_URL_FROM_CONTEXT)
  55. ///////
  56. #define CTXFLG_FULL (CTXFLG_EXPAND_CONDITIONAL | CTXFLG_REGISTER_CONTEXT | CTXFLG_URL_FROM_CONTEXT)
  57. struct ContextDef
  58. {
  59. HscContext iVal;
  60. BSTR bstrPlace;
  61. HelpHost::CompId idComp;
  62. BSTR bstrSubPanel;
  63. BSTR bstrURL;
  64. DWORD dwFlags;
  65. };
  66. static const ContextDef c_context[] =
  67. {
  68. { HSCCONTEXT_INVALID , NULL , HelpHost::COMPID_MAX , NULL , NULL , CTXFLG_NOP },
  69. { HSCCONTEXT_STARTUP , c_bstrPlace_FullWindow , HelpHost::COMPID_MAX , NULL , NULL , CTXFLG_EXPAND_AND_REGISTER },
  70. { HSCCONTEXT_HOMEPAGE , c_bstrPlace_FullWindow , HelpHost::COMPID_HOMEPAGE , NULL , c_bstrURL_Home , CTXFLG_EXPAND_AND_REGISTER },
  71. { HSCCONTEXT_CONTENT , NULL , HelpHost::COMPID_MAX , NULL , NULL , CTXFLG_URL_FROM_CONTEXT },
  72. { HSCCONTEXT_SUBSITE , c_bstrPlace_Normal , HelpHost::COMPID_SUBSITE , c_bstrSub_SubSite , NULL , CTXFLG_FULL },
  73. { HSCCONTEXT_SEARCH , c_bstrPlace_Normal , HelpHost::COMPID_SEARCH , c_bstrSub_Search , c_bstrURL_Search , CTXFLG_FULL },
  74. { HSCCONTEXT_INDEX , c_bstrPlace_Normal , HelpHost::COMPID_INDEX , c_bstrSub_Index , c_bstrURL_Index , CTXFLG_FULL },
  75. { HSCCONTEXT_FAVORITES , c_bstrPlace_Normal , HelpHost::COMPID_FAVORITES, c_bstrSub_Favorites, c_bstrURL_Fav , CTXFLG_FULL },
  76. { HSCCONTEXT_HISTORY , c_bstrPlace_Normal , HelpHost::COMPID_HISTORY , c_bstrSub_History , c_bstrURL_History , CTXFLG_FULL },
  77. { HSCCONTEXT_CHANNELS , c_bstrPlace_Normal , HelpHost::COMPID_CHANNELS , c_bstrSub_Channels , c_bstrURL_Channels, CTXFLG_FULL },
  78. { HSCCONTEXT_OPTIONS , c_bstrPlace_Normal , HelpHost::COMPID_OPTIONS , c_bstrSub_Options , c_bstrURL_Options , CTXFLG_FULL },
  79. { HSCCONTEXT_CONTENTONLY, c_bstrPlace_ContentOnly, HelpHost::COMPID_MAX , NULL , NULL , CTXFLG_COLLAPSE_AND_NAVIGATE },
  80. { HSCCONTEXT_FULLWINDOW , c_bstrPlace_FullWindow , HelpHost::COMPID_MAX , NULL , NULL , CTXFLG_EXPAND_AND_NAVIGATE },
  81. { HSCCONTEXT_KIOSKMODE , c_bstrPlace_KioskMode , HelpHost::COMPID_MAX , NULL , NULL , CTXFLG_EXPAND_AND_NAVIGATE },
  82. };
  83. ////////////////////////////////////////////////////////////////////////////////
  84. BSTR local_SecureURL(BSTR bstrUrl)
  85. {
  86. HyperLinks::ParsedUrl pu;
  87. pu.Initialize(bstrUrl);
  88. switch (pu.m_fmt)
  89. {
  90. case HyperLinks::FMT_INTERNET_UNKNOWN :
  91. case HyperLinks::FMT_INTERNET_JAVASCRIPT:
  92. case HyperLinks::FMT_INTERNET_VBSCRIPT :
  93. // Block potentially dangerous urls
  94. bstrUrl = (BSTR)c_szURL_Err_BadUrl;
  95. break;
  96. default:
  97. break;
  98. }
  99. return bstrUrl;
  100. }
  101. bool CPCHHelpCenterExternal::ProcessNavigation( /*[in]*/ HscPanel idPanel ,
  102. /*[in]*/ BSTR bstrURL ,
  103. /*[in]*/ BSTR bstrFrame ,
  104. /*[in]*/ bool fLoading ,
  105. /*[in/out]*/ VARIANT_BOOL& Cancel )
  106. {
  107. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::ProcessNavigation" );
  108. HRESULT hr;
  109. HyperLinks::ParsedUrl pu;
  110. bool fProceed = true;
  111. bool fShowNormal = false;
  112. bool fShowHTMLHELP = false;
  113. if(m_fPassivated || m_fShuttingDown)
  114. {
  115. Cancel = VARIANT_TRUE;
  116. fProceed = false;
  117. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  118. }
  119. m_dwInBeforeNavigate++;
  120. if(!MPC::StrICmp( bstrURL, L"about:blank" ))
  121. {
  122. fProceed = false;
  123. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Ignore Navigation.
  124. }
  125. //
  126. // This is the default redirection from the CONTEXT panel to the CONTENTS panel.
  127. //
  128. if(idPanel == HSCPANEL_CONTEXT)
  129. {
  130. if(!MPC::StrICmp( bstrFrame, L"HelpCtrContents" ))
  131. {
  132. __MPC_EXIT_IF_METHOD_FAILS(hr, SetPanelUrl( HSCPANEL_CONTENTS, bstrURL ));
  133. Cancel = VARIANT_TRUE;
  134. fProceed = false;
  135. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  136. }
  137. }
  138. ////////////////////////////////////////////////////////////////////////////////
  139. //
  140. // Check the url and make a copy of its state.
  141. //
  142. if(m_hs->IsTravelling() == false)
  143. {
  144. HyperLinks::UrlHandle uh;
  145. __MPC_EXIT_IF_METHOD_FAILS(hr, HyperLinks::Lookup::s_GLOBAL->Get( bstrURL, uh, /*dwWaitForCheck*/100 ));
  146. if((HyperLinks::ParsedUrl*)uh) pu = *(HyperLinks::ParsedUrl*)uh;
  147. }
  148. else
  149. {
  150. __MPC_EXIT_IF_METHOD_FAILS(hr, pu.Initialize( bstrURL ));
  151. }
  152. // If hcp redirect, take the redirected URL
  153. if (pu.m_hcpRedir) bstrURL = (BSTR)(pu.m_strURL.c_str());
  154. if(pu.m_fmt == HyperLinks::FMT_INTERNET_JAVASCRIPT ||
  155. pu.m_fmt == HyperLinks::FMT_INTERNET_VBSCRIPT )
  156. {
  157. fProceed = false;
  158. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Ignore Navigation.
  159. }
  160. ////////////////////////////////////////////////////////////////////////////////
  161. //
  162. // Check for navigation/url problems.
  163. //
  164. {
  165. MPC::wstring strErrorURL;
  166. bool fError = false;
  167. if(pu.m_fmt == HyperLinks::FMT_INVALID ||
  168. pu.m_state == HyperLinks::STATE_INVALID ||
  169. pu.m_state == HyperLinks::STATE_MALFORMED )
  170. {
  171. MPC::HTML::vBuildHREF( strErrorURL, c_szURL_Err_BadUrl, L"URL", bstrURL, NULL );
  172. fError = true;
  173. }
  174. else if(pu.m_fmt == HyperLinks::FMT_RESOURCE)
  175. {
  176. //
  177. // WebBrowser error redirection.
  178. //
  179. // res://C:\WINNT\System32\shdoclc.dll/dnserror.htm#file://C:\file\test.htm
  180. //
  181. MPC::wstring strURL;
  182. CComBSTR bstrURLOriginal;
  183. CComBSTR bstrTitle;
  184. CPCHHelpSessionItem* hchsi = m_hs->Current();
  185. if(hchsi)
  186. {
  187. bstrURLOriginal = hchsi->GetURL();
  188. (void)m_hs->LookupTitle( bstrURLOriginal, bstrTitle, /*fUseIECache*/false );
  189. }
  190. MPC::HTML::vBuildHREF( strErrorURL, c_szURL_Err_Redirect, L"URL" , bstrURL ,
  191. L"FRAME" , bstrFrame ,
  192. L"REALURL", bstrURLOriginal,
  193. L"TITLE" , bstrTitle , NULL );
  194. fError = true;
  195. }
  196. else if(pu.m_state == HyperLinks::STATE_NOTFOUND)
  197. {
  198. CComBSTR bstrTitle; (void)m_hs->LookupTitle( bstrURL, bstrTitle, /*fUseIECache*/false );
  199. MPC::HTML::vBuildHREF( strErrorURL, c_szURL_Err_NotFound, L"URL" , bstrURL ,
  200. L"TITLE", bstrTitle, NULL );
  201. fError = true;
  202. }
  203. else if(pu.m_state == HyperLinks::STATE_UNREACHABLE)
  204. {
  205. CComBSTR bstrTitle; (void)m_hs->LookupTitle( bstrURL, bstrTitle, /*fUseIECache*/false );
  206. MPC::HTML::vBuildHREF( strErrorURL, c_szURL_Err_Unreachable, L"URL" , bstrURL ,
  207. L"TITLE", bstrTitle, NULL );
  208. fError = true;
  209. }
  210. else if(pu.m_state == HyperLinks::STATE_OFFLINE)
  211. {
  212. CComBSTR bstrTitle; (void)m_hs->LookupTitle( bstrURL, bstrTitle, /*fUseIECache*/false );
  213. MPC::HTML::vBuildHREF( strErrorURL, c_szURL_Err_Offline, L"URL" , bstrURL ,
  214. L"TITLE", bstrTitle, NULL );
  215. fError = true;
  216. }
  217. if(fError)
  218. {
  219. __MPC_EXIT_IF_METHOD_FAILS(hr, SetPanelUrl( HSCPANEL_CONTENTS, strErrorURL.c_str() ));
  220. fProceed = false;
  221. Cancel = VARIANT_TRUE;
  222. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  223. }
  224. }
  225. ////////////////////////////////////////////////////////////////////////////////
  226. if(pu.m_fmt == HyperLinks::FMT_MSITS)
  227. {
  228. //
  229. // Not in the right context, redirect to the HH wrapper.
  230. //
  231. if(idPanel != HSCPANEL_HHWINDOW)
  232. {
  233. if(!m_panel_HHWINDOW_Wrapper)
  234. {
  235. //
  236. // Force loading of the HHWindow.
  237. //
  238. CComPtr<IMarsPanel> panel;
  239. __MPC_EXIT_IF_METHOD_FAILS(hr, GetPanel( HSCPANEL_HHWINDOW, &panel, true ));
  240. }
  241. __MPC_EXIT_IF_METHOD_FAILS(hr, NavigateHH( pu.m_strURL.c_str() ));
  242. fProceed = false;
  243. fShowHTMLHELP = true;
  244. Cancel = VARIANT_TRUE;
  245. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  246. }
  247. }
  248. ////////////////////////////////////////////////////////////////////////////////
  249. if(pu.m_hcpRedir)
  250. {
  251. //
  252. // Navigate to the redirected URL.
  253. //
  254. __MPC_EXIT_IF_METHOD_FAILS(hr, SetPanelUrl( idPanel, local_SecureURL((BSTR)(pu.m_strURL.c_str())) ));
  255. fProceed = false;
  256. Cancel = VARIANT_TRUE;
  257. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  258. }
  259. ////////////////////////////////////////////////////////////////////////////////
  260. switch(pu.m_fmt)
  261. {
  262. case HyperLinks::FMT_CENTER_HOMEPAGE :
  263. case HyperLinks::FMT_CENTER_SUPPORT :
  264. case HyperLinks::FMT_CENTER_OPTIONS :
  265. case HyperLinks::FMT_CENTER_UPDATE :
  266. case HyperLinks::FMT_CENTER_COMPAT :
  267. case HyperLinks::FMT_CENTER_TOOLS :
  268. case HyperLinks::FMT_CENTER_ERRMSG :
  269. case HyperLinks::FMT_SEARCH :
  270. case HyperLinks::FMT_INDEX :
  271. case HyperLinks::FMT_SUBSITE :
  272. case HyperLinks::FMT_LAYOUT_FULLWINDOW :
  273. case HyperLinks::FMT_LAYOUT_CONTENTONLY:
  274. case HyperLinks::FMT_LAYOUT_KIOSK :
  275. case HyperLinks::FMT_LAYOUT_XML :
  276. case HyperLinks::FMT_REDIRECT :
  277. case HyperLinks::FMT_APPLICATION :
  278. m_hs->CancelNavigation();
  279. break;
  280. }
  281. if(pu.m_fmt == HyperLinks::FMT_CENTER_HOMEPAGE)
  282. {
  283. if(SUCCEEDED(ChangeContext( HSCCONTEXT_HOMEPAGE )))
  284. {
  285. }
  286. fProceed = false;
  287. Cancel = VARIANT_TRUE;
  288. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  289. }
  290. if(pu.m_fmt == HyperLinks::FMT_CENTER_SUPPORT)
  291. {
  292. CComBSTR bstrCtx_URL ; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  293. if(SUCCEEDED(ChangeContext( HSCCONTEXT_CHANNELS, NULL, local_SecureURL(bstrCtx_URL) )))
  294. {
  295. }
  296. fProceed = false;
  297. Cancel = VARIANT_TRUE;
  298. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  299. }
  300. if(pu.m_fmt == HyperLinks::FMT_CENTER_OPTIONS)
  301. {
  302. CComBSTR bstrCtx_URL ; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  303. if(SUCCEEDED(ChangeContext( HSCCONTEXT_OPTIONS, NULL, local_SecureURL(bstrCtx_URL) )))
  304. {
  305. }
  306. fProceed = false;
  307. Cancel = VARIANT_TRUE;
  308. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  309. }
  310. if(pu.m_fmt == HyperLinks::FMT_CENTER_UPDATE)
  311. {
  312. if(SUCCEEDED(ChangeContext( HSCCONTEXT_FULLWINDOW, NULL, c_bstrURL_Center_Update )))
  313. {
  314. }
  315. fProceed = false;
  316. Cancel = VARIANT_TRUE;
  317. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  318. }
  319. if(pu.m_fmt == HyperLinks::FMT_CENTER_COMPAT)
  320. {
  321. if(SUCCEEDED(ChangeContext( HSCCONTEXT_FULLWINDOW, NULL, c_bstrURL_Center_Compat )))
  322. {
  323. }
  324. fProceed = false;
  325. Cancel = VARIANT_TRUE;
  326. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  327. }
  328. if(pu.m_fmt == HyperLinks::FMT_CENTER_TOOLS)
  329. {
  330. CComBSTR bstrCtx_URL ; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  331. if(SUCCEEDED(ChangeContext( HSCCONTEXT_SUBSITE, c_bstrTOC_Center_Tools, local_SecureURL(bstrCtx_URL) )))
  332. {
  333. }
  334. fProceed = false;
  335. Cancel = VARIANT_TRUE;
  336. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  337. }
  338. if(pu.m_fmt == HyperLinks::FMT_CENTER_ERRMSG)
  339. {
  340. if(SUCCEEDED(ChangeContext( HSCCONTEXT_FULLWINDOW, NULL, c_bstrURL_Center_ErrMsg )))
  341. {
  342. }
  343. fProceed = false;
  344. Cancel = VARIANT_TRUE;
  345. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  346. }
  347. ////////////////////////////////////////////////////////////////////////////////
  348. if(pu.m_fmt == HyperLinks::FMT_SEARCH)
  349. {
  350. CComBSTR bstrCtx_Info; (void)pu.GetQueryField( L"query", bstrCtx_Info );
  351. CComBSTR bstrCtx_URL ; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  352. if(SUCCEEDED(ChangeContext( HSCCONTEXT_SEARCH, bstrCtx_Info, local_SecureURL(bstrCtx_URL) )))
  353. {
  354. }
  355. fProceed = false;
  356. Cancel = VARIANT_TRUE;
  357. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  358. }
  359. if(pu.m_fmt == HyperLinks::FMT_INDEX)
  360. {
  361. CComBSTR bstrCtx_Info; (void)pu.GetQueryField( L"scope", bstrCtx_Info );
  362. CComBSTR bstrCtx_URL ; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  363. if(SUCCEEDED(ChangeContext( HSCCONTEXT_INDEX, bstrCtx_Info, local_SecureURL(bstrCtx_URL) )))
  364. {
  365. }
  366. fProceed = false;
  367. Cancel = VARIANT_TRUE;
  368. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  369. }
  370. if(pu.m_fmt == HyperLinks::FMT_SUBSITE)
  371. {
  372. CComBSTR bstrCtx_Info ; (void)pu.GetQueryField( L"node" , bstrCtx_Info );
  373. CComBSTR bstrCtx_URL ; (void)pu.GetQueryField( L"topic" , bstrCtx_URL );
  374. CComBSTR bstrCtx_Extra; (void)pu.GetQueryField( L"select", bstrCtx_Extra );
  375. if(bstrCtx_Extra)
  376. {
  377. bstrCtx_Info += L" ";
  378. bstrCtx_Info += bstrCtx_Extra;
  379. }
  380. if(SUCCEEDED(ChangeContext( HSCCONTEXT_SUBSITE, bstrCtx_Info, local_SecureURL(bstrCtx_URL) )))
  381. {
  382. }
  383. fProceed = false;
  384. Cancel = VARIANT_TRUE;
  385. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  386. }
  387. ////////////////////////////////////////////////////////////////////////////////
  388. if(pu.m_fmt == HyperLinks::FMT_LAYOUT_FULLWINDOW)
  389. {
  390. CComBSTR bstrCtx_URL; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  391. if(SUCCEEDED(ChangeContext( HSCCONTEXT_FULLWINDOW, NULL, local_SecureURL(bstrCtx_URL) )))
  392. {
  393. }
  394. fProceed = false;
  395. Cancel = VARIANT_TRUE;
  396. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  397. }
  398. if(pu.m_fmt == HyperLinks::FMT_LAYOUT_CONTENTONLY)
  399. {
  400. CComBSTR bstrCtx_URL; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  401. if(SUCCEEDED(ChangeContext( HSCCONTEXT_CONTENTONLY, NULL, local_SecureURL(bstrCtx_URL) )))
  402. {
  403. }
  404. fProceed = false;
  405. Cancel = VARIANT_TRUE;
  406. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  407. }
  408. if(pu.m_fmt == HyperLinks::FMT_LAYOUT_KIOSK)
  409. {
  410. CComBSTR bstrCtx_URL; (void)pu.GetQueryField( L"topic", bstrCtx_URL );
  411. if(SUCCEEDED(ChangeContext( HSCCONTEXT_KIOSKMODE, NULL, local_SecureURL(bstrCtx_URL) )))
  412. {
  413. }
  414. fProceed = false;
  415. Cancel = VARIANT_TRUE;
  416. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  417. }
  418. if(pu.m_fmt == HyperLinks::FMT_LAYOUT_XML)
  419. {
  420. // Not valid after startup....
  421. fProceed = false;
  422. Cancel = VARIANT_TRUE;
  423. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  424. }
  425. ////////////////////////////////////////////////////////////////////////////////
  426. if(pu.m_fmt == HyperLinks::FMT_REDIRECT)
  427. {
  428. CComBSTR bstrCtx_URL; (void)pu.GetQueryField( L"online", bstrCtx_URL );
  429. {
  430. HyperLinks::UrlHandle uh;
  431. __MPC_EXIT_IF_METHOD_FAILS(hr, HyperLinks::Lookup::s_GLOBAL->Get( bstrCtx_URL, uh, /*dwWaitForCheck*/HC_TIMEOUT_DESTINATIONREACHABLE ));
  432. //
  433. // If there's a problem with the online URL, let's use the offline one.
  434. //
  435. if(uh->IsOkToProceed() == false)
  436. {
  437. (void)pu.GetQueryField( L"offline", bstrCtx_URL );
  438. }
  439. }
  440. __MPC_EXIT_IF_METHOD_FAILS(hr, SetPanelUrl( HSCPANEL_CONTENTS, local_SecureURL(bstrCtx_URL) ));
  441. fProceed = false;
  442. Cancel = VARIANT_TRUE;
  443. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  444. }
  445. if(pu.m_fmt == HyperLinks::FMT_APPLICATION)
  446. {
  447. fProceed = false;
  448. Cancel = VARIANT_TRUE;
  449. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  450. }
  451. ////////////////////////////////////////////////////////////////////////////////
  452. if(fLoading == false)
  453. {
  454. if(SUCCEEDED(m_Events.FireEvent_BeforeNavigate( bstrURL, bstrFrame, idPanel, &Cancel )))
  455. {
  456. if(Cancel == VARIANT_TRUE)
  457. {
  458. fProceed = false;
  459. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  460. }
  461. }
  462. }
  463. ////////////////////////////////////////////////////////////////////////////////
  464. hr = S_OK;
  465. __HCP_FUNC_CLEANUP;
  466. if(!fShowNormal && !fShowHTMLHELP && Cancel != VARIANT_TRUE)
  467. {
  468. //
  469. // No context selected, pick one based on the panel.
  470. //
  471. if(idPanel == HSCPANEL_HHWINDOW)
  472. {
  473. fShowHTMLHELP = true;
  474. }
  475. else if(idPanel == HSCPANEL_CONTENTS)
  476. {
  477. fShowNormal = true;
  478. }
  479. }
  480. (void)SetCorrectContentPanel( fShowNormal, fShowHTMLHELP, /*fNow*/false );
  481. //
  482. // Workaround for interception VK_BACK navigations.
  483. //
  484. if(fProceed == true)
  485. {
  486. if(m_hs->IsPossibleBack())
  487. {
  488. fProceed = false;
  489. Cancel = VARIANT_TRUE;
  490. (void)m_hs->Back( 1 );
  491. }
  492. }
  493. m_dwInBeforeNavigate--;
  494. __HCP_FUNC_EXIT(fProceed);
  495. }
  496. ////////////////////////////////////////////////////////////////////////////////
  497. ////HRESULT CPCHHelpCenterExternal::ExecCommand_Window( /*[in]*/ HCAPI::CmdData& cd )
  498. ////{
  499. //// __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::ExecCommand_Window" );
  500. ////
  501. //// HRESULT hr;
  502. ////
  503. ////
  504. //// if(m_hwnd)
  505. //// {
  506. //// if(cd.m_fSize)
  507. //// {
  508. //// if(cd.m_lWidth < 200) cd.m_lWidth = 200;
  509. //// if(cd.m_lHeight < 300) cd.m_lHeight = 300;
  510. ////
  511. //// __MPC_EXIT_IF_CALL_RETURNS_FALSE(hr, ::SetWindowPos( m_hwnd ,
  512. //// NULL ,
  513. //// cd.m_lX ,
  514. //// cd.m_lY ,
  515. //// cd.m_lWidth ,
  516. //// cd.m_lHeight ,
  517. //// SWP_NOZORDER ));
  518. //// }
  519. ////
  520. //// if(cd.m_fWindow)
  521. //// {
  522. //// if(cd.m_hwndParent)
  523. //// {
  524. //// __MPC_EXIT_IF_CALL_RETURNS_FALSE(hr, ::SetWindowPos( m_hwnd ,
  525. //// cd.m_hwndParent ,
  526. //// 0 ,
  527. //// 0 ,
  528. //// 0 ,
  529. //// 0 ,
  530. //// SWP_NOMOVE | SWP_NOSIZE ));
  531. //// }
  532. //// }
  533. ////
  534. //// if(cd.m_fMode)
  535. //// {
  536. //// if(cd.m_dwFlags & HCAPI_MODE_ALWAYSONTOP)
  537. //// {
  538. //// __MPC_EXIT_IF_CALL_RETURNS_FALSE(hr, ::SetWindowPos( m_hwnd ,
  539. //// HWND_TOPMOST ,
  540. //// 0 ,
  541. //// 0 ,
  542. //// 0 ,
  543. //// 0 ,
  544. //// SWP_NOMOVE | SWP_NOSIZE ));
  545. //// }
  546. //// }
  547. //// }
  548. ////
  549. //// hr = S_OK;
  550. ////
  551. ////
  552. //// __HCP_FUNC_CLEANUP;
  553. ////
  554. //// __HCP_FUNC_EXIT(hr);
  555. ////}
  556. ////////////////////////////////////////////////////////////////////////////////
  557. HRESULT CPCHHelpCenterExternal::RequestShutdown()
  558. {
  559. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::RequestShutdown" );
  560. HRESULT hr;
  561. VARIANT_BOOL Cancel;
  562. CPCHHelpSessionItem* hchsi;
  563. if(m_fHidden == false)
  564. {
  565. if(SUCCEEDED(m_Events.FireEvent_Shutdown( &Cancel )))
  566. {
  567. if(Cancel == VARIANT_TRUE)
  568. {
  569. __MPC_SET_ERROR_AND_EXIT(hr, E_ACCESSDENIED); // Cancel close...
  570. }
  571. }
  572. if(m_hs) (void)m_hs->ForceHistoryPopulate();
  573. }
  574. hr = S_OK;
  575. __HCP_FUNC_CLEANUP;
  576. __HCP_FUNC_EXIT(hr);
  577. }
  578. ////////////////////////////////////////////////////////////////////////////////
  579. static void local_HideDocument( /*[in]*/ IWebBrowser2* wb )
  580. {
  581. CComPtr<IDispatch> disp;
  582. CComPtr<IHTMLDocument3> doc;
  583. if(SUCCEEDED(wb->get_Document( &disp )) && disp)
  584. {
  585. if(SUCCEEDED(disp.QueryInterface( &doc )))
  586. {
  587. CComPtr<IHTMLElement> body;
  588. if(SUCCEEDED(doc->get_documentElement( &body )) && body)
  589. {
  590. MPC::HTML::IHTMLElementList lst;
  591. MPC::HTML::IHTMLElementIter it;
  592. if(SUCCEEDED(MPC::HTML::EnumerateElements( lst, body )))
  593. {
  594. for(it = lst.begin(); it != lst.end(); it++)
  595. {
  596. CComPtr<IHTMLStyle> style;
  597. if(SUCCEEDED((*it)->get_style( &style )) && style)
  598. {
  599. (void)style->put_display( CComBSTR( L"NONE" ) );
  600. }
  601. }
  602. }
  603. MPC::ReleaseAll( lst );
  604. }
  605. }
  606. }
  607. }
  608. HRESULT CPCHHelpCenterExternal::ChangeContext( /*[in]*/ HscContext iVal ,
  609. /*[in]*/ BSTR bstrInfo ,
  610. /*[in]*/ BSTR bstrURL ,
  611. /*[in]*/ bool fAlsoContent )
  612. {
  613. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::ChangeContext" );
  614. HRESULT hr;
  615. const ContextDef* ptr;
  616. CComBSTR bstrPage;
  617. bool fFromHomePage = false;
  618. bool fToHomePage = false;
  619. //
  620. // If we are minimized, undo it and bring the window to the foreground.
  621. //
  622. if(iVal == HSCCONTEXT_CONTENT && m_hwnd && ::IsIconic( m_hwnd ) && m_shell)
  623. {
  624. (void)m_shell->put_minimized( VARIANT_FALSE );
  625. ::SetForegroundWindow( m_hwnd );
  626. }
  627. if(iVal == HSCCONTEXT_CONTENT)
  628. {
  629. VARIANT_BOOL Cancel = VARIANT_FALSE;
  630. if(ProcessNavigation( HSCPANEL_CONTENTS ,
  631. bstrURL ,
  632. NULL ,
  633. false ,
  634. Cancel ) == false)
  635. {
  636. __MPC_SET_ERROR_AND_EXIT(hr, S_OK);
  637. }
  638. }
  639. //
  640. // Delayed execution if inside OnBeforeNavigate.
  641. //
  642. if(m_dwInBeforeNavigate)
  643. {
  644. DelayedExecution& de = DelayedExecutionAlloc();
  645. de.mode = DELAYMODE_CHANGECONTEXT;
  646. de.iVal = iVal;
  647. de.bstrInfo = bstrInfo;
  648. de.bstrURL = bstrURL;
  649. de.fAlsoContent = fAlsoContent;
  650. __MPC_SET_ERROR_AND_EXIT(hr, DelayedExecutionStart());
  651. }
  652. ////////////////////////////////////////////////////////////////////////////////
  653. if(iVal == HSCCONTEXT_STARTUP)
  654. {
  655. if(STRINGISPRESENT(m_bstrStartURL))
  656. {
  657. bstrPage.Attach( m_bstrStartURL.Detach() );
  658. }
  659. else
  660. {
  661. iVal = HSCCONTEXT_HOMEPAGE;
  662. }
  663. }
  664. else if(STRINGISPRESENT(m_bstrCurrentPlace))
  665. {
  666. if(STRINGISPRESENT(m_bstrStartURL))
  667. {
  668. bstrPage.Attach( m_bstrStartURL.Detach() );
  669. fAlsoContent = true;
  670. }
  671. }
  672. if(m_hs)
  673. {
  674. CPCHHelpSessionItem* item = m_hs->Current();
  675. if(item && item->GetContextID() == HSCCONTEXT_HOMEPAGE)
  676. {
  677. fFromHomePage = true;
  678. }
  679. }
  680. if(iVal == HSCCONTEXT_HOMEPAGE)
  681. {
  682. fToHomePage = true;
  683. }
  684. ////////////////////////////////////////////////////////////////////////////////
  685. {
  686. VARIANT_BOOL Cancel;
  687. if(SUCCEEDED(m_Events.FireEvent_BeforeContextSwitch( iVal, bstrInfo, bstrURL, &Cancel )))
  688. {
  689. if(Cancel == VARIANT_TRUE)
  690. {
  691. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Navigation aborted.
  692. }
  693. }
  694. }
  695. ptr = c_context;
  696. for(int i=0; i<ARRAYSIZE(c_context); i++, ptr++)
  697. {
  698. if(ptr->iVal == iVal)
  699. {
  700. DWORD dwFlags = ptr->dwFlags;
  701. BSTR bstrPlace = ptr->bstrPlace;
  702. //
  703. // Always register the context if we don't have a place (it means we are starting up).
  704. //
  705. if(!STRINGISPRESENT(m_bstrCurrentPlace))
  706. {
  707. dwFlags |= CTXFLG_REGISTER_CONTEXT;
  708. }
  709. //
  710. // If we are not displayed (m_bstrCurrentPlace not set), force a transition to a default place.
  711. //
  712. if(!STRINGISPRESENT(bstrPlace) && !STRINGISPRESENT(m_bstrCurrentPlace))
  713. {
  714. bstrPlace = c_bstrPlace_FullWindow;
  715. }
  716. if(ptr->bstrURL)
  717. {
  718. bstrPage = ptr->bstrURL;
  719. }
  720. if((dwFlags & CTXFLG_URL_FROM_CONTEXT) && STRINGISPRESENT(bstrURL))
  721. {
  722. bstrPage = bstrURL;
  723. }
  724. //
  725. // When we go to KIOSKMODE, disable window size management.
  726. //
  727. if(iVal == HSCCONTEXT_KIOSKMODE)
  728. {
  729. m_pMTP->dwFlags &= ~MTF_MANAGE_WINDOW_SIZE;
  730. }
  731. if(iVal == HSCCONTEXT_SUBSITE && !STRINGISPRESENT(bstrPage))
  732. {
  733. CComPtr<CPCHProxy_IPCHTaxonomyDatabase> db;
  734. CComBSTR bstrNode;
  735. CComBSTR bstrNodeSelect;
  736. CComBSTR bstrNodeURL;
  737. BSTR bstrToLookup = NULL;
  738. long lNavModel;
  739. long lCount;
  740. //
  741. // For subsite, we pass both the root node, the node to select and the URL of the topic, separated by spaces.
  742. //
  743. {
  744. LPWSTR szEnd;
  745. bstrNode = bstrInfo;
  746. if(STRINGISPRESENT(bstrNode))
  747. {
  748. bstrToLookup = bstrNode;
  749. szEnd = wcschr( bstrNode, ' ' );
  750. if(szEnd)
  751. {
  752. *szEnd++ = 0;
  753. bstrNodeSelect = szEnd;
  754. if(STRINGISPRESENT(bstrNodeSelect))
  755. {
  756. bstrToLookup = bstrNodeSelect;
  757. szEnd = wcschr( bstrNodeSelect, ' ' );
  758. if(szEnd)
  759. {
  760. *szEnd++ = 0;
  761. bstrNodeURL = szEnd;
  762. }
  763. }
  764. }
  765. }
  766. }
  767. if(!m_Utility) __MPC_SET_ERROR_AND_EXIT(hr, E_ACCESSDENIED);
  768. __MPC_EXIT_IF_METHOD_FAILS(hr, m_Utility->GetDatabase( &db ));
  769. {
  770. CComPtr<CPCHQueryResult> qrNode;
  771. {
  772. CComPtr<CPCHQueryResultCollection> pColl;
  773. __MPC_EXIT_IF_METHOD_FAILS(hr, db->ExecuteQuery( OfflineCache::ET_NODE, bstrToLookup, &pColl ));
  774. __MPC_EXIT_IF_METHOD_FAILS(hr, pColl->GetItem( 0, &qrNode ));
  775. lNavModel = qrNode->GetData().m_lNavModel;
  776. }
  777. if(lNavModel == QR_DEFAULT)
  778. {
  779. if(UserSettings()->IsDesktopSKU())
  780. {
  781. CComPtr<CPCHQueryResultCollection> pColl;
  782. __MPC_EXIT_IF_METHOD_FAILS(hr, db->ExecuteQuery( OfflineCache::ET_TOPICS_VISIBLE, bstrToLookup, &pColl ));
  783. lCount = pColl->Size();
  784. lNavModel = QR_DESKTOP;
  785. }
  786. else
  787. {
  788. lCount = 0;
  789. lNavModel = QR_SERVER;
  790. }
  791. }
  792. if(lNavModel == QR_DESKTOP && lCount)
  793. {
  794. MPC::wstring strURL;
  795. MPC::HTML::vBuildHREF( strURL, L"hcp://system/panels/Topics.htm", L"path", bstrToLookup, NULL );
  796. bstrPage = strURL.c_str();
  797. }
  798. else
  799. {
  800. bstrPage = qrNode->GetData().m_bstrTopicURL;
  801. }
  802. if(!STRINGISPRESENT(bstrPage)) bstrPage = c_szURL_BLANK;
  803. }
  804. }
  805. ////////////////////////////////////////////////////////////////////////////////
  806. if(dwFlags & CTXFLG_EXPAND_CONDITIONAL)
  807. {
  808. CComPtr<IMarsPanel> panel;
  809. VARIANT_BOOL fContentsVisible = VARIANT_FALSE;
  810. GetPanelDirect( HSCPANEL_NAVBAR, panel );
  811. if(panel)
  812. {
  813. (void)panel->get_visible( &fContentsVisible );
  814. }
  815. if(fContentsVisible == VARIANT_TRUE)
  816. {
  817. dwFlags &= ~CTXFLG_EXPAND_CONDITIONAL;
  818. dwFlags |= CTXFLG_EXPAND;
  819. }
  820. else if(STRINGISPRESENT(m_bstrCurrentPlace))
  821. {
  822. bstrPlace = NULL;
  823. }
  824. }
  825. //
  826. // Fire the PersistSave event.
  827. //
  828. if(fAlsoContent)
  829. {
  830. __MPC_EXIT_IF_METHOD_FAILS(hr, m_hs->ForceHistoryPopulate());
  831. }
  832. if(dwFlags & CTXFLG_EXPAND ) __MPC_EXIT_IF_METHOD_FAILS(hr, SetCorrectContentView( false ));
  833. if(dwFlags & CTXFLG_COLLAPSE) __MPC_EXIT_IF_METHOD_FAILS(hr, SetCorrectContentView( true ));
  834. if(ptr->idComp != HelpHost::COMPID_MAX && m_HelpHost->GetStatus( ptr->idComp ) == false)
  835. {
  836. if(ptr->bstrSubPanel)
  837. {
  838. CComPtr<IWebBrowser2> wb = m_panel_CONTEXT_WebBrowser;
  839. if(wb)
  840. {
  841. CComVariant varURL ( ptr->bstrSubPanel );
  842. CComVariant varFrame( L"SubPanels" );
  843. CComVariant varEmpty;
  844. __MPC_EXIT_IF_METHOD_FAILS(hr, wb->Navigate2( &varURL, &varEmpty, &varFrame, &varEmpty, &varEmpty ));
  845. }
  846. if(m_HelpHost->WaitUntilLoaded( ptr->idComp ) == false)
  847. {
  848. __MPC_EXIT_IF_METHOD_FAILS(hr, E_INVALIDARG);
  849. }
  850. }
  851. }
  852. //
  853. // It's actually a navigation, so register it.
  854. //
  855. if(iVal == HSCCONTEXT_FULLWINDOW && STRINGISPRESENT(bstrPage)) dwFlags |= CTXFLG_REGISTER_CONTEXT;
  856. if(dwFlags & CTXFLG_REGISTER_CONTEXT)
  857. {
  858. __MPC_EXIT_IF_METHOD_FAILS(hr, m_hs->RegisterContextSwitch( iVal, bstrInfo, bstrURL ));
  859. }
  860. if(fAlsoContent)
  861. {
  862. if(!MPC::StrICmp( bstrPage, L"<none>" )) bstrPage.Empty();
  863. if(STRINGISPRESENT(bstrPage))
  864. {
  865. __MPC_EXIT_IF_METHOD_FAILS(hr, m_hs->RecordNavigationInAdvance( bstrPage ));
  866. if(fFromHomePage ||
  867. fToHomePage )
  868. {
  869. CComPtr<IWebBrowser2> wb;
  870. wb = m_panel_CONTENTS_WebBrowser; if(wb) local_HideDocument( wb );
  871. wb = m_panel_HHWINDOW_WebBrowser; if(wb) local_HideDocument( wb );
  872. RefreshUI();
  873. }
  874. __MPC_EXIT_IF_METHOD_FAILS(hr, SetPanelUrl( HSCPANEL_CONTENTS, bstrPage ));
  875. }
  876. else
  877. {
  878. __MPC_EXIT_IF_METHOD_FAILS(hr, m_hs->DuplicateNavigation());
  879. }
  880. }
  881. if(STRINGISPRESENT(bstrPlace))
  882. {
  883. __MPC_EXIT_IF_METHOD_FAILS(hr, TransitionToPlace( bstrPlace ));
  884. }
  885. if(fAlsoContent)
  886. {
  887. __MPC_EXIT_IF_METHOD_FAILS(hr, m_Events.FireEvent_ContextSwitch());
  888. }
  889. __MPC_SET_ERROR_AND_EXIT(hr, S_OK);
  890. }
  891. }
  892. ////////////////////////////////////////////////////////////////////////////////
  893. hr = S_OK;
  894. __HCP_FUNC_CLEANUP;
  895. m_bstrStartURL.Empty();
  896. __HCP_FUNC_EXIT(hr);
  897. }
  898. ////////////////////
  899. HRESULT CPCHHelpCenterExternal::SetCorrectContentView( /*[in]*/ bool fShrinked )
  900. {
  901. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::SetCorrectContentView" );
  902. HRESULT hr;
  903. LPCWSTR szPlace;
  904. CComVariant v( fShrinked ? L"contentonly" : L"normal" );
  905. __MPC_EXIT_IF_METHOD_FAILS(hr, CallFunctionOnPanel( HSCPANEL_NAVBAR, NULL, c_bstrFunc_ChangeView, &v, 1 ));
  906. hr = S_OK;
  907. __HCP_FUNC_CLEANUP;
  908. __HCP_FUNC_EXIT(hr);
  909. }
  910. HRESULT CPCHHelpCenterExternal::SetCorrectContentPanel( /*[in]*/ bool fShowNormal ,
  911. /*[in]*/ bool fShowHTMLHELP ,
  912. /*[in]*/ bool fDoItNow )
  913. {
  914. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::SetCorrectContentPanel" );
  915. HRESULT hr;
  916. CComPtr<IMarsPanelCollection> coll;
  917. bool fLocked = false;
  918. m_DisplayTimer.Stop();
  919. //
  920. // If there's no place, whatever we do will be lost, so delay the action.
  921. //
  922. if(!STRINGISPRESENT(m_bstrCurrentPlace)) fDoItNow = false;
  923. //
  924. // Two panels, HSCPANEL_CONTENTS and HSCPANEL_HHWINDOW, are actually overlapped, so only one at a time can be visible.
  925. //
  926. if(m_shell && SUCCEEDED(m_shell->get_panels( &coll )) && coll)
  927. {
  928. CComPtr<IMarsPanel> panel;
  929. CComPtr<IMarsPanel> panelOld;
  930. HscPanel id;
  931. HscPanel idOld;
  932. if(fShowNormal)
  933. {
  934. id = HSCPANEL_CONTENTS;
  935. idOld = HSCPANEL_HHWINDOW;
  936. }
  937. else if(fShowHTMLHELP)
  938. {
  939. id = HSCPANEL_HHWINDOW;
  940. idOld = HSCPANEL_CONTENTS;
  941. }
  942. else
  943. {
  944. __MPC_SET_ERROR_AND_EXIT(hr, S_OK); // Nothing to do.
  945. }
  946. GetPanelDirect( id, panel );
  947. if(panel)
  948. {
  949. VARIANT_BOOL fVisible;
  950. __MPC_EXIT_IF_METHOD_FAILS(hr, panel->get_visible( &fVisible ));
  951. if(fVisible == VARIANT_FALSE)
  952. {
  953. if(fDoItNow == false)
  954. {
  955. __MPC_EXIT_IF_METHOD_FAILS(hr, m_DisplayTimer.Start( this, fShowNormal ? TimerCallback_DisplayNormal : TimerCallback_DisplayHTMLHELP, 50 ));
  956. }
  957. else
  958. {
  959. coll->lockLayout(); fLocked = true;
  960. GetPanelDirect( idOld, panelOld );
  961. if(panelOld)
  962. {
  963. __MPC_EXIT_IF_METHOD_FAILS(hr, panelOld->put_visible( VARIANT_FALSE ));
  964. __MPC_EXIT_IF_METHOD_FAILS(hr, panel ->put_visible( VARIANT_TRUE ));
  965. }
  966. }
  967. }
  968. }
  969. }
  970. hr = S_OK;
  971. __HCP_FUNC_CLEANUP;
  972. if(fLocked) coll->unlockLayout();
  973. __HCP_FUNC_EXIT(hr);
  974. }
  975. HRESULT CPCHHelpCenterExternal::TimerCallback_DisplayNormal ( /*[in]*/ VARIANT )
  976. {
  977. return SetCorrectContentPanel( /*fShowNormal*/true, /*fShowHTMLHELP*/false, /*fDoItNow*/true );
  978. }
  979. HRESULT CPCHHelpCenterExternal::TimerCallback_DisplayHTMLHELP( /*[in]*/ VARIANT )
  980. {
  981. return SetCorrectContentPanel( /*fShowNormal*/false, /*fShowHTMLHELP*/true, /*fDoItNow*/true );
  982. }
  983. HRESULT CPCHHelpCenterExternal::TimerCallback_DelayedActions( /*[in]*/ VARIANT )
  984. {
  985. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::TimerCallback_DelayedActions" );
  986. while(m_DelayedActions.size())
  987. {
  988. DelayedExecution& de = m_DelayedActions.front();
  989. switch(de.mode)
  990. {
  991. case DELAYMODE_NAVIGATEWEB : (void)SetPanelUrl ( HSCPANEL_CONTENTS, de.bstrURL ); break;
  992. case DELAYMODE_NAVIGATEHH : (void)NavigateHH ( de.bstrURL ); break;
  993. case DELAYMODE_CHANGECONTEXT: (void)ChangeContext( de.iVal, de.bstrInfo, de.bstrURL, de.fAlsoContent ); break;
  994. case DELAYMODE_REFRESHLAYOUT: if(m_shell) (void)m_shell->refreshLayout(); break;
  995. }
  996. m_DelayedActions.pop_front();
  997. }
  998. __HCP_FUNC_EXIT(S_OK);
  999. }
  1000. CPCHHelpCenterExternal::DelayedExecution& CPCHHelpCenterExternal::DelayedExecutionAlloc()
  1001. {
  1002. return *(m_DelayedActions.insert( m_DelayedActions.end() ));
  1003. }
  1004. HRESULT CPCHHelpCenterExternal::DelayedExecutionStart()
  1005. {
  1006. return m_ActionsTimer.Start( this, TimerCallback_DelayedActions, 2 );
  1007. }
  1008. ////////////////////
  1009. HRESULT CPCHHelpCenterExternal::RefreshLayout()
  1010. {
  1011. DelayedExecution& de = DelayedExecutionAlloc();
  1012. de.mode = DELAYMODE_REFRESHLAYOUT;
  1013. return DelayedExecutionStart();
  1014. }
  1015. HRESULT CPCHHelpCenterExternal::EnsurePlace()
  1016. {
  1017. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::EnsurePlace" );
  1018. HRESULT hr;
  1019. //
  1020. // If we are not displayed (m_bstrCurrentPlace not set), force a transition to a default place.
  1021. //
  1022. if(!STRINGISPRESENT(m_bstrCurrentPlace))
  1023. {
  1024. __MPC_EXIT_IF_METHOD_FAILS(hr, TransitionToPlace( c_bstrPlace_FullWindow ));
  1025. }
  1026. hr = S_OK;
  1027. __HCP_FUNC_CLEANUP;
  1028. __HCP_FUNC_EXIT(hr);
  1029. }
  1030. HRESULT CPCHHelpCenterExternal::TransitionToPlace( /*[in]*/ LPCWSTR szMode )
  1031. {
  1032. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::TransitionToPlace" );
  1033. HRESULT hr;
  1034. CComPtr<IMarsPlaceCollection> coll;
  1035. CComBSTR bstrPlace( szMode );
  1036. __MPC_PARAMCHECK_BEGIN(hr)
  1037. __MPC_PARAMCHECK_NOTNULL(m_shell);
  1038. __MPC_PARAMCHECK_END();
  1039. MPC_SCRIPTHELPER_GET__DIRECT__NOTNULL(coll, m_shell, places);
  1040. __MPC_EXIT_IF_METHOD_FAILS(hr, coll->transitionTo( bstrPlace ));
  1041. __MPC_EXIT_IF_METHOD_FAILS(hr, RefreshLayout());
  1042. hr = S_OK;
  1043. __HCP_FUNC_CLEANUP;
  1044. __HCP_FUNC_EXIT(hr);
  1045. }
  1046. HRESULT CPCHHelpCenterExternal::ExtendNavigation()
  1047. {
  1048. __HCP_FUNC_ENTRY( "CPCHHelpCenterExternal::ExtendNavigation" );
  1049. HRESULT hr;
  1050. m_panel_CONTEXT_Events .NotifyStop();
  1051. m_panel_CONTENTS_Events.NotifyStop();
  1052. m_panel_HHWINDOW_Events.NotifyStop();
  1053. hr = S_OK;
  1054. __HCP_FUNC_EXIT(hr);
  1055. }