urlmon: Added ftp pluggable protocol implementation.
This commit is contained in:
parent
ffea80cf0a
commit
ad4a21bc99
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2005 Jacek Caban
|
||||
* Copyright 2005-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
|
||||
|
@ -22,17 +22,64 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
||||
|
||||
typedef struct {
|
||||
Protocol base;
|
||||
|
||||
const IInternetProtocolVtbl *lpInternetProtocolVtbl;
|
||||
const IInternetPriorityVtbl *lpInternetPriorityVtbl;
|
||||
|
||||
LONG ref;
|
||||
} FtpProtocol;
|
||||
|
||||
#define PROTOCOL_THIS(iface) DEFINE_THIS(FtpProtocol, InternetProtocol, iface)
|
||||
|
||||
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
|
||||
#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
|
||||
|
||||
#define ASYNCPROTOCOL_THIS(iface) DEFINE_THIS2(FtpProtocol, base, iface)
|
||||
|
||||
static HRESULT FtpProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD request_flags,
|
||||
IInternetBindInfo *bind_info)
|
||||
{
|
||||
FtpProtocol *This = ASYNCPROTOCOL_THIS(prot);
|
||||
|
||||
This->base.request = InternetOpenUrlW(This->base.internet, url, NULL, 0,
|
||||
request_flags|INTERNET_FLAG_EXISTING_CONNECT|INTERNET_FLAG_PASSIVE,
|
||||
(DWORD_PTR)&This->base);
|
||||
if (!This->base.request && GetLastError() != ERROR_IO_PENDING) {
|
||||
WARN("InternetOpenUrl failed: %d\n", GetLastError());
|
||||
return INET_E_RESOURCE_NOT_FOUND;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT FtpProtocol_start_downloading(Protocol *prot)
|
||||
{
|
||||
FtpProtocol *This = ASYNCPROTOCOL_THIS(prot);
|
||||
DWORD size;
|
||||
BOOL res;
|
||||
|
||||
res = FtpGetFileSize(This->base.request, &size);
|
||||
if(res)
|
||||
This->base.content_length = size;
|
||||
else
|
||||
WARN("FtpGetFileSize failed: %d\n", GetLastError());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void FtpProtocol_close_connection(Protocol *prot)
|
||||
{
|
||||
}
|
||||
|
||||
#undef ASYNCPROTOCOL_THIS
|
||||
|
||||
static const ProtocolVtbl AsyncProtocolVtbl = {
|
||||
FtpProtocol_open_request,
|
||||
FtpProtocol_start_downloading,
|
||||
FtpProtocol_close_connection
|
||||
};
|
||||
|
||||
#define PROTOCOL_THIS(iface) DEFINE_THIS(FtpProtocol, InternetProtocol, iface)
|
||||
|
||||
static HRESULT WINAPI FtpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
||||
{
|
||||
FtpProtocol *This = PROTOCOL_THIS(iface);
|
||||
|
@ -77,6 +124,7 @@ static ULONG WINAPI FtpProtocol_Release(IInternetProtocol *iface)
|
|||
TRACE("(%p) ref=%d\n", This, ref);
|
||||
|
||||
if(!ref) {
|
||||
protocol_close_connection(&This->base);
|
||||
heap_free(This);
|
||||
|
||||
URLMON_UnlockModule();
|
||||
|
@ -90,16 +138,25 @@ static HRESULT WINAPI FtpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|||
DWORD grfPI, DWORD dwReserved)
|
||||
{
|
||||
FtpProtocol *This = PROTOCOL_THIS(iface);
|
||||
FIXME("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
|
||||
pOIBindInfo, grfPI, dwReserved);
|
||||
return E_NOTIMPL;
|
||||
|
||||
static const WCHAR ftpW[] = {'f','t','p',':'};
|
||||
|
||||
TRACE("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
|
||||
pOIBindInfo, grfPI, dwReserved);
|
||||
|
||||
if(strncmpW(szUrl, ftpW, sizeof(ftpW)/sizeof(WCHAR)))
|
||||
return MK_E_SYNTAX;
|
||||
|
||||
return protocol_start(&This->base, PROTOCOL(This), szUrl, pOIProtSink, pOIBindInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI FtpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
|
||||
{
|
||||
FtpProtocol *This = PROTOCOL_THIS(iface);
|
||||
FIXME("(%p)->(%p)\n", This, pProtocolData);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, pProtocolData);
|
||||
|
||||
return protocol_continue(&This->base, pProtocolData);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI FtpProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
||||
|
@ -113,8 +170,11 @@ static HRESULT WINAPI FtpProtocol_Abort(IInternetProtocol *iface, HRESULT hrReas
|
|||
static HRESULT WINAPI FtpProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
||||
{
|
||||
FtpProtocol *This = PROTOCOL_THIS(iface);
|
||||
FIXME("(%p)->(%08x)\n", This, dwOptions);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
||||
|
||||
protocol_close_connection(&This->base);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI FtpProtocol_Suspend(IInternetProtocol *iface)
|
||||
|
@ -135,8 +195,10 @@ static HRESULT WINAPI FtpProtocol_Read(IInternetProtocol *iface, void *pv,
|
|||
ULONG cb, ULONG *pcbRead)
|
||||
{
|
||||
FtpProtocol *This = PROTOCOL_THIS(iface);
|
||||
FIXME("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
||||
|
||||
return protocol_read(&This->base, pv, cb, pcbRead);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI FtpProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
|
||||
|
@ -150,15 +212,19 @@ static HRESULT WINAPI FtpProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER d
|
|||
static HRESULT WINAPI FtpProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
||||
{
|
||||
FtpProtocol *This = PROTOCOL_THIS(iface);
|
||||
FIXME("(%p)->(%08x)\n", This, dwOptions);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
||||
|
||||
return protocol_lock_request(&This->base);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI FtpProtocol_UnlockRequest(IInternetProtocol *iface)
|
||||
{
|
||||
FtpProtocol *This = PROTOCOL_THIS(iface);
|
||||
FIXME("(%p)\n", This);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
return protocol_unlock_request(&This->base);
|
||||
}
|
||||
|
||||
#undef PROTOCOL_THIS
|
||||
|
@ -202,15 +268,21 @@ static ULONG WINAPI FtpPriority_Release(IInternetPriority *iface)
|
|||
static HRESULT WINAPI FtpPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
|
||||
{
|
||||
FtpProtocol *This = PRIORITY_THIS(iface);
|
||||
FIXME("(%p)->(%d)\n", This, nPriority);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%d)\n", This, nPriority);
|
||||
|
||||
This->base.priority = nPriority;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI FtpPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
|
||||
{
|
||||
FtpProtocol *This = PRIORITY_THIS(iface);
|
||||
FIXME("(%p)->(%p)\n", This, pnPriority);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, pnPriority);
|
||||
|
||||
*pnPriority = This->base.priority;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#undef PRIORITY_THIS
|
||||
|
@ -231,8 +303,9 @@ HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
|
|||
|
||||
URLMON_LockModule();
|
||||
|
||||
ret = heap_alloc(sizeof(FtpProtocol));
|
||||
ret = heap_alloc_zero(sizeof(FtpProtocol));
|
||||
|
||||
ret->base.vtbl = &AsyncProtocolVtbl;
|
||||
ret->lpInternetProtocolVtbl = &FtpProtocolVtbl;
|
||||
ret->lpInternetPriorityVtbl = &FtpPriorityVtbl;
|
||||
ret->ref = 1;
|
||||
|
|
Loading…
Reference in New Issue