2 * IShellItem implementation
4 * Copyright 2008 Vincent Povirk for CodeWeavers
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"
28 #define NONAMELESSUNION
29 #define NONAMELESSSTRUCT
33 #include "wine/debug.h"
36 #include "shell32_main.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
41 typedef struct _ShellItem
{
42 const IShellItemVtbl
*lpIShellItemVtbl
;
45 const IPersistIDListVtbl
*lpIPersistIDListVtbl
;
49 static inline ShellItem
*impl_from_IPersistIDList( IPersistIDList
*iface
)
51 return (ShellItem
*)((char*)iface
- FIELD_OFFSET(ShellItem
, lpIPersistIDListVtbl
));
55 static HRESULT WINAPI
ShellItem_QueryInterface(IShellItem
*iface
, REFIID riid
,
58 ShellItem
*This
= (ShellItem
*)iface
;
60 TRACE("(%p,%p,%p)\n", iface
, riid
, ppv
);
62 if (!ppv
) return E_INVALIDARG
;
64 if (IsEqualIID(&IID_IUnknown
, riid
) || IsEqualIID(&IID_IShellItem
, riid
))
68 else if (IsEqualIID(&IID_IPersist
, riid
) || IsEqualIID(&IID_IPersistIDList
, riid
))
70 *ppv
= &(This
->lpIPersistIDListVtbl
);
73 FIXME("not implemented for %s\n", shdebugstr_guid(riid
));
78 IUnknown_AddRef((IUnknown
*)*ppv
);
82 static ULONG WINAPI
ShellItem_AddRef(IShellItem
*iface
)
84 ShellItem
*This
= (ShellItem
*)iface
;
85 ULONG ref
= InterlockedIncrement(&This
->ref
);
87 TRACE("(%p), new refcount=%i\n", iface
, ref
);
92 static ULONG WINAPI
ShellItem_Release(IShellItem
*iface
)
94 ShellItem
*This
= (ShellItem
*)iface
;
95 ULONG ref
= InterlockedDecrement(&This
->ref
);
97 TRACE("(%p), new refcount=%i\n", iface
, ref
);
102 HeapFree(GetProcessHeap(), 0, This
);
108 static HRESULT WINAPI
ShellItem_BindToHandler(IShellItem
*iface
, IBindCtx
*pbc
,
109 REFGUID rbhid
, REFIID riid
, void **ppvOut
)
111 FIXME("(%p,%p,%s,%p,%p)\n", iface
, pbc
, shdebugstr_guid(rbhid
), riid
, ppvOut
);
118 static HRESULT WINAPI
ShellItem_GetParent(IShellItem
*iface
, IShellItem
**ppsi
)
120 FIXME("(%p,%p)\n", iface
, ppsi
);
127 static HRESULT WINAPI
ShellItem_GetDisplayName(IShellItem
*iface
, SIGDN sigdnName
,
130 FIXME("(%p,%x,%p)\n", iface
, sigdnName
, ppszName
);
137 static HRESULT WINAPI
ShellItem_GetAttributes(IShellItem
*iface
, SFGAOF sfgaoMask
,
138 SFGAOF
*psfgaoAttribs
)
140 FIXME("(%p,%x,%p)\n", iface
, sfgaoMask
, psfgaoAttribs
);
147 static HRESULT WINAPI
ShellItem_Compare(IShellItem
*iface
, IShellItem
*oth
,
148 SICHINTF hint
, int *piOrder
)
150 FIXME("(%p,%p,%x,%p)\n", iface
, oth
, hint
, piOrder
);
155 static const IShellItemVtbl ShellItem_Vtbl
= {
156 ShellItem_QueryInterface
,
159 ShellItem_BindToHandler
,
161 ShellItem_GetDisplayName
,
162 ShellItem_GetAttributes
,
167 static HRESULT
ShellItem_GetClassID(ShellItem
* This
, CLSID
*pClassID
)
169 TRACE("(%p,%p)\n", This
, pClassID
);
171 *pClassID
= CLSID_ShellItem
;
176 static HRESULT WINAPI
ShellItem_IPersistIDList_QueryInterface(IPersistIDList
*iface
,
177 REFIID riid
, void **ppv
)
179 ShellItem
*This
= impl_from_IPersistIDList(iface
);
180 return ShellItem_QueryInterface((IShellItem
*)This
, riid
, ppv
);
183 static ULONG WINAPI
ShellItem_IPersistIDList_AddRef(IPersistIDList
*iface
)
185 ShellItem
*This
= impl_from_IPersistIDList(iface
);
186 return ShellItem_AddRef((IShellItem
*)This
);
189 static ULONG WINAPI
ShellItem_IPersistIDList_Release(IPersistIDList
*iface
)
191 ShellItem
*This
= impl_from_IPersistIDList(iface
);
192 return ShellItem_Release((IShellItem
*)This
);
195 static HRESULT WINAPI
ShellItem_IPersistIDList_GetClassID(IPersistIDList
* iface
,
198 ShellItem
*This
= impl_from_IPersistIDList(iface
);
200 return ShellItem_GetClassID(This
, pClassID
);
203 static HRESULT WINAPI
ShellItem_IPersistIDList_SetIDList(IPersistIDList
* iface
,
206 ShellItem
*This
= impl_from_IPersistIDList(iface
);
207 LPITEMIDLIST new_pidl
;
209 TRACE("(%p,%p)\n", This
, pidl
);
211 new_pidl
= ILClone(pidl
);
216 This
->pidl
= new_pidl
;
220 return E_OUTOFMEMORY
;
223 static HRESULT WINAPI
ShellItem_IPersistIDList_GetIDList(IPersistIDList
* iface
,
226 ShellItem
*This
= impl_from_IPersistIDList(iface
);
228 TRACE("(%p,%p)\n", This
, ppidl
);
230 *ppidl
= ILClone(This
->pidl
);
234 return E_OUTOFMEMORY
;
237 static const IPersistIDListVtbl ShellItem_IPersistIDList_Vtbl
= {
238 ShellItem_IPersistIDList_QueryInterface
,
239 ShellItem_IPersistIDList_AddRef
,
240 ShellItem_IPersistIDList_Release
,
241 ShellItem_IPersistIDList_GetClassID
,
242 ShellItem_IPersistIDList_SetIDList
,
243 ShellItem_IPersistIDList_GetIDList
247 HRESULT WINAPI
IShellItem_Constructor(IUnknown
*pUnkOuter
, REFIID riid
, void **ppv
)
252 TRACE("(%p,%s)\n",pUnkOuter
, debugstr_guid(riid
));
256 if (pUnkOuter
) return CLASS_E_NOAGGREGATION
;
258 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(ShellItem
));
259 This
->lpIShellItemVtbl
= &ShellItem_Vtbl
;
262 This
->lpIPersistIDListVtbl
= &ShellItem_IPersistIDList_Vtbl
;
264 ret
= ShellItem_QueryInterface((IShellItem
*)This
, riid
, ppv
);
265 ShellItem_Release((IShellItem
*)This
);
270 HRESULT WINAPI
SHCreateShellItem(LPCITEMIDLIST pidlParent
,
271 IShellFolder
*psfParent
, LPCITEMIDLIST pidl
, IShellItem
**ppsi
)
274 LPITEMIDLIST new_pidl
;
277 TRACE("(%p,%p,%p,%p)\n", pidlParent
, psfParent
, pidl
, ppsi
);
279 if (!pidlParent
&& !psfParent
&& pidl
)
281 new_pidl
= ILClone(pidl
);
283 return E_OUTOFMEMORY
;
287 FIXME("(%p,%p,%p) not implemented\n", pidlParent
, psfParent
, pidl
);
288 return E_NOINTERFACE
;
291 ret
= IShellItem_Constructor(NULL
, &IID_IShellItem
, (void**)&This
);
294 *ppsi
= (IShellItem
*)This
;
295 This
->pidl
= new_pidl
;