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.

274 lines
7.0 KiB

  1. /*
  2. File: PlgProt.h
  3. Copyright (c) 1997-1999 Microsoft Corporation. All Rights Reserved.
  4. Abstract:
  5. DHTMLEd Pluggable Protocol
  6. History:
  7. 06/26/97 Cgomes - ported from trident
  8. 03/20/98 Vank - ported from VID/htmed
  9. */
  10. #if !defined __INC_PLGPROT_H__
  11. #define __INC_PLGPRO_H__
  12. #if _MSC_VER >= 1000
  13. #pragma once
  14. #endif // _MSC_VER >= 1000
  15. #include "resource.h"
  16. #include "dhtmled.h"
  17. #include "proxyframe.h"
  18. #include "private.h"
  19. EXTERN_C const CLSID CLSID_DHTMLEdProtocolInfo;
  20. EXTERN_C const CLSID CLSID_DHTMLEdProtocol;
  21. #define BIND_ASYNC 1
  22. #define ExpectedExpr(expr) \
  23. _ASSERTE((expr)); \
  24. if(!(expr)) \
  25. { return E_UNEXPECTED; }
  26. #define ExpectedPtr(ptr) \
  27. _ASSERTE(ptr != NULL); \
  28. if(ptr == NULL) \
  29. { return E_UNEXPECTED; }
  30. #define InitParam(param) \
  31. if(param != NULL) \
  32. { *param = NULL; }
  33. #define IfNullRet(param) \
  34. _ASSERTE(param != NULL); \
  35. if(param == NULL) \
  36. { return E_INVALIDARG; }
  37. #define IfNullGo(param) \
  38. _ASSERTE(param != NULL); \
  39. if(param == NULL) \
  40. { goto ONERROR; }
  41. #define IfFailGo(hr) \
  42. _ASSERTE(SUCCEEDED(hr)); \
  43. if(FAILED(hr)) \
  44. goto ONERROR;
  45. #define _IfFailGo(hr) \
  46. if(FAILED(hr)) \
  47. goto ONERROR;
  48. #define IfFailRet(hr) \
  49. _ASSERTE(SUCCEEDED(hr)); \
  50. if(FAILED(hr)) \
  51. { return hr; }
  52. #define IfNullPtrGo(ptr) \
  53. _ASSERTE(ptr != NULL); \
  54. if(ptr == NULL) \
  55. { hr = E_POINTER; goto ONERROR;}
  56. #define AtlCreateInstance(ClassName, iid, ppUnk) \
  57. { \
  58. CComObject<ClassName> *pObject = NULL; \
  59. if(SUCCEEDED(CComObject<ClassName>::CreateInstance(&pObject)) && \
  60. pObject != NULL) \
  61. { \
  62. if(FAILED(pObject->GetUnknown()->QueryInterface(iid, (void**) ppUnk))) \
  63. { \
  64. *ppUnk = NULL; \
  65. } \
  66. } \
  67. }
  68. #define dimensionof(a) (sizeof(a)/sizeof(*(a)))
  69. //////////////////////////////////////////////////////////////////////////////
  70. //
  71. // DHTMLEd ProtocolInfo class
  72. //
  73. class ATL_NO_VTABLE CDHTMLEdProtocolInfo :
  74. public CComObjectRootEx<CComMultiThreadModel>,
  75. public IClassFactory,
  76. public IInternetProtocolInfo,
  77. public IProtocolInfoConnector
  78. {
  79. public:
  80. //DECLARE_POLY_AGGREGATABLE(CDHTMLEdProtocolInfo)
  81. //DECLARE_GET_CONTROLLING_UNKNOWN()
  82. BEGIN_COM_MAP(CDHTMLEdProtocolInfo)
  83. COM_INTERFACE_ENTRY(IClassFactory)
  84. COM_INTERFACE_ENTRY(IInternetProtocolInfo)
  85. COM_INTERFACE_ENTRY(IProtocolInfoConnector)
  86. END_COM_MAP()
  87. //
  88. // IClassFactory methods
  89. //
  90. STDMETHODIMP CreateInstance(IUnknown * pUnkOuter, REFIID riid, void **ppvObject);
  91. STDMETHODIMP RemoteCreateInstance( REFIID riid, IUnknown ** ppvObject);
  92. STDMETHODIMP LockServer(BOOL fLock);
  93. STDMETHODIMP RemoteLockServer(BOOL fLock);
  94. //
  95. // IInternetProtocolInfo methods
  96. //
  97. STDMETHODIMP CombineUrl(LPCWSTR pwzBaseUrl,
  98. LPCWSTR pwzRelativeUrl,
  99. DWORD dwFlags,
  100. LPWSTR pwzResult,
  101. DWORD cchResult,
  102. DWORD * pcchResult,
  103. DWORD dwReserved);
  104. STDMETHODIMP CompareUrl(LPCWSTR pwzUrl1,
  105. LPCWSTR pwzUrl2,
  106. DWORD dwFlags);
  107. STDMETHODIMP ParseUrl(LPCWSTR pwzUrl,
  108. PARSEACTION ParseAction,
  109. DWORD dwFlags,
  110. LPWSTR pwzResult,
  111. DWORD cchResult,
  112. DWORD * pcchResult,
  113. DWORD dwReserved);
  114. STDMETHODIMP QueryInfo(LPCWSTR pwzUrl,
  115. QUERYOPTION QueryOption,
  116. DWORD dwQueryFlags,
  117. LPVOID pBuffer,
  118. DWORD cbBuffer,
  119. DWORD * pcbBuf,
  120. DWORD dwReserved);
  121. // IProtocolInfoConnector methods
  122. STDMETHODIMP SetProxyFrame ( SIZE_T* vpProxyFrame );
  123. //
  124. // Data members
  125. //
  126. private:
  127. BOOL m_fZombied:1;
  128. CProxyFrame* m_pProxyFrame;
  129. IProtocolInfoConnector* m_piProtocolConIntf;
  130. //
  131. // constructor
  132. //
  133. public:
  134. CDHTMLEdProtocolInfo();
  135. ~CDHTMLEdProtocolInfo();
  136. void Zombie();
  137. #if defined _DEBUG_ADDREF_RELEASE
  138. public:
  139. ULONG InternalAddRef()
  140. {
  141. ATLTRACE(_T("CDHTMLEdProtocolInfo Ref %d>\n"), m_dwRef+1);
  142. _ASSERTE(m_dwRef != -1L);
  143. return _ThreadModel::Increment(&m_dwRef);
  144. }
  145. ULONG InternalRelease()
  146. {
  147. ATLTRACE(_T("CDHTMLEdProtocolInfo Ref %d<\n"), m_dwRef-1);
  148. return _ThreadModel::Decrement(&m_dwRef);
  149. }
  150. #endif
  151. };
  152. //////////////////////////////////////////////////////////////////////////////
  153. //
  154. // DHTMLEd Protocol class
  155. //
  156. class ATL_NO_VTABLE CDHTMLEdProtocol :
  157. public CComObjectRootEx<CComMultiThreadModel>,
  158. public CComCoClass<CDHTMLEdProtocol, &CLSID_DHTMLEdProtocol>,
  159. public IInternetProtocol,
  160. public IProtocolInfoConnector
  161. {
  162. public:
  163. DECLARE_POLY_AGGREGATABLE(CDHTMLEdProtocol)
  164. DECLARE_GET_CONTROLLING_UNKNOWN()
  165. BEGIN_COM_MAP(CDHTMLEdProtocol)
  166. COM_INTERFACE_ENTRY(IInternetProtocol)
  167. COM_INTERFACE_ENTRY(IProtocolInfoConnector)
  168. END_COM_MAP()
  169. //
  170. // IInternetProtocol methods
  171. //
  172. STDMETHOD(LockRequest)(DWORD dwOptions);
  173. STDMETHOD(Read)(void *pv,ULONG cb,ULONG *pcbRead);
  174. STDMETHOD(Seek)(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
  175. STDMETHOD(UnlockRequest)();
  176. //
  177. // IInternetProtocolRoot methods
  178. //
  179. STDMETHOD(Abort)(HRESULT hrReason,DWORD dwOptions);
  180. STDMETHOD(Continue)(PROTOCOLDATA *pStateInfo);
  181. STDMETHOD(Resume)();
  182. STDMETHOD(Start)(LPCWSTR szUrl, IInternetProtocolSink *pProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfSTI, HANDLE_PTR dwReserved);
  183. STDMETHOD(Suspend)();
  184. STDMETHOD(Terminate)(DWORD dwOptions);
  185. // IProtocolInfoConnector methods
  186. STDMETHODIMP SetProxyFrame ( SIZE_T* vpProxyFrame );
  187. //
  188. // Data members
  189. //
  190. private:
  191. CComPtr<IInternetProtocolSink> m_srpSink; // The protocol sink
  192. CComPtr<IInternetBindInfo> m_srpBindInfo; // The Bind info
  193. CComPtr<IStream> m_srpStream; // Buffer Stream
  194. CComBSTR m_bstrBaseURL; // BaseURL of buffer
  195. DWORD m_bscf;
  196. DWORD m_grfBindF;
  197. DWORD m_grfSTI;
  198. BINDINFO m_bindinfo;
  199. BOOL m_fAborted:1;
  200. BOOL m_fZombied:1;
  201. CProxyFrame* m_pProxyFrame;
  202. //
  203. // constructor
  204. //
  205. public:
  206. CDHTMLEdProtocol();
  207. ~CDHTMLEdProtocol();
  208. void Zombie();
  209. //
  210. // Method members
  211. //
  212. private:
  213. HRESULT ParseAndBind();
  214. void ReportData(ULONG cb);
  215. #if defined _DEBUG_ADDREF_RELEASE
  216. public:
  217. ULONG InternalAddRef()
  218. {
  219. ATLTRACE(_T("CDHTMLEdProtocol Ref %d>\n"), m_dwRef+1);
  220. _ASSERTE(m_dwRef != -1L);
  221. return _ThreadModel::Increment(&m_dwRef);
  222. }
  223. ULONG InternalRelease()
  224. {
  225. ATLTRACE(_T("CDHTMLEdProtocol Ref %d<\n"), m_dwRef-1);
  226. return _ThreadModel::Decrement(&m_dwRef);
  227. }
  228. #endif
  229. };
  230. #endif __INC_PLGPRO_H__
  231. /* end of file*/