Author: cwittich
Date: Sun May 30 12:20:31 2010
New Revision: 47438
URL:
http://svn.reactos.org/svn/reactos?rev=47438&view=rev
Log:
[URLMON]
sync to wine 1.2 RC2
Modified:
trunk/reactos/dll/win32/urlmon/binding.c
trunk/reactos/dll/win32/urlmon/file.c
trunk/reactos/dll/win32/urlmon/umon.c
trunk/reactos/dll/win32/urlmon/uri.c
trunk/reactos/include/psdk/urlmon.idl
Modified: trunk/reactos/dll/win32/urlmon/binding.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/binding.c…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/binding.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/binding.c [iso-8859-1] Sun May 30 12:20:31 2010
@@ -47,6 +47,7 @@
BYTE buf[1024*8];
DWORD size;
BOOL init;
+ HANDLE file;
HRESULT hres;
LPWSTR cache_file;
@@ -57,7 +58,7 @@
typedef struct {
void (*release)(stgmed_obj_t*);
HRESULT (*fill_stgmed)(stgmed_obj_t*,STGMEDIUM*);
- void *(*get_result)(stgmed_obj_t*);
+ HRESULT (*get_result)(stgmed_obj_t*,DWORD,void**);
} stgmed_obj_vtbl;
struct _stgmed_obj_t {
@@ -101,6 +102,7 @@
LPWSTR redirect_url;
IID iid;
BOOL report_mime;
+ BOOL use_cache_file;
DWORD state;
HRESULT hres;
download_state_t download_state;
@@ -132,6 +134,20 @@
buf->size += read;
if(read > 0)
buf->init = TRUE;
+}
+
+static void read_protocol_data(stgmed_buf_t *stgmed_buf)
+{
+ BYTE buf[8192];
+ DWORD read;
+ HRESULT hres;
+
+ fill_stgmed_buffer(stgmed_buf);
+ if(stgmed_buf->size < sizeof(stgmed_buf->buf))
+ return;
+
+ do hres = IInternetProtocol_Read(stgmed_buf->protocol, buf, sizeof(buf),
&read);
+ while(hres == S_OK);
}
static void dump_BINDINFO(BINDINFO *bi)
@@ -339,6 +355,19 @@
IInternetProtocol_Terminate(binding->protocol, 0);
}
+static void cache_file_available(Binding *This, const WCHAR *file_name)
+{
+ heap_free(This->stgmed_buf->cache_file);
+ This->stgmed_buf->cache_file = heap_strdupW(file_name);
+
+ if(This->use_cache_file) {
+ This->stgmed_buf->file = CreateFileW(file_name, GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if(This->stgmed_buf->file == INVALID_HANDLE_VALUE)
+ WARN("CreateFile failed: %u\n", GetLastError());
+ }
+}
+
#define STGMEDUNK_THIS(iface) DEFINE_THIS(stgmed_buf_t, Unknown, iface)
static HRESULT WINAPI StgMedUnk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
@@ -377,6 +406,8 @@
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
+ if(This->file != INVALID_HANDLE_VALUE)
+ CloseHandle(This->file);
IInternetProtocol_Release(This->protocol);
heap_free(This->cache_file);
heap_free(This);
@@ -403,6 +434,7 @@
ret->ref = 1;
ret->size = 0;
ret->init = FALSE;
+ ret->file = INVALID_HANDLE_VALUE;
ret->hres = S_OK;
ret->cache_file = NULL;
@@ -487,6 +519,15 @@
HRESULT hres;
TRACE("(%p)->(%p %d %p)\n", This, pv, cb, pcbRead);
+
+ if(This->buf->file != INVALID_HANDLE_VALUE) {
+ if (!ReadFile(This->buf->file, pv, cb, &read, NULL))
+ return INET_E_DOWNLOAD_FAILURE;
+
+ if(pcbRead)
+ *pcbRead = read;
+ return read ? S_OK : S_FALSE;
+ }
if(This->buf->size) {
read = cb;
@@ -637,12 +678,13 @@
return S_OK;
}
-static void *stgmed_stream_get_result(stgmed_obj_t *obj)
+static HRESULT stgmed_stream_get_result(stgmed_obj_t *obj, DWORD bindf, void **result)
{
ProtocolStream *stream = (ProtocolStream*)obj;
IStream_AddRef(STREAM(stream));
- return STREAM(stream);
+ *result = STREAM(stream);
+ return S_OK;
}
static const stgmed_obj_vtbl stgmed_stream_vtbl = {
@@ -689,16 +731,7 @@
return INET_E_DATA_NOT_AVAILABLE;
}
- fill_stgmed_buffer(file_obj->buf);
- if(file_obj->buf->size == sizeof(file_obj->buf->buf)) {
- BYTE buf[1024];
- DWORD read;
- HRESULT hres;
-
- do {
- hres = IInternetProtocol_Read(file_obj->buf->protocol, buf,
sizeof(buf), &read);
- }while(hres == S_OK);
- }
+ read_protocol_data(file_obj->buf);
stgmed->tymed = TYMED_FILE;
stgmed->u.lpszFileName = file_obj->buf->cache_file;
@@ -707,9 +740,9 @@
return S_OK;
}
-static void *stgmed_file_get_result(stgmed_obj_t *obj)
-{
- return NULL;
+static HRESULT stgmed_file_get_result(stgmed_obj_t *obj, DWORD bindf, void **result)
+{
+ return bindf & BINDF_ASYNCHRONOUS ? MK_S_ASYNCHRONOUS : S_OK;
}
static const stgmed_obj_vtbl stgmed_file_vtbl = {
@@ -987,8 +1020,7 @@
mime_available(This, szStatusText);
break;
case BINDSTATUS_CACHEFILENAMEAVAILABLE:
- heap_free(This->stgmed_buf->cache_file);
- This->stgmed_buf->cache_file = heap_strdupW(szStatusText);
+ cache_file_available(This, szStatusText);
break;
case BINDSTATUS_DECODING:
IBindStatusCallback_OnProgress(This->callback, 0, 0, BINDSTATUS_DECODING,
szStatusText);
@@ -1019,9 +1051,12 @@
if(This->download_state == END_DOWNLOAD || (This->state &
BINDING_STOPPED))
return;
+ if(This->stgmed_buf->file != INVALID_HANDLE_VALUE)
+ read_protocol_data(This->stgmed_buf);
+ else if(This->download_state == BEFORE_DOWNLOAD)
+ fill_stgmed_buffer(This->stgmed_buf);
+
if(This->download_state == BEFORE_DOWNLOAD) {
- fill_stgmed_buffer(This->stgmed_buf);
-
This->download_state = DOWNLOADING;
sent_begindownloaddata = TRUE;
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
@@ -1430,8 +1465,12 @@
if(to_obj)
ret->bindinfo.dwOptions |= 0x100000;
- if(!is_urlmon_protocol(url))
+ if(!(ret->bindf & BINDF_ASYNCHRONOUS)) {
ret->bindf |= BINDF_NEEDFILE;
+ ret->use_cache_file = TRUE;
+ }else if(!is_urlmon_protocol(url)) {
+ ret->bindf |= BINDF_NEEDFILE;
+ }
ret->url = heap_strdupW(url);
@@ -1530,12 +1569,14 @@
if((binding->state & BINDING_STOPPED) && (binding->state &
BINDING_LOCKED))
IInternetProtocol_UnlockRequest(binding->protocol);
- *ppv = binding->stgmed_obj->vtbl->get_result(binding->stgmed_obj);
+ hres = binding->stgmed_obj->vtbl->get_result(binding->stgmed_obj,
binding->bindf, ppv);
+ }else {
+ hres = MK_S_ASYNCHRONOUS;
}
IBinding_Release(BINDING(binding));
- return *ppv ? S_OK : MK_S_ASYNCHRONOUS;
+ return hres;
}
HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void
**ppv)
Modified: trunk/reactos/dll/win32/urlmon/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/file.c?re…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/file.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/file.c [iso-8859-1] Sun May 30 12:20:31 2010
@@ -141,7 +141,10 @@
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST,
&null_char);
file_name = url+sizeof(wszFile)/sizeof(WCHAR);
- if(file_name[0] == '/' && file_name[1] == '/')
+
+ /* Strip both forward and back slashes */
+ if( (file_name[0] == '/' && file_name[1] == '/') ||
+ (file_name[0] == '\\' && file_name[1] == '\\'))
file_name += 2;
if(*file_name == '/')
file_name++;
Modified: trunk/reactos/dll/win32/urlmon/umon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/umon.c?re…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/umon.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/umon.c [iso-8859-1] Sun May 30 12:20:31 2010
@@ -513,6 +513,12 @@
TRACE("(%p, %s, %p, %08x)\n", pmkContext, debugstr_w(szURL), ppmk,
dwFlags);
+ if (ppmk)
+ *ppmk = NULL;
+
+ if (!szURL || !ppmk)
+ return E_INVALIDARG;
+
if (dwFlags & URL_MK_UNIFORM) FIXME("ignoring flag URL_MK_UNIFORM\n");
if(!(obj = alloc_moniker()))
@@ -619,6 +625,9 @@
{
TRACE("(%p %s %p %p)\n", pbc, debugstr_w(szDisplayName), pchEaten, ppmk);
+ if (!pbc || !szDisplayName || !*szDisplayName || !pchEaten || !ppmk)
+ return E_INVALIDARG;
+
if(is_registered_protocol(szDisplayName)) {
HRESULT hres;
Modified: trunk/reactos/dll/win32/urlmon/uri.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/uri.c?rev…
==============================================================================
--- trunk/reactos/dll/win32/urlmon/uri.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/urlmon/uri.c [iso-8859-1] Sun May 30 12:20:31 2010
@@ -1,5 +1,6 @@
/*
* Copyright 2010 Jacek Caban for CodeWeavers
+ * Copyright 2010 Thomas Mullaly
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -97,6 +98,20 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
+
+ if(!pcchProperty)
+ return E_INVALIDARG;
+
+ /* Microsoft's implementation for the ZONE property of a URI seems to be
lacking...
+ * From what I can tell, instead of checking which URLZONE the URI belongs to it
+ * simply assigns URLZONE_INVALID and returns E_NOTIMPL. This also applies to the
GetZone
+ * function.
+ */
+ if(uriProp == Uri_PROPERTY_ZONE) {
+ *pcchProperty = URLZONE_INVALID;
+ return E_NOTIMPL;
+ }
+
return E_NOTIMPL;
}
@@ -111,6 +126,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrAbsoluteUri);
+
+ if(!pstrAbsoluteUri)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -118,6 +137,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrAuthority);
+
+ if(!pstrAuthority)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -125,6 +148,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrDisplayUri);
+
+ if(!pstrDisplayUri)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -132,6 +159,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrDomain);
+
+ if(!pstrDomain)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -139,6 +170,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrExtension);
+
+ if(!pstrExtension)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -146,6 +181,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrFragment);
+
+ if(!pstrFragment)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -160,6 +199,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrPassword);
+
+ if(!pstrPassword)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -167,6 +210,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrPath);
+
+ if(!pstrPath)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -174,6 +221,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrPathAndQuery);
+
+ if(!pstrPathAndQuery)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -181,6 +232,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrQuery);
+
+ if(!pstrQuery)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -188,6 +243,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrRawUri);
+
+ if(!pstrRawUri)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -195,6 +254,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrSchemeName);
+
+ if(!pstrSchemeName)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -202,6 +265,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrUserInfo);
+
+ if(!pstrUserInfo)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -209,6 +276,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pstrUserName);
+
+ if(!pstrUserName)
+ return E_POINTER;
+
return E_NOTIMPL;
}
@@ -216,6 +287,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pdwHostType);
+
+ if(!pdwHostType)
+ return E_INVALIDARG;
+
return E_NOTIMPL;
}
@@ -223,6 +298,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pdwPort);
+
+ if(!pdwPort)
+ return E_INVALIDARG;
+
return E_NOTIMPL;
}
@@ -230,6 +309,10 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pdwScheme);
+
+ if(!pdwScheme)
+ return E_INVALIDARG;
+
return E_NOTIMPL;
}
@@ -237,6 +320,14 @@
{
Uri *This = URI_THIS(iface);
FIXME("(%p)->(%p)\n", This, pdwZone);
+
+ if(!pdwZone)
+ return E_INVALIDARG;
+
+ /* Microsoft doesn't seem to have this implemented yet... See
+ * the comment in Uri_GetPropertyDWORD for more about this.
+ */
+ *pdwZone = URLZONE_INVALID;
return E_NOTIMPL;
}
@@ -296,6 +387,14 @@
TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved,
ppURI);
+ if(!ppURI)
+ return E_INVALIDARG;
+
+ if(!pwzURI) {
+ *ppURI = NULL;
+ return E_INVALIDARG;
+ }
+
ret = heap_alloc(sizeof(Uri));
if(!ret)
return E_OUTOFMEMORY;
Modified: trunk/reactos/include/psdk/urlmon.idl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/urlmon.idl?re…
==============================================================================
--- trunk/reactos/include/psdk/urlmon.idl [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/urlmon.idl [iso-8859-1] Sun May 30 12:20:31 2010
@@ -1231,6 +1231,7 @@
typedef enum tagURLZONE
{
+ URLZONE_INVALID = -1,
URLZONE_PREDEFINED_MIN = 0,
URLZONE_LOCAL_MACHINE = 0,
URLZONE_INTRANET = 1,
@@ -1562,6 +1563,15 @@
Uri_PROPERTY_ZONE = 18,
Uri_PROPERTY_DWORD_LAST = Uri_PROPERTY_ZONE
} Uri_PROPERTY;
+
+ typedef enum
+ {
+ Uri_HOST_UNKNOWN = 0,
+ Uri_HOST_DNS = 1,
+ Uri_HOST_IPV4 = 2,
+ Uri_HOST_IPV6 = 3,
+ Uri_HOST_IDN = 4
+ } Uri_HOST_TYPE;
HRESULT GetPropertyBSTR(
[in] Uri_PROPERTY uriProp,