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.

174 lines
6.4 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. bool m_hcpRedir;
  76. ////////////////////
  77. ParsedUrl();
  78. HRESULT Initialize( /*[in]*/ LPCWSTR szURL );
  79. bool IsLocal ( );
  80. State CheckState ( /*[in/out]*/ bool& fFirstWinInetUse );
  81. bool IsOkToProceed( );
  82. bool HasQueryField( /*[in]*/ LPCWSTR szField );
  83. bool GetQueryField( /*[in]*/ LPCWSTR szField, /*[in]*/ CComBSTR& bstrValue );
  84. };
  85. class UrlHandle
  86. {
  87. friend class Lookup;
  88. Lookup* m_main; // We have a lock on it.
  89. ParsedUrl* m_pu;
  90. void Attach( /*[in]*/ Lookup* main, /*[in]*/ ParsedUrl* pu );
  91. public:
  92. UrlHandle();
  93. ~UrlHandle();
  94. void Release();
  95. operator ParsedUrl*() { return m_pu; }
  96. ParsedUrl* operator->() { return m_pu; }
  97. };
  98. class Lookup :
  99. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>, // For locking...
  100. public MPC::Thread< Lookup, IUnknown >
  101. {
  102. typedef std::list<ParsedUrl*> PendingUrlList;
  103. typedef PendingUrlList::iterator PendingUrlIter;
  104. typedef PendingUrlList::const_iterator PendingUrlIterConst;
  105. typedef std::map<MPC::wstringUC,ParsedUrl> UrlMap;
  106. typedef UrlMap::iterator UrlIter;
  107. typedef UrlMap::const_iterator UrlIterConst;
  108. PendingUrlList m_lst;
  109. UrlMap m_map;
  110. HRESULT RunChecker();
  111. HRESULT CreateItem( /*[in]*/ LPCWSTR szURL, /*[out]*/ ParsedUrl*& pu );
  112. public:
  113. Lookup();
  114. ~Lookup();
  115. ////////////////////////////////////////////////////////////////////////////////
  116. static Lookup* s_GLOBAL;
  117. static HRESULT InitializeSystem();
  118. static void FinalizeSystem ();
  119. ////////////////////////////////////////////////////////////////////////////////
  120. HRESULT Queue( /*[in]*/ LPCWSTR szURL );
  121. HRESULT Get ( /*[in]*/ LPCWSTR szURL, /*[in]*/ UrlHandle& uh, /*[in]*/ DWORD dwWaitForCheck = 0, /*[in]*/ bool fForce = false );
  122. };
  123. HRESULT IsValid( /*[in/out]*/ LPCWSTR szURL );
  124. };
  125. ////////////////////////////////////////////////////////////////////////////////
  126. #endif // !defined(__INCLUDED___PCH___HYPERLINKSLIB_H___)