dmime: Implement band track IDirectMusicTrack_Play.
[wine.git] / dlls / ieframe / shellbrowser.c
blobe2c4c451741cd55c7757c321af5237b804367bec
1 /*
2 * Implementation of IShellBrowser interface
4 * Copyright 2011 Piotr Caban for CodeWeavers
5 * Copyright 2012 Jacek Caban for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <assert.h>
24 #include "ieframe.h"
25 #include "exdispid.h"
26 #include "shlwapi.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
32 const WCHAR *error_url_frag(const WCHAR *url)
34 if(!wcsncmp(url, L"res://", ARRAY_SIZE(L"res://")-1)) {
35 WCHAR buf[MAX_PATH];
36 UINT len = GetSystemDirectoryW(buf, ARRAY_SIZE(buf));
38 if(len && !wcsncmp(url + ARRAY_SIZE(L"res://")-1, buf, len)) {
39 len += ARRAY_SIZE(L"res://")-1;
40 if(!wcsncmp(url + len, L"\\shdoclc.dll/ERROR.HTM", ARRAY_SIZE(L"\\shdoclc.dll/ERROR.HTM")-1)) {
41 len += ARRAY_SIZE(L"\\shdoclc.dll/ERROR.HTM")-1;
42 url = wcschr(url + len, '#');
43 return url ? url + 1 : NULL;
47 return NULL;
50 static inline ShellBrowser *impl_from_IShellBrowser(IShellBrowser *iface)
52 return CONTAINING_RECORD(iface, ShellBrowser, IShellBrowser_iface);
55 static HRESULT WINAPI ShellBrowser_QueryInterface(IShellBrowser* iface, REFIID riid, void **ppv)
57 ShellBrowser *This = impl_from_IShellBrowser(iface);
59 if(IsEqualGUID(&IID_IUnknown, riid)) {
60 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
61 *ppv = &This->IShellBrowser_iface;
62 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
63 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
64 *ppv = &This->IShellBrowser_iface;
65 }else if(IsEqualGUID(&IID_IShellBrowser, riid)) {
66 TRACE("(%p)->(IID_IShellBrowser %p)\n", This, ppv);
67 *ppv = &This->IShellBrowser_iface;
68 }else if(IsEqualGUID(&IID_IBrowserService, riid)) {
69 TRACE("(%p)->(IID_IBrowserService %p)\n", This, ppv);
70 *ppv = &This->IBrowserService_iface;
71 }else if(IsEqualGUID(&IID_IDocObjectService, riid)) {
72 TRACE("(%p)->(IID_IDocObjectService %p)\n", This, ppv);
73 *ppv = &This->IDocObjectService_iface;
74 }else {
75 FIXME("%p %s %p\n", This, debugstr_guid(riid), ppv);
76 *ppv = NULL;
77 return E_NOINTERFACE;
80 IUnknown_AddRef((IUnknown*)*ppv);
81 return S_OK;
84 static ULONG WINAPI ShellBrowser_AddRef(
85 IShellBrowser* iface)
87 ShellBrowser *This = impl_from_IShellBrowser(iface);
88 LONG ref = InterlockedIncrement(&This->ref);
90 TRACE("(%p) ref=%ld\n", This, ref);
92 return ref;
95 static ULONG WINAPI ShellBrowser_Release(IShellBrowser* iface)
97 ShellBrowser *This = impl_from_IShellBrowser(iface);
98 LONG ref = InterlockedDecrement(&This->ref);
100 TRACE("(%p) ref=%ld\n", This, ref);
102 if(!ref) {
103 assert(!This->doc_host);
104 free(This);
107 return ref;
110 static HRESULT WINAPI ShellBrowser_GetWindow(
111 IShellBrowser* iface,
112 HWND *phwnd)
114 ShellBrowser *This = impl_from_IShellBrowser(iface);
115 FIXME("%p %p\n", This, phwnd);
116 return E_NOTIMPL;
119 static HRESULT WINAPI ShellBrowser_ContextSensitiveHelp(
120 IShellBrowser* iface,
121 BOOL fEnterMode)
123 ShellBrowser *This = impl_from_IShellBrowser(iface);
124 FIXME("%p %d\n", This, fEnterMode);
125 return E_NOTIMPL;
128 static HRESULT WINAPI ShellBrowser_InsertMenusSB(
129 IShellBrowser* iface,
130 HMENU hmenuShared,
131 LPOLEMENUGROUPWIDTHS lpMenuWidths)
133 ShellBrowser *This = impl_from_IShellBrowser(iface);
134 FIXME("%p %p %p\n", This, hmenuShared, lpMenuWidths);
135 return E_NOTIMPL;
138 static HRESULT WINAPI ShellBrowser_SetMenuSB(
139 IShellBrowser* iface,
140 HMENU hmenuShared,
141 HOLEMENU holemenuReserved,
142 HWND hwndActiveObject)
144 ShellBrowser *This = impl_from_IShellBrowser(iface);
145 FIXME("%p %p %p %p\n", This, hmenuShared, holemenuReserved, hwndActiveObject);
146 return E_NOTIMPL;
149 static HRESULT WINAPI ShellBrowser_RemoveMenusSB(
150 IShellBrowser* iface,
151 HMENU hmenuShared)
153 ShellBrowser *This = impl_from_IShellBrowser(iface);
154 FIXME("%p %p\n", This, hmenuShared);
155 return E_NOTIMPL;
158 static HRESULT WINAPI ShellBrowser_SetStatusTextSB(
159 IShellBrowser* iface,
160 LPCOLESTR pszStatusText)
162 ShellBrowser *This = impl_from_IShellBrowser(iface);
163 FIXME("%p %s\n", This, debugstr_w(pszStatusText));
164 return E_NOTIMPL;
167 static HRESULT WINAPI ShellBrowser_EnableModelessSB(
168 IShellBrowser* iface,
169 BOOL fEnable)
171 ShellBrowser *This = impl_from_IShellBrowser(iface);
172 FIXME("%p %d\n", This, fEnable);
173 return E_NOTIMPL;
176 static HRESULT WINAPI ShellBrowser_TranslateAcceleratorSB(
177 IShellBrowser* iface,
178 MSG *pmsg,
179 WORD wID)
181 ShellBrowser *This = impl_from_IShellBrowser(iface);
182 FIXME("%p %p %d\n", This, pmsg, (int)wID);
183 return E_NOTIMPL;
186 static HRESULT WINAPI ShellBrowser_BrowseObject(
187 IShellBrowser* iface,
188 LPCITEMIDLIST pidl,
189 UINT wFlags)
191 ShellBrowser *This = impl_from_IShellBrowser(iface);
192 FIXME("%p %p %u\n", This, pidl, wFlags);
193 return E_NOTIMPL;
196 static HRESULT WINAPI ShellBrowser_GetViewStateStream(
197 IShellBrowser* iface,
198 DWORD grfMode,
199 IStream **ppStrm)
201 ShellBrowser *This = impl_from_IShellBrowser(iface);
202 FIXME("%p %lx %p\n", This, grfMode, ppStrm);
203 return E_NOTIMPL;
206 static HRESULT WINAPI ShellBrowser_GetControlWindow(
207 IShellBrowser* iface,
208 UINT id,
209 HWND *phwnd)
211 ShellBrowser *This = impl_from_IShellBrowser(iface);
212 FIXME("%p %u %p\n", This, id, phwnd);
213 return E_NOTIMPL;
216 static HRESULT WINAPI ShellBrowser_SendControlMsg(
217 IShellBrowser* iface,
218 UINT id,
219 UINT uMsg,
220 WPARAM wParam,
221 LPARAM lParam,
222 LRESULT *pret)
224 ShellBrowser *This = impl_from_IShellBrowser(iface);
225 FIXME("%p %u %u %p\n", This, id, uMsg, pret);
226 return E_NOTIMPL;
229 static HRESULT WINAPI ShellBrowser_QueryActiveShellView(
230 IShellBrowser* iface,
231 IShellView **ppshv)
233 ShellBrowser *This = impl_from_IShellBrowser(iface);
234 FIXME("%p %p\n", This, ppshv);
235 return E_NOTIMPL;
238 static HRESULT WINAPI ShellBrowser_OnViewWindowActive(
239 IShellBrowser* iface,
240 IShellView *pshv)
242 ShellBrowser *This = impl_from_IShellBrowser(iface);
243 FIXME("%p %p\n", This, pshv);
244 return E_NOTIMPL;
247 static HRESULT WINAPI ShellBrowser_SetToolbarItems(
248 IShellBrowser* iface,
249 LPTBBUTTONSB lpButtons,
250 UINT nButtons,
251 UINT uFlags)
253 ShellBrowser *This = impl_from_IShellBrowser(iface);
254 FIXME("%p %p %u %u\n", This, lpButtons, nButtons, uFlags);
255 return E_NOTIMPL;
258 static const IShellBrowserVtbl ShellBrowserVtbl = {
259 ShellBrowser_QueryInterface,
260 ShellBrowser_AddRef,
261 ShellBrowser_Release,
262 ShellBrowser_GetWindow,
263 ShellBrowser_ContextSensitiveHelp,
264 ShellBrowser_InsertMenusSB,
265 ShellBrowser_SetMenuSB,
266 ShellBrowser_RemoveMenusSB,
267 ShellBrowser_SetStatusTextSB,
268 ShellBrowser_EnableModelessSB,
269 ShellBrowser_TranslateAcceleratorSB,
270 ShellBrowser_BrowseObject,
271 ShellBrowser_GetViewStateStream,
272 ShellBrowser_GetControlWindow,
273 ShellBrowser_SendControlMsg,
274 ShellBrowser_QueryActiveShellView,
275 ShellBrowser_OnViewWindowActive,
276 ShellBrowser_SetToolbarItems
279 static inline ShellBrowser *impl_from_IBrowserService(IBrowserService *iface)
281 return CONTAINING_RECORD(iface, ShellBrowser, IBrowserService_iface);
284 static HRESULT WINAPI BrowserService_QueryInterface(
285 IBrowserService* iface,
286 REFIID riid,
287 void **ppvObject)
289 ShellBrowser *This = impl_from_IBrowserService(iface);
290 return IShellBrowser_QueryInterface(&This->IShellBrowser_iface, riid, ppvObject);
293 static ULONG WINAPI BrowserService_AddRef(
294 IBrowserService *iface)
296 ShellBrowser *This = impl_from_IBrowserService(iface);
297 return IShellBrowser_AddRef(&This->IShellBrowser_iface);
300 static ULONG WINAPI BrowserService_Release(
301 IBrowserService* iface)
303 ShellBrowser *This = impl_from_IBrowserService(iface);
304 return IShellBrowser_Release(&This->IShellBrowser_iface);
307 static HRESULT WINAPI BrowserService_GetParentSite(
308 IBrowserService* iface,
309 IOleInPlaceSite **ppipsite)
311 ShellBrowser *This = impl_from_IBrowserService(iface);
312 FIXME("%p %p\n", This, ppipsite);
313 return E_NOTIMPL;
316 static HRESULT WINAPI BrowserService_SetTitle(
317 IBrowserService* iface,
318 IShellView *psv,
319 LPCWSTR pszName)
321 ShellBrowser *This = impl_from_IBrowserService(iface);
322 FIXME("%p %p %s\n", This, psv, debugstr_w(pszName));
323 return E_NOTIMPL;
326 static HRESULT WINAPI BrowserService_GetTitle(
327 IBrowserService* iface,
328 IShellView *psv,
329 LPWSTR pszName,
330 DWORD cchName)
332 ShellBrowser *This = impl_from_IBrowserService(iface);
333 FIXME("%p %p %p %ld\n", This, psv, pszName, cchName);
334 return E_NOTIMPL;
337 static HRESULT WINAPI BrowserService_GetOleObject(
338 IBrowserService* iface,
339 IOleObject **ppobjv)
341 ShellBrowser *This = impl_from_IBrowserService(iface);
342 FIXME("%p %p\n", This, ppobjv);
343 return E_NOTIMPL;
346 static HRESULT WINAPI BrowserService_GetTravelLog(
347 IBrowserService* iface,
348 ITravelLog **pptl)
350 ShellBrowser *This = impl_from_IBrowserService(iface);
351 FIXME("%p %p\n", This, pptl);
352 return E_NOTIMPL;
355 static HRESULT WINAPI BrowserService_ShowControlWindow(
356 IBrowserService* iface,
357 UINT id,
358 BOOL fShow)
360 ShellBrowser *This = impl_from_IBrowserService(iface);
361 FIXME("%p %u %d\n", This, id, fShow);
362 return E_NOTIMPL;
365 static HRESULT WINAPI BrowserService_IsControlWindowShown(
366 IBrowserService* iface,
367 UINT id,
368 BOOL *pfShown)
370 ShellBrowser *This = impl_from_IBrowserService(iface);
371 FIXME("%p %u %p\n", This, id, pfShown);
372 return E_NOTIMPL;
375 static HRESULT WINAPI BrowserService_IEGetDisplayName(
376 IBrowserService* iface,
377 PCIDLIST_ABSOLUTE pidl,
378 LPWSTR pwszName,
379 UINT uFlags)
381 ShellBrowser *This = impl_from_IBrowserService(iface);
382 FIXME("%p %p %p %u\n", This, pidl, pwszName, uFlags);
383 return E_NOTIMPL;
386 static HRESULT WINAPI BrowserService_IEParseDisplayName(
387 IBrowserService* iface,
388 UINT uiCP,
389 LPCWSTR pwszPath,
390 PIDLIST_ABSOLUTE *ppidlOut)
392 ShellBrowser *This = impl_from_IBrowserService(iface);
393 FIXME("%p %u %s %p\n", This, uiCP, debugstr_w(pwszPath), ppidlOut);
394 return E_NOTIMPL;
397 static HRESULT WINAPI BrowserService_DisplayParseError(
398 IBrowserService* iface,
399 HRESULT hres,
400 LPCWSTR pwszPath)
402 ShellBrowser *This = impl_from_IBrowserService(iface);
403 FIXME("%p %lx %s\n", This, hres, debugstr_w(pwszPath));
404 return E_NOTIMPL;
407 static HRESULT WINAPI BrowserService_NavigateToPidl(
408 IBrowserService* iface,
409 PCIDLIST_ABSOLUTE pidl,
410 DWORD grfHLNF)
412 ShellBrowser *This = impl_from_IBrowserService(iface);
413 FIXME("%p %p %ld\n", This, pidl, grfHLNF);
414 return E_NOTIMPL;
417 static HRESULT WINAPI BrowserService_SetNavigateState(
418 IBrowserService* iface,
419 BNSTATE bnstate)
421 ShellBrowser *This = impl_from_IBrowserService(iface);
422 FIXME("%p %d\n", This, bnstate);
423 return E_NOTIMPL;
426 static HRESULT WINAPI BrowserService_GetNavigateState(
427 IBrowserService* iface,
428 BNSTATE *pbnstate)
430 ShellBrowser *This = impl_from_IBrowserService(iface);
431 FIXME("%p %p\n", This, pbnstate);
432 return E_NOTIMPL;
435 static HRESULT WINAPI BrowserService_NotifyRedirect(
436 IBrowserService* iface,
437 IShellView *psv,
438 PCIDLIST_ABSOLUTE pidl,
439 BOOL *pfDidBrowse)
441 ShellBrowser *This = impl_from_IBrowserService(iface);
442 FIXME("%p %p %p %p\n", This, psv, pidl, pfDidBrowse);
443 return E_NOTIMPL;
446 static HRESULT WINAPI BrowserService_UpdateWindowList(
447 IBrowserService* iface)
449 ShellBrowser *This = impl_from_IBrowserService(iface);
450 FIXME("%p\n", This);
451 return E_NOTIMPL;
454 static HRESULT WINAPI BrowserService_UpdateBackForwardState(
455 IBrowserService* iface)
457 ShellBrowser *This = impl_from_IBrowserService(iface);
458 FIXME("%p\n", This);
459 return E_NOTIMPL;
462 static HRESULT WINAPI BrowserService_SetFlags(
463 IBrowserService* iface,
464 DWORD dwFlags,
465 DWORD dwFlagMask)
467 ShellBrowser *This = impl_from_IBrowserService(iface);
468 FIXME("%p %lx %lx\n", This, dwFlags, dwFlagMask);
469 return E_NOTIMPL;
472 static HRESULT WINAPI BrowserService_GetFlags(
473 IBrowserService* iface,
474 DWORD *pdwFlags)
476 ShellBrowser *This = impl_from_IBrowserService(iface);
477 FIXME("%p %p\n", This, pdwFlags);
478 return E_NOTIMPL;
481 static HRESULT WINAPI BrowserService_CanNavigateNow(
482 IBrowserService* iface)
484 ShellBrowser *This = impl_from_IBrowserService(iface);
485 FIXME("%p\n", This);
486 return E_NOTIMPL;
489 static HRESULT WINAPI BrowserService_GetPidl(
490 IBrowserService* iface,
491 PIDLIST_ABSOLUTE *ppidl)
493 ShellBrowser *This = impl_from_IBrowserService(iface);
494 FIXME("%p %p\n", This, ppidl);
495 return E_NOTIMPL;
498 static HRESULT WINAPI BrowserService_SetReferrer(
499 IBrowserService* iface,
500 PCIDLIST_ABSOLUTE pidl)
502 ShellBrowser *This = impl_from_IBrowserService(iface);
503 FIXME("%p %p\n", This, pidl);
504 return E_NOTIMPL;
507 static DWORD WINAPI BrowserService_GetBrowserIndex(
508 IBrowserService* iface)
510 ShellBrowser *This = impl_from_IBrowserService(iface);
511 FIXME("%p\n", This);
512 return E_NOTIMPL;
515 static HRESULT WINAPI BrowserService_GetBrowserByIndex(
516 IBrowserService* iface,
517 DWORD dwID,
518 IUnknown **ppunk)
520 ShellBrowser *This = impl_from_IBrowserService(iface);
521 FIXME("%p %lx %p\n", This, dwID, ppunk);
522 return E_NOTIMPL;
525 static HRESULT WINAPI BrowserService_GetHistoryObject(
526 IBrowserService* iface,
527 IOleObject **ppole,
528 IStream **pstm,
529 IBindCtx **ppbc)
531 ShellBrowser *This = impl_from_IBrowserService(iface);
532 FIXME("%p %p %p %p\n", This, ppole, pstm, ppbc);
533 return E_NOTIMPL;
536 static HRESULT WINAPI BrowserService_SetHistoryObject(
537 IBrowserService* iface,
538 IOleObject *pole,
539 BOOL fIsLocalAnchor)
541 ShellBrowser *This = impl_from_IBrowserService(iface);
542 FIXME("%p %p %d\n", This, pole, fIsLocalAnchor);
543 return E_NOTIMPL;
546 static HRESULT WINAPI BrowserService_CacheOLEServer(
547 IBrowserService* iface,
548 IOleObject *pole)
550 ShellBrowser *This = impl_from_IBrowserService(iface);
551 FIXME("%p %p\n", This, pole);
552 return E_NOTIMPL;
555 static HRESULT WINAPI BrowserService_GetSetCodePage(
556 IBrowserService* iface,
557 VARIANT *pvarIn,
558 VARIANT *pvarOut)
560 ShellBrowser *This = impl_from_IBrowserService(iface);
561 FIXME("%p %s %p\n", This, debugstr_variant(pvarIn), pvarOut);
562 return E_NOTIMPL;
565 static HRESULT WINAPI BrowserService_OnHttpEquiv(
566 IBrowserService* iface,
567 IShellView *psv,
568 BOOL fDone,
569 VARIANT *pvarargIn,
570 VARIANT *pvarargOut)
572 ShellBrowser *This = impl_from_IBrowserService(iface);
573 FIXME("%p %p %d %s %p\n", This, psv, fDone, debugstr_variant(pvarargIn), pvarargOut);
574 return E_NOTIMPL;
577 static HRESULT WINAPI BrowserService_GetPalette(
578 IBrowserService* iface,
579 HPALETTE *hpal)
581 ShellBrowser *This = impl_from_IBrowserService(iface);
582 FIXME("%p %p\n", This, hpal);
583 return E_NOTIMPL;
586 static HRESULT WINAPI BrowserService_RegisterWindow(
587 IBrowserService* iface,
588 BOOL fForceRegister,
589 int swc)
591 ShellBrowser *This = impl_from_IBrowserService(iface);
592 FIXME("%p %d %d\n", This, fForceRegister, swc);
593 return E_NOTIMPL;
596 static const IBrowserServiceVtbl BrowserServiceVtbl = {
597 BrowserService_QueryInterface,
598 BrowserService_AddRef,
599 BrowserService_Release,
600 BrowserService_GetParentSite,
601 BrowserService_SetTitle,
602 BrowserService_GetTitle,
603 BrowserService_GetOleObject,
604 BrowserService_GetTravelLog,
605 BrowserService_ShowControlWindow,
606 BrowserService_IsControlWindowShown,
607 BrowserService_IEGetDisplayName,
608 BrowserService_IEParseDisplayName,
609 BrowserService_DisplayParseError,
610 BrowserService_NavigateToPidl,
611 BrowserService_SetNavigateState,
612 BrowserService_GetNavigateState,
613 BrowserService_NotifyRedirect,
614 BrowserService_UpdateWindowList,
615 BrowserService_UpdateBackForwardState,
616 BrowserService_SetFlags,
617 BrowserService_GetFlags,
618 BrowserService_CanNavigateNow,
619 BrowserService_GetPidl,
620 BrowserService_SetReferrer,
621 BrowserService_GetBrowserIndex,
622 BrowserService_GetBrowserByIndex,
623 BrowserService_GetHistoryObject,
624 BrowserService_SetHistoryObject,
625 BrowserService_CacheOLEServer,
626 BrowserService_GetSetCodePage,
627 BrowserService_OnHttpEquiv,
628 BrowserService_GetPalette,
629 BrowserService_RegisterWindow
632 static inline ShellBrowser *impl_from_IDocObjectService(IDocObjectService *iface)
634 return CONTAINING_RECORD(iface, ShellBrowser, IDocObjectService_iface);
637 static HRESULT WINAPI DocObjectService_QueryInterface(
638 IDocObjectService* iface,
639 REFIID riid,
640 void **ppvObject)
642 ShellBrowser *This = impl_from_IDocObjectService(iface);
643 return IShellBrowser_QueryInterface(&This->IShellBrowser_iface, riid, ppvObject);
646 static ULONG WINAPI DocObjectService_AddRef(
647 IDocObjectService* iface)
649 ShellBrowser *This = impl_from_IDocObjectService(iface);
650 return IShellBrowser_AddRef(&This->IShellBrowser_iface);
653 static ULONG WINAPI DocObjectService_Release(
654 IDocObjectService* iface)
656 ShellBrowser *This = impl_from_IDocObjectService(iface);
657 return IShellBrowser_Release(&This->IShellBrowser_iface);
660 static HRESULT WINAPI DocObjectService_FireBeforeNavigate2(
661 IDocObjectService* iface,
662 IDispatch *pDispatch,
663 LPCWSTR lpszUrl,
664 DWORD dwFlags,
665 LPCWSTR lpszFrameName,
666 BYTE *pPostData,
667 DWORD cbPostData,
668 LPCWSTR lpszHeaders,
669 BOOL fPlayNavSound,
670 BOOL *pfCancel)
672 ShellBrowser *This = impl_from_IDocObjectService(iface);
673 VARIANT var_url, var_flags, var_frame_name, var_post_data, var_post_data2, var_headers;
674 VARIANTARG params[7];
675 DISPPARAMS dp = {params, NULL, 7, 0};
676 VARIANT_BOOL cancel = VARIANT_FALSE;
677 SAFEARRAY *post_data;
678 WCHAR file_path[MAX_PATH];
679 DWORD file_path_len = ARRAY_SIZE(file_path);
681 TRACE("%p %p %s %lx %s %p %ld %s %d %p\n", This, pDispatch, debugstr_w(lpszUrl),
682 dwFlags, debugstr_w(lpszFrameName), pPostData, cbPostData,
683 debugstr_w(lpszHeaders), fPlayNavSound, pfCancel);
685 if(cbPostData) {
686 post_data = SafeArrayCreateVector(VT_UI1, 0, cbPostData);
687 if(!post_data)
688 return E_OUTOFMEMORY;
689 memcpy(post_data->pvData, pPostData, cbPostData);
690 }else {
691 post_data = NULL;
694 V_VT(params) = VT_BOOL|VT_BYREF;
695 V_BOOLREF(params) = &cancel;
697 V_VT(params+1) = (VT_BYREF|VT_VARIANT);
698 V_VARIANTREF(params+1) = &var_headers;
699 V_VT(&var_headers) = VT_BSTR;
700 V_BSTR(&var_headers) = lpszHeaders ? SysAllocString(lpszHeaders) : NULL;
702 V_VT(params+2) = (VT_BYREF|VT_VARIANT);
703 V_VARIANTREF(params+2) = &var_post_data2;
704 V_VT(&var_post_data2) = (VT_BYREF|VT_VARIANT);
705 V_VARIANTREF(&var_post_data2) = &var_post_data;
707 if(post_data) {
708 V_VT(&var_post_data) = VT_UI1|VT_ARRAY;
709 V_ARRAY(&var_post_data) = post_data;
710 }else {
711 V_VT(&var_post_data) = VT_EMPTY;
714 V_VT(params+3) = (VT_BYREF|VT_VARIANT);
715 V_VARIANTREF(params+3) = &var_frame_name;
716 V_VT(&var_frame_name) = VT_BSTR;
717 V_BSTR(&var_frame_name) = lpszFrameName ? SysAllocString(lpszFrameName) : NULL;
719 V_VT(params+4) = (VT_BYREF|VT_VARIANT);
720 V_VARIANTREF(params+4) = &var_flags;
721 V_VT(&var_flags) = VT_I4;
722 V_I4(&var_flags) = 0;
724 V_VT(params+5) = (VT_BYREF|VT_VARIANT);
725 V_VARIANTREF(params+5) = &var_url;
726 V_VT(&var_url) = VT_BSTR;
727 if(PathCreateFromUrlW(lpszUrl, file_path, &file_path_len, 0) == S_OK)
728 V_BSTR(&var_url) = SysAllocString(file_path);
729 else
730 V_BSTR(&var_url) = SysAllocString(lpszUrl);
732 V_VT(params+6) = (VT_DISPATCH);
733 V_DISPATCH(params+6) = (IDispatch*)This->doc_host->wb;
735 /* Keep reference to This. It may be released in event handler. */
736 IShellBrowser_AddRef(&This->IShellBrowser_iface);
738 TRACE(">>>\n");
739 call_sink(This->doc_host->cps.wbe2, DISPID_BEFORENAVIGATE2, &dp);
740 TRACE("<<<\n");
742 IShellBrowser_Release(&This->IShellBrowser_iface);
744 SysFreeString(V_BSTR(&var_url));
745 SysFreeString(V_BSTR(&var_headers));
746 SysFreeString(V_BSTR(&var_frame_name));
747 SafeArrayDestroy(post_data);
749 *pfCancel = !!cancel;
750 return S_OK;
753 static HRESULT WINAPI DocObjectService_FireNavigateComplete2(
754 IDocObjectService* iface,
755 IHTMLWindow2 *pHTMLWindow2,
756 DWORD dwFlags)
758 ShellBrowser *This = impl_from_IDocObjectService(iface);
759 DocHost *doc_host = This->doc_host;
760 IHTMLPrivateWindow *priv_window;
761 const WCHAR *orig_url;
762 VARIANTARG params[2];
763 DISPPARAMS dp = {params, NULL, 2, 0};
764 VARIANT url_var;
765 BSTR url;
766 HRESULT hres;
768 TRACE("%p %p %lx\n", This, pHTMLWindow2, dwFlags);
770 update_navigation_commands(This->doc_host);
772 if(doc_host->travellog.loading_pos != -1) {
773 WARN("histupdate not notified\n");
774 doc_host->travellog.position = doc_host->travellog.loading_pos;
775 doc_host->travellog.loading_pos = -1;
778 hres = IHTMLWindow2_QueryInterface(pHTMLWindow2, &IID_IHTMLPrivateWindow, (void**)&priv_window);
779 if(FAILED(hres))
780 return hres;
782 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &url);
783 IHTMLPrivateWindow_Release(priv_window);
784 if(FAILED(hres))
785 return hres;
787 TRACE("got URL %s\n", debugstr_w(url));
788 set_dochost_url(This->doc_host, url);
790 orig_url = error_url_frag(url);
791 if(orig_url) {
792 BSTR tmp = SysAllocString(orig_url);
793 SysFreeString(url);
794 url = tmp;
797 V_VT(params) = (VT_BYREF|VT_VARIANT);
798 V_VARIANTREF(params) = &url_var;
800 V_VT(params+1) = VT_DISPATCH;
801 V_DISPATCH(params+1) = (IDispatch*)doc_host->wb;
803 V_VT(&url_var) = VT_BSTR;
804 V_BSTR(&url_var) = url;
806 /* Keep reference to This. It may be released in event handler. */
807 IShellBrowser_AddRef(&This->IShellBrowser_iface);
809 TRACE(">>>\n");
810 call_sink(This->doc_host->cps.wbe2, DISPID_NAVIGATECOMPLETE2, &dp);
811 TRACE("<<<\n");
813 SysFreeString(url);
815 IShellBrowser_Release(&This->IShellBrowser_iface);
816 return S_OK;
819 static HRESULT WINAPI DocObjectService_FireDownloadBegin(
820 IDocObjectService* iface)
822 ShellBrowser *This = impl_from_IDocObjectService(iface);
823 FIXME("%p\n", This);
824 return E_NOTIMPL;
827 static HRESULT WINAPI DocObjectService_FireDownloadComplete(
828 IDocObjectService* iface)
830 ShellBrowser *This = impl_from_IDocObjectService(iface);
831 FIXME("%p\n", This);
832 return E_NOTIMPL;
835 static HRESULT WINAPI DocObjectService_FireDocumentComplete(
836 IDocObjectService* iface,
837 IHTMLWindow2 *pHTMLWindow,
838 DWORD dwFlags)
840 ShellBrowser *This = impl_from_IDocObjectService(iface);
841 IHTMLPrivateWindow *priv_window;
842 const WCHAR *orig_url;
843 VARIANTARG params[2];
844 DISPPARAMS dp = {params, NULL, 2, 0};
845 VARIANT url_var;
846 BSTR url;
847 HRESULT hres;
849 TRACE("%p %p %lx\n", This, pHTMLWindow, dwFlags);
851 hres = IHTMLWindow2_QueryInterface(pHTMLWindow, &IID_IHTMLPrivateWindow, (void**)&priv_window);
852 if(FAILED(hres))
853 return hres;
855 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &url);
856 IHTMLPrivateWindow_Release(priv_window);
857 if(FAILED(hres))
858 return hres;
860 TRACE("got URL %s\n", debugstr_w(url));
862 orig_url = error_url_frag(url);
863 if(orig_url) {
864 BSTR tmp = SysAllocString(orig_url);
865 SysFreeString(url);
866 url = tmp;
869 V_VT(params) = (VT_BYREF|VT_VARIANT);
870 V_VARIANTREF(params) = &url_var;
872 V_VT(params+1) = VT_DISPATCH;
873 V_DISPATCH(params+1) = (IDispatch*)This->doc_host->wb;
875 V_VT(&url_var) = VT_BSTR;
876 V_BSTR(&url_var) = url;
878 /* Keep reference to This. It may be released in event handler. */
879 IShellBrowser_AddRef(&This->IShellBrowser_iface);
881 TRACE(">>>\n");
882 call_sink(This->doc_host->cps.wbe2, DISPID_DOCUMENTCOMPLETE, &dp);
883 TRACE("<<<\n");
885 SysFreeString(url);
887 IShellBrowser_Release(&This->IShellBrowser_iface);
888 return S_OK;
891 static HRESULT WINAPI DocObjectService_UpdateDesktopComponent(
892 IDocObjectService* iface,
893 IHTMLWindow2 *pHTMLWindow)
895 ShellBrowser *This = impl_from_IDocObjectService(iface);
896 FIXME("%p %p\n", This, pHTMLWindow);
897 return E_NOTIMPL;
900 static HRESULT WINAPI DocObjectService_GetPendingUrl(
901 IDocObjectService* iface,
902 BSTR *pbstrPendingUrl)
904 ShellBrowser *This = impl_from_IDocObjectService(iface);
905 FIXME("%p %p\n", This, pbstrPendingUrl);
906 return E_NOTIMPL;
909 static HRESULT WINAPI DocObjectService_ActiveElementChanged(
910 IDocObjectService* iface,
911 IHTMLElement *pHTMLElement)
913 ShellBrowser *This = impl_from_IDocObjectService(iface);
914 FIXME("%p %p\n", This, pHTMLElement);
915 return E_NOTIMPL;
918 static HRESULT WINAPI DocObjectService_GetUrlSearchComponent(
919 IDocObjectService* iface,
920 BSTR *pbstrSearch)
922 ShellBrowser *This = impl_from_IDocObjectService(iface);
923 FIXME("%p %p\n", This, pbstrSearch);
924 return E_NOTIMPL;
927 static HRESULT WINAPI DocObjectService_IsErrorUrl(
928 IDocObjectService* iface,
929 LPCWSTR lpszUrl,
930 BOOL *pfIsError)
932 ShellBrowser *This = impl_from_IDocObjectService(iface);
934 TRACE("(%p)->(%s %p)\n", This, debugstr_w(lpszUrl), pfIsError);
936 *pfIsError = !!error_url_frag(lpszUrl);
937 return S_OK;
940 static const IDocObjectServiceVtbl DocObjectServiceVtbl = {
941 DocObjectService_QueryInterface,
942 DocObjectService_AddRef,
943 DocObjectService_Release,
944 DocObjectService_FireBeforeNavigate2,
945 DocObjectService_FireNavigateComplete2,
946 DocObjectService_FireDownloadBegin,
947 DocObjectService_FireDownloadComplete,
948 DocObjectService_FireDocumentComplete,
949 DocObjectService_UpdateDesktopComponent,
950 DocObjectService_GetPendingUrl,
951 DocObjectService_ActiveElementChanged,
952 DocObjectService_GetUrlSearchComponent,
953 DocObjectService_IsErrorUrl
956 HRESULT create_browser_service(DocHost *doc_host, ShellBrowser **ret)
958 ShellBrowser *sb;
960 sb = malloc(sizeof(ShellBrowser));
961 if(!sb)
962 return E_OUTOFMEMORY;
964 sb->IShellBrowser_iface.lpVtbl = &ShellBrowserVtbl;
965 sb->IBrowserService_iface.lpVtbl = &BrowserServiceVtbl;
966 sb->IDocObjectService_iface.lpVtbl = &DocObjectServiceVtbl;
968 sb->ref = 1;
969 sb->doc_host = doc_host;
971 *ret = sb;
972 return S_OK;
975 void detach_browser_service(ShellBrowser *sb)
977 sb->doc_host = NULL;
978 IShellBrowser_Release(&sb->IShellBrowser_iface);
981 static inline NewWindowManager *impl_from_INewWindowManager(INewWindowManager *iface)
983 return CONTAINING_RECORD(iface, NewWindowManager, INewWindowManager_iface);
986 static HRESULT WINAPI NewWindowManager_QueryInterface(INewWindowManager *iface, REFIID riid, void **ppv)
988 NewWindowManager *This = impl_from_INewWindowManager(iface);
990 if(IsEqualGUID(&IID_IUnknown, riid)) {
991 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
992 *ppv = &This->INewWindowManager_iface;
993 }else if(IsEqualGUID(&IID_INewWindowManager, riid)) {
994 TRACE("(%p)->(IID_INewWindowManager %p)\n", This, ppv);
995 *ppv = &This->INewWindowManager_iface;
996 }else {
997 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
998 *ppv = NULL;
999 return E_NOINTERFACE;
1002 IUnknown_AddRef((IUnknown*)*ppv);
1003 return S_OK;
1006 static ULONG WINAPI NewWindowManager_AddRef(INewWindowManager *iface)
1008 NewWindowManager *This = impl_from_INewWindowManager(iface);
1010 TRACE("(%p)\n", This);
1012 return IOleClientSite_AddRef(&This->doc_host->IOleClientSite_iface);
1015 static ULONG WINAPI NewWindowManager_Release(INewWindowManager *iface)
1017 NewWindowManager *This = impl_from_INewWindowManager(iface);
1019 TRACE("(%p)\n", This);
1021 return IOleClientSite_Release(&This->doc_host->IOleClientSite_iface);
1024 static HRESULT WINAPI NewWindowManager_EvaluateNewWindow(INewWindowManager *iface, LPCWSTR pszUrl,
1025 LPCWSTR pszName, LPCWSTR pszUrlContext, LPCWSTR pszFeatures, BOOL fReplace, DWORD dwFlags,
1026 DWORD dwUserActionTime)
1028 NewWindowManager *This = impl_from_INewWindowManager(iface);
1029 FIXME("(%p)->(%s %s %s %s %x %lx %ld)\n", This, debugstr_w(pszUrl), debugstr_w(pszName), debugstr_w(pszUrlContext),
1030 debugstr_w(pszFeatures), fReplace, dwFlags, dwUserActionTime);
1031 return S_OK;
1034 static const INewWindowManagerVtbl NewWindowManagerVtbl = {
1035 NewWindowManager_QueryInterface,
1036 NewWindowManager_AddRef,
1037 NewWindowManager_Release,
1038 NewWindowManager_EvaluateNewWindow
1041 void NewWindowManager_Init(DocHost *doc_host)
1043 doc_host->nwm.INewWindowManager_iface.lpVtbl = &NewWindowManagerVtbl;
1044 doc_host->nwm.doc_host = doc_host;