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 HeapFree(GetProcessHeap(), 0, This);
395 return E_OUTOFMEMORY;
398 *ppsdf = (Folder*)This;
402 static HRESULT WINAPI ShellDispatch_QueryInterface(IShellDispatch *iface,
403 REFIID riid, LPVOID *ppv)
405 ShellDispatch *This = impl_from_IShellDispatch(iface);
407 TRACE("(%p,%p,%p)\n", iface, riid, ppv);
409 if (!ppv) return E_INVALIDARG;
411 if (IsEqualIID(&IID_IUnknown, riid) ||
412 IsEqualIID(&IID_IDispatch, riid) ||
413 IsEqualIID(&IID_IShellDispatch, riid))
417 FIXME("not implemented for %s\n", shdebugstr_guid(riid));
419 return E_NOINTERFACE;
421 IUnknown_AddRef((IUnknown*)*ppv);
425 static ULONG WINAPI ShellDispatch_AddRef(IShellDispatch *iface)
427 ShellDispatch *This = impl_from_IShellDispatch(iface);
428 ULONG ref = InterlockedIncrement(&This->ref);
430 TRACE("(%p), new refcount=%i\n", iface, ref);
435 static ULONG WINAPI ShellDispatch_Release(IShellDispatch *iface)
437 ShellDispatch *This = impl_from_IShellDispatch(iface);
438 ULONG ref = InterlockedDecrement(&This->ref);
440 TRACE("(%p), new refcount=%i\n", iface, ref);
444 ITypeInfo_Release(This->iTypeInfo);
445 HeapFree(GetProcessHeap(), 0, This);
450 static HRESULT WINAPI ShellDispatch_GetTypeInfoCount(IShellDispatch *iface,
453 TRACE("(%p,%p)\n", iface, pctinfo);
459 static HRESULT WINAPI ShellDispatch_GetTypeInfo(IShellDispatch *iface,
460 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
462 ShellDispatch *This = impl_from_IShellDispatch(iface);
464 TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
466 ITypeInfo_AddRef(This->iTypeInfo);
467 *ppTInfo = This->iTypeInfo;
471 static HRESULT WINAPI ShellDispatch_GetIDsOfNames(IShellDispatch *iface,
472 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
474 ShellDispatch *This = impl_from_IShellDispatch(iface);
476 TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
479 return ITypeInfo_GetIDsOfNames(This->iTypeInfo, rgszNames, cNames, rgDispId);
482 static HRESULT WINAPI ShellDispatch_Invoke(IShellDispatch *iface,
483 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
484 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
487 ShellDispatch *This = impl_from_IShellDispatch(iface);
489 TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
490 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
492 return ITypeInfo_Invoke(This->iTypeInfo, This, dispIdMember, wFlags,
493 pDispParams, pVarResult, pExcepInfo, puArgErr);
496 static HRESULT WINAPI ShellDispatch_get_Application(IShellDispatch *iface,
499 FIXME("(%p,%p)\n", iface, ppid);
505 static HRESULT WINAPI ShellDispatch_get_Parent(IShellDispatch *iface,
508 FIXME("(%p,%p)\n", iface, ppid);
514 static HRESULT WINAPI ShellDispatch_NameSpace(IShellDispatch *iface,
515 VARIANT vDir, Folder **ppsdf)
517 TRACE("(%p,%p)\n", iface, ppsdf);
519 return Folder_Constructor(&vDir, ppsdf);
522 static HRESULT WINAPI ShellDispatch_BrowseForFolder(IShellDispatch *iface,
523 LONG Hwnd, BSTR Title, LONG Options, VARIANT RootFolder, Folder **ppsdf)
525 FIXME("(%p,%x,%s,%x,%p)\n", iface, Hwnd, debugstr_w(Title), Options, ppsdf);
531 static HRESULT WINAPI ShellDispatch_Windows(IShellDispatch *iface,
534 FIXME("(%p,%p)\n", iface, ppid);
540 static HRESULT WINAPI ShellDispatch_Open(IShellDispatch *iface, VARIANT vDir)
542 FIXME("(%p)\n", iface);
547 static HRESULT WINAPI ShellDispatch_Explore(IShellDispatch *iface, VARIANT vDir)
549 FIXME("(%p)\n", iface);
554 static HRESULT WINAPI ShellDispatch_MinimizeAll(IShellDispatch *iface)
556 FIXME("(%p)\n", iface);
561 static HRESULT WINAPI ShellDispatch_UndoMinimizeALL(IShellDispatch *iface)
563 FIXME("(%p)\n", iface);
568 static HRESULT WINAPI ShellDispatch_FileRun(IShellDispatch *iface)
570 FIXME("(%p)\n", iface);
575 static HRESULT WINAPI ShellDispatch_CascadeWindows(IShellDispatch *iface)
577 FIXME("(%p)\n", iface);
582 static HRESULT WINAPI ShellDispatch_TileVertically(IShellDispatch *iface)
584 FIXME("(%p)\n", iface);
589 static HRESULT WINAPI ShellDispatch_TileHorizontally(IShellDispatch *iface)
591 FIXME("(%p)\n", iface);
596 static HRESULT WINAPI ShellDispatch_ShutdownWindows(IShellDispatch *iface)
598 FIXME("(%p)\n", iface);
603 static HRESULT WINAPI ShellDispatch_Suspend(IShellDispatch *iface)
605 FIXME("(%p)\n", iface);
610 static HRESULT WINAPI ShellDispatch_EjectPC(IShellDispatch *iface)
612 FIXME("(%p)\n", iface);
617 static HRESULT WINAPI ShellDispatch_SetTime(IShellDispatch *iface)
619 FIXME("(%p)\n", iface);
624 static HRESULT WINAPI ShellDispatch_TrayProperties(IShellDispatch *iface)
626 FIXME("(%p)\n", iface);
631 static HRESULT WINAPI ShellDispatch_Help(IShellDispatch *iface)
633 FIXME("(%p)\n", iface);
638 static HRESULT WINAPI ShellDispatch_FindFiles(IShellDispatch *iface)
640 FIXME("(%p)\n", iface);
645 static HRESULT WINAPI ShellDispatch_FindComputer(IShellDispatch *iface)
647 FIXME("(%p)\n", iface);
652 static HRESULT WINAPI ShellDispatch_RefreshMenu(IShellDispatch *iface)
654 FIXME("(%p)\n", iface);
659 static HRESULT WINAPI ShellDispatch_ControlPanelItem(IShellDispatch *iface,
662 FIXME("(%p,%s)\n", iface, debugstr_w(szDir));
667 static const IShellDispatchVtbl ShellDispatch_Vtbl = {
668 ShellDispatch_QueryInterface,
669 ShellDispatch_AddRef,
670 ShellDispatch_Release,
671 ShellDispatch_GetTypeInfoCount,
672 ShellDispatch_GetTypeInfo,
673 ShellDispatch_GetIDsOfNames,
674 ShellDispatch_Invoke,
675 ShellDispatch_get_Application,
676 ShellDispatch_get_Parent,
677 ShellDispatch_NameSpace,
678 ShellDispatch_BrowseForFolder,
679 ShellDispatch_Windows,
681 ShellDispatch_Explore,
682 ShellDispatch_MinimizeAll,
683 ShellDispatch_UndoMinimizeALL,
684 ShellDispatch_FileRun,
685 ShellDispatch_CascadeWindows,
686 ShellDispatch_TileVertically,
687 ShellDispatch_TileHorizontally,
688 ShellDispatch_ShutdownWindows,
689 ShellDispatch_Suspend,
690 ShellDispatch_EjectPC,
691 ShellDispatch_SetTime,
692 ShellDispatch_TrayProperties,
694 ShellDispatch_FindFiles,
695 ShellDispatch_FindComputer,
696 ShellDispatch_RefreshMenu,
697 ShellDispatch_ControlPanelItem
700 HRESULT WINAPI IShellDispatch_Constructor(IUnknown *pUnkOuter, REFIID riid,
706 TRACE("(%p,%s)\n", pUnkOuter, debugstr_guid(riid));
710 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
712 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ShellDispatch));
713 if (!This) return E_OUTOFMEMORY;
714 This->IShellDispatch_iface.lpVtbl = &ShellDispatch_Vtbl;
717 ret = load_type_info(&IID_IShellDispatch, &This->iTypeInfo);
720 HeapFree(GetProcessHeap(), 0, This);
724 ret = ShellDispatch_QueryInterface(&This->IShellDispatch_iface, riid, ppv);
725 ShellDispatch_Release(&This->IShellDispatch_iface);