Left: | ||
Right: |
OLD | NEW |
---|---|
1 #ifndef PASSTHROUGHAPP_PROTOCOLIMPL_INL | 1 #ifndef PASSTHROUGHAPP_PROTOCOLIMPL_INL |
2 #define PASSTHROUGHAPP_PROTOCOLIMPL_INL | 2 #define PASSTHROUGHAPP_PROTOCOLIMPL_INL |
3 | 3 |
4 #if _MSC_VER > 1000 | 4 #if _MSC_VER > 1000 |
5 » #pragma once | 5 #pragma once |
6 #endif // _MSC_VER > 1000 | 6 #endif // _MSC_VER > 1000 |
7 | 7 |
8 #ifndef PASSTHROUGHAPP_PROTOCOLIMPL_H | 8 #ifndef PASSTHROUGHAPP_PROTOCOLIMPL_H |
9 » #error ProtocolImpl.inl requires ProtocolImpl.h to be included first | 9 #error ProtocolImpl.inl requires ProtocolImpl.h to be included first |
10 #endif | 10 #endif |
11 | 11 |
12 namespace PassthroughAPP | 12 namespace PassthroughAPP |
13 { | 13 { |
14 | 14 |
15 namespace Detail | 15 namespace Detail |
16 { | 16 { |
17 | 17 |
18 #ifdef WIN64 | 18 #ifdef WIN64 |
19 » template <class T> | 19 template <class T> |
20 inline HRESULT WINAPI QIPassthrough<T>:: | 20 inline HRESULT WINAPI QIPassthrough<T>:: |
21 » QueryInterfacePassthroughT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw) | 21 QueryInterfacePassthroughT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR d w) |
22 #else | 22 #else |
23 | 23 |
24 template <class T> | 24 template <class T> |
25 inline HRESULT WINAPI QIPassthrough<T>:: | 25 inline HRESULT WINAPI QIPassthrough<T>:: |
26 » QueryInterfacePassthroughT(void* pv, REFIID riid, LPVOID* ppv, DWORD dw) | 26 QueryInterfacePassthroughT(void* pv, REFIID riid, LPVOID* ppv, DWORD dw) |
27 #endif | 27 #endif |
28 { | 28 { |
29 » ATLASSERT(pv != 0); | 29 ATLASSERT(pv != 0); |
30 » T* pT = static_cast<T*>(pv); | 30 T* pT = static_cast<T*>(pv); |
31 | 31 |
32 » IUnknown* punkTarget = pT->GetTargetUnknown(); | 32 IUnknown* punkTarget = pT->GetTargetUnknown(); |
33 » ATLASSERT(punkTarget != 0); | 33 ATLASSERT(punkTarget != 0); |
34 » if (!punkTarget) | 34 if (!punkTarget) |
35 » { | 35 { |
36 » » ATLTRACE(_T("Interface queried before target unknown is set")); | 36 ATLTRACE(_T("Interface queried before target unknown is set")); |
37 » » return E_UNEXPECTED; | 37 return E_UNEXPECTED; |
38 » } | 38 } |
39 | 39 |
40 » IUnknown* punkWrapper = pT->GetUnknown(); | 40 IUnknown* punkWrapper = pT->GetUnknown(); |
41 | 41 |
42 » typename T::ObjectLock lock(pT); | 42 typename T::ObjectLock lock(pT); |
43 » return QueryInterfacePassthrough( | 43 return QueryInterfacePassthrough( |
44 » » pv, riid, ppv, dw, punkTarget, punkWrapper); | 44 pv, riid, ppv, dw, punkTarget, punkWrapper); |
45 } | 45 } |
46 #ifdef WIN64 | 46 #ifdef WIN64 |
47 template <class T> | 47 template <class T> |
48 inline HRESULT WINAPI QIPassthrough<T>:: | 48 inline HRESULT WINAPI QIPassthrough<T>:: |
49 » QueryInterfaceDebugT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw) | 49 QueryInterfaceDebugT(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw) |
50 #else | 50 #else |
51 template <class T> | 51 template <class T> |
52 inline HRESULT WINAPI QIPassthrough<T>:: | 52 inline HRESULT WINAPI QIPassthrough<T>:: |
53 » QueryInterfaceDebugT(void* pv, REFIID riid, LPVOID* ppv, DWORD dw) | 53 QueryInterfaceDebugT(void* pv, REFIID riid, LPVOID* ppv, DWORD dw) |
54 #endif | 54 #endif |
55 { | 55 { |
56 » ATLASSERT(pv != 0); | 56 ATLASSERT(pv != 0); |
57 » T* pT = static_cast<T*>(pv); | 57 T* pT = static_cast<T*>(pv); |
58 | 58 |
59 » IUnknown* punkTarget = pT->GetTargetUnknown(); | 59 IUnknown* punkTarget = pT->GetTargetUnknown(); |
60 //» ATLASSERT(punkTarget != 0); | 60 //» ATLASSERT(punkTarget != 0); |
61 » if (!punkTarget) | 61 if (!punkTarget) |
62 » { | 62 { |
63 //» » ATLTRACE(_T("Interface queried before target unknown is set")); | 63 //» » ATLTRACE(_T("Interface queried before target unknown is set")); |
64 » » return E_UNEXPECTED; | 64 return E_UNEXPECTED; |
65 » } | 65 } |
66 | 66 |
67 » typename T::ObjectLock lock(pT); | 67 typename T::ObjectLock lock(pT); |
68 | 68 |
69 » return QueryInterfaceDebug(pv, riid, ppv, dw, punkTarget); | 69 return QueryInterfaceDebug(pv, riid, ppv, dw, punkTarget); |
70 } | 70 } |
71 #ifdef WIN64 | 71 #ifdef WIN64 |
72 inline HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid, | 72 inline HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid, |
73 » LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper) | 73 LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget, IUnknown* punkWrapper) |
74 #else | 74 #else |
75 inline HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid, | 75 inline HRESULT WINAPI QueryInterfacePassthrough(void* pv, REFIID riid, |
76 » LPVOID* ppv, DWORD dw, IUnknown* punkTarget, IUnknown* punkWrapper) | 76 LPVOID* ppv, DWORD dw, IUnknown* punkTarget, IUnknown* punkWrapper) |
77 #endif | 77 #endif |
78 { | 78 { |
79 ATLASSERT(pv != 0); | 79 ATLASSERT(pv != 0); |
80 ATLASSERT(ppv != 0); | 80 ATLASSERT(ppv != 0); |
81 ATLASSERT(dw != 0); | 81 ATLASSERT(dw != 0); |
82 ATLASSERT(punkTarget != 0); | 82 ATLASSERT(punkTarget != 0); |
83 | 83 |
84 | 84 |
85 const PassthroughItfData& data = | 85 const PassthroughItfData& data = |
86 *reinterpret_cast<const PassthroughItfData*>(dw); | 86 *reinterpret_cast<const PassthroughItfData*>(dw); |
87 | 87 |
88 IUnknown** ppUnk = reinterpret_cast<IUnknown**>( | 88 IUnknown** ppUnk = reinterpret_cast<IUnknown**>( |
89 static_cast<char*>(pv) + data.offsetUnk); | 89 static_cast<char*>(pv) + data.offsetUnk); |
90 | 90 |
91 HRESULT hr = S_OK; | 91 HRESULT hr = S_OK; |
92 if (!*ppUnk) | 92 if (!*ppUnk) |
93 { | 93 { |
94 CComPtr<IUnknown> spUnk; | 94 CComPtr<IUnknown> spUnk; |
95 hr = punkTarget->QueryInterface(riid, | 95 hr = punkTarget->QueryInterface(riid, |
96 reinterpret_cast<void**>(&spUnk)); | 96 reinterpret_cast<void**>(&spUnk)); |
97 ATLASSERT(FAILED(hr) || spUnk != 0); | 97 ATLASSERT(FAILED(hr) || spUnk != 0); |
98 if (SUCCEEDED(hr)) | 98 if (SUCCEEDED(hr)) |
99 { | 99 { |
100 *ppUnk = spUnk.Detach(); | 100 *ppUnk = spUnk.Detach(); |
101 | 101 |
102 // Need to QI for base interface to fill in base target pointer | 102 // Need to QI for base interface to fill in base target pointer |
103 if (data.piidBase) | 103 if (data.piidBase) |
104 { | 104 { |
105 ATLASSERT(punkWrapper != 0); | 105 ATLASSERT(punkWrapper != 0); |
106 hr = punkWrapper->QueryInterface(*data.piidBase, | 106 hr = punkWrapper->QueryInterface(*data.piidBase, |
107 reinterpret_cast<void**>(&spUnk)); | 107 reinterpret_cast<void**>(&spUnk)); |
108 // since QI for derived interface succeeded, | 108 // since QI for derived interface succeeded, |
109 // QI for base interface must succeed, too | 109 // QI for base interface must succeed, too |
110 ATLASSERT(SUCCEEDED(hr)); | 110 ATLASSERT(SUCCEEDED(hr)); |
111 } | 111 } |
112 } | 112 } |
113 } | 113 } |
114 if (SUCCEEDED(hr)) | 114 if (SUCCEEDED(hr)) |
115 { | 115 { |
116 CComPtr<IUnknown> spItf = reinterpret_cast<IUnknown*>( | 116 CComPtr<IUnknown> spItf = reinterpret_cast<IUnknown*>( |
117 static_cast<char*>(pv) + data.offsetItf); | 117 static_cast<char*>(pv) + data.offsetItf); |
118 *ppv = spItf.Detach(); | 118 *ppv = spItf.Detach(); |
119 } | 119 } |
120 else | 120 else |
121 { | 121 { |
122 ATLASSERT(_T("Interface not supported by target unknown")); | 122 ATLASSERT(_T("Interface not supported by target unknown")); |
123 } | 123 } |
124 return hr; | 124 return hr; |
125 } | 125 } |
126 | 126 |
127 inline HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid, | 127 inline HRESULT WINAPI QueryInterfaceDebug(void* pv, REFIID riid, |
128 LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget) | 128 LPVOID* ppv, DWORD_PTR dw, IUnknown* punkTarget) |
129 { | 129 { |
130 ATLASSERT(pv != 0); | 130 ATLASSERT(pv != 0); |
131 ATLASSERT(ppv != 0); | 131 ATLASSERT(ppv != 0); |
132 ATLASSERT(punkTarget != 0); | 132 ATLASSERT(punkTarget != 0); |
133 | 133 |
134 CComPtr<IUnknown> spUnk; | 134 CComPtr<IUnknown> spUnk; |
135 HRESULT hr = punkTarget->QueryInterface(riid, | 135 HRESULT hr = punkTarget->QueryInterface(riid, |
136 reinterpret_cast<void**>(&spUnk)); | 136 reinterpret_cast<void**>(&spUnk)); |
137 ATLASSERT(FAILED(hr) || spUnk != 0); | 137 ATLASSERT(FAILED(hr) || spUnk != 0); |
138 if (SUCCEEDED(hr)) | 138 if (SUCCEEDED(hr)) |
139 { | 139 { |
140 //Added by MH to display interface CLSID in debug | 140 //Added by MH to display interface CLSID in debug |
141 OLECHAR wszBuff[39]; | 141 OLECHAR wszBuff[39]; |
142 int i = StringFromGUID2(riid, wszBuff, 39); | 142 int i = StringFromGUID2(riid, wszBuff, 39); |
143 USES_CONVERSION; | 143 USES_CONVERSION; |
144 ATLTRACE(_T("=====>Unrecognized interface supported by target un known=%s\n"), OLE2T(wszBuff)); | 144 ATLTRACE(_T("=====>Unrecognized interface supported by target unknown=%s \n"), OLE2T(wszBuff)); |
145 } | 145 } |
146 | 146 |
147 // We don't support this interface, so return an error. | 147 // We don't support this interface, so return an error. |
148 // The operations above are for debugging purposes only, | 148 // The operations above are for debugging purposes only, |
149 // this function is not supposed to ever return success | 149 // this function is not supposed to ever return success |
150 return E_NOINTERFACE; | 150 return E_NOINTERFACE; |
151 } | 151 } |
152 | 152 |
153 inline HRESULT QueryServicePassthrough(REFGUID guidService, | 153 inline HRESULT QueryServicePassthrough(REFGUID guidService, |
154 IUnknown* punkThis, REFIID riid, void** ppv, | 154 IUnknown* punkThis, REFIID riid, void** ppv, |
155 IServiceProvider* pClientProvider) | 155 IServiceProvider* pClientProvider) |
156 { | 156 { |
157 ATLASSERT(punkThis != 0); | 157 ATLASSERT(punkThis != 0); |
158 CComPtr<IUnknown> spDummy; | 158 CComPtr<IUnknown> spDummy; |
159 HRESULT hr = pClientProvider ? | 159 HRESULT hr = pClientProvider ? |
160 pClientProvider->QueryService(guidService, riid, | 160 pClientProvider->QueryService(guidService, riid, |
161 reinterpret_cast<void**>(&spDummy)) : | 161 reinterpret_cast<void**>(&spDummy)) : |
162 E_NOINTERFACE; | 162 E_NOINTERFACE; |
163 if (SUCCEEDED(hr)) | 163 if (SUCCEEDED(hr)) |
164 { | 164 { |
165 hr = punkThis->QueryInterface(riid, ppv); | 165 hr = punkThis->QueryInterface(riid, ppv); |
166 } | 166 } |
167 return hr; | 167 return hr; |
168 } | 168 } |
169 | 169 |
170 } // end namespace PassthroughAPP::Detail | 170 } // end namespace PassthroughAPP::Detail |
171 | 171 |
172 // ===== IInternetProtocolImpl ===== | 172 // ===== IInternetProtocolImpl ===== |
173 | 173 |
174 inline STDMETHODIMP IInternetProtocolImpl::SetTargetUnknown( | 174 inline STDMETHODIMP IInternetProtocolImpl::SetTargetUnknown( |
175 IUnknown* punkTarget) | 175 IUnknown* punkTarget) |
176 { | 176 { |
177 ATLASSERT(punkTarget != 0); | 177 ATLASSERT(punkTarget != 0); |
178 if (!punkTarget) | 178 if (!punkTarget) |
179 { | 179 { |
180 return E_POINTER; | 180 return E_POINTER; |
181 } | 181 } |
182 | 182 |
183 // This method should only be called once, and be the only source | 183 // This method should only be called once, and be the only source |
184 // of target interface pointers. | 184 // of target interface pointers. |
185 ATLASSERT(m_spInternetProtocolUnk == 0); | 185 ATLASSERT(m_spInternetProtocolUnk == 0); |
186 ATLASSERT(m_spInternetProtocol == 0); | 186 ATLASSERT(m_spInternetProtocol == 0); |
187 if (m_spInternetProtocolUnk || m_spInternetProtocol) | 187 if (m_spInternetProtocolUnk || m_spInternetProtocol) |
188 { | 188 { |
189 return E_UNEXPECTED; | 189 return E_UNEXPECTED; |
190 } | 190 } |
191 | 191 |
192 // We expect the target unknown to implement at least IInternetProtocol | 192 // We expect the target unknown to implement at least IInternetProtocol |
193 // Otherwise we reject it | 193 // Otherwise we reject it |
194 HRESULT hr = punkTarget->QueryInterface(&m_spInternetProtocol); | 194 HRESULT hr = punkTarget->QueryInterface(&m_spInternetProtocol); |
195 ATLASSERT(FAILED(hr) || m_spInternetProtocol != 0); | 195 ATLASSERT(FAILED(hr) || m_spInternetProtocol != 0); |
196 if (FAILED(hr)) | 196 if (FAILED(hr)) |
197 { | 197 { |
198 return hr; | 198 return hr; |
199 } | 199 } |
200 | 200 |
201 ATLASSERT(m_spInternetProtocolInfo == 0); | 201 ATLASSERT(m_spInternetProtocolInfo == 0); |
202 ATLASSERT(m_spInternetPriority == 0); | 202 ATLASSERT(m_spInternetPriority == 0); |
203 ATLASSERT(m_spInternetThreadSwitch == 0); | 203 ATLASSERT(m_spInternetThreadSwitch == 0); |
204 ATLASSERT(m_spWinInetInfo == 0); | 204 ATLASSERT(m_spWinInetInfo == 0); |
205 ATLASSERT(m_spWinInetHttpInfo == 0); | 205 ATLASSERT(m_spWinInetHttpInfo == 0); |
206 | 206 |
207 m_spInternetProtocolUnk = punkTarget; | 207 m_spInternetProtocolUnk = punkTarget; |
208 return S_OK; | 208 return S_OK; |
209 } | 209 } |
210 | 210 |
211 inline void IInternetProtocolImpl::ReleaseAll() | 211 inline void IInternetProtocolImpl::ReleaseAll() |
212 { | 212 { |
213 m_spInternetProtocolUnk.Release(); | 213 m_spInternetProtocolUnk.Release(); |
214 m_spInternetProtocol.Release(); | 214 m_spInternetProtocol.Release(); |
215 m_spInternetProtocolInfo.Release(); | 215 m_spInternetProtocolInfo.Release(); |
216 m_spInternetPriority.Release(); | 216 m_spInternetPriority.Release(); |
217 m_spInternetThreadSwitch.Release(); | 217 m_spInternetThreadSwitch.Release(); |
218 m_spWinInetInfo.Release(); | 218 m_spWinInetInfo.Release(); |
219 m_spWinInetHttpInfo.Release(); | 219 m_spWinInetHttpInfo.Release(); |
220 } | 220 } |
221 | 221 |
222 // IInternetProtocolRoot | 222 // IInternetProtocolRoot |
223 inline STDMETHODIMP IInternetProtocolImpl::Start( | 223 inline STDMETHODIMP IInternetProtocolImpl::Start( |
224 /* [in] */ LPCWSTR szUrl, | 224 /* [in] */ LPCWSTR szUrl, |
225 /* [in] */ IInternetProtocolSink *pOIProtSink, | 225 /* [in] */ IInternetProtocolSink *pOIProtSink, |
226 /* [in] */ IInternetBindInfo *pOIBindInfo, | 226 /* [in] */ IInternetBindInfo *pOIBindInfo, |
227 /* [in] */ DWORD grfPI, | 227 /* [in] */ DWORD grfPI, |
228 /* [in] */ HANDLE_PTR dwReserved) | 228 /* [in] */ HANDLE_PTR dwReserved) |
229 { | 229 { |
230 ATLASSERT(m_spInternetProtocol != 0); | 230 ATLASSERT(m_spInternetProtocol != 0); |
231 return m_spInternetProtocol ? | 231 return m_spInternetProtocol ? |
232 m_spInternetProtocol->Start(szUrl, pOIProtSink, pOIBindInfo, grf PI, | 232 m_spInternetProtocol->Start(szUrl, pOIProtSink, pOIBindInfo, grfPI, |
233 dwReserved) : | 233 dwReserved) : |
234 E_UNEXPECTED; | 234 E_UNEXPECTED; |
235 } | 235 } |
236 | 236 |
237 inline STDMETHODIMP IInternetProtocolImpl::Continue( | 237 inline STDMETHODIMP IInternetProtocolImpl::Continue( |
238 /* [in] */ PROTOCOLDATA *pProtocolData) | 238 /* [in] */ PROTOCOLDATA *pProtocolData) |
239 { | 239 { |
240 ATLASSERT(m_spInternetProtocol != 0); | 240 ATLASSERT(m_spInternetProtocol != 0); |
241 return m_spInternetProtocol ? | 241 return m_spInternetProtocol ? |
242 m_spInternetProtocol->Continue(pProtocolData) : | 242 m_spInternetProtocol->Continue(pProtocolData) : |
243 E_UNEXPECTED; | 243 E_UNEXPECTED; |
244 } | 244 } |
245 | 245 |
246 inline STDMETHODIMP IInternetProtocolImpl::Abort( | 246 inline STDMETHODIMP IInternetProtocolImpl::Abort( |
247 /* [in] */ HRESULT hrReason, | 247 /* [in] */ HRESULT hrReason, |
248 /* [in] */ DWORD dwOptions) | 248 /* [in] */ DWORD dwOptions) |
249 { | 249 { |
250 ATLASSERT(m_spInternetProtocol != 0); | 250 ATLASSERT(m_spInternetProtocol != 0); |
251 return m_spInternetProtocol ? | 251 return m_spInternetProtocol ? |
252 m_spInternetProtocol->Abort(hrReason, dwOptions) : | 252 m_spInternetProtocol->Abort(hrReason, dwOptions) : |
253 E_UNEXPECTED; | 253 E_UNEXPECTED; |
254 } | 254 } |
255 | 255 |
256 inline STDMETHODIMP IInternetProtocolImpl::Terminate( | 256 inline STDMETHODIMP IInternetProtocolImpl::Terminate( |
257 /* [in] */ DWORD dwOptions) | 257 /* [in] */ DWORD dwOptions) |
258 { | 258 { |
259 ATLASSERT(m_spInternetProtocol != 0); | 259 ATLASSERT(m_spInternetProtocol != 0); |
260 return m_spInternetProtocol ? | 260 return m_spInternetProtocol ? |
261 m_spInternetProtocol->Terminate(dwOptions) : | 261 m_spInternetProtocol->Terminate(dwOptions) : |
262 E_UNEXPECTED; | 262 E_UNEXPECTED; |
263 } | 263 } |
264 | 264 |
265 inline STDMETHODIMP IInternetProtocolImpl::Suspend() | 265 inline STDMETHODIMP IInternetProtocolImpl::Suspend() |
266 { | 266 { |
267 ATLASSERT(m_spInternetProtocol != 0); | 267 ATLASSERT(m_spInternetProtocol != 0); |
268 return m_spInternetProtocol ? | 268 return m_spInternetProtocol ? |
269 m_spInternetProtocol->Suspend() : | 269 m_spInternetProtocol->Suspend() : |
270 E_UNEXPECTED; | 270 E_UNEXPECTED; |
271 } | 271 } |
272 | 272 |
273 inline STDMETHODIMP IInternetProtocolImpl::Resume() | 273 inline STDMETHODIMP IInternetProtocolImpl::Resume() |
274 { | 274 { |
275 ATLASSERT(m_spInternetProtocol != 0); | 275 ATLASSERT(m_spInternetProtocol != 0); |
276 return m_spInternetProtocol ? | 276 return m_spInternetProtocol ? |
277 m_spInternetProtocol->Resume() : | 277 m_spInternetProtocol->Resume() : |
278 E_UNEXPECTED; | 278 E_UNEXPECTED; |
279 } | 279 } |
280 | 280 |
281 // IInternetProtocol | 281 // IInternetProtocol |
282 inline STDMETHODIMP IInternetProtocolImpl::Read( | 282 inline STDMETHODIMP IInternetProtocolImpl::Read( |
283 /* [in, out] */ void *pv, | 283 /* [in, out] */ void *pv, |
284 /* [in] */ ULONG cb, | 284 /* [in] */ ULONG cb, |
285 /* [out] */ ULONG *pcbRead) | 285 /* [out] */ ULONG *pcbRead) |
286 { | 286 { |
287 ATLASSERT(m_spInternetProtocol != 0); | 287 ATLASSERT(m_spInternetProtocol != 0); |
288 return m_spInternetProtocol ? | 288 return m_spInternetProtocol ? |
289 m_spInternetProtocol->Read(pv, cb, pcbRead) : | 289 m_spInternetProtocol->Read(pv, cb, pcbRead) : |
290 E_UNEXPECTED; | 290 E_UNEXPECTED; |
291 } | 291 } |
292 | 292 |
293 inline STDMETHODIMP IInternetProtocolImpl::Seek( | 293 inline STDMETHODIMP IInternetProtocolImpl::Seek( |
294 /* [in] */ LARGE_INTEGER dlibMove, | 294 /* [in] */ LARGE_INTEGER dlibMove, |
295 /* [in] */ DWORD dwOrigin, | 295 /* [in] */ DWORD dwOrigin, |
296 /* [out] */ ULARGE_INTEGER *plibNewPosition) | 296 /* [out] */ ULARGE_INTEGER *plibNewPosition) |
297 { | 297 { |
298 ATLASSERT(m_spInternetProtocol != 0); | 298 ATLASSERT(m_spInternetProtocol != 0); |
299 return m_spInternetProtocol ? | 299 return m_spInternetProtocol ? |
300 m_spInternetProtocol->Seek(dlibMove, dwOrigin, plibNewPosition) : | 300 m_spInternetProtocol->Seek(dlibMove, dwOrigin, plibNewPosition) : |
301 E_UNEXPECTED; | 301 E_UNEXPECTED; |
302 } | 302 } |
303 | 303 |
304 inline STDMETHODIMP IInternetProtocolImpl::LockRequest( | 304 inline STDMETHODIMP IInternetProtocolImpl::LockRequest( |
305 /* [in] */ DWORD dwOptions) | 305 /* [in] */ DWORD dwOptions) |
306 { | 306 { |
307 ATLASSERT(m_spInternetProtocol != 0); | 307 ATLASSERT(m_spInternetProtocol != 0); |
308 return m_spInternetProtocol ? | 308 return m_spInternetProtocol ? |
309 m_spInternetProtocol->LockRequest(dwOptions) : | 309 m_spInternetProtocol->LockRequest(dwOptions) : |
310 E_UNEXPECTED; | 310 E_UNEXPECTED; |
311 } | 311 } |
312 | 312 |
313 inline STDMETHODIMP IInternetProtocolImpl::UnlockRequest() | 313 inline STDMETHODIMP IInternetProtocolImpl::UnlockRequest() |
314 { | 314 { |
315 ATLASSERT(m_spInternetProtocol != 0); | 315 ATLASSERT(m_spInternetProtocol != 0); |
316 return m_spInternetProtocol ? | 316 return m_spInternetProtocol ? |
317 m_spInternetProtocol->UnlockRequest() : | 317 m_spInternetProtocol->UnlockRequest() : |
318 E_UNEXPECTED; | 318 E_UNEXPECTED; |
319 } | 319 } |
320 | 320 |
321 // IInternetProtocolInfo | 321 // IInternetProtocolInfo |
322 inline STDMETHODIMP IInternetProtocolImpl::ParseUrl( | 322 inline STDMETHODIMP IInternetProtocolImpl::ParseUrl( |
323 /* [in] */ LPCWSTR pwzUrl, | 323 /* [in] */ LPCWSTR pwzUrl, |
324 /* [in] */ PARSEACTION ParseAction, | 324 /* [in] */ PARSEACTION ParseAction, |
325 /* [in] */ DWORD dwParseFlags, | 325 /* [in] */ DWORD dwParseFlags, |
326 /* [out] */ LPWSTR pwzResult, | 326 /* [out] */ LPWSTR pwzResult, |
327 /* [in] */ DWORD cchResult, | 327 /* [in] */ DWORD cchResult, |
328 /* [out] */ DWORD *pcchResult, | 328 /* [out] */ DWORD *pcchResult, |
329 /* [in] */ DWORD dwReserved) | 329 /* [in] */ DWORD dwReserved) |
330 { | 330 { |
331 ATLASSERT(m_spInternetProtocolInfo != 0); | 331 ATLASSERT(m_spInternetProtocolInfo != 0); |
332 return m_spInternetProtocolInfo ? | 332 return m_spInternetProtocolInfo ? |
333 m_spInternetProtocolInfo->ParseUrl(pwzUrl, ParseAction, dwParseF lags, | 333 m_spInternetProtocolInfo->ParseUrl(pwzUrl, ParseAction, dwParseFlags, |
334 pwzResult, cchResult, pcchResult, dwReserved) : | 334 pwzResult, cchResult, pcchResult, dwReserved) : |
335 E_UNEXPECTED; | 335 E_UNEXPECTED; |
336 } | 336 } |
337 | 337 |
338 inline STDMETHODIMP IInternetProtocolImpl::CombineUrl( | 338 inline STDMETHODIMP IInternetProtocolImpl::CombineUrl( |
339 /* [in] */ LPCWSTR pwzBaseUrl, | 339 /* [in] */ LPCWSTR pwzBaseUrl, |
340 /* [in] */ LPCWSTR pwzRelativeUrl, | 340 /* [in] */ LPCWSTR pwzRelativeUrl, |
341 /* [in] */ DWORD dwCombineFlags, | 341 /* [in] */ DWORD dwCombineFlags, |
342 /* [out] */ LPWSTR pwzResult, | 342 /* [out] */ LPWSTR pwzResult, |
343 /* [in] */ DWORD cchResult, | 343 /* [in] */ DWORD cchResult, |
344 /* [out] */ DWORD *pcchResult, | 344 /* [out] */ DWORD *pcchResult, |
345 /* [in] */ DWORD dwReserved) | 345 /* [in] */ DWORD dwReserved) |
346 { | 346 { |
347 ATLASSERT(m_spInternetProtocolInfo != 0); | 347 ATLASSERT(m_spInternetProtocolInfo != 0); |
348 return m_spInternetProtocolInfo ? | 348 return m_spInternetProtocolInfo ? |
349 m_spInternetProtocolInfo->CombineUrl(pwzBaseUrl, pwzRelativeUrl, | 349 m_spInternetProtocolInfo->CombineUrl(pwzBaseUrl, pwzRelativeUrl, |
350 dwCombineFlags, pwzResult, cchResult, pcchResult, dwRese rved) : | 350 dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved) : |
351 E_UNEXPECTED; | 351 E_UNEXPECTED; |
352 } | 352 } |
353 | 353 |
354 inline STDMETHODIMP IInternetProtocolImpl::CompareUrl( | 354 inline STDMETHODIMP IInternetProtocolImpl::CompareUrl( |
355 /* [in] */ LPCWSTR pwzUrl1, | 355 /* [in] */ LPCWSTR pwzUrl1, |
356 /* [in] */ LPCWSTR pwzUrl2, | 356 /* [in] */ LPCWSTR pwzUrl2, |
357 /* [in] */ DWORD dwCompareFlags) | 357 /* [in] */ DWORD dwCompareFlags) |
358 { | 358 { |
359 ATLASSERT(m_spInternetProtocolInfo != 0); | 359 ATLASSERT(m_spInternetProtocolInfo != 0); |
360 return m_spInternetProtocolInfo ? | 360 return m_spInternetProtocolInfo ? |
361 m_spInternetProtocolInfo->CompareUrl(pwzUrl1,pwzUrl2, dwCompareF lags) : | 361 m_spInternetProtocolInfo->CompareUrl(pwzUrl1,pwzUrl2, dwCompareFlags) : |
362 E_UNEXPECTED; | 362 E_UNEXPECTED; |
363 } | 363 } |
364 | 364 |
365 inline STDMETHODIMP IInternetProtocolImpl::QueryInfo( | 365 inline STDMETHODIMP IInternetProtocolImpl::QueryInfo( |
366 /* [in] */ LPCWSTR pwzUrl, | 366 /* [in] */ LPCWSTR pwzUrl, |
367 /* [in] */ QUERYOPTION QueryOption, | 367 /* [in] */ QUERYOPTION QueryOption, |
368 /* [in] */ DWORD dwQueryFlags, | 368 /* [in] */ DWORD dwQueryFlags, |
369 /* [in, out] */ LPVOID pBuffer, | 369 /* [in, out] */ LPVOID pBuffer, |
370 /* [in] */ DWORD cbBuffer, | 370 /* [in] */ DWORD cbBuffer, |
371 /* [in, out] */ DWORD *pcbBuf, | 371 /* [in, out] */ DWORD *pcbBuf, |
372 /* [in] */ DWORD dwReserved) | 372 /* [in] */ DWORD dwReserved) |
373 { | 373 { |
374 ATLASSERT(m_spInternetProtocolInfo != 0); | 374 ATLASSERT(m_spInternetProtocolInfo != 0); |
375 return m_spInternetProtocolInfo ? | 375 return m_spInternetProtocolInfo ? |
376 m_spInternetProtocolInfo->QueryInfo(pwzUrl, QueryOption, dwQuery Flags, | 376 m_spInternetProtocolInfo->QueryInfo(pwzUrl, QueryOption, dwQueryFlags, |
377 pBuffer, cbBuffer, pcbBuf, dwReserved) : | 377 pBuffer, cbBuffer, pcbBuf, dwReserved) : |
378 E_UNEXPECTED; | 378 E_UNEXPECTED; |
379 } | 379 } |
380 | 380 |
381 // IInternetPriority | 381 // IInternetPriority |
382 inline STDMETHODIMP IInternetProtocolImpl::SetPriority( | 382 inline STDMETHODIMP IInternetProtocolImpl::SetPriority( |
383 /* [in] */ LONG nPriority) | 383 /* [in] */ LONG nPriority) |
384 { | 384 { |
385 ATLASSERT(m_spInternetPriority != 0); | 385 ATLASSERT(m_spInternetPriority != 0); |
386 return m_spInternetPriority ? | 386 return m_spInternetPriority ? |
387 m_spInternetPriority->SetPriority(nPriority) : | 387 m_spInternetPriority->SetPriority(nPriority) : |
388 E_UNEXPECTED; | 388 E_UNEXPECTED; |
389 } | 389 } |
390 | 390 |
391 inline STDMETHODIMP IInternetProtocolImpl::GetPriority( | 391 inline STDMETHODIMP IInternetProtocolImpl::GetPriority( |
392 /* [out] */ LONG *pnPriority) | 392 /* [out] */ LONG *pnPriority) |
393 { | 393 { |
394 ATLASSERT(m_spInternetPriority != 0); | 394 ATLASSERT(m_spInternetPriority != 0); |
395 return m_spInternetPriority ? | 395 return m_spInternetPriority ? |
396 m_spInternetPriority->GetPriority(pnPriority) : | 396 m_spInternetPriority->GetPriority(pnPriority) : |
397 E_UNEXPECTED; | 397 E_UNEXPECTED; |
398 } | 398 } |
399 | 399 |
400 // IInternetThreadSwitch | 400 // IInternetThreadSwitch |
401 inline STDMETHODIMP IInternetProtocolImpl::Prepare() | 401 inline STDMETHODIMP IInternetProtocolImpl::Prepare() |
402 { | 402 { |
403 ATLASSERT(m_spInternetThreadSwitch != 0); | 403 ATLASSERT(m_spInternetThreadSwitch != 0); |
404 return m_spInternetThreadSwitch ? | 404 return m_spInternetThreadSwitch ? |
405 m_spInternetThreadSwitch->Prepare() : | 405 m_spInternetThreadSwitch->Prepare() : |
406 E_UNEXPECTED; | 406 E_UNEXPECTED; |
407 } | 407 } |
408 | 408 |
409 inline STDMETHODIMP IInternetProtocolImpl::Continue() | 409 inline STDMETHODIMP IInternetProtocolImpl::Continue() |
410 { | 410 { |
411 ATLASSERT(m_spInternetThreadSwitch != 0); | 411 ATLASSERT(m_spInternetThreadSwitch != 0); |
412 return m_spInternetThreadSwitch ? | 412 return m_spInternetThreadSwitch ? |
413 m_spInternetThreadSwitch->Continue() : | 413 m_spInternetThreadSwitch->Continue() : |
414 E_UNEXPECTED; | 414 E_UNEXPECTED; |
415 } | 415 } |
416 | 416 |
417 // IWinInetInfo | 417 // IWinInetInfo |
418 inline STDMETHODIMP IInternetProtocolImpl::QueryOption( | 418 inline STDMETHODIMP IInternetProtocolImpl::QueryOption( |
419 /* [in] */ DWORD dwOption, | 419 /* [in] */ DWORD dwOption, |
420 /* [in, out] */ LPVOID pBuffer, | 420 /* [in, out] */ LPVOID pBuffer, |
421 /* [in, out] */ DWORD *pcbBuf) | 421 /* [in, out] */ DWORD *pcbBuf) |
422 { | 422 { |
423 ATLASSERT(m_spWinInetInfo != 0); | 423 ATLASSERT(m_spWinInetInfo != 0); |
424 return m_spWinInetInfo ? | 424 return m_spWinInetInfo ? |
425 m_spWinInetInfo->QueryOption(dwOption, pBuffer, pcbBuf) : | 425 m_spWinInetInfo->QueryOption(dwOption, pBuffer, pcbBuf) : |
426 E_UNEXPECTED; | 426 E_UNEXPECTED; |
427 } | 427 } |
428 | 428 |
429 // IWinInetHttpInfo | 429 // IWinInetHttpInfo |
430 inline STDMETHODIMP IInternetProtocolImpl::QueryInfo( | 430 inline STDMETHODIMP IInternetProtocolImpl::QueryInfo( |
431 /* [in] */ DWORD dwOption, | 431 /* [in] */ DWORD dwOption, |
432 /* [in, out] */ LPVOID pBuffer, | 432 /* [in, out] */ LPVOID pBuffer, |
433 /* [in, out] */ DWORD *pcbBuf, | 433 /* [in, out] */ DWORD *pcbBuf, |
434 /* [in, out] */ DWORD *pdwFlags, | 434 /* [in, out] */ DWORD *pdwFlags, |
435 /* [in, out] */ DWORD *pdwReserved) | 435 /* [in, out] */ DWORD *pdwReserved) |
436 { | 436 { |
437 ATLASSERT(m_spWinInetHttpInfo != 0); | 437 ATLASSERT(m_spWinInetHttpInfo != 0); |
438 return m_spWinInetHttpInfo ? | 438 return m_spWinInetHttpInfo ? |
439 m_spWinInetHttpInfo->QueryInfo(dwOption, pBuffer, pcbBuf, pdwFla gs, | 439 m_spWinInetHttpInfo->QueryInfo(dwOption, pBuffer, pcbBuf, pdwFlags, |
440 pdwReserved) : | 440 pdwReserved) : |
441 E_UNEXPECTED; | 441 E_UNEXPECTED; |
442 } | 442 } |
443 | 443 |
444 // ===== IInternetProtocolSinkImpl ===== | 444 // ===== IInternetProtocolSinkImpl ===== |
445 | 445 |
446 inline HRESULT IInternetProtocolSinkImpl::OnStart(LPCWSTR szUrl, | 446 inline HRESULT IInternetProtocolSinkImpl::OnStart(LPCWSTR szUrl, |
447 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, | 447 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, |
448 DWORD grfPI, DWORD dwReserved, IInternetProtocol* pTargetProtocol) | 448 DWORD grfPI, DWORD dwReserved, IInternetProtocol* pTargetProtocol) |
449 { | 449 { |
450 ATLASSERT(pOIProtSink != 0); | 450 ATLASSERT(pOIProtSink != 0); |
451 ATLASSERT(pOIBindInfo != 0); | 451 ATLASSERT(pOIBindInfo != 0); |
452 ATLASSERT(pTargetProtocol != 0); | 452 ATLASSERT(pTargetProtocol != 0); |
453 if (!pOIProtSink || !pOIBindInfo || !pTargetProtocol) | 453 if (!pOIProtSink || !pOIBindInfo || !pTargetProtocol) |
454 { | 454 { |
455 return E_POINTER; | 455 return E_POINTER; |
456 } | 456 } |
457 | 457 |
458 // This method should only be called once, and be the only source | 458 // This method should only be called once, and be the only source |
459 // of target interface pointers. | 459 // of target interface pointers. |
460 ATLASSERT(m_spInternetProtocolSink == 0); | 460 ATLASSERT(m_spInternetProtocolSink == 0); |
461 ATLASSERT(m_spInternetBindInfo == 0); | 461 ATLASSERT(m_spInternetBindInfo == 0); |
462 ATLASSERT(m_spTargetProtocol == 0); | 462 ATLASSERT(m_spTargetProtocol == 0); |
463 if (m_spInternetProtocolSink || m_spInternetBindInfo || m_spTargetProtoc ol) | 463 if (m_spInternetProtocolSink || m_spInternetBindInfo || m_spTargetProtocol) |
464 { | 464 { |
465 return E_UNEXPECTED; | 465 return E_UNEXPECTED; |
466 } | 466 } |
467 | 467 |
468 ATLASSERT(m_spServiceProvider == 0); | 468 ATLASSERT(m_spServiceProvider == 0); |
469 | 469 |
470 m_spInternetProtocolSink = pOIProtSink; | 470 m_spInternetProtocolSink = pOIProtSink; |
471 m_spInternetBindInfo = pOIBindInfo; | 471 m_spInternetBindInfo = pOIBindInfo; |
472 m_spTargetProtocol = pTargetProtocol; | 472 m_spTargetProtocol = pTargetProtocol; |
473 return S_OK; | 473 return S_OK; |
474 } | 474 } |
475 | 475 |
476 inline void IInternetProtocolSinkImpl::ReleaseAll() | 476 inline void IInternetProtocolSinkImpl::ReleaseAll() |
477 { | 477 { |
478 m_spInternetProtocolSink.Release(); | 478 m_spInternetProtocolSink.Release(); |
479 m_spServiceProvider.Release(); | 479 m_spServiceProvider.Release(); |
480 m_spInternetBindInfo.Release(); | 480 m_spInternetBindInfo.Release(); |
481 m_spTargetProtocol.Release(); | 481 m_spTargetProtocol.Release(); |
482 } | 482 } |
483 | 483 |
484 inline IServiceProvider* IInternetProtocolSinkImpl::GetClientServiceProvider() | 484 inline IServiceProvider* IInternetProtocolSinkImpl::GetClientServiceProvider() |
485 { | 485 { |
486 return m_spServiceProvider; | 486 return m_spServiceProvider; |
487 } | 487 } |
488 | 488 |
489 inline HRESULT IInternetProtocolSinkImpl::QueryServiceFromClient( | 489 inline HRESULT IInternetProtocolSinkImpl::QueryServiceFromClient( |
490 REFGUID guidService, REFIID riid, void** ppvObject) | 490 REFGUID guidService, REFIID riid, void** ppvObject) |
491 { | 491 { |
492 HRESULT hr = S_OK; | 492 HRESULT hr = S_OK; |
493 CComPtr<IServiceProvider> spClientProvider = m_spServiceProvider; | 493 CComPtr<IServiceProvider> spClientProvider = m_spServiceProvider; |
494 if (!spClientProvider) | 494 if (!spClientProvider) |
495 { | 495 { |
496 hr = m_spInternetProtocolSink->QueryInterface(&spClientProvider) ; | 496 hr = m_spInternetProtocolSink->QueryInterface(&spClientProvider); |
497 ATLASSERT(SUCCEEDED(hr) && spClientProvider != 0); | 497 ATLASSERT(SUCCEEDED(hr) && spClientProvider != 0); |
498 } | 498 } |
499 if (SUCCEEDED(hr)) | 499 if (SUCCEEDED(hr)) |
500 { | 500 { |
501 hr = spClientProvider->QueryService(guidService, riid, ppvObject ); | 501 hr = spClientProvider->QueryService(guidService, riid, ppvObject); |
502 } | 502 } |
503 return hr; | 503 return hr; |
504 } | 504 } |
505 | 505 |
506 // IInternetProtocolSink | 506 // IInternetProtocolSink |
507 inline STDMETHODIMP IInternetProtocolSinkImpl::Switch( | 507 inline STDMETHODIMP IInternetProtocolSinkImpl::Switch( |
508 /* [in] */ PROTOCOLDATA *pProtocolData) | 508 /* [in] */ PROTOCOLDATA *pProtocolData) |
509 { | 509 { |
510 ATLASSERT(m_spInternetProtocolSink != 0); | 510 ATLASSERT(m_spInternetProtocolSink != 0); |
511 return m_spInternetProtocolSink ? | 511 return m_spInternetProtocolSink ? |
512 m_spInternetProtocolSink->Switch(pProtocolData) : | 512 m_spInternetProtocolSink->Switch(pProtocolData) : |
513 E_UNEXPECTED; | 513 E_UNEXPECTED; |
514 } | 514 } |
515 | 515 |
516 inline STDMETHODIMP IInternetProtocolSinkImpl::ReportProgress( | 516 inline STDMETHODIMP IInternetProtocolSinkImpl::ReportProgress( |
517 /* [in] */ ULONG ulStatusCode, | 517 /* [in] */ ULONG ulStatusCode, |
518 /* [in] */ LPCWSTR szStatusText) | 518 /* [in] */ LPCWSTR szStatusText) |
519 { | 519 { |
520 ATLASSERT(m_spInternetProtocolSink != 0); | 520 ATLASSERT(m_spInternetProtocolSink != 0); |
521 return m_spInternetProtocolSink ? | 521 return m_spInternetProtocolSink ? |
522 m_spInternetProtocolSink->ReportProgress(ulStatusCode, szStatusT ext) : | 522 m_spInternetProtocolSink->ReportProgress(ulStatusCode, szStatusText) : |
523 E_UNEXPECTED; | 523 E_UNEXPECTED; |
524 } | 524 } |
525 | 525 |
526 inline STDMETHODIMP IInternetProtocolSinkImpl::ReportData( | 526 inline STDMETHODIMP IInternetProtocolSinkImpl::ReportData( |
527 /* [in] */ DWORD grfBSCF, | 527 /* [in] */ DWORD grfBSCF, |
528 /* [in] */ ULONG ulProgress, | 528 /* [in] */ ULONG ulProgress, |
529 /* [in] */ ULONG ulProgressMax) | 529 /* [in] */ ULONG ulProgressMax) |
530 { | 530 { |
531 ATLASSERT(m_spInternetProtocolSink != 0); | 531 ATLASSERT(m_spInternetProtocolSink != 0); |
532 return m_spInternetProtocolSink ? | 532 return m_spInternetProtocolSink ? |
533 m_spInternetProtocolSink->ReportData(grfBSCF, ulProgress, | 533 m_spInternetProtocolSink->ReportData(grfBSCF, ulProgress, |
534 ulProgressMax) : | 534 ulProgressMax) : |
535 E_UNEXPECTED; | 535 E_UNEXPECTED; |
536 } | 536 } |
537 | 537 |
538 inline STDMETHODIMP IInternetProtocolSinkImpl::ReportResult( | 538 inline STDMETHODIMP IInternetProtocolSinkImpl::ReportResult( |
539 /* [in] */ HRESULT hrResult, | 539 /* [in] */ HRESULT hrResult, |
540 /* [in] */ DWORD dwError, | 540 /* [in] */ DWORD dwError, |
541 /* [in] */ LPCWSTR szResult) | 541 /* [in] */ LPCWSTR szResult) |
542 { | 542 { |
543 // ATLASSERT(m_spInternetProtocolSink != 0); | 543 ATLASSERT(m_spInternetProtocolSink != 0); |
544 return m_spInternetProtocolSink ? | 544 |
545 m_spInternetProtocolSink->ReportResult(hrResult, dwError, szResu lt) : | 545 // On some websites there are broken requests, that keep on redirecting with out a stop. |
546 E_UNEXPECTED; | 546 // For example: http://telegrafua.com/ has a request to: http://www.ool.ua/w ebroot/delivery/images/ool-button.gif |
547 } | 547 // which causes IE tab to crash in urlmon.dll. That request doesn't ever res olve, since it's constantly responding |
548 | 548 // with HTTP 302. |
549 // IServiceProvider | 549 |
550 inline STDMETHODIMP IInternetProtocolSinkImpl::QueryService( | 550 // It seems like WinInet (urlmon.dll) doesn't expect anything like that to h appen, and relies on APP to make sure it doesn't. |
551 /* [in] */ REFGUID guidService, | 551 // So here we detect if there has been too many redirects (ie INET_E_REDIREC T_FAILED) and we just notify WinInet |
552 /* [in] */ REFIID riid, | 552 // that there has been a generic problem, not redirect specific error. |
553 /* [out] */ void** ppvObject) | 553 |
554 { | 554 if (hrResult == INET_E_REDIRECT_FAILED) |
555 ATLASSERT(m_spServiceProvider != 0); | 555 hrResult = S_FALSE; |
Wladimir Palant
2013/03/05 15:21:48
Is that issue really specific to INET_E_REDIRECT_F
Oleksandr
2013/03/05 18:03:08
I have not seen anything like this for any other e
| |
556 return m_spServiceProvider ? | 556 |
557 m_spServiceProvider->QueryService(guidService, riid, ppvObject) : | 557 return m_spInternetProtocolSink ? |
558 E_UNEXPECTED; | 558 m_spInternetProtocolSink->ReportResult(hrResult, dwError, szResult) : |
559 } | 559 E_UNEXPECTED; |
Oleksandr
2013/03/05 13:44:10
The actual fix is below. All other changes are jus
Wladimir Palant
2013/03/05 15:21:48
In general, it's a good idea to separate style cha
| |
560 | 560 } |
561 // IInternetBindInfo | 561 |
562 inline STDMETHODIMP IInternetProtocolSinkImpl::GetBindInfo( | 562 // IServiceProvider |
563 /* [out] */ DWORD *grfBINDF, | 563 inline STDMETHODIMP IInternetProtocolSinkImpl::QueryService( |
564 /* [in, out] */ BINDINFO *pbindinfo) | 564 /* [in] */ REFGUID guidService, |
565 { | 565 /* [in] */ REFIID riid, |
566 ATLASSERT(m_spInternetBindInfo != 0); | 566 /* [out] */ void** ppvObject) |
567 return m_spInternetBindInfo ? | 567 { |
568 m_spInternetBindInfo->GetBindInfo(grfBINDF, pbindinfo) : | 568 ATLASSERT(m_spServiceProvider != 0); |
569 E_UNEXPECTED; | 569 return m_spServiceProvider ? |
570 } | 570 m_spServiceProvider->QueryService(guidService, riid, ppvObject) : |
571 | 571 E_UNEXPECTED; |
572 inline STDMETHODIMP IInternetProtocolSinkImpl::GetBindString( | 572 } |
573 /* [in] */ ULONG ulStringType, | 573 |
574 /* [in, out] */ LPOLESTR *ppwzStr, | 574 // IInternetBindInfo |
575 /* [in] */ ULONG cEl, | 575 inline STDMETHODIMP IInternetProtocolSinkImpl::GetBindInfo( |
576 /* [in, out] */ ULONG *pcElFetched) | 576 /* [out] */ DWORD *grfBINDF, |
577 { | 577 /* [in, out] */ BINDINFO *pbindinfo) |
578 ATLASSERT(m_spInternetBindInfo != 0); | 578 { |
579 return m_spInternetBindInfo ? | 579 ATLASSERT(m_spInternetBindInfo != 0); |
580 m_spInternetBindInfo->GetBindString(ulStringType, ppwzStr, cEl, | 580 return m_spInternetBindInfo ? |
581 pcElFetched) : | 581 m_spInternetBindInfo->GetBindInfo(grfBINDF, pbindinfo) : |
582 E_UNEXPECTED; | 582 E_UNEXPECTED; |
583 } | 583 } |
584 | 584 |
585 // ===== CInternetProtocolSinkWithSP ===== | 585 inline STDMETHODIMP IInternetProtocolSinkImpl::GetBindString( |
586 | 586 /* [in] */ ULONG ulStringType, |
587 template <class T, class ThreadModel> | 587 /* [in, out] */ LPOLESTR *ppwzStr, |
588 inline HRESULT CInternetProtocolSinkWithSP<T, ThreadModel>::OnStart( | 588 /* [in] */ ULONG cEl, |
589 LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, | 589 /* [in, out] */ ULONG *pcElFetched) |
590 IInternetBindInfo *pOIBindInfo, DWORD grfPI, DWORD dwReserved, | 590 { |
591 IInternetProtocol* pTargetProtocol) | 591 ATLASSERT(m_spInternetBindInfo != 0); |
592 { | 592 return m_spInternetBindInfo ? |
593 ATLASSERT(m_spServiceProvider == 0); | 593 m_spInternetBindInfo->GetBindString(ulStringType, ppwzStr, cEl, |
594 if (m_spServiceProvider) | 594 pcElFetched) : |
595 { | 595 E_UNEXPECTED; |
596 return E_UNEXPECTED; | 596 } |
597 } | 597 |
598 HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, | 598 // ===== CInternetProtocolSinkWithSP ===== |
599 dwReserved, pTargetProtocol); | 599 |
600 if (SUCCEEDED(hr)) | 600 template <class T, class ThreadModel> |
601 { | 601 inline HRESULT CInternetProtocolSinkWithSP<T, ThreadModel>::OnStart( |
602 pOIProtSink->QueryInterface(&m_spServiceProvider); | 602 LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, |
603 } | 603 IInternetBindInfo *pOIBindInfo, DWORD grfPI, DWORD dwReserved, |
604 return hr; | 604 IInternetProtocol* pTargetProtocol) |
605 } | 605 { |
606 | 606 ATLASSERT(m_spServiceProvider == 0); |
607 template <class T, class ThreadModel> | 607 if (m_spServiceProvider) |
608 inline HRESULT CInternetProtocolSinkWithSP<T, ThreadModel>:: | 608 { |
609 _InternalQueryService(REFGUID guidService, REFIID riid, void** ppvObject ) | 609 return E_UNEXPECTED; |
610 { | 610 } |
611 return E_NOINTERFACE; | 611 HRESULT hr = BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, |
612 } | 612 dwReserved, pTargetProtocol); |
613 | 613 if (SUCCEEDED(hr)) |
614 template <class T, class ThreadModel> | 614 { |
615 inline STDMETHODIMP CInternetProtocolSinkWithSP<T, ThreadModel>::QueryService( | 615 pOIProtSink->QueryInterface(&m_spServiceProvider); |
616 REFGUID guidService, REFIID riid, void** ppv) | 616 } |
617 { | 617 return hr; |
618 T* pT = static_cast<T*>(this); | 618 } |
619 HRESULT hr = pT->_InternalQueryService(guidService, riid, ppv); | 619 |
620 if (FAILED(hr) && m_spServiceProvider) | 620 template <class T, class ThreadModel> |
621 { | 621 inline HRESULT CInternetProtocolSinkWithSP<T, ThreadModel>:: |
622 hr = m_spServiceProvider->QueryService(guidService, riid, ppv); | 622 _InternalQueryService(REFGUID guidService, REFIID riid, void** ppvObject) |
623 } | 623 { |
624 return hr; | 624 return E_NOINTERFACE; |
625 } | 625 } |
626 | 626 |
627 // ===== NoSinkStartPolicy ===== | 627 template <class T, class ThreadModel> |
628 | 628 inline STDMETHODIMP CInternetProtocolSinkWithSP<T, ThreadModel>::QueryService( |
629 inline HRESULT NoSinkStartPolicy::OnStart(LPCWSTR szUrl, | 629 REFGUID guidService, REFIID riid, void** ppv) |
630 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, | 630 { |
631 DWORD grfPI, DWORD dwReserved, IInternetProtocol* pTargetProtocol) | 631 T* pT = static_cast<T*>(this); |
632 { | 632 HRESULT hr = pT->_InternalQueryService(guidService, riid, ppv); |
633 // ATLASSERT(pTargetProtocol != 0); | 633 if (FAILED(hr) && m_spServiceProvider) |
634 return pTargetProtocol->Start(szUrl, pOIProtSink, pOIBindInfo, | 634 { |
635 grfPI, dwReserved); | 635 hr = m_spServiceProvider->QueryService(guidService, riid, ppv); |
636 } | 636 } |
637 | 637 return hr; |
638 // ===== CComObjectSharedRef ===== | 638 } |
639 | 639 |
640 template<class Base> | 640 // ===== NoSinkStartPolicy ===== |
641 inline CComObjectSharedRef<Base>::CComObjectSharedRef(IUnknown* punkOuter) : | 641 |
642 m_punkOuter(punkOuter) | 642 inline HRESULT NoSinkStartPolicy::OnStart(LPCWSTR szUrl, |
643 { | 643 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, |
644 ATLASSERT(m_punkOuter != 0); | 644 DWORD grfPI, DWORD dwReserved, IInternetProtocol* pTargetProtocol) |
645 } | 645 { |
646 | 646 ATLASSERT(pTargetProtocol != 0); |
647 template<class Base> | 647 return pTargetProtocol->Start(szUrl, pOIProtSink, pOIBindInfo, |
648 inline STDMETHODIMP CComObjectSharedRef<Base>::QueryInterface(REFIID iid, | 648 grfPI, dwReserved); |
649 void** ppvObject) | 649 } |
650 { | 650 |
651 return _InternalQueryInterface(iid, ppvObject); | 651 // ===== CComObjectSharedRef ===== |
652 } | 652 |
653 | 653 template<class Base> |
654 template<class Base> | 654 inline CComObjectSharedRef<Base>::CComObjectSharedRef(IUnknown* punkOuter) : |
655 inline STDMETHODIMP_(ULONG) CComObjectSharedRef<Base>::AddRef() | 655 m_punkOuter(punkOuter) |
656 { | 656 { |
657 if (m_punkOuter) | 657 ATLASSERT(m_punkOuter != 0); |
658 { | 658 } |
659 m_punkOuter->AddRef(); | 659 |
660 } | 660 template<class Base> |
661 return InternalAddRef(); | 661 inline STDMETHODIMP CComObjectSharedRef<Base>::QueryInterface(REFIID iid, |
662 } | 662 void** ppvObject) |
663 | 663 { |
664 template<class Base> | 664 HRESULT hr = _InternalQueryInterface(iid, ppvObject); |
665 inline STDMETHODIMP_(ULONG) CComObjectSharedRef<Base>::Release() | 665 |
666 { | 666 return hr; |
667 ULONG l = InternalRelease(); | 667 |
668 if (!l) | 668 } |
669 { | 669 |
670 ReleaseAll(); | 670 template<class Base> |
671 } | 671 inline STDMETHODIMP_(ULONG) CComObjectSharedRef<Base>::AddRef() |
672 if (m_punkOuter) | 672 { |
673 { | 673 if (m_punkOuter) |
674 m_punkOuter->Release(); | 674 { |
675 } | 675 m_punkOuter->AddRef(); |
676 return l; | 676 } |
677 } | 677 return InternalAddRef(); |
678 | 678 } |
679 // ===== CustomSinkStartPolicy ===== | 679 |
680 | 680 template<class Base> |
681 template <class Sink> | 681 inline STDMETHODIMP_(ULONG) CComObjectSharedRef<Base>::Release() |
682 inline CustomSinkStartPolicy<Sink>:: | 682 { |
683 CustomSinkStartPolicy(IUnknown* punkOuter) : | 683 ULONG l = InternalRelease(); |
684 m_internetSink(punkOuter) | 684 if (!l) |
685 { | 685 { |
686 } | 686 ReleaseAll(); |
687 | 687 } |
688 template <class Sink> | 688 if (m_punkOuter) |
689 inline HRESULT CustomSinkStartPolicy<Sink>::OnStart(LPCWSTR szUrl, | 689 { |
690 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, | 690 m_punkOuter->Release(); |
691 DWORD grfPI, DWORD dwReserved, IInternetProtocol* pTargetProtocol) | 691 } |
692 { | 692 return l; |
693 ATLASSERT(pTargetProtocol); | 693 } |
694 HRESULT hr = m_internetSink.OnStart(szUrl, pOIProtSink, pOIBindInfo, | 694 |
695 grfPI, dwReserved, pTargetProtocol); | 695 // ===== CustomSinkStartPolicy ===== |
696 | 696 |
697 //We return INET_E_REDIRECT_FAILED in case we have iframe blocking. | 697 template <class Sink> |
698 if (hr == INET_E_REDIRECT_FAILED) | 698 inline CustomSinkStartPolicy<Sink>:: |
699 { | 699 CustomSinkStartPolicy(IUnknown* punkOuter) : |
700 return S_OK; | 700 m_internetSink(punkOuter) |
701 } | 701 { |
702 CComPtr<IInternetProtocolSink> spSink; | 702 } |
703 CComPtr<IInternetBindInfo> spBindInfo; | 703 |
704 if (SUCCEEDED(hr)) | 704 template <class Sink> |
705 { | 705 inline HRESULT CustomSinkStartPolicy<Sink>::OnStart(LPCWSTR szUrl, |
706 hr = m_internetSink.QueryInterface(&spSink); | 706 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, |
707 ATLASSERT(SUCCEEDED(hr) && spSink != 0); | 707 DWORD grfPI, DWORD dwReserved, IInternetProtocol* pTargetProtocol) |
708 } | 708 { |
709 if (SUCCEEDED(hr)) | 709 ATLASSERT(pTargetProtocol); |
710 { | 710 HRESULT hr = m_internetSink.OnStart(szUrl, pOIProtSink, pOIBindInfo, |
711 hr = m_internetSink.QueryInterface(&spBindInfo); | 711 grfPI, dwReserved, pTargetProtocol); |
712 ATLASSERT(SUCCEEDED(hr) && spBindInfo != 0); | 712 |
713 } | 713 //We return INET_E_REDIRECT_FAILED in case we have iframe blocking. |
714 if (SUCCEEDED(hr)) | 714 if (hr == INET_E_REDIRECT_FAILED) |
715 { | 715 { |
716 hr = pTargetProtocol->Start(szUrl, spSink, spBindInfo, grfPI, | 716 return hr; |
717 dwReserved); | 717 } |
718 } | 718 CComPtr<IInternetProtocolSink> spSink; |
719 else | 719 CComPtr<IInternetBindInfo> spBindInfo; |
720 { | 720 if (SUCCEEDED(hr)) |
721 | 721 { |
722 } | 722 hr = m_internetSink.QueryInterface(&spSink); |
723 return hr; | 723 ATLASSERT(SUCCEEDED(hr) && spSink != 0); |
724 } | 724 } |
725 template <class Sink> | 725 if (SUCCEEDED(hr)) |
726 inline HRESULT CustomSinkStartPolicy<Sink>::Read(/* [in, out] */ void *pv,/* [in ] */ ULONG cb,/* [out] */ ULONG *pcbRead) | 726 { |
727 { | 727 hr = m_internetSink.QueryInterface(&spBindInfo); |
728 return m_internetSink.Read(pv, cb, pcbRead); | 728 ATLASSERT(SUCCEEDED(hr) && spBindInfo != 0); |
729 } | 729 } |
730 | 730 if (SUCCEEDED(hr)) |
731 // ===== CInternetProtocol ===== | 731 { |
732 | 732 hr = pTargetProtocol->Start(szUrl, spSink, spBindInfo, grfPI, |
733 template <class StartPolicy, class ThreadModel> | 733 dwReserved); |
734 inline CInternetProtocol<StartPolicy, ThreadModel>::CInternetProtocol() : | 734 } |
735 StartPolicy(GetUnknown()) | 735 else |
736 { | 736 { |
737 } | 737 |
738 | 738 } |
739 // IInternetProtocolRoot | 739 return hr; |
740 template <class StartPolicy, class ThreadModel> | 740 } |
741 inline STDMETHODIMP CInternetProtocol<StartPolicy, ThreadModel>::Start( | 741 template <class Sink> |
742 LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, | 742 inline HRESULT CustomSinkStartPolicy<Sink>::Read(/* [in, out] */ void *pv,/* [ in] */ ULONG cb,/* [out] */ ULONG *pcbRead) |
743 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) | 743 { |
744 { | 744 return m_internetSink.Read(pv, cb, pcbRead); |
745 ATLASSERT(m_spInternetProtocol != 0); | 745 } |
746 if (!m_spInternetProtocol) | 746 |
747 { | 747 // ===== CInternetProtocol ===== |
748 return E_UNEXPECTED; | 748 |
749 } | 749 template <class StartPolicy, class ThreadModel> |
750 | 750 inline CInternetProtocol<StartPolicy, ThreadModel>::CInternetProtocol() : |
751 return StartPolicy::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, | 751 StartPolicy(GetUnknown()) |
752 dwReserved, m_spInternetProtocol); | 752 { |
753 } | 753 } |
754 template <class StartPolicy, class ThreadModel> | 754 |
755 inline STDMETHODIMP CInternetProtocol<StartPolicy, ThreadModel>::Read( | 755 // IInternetProtocolRoot |
756 /* [in, out] */ void *pv, | 756 template <class StartPolicy, class ThreadModel> |
757 /* [in] */ ULONG cb, | 757 inline STDMETHODIMP CInternetProtocol<StartPolicy, ThreadModel>::Start( |
758 /* [out] */ ULONG *pcbRead) | 758 LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, |
759 { | 759 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved) |
760 return StartPolicy::Read(pv, cb, pcbRead); | 760 { |
761 } | 761 ATLASSERT(m_spInternetProtocol != 0); |
762 if (!m_spInternetProtocol) | |
763 { | |
764 return E_UNEXPECTED; | |
765 } | |
766 | |
767 return StartPolicy::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, | |
768 dwReserved, m_spInternetProtocol); | |
769 } | |
770 template <class StartPolicy, class ThreadModel> | |
771 inline STDMETHODIMP CInternetProtocol<StartPolicy, ThreadModel>::Read( | |
772 /* [in, out] */ void *pv, | |
773 /* [in] */ ULONG cb, | |
774 /* [out] */ ULONG *pcbRead) | |
775 { | |
776 return StartPolicy::Read(pv, cb, pcbRead); | |
777 } | |
762 } // end namespace PassthroughAPP | 778 } // end namespace PassthroughAPP |
763 | 779 |
764 #endif // PASSTHROUGHAPP_PROTOCOLIMPL_INL | 780 #endif // PASSTHROUGHAPP_PROTOCOLIMPL_INL |
OLD | NEW |