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.

443 lines
16 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. HelpSession.h
  5. Abstract:
  6. This file contains the declaration of the class used to implement
  7. the Help Session inside the Help Center Application.
  8. Revision History:
  9. Davide Massarenti (dmassare) 08/07/99
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___PCH___HELPSESSION_H___)
  13. #define __INCLUDED___PCH___HELPSESSION_H___
  14. /////////////////////////////////////////////////////////////////////////////
  15. //
  16. // Uncomment if you want to enable Help Session traces.
  17. //
  18. //#define HSS_RPRD
  19. ////////////////////////////////////////
  20. //
  21. // From HelpServiceTypeLib.idl
  22. //
  23. #include <HelpServiceTypeLib.h>
  24. //
  25. // From HelpCenterTypeLib.idl
  26. //
  27. #include <HelpCenterTypeLib.h>
  28. #include <MPC_streams.h>
  29. #include <TaxonomyDatabase.h>
  30. ////////////////////
  31. class CPCHHelpCenterExternal;
  32. class CPCHHelpSessionItem;
  33. class CPCHHelpSession;
  34. ////////////////////////////////////////////////////////////////////////////////
  35. typedef enum
  36. {
  37. HSCPANEL_INVALID = 0,
  38. HSCPANEL_NAVBAR ,
  39. HSCPANEL_MININAVBAR ,
  40. HSCPANEL_CONTEXT ,
  41. HSCPANEL_CONTENTS ,
  42. HSCPANEL_HHWINDOW ,
  43. } HscPanel;
  44. typedef enum
  45. {
  46. HSCCONTEXT_INVALID = 0,
  47. HSCCONTEXT_STARTUP ,
  48. HSCCONTEXT_HOMEPAGE ,
  49. HSCCONTEXT_CONTENT ,
  50. HSCCONTEXT_SUBSITE ,
  51. HSCCONTEXT_SEARCH ,
  52. HSCCONTEXT_INDEX ,
  53. HSCCONTEXT_FAVORITES ,
  54. HSCCONTEXT_HISTORY ,
  55. HSCCONTEXT_CHANNELS ,
  56. HSCCONTEXT_OPTIONS ,
  57. ////////////////////////////////////////
  58. HSCCONTEXT_CONTENTONLY ,
  59. HSCCONTEXT_FULLWINDOW ,
  60. HSCCONTEXT_KIOSKMODE ,
  61. } HscContext;
  62. ////////////////////
  63. class ATL_NO_VTABLE CPCHHelpSessionItem : // Hungarian: hchsi
  64. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  65. public IDispatchImpl<IPCHHelpSessionItem, &IID_IPCHHelpSessionItem, &LIBID_HelpCenterTypeLib>
  66. {
  67. friend class CPCHHelpSession;
  68. static const int NO_LINK = -1;
  69. struct State
  70. {
  71. typedef std::map<MPC::wstringUC,MPC::wstring> PropertyMap;
  72. typedef PropertyMap::iterator PropertyIter;
  73. typedef PropertyMap::const_iterator PropertyIterConst;
  74. ////////////////////////////////////////
  75. CPCHHelpSessionItem* m_parent;
  76. bool m_fValid;
  77. bool m_fDirty;
  78. DWORD m_dwLoaded;
  79. MPC::CComHGLOBAL m_hgWebBrowser_CONTENTS;
  80. MPC::CComHGLOBAL m_hgWebBrowser_HHWINDOW;
  81. PropertyMap m_mapProperties;
  82. ////////////////////////////////////////
  83. void Erase( /*[in]*/ bool fUnvalidate );
  84. HRESULT Load ( );
  85. HRESULT Save ( );
  86. private:
  87. // copy constructors...
  88. State ( /*[in]*/ const State& state );
  89. State& operator=( /*[in]*/ const State& state );
  90. public:
  91. State( /*[in]*/ CPCHHelpSessionItem* parent );
  92. HRESULT AcquireState( );
  93. HRESULT ReleaseState( /*[in]*/ bool fForce );
  94. HRESULT Populate( /*[in ]*/ bool fUseHH );
  95. HRESULT Restore ( /*[in ]*/ bool fUseHH );
  96. HRESULT Delete ( );
  97. HRESULT Clone ( /*[out]*/ State& state );
  98. };
  99. ////////////////////////////////////////
  100. CPCHHelpSession* m_parent;
  101. State m_state;
  102. bool m_fSaved;
  103. bool m_fInitialized;
  104. ////////////////////
  105. //
  106. // Persisted
  107. //
  108. Taxonomy::HelpSet m_ths;
  109. CComBSTR m_bstrURL;
  110. CComBSTR m_bstrTitle;
  111. DATE m_dLastVisited;
  112. DATE m_dDuration;
  113. long m_lNumOfHits;
  114. int m_iIndexPrev;
  115. int m_iIndex;
  116. int m_iIndexNext;
  117. long m_lContextID; // HscContext
  118. CComBSTR m_bstrContextInfo;
  119. CComBSTR m_bstrContextURL;
  120. bool m_fUseHH;
  121. //
  122. ////////////////////
  123. ////////////////////////////////////////
  124. void HistorySelect ( );
  125. HRESULT HistoryPopulate( );
  126. HRESULT HistoryRestore ( );
  127. HRESULT HistoryDelete ( );
  128. HRESULT HistoryClone ( /*[in]*/ bool fContext, /*[in]*/ CPCHHelpSessionItem* hsi );
  129. public:
  130. BEGIN_COM_MAP(CPCHHelpSessionItem)
  131. COM_INTERFACE_ENTRY(IDispatch)
  132. COM_INTERFACE_ENTRY(IPCHHelpSessionItem)
  133. END_COM_MAP()
  134. CPCHHelpSessionItem();
  135. void Initialize( /*[in]*/ CPCHHelpSession* parent, /*[in]*/ bool fNew );
  136. void Passivate ( );
  137. HRESULT Load( /*[in]*/ MPC::Serializer& streamIn );
  138. HRESULT Save( /*[in]*/ MPC::Serializer& streamOut, bool fForce = false );
  139. ////////////////////////////////////////
  140. HRESULT Enter();
  141. HRESULT Leave();
  142. bool SeenLongEnough( DWORD dwSeconds ) const;
  143. bool SameURL( CPCHHelpSessionItem* right ) const;
  144. bool SameURL( LPCWSTR right ) const;
  145. bool SameSKU( /*[in]*/ const Taxonomy::HelpSet& ths ) const;
  146. ////////////////////////////////////////
  147. CPCHHelpSession* GetParent () { return m_parent ; }
  148. const CComBSTR& GetURL () const { return m_bstrURL ; }
  149. int GetIndex () const { return m_iIndex ; }
  150. const HscContext GetContextID () const { return (HscContext)m_lContextID ; }
  151. const CComBSTR& GetContextInfo() const { return m_bstrContextInfo; }
  152. const CComBSTR& GetContextURL () const { return m_bstrContextURL ; }
  153. static HscContext LookupContext( /*[in]*/ LPCWSTR szName );
  154. static LPCWSTR LookupContext( /*[in]*/ HscContext iVal );
  155. ////////////////////////////////////////
  156. CPCHHelpSessionItem* Previous();
  157. CPCHHelpSessionItem* Next ();
  158. HRESULT ExtractTitle();
  159. ////////////////////////////////////////
  160. public:
  161. // IPCHHelpSessionItem
  162. void put_THS ( /*[in]*/ const Taxonomy::HelpSet& ths ); // Internal Method.
  163. STDMETHOD(get_SKU )( /*[out, retval]*/ BSTR * pVal );
  164. STDMETHOD(get_Language )( /*[out, retval]*/ long * pVal );
  165. STDMETHOD(get_URL )( /*[out, retval]*/ BSTR * pVal );
  166. HRESULT put_URL ( /*[in]*/ BSTR newVal ); // Internal Method.
  167. STDMETHOD(get_Title )( /*[out, retval]*/ BSTR * pVal );
  168. HRESULT put_Title ( /*[in]*/ BSTR newVal ); // Internal Method.
  169. STDMETHOD(get_LastVisited)( /*[out, retval]*/ DATE * pVal );
  170. STDMETHOD(get_Duration )( /*[out, retval]*/ DATE * pVal );
  171. STDMETHOD(get_NumOfHits )( /*[out, retval]*/ long * pVal );
  172. STDMETHOD(get_ContextName)( /*[out, retval]*/ BSTR *pVal );
  173. STDMETHOD(get_ContextInfo)( /*[out, retval]*/ BSTR *pVal );
  174. STDMETHOD(get_ContextURL )( /*[out, retval]*/ BSTR *pVal );
  175. STDMETHOD(get_Property )( /*[in]*/ BSTR bstrName, /*[out, retval]*/ VARIANT *pVal );
  176. STDMETHOD(put_Property )( /*[in]*/ BSTR bstrName, /*[in]*/ VARIANT newVal );
  177. STDMETHOD(CheckProperty)( /*[in]*/ BSTR bstrName, /*[out, retval]*/ VARIANT_BOOL *pVal );
  178. };
  179. /////////////////////////////////////////////////////////////////////////////
  180. class ATL_NO_VTABLE CPCHHelpSession : // Hungarian: hchs
  181. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  182. public IDispatchImpl<IPCHHelpSession, &IID_IPCHHelpSession, &LIBID_HelpCenterTypeLib>
  183. {
  184. friend class CPCHHelpSessionItem;
  185. #ifdef DEBUG
  186. void DEBUG_DumpState_HG ( /*[in]*/ MPC::FileLog& log, /*[in]*/ MPC::CComHGLOBAL& hg );
  187. void DEBUG_DumpState_BLOB( /*[in]*/ MPC::FileLog& log, /*[in]*/ CPCHHelpSessionItem* hsi );
  188. void DEBUG_DumpState( /*[in]*/ LPCWSTR szText, /*[in]*/ bool fHeader, /*[in]*/ bool fCurrent, /*[in]*/ bool fAll, /*[in]*/ bool fState );
  189. void DEBUG_DumpSavedPages();
  190. #else
  191. inline void DEBUG_DumpState_HG ( /*[in]*/ MPC::FileLog& log, /*[in]*/ MPC::CComHGLOBAL& hg ) {}
  192. inline void DEBUG_DumpState_BLOB( /*[in]*/ MPC::FileLog& log, /*[in]*/ CPCHHelpSessionItem* hsi ) {}
  193. inline void DEBUG_DumpState( /*[in]*/ LPCWSTR szText, /*[in]*/ bool fHeader, /*[in]*/ bool fCurrent, /*[in]*/ bool fAll, /*[in]*/ bool fState ) {}
  194. inline void DEBUG_DumpSavedPages() {}
  195. #endif
  196. ////////////////////////////////////////
  197. public:
  198. struct TitleEntry
  199. {
  200. MPC::wstring m_szTitle;
  201. bool m_fStrong;
  202. TitleEntry()
  203. {
  204. m_fStrong = false;
  205. }
  206. };
  207. typedef std::map<MPC::wstringUC,TitleEntry> TitleMap;
  208. typedef TitleMap::iterator TitleIter;
  209. typedef TitleMap::const_iterator TitleIterConst;
  210. typedef std::list< CPCHHelpSessionItem* > List;
  211. typedef List::iterator Iter;
  212. typedef List::const_iterator IterConst;
  213. ////////////////////////////////////////
  214. private:
  215. friend class CPCHHelpSessionItem;
  216. CPCHHelpCenterExternal* m_parent;
  217. MPC::wstring m_szBackupFile;
  218. MPC::StorageObject m_disk;
  219. DATE m_dStartOfSession;
  220. CComPtr<IUrlHistoryStg> m_pIHistory; // For looking up URL titles.
  221. MPC::WStringUCList m_lstIgnore;
  222. TitleMap m_mapTitles;
  223. List m_lstVisitedPages;
  224. List m_lstCachedVisitedPages;
  225. CComPtr<CPCHHelpSessionItem> m_hsiCurrentPage;
  226. DWORD m_dwTravelling;
  227. bool m_fAlreadySaved;
  228. bool m_fAlreadyCreated;
  229. bool m_fOverwrite;
  230. DWORD m_dwIgnore;
  231. DWORD m_dwNoEvents;
  232. DATE m_dLastNavigation;
  233. int m_iLastIndex;
  234. long m_lContextID;
  235. CComBSTR m_bstrContextInfo;
  236. CComBSTR m_bstrContextURL;
  237. bool m_fPossibleBack;
  238. DWORD m_dwPossibleBack;
  239. ////////////////////////////////////////
  240. HRESULT Load ( );
  241. HRESULT Save ( );
  242. HRESULT Clone( /*[in]*/ CPCHHelpSession& hsCopy );
  243. HRESULT ItemState_GetIndexObject ( /*[in]*/ bool fCreate, /*[out]*/ MPC::StorageObject*& child );
  244. HRESULT ItemState_GetStorageObject( /*[in]*/ int iIndex, /*[in]*/ bool fCreate, /*[out]*/ MPC::StorageObject*& child );
  245. ////////////////////////////////////////
  246. #ifdef HSS_RPRD
  247. HRESULT DumpSession();
  248. #endif
  249. ////////////////////////////////////////
  250. HRESULT Erase();
  251. HRESULT ResetTitles();
  252. HRESULT FilterPages( /*[in]*/ HS_MODE hsMode, /*[out]*/ List& lstObject );
  253. CPCHHelpSessionItem* FindPage( /*[in]*/ BSTR bstrURL );
  254. CPCHHelpSessionItem* FindPage( /*[in]*/ IPCHHelpSessionItem* pHSI );
  255. CPCHHelpSessionItem* FindPage( /*[in]*/ int iIndex );
  256. ////////////////////////////////////////
  257. HRESULT LeaveCurrentPage( /*[in]*/ bool fSaveHistory = true , /*[in]*/ bool fClearPage = true );
  258. HRESULT FindTravelLog( /*[in]*/ long lLength, /*[out]*/ CPCHHelpSessionItem*& hsi );
  259. HRESULT Travel ( /*[in] */ CPCHHelpSessionItem* hsi );
  260. HRESULT Travel ( /*[in]*/ long lLength );
  261. HRESULT AllocateItem ( /*[in]*/ bool fNew, /*[in]*/ bool fLink, /*[in]*/ bool fNewIndex, /*[out]*/ CComPtr<CPCHHelpSessionItem>& hsi );
  262. HRESULT SetCurrentItem( /*[in]*/ bool fLink, /*[in ]*/ CPCHHelpSessionItem* hsi );
  263. HRESULT AppendToCached( /*[in ]*/ CPCHHelpSessionItem* hsi );
  264. ////////////////////////////////////////
  265. public:
  266. BEGIN_COM_MAP(CPCHHelpSession)
  267. COM_INTERFACE_ENTRY(IDispatch)
  268. COM_INTERFACE_ENTRY(IPCHHelpSession)
  269. END_COM_MAP()
  270. CPCHHelpSession();
  271. virtual ~CPCHHelpSession();
  272. HRESULT Initialize( /*[in]*/ CPCHHelpCenterExternal* parent );
  273. HRESULT Persist ( );
  274. void Passivate ( );
  275. CPCHHelpCenterExternal* GetParent() { return m_parent; }
  276. ////////////////////
  277. HRESULT ItemState_CreateStream( /*[in]*/ int iIndex, /*[out]*/ CComPtr<IStream>& stream );
  278. HRESULT ItemState_GetStream ( /*[in]*/ int iIndex, /*[out]*/ CComPtr<IStream>& stream );
  279. HRESULT ItemState_DeleteStream( /*[in]*/ int iIndex );
  280. HRESULT ForceHistoryPopulate();
  281. ////////////////////
  282. HRESULT RecordTitle( /*[in]*/ BSTR bstrURL, /*[in ]*/ BSTR bstrTitle, /*[in]*/ bool fStrong );
  283. HRESULT LookupTitle( /*[in]*/ BSTR bstrURL, /*[out]*/ CComBSTR& bstrTitle, /*[in]*/ bool fUseIECache );
  284. HRESULT RegisterContextSwitch ( /*[in]*/ HscContext iVal, /*[in]*/ BSTR bstrInfo, /*[in]*/ BSTR bstrURL, /*[out]*/ CPCHHelpSessionItem* *pVal = NULL );
  285. HRESULT RecordNavigationInAdvance( /*[in]*/ BSTR bstrURL );
  286. HRESULT DuplicateNavigation ( );
  287. HRESULT CancelNavigation ( );
  288. void SetThreshold ( );
  289. void CancelThreshold ( );
  290. bool HasThresholdExpired ( );
  291. bool IsUrlToIgnore ( /*[in]*/ LPCWSTR szURL, /*[in]*/ bool fRemove );
  292. HRESULT IgnoreUrl ( /*[in]*/ LPCWSTR szURL );
  293. HRESULT StartNavigation ( /*[in]*/ BSTR bstrURL, /*[in]*/ HscPanel idPanel );
  294. HRESULT CompleteNavigation ( /*[in]*/ HscPanel idPanel );
  295. bool IsTravelling() { return m_dwTravelling != 0; }
  296. CPCHHelpSessionItem* Current () { return m_hsiCurrentPage; }
  297. void PossibleBack ();
  298. bool IsPossibleBack();
  299. ////////////////////
  300. public:
  301. #ifdef DEBUG
  302. void DebugDump() const;
  303. #endif
  304. public:
  305. // IPCHHelpSession
  306. STDMETHOD(get_CurrentContext)( /*[out, retval]*/ IPCHHelpSessionItem* *ppHSI );
  307. STDMETHOD(VisitedHelpPages)( /*[in]*/ HS_MODE hsMode, /*[out, retval]*/ IPCHCollection* *ppC );
  308. STDMETHOD(SetTitle )( /*[in]*/ BSTR bstrURL, /*[in]*/ BSTR bstrTitle );
  309. STDMETHOD(ForceNavigation )( /*[in]*/ BSTR bstrURL );
  310. STDMETHOD(IgnoreNavigation)( );
  311. STDMETHOD(EraseNavigation )( );
  312. STDMETHOD(IsNavigating )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  313. STDMETHOD(Back )( /*[in]*/ long lLength );
  314. STDMETHOD(Forward )( /*[in]*/ long lLength );
  315. STDMETHOD(IsValid )( /*[in]*/ long lLength, /*[out, retval]*/ VARIANT_BOOL *pVal );
  316. STDMETHOD(Navigate)( /*[in]*/ IPCHHelpSessionItem* pHSI );
  317. STDMETHOD(ChangeContext)( /*[in]*/ BSTR bstrName, /*[in,optional]*/ VARIANT vInfo, /*[in,optional]*/ VARIANT vURL );
  318. };
  319. /////////////////////////////////////////////////////////////////////////////
  320. #endif // !defined(__INCLUDED___PCH___HELPSESSION_H___)