Sync to Wine-20050111:

Michael Stefaniuc <mstefani@redhat.de>
- Do not check for non NULL pointer before HeapFree'ing it. It's
  redundant.
Jacek Caban <jack@itma.pwr.wroc.pl>
- Added test of BindToStorage.
- Added some declarations to urlmon.idl.
- Implemented CreateAsyncBindCtx.
- Added test.

svn path=/trunk/; revision=13003
This commit is contained in:
Gé van Geldorp 2005-01-12 23:10:02 +00:00
parent 0edd21e67f
commit 222cd13d93

View file

@ -123,9 +123,7 @@ static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
/* destroy the object if there's no more reference on it */ /* destroy the object if there's no more reference on it */
if (ref == 0) { if (ref == 0) {
if (This->URLName!=NULL)
HeapFree(GetProcessHeap(),0,This->URLName); HeapFree(GetProcessHeap(),0,This->URLName);
HeapFree(GetProcessHeap(),0,This); HeapFree(GetProcessHeap(),0,This);
} }
@ -186,7 +184,6 @@ static HRESULT WINAPI URLMonikerImpl_Load(IMoniker* iface,IStream* pStm)
res = IStream_Read(pStm, &len, sizeof(ULONG), &got); res = IStream_Read(pStm, &len, sizeof(ULONG), &got);
if(SUCCEEDED(res)) { if(SUCCEEDED(res)) {
if(got == sizeof(ULONG)) { if(got == sizeof(ULONG)) {
if(This->URLName)
HeapFree(GetProcessHeap(), 0, This->URLName); HeapFree(GetProcessHeap(), 0, This->URLName);
This->URLName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(len+1)); This->URLName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(len+1));
if(!This->URLName) if(!This->URLName)
@ -324,6 +321,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
IBindStatusCallback *pbscb; IBindStatusCallback *pbscb;
BINDINFO bi; BINDINFO bi;
DWORD bindf; DWORD bindf;
IStream *pstr;
FIXME("(%p)->(%p,%p,%s,%p): stub\n",This,pbc,pmkToLeft,debugstr_guid(riid),ppvObject); FIXME("(%p)->(%p,%p,%s,%p): stub\n",This,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
if(pmkToLeft) { if(pmkToLeft) {
@ -339,8 +337,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
We also need to implement IStream ourselves so that IStream_Read can return We also need to implement IStream ourselves so that IStream_Read can return
E_PENDING */ E_PENDING */
hres = CreateStreamOnHGlobal(0, TRUE, (IStream**)ppvObject); hres = CreateStreamOnHGlobal(0, TRUE, &pstr);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
TRACE("Created dummy stream...\n"); TRACE("Created dummy stream...\n");
@ -401,7 +398,6 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
hres = IBindStatusCallback_OnProgress(pbscb, 0, 0, BINDSTATUS_SENDINGREQUEST, NULL); hres = IBindStatusCallback_OnProgress(pbscb, 0, 0, BINDSTATUS_SENDINGREQUEST, NULL);
hres = E_OUTOFMEMORY; /* FIXME */ hres = E_OUTOFMEMORY; /* FIXME */
if(HttpSendRequestW(This->hrequest, NULL, 0, NULL, 0)) { if(HttpSendRequestW(This->hrequest, NULL, 0, NULL, 0)) {
len = 0; len = 0;
HttpQueryInfoW(This->hrequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &len, &lensz, NULL); HttpQueryInfoW(This->hrequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &len, &lensz, NULL);
@ -414,7 +410,7 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
fmt.lindex = -1; fmt.lindex = -1;
fmt.tymed = TYMED_ISTREAM; fmt.tymed = TYMED_ISTREAM;
stg.tymed = TYMED_ISTREAM; stg.tymed = TYMED_ISTREAM;
stg.u.pstm = *(IStream**)ppvObject; stg.u.pstm = pstr;
stg.pUnkForRelease = NULL; stg.pUnkForRelease = NULL;
while(1) { while(1) {
@ -424,9 +420,9 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
if(InternetReadFile(This->hrequest, buf, sizeof(buf), &bufread)) { if(InternetReadFile(This->hrequest, buf, sizeof(buf), &bufread)) {
TRACE("read %ld bytes %s...\n", bufread, debugstr_an(buf, 10)); TRACE("read %ld bytes %s...\n", bufread, debugstr_an(buf, 10));
if(bufread == 0) break; if(bufread == 0) break;
IStream_Write(*(IStream**)ppvObject, buf, bufread, &written); IStream_Write(pstr, buf, bufread, &written);
total_read += bufread; total_read += bufread;
IStream_Seek(*(IStream**)ppvObject, last_read_pos, STREAM_SEEK_SET, NULL); IStream_Seek(pstr, last_read_pos, STREAM_SEEK_SET, NULL);
hres = IBindStatusCallback_OnProgress(pbscb, total_read, len, (total_read == bufread) ? hres = IBindStatusCallback_OnProgress(pbscb, total_read, len, (total_read == bufread) ?
BINDSTATUS_BEGINDOWNLOADDATA : BINDSTATUS_BEGINDOWNLOADDATA :
BINDSTATUS_DOWNLOADINGDATA, NULL); BINDSTATUS_DOWNLOADINGDATA, NULL);
@ -448,9 +444,11 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
InternetCloseHandle(This->hrequest); InternetCloseHandle(This->hrequest);
InternetCloseHandle(This->hconnect); InternetCloseHandle(This->hconnect);
InternetCloseHandle(This->hinternet); InternetCloseHandle(This->hinternet);
IBindStatusCallback_Release(pbscb);
} }
} }
} }
*ppvObject = (VOID*)pstr;
return hres; return hres;
} }
@ -752,7 +750,7 @@ static HRESULT WINAPI URLMonikerImpl_IBinding_Abort(IBinding* iface)
static HRESULT WINAPI URLMonikerImpl_IBinding_GetBindResult(IBinding* iface, CLSID* pclsidProtocol, DWORD* pdwResult, LPOLESTR* pszResult, DWORD* pdwReserved) static HRESULT WINAPI URLMonikerImpl_IBinding_GetBindResult(IBinding* iface, CLSID* pclsidProtocol, DWORD* pdwResult, LPOLESTR* pszResult, DWORD* pdwReserved)
{ {
ICOM_THIS_MULTI(URLMonikerImpl, lpvtbl2, iface); ICOM_THIS_MULTI(URLMonikerImpl, lpvtbl2, iface);
FIXME("(%p)->(%s, %p, %p, %p): stub\n", This, debugstr_guid(pclsidProtocol), pdwResult, pszResult, pdwReserved); FIXME("(%p)->(%p, %p, %p, %p): stub\n", This, pclsidProtocol, pdwResult, pszResult, pdwReserved);
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -882,8 +880,36 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeft
HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback, HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
IEnumFORMATETC *format, IBindCtx **pbind) IEnumFORMATETC *format, IBindCtx **pbind)
{ {
FIXME("stub.\n"); HRESULT hres;
BIND_OPTS bindopts;
IBindCtx *bctx;
TRACE("(%08lx %p %p %p)\n", reserved, callback, format, pbind);
if(!callback)
return E_INVALIDARG; return E_INVALIDARG;
if(format)
FIXME("format is not supported yet\n");
hres = CreateBindCtx(0, &bctx);
if(FAILED(hres))
return hres;
bindopts.cbStruct = sizeof(BIND_OPTS);
bindopts.grfFlags = BIND_MAYBOTHERUSER;
bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
bindopts.dwTickCountDeadline = 0;
IBindCtx_SetBindOptions(bctx, &bindopts);
hres = IBindCtx_RegisterObjectParam(bctx, (LPOLESTR)BSCBHolder, (IUnknown*)callback);
if(FAILED(hres)) {
IBindCtx_Release(bctx);
return hres;
}
*pbind = bctx;
return S_OK;
} }
/*********************************************************************** /***********************************************************************
* CreateAsyncBindCtxEx (URLMON.@) * CreateAsyncBindCtxEx (URLMON.@)