2005-11-14 16:12:43 +01:00
|
|
|
/*
|
2007-02-08 02:32:48 +01:00
|
|
|
* Copyright 2005-2007 Jacek Caban for CodeWeavers
|
2005-11-14 16:12:43 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-11-14 16:12:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "urlmon_main.h"
|
2007-12-30 17:45:00 +01:00
|
|
|
#include "winreg.h"
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
static WCHAR cbinding_contextW[] = {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
|
2007-12-30 17:45:00 +01:00
|
|
|
static WCHAR bscb_holderW[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
|
2007-12-30 17:44:02 +01:00
|
|
|
|
2006-05-31 19:45:16 +02:00
|
|
|
typedef struct Binding Binding;
|
|
|
|
|
2007-02-07 17:29:12 +01:00
|
|
|
struct _task_header_t;
|
2007-02-07 17:31:04 +01:00
|
|
|
|
2007-02-07 17:29:12 +01:00
|
|
|
typedef void (*task_proc_t)(Binding*, struct _task_header_t*);
|
2006-05-31 19:45:16 +02:00
|
|
|
|
2007-02-07 17:29:12 +01:00
|
|
|
typedef struct _task_header_t {
|
2007-02-07 17:31:04 +01:00
|
|
|
task_proc_t proc;
|
2007-02-07 17:29:12 +01:00
|
|
|
struct _task_header_t *next;
|
|
|
|
} task_header_t;
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
typedef struct {
|
2008-01-31 18:15:11 +01:00
|
|
|
const IUnknownVtbl *lpUnknownVtbl;
|
2006-05-31 19:45:16 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IInternetProtocol *protocol;
|
|
|
|
|
|
|
|
BYTE buf[1024*8];
|
2008-01-31 18:15:11 +01:00
|
|
|
DWORD size;
|
|
|
|
BOOL init;
|
2007-02-10 16:32:44 +01:00
|
|
|
HRESULT hres;
|
2008-01-31 18:17:18 +01:00
|
|
|
|
|
|
|
LPWSTR cache_file;
|
2008-01-31 18:15:11 +01:00
|
|
|
} stgmed_buf_t;
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
typedef struct _stgmed_obj_t stgmed_obj_t;
|
2008-01-31 18:15:11 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2008-01-31 18:15:53 +01:00
|
|
|
void (*release)(stgmed_obj_t*);
|
|
|
|
HRESULT (*fill_stgmed)(stgmed_obj_t*,STGMEDIUM*);
|
|
|
|
void *(*get_result)(stgmed_obj_t*);
|
|
|
|
} stgmed_obj_vtbl;
|
2008-01-31 18:15:11 +01:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
struct _stgmed_obj_t {
|
|
|
|
const stgmed_obj_vtbl *vtbl;
|
|
|
|
};
|
2008-01-31 18:15:11 +01:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
#define STGMEDUNK(x) ((IUnknown*) &(x)->lpUnknownVtbl)
|
2006-05-31 19:45:16 +02:00
|
|
|
|
2007-08-03 13:35:35 +02:00
|
|
|
typedef enum {
|
|
|
|
BEFORE_DOWNLOAD,
|
|
|
|
DOWNLOADING,
|
|
|
|
END_DOWNLOAD
|
|
|
|
} download_state_t;
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
#define BINDING_LOCKED 0x0001
|
|
|
|
#define BINDING_STOPPED 0x0002
|
|
|
|
#define BINDING_OBJAVAIL 0x0004
|
2007-12-17 01:38:50 +01:00
|
|
|
|
2006-05-31 19:45:16 +02:00
|
|
|
struct Binding {
|
2005-11-14 16:12:43 +01:00
|
|
|
const IBindingVtbl *lpBindingVtbl;
|
2009-05-18 18:31:03 +02:00
|
|
|
const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
|
2005-11-14 16:12:43 +01:00
|
|
|
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
|
2009-03-29 21:31:15 +02:00
|
|
|
const IWinInetHttpInfoVtbl *lpWinInetHttpInfoVtbl;
|
2005-11-14 16:12:43 +01:00
|
|
|
const IServiceProviderVtbl *lpServiceProviderVtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
IBindStatusCallback *callback;
|
|
|
|
IInternetProtocol *protocol;
|
2006-01-05 13:42:32 +01:00
|
|
|
IServiceProvider *service_provider;
|
2008-01-31 18:15:11 +01:00
|
|
|
|
|
|
|
stgmed_buf_t *stgmed_buf;
|
2008-01-31 18:15:53 +01:00
|
|
|
stgmed_obj_t *stgmed_obj;
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
BINDINFO bindinfo;
|
|
|
|
DWORD bindf;
|
2007-12-30 17:45:00 +01:00
|
|
|
BOOL to_object;
|
2005-11-14 16:12:43 +01:00
|
|
|
LPWSTR mime;
|
2007-12-13 20:25:59 +01:00
|
|
|
UINT clipboard_format;
|
2005-11-14 16:12:43 +01:00
|
|
|
LPWSTR url;
|
2007-12-30 17:45:00 +01:00
|
|
|
IID iid;
|
2007-02-08 02:33:32 +01:00
|
|
|
BOOL report_mime;
|
2007-12-17 01:38:50 +01:00
|
|
|
DWORD state;
|
2007-12-30 17:43:11 +01:00
|
|
|
HRESULT hres;
|
2007-08-03 13:35:35 +02:00
|
|
|
download_state_t download_state;
|
2007-12-30 17:45:00 +01:00
|
|
|
IUnknown *obj;
|
|
|
|
IMoniker *mon;
|
|
|
|
IBindCtx *bctx;
|
2006-05-25 18:35:35 +02:00
|
|
|
HWND notif_hwnd;
|
2006-05-27 22:56:20 +02:00
|
|
|
|
2006-05-31 19:45:16 +02:00
|
|
|
CRITICAL_SECTION section;
|
2006-01-09 17:18:06 +01:00
|
|
|
};
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
#define BINDING(x) ((IBinding*) &(x)->lpBindingVtbl)
|
|
|
|
#define BINDINF(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl)
|
2009-03-29 21:31:15 +02:00
|
|
|
#define INETINFO(x) ((IWinInetHttpInfo*) &(x)->lpWinInetHttpInfoVtbl)
|
2005-11-14 16:12:43 +01:00
|
|
|
#define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
|
|
|
|
|
2006-01-09 17:18:06 +01:00
|
|
|
#define STREAM(x) ((IStream*) &(x)->lpStreamVtbl)
|
2007-07-24 03:35:53 +02:00
|
|
|
#define HTTPNEG2(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
static void fill_stgmed_buffer(stgmed_buf_t *buf)
|
2006-06-03 00:26:48 +02:00
|
|
|
{
|
|
|
|
DWORD read = 0;
|
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
if(sizeof(buf->buf) == buf->size)
|
2006-06-03 00:26:48 +02:00
|
|
|
return;
|
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
buf->hres = IInternetProtocol_Read(buf->protocol, buf->buf+buf->size,
|
|
|
|
sizeof(buf->buf)-buf->size, &read);
|
|
|
|
buf->size += read;
|
2007-07-24 03:30:17 +02:00
|
|
|
if(read > 0)
|
2008-01-31 18:15:11 +01:00
|
|
|
buf->init = TRUE;
|
2006-06-03 00:26:48 +02:00
|
|
|
}
|
|
|
|
|
2006-05-27 22:56:40 +02:00
|
|
|
static void dump_BINDINFO(BINDINFO *bi)
|
|
|
|
{
|
2006-11-29 11:03:44 +01:00
|
|
|
static const char * const BINDINFOF_str[] = {
|
2006-05-27 22:56:40 +02:00
|
|
|
"#0",
|
|
|
|
"BINDINFOF_URLENCODESTGMEDDATA",
|
|
|
|
"BINDINFOF_URLENCODEDEXTRAINFO"
|
|
|
|
};
|
|
|
|
|
2006-11-29 11:03:44 +01:00
|
|
|
static const char * const BINDVERB_str[] = {
|
2006-05-27 22:56:40 +02:00
|
|
|
"BINDVERB_GET",
|
|
|
|
"BINDVERB_POST",
|
|
|
|
"BINDVERB_PUT",
|
|
|
|
"BINDVERB_CUSTOM"
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE("\n"
|
|
|
|
"BINDINFO = {\n"
|
2006-10-05 23:49:11 +02:00
|
|
|
" %d, %s,\n"
|
|
|
|
" {%d, %p, %p},\n"
|
2006-05-27 22:56:40 +02:00
|
|
|
" %s,\n"
|
|
|
|
" %s,\n"
|
|
|
|
" %s,\n"
|
2006-10-05 23:49:11 +02:00
|
|
|
" %d, %08x, %d, %d\n"
|
|
|
|
" {%d %p %x},\n"
|
2006-05-27 22:56:40 +02:00
|
|
|
" %s\n"
|
2006-10-05 23:49:11 +02:00
|
|
|
" %p, %d\n"
|
2006-05-27 22:56:40 +02:00
|
|
|
"}\n",
|
|
|
|
|
|
|
|
bi->cbSize, debugstr_w(bi->szExtraInfo),
|
|
|
|
bi->stgmedData.tymed, bi->stgmedData.u.hGlobal, bi->stgmedData.pUnkForRelease,
|
|
|
|
bi->grfBindInfoF > BINDINFOF_URLENCODEDEXTRAINFO
|
|
|
|
? "unknown" : BINDINFOF_str[bi->grfBindInfoF],
|
|
|
|
bi->dwBindVerb > BINDVERB_CUSTOM
|
|
|
|
? "unknown" : BINDVERB_str[bi->dwBindVerb],
|
|
|
|
debugstr_w(bi->szCustomVerb),
|
2006-09-29 12:42:10 +02:00
|
|
|
bi->cbstgmedData, bi->dwOptions, bi->dwOptionsFlags, bi->dwCodePage,
|
2006-05-27 22:56:40 +02:00
|
|
|
bi->securityAttributes.nLength,
|
|
|
|
bi->securityAttributes.lpSecurityDescriptor,
|
|
|
|
bi->securityAttributes.bInheritHandle,
|
|
|
|
debugstr_guid(&bi->iid),
|
|
|
|
bi->pUnk, bi->dwReserved
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-05-14 00:49:33 +02:00
|
|
|
static void mime_available(Binding *This, LPCWSTR mime)
|
2007-12-13 20:25:59 +01:00
|
|
|
{
|
2009-05-14 00:49:33 +02:00
|
|
|
heap_free(This->mime);
|
|
|
|
This->mime = heap_strdupW(mime);
|
2007-12-13 20:25:59 +01:00
|
|
|
|
2009-05-14 00:49:33 +02:00
|
|
|
if(!This->mime || !This->report_mime)
|
2007-12-13 20:25:59 +01:00
|
|
|
return;
|
|
|
|
|
2009-05-14 00:49:33 +02:00
|
|
|
IBindStatusCallback_OnProgress(This->callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE, This->mime);
|
2007-12-13 20:25:59 +01:00
|
|
|
|
2009-05-14 00:49:33 +02:00
|
|
|
This->clipboard_format = RegisterClipboardFormatW(This->mime);
|
2007-12-13 20:25:59 +01:00
|
|
|
}
|
|
|
|
|
2007-12-30 17:43:11 +01:00
|
|
|
static void stop_binding(Binding *binding, HRESULT hres, LPCWSTR str)
|
|
|
|
{
|
|
|
|
if(binding->state & BINDING_LOCKED) {
|
|
|
|
IInternetProtocol_UnlockRequest(binding->protocol);
|
|
|
|
binding->state &= ~BINDING_LOCKED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(binding->state & BINDING_STOPPED)) {
|
|
|
|
binding->state |= BINDING_STOPPED;
|
|
|
|
|
|
|
|
IBindStatusCallback_OnStopBinding(binding->callback, hres, str);
|
|
|
|
binding->hres = hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
static LPWSTR get_mime_clsid(LPCWSTR mime, CLSID *clsid)
|
|
|
|
{
|
|
|
|
LPWSTR key_name, ret;
|
|
|
|
DWORD res, type, size;
|
|
|
|
HKEY hkey;
|
|
|
|
int len;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR mime_keyW[] =
|
|
|
|
{'M','I','M','E','\\','D','a','t','a','b','a','s','e','\\',
|
|
|
|
'C','o','n','t','e','n','t',' ','T','y','p','e','\\'};
|
|
|
|
static const WCHAR clsidW[] = {'C','L','S','I','D',0};
|
|
|
|
|
|
|
|
len = strlenW(mime)+1;
|
|
|
|
key_name = heap_alloc(sizeof(mime_keyW) + len*sizeof(WCHAR));
|
|
|
|
memcpy(key_name, mime_keyW, sizeof(mime_keyW));
|
|
|
|
strcpyW(key_name + sizeof(mime_keyW)/sizeof(WCHAR), mime);
|
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_CLASSES_ROOT, key_name, &hkey);
|
|
|
|
heap_free(key_name);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
WARN("Could not open MIME key: %x\n", res);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = 50*sizeof(WCHAR);
|
|
|
|
ret = heap_alloc(size);
|
|
|
|
res = RegQueryValueExW(hkey, clsidW, NULL, &type, (LPBYTE)ret, &size);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS) {
|
|
|
|
WARN("Could not get CLSID: %08x\n", res);
|
|
|
|
heap_free(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CLSIDFromString(ret, clsid);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("Could not parse CLSID: %08x\n", hres);
|
|
|
|
heap_free(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void load_doc_mon(Binding *binding, IPersistMoniker *persist)
|
|
|
|
{
|
|
|
|
IBindCtx *bctx;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CreateAsyncBindCtxEx(binding->bctx, 0, NULL, NULL, &bctx, 0);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CreateAsyncBindCtxEx failed: %08x\n", hres);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindCtx_RevokeObjectParam(bctx, bscb_holderW);
|
|
|
|
IBindCtx_RegisterObjectParam(bctx, cbinding_contextW, (IUnknown*)BINDING(binding));
|
|
|
|
|
|
|
|
hres = IPersistMoniker_Load(persist, binding->download_state == END_DOWNLOAD, binding->mon, bctx, 0x12);
|
|
|
|
IBindCtx_RevokeObjectParam(bctx, cbinding_contextW);
|
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
FIXME("Load failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
2008-02-22 02:09:12 +01:00
|
|
|
static HRESULT create_mime_object(Binding *binding, const CLSID *clsid, LPCWSTR clsid_str)
|
2007-12-30 17:45:00 +01:00
|
|
|
{
|
|
|
|
IPersistMoniker *persist;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2008-02-22 02:09:12 +01:00
|
|
|
hres = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
2007-12-30 17:45:00 +01:00
|
|
|
&binding->iid, (void**)&binding->obj);
|
2008-02-22 02:09:12 +01:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CoCreateInstance failed: %08x\n", hres);
|
|
|
|
return INET_E_CANNOT_INSTANTIATE_OBJECT;
|
|
|
|
}
|
2007-12-30 17:45:00 +01:00
|
|
|
|
|
|
|
binding->state |= BINDING_OBJAVAIL;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(binding->obj, &IID_IPersistMoniker, (void**)&persist);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IMonikerProp *prop;
|
|
|
|
|
|
|
|
hres = IPersistMoniker_QueryInterface(persist, &IID_IMonikerProp, (void**)&prop);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IMonikerProp_PutProperty(prop, MIMETYPEPROP, binding->mime);
|
|
|
|
IMonikerProp_PutProperty(prop, CLASSIDPROP, clsid_str);
|
|
|
|
IMonikerProp_Release(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
load_doc_mon(binding, persist);
|
|
|
|
|
|
|
|
IPersistMoniker_Release(persist);
|
|
|
|
}else {
|
|
|
|
FIXME("Could not get IPersistMoniker: %08x\n", hres);
|
|
|
|
/* FIXME: Try query IPersistFile */
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindStatusCallback_OnObjectAvailable(binding->callback, &binding->iid, binding->obj);
|
|
|
|
|
2008-02-22 02:09:12 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_object(Binding *binding)
|
|
|
|
{
|
|
|
|
LPWSTR clsid_str;
|
|
|
|
CLSID clsid;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!binding->mime) {
|
|
|
|
FIXME("MIME not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(clsid_str = get_mime_clsid(binding->mime, &clsid))) {
|
|
|
|
FIXME("Could not find object for MIME %s\n", debugstr_w(binding->mime));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_CLASSIDAVAILABLE, clsid_str);
|
|
|
|
IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_BEGINSYNCOPERATION, NULL);
|
|
|
|
|
|
|
|
hres = create_mime_object(binding, &clsid, clsid_str);
|
|
|
|
heap_free(clsid_str);
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_ENDSYNCOPERATION, NULL);
|
|
|
|
|
2008-02-22 02:09:12 +01:00
|
|
|
stop_binding(binding, hres, NULL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
IInternetProtocol_Terminate(binding->protocol, 0);
|
2007-12-30 17:45:00 +01:00
|
|
|
}
|
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
#define STGMEDUNK_THIS(iface) DEFINE_THIS(stgmed_buf_t, Unknown, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI StgMedUnk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
stgmed_buf_t *This = STGMEDUNK_THIS(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
|
|
|
|
*ppv = STGMEDUNK(This);
|
|
|
|
IUnknown_AddRef(STGMEDUNK(This));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StgMedUnk_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
stgmed_buf_t *This = STGMEDUNK_THIS(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI StgMedUnk_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
stgmed_buf_t *This = STGMEDUNK_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
IInternetProtocol_Release(This->protocol);
|
2008-01-31 18:17:18 +01:00
|
|
|
heap_free(This->cache_file);
|
2008-01-31 18:15:11 +01:00
|
|
|
heap_free(This);
|
|
|
|
|
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef STGMEDUNK_THIS
|
|
|
|
|
|
|
|
static const IUnknownVtbl StgMedUnkVtbl = {
|
|
|
|
StgMedUnk_QueryInterface,
|
|
|
|
StgMedUnk_AddRef,
|
|
|
|
StgMedUnk_Release
|
|
|
|
};
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
static stgmed_buf_t *create_stgmed_buf(IInternetProtocol *protocol)
|
|
|
|
{
|
|
|
|
stgmed_buf_t *ret = heap_alloc(sizeof(*ret));
|
|
|
|
|
|
|
|
ret->lpUnknownVtbl = &StgMedUnkVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
ret->size = 0;
|
|
|
|
ret->init = FALSE;
|
|
|
|
ret->hres = S_OK;
|
2008-01-31 18:17:18 +01:00
|
|
|
ret->cache_file = NULL;
|
2008-01-31 18:15:53 +01:00
|
|
|
|
|
|
|
IInternetProtocol_AddRef(protocol);
|
|
|
|
ret->protocol = protocol;
|
|
|
|
|
|
|
|
URLMON_LockModule();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
stgmed_obj_t stgmed_obj;
|
|
|
|
const IStreamVtbl *lpStreamVtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
stgmed_buf_t *buf;
|
|
|
|
} ProtocolStream;
|
|
|
|
|
2006-01-09 17:18:06 +01:00
|
|
|
#define STREAM_THIS(iface) DEFINE_THIS(ProtocolStream, Stream, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_QueryInterface(IStream *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = STREAM(This);
|
|
|
|
}else if(IsEqualGUID(&IID_ISequentialStream, riid)) {
|
|
|
|
TRACE("(%p)->(IID_ISequentialStream %p)\n", This, ppv);
|
|
|
|
*ppv = STREAM(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IStream, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IStream %p)\n", This, ppv);
|
|
|
|
*ppv = STREAM(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IStream_AddRef(STREAM(This));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ProtocolStream_AddRef(IStream *iface)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-01-09 17:18:06 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ProtocolStream_Release(IStream *iface)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-01-09 17:18:06 +01:00
|
|
|
|
|
|
|
if(!ref) {
|
2008-01-31 18:15:11 +01:00
|
|
|
IUnknown_Release(STGMEDUNK(This->buf));
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2006-01-09 17:20:04 +01:00
|
|
|
|
|
|
|
URLMON_UnlockModule();
|
2006-01-09 17:18:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_Read(IStream *iface, void *pv,
|
2008-01-31 18:15:11 +01:00
|
|
|
ULONG cb, ULONG *pcbRead)
|
2006-01-09 17:18:06 +01:00
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
DWORD read = 0, pread = 0;
|
2008-01-31 18:15:11 +01:00
|
|
|
HRESULT hres;
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%p %d %p)\n", This, pv, cb, pcbRead);
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
if(This->buf->size) {
|
2006-01-09 17:18:06 +01:00
|
|
|
read = cb;
|
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
if(read > This->buf->size)
|
|
|
|
read = This->buf->size;
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
memcpy(pv, This->buf->buf, read);
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
if(read < This->buf->size)
|
|
|
|
memmove(This->buf->buf, This->buf->buf+read, This->buf->size-read);
|
|
|
|
This->buf->size -= read;
|
2006-01-09 17:18:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(read == cb) {
|
2007-08-03 23:10:55 +02:00
|
|
|
if (pcbRead)
|
|
|
|
*pcbRead = read;
|
2006-01-09 17:18:06 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
hres = This->buf->hres = IInternetProtocol_Read(This->buf->protocol, (PBYTE)pv+read, cb-read, &pread);
|
2007-08-03 23:10:55 +02:00
|
|
|
if (pcbRead)
|
|
|
|
*pcbRead = read + pread;
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
if(hres == E_PENDING)
|
2006-05-25 18:40:47 +02:00
|
|
|
return E_PENDING;
|
2008-01-31 18:15:11 +01:00
|
|
|
else if(FAILED(hres))
|
|
|
|
FIXME("Read failed: %08x\n", hres);
|
2006-05-25 18:40:47 +02:00
|
|
|
|
2006-01-09 17:18:06 +01:00
|
|
|
return read || pread ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_Write(IStream *iface, const void *pv,
|
|
|
|
ULONG cb, ULONG *pcbWritten)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%p %d %p)\n", This, pv, cb, pcbWritten);
|
2006-01-09 17:18:06 +01:00
|
|
|
|
|
|
|
return STG_E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
|
|
|
|
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%d %08x %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2006-01-09 17:18:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%d)\n", This, libNewSize.u.LowPart);
|
2006-01-09 17:18:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_CopyTo(IStream *iface, IStream *pstm,
|
|
|
|
ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%p %d %p %p)\n", This, pstm, cb.u.LowPart, pcbRead, pcbWritten);
|
2006-01-09 17:18:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_Commit(IStream *iface, DWORD grfCommitFlags)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%08x)\n", This, grfCommitFlags);
|
2006-01-09 17:18:06 +01:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_Revert(IStream *iface)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
|
|
|
|
ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%d %d %d)\n", This, libOffset.u.LowPart, cb.u.LowPart, dwLockType);
|
2006-01-09 17:18:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_UnlockRegion(IStream *iface,
|
|
|
|
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%d %d %d)\n", This, libOffset.u.LowPart, cb.u.LowPart, dwLockType);
|
2006-01-09 17:18:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_Stat(IStream *iface, STATSTG *pstatstg,
|
|
|
|
DWORD dwStatFlag)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%p %08x)\n", This, pstatstg, dwStatFlag);
|
2006-01-09 17:18:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolStream_Clone(IStream *iface, IStream **ppstm)
|
|
|
|
{
|
|
|
|
ProtocolStream *This = STREAM_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, ppstm);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef STREAM_THIS
|
|
|
|
|
|
|
|
static const IStreamVtbl ProtocolStreamVtbl = {
|
|
|
|
ProtocolStream_QueryInterface,
|
|
|
|
ProtocolStream_AddRef,
|
|
|
|
ProtocolStream_Release,
|
|
|
|
ProtocolStream_Read,
|
|
|
|
ProtocolStream_Write,
|
|
|
|
ProtocolStream_Seek,
|
|
|
|
ProtocolStream_SetSize,
|
|
|
|
ProtocolStream_CopyTo,
|
|
|
|
ProtocolStream_Commit,
|
|
|
|
ProtocolStream_Revert,
|
|
|
|
ProtocolStream_LockRegion,
|
|
|
|
ProtocolStream_UnlockRegion,
|
|
|
|
ProtocolStream_Stat,
|
|
|
|
ProtocolStream_Clone
|
|
|
|
};
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
static void stgmed_stream_release(stgmed_obj_t *obj)
|
|
|
|
{
|
|
|
|
ProtocolStream *stream = (ProtocolStream*)obj;
|
|
|
|
IStream_Release(STREAM(stream));
|
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
static HRESULT stgmed_stream_fill_stgmed(stgmed_obj_t *obj, STGMEDIUM *stgmed)
|
2006-01-09 17:18:06 +01:00
|
|
|
{
|
2008-01-31 18:15:53 +01:00
|
|
|
ProtocolStream *stream = (ProtocolStream*)obj;
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
stgmed->tymed = TYMED_ISTREAM;
|
|
|
|
stgmed->u.pstm = STREAM(stream);
|
|
|
|
stgmed->pUnkForRelease = STGMEDUNK(stream->buf);
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2006-01-09 17:18:06 +01:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
static void *stgmed_stream_get_result(stgmed_obj_t *obj)
|
|
|
|
{
|
|
|
|
ProtocolStream *stream = (ProtocolStream*)obj;
|
2006-01-09 17:20:04 +01:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
IStream_AddRef(STREAM(stream));
|
|
|
|
return STREAM(stream);
|
2006-01-09 17:18:06 +01:00
|
|
|
}
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
static const stgmed_obj_vtbl stgmed_stream_vtbl = {
|
|
|
|
stgmed_stream_release,
|
|
|
|
stgmed_stream_fill_stgmed,
|
|
|
|
stgmed_stream_get_result
|
|
|
|
};
|
|
|
|
|
2008-01-31 18:17:48 +01:00
|
|
|
typedef struct {
|
|
|
|
stgmed_obj_t stgmed_obj;
|
|
|
|
stgmed_buf_t *buf;
|
|
|
|
} stgmed_file_obj_t;
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
static stgmed_obj_t *create_stgmed_stream(stgmed_buf_t *buf)
|
2008-01-31 18:15:11 +01:00
|
|
|
{
|
|
|
|
ProtocolStream *ret = heap_alloc(sizeof(ProtocolStream));
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
ret->stgmed_obj.vtbl = &stgmed_stream_vtbl;
|
2008-01-31 18:15:11 +01:00
|
|
|
ret->lpStreamVtbl = &ProtocolStreamVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
|
|
|
|
IUnknown_AddRef(STGMEDUNK(buf));
|
|
|
|
ret->buf = buf;
|
|
|
|
|
|
|
|
URLMON_LockModule();
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
return &ret->stgmed_obj;
|
2008-01-31 18:15:11 +01:00
|
|
|
}
|
|
|
|
|
2008-01-31 18:17:48 +01:00
|
|
|
static void stgmed_file_release(stgmed_obj_t *obj)
|
|
|
|
{
|
2008-02-06 17:42:55 +01:00
|
|
|
stgmed_file_obj_t *file_obj = (stgmed_file_obj_t*)obj;
|
|
|
|
|
|
|
|
IUnknown_Release(STGMEDUNK(file_obj->buf));
|
|
|
|
heap_free(file_obj);
|
2008-01-31 18:17:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT stgmed_file_fill_stgmed(stgmed_obj_t *obj, STGMEDIUM *stgmed)
|
|
|
|
{
|
|
|
|
stgmed_file_obj_t *file_obj = (stgmed_file_obj_t*)obj;
|
|
|
|
|
|
|
|
if(!file_obj->buf->cache_file) {
|
|
|
|
WARN("cache_file not set\n");
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
stgmed->tymed = TYMED_FILE;
|
|
|
|
stgmed->u.lpszFileName = file_obj->buf->cache_file;
|
|
|
|
stgmed->pUnkForRelease = STGMEDUNK(file_obj->buf);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *stgmed_file_get_result(stgmed_obj_t *obj)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const stgmed_obj_vtbl stgmed_file_vtbl = {
|
|
|
|
stgmed_file_release,
|
|
|
|
stgmed_file_fill_stgmed,
|
|
|
|
stgmed_file_get_result
|
|
|
|
};
|
|
|
|
|
|
|
|
static stgmed_obj_t *create_stgmed_file(stgmed_buf_t *buf)
|
|
|
|
{
|
|
|
|
stgmed_file_obj_t *ret = heap_alloc(sizeof(*ret));
|
|
|
|
|
|
|
|
ret->stgmed_obj.vtbl = &stgmed_file_vtbl;
|
|
|
|
|
|
|
|
IUnknown_AddRef(STGMEDUNK(buf));
|
|
|
|
ret->buf = buf;
|
|
|
|
|
|
|
|
return &ret->stgmed_obj;
|
|
|
|
}
|
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
#define BINDING_THIS(iface) DEFINE_THIS(Binding, Binding, iface)
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = BINDING(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IBinding, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBinding %p)\n", This, ppv);
|
|
|
|
*ppv = BINDING(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv);
|
|
|
|
*ppv = PROTSINK(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv);
|
|
|
|
*ppv = BINDINF(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
|
|
|
|
*ppv = SERVPROV(This);
|
2009-03-29 21:31:15 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IWinInetInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv);
|
|
|
|
|
|
|
|
/* NOTE: This violidates COM rules, but tests prove that we should do it */
|
|
|
|
if(!get_wininet_info(This->protocol))
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
*ppv = INETINFO(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
|
|
|
|
IWinInetHttpInfo *http_info;
|
|
|
|
IWinInetInfo *info;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv);
|
|
|
|
|
|
|
|
info = get_wininet_info(This->protocol);
|
|
|
|
if(!info)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
hres = IWinInetInfo_QueryInterface(info, &IID_IWinInetHttpInfo, (void**)&http_info);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IWinInetHttpInfo_Release(http_info);
|
|
|
|
*ppv = INETINFO(This);
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
2006-01-09 17:20:04 +01:00
|
|
|
if(*ppv) {
|
|
|
|
IBinding_AddRef(BINDING(This));
|
2005-11-14 16:12:43 +01:00
|
|
|
return S_OK;
|
2006-01-09 17:20:04 +01:00
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
WARN("Unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Binding_AddRef(IBinding *iface)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Binding_Release(IBinding *iface)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
if(!ref) {
|
2009-05-11 13:14:45 +02:00
|
|
|
if(This->notif_hwnd)
|
|
|
|
release_notif_hwnd(This->notif_hwnd);
|
2007-12-30 17:45:00 +01:00
|
|
|
if(This->mon)
|
|
|
|
IMoniker_Release(This->mon);
|
2005-11-14 16:12:43 +01:00
|
|
|
if(This->callback)
|
|
|
|
IBindStatusCallback_Release(This->callback);
|
|
|
|
if(This->protocol)
|
|
|
|
IInternetProtocol_Release(This->protocol);
|
2006-01-05 13:42:32 +01:00
|
|
|
if(This->service_provider)
|
|
|
|
IServiceProvider_Release(This->service_provider);
|
2008-01-31 18:15:11 +01:00
|
|
|
if(This->stgmed_buf)
|
|
|
|
IUnknown_Release(STGMEDUNK(This->stgmed_buf));
|
2008-01-31 18:15:53 +01:00
|
|
|
if(This->stgmed_obj)
|
|
|
|
This->stgmed_obj->vtbl->release(This->stgmed_obj);
|
2007-12-30 17:45:00 +01:00
|
|
|
if(This->obj)
|
|
|
|
IUnknown_Release(This->obj);
|
|
|
|
if(This->bctx)
|
|
|
|
IBindCtx_Release(This->bctx);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
ReleaseBindInfo(&This->bindinfo);
|
2007-03-10 22:10:52 +01:00
|
|
|
This->section.DebugInfo->Spare[0] = 0;
|
2006-05-31 19:45:16 +02:00
|
|
|
DeleteCriticalSection(&This->section);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This->mime);
|
|
|
|
heap_free(This->url);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2006-01-09 17:20:04 +01:00
|
|
|
|
|
|
|
URLMON_UnlockModule();
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_Abort(IBinding *iface)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_Suspend(IBinding *iface)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_Resume(IBinding *iface)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%d)\n", This, nPriority);
|
2005-11-14 16:12:43 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pnPriority);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
|
|
|
|
DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
|
|
|
|
{
|
|
|
|
Binding *This = BINDING_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p %p %p %p)\n", This, pclsidProtocol, pdwResult, pszResult, pdwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
static Binding *get_bctx_binding(IBindCtx *bctx)
|
|
|
|
{
|
|
|
|
IBinding *binding;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IBindCtx_GetObjectParam(bctx, cbinding_contextW, &unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void*)&binding);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* FIXME!!! */
|
|
|
|
return BINDING_THIS(binding);
|
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
#undef BINDING_THIS
|
|
|
|
|
|
|
|
static const IBindingVtbl BindingVtbl = {
|
|
|
|
Binding_QueryInterface,
|
|
|
|
Binding_AddRef,
|
|
|
|
Binding_Release,
|
|
|
|
Binding_Abort,
|
|
|
|
Binding_Suspend,
|
|
|
|
Binding_Resume,
|
|
|
|
Binding_SetPriority,
|
|
|
|
Binding_GetPriority,
|
|
|
|
Binding_GetBindResult
|
|
|
|
};
|
|
|
|
|
2009-05-18 18:31:03 +02:00
|
|
|
#define PROTSINK_THIS(iface) DEFINE_THIS(Binding, IInternetProtocolSink, iface)
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI InternetProtocolSink_QueryInterface(IInternetProtocolSink *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
Binding *This = PROTSINK_THIS(iface);
|
|
|
|
return IBinding_QueryInterface(BINDING(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocolSink_AddRef(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
Binding *This = PROTSINK_THIS(iface);
|
|
|
|
return IBinding_AddRef(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocolSink_Release(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
Binding *This = PROTSINK_THIS(iface);
|
|
|
|
return IBinding_Release(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetProtocolSink_Switch(IInternetProtocolSink *iface,
|
|
|
|
PROTOCOLDATA *pProtocolData)
|
|
|
|
{
|
|
|
|
Binding *This = PROTSINK_THIS(iface);
|
2006-05-25 18:39:26 +02:00
|
|
|
|
2009-05-11 22:01:05 +02:00
|
|
|
WARN("(%p)->(%p)\n", This, pProtocolData);
|
2006-05-25 18:39:26 +02:00
|
|
|
|
2009-05-11 22:01:05 +02:00
|
|
|
return E_FAIL;
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
2007-02-07 17:31:04 +01:00
|
|
|
static void on_progress(Binding *This, ULONG progress, ULONG progress_max,
|
|
|
|
ULONG status_code, LPCWSTR status_text)
|
|
|
|
{
|
2009-05-11 22:01:54 +02:00
|
|
|
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
|
|
|
|
status_code, status_text);
|
2007-02-07 17:31:04 +01:00
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
static HRESULT WINAPI InternetProtocolSink_ReportProgress(IInternetProtocolSink *iface,
|
|
|
|
ULONG ulStatusCode, LPCWSTR szStatusText)
|
|
|
|
{
|
|
|
|
Binding *This = PROTSINK_THIS(iface);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%u %s)\n", This, ulStatusCode, debugstr_w(szStatusText));
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
switch(ulStatusCode) {
|
2006-05-25 18:37:55 +02:00
|
|
|
case BINDSTATUS_FINDINGRESOURCE:
|
|
|
|
on_progress(This, 0, 0, BINDSTATUS_FINDINGRESOURCE, szStatusText);
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_CONNECTING:
|
|
|
|
on_progress(This, 0, 0, BINDSTATUS_CONNECTING, szStatusText);
|
|
|
|
break;
|
2007-02-07 17:30:28 +01:00
|
|
|
case BINDSTATUS_BEGINDOWNLOADDATA:
|
2008-01-31 18:15:11 +01:00
|
|
|
fill_stgmed_buffer(This->stgmed_buf);
|
2007-02-07 17:30:28 +01:00
|
|
|
break;
|
2005-12-26 13:27:10 +01:00
|
|
|
case BINDSTATUS_SENDINGREQUEST:
|
2006-05-25 18:35:35 +02:00
|
|
|
on_progress(This, 0, 0, BINDSTATUS_SENDINGREQUEST, szStatusText);
|
2005-12-26 13:27:10 +01:00
|
|
|
break;
|
2007-12-30 17:40:26 +01:00
|
|
|
case BINDSTATUS_PROTOCOLCLASSID:
|
|
|
|
break;
|
2009-05-14 00:49:33 +02:00
|
|
|
case BINDSTATUS_MIMETYPEAVAILABLE:
|
2005-12-26 13:27:10 +01:00
|
|
|
case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
|
2009-05-14 00:49:33 +02:00
|
|
|
mime_available(This, szStatusText);
|
2005-12-26 13:27:10 +01:00
|
|
|
break;
|
|
|
|
case BINDSTATUS_CACHEFILENAMEAVAILABLE:
|
2008-01-31 18:17:18 +01:00
|
|
|
heap_free(This->stgmed_buf->cache_file);
|
|
|
|
This->stgmed_buf->cache_file = heap_strdupW(szStatusText);
|
2005-12-26 13:27:10 +01:00
|
|
|
break;
|
2009-05-18 03:06:08 +02:00
|
|
|
case BINDSTATUS_DECODING:
|
|
|
|
IBindStatusCallback_OnProgress(This->callback, 0, 0, BINDSTATUS_DECODING, szStatusText);
|
|
|
|
break;
|
|
|
|
case BINDSTATUS_LOADINGMIMEHANDLER:
|
|
|
|
on_progress(This, 0, 0, BINDSTATUS_LOADINGMIMEHANDLER, szStatusText);
|
|
|
|
break;
|
2009-05-14 00:49:33 +02:00
|
|
|
case BINDSTATUS_DIRECTBIND: /* FIXME: Handle BINDSTATUS_DIRECTBIND in BindProtocol */
|
2007-02-08 02:33:32 +01:00
|
|
|
This->report_mime = FALSE;
|
|
|
|
break;
|
2009-01-12 18:20:14 +01:00
|
|
|
case BINDSTATUS_ACCEPTRANGES:
|
|
|
|
break;
|
2005-11-14 16:12:43 +01:00
|
|
|
default:
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("Unhandled status code %d\n", ulStatusCode);
|
2005-11-14 16:12:43 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
};
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-07 17:29:52 +01:00
|
|
|
static void report_data(Binding *This, DWORD bscf, ULONG progress, ULONG progress_max)
|
2007-02-07 17:31:04 +01:00
|
|
|
{
|
|
|
|
FORMATETC formatetc = {0, NULL, 1, -1, TYMED_ISTREAM};
|
2007-08-03 03:46:58 +02:00
|
|
|
BOOL sent_begindownloaddata = FALSE;
|
2007-02-07 17:31:04 +01:00
|
|
|
|
2007-02-07 17:29:52 +01:00
|
|
|
TRACE("(%p)->(%d %u %u)\n", This, bscf, progress, progress_max);
|
|
|
|
|
2009-03-02 03:18:19 +01:00
|
|
|
if(This->download_state == END_DOWNLOAD || (This->state & BINDING_STOPPED))
|
2007-08-03 13:35:35 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if(This->download_state == BEFORE_DOWNLOAD) {
|
2008-01-31 18:15:11 +01:00
|
|
|
fill_stgmed_buffer(This->stgmed_buf);
|
2007-02-10 16:32:03 +01:00
|
|
|
|
2007-08-03 13:35:35 +02:00
|
|
|
This->download_state = DOWNLOADING;
|
2007-08-03 03:46:58 +02:00
|
|
|
sent_begindownloaddata = TRUE;
|
2007-02-08 02:34:13 +01:00
|
|
|
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
|
|
|
|
BINDSTATUS_BEGINDOWNLOADDATA, This->url);
|
2008-01-31 18:17:18 +01:00
|
|
|
|
|
|
|
if(This->stgmed_buf->cache_file)
|
|
|
|
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
|
|
|
|
BINDSTATUS_CACHEFILENAMEAVAILABLE, This->stgmed_buf->cache_file);
|
2007-02-07 17:29:52 +01:00
|
|
|
}
|
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
if(This->stgmed_buf->hres == S_FALSE || (bscf & BSCF_LASTDATANOTIFICATION)) {
|
2007-08-03 03:45:17 +02:00
|
|
|
This->download_state = END_DOWNLOAD;
|
2007-02-08 02:34:13 +01:00
|
|
|
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
|
|
|
|
BINDSTATUS_ENDDOWNLOADDATA, This->url);
|
2007-08-03 03:46:58 +02:00
|
|
|
}else if(!sent_begindownloaddata) {
|
|
|
|
IBindStatusCallback_OnProgress(This->callback, progress, progress_max,
|
|
|
|
BINDSTATUS_DOWNLOADINGDATA, This->url);
|
2007-02-10 16:32:03 +01:00
|
|
|
}
|
2007-02-07 17:29:52 +01:00
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
if(This->to_object) {
|
|
|
|
if(!(This->state & BINDING_OBJAVAIL))
|
|
|
|
create_object(This);
|
|
|
|
}else {
|
2008-01-31 18:15:53 +01:00
|
|
|
STGMEDIUM stgmed;
|
2008-01-31 18:17:48 +01:00
|
|
|
HRESULT hres;
|
2008-01-31 18:15:53 +01:00
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
if(!(This->state & BINDING_LOCKED)) {
|
|
|
|
HRESULT hres = IInternetProtocol_LockRequest(This->protocol, 0);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
This->state |= BINDING_LOCKED;
|
|
|
|
}
|
2007-02-07 17:29:52 +01:00
|
|
|
|
2008-01-31 18:17:48 +01:00
|
|
|
hres = This->stgmed_obj->vtbl->fill_stgmed(This->stgmed_obj, &stgmed);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
stop_binding(This, hres, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
formatetc.tymed = stgmed.tymed;
|
2007-12-30 17:45:00 +01:00
|
|
|
formatetc.cfFormat = This->clipboard_format;
|
2008-01-31 18:15:53 +01:00
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
IBindStatusCallback_OnDataAvailable(This->callback, bscf, progress,
|
2008-01-31 18:15:53 +01:00
|
|
|
&formatetc, &stgmed);
|
2007-02-07 17:29:52 +01:00
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
if(This->download_state == END_DOWNLOAD)
|
|
|
|
stop_binding(This, S_OK, NULL);
|
|
|
|
}
|
2007-02-07 17:31:04 +01:00
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
static HRESULT WINAPI InternetProtocolSink_ReportData(IInternetProtocolSink *iface,
|
|
|
|
DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
|
|
|
|
{
|
|
|
|
Binding *This = PROTSINK_THIS(iface);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2009-05-11 22:01:39 +02:00
|
|
|
report_data(This, grfBSCF, ulProgress, ulProgressMax);
|
2005-11-14 16:12:43 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetProtocolSink_ReportResult(IInternetProtocolSink *iface,
|
|
|
|
HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
|
|
|
|
{
|
|
|
|
Binding *This = PROTSINK_THIS(iface);
|
2006-05-25 18:33:21 +02:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult));
|
2006-05-25 18:33:21 +02:00
|
|
|
|
2009-05-11 22:01:39 +02:00
|
|
|
IInternetProtocol_Terminate(This->protocol, 0);
|
|
|
|
stop_binding(This, hrResult, szResult);
|
2006-05-25 18:33:21 +02:00
|
|
|
return S_OK;
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef PROTSINK_THIS
|
|
|
|
|
|
|
|
static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = {
|
|
|
|
InternetProtocolSink_QueryInterface,
|
|
|
|
InternetProtocolSink_AddRef,
|
|
|
|
InternetProtocolSink_Release,
|
|
|
|
InternetProtocolSink_Switch,
|
|
|
|
InternetProtocolSink_ReportProgress,
|
|
|
|
InternetProtocolSink_ReportData,
|
|
|
|
InternetProtocolSink_ReportResult
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BINDINF_THIS(iface) DEFINE_THIS(Binding, InternetBindInfo, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_QueryInterface(IInternetBindInfo *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
Binding *This = BINDINF_THIS(iface);
|
|
|
|
return IBinding_QueryInterface(BINDING(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
Binding *This = BINDINF_THIS(iface);
|
|
|
|
return IBinding_AddRef(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
Binding *This = BINDINF_THIS(iface);
|
|
|
|
return IBinding_Release(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_GetBindInfo(IInternetBindInfo *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
|
|
|
Binding *This = BINDINF_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
|
|
|
|
|
|
|
|
*grfBINDF = This->bindf;
|
|
|
|
|
2008-03-18 22:42:20 +01:00
|
|
|
*pbindinfo = This->bindinfo;
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
if(pbindinfo->szExtraInfo || pbindinfo->szCustomVerb)
|
|
|
|
FIXME("copy strings\n");
|
|
|
|
|
2007-07-24 03:31:24 +02:00
|
|
|
if(pbindinfo->stgmedData.pUnkForRelease)
|
|
|
|
IUnknown_AddRef(pbindinfo->stgmedData.pUnkForRelease);
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
if(pbindinfo->pUnk)
|
|
|
|
IUnknown_AddRef(pbindinfo->pUnk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_GetBindString(IInternetBindInfo *iface,
|
|
|
|
ULONG ulStringType, LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
|
|
|
|
{
|
|
|
|
Binding *This = BINDINF_THIS(iface);
|
2006-01-05 12:17:59 +01:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%d %p %d %p)\n", This, ulStringType, ppwzStr, cEl, pcElFetched);
|
2006-01-05 12:17:59 +01:00
|
|
|
|
|
|
|
switch(ulStringType) {
|
|
|
|
case BINDSTRING_ACCEPT_MIMES: {
|
|
|
|
static const WCHAR wszMimes[] = {'*','/','*',0};
|
|
|
|
|
|
|
|
if(!ppwzStr || !pcElFetched)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
ppwzStr[0] = CoTaskMemAlloc(sizeof(wszMimes));
|
|
|
|
memcpy(ppwzStr[0], wszMimes, sizeof(wszMimes));
|
|
|
|
*pcElFetched = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
case BINDSTRING_USER_AGENT: {
|
|
|
|
IInternetBindInfo *bindinfo = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_QueryInterface(This->callback, &IID_IInternetBindInfo,
|
|
|
|
(void**)&bindinfo);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IInternetBindInfo_GetBindString(bindinfo, ulStringType, ppwzStr,
|
|
|
|
cEl, pcElFetched);
|
|
|
|
IInternetBindInfo_Release(bindinfo);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
2009-05-18 03:05:39 +02:00
|
|
|
case BINDSTRING_URL: {
|
|
|
|
DWORD size = (strlenW(This->url)+1) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
if(!ppwzStr || !pcElFetched)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppwzStr = CoTaskMemAlloc(size);
|
|
|
|
memcpy(*ppwzStr, This->url, size);
|
|
|
|
*pcElFetched = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-01-05 12:17:59 +01:00
|
|
|
}
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("not supported string type %d\n", ulStringType);
|
2005-11-14 16:12:43 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef BINDF_THIS
|
|
|
|
|
|
|
|
static const IInternetBindInfoVtbl InternetBindInfoVtbl = {
|
|
|
|
InternetBindInfo_QueryInterface,
|
|
|
|
InternetBindInfo_AddRef,
|
|
|
|
InternetBindInfo_Release,
|
|
|
|
InternetBindInfo_GetBindInfo,
|
|
|
|
InternetBindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
2009-03-29 21:31:15 +02:00
|
|
|
#define INETINFO_THIS(iface) DEFINE_THIS(Binding, WinInetHttpInfo, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI WinInetHttpInfo_QueryInterface(IWinInetHttpInfo *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
Binding *This = INETINFO_THIS(iface);
|
|
|
|
return IBinding_QueryInterface(BINDING(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI WinInetHttpInfo_AddRef(IWinInetHttpInfo *iface)
|
|
|
|
{
|
|
|
|
Binding *This = INETINFO_THIS(iface);
|
|
|
|
return IBinding_AddRef(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI WinInetHttpInfo_Release(IWinInetHttpInfo *iface)
|
|
|
|
{
|
|
|
|
Binding *This = INETINFO_THIS(iface);
|
|
|
|
return IBinding_Release(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WinInetHttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOption,
|
|
|
|
void *pBuffer, DWORD *pcbBuffer)
|
|
|
|
{
|
|
|
|
Binding *This = INETINFO_THIS(iface);
|
|
|
|
FIXME("(%p)->(%x %p %p)\n", This, dwOption, pBuffer, pcbBuffer);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WinInetHttpInfo_QueryInfo(IWinInetHttpInfo *iface, DWORD dwOption,
|
|
|
|
void *pBuffer, DWORD *pcbBuffer, DWORD *pdwFlags, DWORD *pdwReserved)
|
|
|
|
{
|
|
|
|
Binding *This = INETINFO_THIS(iface);
|
|
|
|
FIXME("(%p)->(%x %p %p %p %p)\n", This, dwOption, pBuffer, pcbBuffer, pdwFlags, pdwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef INETINFO_THIS
|
|
|
|
|
|
|
|
static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = {
|
|
|
|
WinInetHttpInfo_QueryInterface,
|
|
|
|
WinInetHttpInfo_AddRef,
|
|
|
|
WinInetHttpInfo_Release,
|
|
|
|
WinInetHttpInfo_QueryOption,
|
|
|
|
WinInetHttpInfo_QueryInfo
|
|
|
|
};
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
#define SERVPROV_THIS(iface) DEFINE_THIS(Binding, ServiceProvider, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
Binding *This = SERVPROV_THIS(iface);
|
|
|
|
return IBinding_QueryInterface(BINDING(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
Binding *This = SERVPROV_THIS(iface);
|
|
|
|
return IBinding_AddRef(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
Binding *This = SERVPROV_THIS(iface);
|
|
|
|
return IBinding_Release(BINDING(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
Binding *This = SERVPROV_THIS(iface);
|
2006-01-05 13:42:43 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if(This->service_provider) {
|
|
|
|
hres = IServiceProvider_QueryService(This->service_provider, guidService,
|
|
|
|
riid, ppv);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unknown service %s\n", debugstr_guid(guidService));
|
2005-11-14 16:12:43 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef SERVPROV_THIS
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl ServiceProviderVtbl = {
|
|
|
|
ServiceProvider_QueryInterface,
|
|
|
|
ServiceProvider_AddRef,
|
|
|
|
ServiceProvider_Release,
|
|
|
|
ServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback)
|
|
|
|
{
|
2007-10-26 00:21:21 +02:00
|
|
|
IUnknown *unk;
|
2005-11-14 16:12:43 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
hres = IBindCtx_GetObjectParam(pbc, bscb_holderW, &unk);
|
2007-10-26 00:21:21 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)callback);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2008-01-31 18:10:18 +01:00
|
|
|
return SUCCEEDED(hres) ? S_OK : INET_E_DATA_NOT_AVAILABLE;
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
2007-02-07 17:27:35 +01:00
|
|
|
static BOOL is_urlmon_protocol(LPCWSTR url)
|
|
|
|
{
|
|
|
|
static const WCHAR wszCdl[] = {'c','d','l'};
|
|
|
|
static const WCHAR wszFile[] = {'f','i','l','e'};
|
|
|
|
static const WCHAR wszFtp[] = {'f','t','p'};
|
|
|
|
static const WCHAR wszGopher[] = {'g','o','p','h','e','r'};
|
|
|
|
static const WCHAR wszHttp[] = {'h','t','t','p'};
|
|
|
|
static const WCHAR wszHttps[] = {'h','t','t','p','s'};
|
|
|
|
static const WCHAR wszMk[] = {'m','k'};
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
LPCWSTR scheme;
|
|
|
|
int len;
|
|
|
|
} protocol_list[] = {
|
|
|
|
{wszCdl, sizeof(wszCdl) /sizeof(WCHAR)},
|
|
|
|
{wszFile, sizeof(wszFile) /sizeof(WCHAR)},
|
|
|
|
{wszFtp, sizeof(wszFtp) /sizeof(WCHAR)},
|
|
|
|
{wszGopher, sizeof(wszGopher)/sizeof(WCHAR)},
|
|
|
|
{wszHttp, sizeof(wszHttp) /sizeof(WCHAR)},
|
|
|
|
{wszHttps, sizeof(wszHttps) /sizeof(WCHAR)},
|
|
|
|
{wszMk, sizeof(wszMk) /sizeof(WCHAR)}
|
|
|
|
};
|
|
|
|
|
2008-11-13 23:20:48 +01:00
|
|
|
unsigned int i;
|
|
|
|
int len = lstrlenW(url);
|
2007-02-07 17:27:35 +01:00
|
|
|
|
|
|
|
for(i=0; i < sizeof(protocol_list)/sizeof(protocol_list[0]); i++) {
|
|
|
|
if(len >= protocol_list[i].len
|
|
|
|
&& !memcmp(url, protocol_list[i].scheme, protocol_list[i].len*sizeof(WCHAR)))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, IBindCtx *pbc,
|
|
|
|
BOOL to_obj, REFIID riid, Binding **binding)
|
2005-11-14 16:12:43 +01:00
|
|
|
{
|
|
|
|
Binding *ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2006-01-09 17:20:04 +01:00
|
|
|
URLMON_LockModule();
|
|
|
|
|
2007-12-30 17:43:39 +01:00
|
|
|
ret = heap_alloc_zero(sizeof(Binding));
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
ret->lpBindingVtbl = &BindingVtbl;
|
2009-05-18 18:31:03 +02:00
|
|
|
ret->lpIInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl;
|
2005-11-14 16:12:43 +01:00
|
|
|
ret->lpInternetBindInfoVtbl = &InternetBindInfoVtbl;
|
2009-03-29 21:31:15 +02:00
|
|
|
ret->lpWinInetHttpInfoVtbl = &WinInetHttpInfoVtbl;
|
2005-11-14 16:12:43 +01:00
|
|
|
ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
|
|
|
|
|
|
|
|
ret->ref = 1;
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
ret->to_object = to_obj;
|
|
|
|
ret->iid = *riid;
|
2006-05-25 18:35:35 +02:00
|
|
|
ret->notif_hwnd = get_notif_hwnd();
|
2007-12-30 17:44:02 +01:00
|
|
|
ret->report_mime = !binding_ctx;
|
2007-08-03 13:35:35 +02:00
|
|
|
ret->download_state = BEFORE_DOWNLOAD;
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
if(to_obj) {
|
|
|
|
IBindCtx_AddRef(pbc);
|
|
|
|
ret->bctx = pbc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mon) {
|
|
|
|
IMoniker_AddRef(mon);
|
|
|
|
ret->mon = mon;
|
|
|
|
}
|
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
ret->bindinfo.cbSize = sizeof(BINDINFO);
|
|
|
|
|
2006-05-31 19:45:16 +02:00
|
|
|
InitializeCriticalSection(&ret->section);
|
2007-03-10 22:10:52 +01:00
|
|
|
ret->section.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": Binding.section");
|
2006-05-31 19:45:16 +02:00
|
|
|
|
2005-11-14 16:12:43 +01:00
|
|
|
hres = get_callback(pbc, &ret->callback);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("Could not get IBindStatusCallback\n");
|
|
|
|
IBinding_Release(BINDING(ret));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2006-01-05 13:42:32 +01:00
|
|
|
IBindStatusCallback_QueryInterface(ret->callback, &IID_IServiceProvider,
|
|
|
|
(void**)&ret->service_provider);
|
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
if(binding_ctx) {
|
|
|
|
ret->protocol = binding_ctx->protocol;
|
|
|
|
IInternetProtocol_AddRef(ret->protocol);
|
|
|
|
}else {
|
|
|
|
hres = create_binding_protocol(url, TRUE, &ret->protocol);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("Could not get protocol handler\n");
|
|
|
|
IBinding_Release(BINDING(ret));
|
|
|
|
return hres;
|
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_GetBindInfo(ret->callback, &ret->bindf, &ret->bindinfo);
|
|
|
|
if(FAILED(hres)) {
|
2006-10-05 23:49:11 +02:00
|
|
|
WARN("GetBindInfo failed: %08x\n", hres);
|
2005-11-14 16:12:43 +01:00
|
|
|
IBinding_Release(BINDING(ret));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
TRACE("bindf %08x\n", ret->bindf);
|
2006-05-27 22:56:40 +02:00
|
|
|
dump_BINDINFO(&ret->bindinfo);
|
|
|
|
|
2005-12-26 13:27:10 +01:00
|
|
|
ret->bindf |= BINDF_FROMURLMON;
|
2007-12-30 17:45:00 +01:00
|
|
|
if(to_obj)
|
|
|
|
ret->bindinfo.dwOptions |= 0x100000;
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2007-02-07 17:27:35 +01:00
|
|
|
if(!is_urlmon_protocol(url))
|
2005-12-26 13:27:10 +01:00
|
|
|
ret->bindf |= BINDF_NEEDFILE;
|
|
|
|
|
2007-12-30 17:43:39 +01:00
|
|
|
ret->url = heap_strdupW(url);
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
if(binding_ctx) {
|
2008-01-31 18:15:11 +01:00
|
|
|
ret->stgmed_buf = binding_ctx->stgmed_buf;
|
|
|
|
IUnknown_AddRef(STGMEDUNK(ret->stgmed_buf));
|
2007-12-30 17:44:02 +01:00
|
|
|
ret->clipboard_format = binding_ctx->clipboard_format;
|
|
|
|
}else {
|
2008-01-31 18:15:11 +01:00
|
|
|
ret->stgmed_buf = create_stgmed_buf(ret->protocol);
|
2007-12-30 17:44:02 +01:00
|
|
|
}
|
2008-01-31 18:15:53 +01:00
|
|
|
|
2008-01-31 18:16:31 +01:00
|
|
|
if(to_obj) {
|
|
|
|
ret->stgmed_obj = NULL;
|
|
|
|
}else if(IsEqualGUID(&IID_IStream, riid)) {
|
|
|
|
ret->stgmed_obj = create_stgmed_stream(ret->stgmed_buf);
|
2008-01-31 18:17:48 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
ret->bindf |= BINDF_NEEDFILE;
|
|
|
|
ret->stgmed_obj = create_stgmed_file(ret->stgmed_buf);
|
2008-01-31 18:16:31 +01:00
|
|
|
}else {
|
|
|
|
FIXME("Unsupported riid %s\n", debugstr_guid(riid));
|
|
|
|
IBinding_Release(BINDING(ret));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
*binding = ret;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, LPCWSTR url, IBindCtx *pbc,
|
|
|
|
BOOL to_obj, REFIID riid, Binding **ret)
|
2005-11-14 16:12:43 +01:00
|
|
|
{
|
|
|
|
Binding *binding = NULL;
|
|
|
|
HRESULT hres;
|
2007-08-07 06:08:31 +02:00
|
|
|
MSG msg;
|
2005-11-14 16:12:43 +01:00
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
hres = Binding_Create(mon, binding_ctx, url, pbc, to_obj, riid, &binding);
|
2005-11-14 16:12:43 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IBindStatusCallback_OnStartBinding(binding->callback, 0, BINDING(binding));
|
|
|
|
if(FAILED(hres)) {
|
2006-10-05 23:49:11 +02:00
|
|
|
WARN("OnStartBinding failed: %08x\n", hres);
|
2008-02-22 02:09:27 +01:00
|
|
|
stop_binding(binding, INET_E_DOWNLOAD_FAILURE, NULL);
|
2005-11-14 16:12:43 +01:00
|
|
|
IBinding_Release(BINDING(binding));
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
if(binding_ctx) {
|
|
|
|
set_binding_sink(binding->protocol, PROTSINK(binding));
|
|
|
|
report_data(binding, 0, 0, 0);
|
|
|
|
}else {
|
|
|
|
hres = IInternetProtocol_Start(binding->protocol, url, PROTSINK(binding),
|
2009-05-14 00:49:33 +02:00
|
|
|
BINDINF(binding), PI_APARTMENTTHREADED|PI_MIMEVERIFICATION, 0);
|
2007-12-30 17:42:17 +01:00
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
TRACE("start ret %08x\n", hres);
|
2006-05-25 18:34:15 +02:00
|
|
|
|
2008-02-18 01:04:53 +01:00
|
|
|
if(FAILED(hres) && hres != E_PENDING) {
|
2007-12-30 17:44:02 +01:00
|
|
|
stop_binding(binding, hres, NULL);
|
|
|
|
IBinding_Release(BINDING(binding));
|
2006-05-25 18:34:15 +02:00
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
|
|
|
|
2007-08-07 06:08:31 +02:00
|
|
|
while(!(binding->bindf & BINDF_ASYNCHRONOUS) &&
|
2007-12-30 17:43:26 +01:00
|
|
|
!(binding->state & BINDING_STOPPED)) {
|
2007-08-07 06:08:31 +02:00
|
|
|
MsgWaitForMultipleObjects(0, NULL, FALSE, 5000, QS_POSTMESSAGE);
|
|
|
|
while (PeekMessageW(&msg, binding->notif_hwnd, WM_USER, WM_USER+117, PM_REMOVE|PM_NOYIELD)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:42:17 +01:00
|
|
|
*ret = binding;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT bind_to_storage(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv)
|
|
|
|
{
|
2007-12-30 17:44:02 +01:00
|
|
|
Binding *binding = NULL, *binding_ctx;
|
2007-12-30 17:42:17 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
2007-12-30 17:44:02 +01:00
|
|
|
binding_ctx = get_bctx_binding(pbc);
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
hres = start_binding(NULL, binding_ctx, url, pbc, FALSE, riid, &binding);
|
2007-12-30 17:44:02 +01:00
|
|
|
if(binding_ctx)
|
|
|
|
IBinding_Release(BINDING(binding_ctx));
|
2007-12-30 17:42:17 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2008-01-31 18:15:11 +01:00
|
|
|
if(binding->hres == S_OK && binding->stgmed_buf->init) {
|
2007-12-30 17:43:26 +01:00
|
|
|
if((binding->state & BINDING_STOPPED) && (binding->state & BINDING_LOCKED))
|
2007-02-07 17:28:17 +01:00
|
|
|
IInternetProtocol_UnlockRequest(binding->protocol);
|
2006-05-25 18:34:15 +02:00
|
|
|
|
2008-01-31 18:15:53 +01:00
|
|
|
*ppv = binding->stgmed_obj->vtbl->get_result(binding->stgmed_obj);
|
2006-05-25 18:34:15 +02:00
|
|
|
}
|
2005-11-14 16:12:43 +01:00
|
|
|
|
|
|
|
IBinding_Release(BINDING(binding));
|
|
|
|
|
2008-01-31 18:17:48 +01:00
|
|
|
return *ppv ? S_OK : MK_S_ASYNCHRONOUS;
|
2005-11-14 16:12:43 +01:00
|
|
|
}
|
2007-12-30 17:45:00 +01:00
|
|
|
|
|
|
|
HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
Binding *binding;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
hres = start_binding(mon, NULL, url, pbc, TRUE, riid, &binding);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(binding->hres != S_OK) {
|
|
|
|
hres = SUCCEEDED(binding->hres) ? S_OK : binding->hres;
|
|
|
|
}else if(binding->bindf & BINDF_ASYNCHRONOUS) {
|
|
|
|
hres = MK_S_ASYNCHRONOUS;
|
|
|
|
}else {
|
|
|
|
*ppv = binding->obj;
|
|
|
|
IUnknown_AddRef(binding->obj);
|
|
|
|
hres = S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
IBinding_Release(BINDING(binding));
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|