Jacek Caban : urlmon: Added BindProtocol's IInternetPriority
implementation .
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jan 24 06:18:34 CST 2007
Module: wine
Branch: master
Commit: fed5d9e1fffaa2b0c6e9bb0bd027ca74959866b7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fed5d9e1fffaa2b0c6e9bb0bd027ca74959866b7
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Jan 23 23:33:38 2007 +0100
urlmon: Added BindProtocol's IInternetPriority implementation.
---
dlls/urlmon/bindprot.c | 24 ++++++++++--
dlls/urlmon/tests/protocol.c | 79 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 96 insertions(+), 7 deletions(-)
diff --git a/dlls/urlmon/bindprot.c b/dlls/urlmon/bindprot.c
index c3ad2b0..c7e62f9 100644
--- a/dlls/urlmon/bindprot.c
+++ b/dlls/urlmon/bindprot.c
@@ -42,6 +42,8 @@ typedef struct {
IInternetProtocol *protocol;
IInternetBindInfo *bind_info;
IInternetProtocolSink *protocol_sink;
+
+ LONG priority;
} BindProtocol;
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
@@ -126,6 +128,7 @@ static HRESULT WINAPI BindProtocol_Start
{
BindProtocol *This = PROTOCOL_THIS(iface);
IInternetProtocol *protocol = NULL;
+ IInternetPriority *priority;
IServiceProvider *service_provider;
CLSID clsid = IID_NULL;
LPOLESTR clsid_str;
@@ -178,6 +181,12 @@ static HRESULT WINAPI BindProtocol_Start
IInternetProtocolSink_AddRef(pOIProtSink);
This->protocol_sink = pOIProtSink;
+ hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
+ if(SUCCEEDED(hres)) {
+ IInternetPriority_SetPriority(priority, This->priority);
+ IInternetPriority_Release(priority);
+ }
+
return IInternetProtocol_Start(protocol, szUrl, PROTSINK(This), BINDINFO(This), 0, 0);
}
@@ -356,15 +365,21 @@ static ULONG WINAPI InternetPriority_Rel
static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
{
BindProtocol *This = PRIORITY_THIS(iface);
- FIXME("(%p)->(%d)\n", This, nPriority);
- return E_NOTIMPL;
+
+ TRACE("(%p)->(%d)\n", This, nPriority);
+
+ This->priority = nPriority;
+ return S_OK;
}
static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
{
BindProtocol *This = PRIORITY_THIS(iface);
- FIXME("(%p)->(%p)\n", This, pnPriority);
- return E_NOTIMPL;
+
+ TRACE("(%p)->(%p)\n", This, pnPriority);
+
+ *pnPriority = This->priority;
+ return S_OK;
}
#undef PRIORITY_THIS
@@ -476,6 +491,7 @@ HRESULT create_binding_protocol(LPCWSTR
ret->protocol = NULL;
ret->bind_info = NULL;
ret->protocol_sink = NULL;
+ ret->priority = 0;
*protocol = PROTOCOL(ret);
return S_OK;
diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c
index ddcf47e..81c3757 100644
--- a/dlls/urlmon/tests/protocol.c
+++ b/dlls/urlmon/tests/protocol.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Jacek Caban
+ * Copyright 2005-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
@@ -77,6 +77,7 @@ DEFINE_EXPECT(CreateInstance);
DEFINE_EXPECT(Start);
DEFINE_EXPECT(Terminate);
DEFINE_EXPECT(Read);
+DEFINE_EXPECT(SetPriority);
static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
static const WCHAR index_url[] =
@@ -486,6 +487,47 @@ static IInternetBindInfoVtbl bind_info_v
static IInternetBindInfo bind_info = { &bind_info_vtbl };
+static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface,
+ REFIID riid, void **ppv)
+{
+ ok(0, "unexpected call\n");
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
+{
+ CHECK_EXPECT(SetPriority);
+ ok(nPriority == 100, "nPriority=%d\n", nPriority);
+ return S_OK;
+}
+
+static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+
+static const IInternetPriorityVtbl InternetPriorityVtbl = {
+ InternetPriority_QueryInterface,
+ InternetPriority_AddRef,
+ InternetPriority_Release,
+ InternetPriority_SetPriority,
+ InternetPriority_GetPriority
+};
+
+static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
+
static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
@@ -493,8 +535,10 @@ static HRESULT WINAPI Protocol_QueryInte
return S_OK;
}
- if(IsEqualGUID(&IID_IInternetPriority, riid))
- return E_NOINTERFACE; /* TODO */
+ if(IsEqualGUID(&IID_IInternetPriority, riid)) {
+ *ppv = &InternetPriority;
+ return S_OK;
+ }
ok(0, "unexpected call\n");
*ppv = NULL;
@@ -1233,7 +1277,9 @@ static void test_mk_protocol(void)
static void test_CreateBinding(void)
{
IInternetProtocol *protocol;
+ IInternetPriority *priority;
IInternetSession *session;
+ LONG p;
BYTE buf[1000];
DWORD read;
HRESULT hres;
@@ -1265,9 +1311,26 @@ static void test_CreateBinding(void)
hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
+ hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
+ ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres);
+
+ p = 0xdeadbeef;
+ hres = IInternetPriority_GetPriority(priority, &p);
+ ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
+ ok(!p, "p=%d\n", p);
+
+ hres = IInternetPriority_SetPriority(priority, 100);
+ ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
+
+ p = 0xdeadbeef;
+ hres = IInternetPriority_GetPriority(priority, &p);
+ ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
+ ok(p == 100, "p=%d\n", p);
+
SET_EXPECT(QueryService_InternetProtocol);
SET_EXPECT(CreateInstance);
SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
+ SET_EXPECT(SetPriority);
SET_EXPECT(Start);
expect_hrResult = S_OK;
@@ -1277,6 +1340,7 @@ static void test_CreateBinding(void)
CHECK_CALLED(QueryService_InternetProtocol);
CHECK_CALLED(CreateInstance);
CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
+ CHECK_CALLED(SetPriority);
CHECK_CALLED(Start);
SET_EXPECT(Read);
@@ -1293,11 +1357,20 @@ static void test_CreateBinding(void)
ok(!read, "read = %d\n", read);
CHECK_CALLED(Read);
+ p = 0xdeadbeef;
+ hres = IInternetPriority_GetPriority(priority, &p);
+ ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
+ ok(p == 100, "p=%d\n", p);
+
+ hres = IInternetPriority_SetPriority(priority, 101);
+ ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
+
SET_EXPECT(Terminate);
hres = IInternetProtocol_Terminate(protocol, 0xdeadbeef);
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
CHECK_CALLED(Terminate);
+ IInternetPriority_Release(priority);
IInternetBindInfo_Release(prot_bind_info);
IInternetProtocol_Release(protocol);
IInternetSession_Release(session);
More information about the wine-cvs
mailing list