Release 20030408.
[wine/gsoc-2012-control.git] / dlls / shell32 / shfldr_fs.c
blob435636d419bc9fa976e3f560552fd883c38ee079
2 /*
3 * file system folder
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998, 1999, 2002 Juergen Schmied
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdio.h>
30 #define NONAMELESSUNION
31 #define NONAMELESSSTRUCT
32 #include "winerror.h"
33 #include "winbase.h"
34 #include "winreg.h"
36 #include "ole2.h"
37 #include "shlguid.h"
39 #include "pidl.h"
40 #include "undocshell.h"
41 #include "shell32_main.h"
42 #include "shresdef.h"
43 #include "shlwapi.h"
44 #include "shellfolder.h"
45 #include "wine/debug.h"
46 #include "debughlp.h"
47 #include "shfldr.h"
49 WINE_DEFAULT_DEBUG_CHANNEL (shell);
51 /***********************************************************************
52 * IShellFolder implementation
55 typedef struct {
56 ICOM_VFIELD (IUnknown);
57 DWORD ref;
58 ICOM_VTABLE (IShellFolder2) * lpvtblShellFolder;
59 ICOM_VTABLE (IPersistFolder3) * lpvtblPersistFolder3;
60 ICOM_VTABLE (IDropTarget) * lpvtblDropTarget;
61 ICOM_VTABLE (ISFHelper) * lpvtblSFHelper;
63 IUnknown *pUnkOuter; /* used for aggregation */
65 CLSID *pclsid;
67 /* both paths are parsible from the desktop */
68 LPSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */
70 LPITEMIDLIST pidlRoot; /* absolute pidl */
72 int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
74 UINT cfShellIDList; /* clipboardformat for IDropTarget */
75 BOOL fAcceptFmt; /* flag for pending Drop */
76 } IGenericSFImpl;
78 static struct ICOM_VTABLE (IUnknown) unkvt;
79 static struct ICOM_VTABLE (IShellFolder2) sfvt;
80 static struct ICOM_VTABLE (IPersistFolder3) vt_FSFldr_PersistFolder3; /* IPersistFolder3 for a FS_Folder */
81 static struct ICOM_VTABLE (IDropTarget) dtvt;
82 static struct ICOM_VTABLE (ISFHelper) shvt;
84 #define _IShellFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblShellFolder)))
85 #define _ICOM_THIS_From_IShellFolder2(class, name) class* This = (class*)(((char*)name)-_IShellFolder2_Offset);
87 #define _IPersistFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder3)))
88 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
90 #define _IPersistFolder3_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder3)))
91 #define _ICOM_THIS_From_IPersistFolder3(class, name) class* This = (class*)(((char*)name)-_IPersistFolder3_Offset);
93 #define _IDropTarget_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblDropTarget)))
94 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
96 #define _ISFHelper_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblSFHelper)))
97 #define _ICOM_THIS_From_ISFHelper(class, name) class* This = (class*)(((char*)name)-_ISFHelper_Offset);
100 converts This to a interface pointer
102 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
103 #define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder)
104 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpvtblShellFolder)
105 #define _IPersist_(This) (IPersist*)&(This->lpvtblPersistFolder3)
106 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpvtblPersistFolder3)
107 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpvtblPersistFolder3)
108 #define _IPersistFolder3_(This) (IPersistFolder3*)&(This->lpvtblPersistFolder3)
109 #define _IDropTarget_(This) (IDropTarget*)&(This->lpvtblDropTarget)
110 #define _ISFHelper_(This) (ISFHelper*)&(This->lpvtblSFHelper)
112 /**************************************************************************
113 * registers clipboardformat once
115 static void SF_RegisterClipFmt (IGenericSFImpl * This)
117 TRACE ("(%p)\n", This);
119 if (!This->cfShellIDList) {
120 This->cfShellIDList = RegisterClipboardFormatA (CFSTR_SHELLIDLIST);
124 /**************************************************************************
125 * we need a separate IUnknown to handle aggregation
126 * (inner IUnknown)
128 static HRESULT WINAPI IUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, LPVOID * ppvObj)
130 ICOM_THIS (IGenericSFImpl, iface);
132 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
134 *ppvObj = NULL;
136 if (IsEqualIID (riid, &IID_IUnknown))
137 *ppvObj = _IUnknown_ (This);
138 else if (IsEqualIID (riid, &IID_IShellFolder))
139 *ppvObj = _IShellFolder_ (This);
140 else if (IsEqualIID (riid, &IID_IShellFolder2))
141 *ppvObj = _IShellFolder_ (This);
142 else if (IsEqualIID (riid, &IID_IPersist))
143 *ppvObj = _IPersist_ (This);
144 else if (IsEqualIID (riid, &IID_IPersistFolder))
145 *ppvObj = _IPersistFolder_ (This);
146 else if (IsEqualIID (riid, &IID_IPersistFolder2))
147 *ppvObj = _IPersistFolder2_ (This);
148 else if (IsEqualIID (riid, &IID_IPersistFolder3))
149 *ppvObj = _IPersistFolder3_ (This);
150 else if (IsEqualIID (riid, &IID_ISFHelper))
151 *ppvObj = _ISFHelper_ (This);
152 else if (IsEqualIID (riid, &IID_IDropTarget)) {
153 *ppvObj = _IDropTarget_ (This);
154 SF_RegisterClipFmt (This);
157 if (*ppvObj) {
158 IUnknown_AddRef ((IUnknown *) (*ppvObj));
159 TRACE ("-- Interface = %p\n", *ppvObj);
160 return S_OK;
162 TRACE ("-- Interface: E_NOINTERFACE\n");
163 return E_NOINTERFACE;
166 static ULONG WINAPI IUnknown_fnAddRef (IUnknown * iface)
168 ICOM_THIS (IGenericSFImpl, iface);
170 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
172 return ++(This->ref);
175 static ULONG WINAPI IUnknown_fnRelease (IUnknown * iface)
177 ICOM_THIS (IGenericSFImpl, iface);
179 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
181 if (!--(This->ref)) {
182 TRACE ("-- destroying IShellFolder(%p)\n", This);
184 if (This->pidlRoot)
185 SHFree (This->pidlRoot);
186 if (This->sPathTarget)
187 SHFree (This->sPathTarget);
188 LocalFree ((HLOCAL) This);
189 return 0;
191 return This->ref;
194 static ICOM_VTABLE (IUnknown) unkvt =
196 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE IUnknown_fnQueryInterface,
197 IUnknown_fnAddRef,
198 IUnknown_fnRelease,
201 static shvheader GenericSFHeader[] = {
202 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
203 {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
204 {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
205 {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
206 {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
209 #define GENERICSHELLVIEWCOLUMNS 5
211 /**************************************************************************
212 * IFSFolder_Constructor
214 * NOTES
215 * creating undocumented ShellFS_Folder as part of an aggregation
216 * {F3364BA0-65B9-11CE-A9BA-00AA004AE837}
219 HRESULT WINAPI IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
221 IGenericSFImpl *sf;
223 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
225 if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
226 return CLASS_E_NOAGGREGATION;
227 sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
228 if (!sf)
229 return E_OUTOFMEMORY;
231 sf->ref = 0;
232 ICOM_VTBL (sf) = &unkvt;
233 sf->lpvtblShellFolder = &sfvt;
234 sf->lpvtblPersistFolder3 = &vt_FSFldr_PersistFolder3;
235 sf->lpvtblDropTarget = &dtvt;
236 sf->lpvtblSFHelper = &shvt;
237 sf->pclsid = (CLSID *) & CLSID_ShellFSFolder;
238 sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_ (sf);
240 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
241 IUnknown_Release (_IUnknown_ (sf));
242 return E_NOINTERFACE;
245 TRACE ("--%p\n", *ppv);
246 return S_OK;
249 /**************************************************************************
250 * IShellFolder_fnQueryInterface
252 * PARAMETERS
253 * REFIID riid [in ] Requested InterfaceID
254 * LPVOID* ppvObject [out] Interface* to hold the result
256 static HRESULT WINAPI IShellFolder_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
258 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
260 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
262 return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj);
265 /**************************************************************************
266 * IShellFolder_AddRef
269 static ULONG WINAPI IShellFolder_fnAddRef (IShellFolder2 * iface)
271 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
273 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
275 return IUnknown_AddRef (This->pUnkOuter);
278 /**************************************************************************
279 * IShellFolder_fnRelease
281 static ULONG WINAPI IShellFolder_fnRelease (IShellFolder2 * iface)
283 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
285 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
287 return IUnknown_Release (This->pUnkOuter);
290 /**************************************************************************
291 * IShellFolder_ParseDisplayName {SHELL32}
293 * Parse a display name.
295 * PARAMS
296 * hwndOwner [in] Parent window for any message's
297 * pbc [in] Reserved
298 * lpszDisplayName [in] Unicode displayname.
299 * pchEaten [out] (unicode) characters processed
300 * ppidl [out] complex pidl to item
301 * pdwAttributes [out] items attributes
303 * NOTES
304 * Every folder tries to parse only its own (the leftmost) pidl and creates a
305 * subfolder to evaluate the remaining parts.
306 * Now we can parse into namespaces implemented by shell extensions
308 * Behaviour on win98: lpszDisplayName=NULL -> crash
309 * lpszDisplayName="" -> returns mycoputer-pidl
311 * FIXME
312 * pdwAttributes is not set
313 * pchEaten is not set like in windows
315 static HRESULT WINAPI
316 IShellFolder_fnParseDisplayName (IShellFolder2 * iface,
317 HWND hwndOwner,
318 LPBC pbcReserved,
319 LPOLESTR lpszDisplayName,
320 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
322 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
324 HRESULT hr = E_OUTOFMEMORY;
325 LPCWSTR szNext = NULL;
326 WCHAR szElement[MAX_PATH];
327 CHAR szPath[MAX_PATH];
328 LPITEMIDLIST pidlTemp = NULL;
329 DWORD len;
331 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
332 This, hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
334 if (!lpszDisplayName || !ppidl)
335 return E_INVALIDARG;
337 if (pchEaten)
338 *pchEaten = 0; /* strange but like the original */
340 if (*lpszDisplayName) {
341 /* get the next element */
342 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
344 /* build the full pathname to the element */
345 lstrcpyA(szPath, This->sPathTarget);
346 PathAddBackslashA(szPath);
347 len = lstrlenA(szPath);
348 WideCharToMultiByte(CP_ACP, 0, szElement, -1, szPath + len, MAX_PATH - len, NULL, NULL);
350 /* get the pidl */
351 pidlTemp = _ILCreateFromPathA(szPath);
352 if (pidlTemp) {
353 if (szNext && *szNext) {
354 /* try to analyse the next element */
355 hr = SHELL32_ParseNextElement (hwndOwner, iface, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
356 } else {
357 /* it's the last element */
358 if (pdwAttributes && *pdwAttributes) {
359 SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
361 hr = S_OK;
366 if (!hr)
367 *ppidl = pidlTemp;
368 else
369 *ppidl = NULL;
371 TRACE ("(%p)->(-- pidl=%p ret=0x%08lx)\n", This, ppidl ? *ppidl : 0, hr);
373 return hr;
376 /**************************************************************************
377 * IShellFolder_fnEnumObjects
378 * PARAMETERS
379 * HWND hwndOwner, //[in ] Parent Window
380 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
381 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
383 static HRESULT WINAPI
384 IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
386 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
388 TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
390 *ppEnumIDList = IEnumIDList_Constructor (This->sPathTarget, dwFlags, EIDL_FILE);
392 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
394 return *ppEnumIDList ? S_OK : E_OUTOFMEMORY;
397 /**************************************************************************
398 * IShellFolder_fnBindToObject
399 * PARAMETERS
400 * LPCITEMIDLIST pidl, //[in ] relative pidl to open
401 * LPBC pbc, //[in ] reserved
402 * REFIID riid, //[in ] Initial Interface
403 * LPVOID* ppvObject //[out] Interface*
405 static HRESULT WINAPI
406 IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
408 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
410 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
412 return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut);
415 /**************************************************************************
416 * IShellFolder_fnBindToStorage
417 * PARAMETERS
418 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
419 * LPBC pbc, //[in ] reserved
420 * REFIID riid, //[in ] Initial storage interface
421 * LPVOID* ppvObject //[out] Interface* returned
423 static HRESULT WINAPI
424 IShellFolder_fnBindToStorage (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
426 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
428 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
430 *ppvOut = NULL;
431 return E_NOTIMPL;
434 /**************************************************************************
435 * IShellFolder_fnCompareIDs
438 static HRESULT WINAPI
439 IShellFolder_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
441 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
443 int nReturn;
445 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
446 nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
447 TRACE ("-- %i\n", nReturn);
448 return nReturn;
451 /**************************************************************************
452 * IShellFolder_fnCreateViewObject
454 static HRESULT WINAPI
455 IShellFolder_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
457 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
459 LPSHELLVIEW pShellView;
460 HRESULT hr = E_INVALIDARG;
462 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut);
464 if (ppvOut) {
465 *ppvOut = NULL;
467 if (IsEqualIID (riid, &IID_IDropTarget)) {
468 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, ppvOut);
469 } else if (IsEqualIID (riid, &IID_IContextMenu)) {
470 FIXME ("IContextMenu not implemented\n");
471 hr = E_NOTIMPL;
472 } else if (IsEqualIID (riid, &IID_IShellView)) {
473 pShellView = IShellView_Constructor ((IShellFolder *) iface);
474 if (pShellView) {
475 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
476 IShellView_Release (pShellView);
480 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
481 return hr;
484 /**************************************************************************
485 * IShellFolder_fnGetAttributesOf
487 * PARAMETERS
488 * UINT cidl, //[in ] num elements in pidl array
489 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
490 * ULONG* rgfInOut) //[out] result array
493 static HRESULT WINAPI
494 IShellFolder_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
496 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
498 HRESULT hr = S_OK;
500 TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
502 if ((!cidl) || (!apidl) || (!rgfInOut))
503 return E_INVALIDARG;
505 while (cidl > 0 && *apidl) {
506 pdump (*apidl);
507 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
508 apidl++;
509 cidl--;
512 TRACE ("-- result=0x%08lx\n", *rgfInOut);
514 return hr;
517 /**************************************************************************
518 * IShellFolder_fnGetUIObjectOf
520 * PARAMETERS
521 * HWND hwndOwner, //[in ] Parent window for any output
522 * UINT cidl, //[in ] array size
523 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
524 * REFIID riid, //[in ] Requested Interface
525 * UINT* prgfInOut, //[ ] reserved
526 * LPVOID* ppvObject) //[out] Resulting Interface
528 * NOTES
529 * This function gets asked to return "view objects" for one or more (multiple select)
530 * items:
531 * The viewobject typically is an COM object with one of the following interfaces:
532 * IExtractIcon,IDataObject,IContextMenu
533 * In order to support icon positions in the default Listview your DataObject
534 * must implement the SetData method (in addition to GetData :) - the shell passes
535 * a barely documented "Icon positions" structure to SetData when the drag starts,
536 * and GetData's it if the drop is in another explorer window that needs the positions.
538 static HRESULT WINAPI
539 IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface,
540 HWND hwndOwner,
541 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
543 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
545 LPITEMIDLIST pidl;
546 IUnknown *pObj = NULL;
547 HRESULT hr = E_INVALIDARG;
549 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
550 This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
552 if (ppvOut) {
553 *ppvOut = NULL;
555 if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
556 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
557 hr = S_OK;
558 } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
559 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
560 hr = S_OK;
561 } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
562 pidl = ILCombine (This->pidlRoot, apidl[0]);
563 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
564 SHFree (pidl);
565 hr = S_OK;
566 } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
567 pidl = ILCombine (This->pidlRoot, apidl[0]);
568 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
569 SHFree (pidl);
570 hr = S_OK;
571 } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
572 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
573 } else {
574 hr = E_NOINTERFACE;
577 if (!pObj)
578 hr = E_OUTOFMEMORY;
580 *ppvOut = pObj;
582 TRACE ("(%p)->hr=0x%08lx\n", This, hr);
583 return hr;
586 /**************************************************************************
587 * IShellFolder_fnGetDisplayNameOf
588 * Retrieves the display name for the specified file object or subfolder
590 * PARAMETERS
591 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
592 * DWORD dwFlags, //[in ] SHGNO formatting flags
593 * LPSTRRET lpName) //[out] Returned display name
595 * FIXME
596 * if the name is in the pidl the ret value should be a STRRET_OFFSET
599 static HRESULT WINAPI
600 IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
602 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
604 CHAR szPath[MAX_PATH] = "";
605 int len = 0;
606 BOOL bSimplePidl;
608 TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
609 pdump (pidl);
611 if (!pidl || !strRet)
612 return E_INVALIDARG;
614 bSimplePidl = _ILIsPidlSimple (pidl);
616 /* take names of special folders only if its only this folder */
617 if (_ILIsSpecialFolder (pidl)) {
618 if (bSimplePidl) {
619 _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
620 } else {
621 FIXME ("special pidl\n");
623 } else {
624 if (!(dwFlags & SHGDN_INFOLDER) && (dwFlags & SHGDN_FORPARSING) && This->sPathTarget) {
625 lstrcpyA (szPath, This->sPathTarget); /* get path to root */
626 PathAddBackslashA (szPath);
627 len = lstrlenA (szPath);
629 _ILSimpleGetText (pidl, szPath + len, MAX_PATH - len); /* append my own path */
631 /* MSDN also mentions SHGDN_FOREDITING, which isn't defined in wine */
632 if (!_ILIsFolder (pidl) && !(dwFlags & SHGDN_FORPARSING) &&
633 ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
634 HKEY hKey;
635 DWORD dwData;
636 DWORD dwDataSize = sizeof (DWORD);
637 BOOL doHide = 0; /* The default value is FALSE (win98 at least) */
639 /* XXX should it do this only for known file types? -- that would make it even slower! */
640 /* XXX That's what the prompt says!! */
641 if (!RegCreateKeyExA (HKEY_CURRENT_USER,
642 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
643 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) {
644 if (!RegQueryValueExA (hKey, "HideFileExt", 0, 0, (LPBYTE) & dwData, &dwDataSize))
645 doHide = dwData;
646 RegCloseKey (hKey);
648 if (doHide && szPath[0] != '.')
649 PathRemoveExtensionA (szPath);
653 if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */
654 PathAddBackslashA (szPath);
655 len = lstrlenA (szPath);
657 if (!SUCCEEDED
658 (SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len)))
659 return E_OUTOFMEMORY;
661 strRet->uType = STRRET_CSTR;
662 lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
664 TRACE ("-- (%p)->(%s)\n", This, szPath);
665 return S_OK;
668 /**************************************************************************
669 * IShellFolder_fnSetNameOf
670 * Changes the name of a file object or subfolder, possibly changing its item
671 * identifier in the process.
673 * PARAMETERS
674 * HWND hwndOwner, //[in ] Owner window for output
675 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
676 * LPCOLESTR lpszName, //[in ] the items new display name
677 * DWORD dwFlags, //[in ] SHGNO formatting flags
678 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
680 static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
681 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
683 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
684 char szSrc[MAX_PATH],
685 szDest[MAX_PATH];
686 int len;
687 BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl));
689 TRACE ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
691 /* build source path */
692 if (dwFlags & SHGDN_INFOLDER) {
693 strcpy (szSrc, This->sPathTarget);
694 PathAddBackslashA (szSrc);
695 len = strlen (szSrc);
696 _ILSimpleGetText (pidl, szSrc + len, MAX_PATH - len);
697 } else {
698 /* FIXME: Can this work with a simple PIDL? */
699 SHGetPathFromIDListA (pidl, szSrc);
702 /* build destination path */
703 strcpy (szDest, This->sPathTarget);
704 PathAddBackslashA (szDest);
705 len = strlen (szDest);
706 WideCharToMultiByte (CP_ACP, 0, lpName, -1, szDest + len, MAX_PATH - len, NULL, NULL);
707 szDest[MAX_PATH - 1] = 0;
708 TRACE ("src=%s dest=%s\n", szSrc, szDest);
709 if (MoveFileA (szSrc, szDest)) {
710 if (pPidlOut)
711 *pPidlOut = _ILCreateFromPathA(szDest);
712 SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest);
713 return S_OK;
715 return E_FAIL;
718 static HRESULT WINAPI IShellFolder_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
720 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
721 FIXME ("(%p)\n", This);
722 return E_NOTIMPL;
724 static HRESULT WINAPI IShellFolder_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
726 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
727 FIXME ("(%p)\n", This);
728 return E_NOTIMPL;
730 static HRESULT WINAPI
731 IShellFolder_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
733 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
735 TRACE ("(%p)\n", This);
737 if (pSort)
738 *pSort = 0;
739 if (pDisplay)
740 *pDisplay = 0;
742 return S_OK;
744 static HRESULT WINAPI IShellFolder_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
746 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
748 TRACE ("(%p)\n", This);
750 if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS)
751 return E_INVALIDARG;
753 *pcsFlags = GenericSFHeader[iColumn].pcsFlags;
755 return S_OK;
757 static HRESULT WINAPI
758 IShellFolder_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
760 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
761 FIXME ("(%p)\n", This);
763 return E_NOTIMPL;
765 static HRESULT WINAPI
766 IShellFolder_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
768 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
769 HRESULT hr = E_FAIL;
771 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
773 if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS)
774 return E_INVALIDARG;
776 if (!pidl) {
777 /* the header titles */
778 psd->fmt = GenericSFHeader[iColumn].fmt;
779 psd->cxChar = GenericSFHeader[iColumn].cxChar;
780 psd->str.uType = STRRET_CSTR;
781 LoadStringA (shell32_hInstance, GenericSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
782 return S_OK;
783 } else {
784 /* the data from the pidl */
785 switch (iColumn) {
786 case 0: /* name */
787 hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
788 break;
789 case 1: /* size */
790 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
791 break;
792 case 2: /* type */
793 _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
794 break;
795 case 3: /* date */
796 _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
797 break;
798 case 4: /* attributes */
799 _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
800 break;
802 hr = S_OK;
803 psd->str.uType = STRRET_CSTR;
806 return hr;
808 static HRESULT WINAPI IShellFolder_fnMapNameToSCID (IShellFolder2 * iface, LPCWSTR pwszName, SHCOLUMNID * pscid)
810 _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
811 FIXME ("(%p)\n", This);
812 return E_NOTIMPL;
815 static ICOM_VTABLE (IShellFolder2) sfvt =
817 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
818 IShellFolder_fnQueryInterface,
819 IShellFolder_fnAddRef,
820 IShellFolder_fnRelease,
821 IShellFolder_fnParseDisplayName,
822 IShellFolder_fnEnumObjects,
823 IShellFolder_fnBindToObject,
824 IShellFolder_fnBindToStorage,
825 IShellFolder_fnCompareIDs,
826 IShellFolder_fnCreateViewObject,
827 IShellFolder_fnGetAttributesOf,
828 IShellFolder_fnGetUIObjectOf,
829 IShellFolder_fnGetDisplayNameOf,
830 IShellFolder_fnSetNameOf,
831 /* ShellFolder2 */
832 IShellFolder_fnGetDefaultSearchGUID,
833 IShellFolder_fnEnumSearches,
834 IShellFolder_fnGetDefaultColumn,
835 IShellFolder_fnGetDefaultColumnState,
836 IShellFolder_fnGetDetailsEx,
837 IShellFolder_fnGetDetailsOf,
838 IShellFolder_fnMapNameToSCID
841 /****************************************************************************
842 * ISFHelper for IShellFolder implementation
845 static HRESULT WINAPI ISFHelper_fnQueryInterface (ISFHelper * iface, REFIID riid, LPVOID * ppvObj)
847 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
849 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
851 return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj);
854 static ULONG WINAPI ISFHelper_fnAddRef (ISFHelper * iface)
856 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
858 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
860 return IUnknown_AddRef (This->pUnkOuter);
863 static ULONG WINAPI ISFHelper_fnRelease (ISFHelper * iface)
865 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
867 TRACE ("(%p)\n", This);
869 return IUnknown_Release (This->pUnkOuter);
872 /****************************************************************************
873 * ISFHelper_fnAddFolder
875 * creates a unique folder name
878 static HRESULT WINAPI ISFHelper_fnGetUniqueName (ISFHelper * iface, LPSTR lpName, UINT uLen)
880 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface)
881 IEnumIDList *penum;
882 HRESULT hr;
883 char szText[MAX_PATH];
884 char *szNewFolder = "New Folder";
886 TRACE ("(%p)(%s %u)\n", This, lpName, uLen);
888 if (uLen < strlen (szNewFolder) + 4)
889 return E_POINTER;
891 strcpy (lpName, szNewFolder);
893 hr = IShellFolder_fnEnumObjects (_IShellFolder2_ (This), 0,
894 SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum);
895 if (penum) {
896 LPITEMIDLIST pidl;
897 DWORD dwFetched;
898 int i = 1;
900 next:IEnumIDList_Reset (penum);
901 while (S_OK == IEnumIDList_Next (penum, 1, &pidl, &dwFetched) && dwFetched) {
902 _ILSimpleGetText (pidl, szText, MAX_PATH);
903 if (0 == strcasecmp (szText, lpName)) {
904 sprintf (lpName, "%s %d", szNewFolder, i++);
905 if (i > 99) {
906 hr = E_FAIL;
907 break;
909 goto next;
913 IEnumIDList_Release (penum);
915 return hr;
918 /****************************************************************************
919 * ISFHelper_fnAddFolder
921 * adds a new folder.
924 static HRESULT WINAPI ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCSTR lpName, LPITEMIDLIST * ppidlOut)
926 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface)
927 char lpstrNewDir[MAX_PATH];
928 DWORD bRes;
929 HRESULT hres = E_FAIL;
931 TRACE ("(%p)(%s %p)\n", This, lpName, ppidlOut);
933 strcpy (lpstrNewDir, This->sPathTarget);
934 PathAppendA(lpstrNewDir, lpName);
936 bRes = CreateDirectoryA (lpstrNewDir, NULL);
937 if (bRes) {
938 SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHA, lpstrNewDir, NULL);
939 if (ppidlOut)
940 *ppidlOut = _ILCreateFromPathA(lpstrNewDir);
941 hres = S_OK;
942 } else {
943 char lpstrText[128 + MAX_PATH];
944 char lpstrTempText[128];
945 char lpstrCaption[256];
947 /* Cannot Create folder because of permissions */
948 LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_DENIED, lpstrTempText, sizeof (lpstrTempText));
949 LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, lpstrCaption, sizeof (lpstrCaption));
950 sprintf (lpstrText, lpstrTempText, lpstrNewDir);
951 MessageBoxA (hwnd, lpstrText, lpstrCaption, MB_OK | MB_ICONEXCLAMATION);
954 return hres;
957 /****************************************************************************
958 * ISFHelper_fnDeleteItems
960 * deletes items in folder
962 static HRESULT WINAPI ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl)
964 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface)
965 UINT i;
966 char szPath[MAX_PATH];
967 BOOL bConfirm = TRUE;
969 TRACE ("(%p)(%u %p)\n", This, cidl, apidl);
971 /* deleting multiple items so give a slightly different warning */
972 if (cidl != 1) {
973 char tmp[8];
975 snprintf (tmp, sizeof (tmp), "%d", cidl);
976 if (!SHELL_ConfirmDialog(ASK_DELETE_MULTIPLE_ITEM, tmp))
977 return E_FAIL;
978 bConfirm = FALSE;
981 for (i = 0; i < cidl; i++) {
982 strcpy (szPath, This->sPathTarget);
983 PathAddBackslashA (szPath);
984 _ILSimpleGetText (apidl[i], szPath + strlen (szPath), MAX_PATH);
986 if (_ILIsFolder (apidl[i])) {
987 LPITEMIDLIST pidl;
989 TRACE ("delete %s\n", szPath);
990 if (!SHELL_DeleteDirectoryA (szPath, bConfirm)) {
991 TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm);
992 return E_FAIL;
994 pidl = ILCombine (This->pidlRoot, apidl[i]);
995 SHChangeNotify (SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL);
996 SHFree (pidl);
997 } else if (_ILIsValue (apidl[i])) {
998 LPITEMIDLIST pidl;
1000 TRACE ("delete %s\n", szPath);
1001 if (!SHELL_DeleteFileA (szPath, bConfirm)) {
1002 TRACE ("delete %s failed, bConfirm=%d\n", szPath, bConfirm);
1003 return E_FAIL;
1005 pidl = ILCombine (This->pidlRoot, apidl[i]);
1006 SHChangeNotify (SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL);
1007 SHFree (pidl);
1011 return S_OK;
1014 /****************************************************************************
1015 * ISFHelper_fnCopyItems
1017 * copies items to this folder
1019 static HRESULT WINAPI
1020 ISFHelper_fnCopyItems (ISFHelper * iface, IShellFolder * pSFFrom, UINT cidl, LPCITEMIDLIST * apidl)
1022 UINT i;
1023 IPersistFolder2 *ppf2 = NULL;
1024 char szSrcPath[MAX_PATH],
1025 szDstPath[MAX_PATH];
1027 _ICOM_THIS_From_ISFHelper (IGenericSFImpl, iface);
1029 TRACE ("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
1031 IShellFolder_QueryInterface (pSFFrom, &IID_IPersistFolder2, (LPVOID *) & ppf2);
1032 if (ppf2) {
1033 LPITEMIDLIST pidl;
1035 if (SUCCEEDED (IPersistFolder2_GetCurFolder (ppf2, &pidl))) {
1036 for (i = 0; i < cidl; i++) {
1037 SHGetPathFromIDListA (pidl, szSrcPath);
1038 PathAddBackslashA (szSrcPath);
1039 _ILSimpleGetText (apidl[i], szSrcPath + strlen (szSrcPath), MAX_PATH);
1041 strcpy (szDstPath, This->sPathTarget);
1042 PathAddBackslashA (szDstPath);
1043 _ILSimpleGetText (apidl[i], szDstPath + strlen (szDstPath), MAX_PATH);
1044 MESSAGE ("would copy %s to %s\n", szSrcPath, szDstPath);
1046 SHFree (pidl);
1048 IPersistFolder2_Release (ppf2);
1050 return S_OK;
1053 static ICOM_VTABLE (ISFHelper) shvt =
1055 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1056 ISFHelper_fnQueryInterface,
1057 ISFHelper_fnAddRef,
1058 ISFHelper_fnRelease,
1059 ISFHelper_fnGetUniqueName,
1060 ISFHelper_fnAddFolder,
1061 ISFHelper_fnDeleteItems,
1062 ISFHelper_fnCopyItems
1065 /************************************************************************
1066 * IFSFldr_PersistFolder3_QueryInterface
1069 static HRESULT WINAPI IFSFldr_PersistFolder3_QueryInterface (IPersistFolder3 * iface, REFIID iid, LPVOID * ppvObj)
1071 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1073 TRACE ("(%p)\n", This);
1075 return IUnknown_QueryInterface (This->pUnkOuter, iid, ppvObj);
1078 /************************************************************************
1079 * IFSFldr_PersistFolder3_AddRef
1082 static ULONG WINAPI IFSFldr_PersistFolder3_AddRef (IPersistFolder3 * iface)
1084 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1086 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
1088 return IUnknown_AddRef (This->pUnkOuter);
1091 /************************************************************************
1092 * IFSFldr_PersistFolder3_Release
1095 static ULONG WINAPI IFSFldr_PersistFolder3_Release (IPersistFolder3 * iface)
1097 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1099 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
1101 return IUnknown_Release (This->pUnkOuter);
1104 /************************************************************************
1105 * IFSFldr_PersistFolder3_GetClassID
1107 static HRESULT WINAPI IFSFldr_PersistFolder3_GetClassID (IPersistFolder3 * iface, CLSID * lpClassId)
1109 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1111 TRACE ("(%p)\n", This);
1113 if (!lpClassId)
1114 return E_POINTER;
1115 *lpClassId = *This->pclsid;
1117 return S_OK;
1120 /************************************************************************
1121 * IFSFldr_PersistFolder3_Initialize
1123 * NOTES
1124 * sPathTarget is not set. Don't know how to handle in a non rooted environment.
1126 static HRESULT WINAPI IFSFldr_PersistFolder3_Initialize (IPersistFolder3 * iface, LPCITEMIDLIST pidl)
1128 char sTemp[MAX_PATH];
1130 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1132 TRACE ("(%p)->(%p)\n", This, pidl);
1134 if (This->pidlRoot)
1135 SHFree (This->pidlRoot); /* free the old pidl */
1136 This->pidlRoot = ILClone (pidl); /* set my pidl */
1138 if (This->sPathTarget)
1139 SHFree (This->sPathTarget);
1141 /* set my path */
1142 if (SHGetPathFromIDListA (pidl, sTemp)) {
1143 This->sPathTarget = SHAlloc (strlen (sTemp) + 1);
1144 strcpy (This->sPathTarget, sTemp);
1147 TRACE ("--(%p)->(%s)\n", This, This->sPathTarget);
1148 return S_OK;
1151 /**************************************************************************
1152 * IFSFldr_PersistFolder3_GetCurFolder
1154 static HRESULT WINAPI IFSFldr_PersistFolder3_fnGetCurFolder (IPersistFolder3 * iface, LPITEMIDLIST * pidl)
1156 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1158 TRACE ("(%p)->(%p)\n", This, pidl);
1160 if (!pidl) return E_POINTER;
1161 *pidl = ILClone (This->pidlRoot);
1162 return S_OK;
1165 /**************************************************************************
1166 * IFSFldr_PersistFolder3_InitializeEx
1168 * FIXME: errorhandling
1170 static HRESULT WINAPI
1171 IFSFldr_PersistFolder3_InitializeEx (IPersistFolder3 * iface,
1172 IBindCtx * pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO * ppfti)
1174 char sTemp[MAX_PATH];
1176 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1178 TRACE ("(%p)->(%p,%p,%p)\n", This, pbc, pidlRoot, ppfti);
1179 if (ppfti)
1180 TRACE ("--%p %s %s 0x%08lx 0x%08x\n",
1181 ppfti->pidlTargetFolder, debugstr_w (ppfti->szTargetParsingName),
1182 debugstr_w (ppfti->szNetworkProvider), ppfti->dwAttributes, ppfti->csidl);
1184 pdump (pidlRoot);
1185 if (ppfti && ppfti->pidlTargetFolder)
1186 pdump (ppfti->pidlTargetFolder);
1188 if (This->pidlRoot)
1189 __SHFreeAndNil (&This->pidlRoot); /* free the old */
1190 if (This->sPathTarget)
1191 __SHFreeAndNil (&This->sPathTarget);
1194 * Root path and pidl
1196 This->pidlRoot = ILClone (pidlRoot);
1199 * the target folder is spezified in csidl OR pidlTargetFolder OR szTargetParsingName
1201 if (ppfti) {
1202 if (ppfti->csidl != -1) {
1203 if (SHGetSpecialFolderPathA (0, sTemp, ppfti->csidl, ppfti->csidl & CSIDL_FLAG_CREATE)) {
1204 __SHCloneStrA (&This->sPathTarget, sTemp);
1206 } else if (ppfti->szTargetParsingName[0]) {
1207 __SHCloneStrWtoA (&This->sPathTarget, ppfti->szTargetParsingName);
1208 } else if (ppfti->pidlTargetFolder) {
1209 if (SHGetPathFromIDListA (ppfti->pidlTargetFolder, sTemp)) {
1210 __SHCloneStrA (&This->sPathTarget, sTemp);
1215 TRACE ("--(%p)->(target=%s)\n", This, debugstr_a (This->sPathTarget));
1216 pdump (This->pidlRoot);
1217 return (This->sPathTarget) ? S_OK : E_FAIL;
1220 static HRESULT WINAPI
1221 IFSFldr_PersistFolder3_GetFolderTargetInfo (IPersistFolder3 * iface, PERSIST_FOLDER_TARGET_INFO * ppfti)
1223 _ICOM_THIS_From_IPersistFolder3 (IGenericSFImpl, iface);
1224 FIXME ("(%p)->(%p)\n", This, ppfti);
1225 ZeroMemory (ppfti, sizeof (ppfti));
1226 return E_NOTIMPL;
1229 static ICOM_VTABLE (IPersistFolder3) vt_FSFldr_PersistFolder3 =
1231 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1232 IFSFldr_PersistFolder3_QueryInterface,
1233 IFSFldr_PersistFolder3_AddRef,
1234 IFSFldr_PersistFolder3_Release,
1235 IFSFldr_PersistFolder3_GetClassID,
1236 IFSFldr_PersistFolder3_Initialize,
1237 IFSFldr_PersistFolder3_fnGetCurFolder,
1238 IFSFldr_PersistFolder3_InitializeEx,
1239 IFSFldr_PersistFolder3_GetFolderTargetInfo
1242 /****************************************************************************
1243 * ISFDropTarget implementation
1245 static BOOL ISFDropTarget_QueryDrop (IDropTarget * iface, DWORD dwKeyState, LPDWORD pdwEffect)
1247 DWORD dwEffect = *pdwEffect;
1249 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1251 *pdwEffect = DROPEFFECT_NONE;
1253 if (This->fAcceptFmt) { /* Does our interpretation of the keystate ... */
1254 *pdwEffect = KeyStateToDropEffect (dwKeyState);
1256 /* ... matches the desired effect ? */
1257 if (dwEffect & *pdwEffect) {
1258 return TRUE;
1261 return FALSE;
1264 static HRESULT WINAPI ISFDropTarget_QueryInterface (IDropTarget * iface, REFIID riid, LPVOID * ppvObj)
1266 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1268 TRACE ("(%p)\n", This);
1270 return IUnknown_QueryInterface (This->pUnkOuter, riid, ppvObj);
1273 static ULONG WINAPI ISFDropTarget_AddRef (IDropTarget * iface)
1275 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1277 TRACE ("(%p)\n", This);
1279 return IUnknown_AddRef (This->pUnkOuter);
1282 static ULONG WINAPI ISFDropTarget_Release (IDropTarget * iface)
1284 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1286 TRACE ("(%p)\n", This);
1288 return IUnknown_Release (This->pUnkOuter);
1291 static HRESULT WINAPI
1292 ISFDropTarget_DragEnter (IDropTarget * iface, IDataObject * pDataObject, DWORD dwKeyState, POINTL pt, DWORD * pdwEffect)
1294 FORMATETC fmt;
1296 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1298 TRACE ("(%p)->(DataObject=%p)\n", This, pDataObject);
1300 InitFormatEtc (fmt, This->cfShellIDList, TYMED_HGLOBAL);
1302 This->fAcceptFmt = (S_OK == IDataObject_QueryGetData (pDataObject, &fmt)) ? TRUE : FALSE;
1304 ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect);
1306 return S_OK;
1309 static HRESULT WINAPI ISFDropTarget_DragOver (IDropTarget * iface, DWORD dwKeyState, POINTL pt, DWORD * pdwEffect)
1311 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1313 TRACE ("(%p)\n", This);
1315 if (!pdwEffect)
1316 return E_INVALIDARG;
1318 ISFDropTarget_QueryDrop (iface, dwKeyState, pdwEffect);
1320 return S_OK;
1323 static HRESULT WINAPI ISFDropTarget_DragLeave (IDropTarget * iface)
1325 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1327 TRACE ("(%p)\n", This);
1329 This->fAcceptFmt = FALSE;
1331 return S_OK;
1334 static HRESULT WINAPI
1335 ISFDropTarget_Drop (IDropTarget * iface, IDataObject * pDataObject, DWORD dwKeyState, POINTL pt, DWORD * pdwEffect)
1337 _ICOM_THIS_From_IDropTarget (IGenericSFImpl, iface);
1339 FIXME ("(%p) object dropped\n", This);
1341 return E_NOTIMPL;
1344 static struct ICOM_VTABLE (IDropTarget) dtvt = {
1345 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1346 ISFDropTarget_QueryInterface,
1347 ISFDropTarget_AddRef,
1348 ISFDropTarget_Release,
1349 ISFDropTarget_DragEnter,
1350 ISFDropTarget_DragOver,
1351 ISFDropTarget_DragLeave,
1352 ISFDropTarget_Drop