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.

277 lines
14 KiB

  1. // --------------------------------------------------------------------------------
  2. // MHTMLURL.H
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // Steven J. Bailey
  5. // --------------------------------------------------------------------------------
  6. #ifndef __MHTMLURL_H
  7. #define __MHTMLURL_H
  8. #ifndef MAC
  9. // --------------------------------------------------------------------------------
  10. // Depends
  11. // --------------------------------------------------------------------------------
  12. #include "privunk.h"
  13. #include "inetprot.h"
  14. // --------------------------------------------------------------------------------
  15. // Forward Decls
  16. // --------------------------------------------------------------------------------
  17. class CMessageTree;
  18. typedef CMessageTree *LPMESSAGETREE;
  19. class CMimeActiveUrlCache;
  20. typedef class CActiveUrlRequest *LPURLREQUEST;
  21. // --------------------------------------------------------------------------------
  22. // Global Active Url Cache Object
  23. // --------------------------------------------------------------------------------
  24. extern CMimeActiveUrlCache *g_pUrlCache;
  25. // --------------------------------------------------------------------------------
  26. // REQSTATE_xxxx States
  27. // --------------------------------------------------------------------------------
  28. #define REQSTATE_RESULTREPORTED 0x00000001 // I have called ReportResult, don't call again
  29. #define REQSTATE_DOWNLOADED 0x00000002 // The data is all present in pLockBytes
  30. #define REQSTATE_BINDF_NEEDFILE 0x00000004 // Need to use a file
  31. // --------------------------------------------------------------------------------
  32. // CActiveUrlRequest
  33. // --------------------------------------------------------------------------------
  34. class CActiveUrlRequest : public CPrivateUnknown,
  35. public IOInetProtocol,
  36. public IOInetProtocolInfo,
  37. public IServiceProvider
  38. {
  39. public:
  40. // ----------------------------------------------------------------------------
  41. // Construction
  42. // ----------------------------------------------------------------------------
  43. CActiveUrlRequest(IUnknown *pUnkOuter=NULL);
  44. virtual ~CActiveUrlRequest(void);
  45. // ---------------------------------------------------------------------------
  46. // IUnknown members
  47. // ---------------------------------------------------------------------------
  48. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj) {
  49. return CPrivateUnknown::QueryInterface(riid, ppvObj); };
  50. virtual STDMETHODIMP_(ULONG) AddRef(void) {
  51. return CPrivateUnknown::AddRef();};
  52. virtual STDMETHODIMP_(ULONG) Release(void) {
  53. return CPrivateUnknown::Release(); };
  54. // ----------------------------------------------------------------------------
  55. // IOInetProtocol methods
  56. // ----------------------------------------------------------------------------
  57. STDMETHODIMP Start(LPCWSTR pwszUrl, IOInetProtocolSink *pProtSink, IOInetBindInfo *pBindInfo, DWORD grfSTI, HANDLE_PTR dwReserved);
  58. STDMETHODIMP Terminate(DWORD dwOptions);
  59. STDMETHODIMP Read(LPVOID pv,ULONG cb, ULONG *pcbRead);
  60. STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
  61. STDMETHODIMP LockRequest(DWORD dwOptions) { return E_NOTIMPL; }
  62. STDMETHODIMP UnlockRequest(void) { return E_NOTIMPL; }
  63. STDMETHODIMP Suspend(void) { return E_NOTIMPL; }
  64. STDMETHODIMP Resume(void) { return E_NOTIMPL; }
  65. STDMETHODIMP Abort(HRESULT hrReason, DWORD dwOptions) { return E_NOTIMPL; }
  66. STDMETHODIMP Continue(PROTOCOLDATA *pStateInfo) { return E_NOTIMPL; }
  67. // ----------------------------------------------------------------------------
  68. // IServiceProvider methods
  69. // ----------------------------------------------------------------------------
  70. STDMETHODIMP QueryService(REFGUID rsid, REFIID riid, void **ppvObj); /* IServiceProvider */
  71. // ----------------------------------------------------------------------------
  72. // IOInetProtocolInfo methods
  73. // ----------------------------------------------------------------------------
  74. STDMETHODIMP CombineUrl(LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved);
  75. STDMETHODIMP ParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved);
  76. STDMETHODIMP CompareUrl(LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags) { return E_NOTIMPL; }
  77. STDMETHODIMP QueryInfo(LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved);
  78. // ----------------------------------------------------------------------------
  79. // Called from CMimeMessageTree during Binding
  80. // ----------------------------------------------------------------------------
  81. void OnFullyAvailable(LPCWSTR pszCntType, IStream *pStream, LPMESSAGETREE pWebBook, HBODY hBody);
  82. // Async Binding Methods
  83. void OnStartBinding(LPCWSTR pszCntType, IStream *pStream, LPMESSAGETREE pWebBook, HBODY hBody);
  84. void OnBindingDataAvailable(void);
  85. void OnBindingComplete(HRESULT hrResult);
  86. // ----------------------------------------------------------------------------
  87. // CActiveUrlRequest Members
  88. // ----------------------------------------------------------------------------
  89. virtual HRESULT PrivateQueryInterface(REFIID riid, LPVOID * ppvObj);
  90. private:
  91. // ----------------------------------------------------------------------------
  92. // Private Methods
  93. // ----------------------------------------------------------------------------
  94. void _ReportResult(HRESULT hrResult);
  95. HRESULT _FillReturnString(LPCWSTR pszUrl, DWORD cchUrl, LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult);
  96. HRESULT _HrStreamToNeedFile(void);
  97. HRESULT _HrReportData(void);
  98. HRESULT _HrInitializeNeedFile(LPMESSAGETREE pTree, HBODY hBody);
  99. private:
  100. // ----------------------------------------------------------------------------
  101. // Private Data
  102. // ----------------------------------------------------------------------------
  103. IOInetProtocolSink *m_pProtSink; // Protocol Sink from IOInetProtocol::Start
  104. IOInetBindInfo *m_pBindInfo; // BindInfo from IOInetProtocol::Start
  105. IStream *m_pStream; // The data source
  106. LPSTR m_pszRootUrl; // Root document Url
  107. LPSTR m_pszBodyUrl; // Body Url
  108. IUnknown *m_pUnkKeepAlive; // This protocol may activate an object
  109. LPURLREQUEST m_pNext; // Next Request
  110. LPURLREQUEST m_pPrev; // Prev Request
  111. DWORD m_dwState; // Keep track of some state
  112. HANDLE m_hNeedFile; // Need File
  113. DWORD m_dwBSCF; // Bind Status Callback Flags That I've Reported
  114. CRITICAL_SECTION m_cs; // Thread Safety
  115. // ----------------------------------------------------------------------------
  116. // Friend
  117. // ----------------------------------------------------------------------------
  118. friend CMessageTree; // Accesses, m_pszRootUrl, m_pNext, m_pPrev
  119. };
  120. // --------------------------------------------------------------------------------
  121. // ACTIVEURL_xxx
  122. // --------------------------------------------------------------------------------
  123. #define ACTIVEURL_ISFAKEURL 0x00000001 // Specifies that the activeurl is a mid
  124. // --------------------------------------------------------------------------------
  125. // CActiveUrl
  126. // --------------------------------------------------------------------------------
  127. class CActiveUrl : public IUnknown
  128. {
  129. public:
  130. // ----------------------------------------------------------------------------
  131. // Construction
  132. // ----------------------------------------------------------------------------
  133. CActiveUrl(void);
  134. ~CActiveUrl(void);
  135. // ---------------------------------------------------------------------------
  136. // IUnknown members
  137. // ---------------------------------------------------------------------------
  138. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  139. STDMETHODIMP_(ULONG) AddRef(void);
  140. STDMETHODIMP_(ULONG) Release(void);
  141. // ---------------------------------------------------------------------------
  142. // CActiveUrl Members
  143. // ---------------------------------------------------------------------------
  144. HRESULT Init(BINDF bindf, LPMESSAGETREE pWebBook);
  145. HRESULT IsActive(void);
  146. HRESULT CompareRootUrl(LPCSTR pszUrl);
  147. HRESULT BindToObject(REFIID riid, LPVOID *ppv);
  148. HRESULT CreateWebPage(IStream *pStmRoot, LPWEBPAGEOPTIONS pOptions, DWORD dwReserved, IMoniker **ppMoniker);
  149. void RevokeWebBook(LPMESSAGETREE pWebBook);
  150. CActiveUrl *PGetNext(void) { return m_pNext; }
  151. CActiveUrl *PGetPrev(void) { return m_pPrev; }
  152. void SetNext(CActiveUrl *pNext) { m_pNext = pNext; }
  153. void SetPrev(CActiveUrl *pPrev) { m_pPrev = pPrev; }
  154. void DontKeepAlive(void);
  155. // ---------------------------------------------------------------------------
  156. // CActiveUrl Inline Members
  157. // ---------------------------------------------------------------------------
  158. void SetFlag(DWORD dwFlags) {
  159. EnterCriticalSection(&m_cs);
  160. FLAGSET(m_dwFlags, dwFlags);
  161. LeaveCriticalSection(&m_cs);
  162. }
  163. BOOL FIsFlagSet(DWORD dwFlags) {
  164. EnterCriticalSection(&m_cs);
  165. BOOL f = ISFLAGSET(m_dwFlags, dwFlags);
  166. LeaveCriticalSection(&m_cs);
  167. return f;
  168. }
  169. private:
  170. // ---------------------------------------------------------------------------
  171. // Private Data
  172. // ---------------------------------------------------------------------------
  173. LONG m_cRef; // Reference Count
  174. IUnknown *m_pUnkAlive; // Keep it alive
  175. IUnknown *m_pUnkInner; // The ActiveUrl's Inner Unknown
  176. LPMESSAGETREE m_pWebBook; // Pointer to the active Url
  177. CActiveUrl *m_pNext; // Next Active Url
  178. CActiveUrl *m_pPrev; // Prev Active Url
  179. DWORD m_dwFlags; // Flags
  180. CRITICAL_SECTION m_cs; // Thread Safety
  181. };
  182. typedef CActiveUrl *LPACTIVEURL;
  183. // --------------------------------------------------------------------------------
  184. // CMimeActiveUrlCache
  185. // --------------------------------------------------------------------------------
  186. class CMimeActiveUrlCache : public IUnknown
  187. {
  188. public:
  189. // ----------------------------------------------------------------------------
  190. // Construction
  191. // ----------------------------------------------------------------------------
  192. CMimeActiveUrlCache(void);
  193. ~CMimeActiveUrlCache(void);
  194. // ---------------------------------------------------------------------------
  195. // IUnknown members
  196. // ---------------------------------------------------------------------------
  197. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  198. STDMETHODIMP_(ULONG) AddRef(void);
  199. STDMETHODIMP_(ULONG) Release(void);
  200. // ---------------------------------------------------------------------------
  201. // ObjectFromMoniker - Called from Trident
  202. // ---------------------------------------------------------------------------
  203. HRESULT ActiveObjectFromMoniker(
  204. /* in */ BINDF bindf,
  205. /* in */ IMoniker *pmkOriginal,
  206. /* in */ IBindCtx *pBindCtx,
  207. /* in */ REFIID riid,
  208. /* out */ LPVOID *ppvObject,
  209. /* out */ IMoniker **ppmkNew);
  210. // ---------------------------------------------------------------------------
  211. // ObjectFromUrl - Called from CActiveUrlRequest::Start
  212. // ---------------------------------------------------------------------------
  213. HRESULT ActiveObjectFromUrl(
  214. /* in */ LPCSTR pszRootUrl,
  215. /* in */ BOOL fCreate,
  216. /* in */ REFIID riid,
  217. /* out */ LPVOID *ppvObject,
  218. /* out */ IUnknown **ppUnkKeepAlive);
  219. // ---------------------------------------------------------------------------
  220. // RegisterActiveObject - Called from CMimeMessageTree::CreateRootMoniker
  221. // ---------------------------------------------------------------------------
  222. HRESULT RegisterActiveObject(
  223. /* in */ LPCSTR pszRootUrl,
  224. /* in */ LPMESSAGETREE pWebBook);
  225. HRESULT RemoveUrl(LPACTIVEURL pActiveUrl);
  226. private:
  227. // ---------------------------------------------------------------------------
  228. // Memory
  229. // ---------------------------------------------------------------------------
  230. void _FreeActiveUrlList(BOOL fAll);
  231. void _HandlePragmaNoCache(BINDF bindf, LPCSTR pszUrl);
  232. HRESULT _RegisterUrl(LPMESSAGETREE pWebBook, BINDF bindf, LPACTIVEURL *ppActiveUrl);
  233. HRESULT _ResolveUrl(LPCSTR pszUrl, LPACTIVEURL *ppActiveUrl);
  234. HRESULT _RemoveUrl(LPACTIVEURL pActiveUrl);
  235. private:
  236. // ---------------------------------------------------------------------------
  237. // Private Data
  238. // ---------------------------------------------------------------------------
  239. LONG m_cRef; // Reference Count
  240. ULONG m_cActive; // Number of active items
  241. LPACTIVEURL m_pHead; // Head Active Url
  242. CRITICAL_SECTION m_cs; // Thread Safety
  243. };
  244. #endif // !MAC
  245. #endif // __MHTMLURL_H