static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv) { DocHost *This = CLIENTSITE_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); *ppv = CLIENTSITE(This); }else if(IsEqualGUID(&IID_IOleClientSite, riid)) { TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv); *ppv = CLIENTSITE(This); }else if(IsEqualGUID(&IID_IOleWindow, riid)) { TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv); *ppv = INPLACESITE(This); }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) { TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv); *ppv = INPLACESITE(This); }else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)) { TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppv); *ppv = DOCHOSTUI(This); }else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) { TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv); *ppv = DOCHOSTUI2(This); }else if(IsEqualGUID(&IID_IOleDocumentSite, riid)) { TRACE("(%p)->(IID_IOleDocumentSite %p)\n", This, ppv); *ppv = DOCSITE(This); }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) { TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv); *ppv = OLECMD(This); }else if(IsEqualGUID(&IID_IDispatch, riid)) { TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); *ppv = CLDISP(This); }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv); *ppv = SERVPROV(This); } if(*ppv) { IOleClientSite_AddRef(CLIENTSITE(This)); return S_OK; } WARN("Unsupported intrface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; }
void deactivate_document(DocHost *This) { IOleInPlaceObjectWindowless *winobj; IOleObject *oleobj = NULL; IHlinkTarget *hlink = NULL; HRESULT hres; if(This->doc_navigate) { IUnknown_Release(This->doc_navigate); This->doc_navigate = NULL; } if(This->is_prop_notif) advise_prop_notif(This, FALSE); if(This->view) IOleDocumentView_UIActivate(This->view, FALSE); hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless, (void**)&winobj); if(SUCCEEDED(hres)) { IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj); IOleInPlaceObjectWindowless_Release(winobj); } if(This->view) { IOleDocumentView_Show(This->view, FALSE); IOleDocumentView_CloseView(This->view, 0); IOleDocumentView_SetInPlaceSite(This->view, NULL); IOleDocumentView_Release(This->view); This->view = NULL; } hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj); if(SUCCEEDED(hres)) IOleObject_Close(oleobj, OLECLOSE_NOSAVE); hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink); if(SUCCEEDED(hres)) { IHlinkTarget_SetBrowseContext(hlink, NULL); IHlinkTarget_Release(hlink); } if(oleobj) { IOleClientSite *client_site = NULL; IOleObject_GetClientSite(oleobj, &client_site); if(client_site) { if(client_site == CLIENTSITE(This)) IOleObject_SetClientSite(oleobj, NULL); IOleClientSite_Release(client_site); } IOleObject_Release(oleobj); } IUnknown_Release(This->document); This->document = NULL; }
static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx, IBindStatusCallback *callback) { WCHAR schema[30]; DWORD schema_len; HRESULT hres; static const WCHAR httpW[] = {'h','t','t','p',0}; static const WCHAR httpsW[] = {'h','t','t','p','s',0}; static const WCHAR ftpW[]= {'f','t','p',0}; if(mon) { IMoniker_AddRef(mon); }else { hres = create_moniker(url, &mon); if(FAILED(hres)) return hres; } CoTaskMemFree(This->url); hres = IMoniker_GetDisplayName(mon, 0, NULL, &This->url); if(FAILED(hres)) FIXME("GetDisplayName failed: %08x\n", hres); IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, (IUnknown*)CLIENTSITE(This)); hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]), &schema_len, 0); if(SUCCEEDED(hres) && (!strcmpW(schema, httpW) || !strcmpW(schema, httpsW) || !strcmpW(schema, ftpW))) { hres = http_load_hack(This, mon, callback, bindctx); }else { IUnknown *unk = NULL; hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if(SUCCEEDED(hres)) { hres = S_OK; if(unk) IUnknown_Release(unk); }else if(try_application_url(url)) { hres = S_OK; }else { FIXME("BindToObject failed: %08x\n", hres); } } IMoniker_Release(mon); return S_OK; }
static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError) { BindStatusCallback *This = BINDSC_THIS(iface); TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError)); set_status_text(This, emptyW); if(This->doc_host) { IOleClientSite_Release(CLIENTSITE(This->doc_host)); This->doc_host = NULL; } return S_OK; }
HRESULT dochost_object_available(DocHost *This, IUnknown *doc) { READYSTATE ready_state; task_header_t *task; IOleObject *oleobj; HRESULT hres; IUnknown_AddRef(doc); This->document = doc; hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj); if(SUCCEEDED(hres)) { CLSID clsid; hres = IOleObject_GetUserClassID(oleobj, &clsid); if(SUCCEEDED(hres)) TRACE("Got clsid %s\n", IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid)); hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This)); if(FAILED(hres)) FIXME("SetClientSite failed: %08x\n", hres); IOleObject_Release(oleobj); } else { FIXME("Could not get IOleObject iface: %08x\n", hres); } /* FIXME: Call SetAdvise */ task = heap_alloc(sizeof(*task)); push_dochost_task(This, task, object_available_proc, FALSE); hres = get_doc_ready_state(This, &ready_state); if(SUCCEEDED(hres)) { if(ready_state == READYSTATE_COMPLETE) push_ready_state_task(This, READYSTATE_COMPLETE); if(ready_state != READYSTATE_COMPLETE || This->doc_navigate) advise_prop_notif(This, TRUE); } return S_OK; }
static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx, IBindStatusCallback *callback) { IUnknown *unk = NULL; WCHAR *display_name; HRESULT hres; if(mon) { IMoniker_AddRef(mon); }else { hres = create_moniker(url, &mon); if(FAILED(hres)) return hres; } hres = IMoniker_GetDisplayName(mon, 0, NULL, &display_name); if(FAILED(hres)) { FIXME("GetDisplayName failed: %08x\n", hres); return hres; } hres = set_dochost_url(This, display_name); CoTaskMemFree(display_name); if(FAILED(hres)) return hres; IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, (IUnknown*)CLIENTSITE(This)); hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if(SUCCEEDED(hres)) { hres = S_OK; if(unk) IUnknown_Release(unk); }else if(try_application_url(url)) { hres = S_OK; }else { FIXME("BindToObject failed: %08x\n", hres); } IMoniker_Release(mon); return S_OK; }
static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface) { BindStatusCallback *This = BINDSC_THIS(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref=%d\n", This, ref); if(!ref) { if(This->doc_host) IOleClientSite_Release(CLIENTSITE(This->doc_host)); if(This->post_data) GlobalFree(This->post_data); SysFreeString(This->headers); heap_free(This->url); heap_free(This); } return ref; }
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk) { BindStatusCallback *This = BINDSC_THIS(iface); task_header_t *task; IOleObject *oleobj; HRESULT hres; TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk); IUnknown_AddRef(punk); This->doc_host->document = punk; hres = IUnknown_QueryInterface(punk, &IID_IOleObject, (void**)&oleobj); if(SUCCEEDED(hres)) { CLSID clsid; hres = IOleObject_GetUserClassID(oleobj, &clsid); if(SUCCEEDED(hres)) TRACE("Got clsid %s\n", IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid)); hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This->doc_host)); if(FAILED(hres)) FIXME("SetClientSite failed: %08x\n", hres); IOleObject_Release(oleobj); }else { FIXME("Could not get IOleObject iface: %08x\n", hres); } /* FIXME: Call SetAdvise */ /* FIXME: Call Invoke(DISPID_READYSTATE) */ task = heap_alloc(sizeof(*task)); push_dochost_task(This->doc_host, task, object_available_proc, FALSE); return S_OK; }
static BindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYTE post_data, ULONG post_data_len, LPCWSTR headers) { BindStatusCallback *ret = heap_alloc(sizeof(BindStatusCallback)); ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl; ret->lpHttpNegotiateVtbl = &HttpNegotiateVtbl; ret->ref = 1; ret->url = heap_strdupW(url); ret->post_data = NULL; ret->post_data_len = post_data_len; ret->headers = headers ? SysAllocString(headers) : NULL; ret->doc_host = doc_host; IOleClientSite_AddRef(CLIENTSITE(doc_host)); if(post_data) { ret->post_data = GlobalAlloc(0, post_data_len); memcpy(ret->post_data, post_data, post_data_len); } return ret; }
static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv) { DocHost *This = OLECMD_THIS(iface); return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); }
static ULONG WINAPI ClServiceProvider_Release(IServiceProvider *iface) { DocHost *This = SERVPROV_THIS(iface); return IOleClientSite_Release(CLIENTSITE(This)); }
static HRESULT WINAPI ClServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv) { DocHost *This = SERVPROV_THIS(iface); return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); }
static ULONG WINAPI ClDispatch_Release(IDispatch *iface) { DocHost *This = DISP_THIS(iface); return IOleClientSite_Release(CLIENTSITE(This)); }
static HRESULT WINAPI ClDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv) { DocHost *This = DISP_THIS(iface); return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); }
static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface, REFIID riid, void **ppv) { DocHost *This = PROPNOTIF_THIS(iface); return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); }
static HRESULT WINAPI OleDocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv) { DocHost *This = DOCSITE_THIS(iface); return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); }
static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface) { DocHost *This = OLECMD_THIS(iface); return IOleClientSite_Release(CLIENTSITE(This)); }
static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv) { DocHost *This = DOCHOSTUI_THIS(iface); return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv); }
static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface) { DocHost *This = INPLACEFRAME_THIS(iface); return IOleClientSite_AddRef(CLIENTSITE(This)); }
static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface) { DocHost *This = PROPNOTIF_THIS(iface); return IOleClientSite_Release(CLIENTSITE(This)); }
static ULONG WINAPI OleDocumentSite_Release(IOleDocumentSite *iface) { DocHost *This = DOCSITE_THIS(iface); return IOleClientSite_Release(CLIENTSITE(This)); }
static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface) { DocHost *This = INPLACESITE_THIS(iface); return IOleClientSite_Release(CLIENTSITE(This)); }
static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface) { DocHost *This = DOCHOSTUI_THIS(iface); return IOleClientSite_Release(CLIENTSITE(This)); }