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.

172 lines
6.2 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. HyperLinksLib.h
  5. Abstract:
  6. This file contains the declaration of the HyperLinks library of classes.
  7. Revision History:
  8. Davide Massarenti (Dmassare) 11/28/2000
  9. created
  10. ******************************************************************************/
  11. #if !defined(__INCLUDED___PCH___HYPERLINKSLIB_H___)
  12. #define __INCLUDED___PCH___HYPERLINKSLIB_H___
  13. #include <MPC_COM.h>
  14. #include <MPC_Utils.h>
  15. #include <MPC_HTML.h>
  16. ////////////////////////////////////////////////////////////////////////////////
  17. namespace HyperLinks
  18. {
  19. typedef enum
  20. {
  21. FMT_INVALID ,
  22. FMT_INTERNET_UNKNOWN ,
  23. FMT_INTERNET_FTP , // InternetCrackUrl returned INTERNET_SCHEME_FTP
  24. FMT_INTERNET_GOPHER , // InternetCrackUrl returned INTERNET_SCHEME_GOPHER
  25. FMT_INTERNET_HTTP , // InternetCrackUrl returned INTERNET_SCHEME_HTTP
  26. FMT_INTERNET_HTTPS , // InternetCrackUrl returned INTERNET_SCHEME_HTTPS
  27. FMT_INTERNET_FILE , // InternetCrackUrl returned INTERNET_SCHEME_FILE
  28. FMT_INTERNET_NEWS , // InternetCrackUrl returned INTERNET_SCHEME_NEWS
  29. FMT_INTERNET_MAILTO , // InternetCrackUrl returned INTERNET_SCHEME_MAILTO
  30. FMT_INTERNET_SOCKS , // InternetCrackUrl returned INTERNET_SCHEME_SOCKS
  31. FMT_INTERNET_JAVASCRIPT, // InternetCrackUrl returned INTERNET_SCHEME_JAVASCRIPT
  32. FMT_INTERNET_VBSCRIPT , // InternetCrackUrl returned INTERNET_SCHEME_VBSCRIPT
  33. FMT_HCP , // hcp://<something>
  34. FMT_HCP_REDIR , // hcp:<something>
  35. FMT_MSITS , // ms-its:<file name>::/<stream name>
  36. FMT_CENTER_HOMEPAGE , // hcp://services/centers/homepage
  37. FMT_CENTER_SUPPORT , // hcp://services/centers/support
  38. FMT_CENTER_OPTIONS , // hcp://services/centers/options
  39. FMT_CENTER_UPDATE , // hcp://services/centers/update
  40. FMT_CENTER_COMPAT , // hcp://services/centers/compat
  41. FMT_CENTER_TOOLS , // hcp://services/centers/tools
  42. FMT_CENTER_ERRMSG , // hcp://services/centers/errmsg
  43. FMT_SEARCH , // hcp://services/search?query=<text to look up>
  44. FMT_INDEX , // hcp://services/index?application=<optional island of help ID>
  45. FMT_SUBSITE , // hcp://services/subsite?node=<subsite location>&topic=<url of the topic to display>&select=<subnode to highlight>
  46. FMT_LAYOUT_FULLWINDOW , // hcp://services/layout/fullwindow?topic=<url of the topic to display>
  47. FMT_LAYOUT_CONTENTONLY , // hcp://services/layout/contentonly?topic=<url of the topic to display>
  48. FMT_LAYOUT_KIOSK , // hcp://services/layout/kiosk?topic=<url of the topic to display>
  49. FMT_LAYOUT_XML , // hcp://services/layout/xml?definition=<url of the layout definition>&topic=<url of the topic to display>
  50. FMT_REDIRECT , // hcp://services/redirect?online=<url>&offline=<backup url>
  51. FMT_APPLICATION , // app:<application to launch>?arg=<optional arguments>&topic=<url of optional topic to display>
  52. FMT_RESOURCE , // res://<file path>/<resource name>
  53. } Format;
  54. typedef enum
  55. {
  56. STATE_INVALID ,
  57. STATE_NOTPROCESSED,
  58. STATE_CHECKING ,
  59. STATE_MALFORMED ,
  60. STATE_ALIVE ,
  61. STATE_NOTFOUND ,
  62. STATE_UNREACHABLE ,
  63. STATE_OFFLINE ,
  64. } State;
  65. ////////////////////
  66. struct ParsedUrl
  67. {
  68. MPC::wstring m_strURL;
  69. Format m_fmt;
  70. State m_state;
  71. DATE m_dLastChecked;
  72. bool m_fBackground;
  73. MPC::wstring m_strBasePart;
  74. MPC::WStringLookup m_mapQuery;
  75. ////////////////////
  76. ParsedUrl();
  77. HRESULT Initialize( /*[in]*/ LPCWSTR szURL );
  78. bool IsLocal ( );
  79. State CheckState ( /*[in/out]*/ bool& fFirstWinInetUse );
  80. bool IsOkToProceed( );
  81. bool HasQueryField( /*[in]*/ LPCWSTR szField );
  82. bool GetQueryField( /*[in]*/ LPCWSTR szField, /*[in]*/ CComBSTR& bstrValue );
  83. };
  84. class UrlHandle
  85. {
  86. friend class Lookup;
  87. Lookup* m_main; // We have a lock on it.
  88. ParsedUrl* m_pu;
  89. void Attach( /*[in]*/ Lookup* main, /*[in]*/ ParsedUrl* pu );
  90. public:
  91. UrlHandle();
  92. ~UrlHandle();
  93. void Release();
  94. operator ParsedUrl*() { return m_pu; }
  95. ParsedUrl* operator->() { return m_pu; }
  96. };
  97. class Lookup :
  98. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>, // For locking...
  99. public MPC::Thread< Lookup, IUnknown >
  100. {
  101. typedef std::list<ParsedUrl*> PendingUrlList;
  102. typedef PendingUrlList::iterator PendingUrlIter;
  103. typedef PendingUrlList::const_iterator PendingUrlIterConst;
  104. typedef std::map<MPC::wstringUC,ParsedUrl> UrlMap;
  105. typedef UrlMap::iterator UrlIter;
  106. typedef UrlMap::const_iterator UrlIterConst;
  107. PendingUrlList m_lst;
  108. UrlMap m_map;
  109. HRESULT RunChecker();
  110. HRESULT CreateItem( /*[in]*/ LPCWSTR szURL, /*[out]*/ ParsedUrl*& pu );
  111. public:
  112. Lookup();
  113. ~Lookup();
  114. ////////////////////////////////////////////////////////////////////////////////
  115. static Lookup* s_GLOBAL;
  116. static HRESULT InitializeSystem();
  117. static void FinalizeSystem ();
  118. ////////////////////////////////////////////////////////////////////////////////
  119. HRESULT Queue( /*[in]*/ LPCWSTR szURL );
  120. HRESULT Get ( /*[in]*/ LPCWSTR szURL, /*[in]*/ UrlHandle& uh, /*[in]*/ DWORD dwWaitForCheck = 0, /*[in]*/ bool fForce = false );
  121. };
  122. HRESULT IsValid( /*[in/out]*/ LPCWSTR szURL );
  123. };
  124. ////////////////////////////////////////////////////////////////////////////////
  125. #endif // !defined(__INCLUDED___PCH___HYPERLINKSLIB_H___)