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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 mshtml_free(This->data);
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);
234 ReleaseBindInfo(&bindinfo);
236 if(strlenW(szUrl)>=sizeof(wszAbout)/sizeof(WCHAR) && !memcmp(wszAbout, szUrl, sizeof(wszAbout))) {
237 text = szUrl + sizeof(wszAbout)/sizeof(WCHAR);
238 if(!strcmpW(wszBlank, text))
242 This->data_len = sizeof(html_begin)+sizeof(html_end)-sizeof(WCHAR)
243 + (text ? strlenW(text)*sizeof(WCHAR) : 0);
244 This->data = mshtml_alloc(This->data_len);
246 memcpy(This->data, html_begin, sizeof(html_begin));
248 strcatW((LPWSTR)This->data, text);
249 strcatW((LPWSTR)This->data, html_end);
253 IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
255 IInternetProtocolSink_ReportData(pOIProtSink,
256 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
257 This->data_len, This->data_len);
259 IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
264 static HRESULT WINAPI AboutProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
266 AboutProtocol *This = PROTOCOL_THIS(iface);
267 FIXME("(%p)->(%p)\n", This, pProtocolData);
271 static HRESULT WINAPI AboutProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
274 AboutProtocol *This = PROTOCOL_THIS(iface);
275 FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
279 static HRESULT WINAPI AboutProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
281 AboutProtocol *This = PROTOCOL_THIS(iface);
282 TRACE("(%p)->(%08lx)\n", This, dwOptions);
286 static HRESULT WINAPI AboutProtocol_Suspend(IInternetProtocol *iface)
288 AboutProtocol *This = PROTOCOL_THIS(iface);
289 FIXME("(%p)\n", This);
293 static HRESULT WINAPI AboutProtocol_Resume(IInternetProtocol *iface)
295 AboutProtocol *This = PROTOCOL_THIS(iface);
296 FIXME("(%p)\n", This);
300 static HRESULT WINAPI AboutProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
302 AboutProtocol *This = PROTOCOL_THIS(iface);
304 TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
309 *pcbRead = (cb > This->data_len-This->cur ? This->data_len-This->cur : cb);
314 memcpy(pv, This->data, *pcbRead);
315 This->cur += *pcbRead;
320 static HRESULT WINAPI AboutProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
321 DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
323 AboutProtocol *This = PROTOCOL_THIS(iface);
324 FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
328 static HRESULT WINAPI AboutProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
330 AboutProtocol *This = PROTOCOL_THIS(iface);
332 TRACE("(%p)->(%ld)\n", This, dwOptions);
337 static HRESULT WINAPI AboutProtocol_UnlockRequest(IInternetProtocol *iface)
339 AboutProtocol *This = PROTOCOL_THIS(iface);
341 TRACE("(%p)\n", This);
348 static const IInternetProtocolVtbl AboutProtocolVtbl = {
349 AboutProtocol_QueryInterface,
350 AboutProtocol_AddRef,
351 AboutProtocol_Release,
353 AboutProtocol_Continue,
355 AboutProtocol_Terminate,
356 AboutProtocol_Suspend,
357 AboutProtocol_Resume,
360 AboutProtocol_LockRequest,
361 AboutProtocol_UnlockRequest
364 static HRESULT WINAPI AboutProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
365 REFIID riid, void **ppv)
370 TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
372 ret = mshtml_alloc(sizeof(AboutProtocol));
373 ret->lpInternetProtocolVtbl = &AboutProtocolVtbl;
379 ret->pUnkOuter = pUnkOuter;
383 if(IsEqualGUID(&IID_IUnknown, riid))
384 *ppv = PROTOCOL(ret);
388 hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
399 static HRESULT WINAPI AboutProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
400 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
401 DWORD* pcchResult, DWORD dwReserved)
403 TRACE("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
404 dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
406 if(ParseAction == PARSE_SECURITY_URL) {
407 int len = lstrlenW(pwzUrl);
412 memcpy(pwzResult, pwzUrl, (len+1)*sizeof(WCHAR));
416 if(ParseAction == PARSE_DOMAIN) {
421 *pcchResult = strlenW(pwzUrl)+1;
427 return INET_E_DEFAULT_ACTION;
430 static HRESULT WINAPI AboutProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
431 LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult,
432 DWORD* pcchResult, DWORD dwReserved)
434 FIXME("%p)->(%s %s %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzBaseUrl), debugstr_w(pwzRelativeUrl),
435 dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved);
439 static HRESULT WINAPI AboutProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
440 LPCWSTR pwzUrl2, DWORD dwCompareFlags)
442 FIXME("%p)->(%s %s %08lx)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
446 static HRESULT WINAPI AboutProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
447 QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
450 FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
451 cbBuffer, pcbBuf, dwReserved);
455 static const IInternetProtocolInfoVtbl AboutProtocolInfoVtbl = {
456 InternetProtocolInfo_QueryInterface,
457 InternetProtocolInfo_AddRef,
458 InternetProtocolInfo_Release,
459 AboutProtocolInfo_ParseUrl,
460 AboutProtocolInfo_CombineUrl,
461 AboutProtocolInfo_CompareUrl,
462 AboutProtocolInfo_QueryInfo
465 static const IClassFactoryVtbl AboutProtocolFactoryVtbl = {
466 ClassFactory_QueryInterface,
468 ClassFactory_Release,
469 AboutProtocolFactory_CreateInstance,
470 ClassFactory_LockServer
473 static ProtocolFactory AboutProtocolFactory = {
474 &AboutProtocolInfoVtbl,
475 &AboutProtocolFactoryVtbl
478 /********************************************************************
479 * ResProtocol implementation
483 const IInternetProtocolVtbl *lpInternetProtocolVtbl;
493 #define PROTOCOL_THIS(iface) DEFINE_THIS(ResProtocol, InternetProtocol, iface)
495 static HRESULT WINAPI ResProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
497 ResProtocol *This = PROTOCOL_THIS(iface);
501 if(IsEqualGUID(&IID_IUnknown, riid)) {
502 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
504 return IUnknown_QueryInterface(This->pUnkOuter, &IID_IUnknown, ppv);
505 *ppv = PROTOCOL(This);
506 }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
507 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", iface, ppv);
508 *ppv = PROTOCOL(This);
509 }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
510 TRACE("(%p)->(IID_IInternetProtocol %p)\n", iface, ppv);
511 *ppv = PROTOCOL(This);
512 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
513 FIXME("IServiceProvider is not implemented\n");
514 return E_NOINTERFACE;
518 TRACE("unknown interface %s\n", debugstr_guid(riid));
519 return E_NOINTERFACE;
522 IInternetProtocol_AddRef(iface);
526 static ULONG WINAPI ResProtocol_AddRef(IInternetProtocol *iface)
528 ResProtocol *This = PROTOCOL_THIS(iface);
529 ULONG ref = InterlockedIncrement(&This->ref);
530 TRACE("(%p) ref=%ld\n", iface, ref);
531 return This->pUnkOuter ? IUnknown_AddRef(This->pUnkOuter) : ref;
534 static ULONG WINAPI ResProtocol_Release(IInternetProtocol *iface)
536 ResProtocol *This = (ResProtocol*)iface;
537 IUnknown *pUnkOuter = This->pUnkOuter;
538 ULONG ref = InterlockedDecrement(&This->ref);
540 TRACE("(%p) ref=%lx\n", iface, ref);
543 mshtml_free(This->data);
548 return pUnkOuter ? IUnknown_Release(pUnkOuter) : ref;
551 static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
552 IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
553 DWORD grfPI, DWORD dwReserved)
555 ResProtocol *This = PROTOCOL_THIS(iface);
556 DWORD grfBINDF = 0, len;
558 LPWSTR url_dll, url_file, url, mime;
563 static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
565 TRACE("(%p)->(%s %p %p %08lx %ld)\n", This, debugstr_w(szUrl), pOIProtSink,
566 pOIBindInfo, grfPI, dwReserved);
568 memset(&bindinfo, 0, sizeof(bindinfo));
569 bindinfo.cbSize = sizeof(BINDINFO);
570 IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
571 ReleaseBindInfo(&bindinfo);
573 len = strlenW(szUrl)+16;
574 url = mshtml_alloc(len*sizeof(WCHAR));
575 hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
577 WARN("CoInternetParseUrl failed: %08lx\n", hres);
579 IInternetProtocolSink_ReportResult(pOIProtSink, hres, 0, NULL);
583 if(len < sizeof(wszRes)/sizeof(wszRes[0]) || memcmp(url, wszRes, sizeof(wszRes))) {
584 WARN("Wrong protocol of url: %s\n", debugstr_w(url));
585 IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
590 url_dll = url + sizeof(wszRes)/sizeof(wszRes[0]);
591 if(!(url_file = strrchrW(url_dll, '/'))) {
592 WARN("wrong url: %s\n", debugstr_w(url));
593 IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
599 hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE);
601 WARN("Could not open dll: %s\n", debugstr_w(url_dll));
602 IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
603 return HRESULT_FROM_WIN32(GetLastError());
606 src = FindResourceW(hdll, url_file, (LPCWSTR)RT_HTML);
608 LPWSTR endpoint = NULL;
609 DWORD file_id = strtolW(url_file, &endpoint, 10);
610 if(endpoint == url_file+strlenW(url_file))
611 src = FindResourceW(hdll, (LPCWSTR)file_id, (LPCWSTR)RT_HTML);
614 WARN("Could not find resource\n");
615 IInternetProtocolSink_ReportResult(pOIProtSink,
616 HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
618 return HRESULT_FROM_WIN32(GetLastError());
623 WARN("data already loaded\n");
624 mshtml_free(This->data);
627 This->data_len = SizeofResource(hdll, src);
628 This->data = mshtml_alloc(This->data_len);
629 memcpy(This->data, LoadResource(hdll, src), This->data_len);
634 hres = FindMimeFromData(NULL, url_file, NULL, 0, NULL, 0, &mime, 0);
636 if(SUCCEEDED(hres)) {
637 IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
641 IInternetProtocolSink_ReportData(pOIProtSink,
642 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
643 This->data_len, This->data_len);
645 IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
650 static HRESULT WINAPI ResProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
652 ResProtocol *This = PROTOCOL_THIS(iface);
653 FIXME("(%p)->(%p)\n", This, pProtocolData);
657 static HRESULT WINAPI ResProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
660 ResProtocol *This = PROTOCOL_THIS(iface);
661 FIXME("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
665 static HRESULT WINAPI ResProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
667 ResProtocol *This = PROTOCOL_THIS(iface);
669 TRACE("(%p)->(%08lx)\n", This, dwOptions);
671 /* test show that we don't have to do anything here */
675 static HRESULT WINAPI ResProtocol_Suspend(IInternetProtocol *iface)
677 ResProtocol *This = PROTOCOL_THIS(iface);
678 FIXME("(%p)\n", This);
682 static HRESULT WINAPI ResProtocol_Resume(IInternetProtocol *iface)
684 ResProtocol *This = PROTOCOL_THIS(iface);
685 FIXME("(%p)\n", This);
689 static HRESULT WINAPI ResProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
691 ResProtocol *This = PROTOCOL_THIS(iface);
693 TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
698 *pcbRead = (cb > This->data_len-This->cur ? This->data_len-This->cur : cb);
703 memcpy(pv, This->data, *pcbRead);
704 This->cur += *pcbRead;
709 static HRESULT WINAPI ResProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
710 DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
712 ResProtocol *This = PROTOCOL_THIS(iface);
713 FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
717 static HRESULT WINAPI ResProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
719 ResProtocol *This = PROTOCOL_THIS(iface);
721 TRACE("(%p)->(%ld)\n", This, dwOptions);
723 /* test show that we don't have to do anything here */
727 static HRESULT WINAPI ResProtocol_UnlockRequest(IInternetProtocol *iface)
729 ResProtocol *This = PROTOCOL_THIS(iface);
731 TRACE("(%p)\n", This);
733 /* test show that we don't have to do anything here */
739 static const IInternetProtocolVtbl ResProtocolVtbl = {
740 ResProtocol_QueryInterface,
744 ResProtocol_Continue,
746 ResProtocol_Terminate,
751 ResProtocol_LockRequest,
752 ResProtocol_UnlockRequest
755 static HRESULT WINAPI ResProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
756 REFIID riid, void **ppv)
761 TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
763 ret = mshtml_alloc(sizeof(ResProtocol));
764 ret->lpInternetProtocolVtbl = &ResProtocolVtbl;
769 ret->pUnkOuter = pUnkOuter;
773 if(IsEqualGUID(&IID_IUnknown, riid))
774 *ppv = PROTOCOL(ret);
778 hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
789 static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
790 PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
791 DWORD* pcchResult, DWORD dwReserved)
793 TRACE("%p)->(%s %d %lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
794 dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
796 if(ParseAction == PARSE_SECURITY_URL) {
800 static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
801 static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
803 if(strlenW(pwzUrl) <= sizeof(wszRes)/sizeof(WCHAR) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
806 ptr = strchrW(pwzUrl + sizeof(wszRes)/sizeof(WCHAR), '/');
810 size = ptr-pwzUrl + sizeof(wszFile)/sizeof(WCHAR) - sizeof(wszRes)/sizeof(WCHAR);
811 if(size >= cchResult)
814 /* FIXME: return full path */
815 memcpy(pwzResult, wszFile, sizeof(wszFile));
816 memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR),
817 pwzUrl + sizeof(wszRes)/sizeof(WCHAR),
818 size*sizeof(WCHAR) - sizeof(wszFile));
826 if(ParseAction == PARSE_DOMAIN) {
831 *pcchResult = strlenW(pwzUrl)+1;
837 return INET_E_DEFAULT_ACTION;
840 static HRESULT WINAPI ResProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
841 LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult, DWORD cchResult,
842 DWORD* pcchResult, DWORD dwReserved)
844 TRACE("%p)->(%s %s %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzBaseUrl), debugstr_w(pwzRelativeUrl),
845 dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved);
847 return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
850 static HRESULT WINAPI ResProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
851 LPCWSTR pwzUrl2, DWORD dwCompareFlags)
853 FIXME("%p)->(%s %s %08lx)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
857 static HRESULT WINAPI ResProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
858 QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
861 FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
862 cbBuffer, pcbBuf, dwReserved);
866 static const IInternetProtocolInfoVtbl ResProtocolInfoVtbl = {
867 InternetProtocolInfo_QueryInterface,
868 InternetProtocolInfo_AddRef,
869 InternetProtocolInfo_Release,
870 ResProtocolInfo_ParseUrl,
871 ResProtocolInfo_CombineUrl,
872 ResProtocolInfo_CompareUrl,
873 ResProtocolInfo_QueryInfo
876 static const IClassFactoryVtbl ResProtocolFactoryVtbl = {
877 ClassFactory_QueryInterface,
879 ClassFactory_Release,
880 ResProtocolFactory_CreateInstance,
881 ClassFactory_LockServer
884 static ProtocolFactory ResProtocolFactory = {
885 &ResProtocolInfoVtbl,
886 &ResProtocolFactoryVtbl
889 HRESULT ProtocolFactory_Create(REFCLSID rclsid, REFIID riid, void **ppv)
891 ProtocolFactory *cf = NULL;
893 if(IsEqualGUID(&CLSID_AboutProtocol, rclsid))
894 cf = &AboutProtocolFactory;
895 else if(IsEqualGUID(&CLSID_ResProtocol, rclsid))
896 cf = &ResProtocolFactory;
899 FIXME("not implemented protocol %s\n", debugstr_guid(rclsid));
900 return CLASS_E_CLASSNOTAVAILABLE;
903 return IUnknown_QueryInterface((IUnknown*)cf, riid, ppv);