2 * Copyright 2005 Jacek Caban
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 /********************************************************************
39 * common ProtocolFactory implementation
42 #define PROTOCOLINFO(x) ((IInternetProtocolInfo*) &(x)->lpInternetProtocolInfoVtbl)
43 #define CLASSFACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl)
44 #define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
47 const IInternetProtocolInfoVtbl *lpInternetProtocolInfoVtbl;
48 const IClassFactoryVtbl *lpClassFactoryVtbl;
51 #define PROTOCOLINFO_THIS(iface) DEFINE_THIS(ProtocolFactory, InternetProtocolInfo, iface)
53 static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
55 ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
58 if(IsEqualGUID(&IID_IUnknown, riid)) {
59 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
60 *ppv = PROTOCOLINFO(This);
61 }else if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
62 TRACE("(%p)->(IID_IInternetProtocolInfo %p)\n", This, ppv);
63 *ppv = PROTOCOLINFO(This);
64 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
65 TRACE("(%p)->(IID_IClassFactory %p)\n", This, ppv);
66 *ppv = CLASSFACTORY(This);
70 WARN("unknown interface %s\n", debugstr_guid(riid));
74 IInternetProtocolInfo_AddRef(iface);
78 static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
80 ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
81 TRACE("(%p)\n", This);
86 static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
88 ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
89 TRACE("(%p)\n", This);
94 #undef PROTOCOLINFO_THIS
96 #define CLASSFACTORY_THIS(iface) DEFINE_THIS(ProtocolFactory, ClassFactory, iface)
98 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
100 ProtocolFactory *This = CLASSFACTORY_THIS(iface);
101 return IInternetProtocolInfo_QueryInterface(PROTOCOLINFO(This), riid, ppv);
104 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
106 ProtocolFactory *This = CLASSFACTORY_THIS(iface);
107 return IInternetProtocolInfo_AddRef(PROTOCOLINFO(This));
110 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
112 ProtocolFactory *This = CLASSFACTORY_THIS(iface);
113 return IInternetProtocolInfo_Release(PROTOCOLINFO(This));
116 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
118 ProtocolFactory *This = CLASSFACTORY_THIS(iface);
120 TRACE("(%p)->(%x)\n", This, dolock);
130 #undef CLASSFACTORY_THIS
132 /********************************************************************
133 * AboutProtocol implementation
137 const IInternetProtocolVtbl *lpInternetProtocolVtbl;
148 #define PROTOCOL_THIS(iface) DEFINE_THIS(AboutProtocol, InternetProtocol, iface)
150 static HRESULT WINAPI AboutProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
152 AboutProtocol *This = PROTOCOL_THIS(iface);
156 if(IsEqualGUID(&IID_IUnknown, riid)) {
157 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
159 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
160 *ppv = PROTOCOL(This);
161 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
162 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", iface, ppv);
163 *ppv = PROTOCOL(This);
164 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
165 TRACE("(%p)->(IID_IInternetProtocol %p)\n", iface, ppv);
166 *ppv = PROTOCOL(This);
167 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
168 FIXME("IServiceProvider is not implemented\n");
169 return E_NOINTERFACE;
173 TRACE("unknown interface %s\n", debugstr_guid(riid));
174 return E_NOINTERFACE;
177 IInternetProtocol_AddRef(iface);
181 static ULONG WINAPI AboutProtocol_AddRef(IInternetProtocol *iface)
183 AboutProtocol *This = PROTOCOL_THIS(iface);
184 ULONG ref = InterlockedIncrement(&This->ref);
185 TRACE("(%p) ref=%ld\n", iface, ref);
186 return This->pUnkOuter ? IUnknown_AddRef(This->pUnkOuter) : ref;
189 static ULONG WINAPI AboutProtocol_Release(IInternetProtocol *iface)
191 AboutProtocol *This = PROTOCOL_THIS(iface);
192 IUnknown *pUnkOuter = This->pUnkOuter;
193 ULONG ref = InterlockedDecrement(&This->ref);
195 TRACE("(%p) ref=%lx\n", iface, ref);
198 HeapFree(GetProcessHeap(), 0, This->data);
199 HeapFree(GetProcessHeap(), 0, This);
203 return pUnkOuter ? IUnknown_Release(pUnkOuter) : ref;
206 static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
207 IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
208 DWORD grfPI, DWORD dwReserved)
210 AboutProtocol *This = PROTOCOL_THIS(iface);
215 static const WCHAR html_begin[] = {0xfeff,'<','H','T','M','L','>',0};
216 static const WCHAR html_end[] = {'<','/','H','T','M','L','>',0};
217 static const WCHAR wszBlank[] = {'b','l','a','n','k',0};
218 static const WCHAR wszAbout[] = {'a','b','o','u','t',':'};
219 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
222 * the about protocol seems not to work as I would expect. It creates html document
223 * for a given url, eg. about:some_text -> <HTML>some_text</HTML> except for the case when
224 * some_text = "blank", when document is blank (<HTML></HMTL>). The same happens
225 * when the url does not have "about:" in the beginning.
228 TRACE("(%p)->(%s %p %p %08lx %ld)\n", This, debugstr_w(szUrl), pOIProtSink,
229 pOIBindInfo, grfPI, dwReserved);
231 memset(&bindinfo, 0, sizeof(bindinfo));
232 bindinfo.cbSize = sizeof(BINDINFO);
233 IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
235 if(strlenW(szUrl)>=sizeof(wszAbout)/sizeof(WCHAR) && !memcmp(wszAbout, szUrl, sizeof(wszAbout))) {
236 text = szUrl + sizeof(wszAbout)/sizeof(WCHAR);
237 if(!strcmpW(wszBlank, text))
241 This->data_len = sizeof(html_begin)+sizeof(html_end)-sizeof(WCHAR)
242 + (text ? strlenW(text)*sizeof(WCHAR) : 0);
243 This->data = HeapAlloc(GetProcessHeap(), 0, This->data_len);
245 memcpy(This->data, html_begin, sizeof(html_begin));
247 strcatW((LPWSTR)This->data, text);
248 strcatW((LPWSTR)This->data, html_end);
252 IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
254 IInternetProtocolSink_ReportData(pOIProtSink,
255 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
256 This->data_len, This->data_len);
258 IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
263 static HRESULT WINAPI AboutProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
265 AboutProtocol *This = PROTOCOL_THIS(iface);
266 FIXME("(%p)->(%p)\n", This, pProtocolData);
270 static HRESULT WINAPI AboutProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
273 AboutProtocol *This = PROTOCOL_THIS(iface);
274 FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
278 static HRESULT WINAPI AboutProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
280 AboutProtocol *This = PROTOCOL_THIS(iface);
281 TRACE("(%p)->(%08lx)\n", This, dwOptions);
285 static HRESULT WINAPI AboutProtocol_Suspend(IInternetProtocol *iface)
287 AboutProtocol *This = PROTOCOL_THIS(iface);
288 FIXME("(%p)\n", This);
292 static HRESULT WINAPI AboutProtocol_Resume(IInternetProtocol *iface)
294 AboutProtocol *This = PROTOCOL_THIS(iface);
295 FIXME("(%p)\n", This);
299 static HRESULT WINAPI AboutProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
301 AboutProtocol *This = PROTOCOL_THIS(iface);
303 TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
308 *pcbRead = (cb > This->data_len-This->cur ? This->data_len-This->cur : cb);
313 memcpy(pv, This->data, *pcbRead);
314 This->cur += *pcbRead;
319 static HRESULT WINAPI AboutProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
320 DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
322 AboutProtocol *This = PROTOCOL_THIS(iface);
323 FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
327 static HRESULT WINAPI AboutProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
329 AboutProtocol *This = PROTOCOL_THIS(iface);
331 TRACE("(%p)->(%ld)\n", This, dwOptions);
336 static HRESULT WINAPI AboutProtocol_UnlockRequest(IInternetProtocol *iface)
338 AboutProtocol *This = PROTOCOL_THIS(iface);
340 TRACE("(%p)\n", This);
347 static const IInternetProtocolVtbl AboutProtocolVtbl = {
348 AboutProtocol_QueryInterface,
349 AboutProtocol_AddRef,
350 AboutProtocol_Release,
352 AboutProtocol_Continue,
354 AboutProtocol_Terminate,
355 AboutProtocol_Suspend,
356 AboutProtocol_Resume,
359 AboutProtocol_LockRequest,
360 AboutProtocol_UnlockRequest
363 static HRESULT WINAPI AboutProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
364 REFIID riid, void **ppv)
369 TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
371 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(AboutProtocol));
372 ret->lpInternetProtocolVtbl = &AboutProtocolVtbl;
378 ret->pUnkOuter = pUnkOuter;
382 if(IsEqualGUID(&IID_IUnknown, riid))
383 *ppv = PROTOCOL(ret);
387 hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
393 HeapFree(GetProcessHeap(), 0, ret);
398 static HRESULT WINAPI AboutProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
399 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
400 DWORD* pcchResult, DWORD dwReserved)
402 FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
403 dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
407 static HRESULT WINAPI AboutProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
408 LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult,
409 DWORD* pcchResult, DWORD dwReserved)
411 FIXME("%p)->(%s %s %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzBaseUrl), debugstr_w(pwzRelativeUrl),
412 dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved);
416 static HRESULT WINAPI AboutProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
417 LPCWSTR pwzUrl2, DWORD dwCompareFlags)
419 FIXME("%p)->(%s %s %08lx)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
423 static HRESULT WINAPI AboutProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
424 QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
427 FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
428 cbBuffer, pcbBuf, dwReserved);
432 static const IInternetProtocolInfoVtbl AboutProtocolInfoVtbl = {
433 InternetProtocolInfo_QueryInterface,
434 InternetProtocolInfo_AddRef,
435 InternetProtocolInfo_Release,
436 AboutProtocolInfo_ParseUrl,
437 AboutProtocolInfo_CombineUrl,
438 AboutProtocolInfo_CompareUrl,
439 AboutProtocolInfo_QueryInfo
442 static const IClassFactoryVtbl AboutProtocolFactoryVtbl = {
443 ClassFactory_QueryInterface,
445 ClassFactory_Release,
446 AboutProtocolFactory_CreateInstance,
447 ClassFactory_LockServer
450 static ProtocolFactory AboutProtocolFactory = {
451 &AboutProtocolInfoVtbl,
452 &AboutProtocolFactoryVtbl
455 /********************************************************************
456 * ResProtocol implementation
460 const IInternetProtocolVtbl *lpInternetProtocolVtbl;
470 #define PROTOCOL_THIS(iface) DEFINE_THIS(ResProtocol, InternetProtocol, iface)
472 static HRESULT WINAPI ResProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
474 ResProtocol *This = PROTOCOL_THIS(iface);
478 if(IsEqualGUID(&IID_IUnknown, riid)) {
479 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
481 return IUnknown_QueryInterface(This->pUnkOuter, &IID_IUnknown, ppv);
482 *ppv = PROTOCOL(This);
483 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
484 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", iface, ppv);
485 *ppv = PROTOCOL(This);
486 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
487 TRACE("(%p)->(IID_IInternetProtocol %p)\n", iface, ppv);
488 *ppv = PROTOCOL(This);
489 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
490 FIXME("IServiceProvider is not implemented\n");
491 return E_NOINTERFACE;
495 TRACE("unknown interface %s\n", debugstr_guid(riid));
496 return E_NOINTERFACE;
499 IInternetProtocol_AddRef(iface);
503 static ULONG WINAPI ResProtocol_AddRef(IInternetProtocol *iface)
505 ResProtocol *This = PROTOCOL_THIS(iface);
506 ULONG ref = InterlockedIncrement(&This->ref);
507 TRACE("(%p) ref=%ld\n", iface, ref);
508 return This->pUnkOuter ? IUnknown_AddRef(This->pUnkOuter) : ref;
511 static ULONG WINAPI ResProtocol_Release(IInternetProtocol *iface)
513 ResProtocol *This = (ResProtocol*)iface;
514 IUnknown *pUnkOuter = This->pUnkOuter;
515 ULONG ref = InterlockedDecrement(&This->ref);
517 TRACE("(%p) ref=%lx\n", iface, ref);
520 HeapFree(GetProcessHeap(), 0, This->data);
521 HeapFree(GetProcessHeap(), 0, This);
525 return pUnkOuter ? IUnknown_Release(pUnkOuter) : ref;
528 static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
529 IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
530 DWORD grfPI, DWORD dwReserved)
532 ResProtocol *This = PROTOCOL_THIS(iface);
537 LPCWSTR url_dll, url_file;
541 static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
543 TRACE("(%p)->(%s %p %p %08lx %ld)\n", This, debugstr_w(szUrl), pOIProtSink,
544 pOIBindInfo, grfPI, dwReserved);
546 memset(&bindinfo, 0, sizeof(bindinfo));
547 bindinfo.cbSize = sizeof(BINDINFO);
548 IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
551 * Implement MIME type checking
552 * Use CoInternetParseUrl (not implemented yet)
555 len = strlenW(szUrl);
556 if(len < sizeof(wszRes)/sizeof(wszRes[0]) || memcmp(szUrl, wszRes, sizeof(wszRes))) {
557 WARN("Wrong protocol of url: %s\n", debugstr_w(szUrl));
558 IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
562 url_dll = szUrl + sizeof(wszRes)/sizeof(wszRes[0]);
563 if(!(url_file = strchrW(url_dll, '/'))) {
564 WARN("wrong url: %s\n", debugstr_w(szUrl));
565 IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
569 memcpy(dll, url_dll, (url_file-url_dll)*sizeof(WCHAR));
570 dll[url_file-url_dll] = 0;
572 hdll = LoadLibraryExW(dll, NULL, LOAD_LIBRARY_AS_DATAFILE);
574 WARN("Could not open dll: %s\n", debugstr_w(dll));
575 IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
576 return HRESULT_FROM_WIN32(GetLastError());
579 src = FindResourceW(hdll, ++url_file, (LPCWSTR)RT_HTML);
581 WARN("Could not find resource: %s\n", debugstr_w(url_file));
582 IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
583 return HRESULT_FROM_WIN32(GetLastError());
587 WARN("data already loaded\n");
588 HeapFree(GetProcessHeap(), 0, This->data);
591 This->data_len = SizeofResource(hdll, src);
592 This->data = HeapAlloc(GetProcessHeap(), 0, This->data_len);
593 memcpy(This->data, LoadResource(hdll, src), This->data_len);
598 IInternetProtocolSink_ReportData(pOIProtSink,
599 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
600 This->data_len, This->data_len);
602 IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
607 static HRESULT WINAPI ResProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
609 ResProtocol *This = PROTOCOL_THIS(iface);
610 FIXME("(%p)->(%p)\n", This, pProtocolData);
614 static HRESULT WINAPI ResProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
617 ResProtocol *This = PROTOCOL_THIS(iface);
618 FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
622 static HRESULT WINAPI ResProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
624 ResProtocol *This = PROTOCOL_THIS(iface);
626 TRACE("(%p)->(%08lx)\n", This, dwOptions);
628 /* test show that we don't have to do anything here */
632 static HRESULT WINAPI ResProtocol_Suspend(IInternetProtocol *iface)
634 ResProtocol *This = PROTOCOL_THIS(iface);
635 FIXME("(%p)\n", This);
639 static HRESULT WINAPI ResProtocol_Resume(IInternetProtocol *iface)
641 ResProtocol *This = PROTOCOL_THIS(iface);
642 FIXME("(%p)\n", This);
646 static HRESULT WINAPI ResProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
648 ResProtocol *This = PROTOCOL_THIS(iface);
650 TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
655 *pcbRead = (cb > This->data_len-This->cur ? This->data_len-This->cur : cb);
660 memcpy(pv, This->data, *pcbRead);
661 This->cur += *pcbRead;
666 static HRESULT WINAPI ResProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
667 DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
669 ResProtocol *This = PROTOCOL_THIS(iface);
670 FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
674 static HRESULT WINAPI ResProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
676 ResProtocol *This = PROTOCOL_THIS(iface);
678 TRACE("(%p)->(%ld)\n", This, dwOptions);
680 /* test show that we don't have to do anything here */
684 static HRESULT WINAPI ResProtocol_UnlockRequest(IInternetProtocol *iface)
686 ResProtocol *This = PROTOCOL_THIS(iface);
688 TRACE("(%p)\n", This);
690 /* test show that we don't have to do anything here */
696 static const IInternetProtocolVtbl ResProtocolVtbl = {
697 ResProtocol_QueryInterface,
701 ResProtocol_Continue,
703 ResProtocol_Terminate,
708 ResProtocol_LockRequest,
709 ResProtocol_UnlockRequest
712 static HRESULT WINAPI ResProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
713 REFIID riid, void **ppv)
718 TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
720 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ResProtocol));
721 ret->lpInternetProtocolVtbl = &ResProtocolVtbl;
726 ret->pUnkOuter = pUnkOuter;
730 if(IsEqualGUID(&IID_IUnknown, riid))
731 *ppv = PROTOCOL(ret);
735 hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
741 HeapFree(GetProcessHeap(), 0, ret);
746 static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
747 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
748 DWORD* pcchResult, DWORD dwReserved)
750 FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
751 dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
755 static HRESULT WINAPI ResProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
756 LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult,
757 DWORD* pcchResult, DWORD dwReserved)
759 FIXME("%p)->(%s %s %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzBaseUrl), debugstr_w(pwzRelativeUrl),
760 dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved);
764 static HRESULT WINAPI ResProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
765 LPCWSTR pwzUrl2, DWORD dwCompareFlags)
767 FIXME("%p)->(%s %s %08lx)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
771 static HRESULT WINAPI ResProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
772 QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
775 FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
776 cbBuffer, pcbBuf, dwReserved);
780 static const IInternetProtocolInfoVtbl ResProtocolInfoVtbl = {
781 InternetProtocolInfo_QueryInterface,
782 InternetProtocolInfo_AddRef,
783 InternetProtocolInfo_Release,
784 ResProtocolInfo_ParseUrl,
785 ResProtocolInfo_CombineUrl,
786 ResProtocolInfo_CompareUrl,
787 ResProtocolInfo_QueryInfo
790 static const IClassFactoryVtbl ResProtocolFactoryVtbl = {
791 ClassFactory_QueryInterface,
793 ClassFactory_Release,
794 ResProtocolFactory_CreateInstance,
795 ClassFactory_LockServer
798 static ProtocolFactory ResProtocolFactory = {
799 &ResProtocolInfoVtbl,
800 &ResProtocolFactoryVtbl
803 HRESULT ProtocolFactory_Create(REFCLSID rclsid, REFIID riid, void **ppv)
805 ProtocolFactory *cf = NULL;
807 if(IsEqualGUID(&CLSID_AboutProtocol, rclsid))
808 cf = &AboutProtocolFactory;
809 else if(IsEqualGUID(&CLSID_ResProtocol, rclsid))
810 cf = &ResProtocolFactory;
813 FIXME("not implemented protocol %s\n", debugstr_guid(rclsid));
814 return CLASS_E_CLASSNOTAVAILABLE;
817 return IUnknown_QueryInterface((IUnknown*)cf, riid, ppv);