urlmon: Added gopher protocol handler stub implementation.

This commit is contained in:
Jacek Caban 2009-03-04 19:06:42 +01:00 committed by Alexandre Julliard
parent d9960c34fa
commit cfb9c099b5
5 changed files with 231 additions and 0 deletions

View File

@ -14,6 +14,7 @@ C_SRCS = \
file.c \
format.c \
ftp.c \
gopher.c \
http.c \
internet.c \
mk.c \

193
dlls/urlmon/gopher.c Normal file
View File

@ -0,0 +1,193 @@
/*
* Copyright 2009 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 "urlmon_main.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
typedef struct {
const IInternetProtocolVtbl *lpInternetProtocolVtbl;
LONG ref;
} GopherProtocol;
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
#define PROTOCOL_THIS(iface) DEFINE_THIS(GopherProtocol, InternetProtocol, iface)
static HRESULT WINAPI GopherProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
{
GopherProtocol *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 GopherProtocol_AddRef(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI GopherProtocol_Release(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
heap_free(This);
URLMON_UnlockModule();
}
return ref;
}
static HRESULT WINAPI GopherProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, DWORD dwReserved)
{
GopherProtocol *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 GopherProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%p)\n", This, pProtocolData);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
DWORD dwOptions)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%08x)\n", This, dwOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Suspend(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Resume(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Read(IInternetProtocol *iface, void *pv,
ULONG cb, ULONG *pcbRead)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%08x)\n", This, dwOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_UnlockRequest(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
#undef PROTOCOL_THIS
static const IInternetProtocolVtbl GopherProtocolVtbl = {
GopherProtocol_QueryInterface,
GopherProtocol_AddRef,
GopherProtocol_Release,
GopherProtocol_Start,
GopherProtocol_Continue,
GopherProtocol_Abort,
GopherProtocol_Terminate,
GopherProtocol_Suspend,
GopherProtocol_Resume,
GopherProtocol_Read,
GopherProtocol_Seek,
GopherProtocol_LockRequest,
GopherProtocol_UnlockRequest
};
HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
{
GopherProtocol *ret;
TRACE("(%p %p)\n", pUnkOuter, ppobj);
URLMON_LockModule();
ret = heap_alloc_zero(sizeof(GopherProtocol));
ret->lpInternetProtocolVtbl = &GopherProtocolVtbl;
ret->ref = 1;
*ppobj = PROTOCOL(ret);
return S_OK;
}

View File

@ -1844,6 +1844,37 @@ static void test_ftp_protocol(void)
ok(!ref, "ref=%d\n", ref);
}
static void test_gopher_protocol(void)
{
IInternetProtocolInfo *protocol_info;
IClassFactory *factory;
IUnknown *unk;
HRESULT hres;
trace("Testing gopher protocol...\n");
hres = CoGetClassObject(&CLSID_GopherProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
if(FAILED(hres))
return;
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**)&async_protocol);
IClassFactory_Release(factory);
ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
IInternetProtocol_Release(async_protocol);
}
static void test_mk_protocol(void)
{
IInternetProtocolInfo *protocol_info;
@ -2132,6 +2163,7 @@ START_TEST(protocol)
test_http_protocol();
test_https_protocol();
test_ftp_protocol();
test_gopher_protocol();
test_mk_protocol();
test_CreateBinding();
test_binding(FILE_TEST);

View File

@ -173,6 +173,8 @@ static const ClassFactory FileProtocolCF =
{ &ClassFactoryVtbl, FileProtocol_Construct};
static const ClassFactory FtpProtocolCF =
{ &ClassFactoryVtbl, FtpProtocol_Construct};
static const ClassFactory GopherProtocolCF =
{ &ClassFactoryVtbl, GopherProtocol_Construct};
static const ClassFactory HttpProtocolCF =
{ &ClassFactoryVtbl, HttpProtocol_Construct};
static const ClassFactory HttpSProtocolCF =
@ -193,6 +195,7 @@ struct object_creation_info
static const WCHAR wszFile[] = {'f','i','l','e',0};
static const WCHAR wszFtp[] = {'f','t','p',0};
static const WCHAR wszGopher[] = {'g','o','p','h','e','r',0};
static const WCHAR wszHttp[] = {'h','t','t','p',0};
static const WCHAR wszHttps[] = {'h','t','t','p','s',0};
static const WCHAR wszMk[] = {'m','k',0};
@ -201,6 +204,7 @@ static const struct object_creation_info object_creation[] =
{
{ &CLSID_FileProtocol, CLASSFACTORY(&FileProtocolCF), wszFile },
{ &CLSID_FtpProtocol, CLASSFACTORY(&FtpProtocolCF), wszFtp },
{ &CLSID_GopherProtocol, CLASSFACTORY(&GopherProtocolCF), wszGopher },
{ &CLSID_HttpProtocol, CLASSFACTORY(&HttpProtocolCF), wszHttp },
{ &CLSID_HttpSProtocol, CLASSFACTORY(&HttpSProtocolCF), wszHttps },
{ &CLSID_MkProtocol, CLASSFACTORY(&MkProtocolCF), wszMk },

View File

@ -42,6 +42,7 @@ extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
/**********************************************************************