2 * Copyright 2005 Jacek Caban
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 struct BindStatusCallback {
42 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
50 #define STATUSCLB_THIS(iface) DEFINE_THIS(BindStatusCallback, BindStatusCallback, iface)
52 static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
53 REFIID riid, void **ppv)
55 BindStatusCallback *This = STATUSCLB_THIS(iface);
58 if(IsEqualGUID(&IID_IUnknown, riid)) {
59 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
60 *ppv = STATUSCLB(This);
61 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
62 TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
63 *ppv = STATUSCLB(This);
67 IBindStatusCallback_AddRef(STATUSCLB(This));
71 TRACE("Unsupported riid = %s\n", debugstr_guid(riid));
75 static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
77 BindStatusCallback *This = STATUSCLB_THIS(iface);
78 LONG ref = InterlockedIncrement(&This->ref);
80 TRACE("(%p) ref = %ld\n", This, ref);
85 static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
87 BindStatusCallback *This = STATUSCLB_THIS(iface);
88 LONG ref = InterlockedDecrement(&This->ref);
90 TRACE("(%p) ref = %ld\n", This, ref);
93 if(This->doc->status_callback == This)
94 This->doc->status_callback = NULL;
95 IHTMLDocument2_Release(HTMLDOC(This->doc));
96 HeapFree(GetProcessHeap(), 0, This);
102 static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface,
103 DWORD dwReserved, IBinding *pbind)
105 BindStatusCallback *This = STATUSCLB_THIS(iface);
107 TRACE("(%p)->(%ld %p)\n", This, dwReserved, pbind);
109 This->binding = pbind;
110 IBinding_AddRef(pbind);
115 static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
117 BindStatusCallback *This = STATUSCLB_THIS(iface);
118 FIXME("(%p)->(%p)\n", This, pnPriority);
122 static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
124 BindStatusCallback *This = STATUSCLB_THIS(iface);
125 FIXME("(%p)->(%ld)\n", This, reserved);
129 static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
130 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
132 BindStatusCallback *This = STATUSCLB_THIS(iface);
133 TRACE("%p)->(%lu %lu %lu %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
134 debugstr_w(szStatusText));
138 static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface,
139 HRESULT hresult, LPCWSTR szError)
141 BindStatusCallback *This = STATUSCLB_THIS(iface);
143 TRACE("(%p)->(%08lx %s)\n", This, hresult, debugstr_w(szError));
145 IBinding_Release(This->binding);
146 This->binding = NULL;
150 static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface,
151 DWORD *grfBINDF, BINDINFO *pbindinfo)
153 BindStatusCallback *This = STATUSCLB_THIS(iface);
156 TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
158 *grfBINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
159 size = pbindinfo->cbSize;
160 memset(pbindinfo, 0, size);
161 pbindinfo->cbSize = size;
166 static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
167 DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
169 BindStatusCallback *This = STATUSCLB_THIS(iface);
170 TRACE("(%p)->(%08lx %ld %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
174 static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface,
175 REFIID riid, IUnknown *punk)
177 BindStatusCallback *This = STATUSCLB_THIS(iface);
178 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
182 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
183 BindStatusCallback_QueryInterface,
184 BindStatusCallback_AddRef,
185 BindStatusCallback_Release,
186 BindStatusCallback_OnStartBinding,
187 BindStatusCallback_GetPriority,
188 BindStatusCallback_OnLowResource,
189 BindStatusCallback_OnProgress,
190 BindStatusCallback_OnStopBinding,
191 BindStatusCallback_GetBindInfo,
192 BindStatusCallback_OnDataAvailable,
193 BindStatusCallback_OnObjectAvailable
196 static BindStatusCallback *BindStatusCallback_Create(HTMLDocument *doc)
198 BindStatusCallback *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(BindStatusCallback));
199 ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
202 IHTMLDocument2_AddRef(HTMLDOC(doc));
206 /**********************************************************
207 * IPersistMoniker implementation
210 #define PERSISTMON_THIS(iface) DEFINE_THIS(HTMLDocument, PersistMoniker, iface)
212 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid,
215 HTMLDocument *This = PERSISTMON_THIS(iface);
216 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
219 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
221 HTMLDocument *This = PERSISTMON_THIS(iface);
222 return IHTMLDocument2_AddRef(HTMLDOC(This));
225 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
227 HTMLDocument *This = PERSISTMON_THIS(iface);
228 return IHTMLDocument2_Release(HTMLDOC(This));
231 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
233 HTMLDocument *This = PERSISTMON_THIS(iface);
234 return IPersist_GetClassID(PERSIST(This), pClassID);
237 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
239 HTMLDocument *This = PERSISTMON_THIS(iface);
240 FIXME("(%p)\n", This);
244 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
245 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
247 HTMLDocument *This = PERSISTMON_THIS(iface);
249 BindStatusCallback *callback;
255 FIXME("(%p)->(%x %p %p %08lx)\n", This, fFullyAvailable, pimkName, pibc, grfMode);
258 * This is a HACK, we should use moniker's BindToStorage instead of Gecko's LoadURI.
260 if(This->nscontainer) {
261 hres = IMoniker_GetDisplayName(pimkName, pibc, NULL, &url);
263 WARN("GetDiaplayName failed: %08lx\n", hres);
266 TRACE("got url: %s\n", debugstr_w(url));
268 nsres = nsIWebNavigation_LoadURI(This->nscontainer->navigation, url,
269 LOAD_FLAGS_NONE, NULL, NULL, NULL);
270 if(NS_SUCCEEDED(nsres))
273 WARN("LoadURI failed: %08lx\n", nsres);
276 /* FIXME: Use grfMode */
279 FIXME("not supported fFullyAvailable\n");
281 FIXME("not supported pibc\n");
283 if(This->status_callback && This->status_callback->binding)
284 IBinding_Abort(This->status_callback->binding);
286 callback = This->status_callback = BindStatusCallback_Create(This);
288 CreateAsyncBindCtx(0, STATUSCLB(callback), NULL, &pbind);
290 hres = IMoniker_BindToStorage(pimkName, pbind, NULL, &IID_IStream, (void**)&str);
292 IStream_Release(str);
294 WARN("BindToStorage failed: %08lx\n", hres);
301 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName,
302 LPBC pbc, BOOL fRemember)
304 HTMLDocument *This = PERSISTMON_THIS(iface);
305 FIXME("(%p)->(%p %p %x)\n", This, pimkName, pbc, fRemember);
309 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
311 HTMLDocument *This = PERSISTMON_THIS(iface);
312 FIXME("(%p)->(%p %p)\n", This, pimkName, pibc);
316 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **ppimkName)
318 HTMLDocument *This = PERSISTMON_THIS(iface);
319 FIXME("(%p)->(%p)\n", This, ppimkName);
323 static const IPersistMonikerVtbl PersistMonikerVtbl = {
324 PersistMoniker_QueryInterface,
325 PersistMoniker_AddRef,
326 PersistMoniker_Release,
327 PersistMoniker_GetClassID,
328 PersistMoniker_IsDirty,
331 PersistMoniker_SaveCompleted,
332 PersistMoniker_GetCurMoniker
335 /**********************************************************
336 * IMonikerProp implementation
339 #define MONPROP_THIS(iface) DEFINE_THIS(HTMLDocument, MonikerProp, iface)
341 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppvObject)
343 HTMLDocument *This = MONPROP_THIS(iface);
344 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
347 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
349 HTMLDocument *This = MONPROP_THIS(iface);
350 return IHTMLDocument2_AddRef(HTMLDOC(This));
353 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
355 HTMLDocument *This = MONPROP_THIS(iface);
356 return IHTMLDocument_Release(HTMLDOC(This));
359 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
361 HTMLDocument *This = MONPROP_THIS(iface);
362 FIXME("(%p)->(%d %s)\n", This, mkp, debugstr_w(val));
366 static const IMonikerPropVtbl MonikerPropVtbl = {
367 MonikerProp_QueryInterface,
370 MonikerProp_PutProperty
373 /**********************************************************
374 * IPersistFile implementation
377 #define PERSISTFILE_THIS(iface) DEFINE_THIS(HTMLDocument, PersistFile, iface)
379 static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *iface, REFIID riid, void **ppvObject)
381 HTMLDocument *This = PERSISTFILE_THIS(iface);
382 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
385 static ULONG WINAPI PersistFile_AddRef(IPersistFile *iface)
387 HTMLDocument *This = PERSISTFILE_THIS(iface);
388 return IHTMLDocument2_AddRef(HTMLDOC(This));
391 static ULONG WINAPI PersistFile_Release(IPersistFile *iface)
393 HTMLDocument *This = PERSISTFILE_THIS(iface);
394 return IHTMLDocument2_Release(HTMLDOC(This));
397 static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *iface, CLSID *pClassID)
399 HTMLDocument *This = PERSISTFILE_THIS(iface);
401 TRACE("(%p)->(%p)\n", This, pClassID);
406 memcpy(pClassID, &CLSID_HTMLDocument, sizeof(CLSID));
410 static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *iface)
412 HTMLDocument *This = PERSISTFILE_THIS(iface);
413 FIXME("(%p)\n", This);
417 static HRESULT WINAPI PersistFile_Load(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
419 HTMLDocument *This = PERSISTFILE_THIS(iface);
420 FIXME("(%p)->(%s %08lx)\n", This, debugstr_w(pszFileName), dwMode);
424 static HRESULT WINAPI PersistFile_Save(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
426 HTMLDocument *This = PERSISTFILE_THIS(iface);
427 FIXME("(%p)->(%s %x)\n", This, debugstr_w(pszFileName), fRemember);
431 static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
433 HTMLDocument *This = PERSISTFILE_THIS(iface);
434 FIXME("(%p)->(%s)\n", This, debugstr_w(pszFileName));
438 static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *iface, LPOLESTR *pszFileName)
440 HTMLDocument *This = PERSISTFILE_THIS(iface);
441 FIXME("(%p)->(%p)\n", This, pszFileName);
445 static const IPersistFileVtbl PersistFileVtbl = {
446 PersistFile_QueryInterface,
449 PersistFile_GetClassID,
453 PersistFile_SaveCompleted,
454 PersistFile_GetCurFile
457 void HTMLDocument_Persist_Init(HTMLDocument *This)
459 This->lpPersistMonikerVtbl = &PersistMonikerVtbl;
460 This->lpPersistFileVtbl = &PersistFileVtbl;
461 This->lpMonikerPropVtbl = &MonikerPropVtbl;
463 This->status_callback = NULL;