ChangeSet ID: 21180 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/09 04:28:26
Modified files: dlls/urlmon/tests: protocol.c dlls/urlmon : http.c
Log message: Jacek Caban jack@itma.pwr.wroc.pl Added implementation of IInternetPriority in HttpProtocol.
Patch: http://cvs.winehq.org/patch.py?id=21180
Old revision New revision Changes Path 1.5 1.6 +59 -0 wine/dlls/urlmon/tests/protocol.c 1.1 1.2 +65 -3 wine/dlls/urlmon/http.c
Index: wine/dlls/urlmon/tests/protocol.c diff -u -p wine/dlls/urlmon/tests/protocol.c:1.5 wine/dlls/urlmon/tests/protocol.c:1.6 --- wine/dlls/urlmon/tests/protocol.c:1.5 9 Nov 2005 10:28:26 -0000 +++ wine/dlls/urlmon/tests/protocol.c 9 Nov 2005 10:28:26 -0000 @@ -206,6 +206,31 @@ static IInternetBindInfoVtbl bind_info_v
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(); } Index: wine/dlls/urlmon/http.c diff -u -p wine/dlls/urlmon/http.c:1.1 wine/dlls/urlmon/http.c:1.2 --- wine/dlls/urlmon/http.c:1.1 9 Nov 2005 10:28:26 -0000 +++ wine/dlls/urlmon/http.c 9 Nov 2005 10:28:26 -0000 @@ -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_Query }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_Unloc
#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 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HttpProtocol));
ret->lpInternetProtocolVtbl = &HttpProtocolVtbl; + ret->lpInternetPriorityVtbl = &HttpPriorityVtbl; + ret->ref = 1;
+ ret->priority = 0; + *ppobj = PROTOCOL(ret);
return S_OK;