2007-08-12 17:39:22 +02:00
|
|
|
/*
|
|
|
|
* Copyright 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
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "urlmon_main.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
|
|
|
|
2007-10-01 14:09:32 +02:00
|
|
|
static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
|
|
|
|
|
|
|
|
extern IID IID_IBindStatusCallbackHolder;
|
|
|
|
|
|
|
|
typedef struct {
|
2011-01-11 00:39:48 +01:00
|
|
|
IBindStatusCallbackEx IBindStatusCallbackEx_iface;
|
|
|
|
IServiceProvider IServiceProvider_iface;
|
|
|
|
IHttpNegotiate2 IHttpNegotiate2_iface;
|
|
|
|
IAuthenticate IAuthenticate_iface;
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IBindStatusCallback *callback;
|
|
|
|
IServiceProvider *serv_prov;
|
|
|
|
} BindStatusCallback;
|
|
|
|
|
2009-06-23 14:53:10 +02:00
|
|
|
static void *get_callback_iface(BindStatusCallback *This, REFIID riid)
|
|
|
|
{
|
|
|
|
void *ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_QueryInterface(This->callback, riid, (void**)&ret);
|
|
|
|
if(FAILED(hres) && This->serv_prov)
|
2009-06-27 00:28:30 +02:00
|
|
|
hres = IServiceProvider_QueryService(This->serv_prov, riid, riid, &ret);
|
2009-06-23 14:53:10 +02:00
|
|
|
|
2009-06-27 00:28:30 +02:00
|
|
|
return SUCCEEDED(hres) ? ret : NULL;
|
2009-06-23 14:53:10 +02:00
|
|
|
}
|
|
|
|
|
2011-01-11 00:39:48 +01:00
|
|
|
static inline BindStatusCallback *impl_from_IBindStatusCallbackEx(IBindStatusCallbackEx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindStatusCallback, IBindStatusCallbackEx_iface);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallbackEx *iface,
|
2007-10-01 14:09:32 +02:00
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
|
2011-01-11 00:39:48 +01:00
|
|
|
*ppv = &This->IBindStatusCallbackEx_iface;
|
2007-10-01 14:09:32 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
|
2011-01-11 00:39:48 +01:00
|
|
|
*ppv = &This->IBindStatusCallbackEx_iface;
|
2009-07-02 23:22:13 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
|
2011-01-11 00:39:48 +01:00
|
|
|
*ppv = &This->IBindStatusCallbackEx_iface;
|
2007-10-01 14:09:32 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBindStatusCallbackHolder, %p)\n", This, ppv);
|
|
|
|
*ppv = This;
|
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
|
2011-01-11 00:39:48 +01:00
|
|
|
*ppv = &This->IServiceProvider_iface;
|
2007-10-01 14:09:32 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate, %p)\n", This, ppv);
|
2011-01-11 00:39:48 +01:00
|
|
|
*ppv = &This->IHttpNegotiate2_iface;
|
2007-10-01 14:09:32 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate2, %p)\n", This, ppv);
|
2011-01-11 00:39:48 +01:00
|
|
|
*ppv = &This->IHttpNegotiate2_iface;
|
2007-10-01 14:09:32 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IAuthenticate, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IAuthenticate, %p)\n", This, ppv);
|
2011-01-11 00:39:48 +01:00
|
|
|
*ppv = &This->IAuthenticate_iface;
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
2012-07-27 11:15:05 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
2007-10-01 14:09:32 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Unsupported riid = %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallbackEx *iface)
|
2007-10-01 14:09:32 +02:00
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref = %d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallbackEx *iface)
|
2007-10-01 14:09:32 +02:00
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref = %d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
if(This->serv_prov)
|
|
|
|
IServiceProvider_Release(This->serv_prov);
|
|
|
|
IBindStatusCallback_Release(This->callback);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallbackEx *iface,
|
2007-10-01 14:09:32 +02:00
|
|
|
DWORD dwReserved, IBinding *pbind)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
|
|
|
|
|
|
|
|
return IBindStatusCallback_OnStartBinding(This->callback, 0xff, pbind);
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
|
2007-10-01 14:09:32 +02:00
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pnPriority);
|
|
|
|
|
|
|
|
return IBindStatusCallback_GetPriority(This->callback, pnPriority);
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
|
2007-10-01 14:09:32 +02:00
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, reserved);
|
|
|
|
|
|
|
|
return IBindStatusCallback_OnLowResource(This->callback, reserved);
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
|
2007-10-01 14:09:32 +02:00
|
|
|
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
|
|
|
|
debugstr_w(szStatusText));
|
|
|
|
|
|
|
|
return IBindStatusCallback_OnProgress(This->callback, ulProgress,
|
|
|
|
ulProgressMax, ulStatusCode, szStatusText);
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallbackEx *iface,
|
2007-10-01 14:09:32 +02:00
|
|
|
HRESULT hresult, LPCWSTR szError)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
|
|
|
|
|
|
|
|
return IBindStatusCallback_OnStopBinding(This->callback, hresult, szError);
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallbackEx *iface,
|
2007-10-01 14:09:32 +02:00
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2009-07-02 23:21:37 +02:00
|
|
|
IBindStatusCallbackEx *bscex;
|
|
|
|
HRESULT hres;
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
|
|
|
|
|
2009-07-02 23:21:37 +02:00
|
|
|
hres = IBindStatusCallback_QueryInterface(This->callback, &IID_IBindStatusCallbackEx, (void**)&bscex);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
DWORD bindf2 = 0, reserv = 0;
|
|
|
|
|
|
|
|
hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, grfBINDF, pbindinfo, &bindf2, &reserv);
|
|
|
|
IBindStatusCallbackEx_Release(bscex);
|
|
|
|
}else {
|
|
|
|
hres = IBindStatusCallback_GetBindInfo(This->callback, grfBINDF, pbindinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallbackEx *iface,
|
2007-10-01 14:09:32 +02:00
|
|
|
DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
|
|
|
|
|
|
|
|
return IBindStatusCallback_OnDataAvailable(This->callback, grfBSCF, dwSize, pformatetc, pstgmed);
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallbackEx *iface,
|
2007-10-01 14:09:32 +02:00
|
|
|
REFIID riid, IUnknown *punk)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
|
|
|
|
|
|
|
|
return IBindStatusCallback_OnObjectAvailable(This->callback, riid, punk);
|
|
|
|
}
|
|
|
|
|
2009-07-02 23:22:13 +02:00
|
|
|
static HRESULT WINAPI BindStatusCallback_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF,
|
|
|
|
BINDINFO *pbindinfo, DWORD *grfBINDF2, DWORD *pdwReserved)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IBindStatusCallbackEx(iface);
|
2009-07-02 23:22:13 +02:00
|
|
|
IBindStatusCallbackEx *bscex;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p %p)\n", This, grfBINDF, pbindinfo, grfBINDF2, pdwReserved);
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_QueryInterface(This->callback, &IID_IBindStatusCallbackEx, (void**)&bscex);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, grfBINDF, pbindinfo, grfBINDF2, pdwReserved);
|
|
|
|
IBindStatusCallbackEx_Release(bscex);
|
|
|
|
}else {
|
|
|
|
hres = IBindStatusCallback_GetBindInfo(This->callback, grfBINDF, pbindinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindStatusCallbackExVtbl BindStatusCallbackExVtbl = {
|
2007-10-01 14:09:32 +02:00
|
|
|
BindStatusCallback_QueryInterface,
|
|
|
|
BindStatusCallback_AddRef,
|
|
|
|
BindStatusCallback_Release,
|
|
|
|
BindStatusCallback_OnStartBinding,
|
|
|
|
BindStatusCallback_GetPriority,
|
|
|
|
BindStatusCallback_OnLowResource,
|
|
|
|
BindStatusCallback_OnProgress,
|
|
|
|
BindStatusCallback_OnStopBinding,
|
|
|
|
BindStatusCallback_GetBindInfo,
|
|
|
|
BindStatusCallback_OnDataAvailable,
|
2009-07-02 23:22:13 +02:00
|
|
|
BindStatusCallback_OnObjectAvailable,
|
|
|
|
BindStatusCallback_GetBindInfoEx
|
2007-10-01 14:09:32 +02:00
|
|
|
};
|
|
|
|
|
2011-01-11 00:39:48 +01:00
|
|
|
static inline BindStatusCallback *impl_from_IServiceProvider(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindStatusCallback, IServiceProvider_iface);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryInterface(IServiceProvider *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IServiceProvider(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_QueryInterface(&This->IBindStatusCallbackEx_iface, riid, ppv);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IServiceProvider(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_AddRef(&This->IBindStatusCallbackEx_iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IServiceProvider(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_Release(&This->IBindStatusCallbackEx_iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IServiceProvider(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IHttpNegotiate, guidService)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate %s %p)\n", This, debugstr_guid(riid), ppv);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_QueryInterface(&This->IBindStatusCallbackEx_iface, riid, ppv);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IHttpNegotiate2, guidService)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate2 %s %p)\n", This, debugstr_guid(riid), ppv);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_QueryInterface(&This->IBindStatusCallbackEx_iface, riid, ppv);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
|
|
|
|
TRACE("(%p)->(IID_IAuthenticate %s %p)\n", This, debugstr_guid(riid), ppv);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_QueryInterface(&This->IBindStatusCallbackEx_iface, riid, ppv);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_QueryInterface(This->callback, riid, ppv);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(This->serv_prov) {
|
|
|
|
hres = IServiceProvider_QueryService(This->serv_prov, guidService, riid, ppv);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl BSCServiceProviderVtbl = {
|
|
|
|
BSCServiceProvider_QueryInterface,
|
|
|
|
BSCServiceProvider_AddRef,
|
|
|
|
BSCServiceProvider_Release,
|
|
|
|
BSCServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
2011-01-11 00:39:48 +01:00
|
|
|
static inline BindStatusCallback *impl_from_IHttpNegotiate2(IHttpNegotiate2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindStatusCallback, IHttpNegotiate2_iface);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI BSCHttpNegotiate_QueryInterface(IHttpNegotiate2 *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IHttpNegotiate2(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_QueryInterface(&This->IBindStatusCallbackEx_iface, riid, ppv);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCHttpNegotiate_AddRef(IHttpNegotiate2 *iface)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IHttpNegotiate2(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_AddRef(&This->IBindStatusCallbackEx_iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCHttpNegotiate_Release(IHttpNegotiate2 *iface)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IHttpNegotiate2(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_Release(&This->IBindStatusCallbackEx_iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface,
|
|
|
|
LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IHttpNegotiate2(iface);
|
2009-06-23 14:53:10 +02:00
|
|
|
IHttpNegotiate *http_negotiate;
|
|
|
|
HRESULT hres = S_OK;
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(szURL), debugstr_w(szHeaders), dwReserved,
|
|
|
|
pszAdditionalHeaders);
|
|
|
|
|
|
|
|
*pszAdditionalHeaders = NULL;
|
|
|
|
|
2009-06-23 14:53:10 +02:00
|
|
|
http_negotiate = get_callback_iface(This, &IID_IHttpNegotiate);
|
|
|
|
if(http_negotiate) {
|
|
|
|
hres = IHttpNegotiate_BeginningTransaction(http_negotiate, szURL, szHeaders,
|
|
|
|
dwReserved, pszAdditionalHeaders);
|
|
|
|
IHttpNegotiate_Release(http_negotiate);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
|
2009-06-23 14:53:10 +02:00
|
|
|
return hres;
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCHttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
|
|
|
|
LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders,
|
|
|
|
LPWSTR *pszAdditionalRequestHeaders)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IHttpNegotiate2(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
LPWSTR additional_headers = NULL;
|
2009-06-23 14:53:10 +02:00
|
|
|
IHttpNegotiate *http_negotiate;
|
2007-10-01 14:09:32 +02:00
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %s %p)\n", This, dwResponseCode, debugstr_w(szResponseHeaders),
|
|
|
|
debugstr_w(szRequestHeaders), pszAdditionalRequestHeaders);
|
|
|
|
|
2009-06-23 14:53:10 +02:00
|
|
|
http_negotiate = get_callback_iface(This, &IID_IHttpNegotiate);
|
|
|
|
if(http_negotiate) {
|
|
|
|
hres = IHttpNegotiate_OnResponse(http_negotiate, dwResponseCode, szResponseHeaders,
|
|
|
|
szRequestHeaders, &additional_headers);
|
|
|
|
IHttpNegotiate_Release(http_negotiate);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
if(pszAdditionalRequestHeaders)
|
|
|
|
*pszAdditionalRequestHeaders = additional_headers;
|
|
|
|
else if(additional_headers)
|
|
|
|
CoTaskMemFree(additional_headers);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCHttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
|
|
|
|
BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IHttpNegotiate2(iface);
|
2009-06-23 14:53:10 +02:00
|
|
|
IHttpNegotiate2 *http_negotiate2;
|
|
|
|
HRESULT hres = E_FAIL;
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %ld)\n", This, pbSecurityId, pcbSecurityId, dwReserved);
|
|
|
|
|
2009-06-23 14:53:10 +02:00
|
|
|
http_negotiate2 = get_callback_iface(This, &IID_IHttpNegotiate2);
|
|
|
|
if(http_negotiate2) {
|
|
|
|
hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, pbSecurityId,
|
|
|
|
pcbSecurityId, dwReserved);
|
|
|
|
IHttpNegotiate2_Release(http_negotiate2);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
|
2009-06-23 14:53:10 +02:00
|
|
|
return hres;
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHttpNegotiate2Vtbl BSCHttpNegotiateVtbl = {
|
|
|
|
BSCHttpNegotiate_QueryInterface,
|
|
|
|
BSCHttpNegotiate_AddRef,
|
|
|
|
BSCHttpNegotiate_Release,
|
|
|
|
BSCHttpNegotiate_BeginningTransaction,
|
|
|
|
BSCHttpNegotiate_OnResponse,
|
|
|
|
BSCHttpNegotiate_GetRootSecurityId
|
|
|
|
};
|
|
|
|
|
2011-01-11 00:39:48 +01:00
|
|
|
static inline BindStatusCallback *impl_from_IAuthenticate(IAuthenticate *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindStatusCallback, IAuthenticate_iface);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI BSCAuthenticate_QueryInterface(IAuthenticate *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IAuthenticate(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_QueryInterface(&This->IBindStatusCallbackEx_iface, riid, ppv);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCAuthenticate_AddRef(IAuthenticate *iface)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IAuthenticate(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_AddRef(&This->IBindStatusCallbackEx_iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCAuthenticate_Release(IAuthenticate *iface)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IAuthenticate(iface);
|
2012-07-27 11:15:05 +02:00
|
|
|
return IBindStatusCallbackEx_Release(&This->IBindStatusCallbackEx_iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCAuthenticate_Authenticate(IAuthenticate *iface,
|
|
|
|
HWND *phwnd, LPWSTR *pszUsername, LPWSTR *pszPassword)
|
|
|
|
{
|
2011-01-11 00:39:48 +01:00
|
|
|
BindStatusCallback *This = impl_from_IAuthenticate(iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
FIXME("(%p)->(%p %p %p)\n", This, phwnd, pszUsername, pszPassword);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IAuthenticateVtbl BSCAuthenticateVtbl = {
|
|
|
|
BSCAuthenticate_QueryInterface,
|
|
|
|
BSCAuthenticate_AddRef,
|
|
|
|
BSCAuthenticate_Release,
|
|
|
|
BSCAuthenticate_Authenticate
|
|
|
|
};
|
|
|
|
|
2010-10-06 21:36:03 +02:00
|
|
|
static void set_callback(BindStatusCallback *This, IBindStatusCallback *bsc)
|
2007-10-01 14:09:32 +02:00
|
|
|
{
|
2010-10-06 21:36:03 +02:00
|
|
|
IServiceProvider *serv_prov;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(This->callback)
|
|
|
|
IBindStatusCallback_Release(This->callback);
|
|
|
|
if(This->serv_prov)
|
|
|
|
IServiceProvider_Release(This->serv_prov);
|
|
|
|
|
|
|
|
IBindStatusCallback_AddRef(bsc);
|
|
|
|
This->callback = bsc;
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_QueryInterface(bsc, &IID_IServiceProvider, (void**)&serv_prov);
|
|
|
|
This->serv_prov = hres == S_OK ? serv_prov : NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-06 21:36:18 +02:00
|
|
|
HRESULT wrap_callback(IBindStatusCallback *bsc, IBindStatusCallback **ret_iface)
|
2010-10-06 21:36:03 +02:00
|
|
|
{
|
|
|
|
BindStatusCallback *ret;
|
|
|
|
|
|
|
|
ret = heap_alloc_zero(sizeof(BindStatusCallback));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
2007-10-01 14:09:32 +02:00
|
|
|
|
2011-01-11 00:39:48 +01:00
|
|
|
ret->IBindStatusCallbackEx_iface.lpVtbl = &BindStatusCallbackExVtbl;
|
|
|
|
ret->IServiceProvider_iface.lpVtbl = &BSCServiceProviderVtbl;
|
|
|
|
ret->IHttpNegotiate2_iface.lpVtbl = &BSCHttpNegotiateVtbl;
|
|
|
|
ret->IAuthenticate_iface.lpVtbl = &BSCAuthenticateVtbl;
|
2007-10-01 14:09:32 +02:00
|
|
|
|
|
|
|
ret->ref = 1;
|
2010-10-06 21:36:03 +02:00
|
|
|
set_callback(ret, bsc);
|
2007-10-01 14:09:32 +02:00
|
|
|
|
2011-01-11 00:39:48 +01:00
|
|
|
*ret_iface = (IBindStatusCallback*)&ret->IBindStatusCallbackEx_iface;
|
2010-10-06 21:36:03 +02:00
|
|
|
return S_OK;
|
2007-10-01 14:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RegisterBindStatusCallback (urlmon.@)
|
|
|
|
*
|
|
|
|
* Register a bind status callback.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pbc [I] Binding context
|
|
|
|
* pbsc [I] Callback to register
|
|
|
|
* ppbscPrevious [O] Destination for previous callback
|
|
|
|
* dwReserved [I] Reserved, must be 0.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid, or
|
|
|
|
* E_OUTOFMEMORY if memory allocation fails.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc,
|
|
|
|
IBindStatusCallback **ppbscPrevious, DWORD dwReserved)
|
|
|
|
{
|
|
|
|
BindStatusCallback *holder;
|
|
|
|
IBindStatusCallback *bsc, *prev = NULL;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %p %p %x)\n", pbc, pbsc, ppbscPrevious, dwReserved);
|
|
|
|
|
|
|
|
if (!pbc || !pbsc)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&bsc);
|
2010-10-06 21:36:03 +02:00
|
|
|
IUnknown_Release(unk);
|
2007-10-01 14:09:32 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2010-10-06 21:36:03 +02:00
|
|
|
if(ppbscPrevious) {
|
|
|
|
IBindStatusCallback_AddRef(holder->callback);
|
|
|
|
*ppbscPrevious = holder->callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_callback(holder, pbsc);
|
|
|
|
|
2007-10-01 14:09:32 +02:00
|
|
|
IBindStatusCallback_Release(bsc);
|
2012-07-27 11:15:05 +02:00
|
|
|
IBindStatusCallbackEx_Release(&holder->IBindStatusCallbackEx_iface);
|
2010-10-06 21:36:03 +02:00
|
|
|
return S_OK;
|
2007-10-01 14:09:32 +02:00
|
|
|
}else {
|
|
|
|
prev = bsc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindCtx_RevokeObjectParam(pbc, BSCBHolder);
|
|
|
|
}
|
|
|
|
|
2010-10-06 21:36:03 +02:00
|
|
|
hres = wrap_callback(pbsc, &bsc);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc);
|
|
|
|
IBindStatusCallback_Release(bsc);
|
|
|
|
}
|
2007-10-01 14:09:32 +02:00
|
|
|
if(FAILED(hres)) {
|
2008-09-28 17:44:56 +02:00
|
|
|
if(prev)
|
|
|
|
IBindStatusCallback_Release(prev);
|
2007-10-01 14:09:32 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ppbscPrevious)
|
|
|
|
*ppbscPrevious = prev;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RevokeBindStatusCallback (URLMON.@)
|
|
|
|
*
|
|
|
|
* Unregister a bind status callback.
|
|
|
|
*
|
|
|
|
* pbc [I] Binding context
|
|
|
|
* pbsc [I] Callback to unregister
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI RevokeBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc)
|
|
|
|
{
|
|
|
|
BindStatusCallback *holder;
|
|
|
|
IBindStatusCallback *callback;
|
|
|
|
IUnknown *unk;
|
|
|
|
BOOL dorevoke = FALSE;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %p)\n", pbc, pbsc);
|
|
|
|
|
|
|
|
if (!pbc || !pbsc)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&callback);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_QueryInterface(callback, &IID_IBindStatusCallbackHolder, (void**)&holder);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
if(pbsc == holder->callback)
|
|
|
|
dorevoke = TRUE;
|
2012-07-27 11:15:05 +02:00
|
|
|
IBindStatusCallbackEx_Release(&holder->IBindStatusCallbackEx_iface);
|
2007-10-01 14:09:32 +02:00
|
|
|
}else if(pbsc == callback) {
|
|
|
|
dorevoke = TRUE;
|
|
|
|
}
|
|
|
|
IBindStatusCallback_Release(callback);
|
|
|
|
|
|
|
|
if(dorevoke)
|
|
|
|
IBindCtx_RevokeObjectParam(pbc, BSCBHolder);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-08-12 17:39:22 +02:00
|
|
|
typedef struct {
|
2011-01-11 00:41:11 +01:00
|
|
|
IBindCtx IBindCtx_iface;
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IBindCtx *bindctx;
|
|
|
|
} AsyncBindCtx;
|
|
|
|
|
2011-01-11 00:41:11 +01:00
|
|
|
static inline AsyncBindCtx *impl_from_IBindCtx(IBindCtx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AsyncBindCtx, IBindCtx_iface);
|
|
|
|
}
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_QueryInterface(IBindCtx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2011-01-11 00:41:11 +01:00
|
|
|
*ppv = &This->IBindCtx_iface;
|
2007-08-12 17:39:22 +02:00
|
|
|
}else if(IsEqualGUID(riid, &IID_IBindCtx)) {
|
|
|
|
TRACE("(%p)->(IID_IBindCtx %p)\n", This, ppv);
|
2011-01-11 00:41:11 +01:00
|
|
|
*ppv = &This->IBindCtx_iface;
|
2007-08-12 17:39:22 +02:00
|
|
|
}else if(IsEqualGUID(riid, &IID_IAsyncBindCtx)) {
|
|
|
|
TRACE("(%p)->(IID_IAsyncBindCtx %p)\n", This, ppv);
|
2011-01-11 00:41:11 +01:00
|
|
|
*ppv = &This->IBindCtx_iface;
|
2007-08-12 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AsyncBindCtx_AddRef(IBindCtx *iface)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AsyncBindCtx_Release(IBindCtx *iface)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
IBindCtx_Release(This->bindctx);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2007-08-12 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_RegisterObjectBound(IBindCtx *iface, IUnknown *punk)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, punk);
|
|
|
|
|
|
|
|
return IBindCtx_RegisterObjectBound(This->bindctx, punk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_RevokeObjectBound(IBindCtx *iface, IUnknown *punk)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p %p)\n", This, punk);
|
|
|
|
|
|
|
|
return IBindCtx_RevokeObjectBound(This->bindctx, punk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_ReleaseBoundObjects(IBindCtx *iface)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IBindCtx_ReleaseBoundObjects(This->bindctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_SetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pbindopts);
|
|
|
|
|
|
|
|
return IBindCtx_SetBindOptions(This->bindctx, pbindopts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_GetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pbindopts);
|
|
|
|
|
|
|
|
return IBindCtx_GetBindOptions(This->bindctx, pbindopts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_GetRunningObjectTable(IBindCtx *iface, IRunningObjectTable **pprot)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pprot);
|
|
|
|
|
|
|
|
return IBindCtx_GetRunningObjectTable(This->bindctx, pprot);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_RegisterObjectParam(IBindCtx *iface, LPOLESTR pszkey, IUnknown *punk)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
|
|
|
|
|
|
|
|
return IBindCtx_RegisterObjectParam(This->bindctx, pszkey, punk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_GetObjectParam(IBindCtx* iface, LPOLESTR pszkey, IUnknown **punk)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
|
|
|
|
|
|
|
|
return IBindCtx_GetObjectParam(This->bindctx, pszkey, punk);
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:42:03 +01:00
|
|
|
static HRESULT WINAPI AsyncBindCtx_RevokeObjectParam(IBindCtx *iface, LPOLESTR pszkey)
|
2007-08-12 17:39:22 +02:00
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
2007-12-30 17:42:03 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(pszkey));
|
2007-08-12 17:39:22 +02:00
|
|
|
|
2007-12-30 17:42:03 +01:00
|
|
|
return IBindCtx_RevokeObjectParam(This->bindctx, pszkey);
|
2007-08-12 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AsyncBindCtx_EnumObjectParam(IBindCtx *iface, IEnumString **pszkey)
|
|
|
|
{
|
2011-01-11 00:41:11 +01:00
|
|
|
AsyncBindCtx *This = impl_from_IBindCtx(iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pszkey);
|
|
|
|
|
|
|
|
return IBindCtx_EnumObjectParam(This->bindctx, pszkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindCtxVtbl AsyncBindCtxVtbl =
|
|
|
|
{
|
|
|
|
AsyncBindCtx_QueryInterface,
|
|
|
|
AsyncBindCtx_AddRef,
|
|
|
|
AsyncBindCtx_Release,
|
|
|
|
AsyncBindCtx_RegisterObjectBound,
|
|
|
|
AsyncBindCtx_RevokeObjectBound,
|
|
|
|
AsyncBindCtx_ReleaseBoundObjects,
|
|
|
|
AsyncBindCtx_SetBindOptions,
|
|
|
|
AsyncBindCtx_GetBindOptions,
|
|
|
|
AsyncBindCtx_GetRunningObjectTable,
|
|
|
|
AsyncBindCtx_RegisterObjectParam,
|
|
|
|
AsyncBindCtx_GetObjectParam,
|
|
|
|
AsyncBindCtx_EnumObjectParam,
|
|
|
|
AsyncBindCtx_RevokeObjectParam
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT init_bindctx(IBindCtx *bindctx, DWORD options,
|
|
|
|
IBindStatusCallback *callback, IEnumFORMATETC *format)
|
|
|
|
{
|
|
|
|
BIND_OPTS bindopts;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(options)
|
|
|
|
FIXME("not supported options %08x\n", options);
|
|
|
|
if(format)
|
|
|
|
FIXME("format is not supported\n");
|
|
|
|
|
|
|
|
bindopts.cbStruct = sizeof(BIND_OPTS);
|
|
|
|
bindopts.grfFlags = BIND_MAYBOTHERUSER;
|
|
|
|
bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
|
|
|
|
bindopts.dwTickCountDeadline = 0;
|
|
|
|
|
|
|
|
hres = IBindCtx_SetBindOptions(bindctx, &bindopts);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(callback) {
|
|
|
|
hres = RegisterBindStatusCallback(bindctx, callback, NULL, 0);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateAsyncBindCtx (urlmon.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
|
|
|
|
IEnumFORMATETC *format, IBindCtx **pbind)
|
|
|
|
{
|
|
|
|
IBindCtx *bindctx;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%08x %p %p %p)\n", reserved, callback, format, pbind);
|
|
|
|
|
|
|
|
if(!pbind || !callback)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hres = CreateBindCtx(0, &bindctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = init_bindctx(bindctx, 0, callback, format);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IBindCtx_Release(bindctx);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbind = bindctx;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateAsyncBindCtxEx (urlmon.@)
|
|
|
|
*
|
|
|
|
* Create an asynchronous bind context.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
|
|
|
|
IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx** pbind,
|
|
|
|
DWORD reserved)
|
|
|
|
{
|
|
|
|
AsyncBindCtx *ret;
|
|
|
|
IBindCtx *bindctx;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %08x %p %p %p %d)\n", ibind, options, callback, format, pbind, reserved);
|
|
|
|
|
|
|
|
if(!pbind)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if(reserved)
|
|
|
|
WARN("reserved=%d\n", reserved);
|
|
|
|
|
2007-12-30 17:42:03 +01:00
|
|
|
if(ibind) {
|
|
|
|
IBindCtx_AddRef(ibind);
|
|
|
|
bindctx = ibind;
|
|
|
|
}else {
|
|
|
|
hres = CreateBindCtx(0, &bindctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
2007-08-12 17:39:22 +02:00
|
|
|
|
2007-11-29 22:12:34 +01:00
|
|
|
ret = heap_alloc(sizeof(AsyncBindCtx));
|
2007-08-12 17:39:22 +02:00
|
|
|
|
2011-01-11 00:41:11 +01:00
|
|
|
ret->IBindCtx_iface.lpVtbl = &AsyncBindCtxVtbl;
|
2007-08-12 17:39:22 +02:00
|
|
|
ret->ref = 1;
|
|
|
|
ret->bindctx = bindctx;
|
|
|
|
|
2011-01-11 00:41:11 +01:00
|
|
|
hres = init_bindctx(&ret->IBindCtx_iface, options, callback, format);
|
2007-08-12 17:39:22 +02:00
|
|
|
if(FAILED(hres)) {
|
2011-01-11 00:41:11 +01:00
|
|
|
IBindCtx_Release(&ret->IBindCtx_iface);
|
2007-08-12 17:39:22 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-01-11 00:41:11 +01:00
|
|
|
*pbind = &ret->IBindCtx_iface;
|
2007-08-12 17:39:22 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|