From 76ce82374e81fce1cc5cad8bd728f33b965706f9 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 12 Jan 2007 12:31:54 +0100 Subject: [PATCH] urlmon: Added mk protocol stub implementation. --- dlls/urlmon/Makefile.in | 1 + dlls/urlmon/mk.c | 205 +++++++++++++++++++++++++++++++++++++++++++ dlls/urlmon/tests/protocol.c | 32 +++++++ dlls/urlmon/urlmon_main.c | 4 + dlls/urlmon/urlmon_main.h | 1 + 5 files changed, 243 insertions(+) create mode 100644 dlls/urlmon/mk.c diff --git a/dlls/urlmon/Makefile.in b/dlls/urlmon/Makefile.in index be3b6a4d164..488114ae962 100644 --- a/dlls/urlmon/Makefile.in +++ b/dlls/urlmon/Makefile.in @@ -14,6 +14,7 @@ C_SRCS = \ ftp.c \ http.c \ internet.c \ + mk.c \ regsvr.c \ sec_mgr.c \ session.c \ diff --git a/dlls/urlmon/mk.c b/dlls/urlmon/mk.c new file mode 100644 index 00000000000..a11e40fe16c --- /dev/null +++ b/dlls/urlmon/mk.c @@ -0,0 +1,205 @@ +/* + * Copyright 2007 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" +#include "urlmon.h" +#include "urlmon_main.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(urlmon); + +typedef struct { + const IInternetProtocolVtbl *lpInternetProtocolVtbl; + LONG ref; +} MkProtocol; + +#define PROTOCOL_THIS(iface) DEFINE_THIS(MkProtocol, InternetProtocol, iface) + +#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl) + +static HRESULT WINAPI MkProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + + *ppv = NULL; + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = PROTOCOL(This); + }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { + TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); + *ppv = PROTOCOL(This); + }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { + TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); + *ppv = PROTOCOL(This); + } + + if(*ppv) { + IInternetProtocol_AddRef(iface); + return S_OK; + } + + WARN("not supported interface %s\n", debugstr_guid(riid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI MkProtocol_AddRef(IInternetProtocol *iface) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + LONG ref = InterlockedIncrement(&This->ref); + TRACE("(%p) ref=%d\n", This, ref); + return ref; +} + +static ULONG WINAPI MkProtocol_Release(IInternetProtocol *iface) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) { + HeapFree(GetProcessHeap(), 0, This); + + URLMON_UnlockModule(); + } + + return ref; +} + +static HRESULT WINAPI MkProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, + IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, + DWORD grfPI, DWORD dwReserved) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink, + pOIBindInfo, grfPI, dwReserved); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)->(%p)\n", This, pProtocolData); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason, + DWORD dwOptions) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)->(%08x)\n", This, dwOptions); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_Suspend(IInternetProtocol *iface) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_Resume(IInternetProtocol *iface) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_Read(IInternetProtocol *iface, void *pv, + ULONG cb, ULONG *pcbRead) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove, + DWORD dwOrgin, ULARGE_INTEGER *plibNewPosition) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrgin, plibNewPosition); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)->(%08x)\n", This, dwOptions); + return E_NOTIMPL; +} + +static HRESULT WINAPI MkProtocol_UnlockRequest(IInternetProtocol *iface) +{ + MkProtocol *This = PROTOCOL_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +#undef PROTOCOL_THIS + +static const IInternetProtocolVtbl MkProtocolVtbl = { + MkProtocol_QueryInterface, + MkProtocol_AddRef, + MkProtocol_Release, + MkProtocol_Start, + MkProtocol_Continue, + MkProtocol_Abort, + MkProtocol_Terminate, + MkProtocol_Suspend, + MkProtocol_Resume, + MkProtocol_Read, + MkProtocol_Seek, + MkProtocol_LockRequest, + MkProtocol_UnlockRequest +}; + +HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) +{ + MkProtocol *ret; + + TRACE("(%p %p)\n", pUnkOuter, ppobj); + + URLMON_LockModule(); + + ret = HeapAlloc(GetProcessHeap(), 0, sizeof(MkProtocol)); + + ret->lpInternetProtocolVtbl = &MkProtocolVtbl; + ret->ref = 1; + + /* NOTE: + * Native returns NULL ppobj and S_OK in CreateInstance if called with IID_IUnknown riid. + */ + *ppobj = PROTOCOL(ret); + + return S_OK; +} diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c index 75f167f16b4..221df9c41f7 100644 --- a/dlls/urlmon/tests/protocol.c +++ b/dlls/urlmon/tests/protocol.c @@ -918,6 +918,37 @@ static HWND create_protocol_window(void) CW_USEDEFAULT, NULL, NULL, NULL, NULL); } +static void test_mk_protocol(void) +{ + IInternetProtocolInfo *protocol_info; + IInternetProtocol *protocol; + IClassFactory *factory; + IUnknown *unk; + HRESULT hres; + + hres = CoGetClassObject(&CLSID_MkProtocol, CLSCTX_INPROC_SERVER, NULL, + &IID_IUnknown, (void**)&unk); + ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres); + + hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); + ok(hres == E_NOINTERFACE, + "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", + hres); + + hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); + ok(hres == S_OK, "Could not get IClassFactory interface\n"); + IUnknown_Release(unk); + if(FAILED(hres)) + return; + + hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, + (void**)&protocol); + IClassFactory_Release(factory); + ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); + + IInternetProtocol_Release(protocol); +} + START_TEST(protocol) { OleInitialize(NULL); @@ -926,6 +957,7 @@ START_TEST(protocol) test_file_protocol(); test_http_protocol(); + test_mk_protocol(); DestroyWindow(protocol_hwnd); diff --git a/dlls/urlmon/urlmon_main.c b/dlls/urlmon/urlmon_main.c index 8ec8424e542..5dc9b549497 100644 --- a/dlls/urlmon/urlmon_main.c +++ b/dlls/urlmon/urlmon_main.c @@ -181,6 +181,8 @@ static const ClassFactory FtpProtocolCF = { &ClassFactoryVtbl, FtpProtocol_Construct}; static const ClassFactory HttpProtocolCF = { &ClassFactoryVtbl, HttpProtocol_Construct}; +static const ClassFactory MkProtocolCF = + { &ClassFactoryVtbl, MkProtocol_Construct}; static const ClassFactory SecurityManagerCF = { &ClassFactoryVtbl, SecManagerImpl_Construct}; static const ClassFactory ZoneManagerCF = @@ -196,12 +198,14 @@ struct object_creation_info static const WCHAR wszFile[] = {'f','i','l','e',0}; static const WCHAR wszFtp[] = {'f','t','p',0}; static const WCHAR wszHttp[] = {'h','t','t','p',0}; +static const WCHAR wszMk[] = {'m','k',0}; static const struct object_creation_info object_creation[] = { { &CLSID_FileProtocol, CLASSFACTORY(&FileProtocolCF), wszFile }, { &CLSID_FtpProtocol, CLASSFACTORY(&FtpProtocolCF), wszFtp }, { &CLSID_HttpProtocol, CLASSFACTORY(&HttpProtocolCF), wszHttp }, + { &CLSID_MkProtocol, CLASSFACTORY(&MkProtocolCF), wszMk }, { &CLSID_InternetSecurityManager, CLASSFACTORY(&SecurityManagerCF), NULL }, { &CLSID_InternetZoneManager, CLASSFACTORY(&ZoneManagerCF), NULL } }; diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index 4e6e2140e74..c3af9eac88f 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -30,6 +30,7 @@ extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); +extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); /********************************************************************** * Dll lifetime tracking declaration for urlmon.dll -- 2.11.4.GIT