2 * IShellDispatch implementation
4 * Copyright 2010 Alexander Morozov for Etersoft
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(shell);
43 IShellDispatch IShellDispatch_iface;
55 static inline ShellDispatch *impl_from_IShellDispatch(IShellDispatch *iface)
57 return CONTAINING_RECORD(iface, ShellDispatch, IShellDispatch_iface);
60 static inline FolderImpl *impl_from_Folder(Folder3 *iface)
62 return CONTAINING_RECORD(iface, FolderImpl, Folder_iface);
65 static HRESULT load_type_info(REFGUID guid, ITypeInfo **pptinfo)
70 ret = LoadRegTypeLib(&LIBID_Shell32, 1, 0, LOCALE_SYSTEM_DEFAULT, &typelib);
73 ERR("LoadRegTypeLib failed: %08x\n", ret);
77 ret = ITypeLib_GetTypeInfoOfGuid(typelib, guid, pptinfo);
78 ITypeLib_Release(typelib);
80 ERR("failed to load ITypeInfo\n");
85 static HRESULT WINAPI FolderImpl_QueryInterface(Folder3 *iface, REFIID riid,
88 FolderImpl *This = impl_from_Folder(iface);
90 TRACE("(%p,%p,%p)\n", iface, riid, ppv);
92 if (!ppv) return E_INVALIDARG;
94 if (IsEqualIID(&IID_IUnknown, riid) ||
95 IsEqualIID(&IID_IDispatch, riid) ||
96 IsEqualIID(&IID_Folder, riid) ||
97 IsEqualIID(&IID_Folder2, riid) ||
98 IsEqualIID(&IID_Folder3, riid))
102 FIXME("not implemented for %s\n", shdebugstr_guid(riid));
104 return E_NOINTERFACE;
106 IUnknown_AddRef((IUnknown*)*ppv);
110 static ULONG WINAPI FolderImpl_AddRef(Folder3 *iface)
112 FolderImpl *This = impl_from_Folder(iface);
113 ULONG ref = InterlockedIncrement(&This->ref);
115 TRACE("(%p), new refcount=%i\n", iface, ref);
120 static ULONG WINAPI FolderImpl_Release(Folder3 *iface)
122 FolderImpl *This = impl_from_Folder(iface);
123 ULONG ref = InterlockedDecrement(&This->ref);
125 TRACE("(%p), new refcount=%i\n", iface, ref);
129 VariantClear(&This->dir);
130 ITypeInfo_Release(This->iTypeInfo);
131 HeapFree(GetProcessHeap(), 0, This);
136 static HRESULT WINAPI FolderImpl_GetTypeInfoCount(Folder3 *iface, UINT *pctinfo)
138 TRACE("(%p,%p)\n", iface, pctinfo);
144 static HRESULT WINAPI FolderImpl_GetTypeInfo(Folder3 *iface, UINT iTInfo,
145 LCID lcid, ITypeInfo **ppTInfo)
147 FolderImpl *This = impl_from_Folder(iface);
149 TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
151 ITypeInfo_AddRef(This->iTypeInfo);
152 *ppTInfo = This->iTypeInfo;
156 static HRESULT WINAPI FolderImpl_GetIDsOfNames(Folder3 *iface, REFIID riid,
157 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
159 FolderImpl *This = impl_from_Folder(iface);
161 TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
164 return ITypeInfo_GetIDsOfNames(This->iTypeInfo, rgszNames, cNames,
168 static HRESULT WINAPI FolderImpl_Invoke(Folder3 *iface, DISPID dispIdMember,
169 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
170 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
172 FolderImpl *This = impl_from_Folder(iface);
174 TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
175 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
177 return ITypeInfo_Invoke(This->iTypeInfo, This, dispIdMember, wFlags,
178 pDispParams, pVarResult, pExcepInfo, puArgErr);
181 static HRESULT WINAPI FolderImpl_get_Title(Folder3 *iface, BSTR *pbs)
183 FolderImpl *This = impl_from_Folder(iface);
187 TRACE("(%p,%p)\n", iface, pbs);
191 if (V_VT(&This->dir) == VT_I4)
193 FIXME("special folder constants are not supported\n");
196 p = PathFindFileNameW(V_BSTR(&This->dir));
198 *pbs = SysAllocStringLen(p, p[len - 1] == '\\' ? len - 1 : len);
199 return *pbs ? S_OK : E_OUTOFMEMORY;
202 static HRESULT WINAPI FolderImpl_get_Application(Folder3 *iface,
205 FIXME("(%p,%p)\n", iface, ppid);
211 static HRESULT WINAPI FolderImpl_get_Parent(Folder3 *iface, IDispatch **ppid)
213 FIXME("(%p,%p)\n", iface, ppid);
219 static HRESULT WINAPI FolderImpl_get_ParentFolder(Folder3 *iface, Folder **ppsf)
221 FIXME("(%p,%p)\n", iface, ppsf);
227 static HRESULT WINAPI FolderImpl_Items(Folder3 *iface, FolderItems **ppid)
229 FIXME("(%p,%p)\n", iface, ppid);
235 static HRESULT WINAPI FolderImpl_ParseName(Folder3 *iface, BSTR bName,
238 FIXME("(%p,%s,%p)\n", iface, debugstr_w(bName), ppid);
244 static HRESULT WINAPI FolderImpl_NewFolder(Folder3 *iface, BSTR bName,
247 FIXME("(%p,%s)\n", iface, debugstr_w(bName));
252 static HRESULT WINAPI FolderImpl_MoveHere(Folder3 *iface, VARIANT vItem,
255 FIXME("(%p)\n", iface);
260 static HRESULT WINAPI FolderImpl_CopyHere(Folder3 *iface, VARIANT vItem,
263 FIXME("(%p)\n", iface);
268 static HRESULT WINAPI FolderImpl_GetDetailsOf(Folder3 *iface, VARIANT vItem,
269 int iColumn, BSTR *pbs)
271 FIXME("(%p,%d,%p)\n", iface, iColumn, pbs);
277 static HRESULT WINAPI FolderImpl_get_Self(Folder3 *iface, FolderItem **ppfi)
279 FIXME("(%p,%p)\n", iface, ppfi);
285 static HRESULT WINAPI FolderImpl_get_OfflineStatus(Folder3 *iface, LONG *pul)
287 FIXME("(%p,%p)\n", iface, pul);
292 static HRESULT WINAPI FolderImpl_Synchronize(Folder3 *iface)
294 FIXME("(%p)\n", iface);
299 static HRESULT WINAPI FolderImpl_get_HaveToShowWebViewBarricade(Folder3 *iface,
300 VARIANT_BOOL *pbHaveToShowWebViewBarricade)
302 FIXME("(%p,%p)\n", iface, pbHaveToShowWebViewBarricade);
307 static HRESULT WINAPI FolderImpl_DismissedWebViewBarricade(Folder3 *iface)
309 FIXME("(%p)\n", iface);
314 static HRESULT WINAPI FolderImpl_get_ShowWebViewBarricade(Folder3 *iface,
315 VARIANT_BOOL *pbShowWebViewBarricade)
317 FIXME("(%p,%p)\n", iface, pbShowWebViewBarricade);
322 static HRESULT WINAPI FolderImpl_put_ShowWebViewBarricade(Folder3 *iface,
323 VARIANT_BOOL bShowWebViewBarricade)
325 FIXME("(%p,%d)\n", iface, bShowWebViewBarricade);
330 static const Folder3Vtbl FolderImpl_Vtbl = {
331 FolderImpl_QueryInterface,
334 FolderImpl_GetTypeInfoCount,
335 FolderImpl_GetTypeInfo,
336 FolderImpl_GetIDsOfNames,
338 FolderImpl_get_Title,
339 FolderImpl_get_Application,
340 FolderImpl_get_Parent,
341 FolderImpl_get_ParentFolder,
343 FolderImpl_ParseName,
344 FolderImpl_NewFolder,
347 FolderImpl_GetDetailsOf,
349 FolderImpl_get_OfflineStatus,
350 FolderImpl_Synchronize,
351 FolderImpl_get_HaveToShowWebViewBarricade,
352 FolderImpl_DismissedWebViewBarricade,
353 FolderImpl_get_ShowWebViewBarricade,
354 FolderImpl_put_ShowWebViewBarricade
357 static HRESULT Folder_Constructor(VARIANT *dir, Folder **ppsdf)
367 /* FIXME: add some checks */
370 if (PathIsDirectoryW(V_BSTR(dir)) &&
371 !PathIsRelativeW(V_BSTR(dir)) &&
372 PathFileExistsW(V_BSTR(dir)))
378 This = HeapAlloc(GetProcessHeap(), 0, sizeof(FolderImpl));
379 if (!This) return E_OUTOFMEMORY;
380 This->Folder_iface.lpVtbl = &FolderImpl_Vtbl;
383 ret = load_type_info(&IID_Folder3, &This->iTypeInfo);
386 HeapFree(GetProcessHeap(), 0, This);
390 VariantInit(&This->dir);
391 ret = VariantCopy(&This->dir, dir);
394 ITypeInfo_Release(This->iTypeInfo);
395 HeapFree(GetProcessHeap(), 0, This);
396 return E_OUTOFMEMORY;
399 *ppsdf = (Folder*)This;
403 static HRESULT WINAPI ShellDispatch_QueryInterface(IShellDispatch *iface,
404 REFIID riid, LPVOID *ppv)
406 ShellDispatch *This = impl_from_IShellDispatch(iface);
408 TRACE("(%p,%p,%p)\n", iface, riid, ppv);
410 if (!ppv) return E_INVALIDARG;
412 if (IsEqualIID(&IID_IUnknown, riid) ||
413 IsEqualIID(&IID_IDispatch, riid) ||
414 IsEqualIID(&IID_IShellDispatch, riid))
418 FIXME("not implemented for %s\n", shdebugstr_guid(riid));
420 return E_NOINTERFACE;
422 IUnknown_AddRef((IUnknown*)*ppv);
426 static ULONG WINAPI ShellDispatch_AddRef(IShellDispatch *iface)
428 ShellDispatch *This = impl_from_IShellDispatch(iface);
429 ULONG ref = InterlockedIncrement(&This->ref);
431 TRACE("(%p), new refcount=%i\n", iface, ref);
436 static ULONG WINAPI ShellDispatch_Release(IShellDispatch *iface)
438 ShellDispatch *This = impl_from_IShellDispatch(iface);
439 ULONG ref = InterlockedDecrement(&This->ref);
441 TRACE("(%p), new refcount=%i\n", iface, ref);
445 ITypeInfo_Release(This->iTypeInfo);
446 HeapFree(GetProcessHeap(), 0, This);
451 static HRESULT WINAPI ShellDispatch_GetTypeInfoCount(IShellDispatch *iface,
454 TRACE("(%p,%p)\n", iface, pctinfo);
460 static HRESULT WINAPI ShellDispatch_GetTypeInfo(IShellDispatch *iface,
461 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
463 ShellDispatch *This = impl_from_IShellDispatch(iface);
465 TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
467 ITypeInfo_AddRef(This->iTypeInfo);
468 *ppTInfo = This->iTypeInfo;
472 static HRESULT WINAPI ShellDispatch_GetIDsOfNames(IShellDispatch *iface,
473 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
475 ShellDispatch *This = impl_from_IShellDispatch(iface);
477 TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
480 return ITypeInfo_GetIDsOfNames(This->iTypeInfo, rgszNames, cNames, rgDispId);
483 static HRESULT WINAPI ShellDispatch_Invoke(IShellDispatch *iface,
484 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
485 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
488 ShellDispatch *This = impl_from_IShellDispatch(iface);
490 TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
491 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
493 return ITypeInfo_Invoke(This->iTypeInfo, This, dispIdMember, wFlags,
494 pDispParams, pVarResult, pExcepInfo, puArgErr);
497 static HRESULT WINAPI ShellDispatch_get_Application(IShellDispatch *iface,
500 FIXME("(%p,%p)\n", iface, ppid);
506 static HRESULT WINAPI ShellDispatch_get_Parent(IShellDispatch *iface,
509 FIXME("(%p,%p)\n", iface, ppid);
515 static HRESULT WINAPI ShellDispatch_NameSpace(IShellDispatch *iface,
516 VARIANT vDir, Folder **ppsdf)
518 TRACE("(%p,%p)\n", iface, ppsdf);
520 return Folder_Constructor(&vDir, ppsdf);
523 static HRESULT WINAPI ShellDispatch_BrowseForFolder(IShellDispatch *iface,
524 LONG Hwnd, BSTR Title, LONG Options, VARIANT RootFolder, Folder **ppsdf)
526 FIXME("(%p,%x,%s,%x,%p)\n", iface, Hwnd, debugstr_w(Title), Options, ppsdf);
532 static HRESULT WINAPI ShellDispatch_Windows(IShellDispatch *iface,
535 FIXME("(%p,%p)\n", iface, ppid);
541 static HRESULT WINAPI ShellDispatch_Open(IShellDispatch *iface, VARIANT vDir)
543 FIXME("(%p)\n", iface);
548 static HRESULT WINAPI ShellDispatch_Explore(IShellDispatch *iface, VARIANT vDir)
550 FIXME("(%p)\n", iface);
555 static HRESULT WINAPI ShellDispatch_MinimizeAll(IShellDispatch *iface)
557 FIXME("(%p)\n", iface);
562 static HRESULT WINAPI ShellDispatch_UndoMinimizeALL(IShellDispatch *iface)
564 FIXME("(%p)\n", iface);
569 static HRESULT WINAPI ShellDispatch_FileRun(IShellDispatch *iface)
571 FIXME("(%p)\n", iface);
576 static HRESULT WINAPI ShellDispatch_CascadeWindows(IShellDispatch *iface)
578 FIXME("(%p)\n", iface);
583 static HRESULT WINAPI ShellDispatch_TileVertically(IShellDispatch *iface)
585 FIXME("(%p)\n", iface);
590 static HRESULT WINAPI ShellDispatch_TileHorizontally(IShellDispatch *iface)
592 FIXME("(%p)\n", iface);
597 static HRESULT WINAPI ShellDispatch_ShutdownWindows(IShellDispatch *iface)
599 FIXME("(%p)\n", iface);
604 static HRESULT WINAPI ShellDispatch_Suspend(IShellDispatch *iface)
606 FIXME("(%p)\n", iface);
611 static HRESULT WINAPI ShellDispatch_EjectPC(IShellDispatch *iface)
613 FIXME("(%p)\n", iface);
618 static HRESULT WINAPI ShellDispatch_SetTime(IShellDispatch *iface)
620 FIXME("(%p)\n", iface);
625 static HRESULT WINAPI ShellDispatch_TrayProperties(IShellDispatch *iface)
627 FIXME("(%p)\n", iface);
632 static HRESULT WINAPI ShellDispatch_Help(IShellDispatch *iface)
634 FIXME("(%p)\n", iface);
639 static HRESULT WINAPI ShellDispatch_FindFiles(IShellDispatch *iface)
641 FIXME("(%p)\n", iface);
646 static HRESULT WINAPI ShellDispatch_FindComputer(IShellDispatch *iface)
648 FIXME("(%p)\n", iface);
653 static HRESULT WINAPI ShellDispatch_RefreshMenu(IShellDispatch *iface)
655 FIXME("(%p)\n", iface);
660 static HRESULT WINAPI ShellDispatch_ControlPanelItem(IShellDispatch *iface,
663 FIXME("(%p,%s)\n", iface, debugstr_w(szDir));
668 static const IShellDispatchVtbl ShellDispatch_Vtbl = {
669 ShellDispatch_QueryInterface,
670 ShellDispatch_AddRef,
671 ShellDispatch_Release,
672 ShellDispatch_GetTypeInfoCount,
673 ShellDispatch_GetTypeInfo,
674 ShellDispatch_GetIDsOfNames,
675 ShellDispatch_Invoke,
676 ShellDispatch_get_Application,
677 ShellDispatch_get_Parent,
678 ShellDispatch_NameSpace,
679 ShellDispatch_BrowseForFolder,
680 ShellDispatch_Windows,
682 ShellDispatch_Explore,
683 ShellDispatch_MinimizeAll,
684 ShellDispatch_UndoMinimizeALL,
685 ShellDispatch_FileRun,
686 ShellDispatch_CascadeWindows,
687 ShellDispatch_TileVertically,
688 ShellDispatch_TileHorizontally,
689 ShellDispatch_ShutdownWindows,
690 ShellDispatch_Suspend,
691 ShellDispatch_EjectPC,
692 ShellDispatch_SetTime,
693 ShellDispatch_TrayProperties,
695 ShellDispatch_FindFiles,
696 ShellDispatch_FindComputer,
697 ShellDispatch_RefreshMenu,
698 ShellDispatch_ControlPanelItem
701 HRESULT WINAPI IShellDispatch_Constructor(IUnknown *pUnkOuter, REFIID riid,
707 TRACE("(%p,%s)\n", pUnkOuter, debugstr_guid(riid));
711 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
713 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ShellDispatch));
714 if (!This) return E_OUTOFMEMORY;
715 This->IShellDispatch_iface.lpVtbl = &ShellDispatch_Vtbl;
718 ret = load_type_info(&IID_IShellDispatch, &This->iTypeInfo);
721 HeapFree(GetProcessHeap(), 0, This);
725 ret = ShellDispatch_QueryInterface(&This->IShellDispatch_iface, riid, ppv);
726 ShellDispatch_Release(&This->IShellDispatch_iface);