Source code of Windows XP (NT5)
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.

488 lines
11 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. impl.cpp
  5. Abstract:
  6. This file contains the implementation of the CPCHLaunch class.
  7. Revision History:
  8. Davide Massarenti (Dmassare) 04/15/2000
  9. created
  10. ******************************************************************************/
  11. #include "StdAfx.h"
  12. ////////////////////////////////////////////////////////////////////////////////
  13. HelpHostProxy::Main::Main()
  14. {
  15. // CComPtr<IPCHHelpHost> m_real;
  16. //
  17. // CComPtr<Window> m_subWindow;
  18. // CComPtr<Panes> m_subPanes;
  19. //
  20. // CComQIPtr<IPCHHelpHostEvents> m_Events;
  21. // CComQIPtr<IPCHHelpHostNavEvents> m_EventsNav;
  22. }
  23. HelpHostProxy::Main::~Main()
  24. {
  25. Passivate();
  26. }
  27. HRESULT HelpHostProxy::Main::FinalConstruct()
  28. {
  29. return Initialize();
  30. }
  31. void HelpHostProxy::Main::FinalRelease()
  32. {
  33. Passivate();
  34. }
  35. ////////////////////
  36. HRESULT HelpHostProxy::Main::Initialize()
  37. {
  38. __HCP_FUNC_ENTRY( "HelpHostProxy::Main::Initialize" );
  39. HRESULT hr;
  40. __MPC_EXIT_IF_METHOD_FAILS(hr, HCAPI::OpenConnection( m_real ));
  41. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &m_subWindow )); __MPC_EXIT_IF_METHOD_FAILS(hr, m_subWindow->Initialize( this ));
  42. __MPC_EXIT_IF_METHOD_FAILS(hr, MPC::CreateInstance( &m_subPanes )); __MPC_EXIT_IF_METHOD_FAILS(hr, m_subPanes ->Initialize( this ));
  43. hr = S_OK;
  44. __HCP_FUNC_CLEANUP;
  45. __HCP_FUNC_EXIT(hr);
  46. }
  47. void HelpHostProxy::Main::Passivate()
  48. {
  49. if(m_subPanes ) { m_subPanes ->Passivate(); m_subPanes .Release(); }
  50. if(m_subWindow) { m_subWindow->Passivate(); m_subWindow.Release(); }
  51. m_Events .Release();
  52. m_EventsNav.Release();
  53. m_real .Release();
  54. }
  55. ////////////////////
  56. STDMETHODIMP HelpHostProxy::Main::put_FilterName( /*[in] */ BSTR Value )
  57. {
  58. return m_real ? m_real->put_FilterName( Value ) : E_FAIL;
  59. }
  60. STDMETHODIMP HelpHostProxy::Main::get_FilterName( /*[out, retval]*/ BSTR *pValue )
  61. {
  62. if(pValue) *pValue = NULL;
  63. return m_real ? m_real->get_FilterName( pValue ) : E_FAIL;
  64. }
  65. STDMETHODIMP HelpHostProxy::Main::get_Namespace( /*[out, retval]*/ BSTR *pValue )
  66. {
  67. if(pValue) *pValue = NULL;
  68. return m_real ? m_real->get_Namespace( pValue ) : E_FAIL;
  69. }
  70. STDMETHODIMP HelpHostProxy::Main::get_Session( /*[out, retval]*/ IDispatch* *pValue )
  71. {
  72. if(pValue) *pValue = NULL;
  73. return m_real ? m_real->get_Session( pValue ) : E_FAIL;
  74. }
  75. STDMETHODIMP HelpHostProxy::Main::get_FilterExpression( /*[out, retval]*/ BSTR *pValue )
  76. {
  77. if(pValue) *pValue = NULL;
  78. return m_real ? m_real->get_FilterExpression( pValue ) : E_FAIL;
  79. }
  80. STDMETHODIMP HelpHostProxy::Main::get_CurrentUrl( /*[out, retval]*/ BSTR *pValue )
  81. {
  82. if(pValue) *pValue = NULL;
  83. return m_real ? m_real->get_CurrentUrl( pValue ) : E_FAIL;
  84. }
  85. STDMETHODIMP HelpHostProxy::Main::get_Panes( /*[out, retval]*/ IHelpHostPanes* *pValue )
  86. {
  87. if(pValue) *pValue = NULL;
  88. return m_subPanes ? m_subPanes.QueryInterface( pValue ) : E_FAIL;
  89. }
  90. STDMETHODIMP HelpHostProxy::Main::get_HelpHostWindow( /*[out, retval]*/ IHelpHostWindow* *pValue )
  91. {
  92. if(pValue) *pValue = NULL;
  93. return m_subWindow ? m_subWindow.QueryInterface( pValue ) : E_FAIL;
  94. }
  95. STDMETHODIMP HelpHostProxy::Main::OpenNamespace( /*[in]*/ BSTR newNamespace, /*[in]*/ BSTR filterName )
  96. {
  97. return m_real ? m_real->OpenNamespace( newNamespace, filterName ) : E_FAIL;
  98. }
  99. STDMETHODIMP HelpHostProxy::Main::DisplayTopicFromURL( /*[in]*/ BSTR url, /*[in]*/ VARIANT options )
  100. {
  101. return m_real ? m_real->DisplayTopicFromURL( url, options ) : E_FAIL;
  102. }
  103. STDMETHODIMP HelpHostProxy::Main::DisplayResultsFromQuery( /*[in]*/ BSTR query, /*[in]*/ BSTR navMoniker, /*[in]*/ VARIANT options )
  104. {
  105. return m_real ? m_real->DisplayResultsFromQuery( query, navMoniker, options ) : E_FAIL;
  106. }
  107. STDMETHODIMP HelpHostProxy::Main::ShowPane( /*[in]*/ BSTR paneName, /*[in]*/ BSTR query, /*[in]*/ BSTR navMoniker, /*[in]*/ VARIANT options )
  108. {
  109. return m_real ? m_real->ShowPane( paneName, query, navMoniker, options ) : E_FAIL;
  110. }
  111. STDMETHODIMP HelpHostProxy::Main::Terminate()
  112. {
  113. return m_real ? m_real->Terminate() : E_FAIL;
  114. }
  115. ////////////////////////////////////////////////////////////////////////////////
  116. ////////////////////////////////////////////////////////////////////////////////
  117. HelpHostProxy::Window::Window()
  118. {
  119. // CComPtr<IPCHHelpHostWindow> m_real;
  120. //
  121. m_Main = NULL; // Main* m_Main;
  122. m_ParentWindow = 0; // long m_ParentWindow;
  123. }
  124. HelpHostProxy::Window::~Window()
  125. {
  126. Passivate();
  127. }
  128. HRESULT HelpHostProxy::Window::Initialize( /*[in]*/ Main* main )
  129. {
  130. m_Main = main;
  131. return S_OK;
  132. }
  133. void HelpHostProxy::Window::Passivate()
  134. {
  135. m_real.Release();
  136. m_Main = NULL;
  137. m_ParentWindow = 0;
  138. }
  139. ////////////////////
  140. STDMETHODIMP HelpHostProxy::Window::put_ParentWindow( /*[in]*/ long hWND )
  141. {
  142. m_ParentWindow = hWND;
  143. return m_real ? m_real->put_ParentWindow( hWND ) : E_FAIL;
  144. }
  145. STDMETHODIMP HelpHostProxy::Window::get_ParentWindow( /*[out, retval]*/ long *phWND )
  146. {
  147. if(phWND == NULL) return E_POINTER;
  148. *phWND = m_ParentWindow;
  149. return S_OK;
  150. }
  151. STDMETHODIMP HelpHostProxy::Window::put_UILanguage( /*[in]*/ long LCID )
  152. {
  153. return m_real ? m_real->put_UILanguage( LCID ) : E_FAIL;
  154. }
  155. STDMETHODIMP HelpHostProxy::Window::get_UILanguage( /*[out, retval]*/ long *pLCID )
  156. {
  157. if(pLCID) *pLCID = 0;
  158. return m_real ? m_real->get_UILanguage( pLCID ) : E_FAIL;
  159. }
  160. STDMETHODIMP HelpHostProxy::Window::put_Visible( /*[in]*/ VARIANT_BOOL Value )
  161. {
  162. return m_real ? m_real->put_Visible( Value ) : E_FAIL;
  163. }
  164. STDMETHODIMP HelpHostProxy::Window::get_Visible( /*[out, retval]*/ VARIANT_BOOL *pValue )
  165. {
  166. if(pValue) *pValue = VARIANT_FALSE;
  167. return m_real ? m_real->get_Visible( pValue ) : E_FAIL;
  168. }
  169. STDMETHODIMP HelpHostProxy::Window::get_OriginX( /*[out, retval]*/ long *pValue )
  170. {
  171. if(pValue) *pValue = 0;
  172. return m_real ? m_real->get_OriginX( pValue ) : E_FAIL;
  173. }
  174. STDMETHODIMP HelpHostProxy::Window::get_OriginY( /*[out, retval]*/ long *pValue )
  175. {
  176. if(pValue) *pValue = 0;
  177. return m_real ? m_real->get_OriginY( pValue ) : E_FAIL;
  178. }
  179. STDMETHODIMP HelpHostProxy::Window::get_Width( /*[out, retval]*/ long *pValue )
  180. {
  181. if(pValue) *pValue = 0;
  182. return m_real ? m_real->get_Width( pValue ) : E_FAIL;
  183. }
  184. STDMETHODIMP HelpHostProxy::Window::get_Height( /*[out, retval]*/ long *pValue )
  185. {
  186. if(pValue) *pValue = 0;
  187. return m_real ? m_real->get_Height( pValue ) : E_FAIL;
  188. }
  189. STDMETHODIMP HelpHostProxy::Window::MoveWindow( /*[in]*/ long originX, /*[in]*/ long originY, /*[in]*/ long width, /*[in]*/ long height )
  190. {
  191. return m_real ? m_real->MoveWindow( originX, originY, width, height ) : E_FAIL;
  192. }
  193. STDMETHODIMP HelpHostProxy::Window::WaitForTermination( /*[in]*/ long timeOut )
  194. {
  195. return E_NOTIMPL;
  196. }
  197. ////////////////////////////////////////////////////////////////////////////////
  198. HelpHostProxy::Panes::Panes()
  199. {
  200. m_Main = NULL; // Main* m_Main;
  201. // List m_Panes;
  202. }
  203. HelpHostProxy::Panes::~Panes()
  204. {
  205. Passivate();
  206. }
  207. HRESULT HelpHostProxy::Panes::Initialize( /*[in]*/ Main* main )
  208. {
  209. __HCP_FUNC_ENTRY( "HelpHostProxy::Panes::Initialize" );
  210. HRESULT hr;
  211. int i;
  212. m_Main = main;
  213. // for(i=0; i<ARRAYSIZE(c_Panes); i++)
  214. // {
  215. // Pane* pVal;
  216. //
  217. // __MPC_EXIT_IF_METHOD_FAILS(hr, c_Panes[i].pfn( pVal ) ); m_Panes.push_back( pVal );
  218. //
  219. // pVal->m_bstrName = c_Panes[i].szName;
  220. //
  221. // __MPC_EXIT_IF_METHOD_FAILS(hr, pVal->Initialize( m_Main ));
  222. //
  223. // __MPC_EXIT_IF_METHOD_FAILS(hr, AddItem( pVal ));
  224. // }
  225. hr = S_OK;
  226. // __HCP_FUNC_CLEANUP;
  227. __HCP_FUNC_EXIT(hr);
  228. }
  229. void HelpHostProxy::Panes::Passivate()
  230. {
  231. MPC::ReleaseAll( m_Panes );
  232. }
  233. HRESULT HelpHostProxy::Panes::GetPane( /*[in]*/ LPCWSTR szName, /*[out]*/ Pane* *pVal )
  234. {
  235. __HCP_FUNC_ENTRY( "HelpHostProxy::Panes::GetPane" );
  236. HRESULT hr;
  237. Iter it;
  238. __MPC_PARAMCHECK_BEGIN(hr)
  239. __MPC_PARAMCHECK_POINTER_AND_SET(pVal,NULL);
  240. __MPC_PARAMCHECK_END();
  241. for(it=m_Panes.begin(); it!=m_Panes.end(); it++)
  242. {
  243. Pane* pane = *it;
  244. if(!MPC::StrICmp( szName, pane->m_bstrName ))
  245. {
  246. *pVal = pane; pane->AddRef();
  247. break;
  248. }
  249. }
  250. hr = S_OK;
  251. __HCP_FUNC_CLEANUP;
  252. __HCP_FUNC_EXIT(hr);
  253. }
  254. ////////////////////
  255. STDMETHODIMP HelpHostProxy::Panes::get_Item( /*[in]*/ VARIANT Index, /*[out]*/ VARIANT* pvar )
  256. {
  257. __HCP_FUNC_ENTRY( "HelpHostProxy::Panes::get_Item" );
  258. HRESULT hr;
  259. __MPC_PARAMCHECK_BEGIN(hr)
  260. __MPC_PARAMCHECK_NOTNULL(pvar);
  261. __MPC_PARAMCHECK_END();
  262. if(Index.vt == VT_BSTR)
  263. {
  264. CComPtr<Pane> pane;
  265. CComVariant v;
  266. __MPC_EXIT_IF_METHOD_FAILS(hr, GetPane( Index.bstrVal, &pane ));
  267. v = pane;
  268. __MPC_EXIT_IF_METHOD_FAILS(hr, v.Detach( pvar ));
  269. }
  270. else if(Index.vt == VT_I4)
  271. {
  272. __MPC_EXIT_IF_METHOD_FAILS(hr, super::get_Item( Index.iVal, pvar ));
  273. }
  274. else
  275. {
  276. __MPC_SET_ERROR_AND_EXIT(hr, E_INVALIDARG);
  277. }
  278. hr = S_OK;
  279. __HCP_FUNC_CLEANUP;
  280. __HCP_FUNC_EXIT(hr);
  281. }
  282. ////////////////////////////////////////////////////////////////////////////////
  283. ////////////////////////////////////////////////////////////////////////////////
  284. HelpHostProxy::Pane::Pane()
  285. {
  286. m_Main = NULL; // Main* m_Main;
  287. //
  288. // CComBSTR m_bstrName;
  289. // CComBSTR m_bstrMoniker;
  290. m_fVisible = VARIANT_FALSE; // VARIANT_BOOL m_fVisible;
  291. }
  292. HelpHostProxy::Pane::~Pane()
  293. {
  294. Passivate();
  295. }
  296. HRESULT HelpHostProxy::Pane::Initialize( /*[in]*/ Main* main )
  297. {
  298. m_Main = main;
  299. return S_OK;
  300. }
  301. void HelpHostProxy::Pane::Passivate()
  302. {
  303. }
  304. ////////////////////
  305. STDMETHODIMP HelpHostProxy::Pane::put_Visible( /*[in]*/ VARIANT_BOOL Value )
  306. {
  307. return S_FALSE;
  308. }
  309. STDMETHODIMP HelpHostProxy::Pane::get_Visible( /*[out, retval]*/ VARIANT_BOOL *pValue )
  310. {
  311. if(pValue == NULL) return E_POINTER;
  312. *pValue = m_fVisible;
  313. return S_OK;
  314. }
  315. STDMETHODIMP HelpHostProxy::Pane::put_NavMoniker( /*[in]*/ BSTR Value )
  316. {
  317. m_bstrMoniker = Value;
  318. return S_OK;
  319. }
  320. STDMETHODIMP HelpHostProxy::Pane::get_NavMoniker( /*[out, retval]*/ BSTR *pValue )
  321. {
  322. return MPC::GetBSTR( m_bstrMoniker, pValue );
  323. }
  324. STDMETHODIMP HelpHostProxy::Pane::get_Name( /*[out, retval]*/ BSTR *pValue )
  325. {
  326. return MPC::GetBSTR( m_bstrName, pValue );
  327. }
  328. STDMETHODIMP HelpHostProxy::Pane::get_CurrentUrl( /*[out, retval]*/ BSTR *pValue )
  329. {
  330. return MPC::GetBSTR( NULL, pValue );
  331. }
  332. STDMETHODIMP HelpHostProxy::Pane::get_WebBrowser( /*[out, retval]*/ IDispatch* *pValue )
  333. {
  334. if(pValue == NULL) return E_POINTER;
  335. *pValue = NULL;
  336. return S_OK;
  337. }
  338. STDMETHODIMP HelpHostProxy::Pane::DisplayTopicFromURL( /*[in]*/ BSTR url, /*[in]*/ VARIANT options )
  339. {
  340. return S_FALSE;
  341. }
  342. STDMETHODIMP HelpHostProxy::Pane::DisplayResultsFromQuery( /*[in]*/ BSTR query, /*[in]*/ VARIANT options )
  343. {
  344. return S_FALSE;
  345. }
  346. STDMETHODIMP HelpHostProxy::Pane::Sync( /*[in]*/ BSTR url, /*[in]*/ VARIANT options )
  347. {
  348. return S_FALSE;
  349. }