Added implementation of IInternetPriority in HttpProtocol.

This commit is contained in:
Jacek Caban 2005-11-09 10:28:26 +00:00 committed by Alexandre Julliard
parent 2762486b35
commit 8c4ead4d27
2 changed files with 124 additions and 3 deletions

View File

@ -32,13 +32,18 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
typedef struct {
const IInternetProtocolVtbl *lpInternetProtocolVtbl;
const IInternetProtocolVtbl *lpInternetProtocolVtbl;
const IInternetPriorityVtbl *lpInternetPriorityVtbl;
LONG priority;
LONG ref;
} HttpProtocol;
#define PROTOCOL_THIS(iface) DEFINE_THIS(HttpProtocol, InternetProtocol, iface)
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
#define PROTOCOL_THIS(iface) DEFINE_THIS(HttpProtocol, InternetProtocol, iface)
static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
{
@ -54,6 +59,9 @@ static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocol *iface, REFI
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
*ppv = PROTOCOL(This);
}else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
*ppv = PRIORITY(This);
}
if(*ppv) {
@ -167,6 +175,56 @@ static HRESULT WINAPI HttpProtocol_UnlockRequest(IInternetProtocol *iface)
#undef PROTOCOL_THIS
#define PRIORITY_THIS(iface) DEFINE_THIS(HttpProtocol, InternetPriority, iface)
static HRESULT WINAPI HttpPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
{
HttpProtocol *This = PRIORITY_THIS(iface);
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
}
static ULONG WINAPI HttpPriority_AddRef(IInternetPriority *iface)
{
HttpProtocol *This = PRIORITY_THIS(iface);
return IInternetProtocol_AddRef(PROTOCOL(This));
}
static ULONG WINAPI HttpPriority_Release(IInternetPriority *iface)
{
HttpProtocol *This = PRIORITY_THIS(iface);
return IInternetProtocol_Release(PROTOCOL(This));
}
static HRESULT WINAPI HttpPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
{
HttpProtocol *This = PRIORITY_THIS(iface);
TRACE("(%p)->(%ld)\n", This, nPriority);
This->priority = nPriority;
return S_OK;
}
static HRESULT WINAPI HttpPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
{
HttpProtocol *This = PRIORITY_THIS(iface);
TRACE("(%p)->(%p)\n", This, pnPriority);
*pnPriority = This->priority;
return S_OK;
}
#undef PRIORITY_THIS
static const IInternetPriorityVtbl HttpPriorityVtbl = {
HttpPriority_QueryInterface,
HttpPriority_AddRef,
HttpPriority_Release,
HttpPriority_SetPriority,
HttpPriority_GetPriority
};
static const IInternetProtocolVtbl HttpProtocolVtbl = {
HttpProtocol_QueryInterface,
HttpProtocol_AddRef,
@ -194,8 +252,12 @@ HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HttpProtocol));
ret->lpInternetProtocolVtbl = &HttpProtocolVtbl;
ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
ret->ref = 1;
ret->priority = 0;
*ppobj = PROTOCOL(ret);
return S_OK;

View File

@ -206,6 +206,31 @@ static IInternetBindInfoVtbl bind_info_vtbl = {
static IInternetBindInfo bind_info = { &bind_info_vtbl };
static void test_priority(IInternetProtocol *protocol)
{
IInternetPriority *priority;
LONG pr;
HRESULT hres;
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08lx\n", hres);
if(FAILED(hres))
return;
hres = IInternetPriority_GetPriority(priority, &pr);
ok(hres == S_OK, "GetPriority failed: %08lx\n", hres);
ok(pr == 0, "pr=%ld, expected 0\n", pr);
hres = IInternetPriority_SetPriority(priority, 1);
ok(hres == S_OK, "SetPriority failed: %08lx\n", hres);
hres = IInternetPriority_GetPriority(priority, &pr);
ok(hres == S_OK, "GetPriority failed: %08lx\n", hres);
ok(pr == 1, "pr=%ld, expected 1\n", pr);
IInternetPriority_Release(priority);
}
static void file_protocol_start(IInternetProtocol *protocol, LPCWSTR url, BOOL is_first)
{
HRESULT hres;
@ -414,11 +439,45 @@ static void test_file_protocol(void) {
IInternetProtocol_Release(protocol);
}
static void test_http_protocol(void)
{
IInternetProtocol *protocol;
IInternetProtocolInfo *protocol_info;
IClassFactory *factory;
IUnknown *unk;
HRESULT hres;
hres = CoGetClassObject(&CLSID_HttpProtocol, CLSCTX_INPROC_SERVER, NULL,
&IID_IUnknown, (void**)&unk);
ok(hres == S_OK, "CoGetClassObject failed: %08lx\n", hres);
if(!SUCCEEDED(hres))
return;
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
ok(hres == E_NOINTERFACE,
"Could not get IInternetProtocolInfo interface: %08lx, 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);
ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres);
test_priority(protocol);
IInternetProtocol_Release(protocol);
}
START_TEST(protocol)
{
OleInitialize(NULL);
test_file_protocol();
test_http_protocol();
OleUninitialize();
}