ReactOS 0.4.17-dev-357-ga8f14ff
protocol.c File Reference
#include <assert.h>
#include "mimeole.h"
#include "inetcomm_private.h"
#include "wine/debug.h"
Include dependency graph for protocol.c:

Go to the source code of this file.

Classes

struct  MimeHtmlProtocol
 
struct  mhtml_url_t
 
struct  MimeHtmlBinding
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (inetcomm)
 
static HRESULT parse_mhtml_url (const WCHAR *url, mhtml_url_t *r)
 
static HRESULT report_result (MimeHtmlProtocol *protocol, HRESULT result)
 
static HRESULT on_mime_message_available (MimeHtmlProtocol *protocol, IMimeMessage *mime_message)
 
static HRESULT load_mime_message (IStream *stream, IMimeMessage **ret)
 
static MimeHtmlBindingimpl_from_IBindStatusCallback (IBindStatusCallback *iface)
 
static HRESULT WINAPI BindStatusCallback_QueryInterface (IBindStatusCallback *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI BindStatusCallback_AddRef (IBindStatusCallback *iface)
 
static ULONG WINAPI BindStatusCallback_Release (IBindStatusCallback *iface)
 
static HRESULT WINAPI BindStatusCallback_OnStartBinding (IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
 
static HRESULT WINAPI BindStatusCallback_GetPriority (IBindStatusCallback *iface, LONG *pnPriority)
 
static HRESULT WINAPI BindStatusCallback_OnLowResource (IBindStatusCallback *iface, DWORD dwReserved)
 
static HRESULT WINAPI BindStatusCallback_OnProgress (IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
 
static HRESULT WINAPI BindStatusCallback_OnStopBinding (IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
 
static HRESULT WINAPI BindStatusCallback_GetBindInfo (IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
 
static HRESULT WINAPI BindStatusCallback_OnDataAvailable (IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
 
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable (IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
 
static MimeHtmlProtocolimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI MimeHtmlProtocol_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI MimeHtmlProtocol_AddRef (IUnknown *iface)
 
static ULONG WINAPI MimeHtmlProtocol_Release (IUnknown *iface)
 
static MimeHtmlProtocolimpl_from_IInternetProtocol (IInternetProtocol *iface)
 
static HRESULT WINAPI InternetProtocol_QueryInterface (IInternetProtocol *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI InternetProtocol_AddRef (IInternetProtocol *iface)
 
static ULONG WINAPI InternetProtocol_Release (IInternetProtocol *iface)
 
static HRESULT WINAPI MimeHtmlProtocol_Start (IInternetProtocol *iface, const WCHAR *szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
 
static HRESULT WINAPI MimeHtmlProtocol_Continue (IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
 
static HRESULT WINAPI MimeHtmlProtocol_Abort (IInternetProtocol *iface, HRESULT hrReason, DWORD dwOptions)
 
static HRESULT WINAPI MimeHtmlProtocol_Terminate (IInternetProtocol *iface, DWORD dwOptions)
 
static HRESULT WINAPI MimeHtmlProtocol_Suspend (IInternetProtocol *iface)
 
static HRESULT WINAPI MimeHtmlProtocol_Resume (IInternetProtocol *iface)
 
static HRESULT WINAPI MimeHtmlProtocol_Read (IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI MimeHtmlProtocol_Seek (IInternetProtocol *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI MimeHtmlProtocol_LockRequest (IInternetProtocol *iface, DWORD dwOptions)
 
static HRESULT WINAPI MimeHtmlProtocol_UnlockRequest (IInternetProtocol *iface)
 
static MimeHtmlProtocolimpl_from_IInternetProtocolInfo (IInternetProtocolInfo *iface)
 
static HRESULT WINAPI MimeHtmlProtocolInfo_QueryInterface (IInternetProtocolInfo *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI MimeHtmlProtocolInfo_AddRef (IInternetProtocolInfo *iface)
 
static ULONG WINAPI MimeHtmlProtocolInfo_Release (IInternetProtocolInfo *iface)
 
static HRESULT WINAPI MimeHtmlProtocolInfo_ParseUrl (IInternetProtocolInfo *iface, LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
 
static HRESULT WINAPI MimeHtmlProtocolInfo_CombineUrl (IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
 
static HRESULT WINAPI MimeHtmlProtocolInfo_CompareUrl (IInternetProtocolInfo *iface, LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
 
static HRESULT WINAPI MimeHtmlProtocolInfo_QueryInfo (IInternetProtocolInfo *iface, LPCWSTR pwzUrl, QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
 
HRESULT MimeHtmlProtocol_create (IUnknown *outer, void **obj)
 

Variables

static const WCHAR mhtml_prefixW [] = L"mhtml:"
 
static const WCHAR mhtml_separatorW [] = L"!x-usc:"
 
static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
 
static const IUnknownVtbl MimeHtmlProtocolInnerVtbl
 
static const IInternetProtocolVtbl MimeHtmlProtocolVtbl
 
static const IInternetProtocolInfoVtbl MimeHtmlProtocolInfoVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file protocol.c.

Function Documentation

◆ BindStatusCallback_AddRef()

static ULONG WINAPI BindStatusCallback_AddRef ( IBindStatusCallback iface)
static

Definition at line 210 of file protocol.c.

211{
214
215 TRACE("(%p) ref=%ld\n", This, ref);
216
217 return ref;
218}
#define InterlockedIncrement
Definition: armddk.h:53
static MimeHtmlBinding * impl_from_IBindStatusCallback(IBindStatusCallback *iface)
Definition: protocol.c:184
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48

◆ BindStatusCallback_GetBindInfo()

static HRESULT WINAPI BindStatusCallback_GetBindInfo ( IBindStatusCallback iface,
DWORD grfBINDF,
BINDINFO *  pbindinfo 
)
static

Definition at line 294 of file protocol.c.

296{
298
299 TRACE("(%p)\n", This);
300
301 *grfBINDF = BINDF_ASYNCHRONOUS;
302 return S_OK;
303}
#define S_OK
Definition: intsafe.h:52

◆ BindStatusCallback_GetPriority()

static HRESULT WINAPI BindStatusCallback_GetPriority ( IBindStatusCallback iface,
LONG pnPriority 
)
static

Definition at line 249 of file protocol.c.

250{
251 return E_NOTIMPL;
252}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ BindStatusCallback_OnDataAvailable()

static HRESULT WINAPI BindStatusCallback_OnDataAvailable ( IBindStatusCallback iface,
DWORD  grfBSCF,
DWORD  dwSize,
FORMATETC *  pformatetc,
STGMEDIUM *  pstgmed 
)
static

Definition at line 305 of file protocol.c.

307{
309 BYTE buf[4*1024];
310 DWORD read;
312
313 TRACE("(%p)\n", This);
314
315 assert(pstgmed->tymed == TYMED_ISTREAM);
316
317 while(1) {
318 hres = IStream_Read(pstgmed->pstm, buf, sizeof(buf), &read);
319 if(FAILED(hres))
320 return hres;
321 if(!read)
322 break;
323 hres = IStream_Write(This->stream, buf, read, NULL);
324 if(FAILED(hres))
325 return hres;
326 }
327 return S_OK;
328}
#define read
Definition: acwin.h:97
#define NULL
Definition: types.h:112
#define assert(_expr)
Definition: assert.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hres
Definition: protocol.c:465
unsigned char BYTE
Definition: xxhash.c:193

◆ BindStatusCallback_OnLowResource()

static HRESULT WINAPI BindStatusCallback_OnLowResource ( IBindStatusCallback iface,
DWORD  dwReserved 
)
static

Definition at line 254 of file protocol.c.

255{
256 return E_NOTIMPL;
257}

◆ BindStatusCallback_OnObjectAvailable()

static HRESULT WINAPI BindStatusCallback_OnObjectAvailable ( IBindStatusCallback iface,
REFIID  riid,
IUnknown punk 
)
static

Definition at line 330 of file protocol.c.

332{
333 ERR("\n");
334 return E_NOTIMPL;
335}
#define ERR(fmt,...)
Definition: precomp.h:57

◆ BindStatusCallback_OnProgress()

static HRESULT WINAPI BindStatusCallback_OnProgress ( IBindStatusCallback iface,
ULONG  ulProgress,
ULONG  ulProgressMax,
ULONG  ulStatusCode,
LPCWSTR  szStatusText 
)
static

Definition at line 259 of file protocol.c.

261{
263 TRACE("(%p)->(%lu/%lu %lu %s)\n", This, ulProgress, ulProgressMax, ulStatusCode, debugstr_w(szStatusText));
264 return S_OK;
265}
#define debugstr_w
Definition: kernel32.h:32

◆ BindStatusCallback_OnStartBinding()

static HRESULT WINAPI BindStatusCallback_OnStartBinding ( IBindStatusCallback iface,
DWORD  dwReserved,
IBinding pib 
)
static

Definition at line 238 of file protocol.c.

240{
242
243 TRACE("(%p)->(%lx %p)\n", This, dwReserved, pib);
244
245 assert(!This->stream);
246 return CreateStreamOnHGlobal(NULL, TRUE, &This->stream);
247}
#define TRUE
Definition: types.h:120
HRESULT WINAPI CreateStreamOnHGlobal(HGLOBAL hGlobal, BOOL delete_on_release, IStream **stream)
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95

◆ BindStatusCallback_OnStopBinding()

static HRESULT WINAPI BindStatusCallback_OnStopBinding ( IBindStatusCallback iface,
HRESULT  hresult,
LPCWSTR  szError 
)
static

Definition at line 267 of file protocol.c.

268{
270 IMimeMessage *mime_message = NULL;
271
272 TRACE("(%p)->(%lx %s)\n", This, hresult, debugstr_w(szError));
273
274 if(SUCCEEDED(hresult)) {
275 hresult = load_mime_message(This->stream, &mime_message);
276 IStream_Release(This->stream);
277 This->stream = NULL;
278 }
279
280 This->status = hresult;
281
282 if(mime_message)
283 on_mime_message_available(This->protocol, mime_message);
284 else
285 report_result(This->protocol, hresult);
286
287 if(mime_message)
288 IMimeMessage_Release(mime_message);
289 IInternetProtocol_Release(&This->protocol->IInternetProtocol_iface);
290 This->protocol = NULL;
291 return S_OK;
292}
static HRESULT load_mime_message(IStream *stream, IMimeMessage **ret)
Definition: protocol.c:163
static HRESULT on_mime_message_available(MimeHtmlProtocol *protocol, IMimeMessage *mime_message)
Definition: protocol.c:98
static HRESULT report_result(MimeHtmlProtocol *protocol, HRESULT result)
Definition: protocol.c:87
#define SUCCEEDED(hr)
Definition: intsafe.h:50

◆ BindStatusCallback_QueryInterface()

static HRESULT WINAPI BindStatusCallback_QueryInterface ( IBindStatusCallback iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 189 of file protocol.c.

191{
193
195 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
196 *ppv = &This->IBindStatusCallback_iface;
197 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
198 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This, ppv);
199 *ppv = &This->IBindStatusCallback_iface;
200 }else {
201 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
202 *ppv = NULL;
203 return E_NOINTERFACE;
204 }
205
206 IUnknown_AddRef((IUnknown*)*ppv);
207 return S_OK;
208}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ BindStatusCallback_Release()

static ULONG WINAPI BindStatusCallback_Release ( IBindStatusCallback iface)
static

Definition at line 220 of file protocol.c.

221{
224
225 TRACE("(%p) ref=%ld\n", This, ref);
226
227 if(!ref) {
228 if(This->protocol)
229 IInternetProtocol_Release(&This->protocol->IInternetProtocol_iface);
230 if(This->stream)
231 IStream_Release(This->stream);
232 free(This);
233 }
234
235 return ref;
236}
#define InterlockedDecrement
Definition: armddk.h:52
#define free
Definition: debug_ros.c:5

◆ impl_from_IBindStatusCallback()

static MimeHtmlBinding * impl_from_IBindStatusCallback ( IBindStatusCallback iface)
inlinestatic

◆ impl_from_IInternetProtocol()

◆ impl_from_IInternetProtocolInfo()

◆ impl_from_IUnknown()

◆ InternetProtocol_AddRef()

static ULONG WINAPI InternetProtocol_AddRef ( IInternetProtocol iface)
static

Definition at line 428 of file protocol.c.

429{
431 return IUnknown_AddRef(This->outer_unk);
432}
static MimeHtmlProtocol * impl_from_IInternetProtocol(IInternetProtocol *iface)
Definition: protocol.c:417

◆ InternetProtocol_QueryInterface()

static HRESULT WINAPI InternetProtocol_QueryInterface ( IInternetProtocol iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 422 of file protocol.c.

423{
425 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
426}

◆ InternetProtocol_Release()

static ULONG WINAPI InternetProtocol_Release ( IInternetProtocol iface)
static

Definition at line 434 of file protocol.c.

435{
437 return IUnknown_Release(This->outer_unk);
438}

◆ load_mime_message()

static HRESULT load_mime_message ( IStream stream,
IMimeMessage **  ret 
)
static

Definition at line 163 of file protocol.c.

164{
165 IMimeMessage *mime_message;
167
168 hres = MimeMessage_create(NULL, (void**)&mime_message);
169 if(FAILED(hres))
170 return hres;
171
172 IMimeMessage_InitNew(mime_message);
173
174 hres = IMimeMessage_Load(mime_message, stream);
175 if(FAILED(hres)) {
176 IMimeMessage_Release(mime_message);
177 return hres;
178 }
179
180 *ret = mime_message;
181 return S_OK;
182}
return ret
Definition: mutex.c:146
HRESULT MimeMessage_create(IUnknown *outer, void **obj)
Definition: mimeole.c:3068
Definition: parse.h:23

Referenced by BindStatusCallback_OnStopBinding().

◆ MimeHtmlProtocol_Abort()

static HRESULT WINAPI MimeHtmlProtocol_Abort ( IInternetProtocol iface,
HRESULT  hrReason,
DWORD  dwOptions 
)
static

Definition at line 520 of file protocol.c.

521{
523 FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
524 return E_NOTIMPL;
525}
#define FIXME(fmt,...)
Definition: precomp.h:53
DWORD dwOptions
Definition: solitaire.cpp:25

◆ MimeHtmlProtocol_AddRef()

static ULONG WINAPI MimeHtmlProtocol_AddRef ( IUnknown iface)
static

Definition at line 382 of file protocol.c.

383{
386
387 TRACE("(%p) ref=%ld\n", This, ref);
388
389 return ref;
390}
static MimeHtmlProtocol * impl_from_IUnknown(IUnknown *iface)
Definition: protocol.c:351
uint32_t ULONG
Definition: typedefs.h:59

◆ MimeHtmlProtocol_Continue()

static HRESULT WINAPI MimeHtmlProtocol_Continue ( IInternetProtocol iface,
PROTOCOLDATA *  pProtocolData 
)
static

Definition at line 513 of file protocol.c.

514{
516 FIXME("(%p)->(%p)\n", This, pProtocolData);
517 return E_NOTIMPL;
518}

◆ MimeHtmlProtocol_create()

HRESULT MimeHtmlProtocol_create ( IUnknown outer,
void **  obj 
)

Definition at line 710 of file protocol.c.

711{
713
714 protocol = malloc(sizeof(*protocol));
715 if(!protocol)
716 return E_OUTOFMEMORY;
717
718 protocol->IUnknown_inner.lpVtbl = &MimeHtmlProtocolInnerVtbl;
719 protocol->IInternetProtocol_iface.lpVtbl = &MimeHtmlProtocolVtbl;
720 protocol->IInternetProtocolInfo_iface.lpVtbl = &MimeHtmlProtocolInfoVtbl;
721 protocol->ref = 1;
722 protocol->outer_unk = outer ? outer : &protocol->IUnknown_inner;
723 protocol->location = NULL;
724 protocol->stream = NULL;
725 protocol->sink = NULL;
726
727 *obj = &protocol->IUnknown_inner;
728 return S_OK;
729}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define malloc
Definition: debug_ros.c:4
static const IUnknownVtbl MimeHtmlProtocolInnerVtbl
Definition: protocol.c:411
static const IInternetProtocolInfoVtbl MimeHtmlProtocolInfoVtbl
Definition: protocol.c:700
static const IInternetProtocolVtbl MimeHtmlProtocolVtbl
Definition: protocol.c:587
static IUnknown * outer
Definition: compobj.c:82

◆ MimeHtmlProtocol_LockRequest()

static HRESULT WINAPI MimeHtmlProtocol_LockRequest ( IInternetProtocol iface,
DWORD  dwOptions 
)
static

Definition at line 573 of file protocol.c.

574{
576 FIXME("(%p)->(%ld)\n", This, dwOptions);
577 return S_OK;
578}

◆ MimeHtmlProtocol_QueryInterface()

static HRESULT WINAPI MimeHtmlProtocol_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 356 of file protocol.c.

357{
359
361 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
362 *ppv = &This->IInternetProtocol_iface;
363 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
364 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
365 *ppv = &This->IInternetProtocol_iface;
366 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
367 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
368 *ppv = &This->IInternetProtocol_iface;
369 }else if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
370 TRACE("(%p)->(IID_IInternetProtocolInfo %p)\n", This, ppv);
371 *ppv = &This->IInternetProtocolInfo_iface;
372 }else {
373 FIXME("unknown interface %s\n", debugstr_guid(riid));
374 *ppv = NULL;
375 return E_NOINTERFACE;
376 }
377
378 IUnknown_AddRef((IUnknown*)*ppv);
379 return S_OK;
380}

◆ MimeHtmlProtocol_Read()

static HRESULT WINAPI MimeHtmlProtocol_Read ( IInternetProtocol iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 548 of file protocol.c.

549{
551 ULONG read = 0;
553
554 TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
555
556 hres = IStream_Read(This->stream, pv, cb, &read);
557 if(pcbRead)
558 *pcbRead = read;
559 if(hres != S_OK)
560 return hres;
561
562 return read ? S_OK : S_FALSE;
563}
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
#define S_FALSE
Definition: winerror.h:3451

◆ MimeHtmlProtocol_Release()

static ULONG WINAPI MimeHtmlProtocol_Release ( IUnknown iface)
static

Definition at line 392 of file protocol.c.

393{
396
397 TRACE("(%p) ref=%lx\n", This, ref);
398
399 if(!ref) {
400 if(This->sink)
401 IInternetProtocolSink_Release(This->sink);
402 if(This->stream)
403 IStream_Release(This->stream);
404 free(This->location);
405 free(This);
406 }
407
408 return ref;
409}

◆ MimeHtmlProtocol_Resume()

static HRESULT WINAPI MimeHtmlProtocol_Resume ( IInternetProtocol iface)
static

Definition at line 541 of file protocol.c.

542{
544 FIXME("(%p)\n", This);
545 return E_NOTIMPL;
546}

◆ MimeHtmlProtocol_Seek()

static HRESULT WINAPI MimeHtmlProtocol_Seek ( IInternetProtocol iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 565 of file protocol.c.

567{
569 FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.LowPart, dwOrigin, plibNewPosition);
570 return E_NOTIMPL;
571}
ULONG LowPart
Definition: typedefs.h:106

◆ MimeHtmlProtocol_Start()

static HRESULT WINAPI MimeHtmlProtocol_Start ( IInternetProtocol iface,
const WCHAR szUrl,
IInternetProtocolSink pOIProtSink,
IInternetBindInfo pOIBindInfo,
DWORD  grfPI,
HANDLE_PTR  dwReserved 
)
static

Definition at line 440 of file protocol.c.

443{
445 BINDINFO bindinfo = { sizeof(bindinfo) };
447 IBindCtx *bind_ctx;
450 DWORD bindf = 0;
451 IMoniker *mon;
453
454 TRACE("(%p)->(%s %p %p %08lx %Ix)\n", This, debugstr_w(szUrl), pOIProtSink, pOIBindInfo, grfPI, dwReserved);
455
456 hres = parse_mhtml_url(szUrl, &url);
457 if(FAILED(hres))
458 return hres;
459
460 if(url.location && !(This->location = wcsdup(url.location)))
461 return E_OUTOFMEMORY;
462
463 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
464 if(FAILED(hres)) {
465 WARN("GetBindInfo failed: %08lx\n", hres);
466 return hres;
467 }
468 if((bindf & (BINDF_ASYNCHRONOUS|BINDF_FROMURLMON|BINDF_NEEDFILE)) != (BINDF_ASYNCHRONOUS|BINDF_FROMURLMON|BINDF_NEEDFILE))
469 FIXME("unsupported bindf %lx\n", bindf);
470
471 IInternetProtocolSink_AddRef(This->sink = pOIProtSink);
472
474 if(!binding)
475 return E_OUTOFMEMORY;
476 memcpy(binding->url, url.mhtml, url.mhtml_len*sizeof(WCHAR));
477 binding->url[url.mhtml_len] = 0;
478
479 hres = CreateURLMoniker(NULL, binding->url, &mon);
480 if(FAILED(hres)) {
481 free(binding);
482 return hres;
483 }
484
485 binding->IBindStatusCallback_iface.lpVtbl = &BindStatusCallbackVtbl;
486 binding->ref = 1;
487 binding->status = E_PENDING;
488 binding->stream = NULL;
489 binding->protocol = NULL;
490
491 hres = CreateAsyncBindCtx(0, &binding->IBindStatusCallback_iface, NULL, &bind_ctx);
492 if(FAILED(hres)) {
493 IMoniker_Release(mon);
494 IBindStatusCallback_Release(&binding->IBindStatusCallback_iface);
495 return hres;
496 }
497
498 IInternetProtocol_AddRef(&This->IInternetProtocol_iface);
499 binding->protocol = This;
500
501 hres = IMoniker_BindToStorage(mon, bind_ctx, NULL, &IID_IStream, (void**)&stream);
502 IBindCtx_Release(bind_ctx);
503 IMoniker_Release(mon);
504 if(stream)
505 IStream_Release(stream);
506 hres = binding->status;
507 IBindStatusCallback_Release(&binding->IBindStatusCallback_iface);
508 if(FAILED(hres) && hres != E_PENDING)
510 return hres;
511}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_PENDING
Definition: dinput.h:172
static HRESULT parse_mhtml_url(const WCHAR *url, mhtml_url_t *r)
Definition: protocol.c:63
static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
Definition: protocol.c:337
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const WCHAR url[]
Definition: encode.c:1384
static DWORD bindf
Definition: protocol.c:70
static RPC_BINDING_HANDLE binding
Definition: server.c:166
short WCHAR
Definition: pedump.c:58
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
Definition: umon.c:732
HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx **pbind)
Definition: bindctx.c:899

◆ MimeHtmlProtocol_Suspend()

static HRESULT WINAPI MimeHtmlProtocol_Suspend ( IInternetProtocol iface)
static

Definition at line 534 of file protocol.c.

535{
537 FIXME("(%p)\n", This);
538 return E_NOTIMPL;
539}

◆ MimeHtmlProtocol_Terminate()

static HRESULT WINAPI MimeHtmlProtocol_Terminate ( IInternetProtocol iface,
DWORD  dwOptions 
)
static

Definition at line 527 of file protocol.c.

528{
530 TRACE("(%p)->(%08lx)\n", This, dwOptions);
531 return S_OK;
532}

◆ MimeHtmlProtocol_UnlockRequest()

static HRESULT WINAPI MimeHtmlProtocol_UnlockRequest ( IInternetProtocol iface)
static

Definition at line 580 of file protocol.c.

581{
583 FIXME("(%p)\n", This);
584 return S_OK;
585}

◆ MimeHtmlProtocolInfo_AddRef()

static ULONG WINAPI MimeHtmlProtocolInfo_AddRef ( IInternetProtocolInfo iface)
static

Definition at line 614 of file protocol.c.

615{
617 return IUnknown_AddRef(This->outer_unk);
618}
static MimeHtmlProtocol * impl_from_IInternetProtocolInfo(IInternetProtocolInfo *iface)
Definition: protocol.c:603

◆ MimeHtmlProtocolInfo_CombineUrl()

static HRESULT WINAPI MimeHtmlProtocolInfo_CombineUrl ( IInternetProtocolInfo iface,
LPCWSTR  pwzBaseUrl,
LPCWSTR  pwzRelativeUrl,
DWORD  dwCombineFlags,
LPWSTR  pwzResult,
DWORD  cchResult,
DWORD pcchResult,
DWORD  dwReserved 
)
static

Definition at line 636 of file protocol.c.

639{
641 size_t len = lstrlenW(mhtml_prefixW);
643 WCHAR *p;
645
646 TRACE("(%p)->(%s %s %08lx %p %ld %p %ld)\n", This, debugstr_w(pwzBaseUrl),
647 debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult,
648 pcchResult, dwReserved);
649
650 hres = parse_mhtml_url(pwzBaseUrl, &url);
651 if(FAILED(hres))
652 return hres;
653
654 if(!wcsnicmp(pwzRelativeUrl, mhtml_prefixW, len)) {
655 FIXME("Relative URL is mhtml protocol\n");
656 return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
657 }
658
659 len += url.mhtml_len;
660 if(*pwzRelativeUrl)
661 len += lstrlenW(pwzRelativeUrl) + lstrlenW(mhtml_separatorW);
662 if(len >= cchResult) {
663 *pcchResult = 0;
664 return E_FAIL;
665 }
666
667 lstrcpyW(pwzResult, mhtml_prefixW);
668 p = pwzResult + lstrlenW(mhtml_prefixW);
669 memcpy(p, url.mhtml, url.mhtml_len*sizeof(WCHAR));
670 p += url.mhtml_len;
671 if(*pwzRelativeUrl) {
673 lstrcatW(p, pwzRelativeUrl);
674 }else {
675 *p = 0;
676 }
677
678 *pcchResult = len;
679 return S_OK;
680}
#define E_FAIL
Definition: ddrawi.h:102
#define wcsnicmp
Definition: compat.h:14
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
static const WCHAR mhtml_prefixW[]
Definition: protocol.c:60
static const WCHAR mhtml_separatorW[]
Definition: protocol.c:61
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

◆ MimeHtmlProtocolInfo_CompareUrl()

static HRESULT WINAPI MimeHtmlProtocolInfo_CompareUrl ( IInternetProtocolInfo iface,
LPCWSTR  pwzUrl1,
LPCWSTR  pwzUrl2,
DWORD  dwCompareFlags 
)
static

Definition at line 682 of file protocol.c.

684{
686 FIXME("(%p)->(%s %s %08lx)\n", This, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
687 return E_NOTIMPL;
688}

◆ MimeHtmlProtocolInfo_ParseUrl()

static HRESULT WINAPI MimeHtmlProtocolInfo_ParseUrl ( IInternetProtocolInfo iface,
LPCWSTR  pwzUrl,
PARSEACTION  ParseAction,
DWORD  dwParseFlags,
LPWSTR  pwzResult,
DWORD  cchResult,
DWORD pcchResult,
DWORD  dwReserved 
)
static

Definition at line 626 of file protocol.c.

629{
631 FIXME("(%p)->(%s %d %lx %p %ld %p %ld)\n", This, debugstr_w(pwzUrl), ParseAction,
632 dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
633 return INET_E_DEFAULT_ACTION;
634}

◆ MimeHtmlProtocolInfo_QueryInfo()

static HRESULT WINAPI MimeHtmlProtocolInfo_QueryInfo ( IInternetProtocolInfo iface,
LPCWSTR  pwzUrl,
QUERYOPTION  QueryOption,
DWORD  dwQueryFlags,
LPVOID  pBuffer,
DWORD  cbBuffer,
DWORD pcbBuf,
DWORD  dwReserved 
)
static

Definition at line 690 of file protocol.c.

693{
695 FIXME("(%p)->(%s %08x %08lx %p %ld %p %ld)\n", This, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
696 cbBuffer, pcbBuf, dwReserved);
697 return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
698}
PVOID pBuffer

◆ MimeHtmlProtocolInfo_QueryInterface()

static HRESULT WINAPI MimeHtmlProtocolInfo_QueryInterface ( IInternetProtocolInfo iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 608 of file protocol.c.

609{
611 return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
612}

◆ MimeHtmlProtocolInfo_Release()

static ULONG WINAPI MimeHtmlProtocolInfo_Release ( IInternetProtocolInfo iface)
static

Definition at line 620 of file protocol.c.

621{
623 return IUnknown_Release(This->outer_unk);
624}

◆ on_mime_message_available()

static HRESULT on_mime_message_available ( MimeHtmlProtocol protocol,
IMimeMessage mime_message 
)
static

Definition at line 98 of file protocol.c.

99{
100 FINDBODY find = {NULL};
101 IMimeBody *mime_body;
102 PROPVARIANT value;
103 HBODY body;
105
106 hres = IMimeMessage_FindFirst(mime_message, &find, &body);
107 if(FAILED(hres))
108 return report_result(protocol, hres);
109
110 if(protocol->location) {
111 BOOL found = FALSE;
112 do {
113 hres = IMimeMessage_FindNext(mime_message, &find, &body);
114 if(FAILED(hres)) {
115 WARN("location %s not found\n", debugstr_w(protocol->location));
116 return report_result(protocol, hres);
117 }
118
119 value.vt = VT_LPWSTR;
120 hres = IMimeMessage_GetBodyProp(mime_message, body, "content-location", 0, &value);
121 if(hres == MIME_E_NOT_FOUND)
122 continue;
123 if(FAILED(hres))
124 return report_result(protocol, hres);
125
126 found = !lstrcmpW(protocol->location, value.pwszVal);
128 }while(!found);
129 }else {
130 hres = IMimeMessage_FindNext(mime_message, &find, &body);
131 if(FAILED(hres)) {
132 WARN("location %s not found\n", debugstr_w(protocol->location));
133 return report_result(protocol, hres);
134 }
135 }
136
137 hres = IMimeMessage_BindToObject(mime_message, body, &IID_IMimeBody, (void**)&mime_body);
138 if(FAILED(hres))
139 return report_result(protocol, hres);
140
141 value.vt = VT_LPWSTR;
142 hres = IMimeBody_GetProp(mime_body, "content-type", 0, &value);
143 if(SUCCEEDED(hres)) {
144 hres = IInternetProtocolSink_ReportProgress(protocol->sink, BINDSTATUS_MIMETYPEAVAILABLE, value.pwszVal);
146 }
147
148 /* FIXME: Create and report cache file. */
149
150 hres = IMimeBody_GetData(mime_body, IET_DECODED, &protocol->stream);
151 if(FAILED(hres))
152 return report_result(protocol, hres);
153
154 IInternetProtocolSink_ReportData(protocol->sink, BSCF_FIRSTDATANOTIFICATION
155 | BSCF_INTERMEDIATEDATANOTIFICATION
156 | BSCF_LASTDATANOTIFICATION
157 | BSCF_DATAFULLYAVAILABLE
158 | BSCF_AVAILABLEDATASIZEUNKNOWN, 0, 0);
159
160 return report_result(protocol, S_OK);
161}
static TAGID TAGID find
Definition: db.cpp:156
#define FALSE
Definition: types.h:117
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: combase.c:709
@ VT_LPWSTR
Definition: compat.h:2325
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
unsigned int BOOL
Definition: ntddk_ex.h:94
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:100
Definition: pdh_main.c:96

Referenced by BindStatusCallback_OnStopBinding().

◆ parse_mhtml_url()

static HRESULT parse_mhtml_url ( const WCHAR url,
mhtml_url_t r 
)
static

Definition at line 63 of file protocol.c.

64{
65 const WCHAR *p;
66
68 return E_FAIL;
69
70 r->mhtml = url + lstrlenW(mhtml_prefixW);
71 p = wcschr(r->mhtml, '!');
72 if(p) {
73 r->mhtml_len = p - r->mhtml;
74 /* FIXME: We handle '!' and '!x-usc:' in URLs as the same thing. Those should not be the same. */
77 else
78 p++;
79 }else {
80 r->mhtml_len = lstrlenW(r->mhtml);
81 }
82
83 r->location = p;
84 return S_OK;
85}
#define wcschr
Definition: compat.h:17
_ACRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:523
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

Referenced by MimeHtmlProtocol_Start(), and MimeHtmlProtocolInfo_CombineUrl().

◆ report_result()

static HRESULT report_result ( MimeHtmlProtocol protocol,
HRESULT  result 
)
static

Definition at line 87 of file protocol.c.

88{
89 if(protocol->sink) {
90 IInternetProtocolSink_ReportResult(protocol->sink, result, ERROR_SUCCESS, NULL);
91 IInternetProtocolSink_Release(protocol->sink);
92 protocol->sink = NULL;
93 }
94
95 return result;
96}
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint64EXT * result
Definition: glext.h:11304

Referenced by all_data_read(), BindStatusCallback_OnStopBinding(), ITSProtocol_Start(), MimeHtmlProtocol_Start(), on_mime_message_available(), protocol_abort(), protocol_continue(), protocol_read(), protocol_start(), start_downloading(), and write_post_stream().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( inetcomm  )

Variable Documentation

◆ BindStatusCallbackVtbl

const IBindStatusCallbackVtbl BindStatusCallbackVtbl
static
Initial value:
= {
}
static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
Definition: protocol.c:210
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk)
Definition: protocol.c:330
static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
Definition: protocol.c:305
static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
Definition: protocol.c:220
static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
Definition: protocol.c:294
static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
Definition: protocol.c:249
static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
Definition: protocol.c:267
static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib)
Definition: protocol.c:238
static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
Definition: protocol.c:259
static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD dwReserved)
Definition: protocol.c:254
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
Definition: protocol.c:189

Definition at line 337 of file protocol.c.

Referenced by MimeHtmlProtocol_Start().

◆ mhtml_prefixW

const WCHAR mhtml_prefixW[] = L"mhtml:"
static

Definition at line 60 of file protocol.c.

Referenced by MimeHtmlProtocolInfo_CombineUrl(), and parse_mhtml_url().

◆ mhtml_separatorW

const WCHAR mhtml_separatorW[] = L"!x-usc:"
static

Definition at line 61 of file protocol.c.

Referenced by MimeHtmlProtocolInfo_CombineUrl(), and parse_mhtml_url().

◆ MimeHtmlProtocolInfoVtbl

const IInternetProtocolInfoVtbl MimeHtmlProtocolInfoVtbl
static
Initial value:
= {
}
static HRESULT WINAPI MimeHtmlProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: protocol.c:636
static HRESULT WINAPI MimeHtmlProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl, QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
Definition: protocol.c:690
static ULONG WINAPI MimeHtmlProtocolInfo_Release(IInternetProtocolInfo *iface)
Definition: protocol.c:620
static HRESULT WINAPI MimeHtmlProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
Definition: protocol.c:626
static HRESULT WINAPI MimeHtmlProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
Definition: protocol.c:682
static HRESULT WINAPI MimeHtmlProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
Definition: protocol.c:608
static ULONG WINAPI MimeHtmlProtocolInfo_AddRef(IInternetProtocolInfo *iface)
Definition: protocol.c:614

Definition at line 700 of file protocol.c.

Referenced by MimeHtmlProtocol_create().

◆ MimeHtmlProtocolInnerVtbl

const IUnknownVtbl MimeHtmlProtocolInnerVtbl
static
Initial value:
= {
}
static ULONG WINAPI MimeHtmlProtocol_Release(IUnknown *iface)
Definition: protocol.c:392
static HRESULT WINAPI MimeHtmlProtocol_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: protocol.c:356
static ULONG WINAPI MimeHtmlProtocol_AddRef(IUnknown *iface)
Definition: protocol.c:382

Definition at line 411 of file protocol.c.

Referenced by MimeHtmlProtocol_create().

◆ MimeHtmlProtocolVtbl

const IInternetProtocolVtbl MimeHtmlProtocolVtbl
static
Initial value:
= {
}
static HRESULT WINAPI MimeHtmlProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
Definition: protocol.c:513
static ULONG WINAPI InternetProtocol_Release(IInternetProtocol *iface)
Definition: protocol.c:434
static HRESULT WINAPI MimeHtmlProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: protocol.c:565
static HRESULT WINAPI MimeHtmlProtocol_Start(IInternetProtocol *iface, const WCHAR *szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
Definition: protocol.c:440
static HRESULT WINAPI MimeHtmlProtocol_UnlockRequest(IInternetProtocol *iface)
Definition: protocol.c:580
static ULONG WINAPI InternetProtocol_AddRef(IInternetProtocol *iface)
Definition: protocol.c:428
static HRESULT WINAPI MimeHtmlProtocol_Read(IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: protocol.c:548
static HRESULT WINAPI MimeHtmlProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason, DWORD dwOptions)
Definition: protocol.c:520
static HRESULT WINAPI MimeHtmlProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
Definition: protocol.c:573
static HRESULT WINAPI MimeHtmlProtocol_Suspend(IInternetProtocol *iface)
Definition: protocol.c:534
static HRESULT WINAPI MimeHtmlProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
Definition: protocol.c:527
static HRESULT WINAPI InternetProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
Definition: protocol.c:422
static HRESULT WINAPI MimeHtmlProtocol_Resume(IInternetProtocol *iface)
Definition: protocol.c:541

Definition at line 587 of file protocol.c.

Referenced by MimeHtmlProtocol_create().