2 * IShellItem implementation
4 * Copyright 2008 Vincent Povirk for CodeWeavers
5 * Copyright 2009 Andrew Hill
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
24 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
26 EXTERN_C HRESULT WINAPI
SHCreateShellItem(LPCITEMIDLIST pidlParent
,
27 IShellFolder
*psfParent
, LPCITEMIDLIST pidl
, IShellItem
**ppsi
);
29 ShellItem::ShellItem()
34 ShellItem::~ShellItem()
39 HRESULT
ShellItem::get_parent_pidl(LPITEMIDLIST
*parent_pidl
)
41 *parent_pidl
= ILClone(pidl
);
44 if (ILRemoveLastID(*parent_pidl
))
60 HRESULT
ShellItem::get_parent_shellfolder(IShellFolder
**ppsf
)
62 LPITEMIDLIST parent_pidl
;
63 CComPtr
<IShellFolder
> desktop
;
66 ret
= get_parent_pidl(&parent_pidl
);
69 ret
= SHGetDesktopFolder(&desktop
);
71 ret
= desktop
->BindToObject(parent_pidl
, NULL
, IID_IShellFolder
, (void**)ppsf
);
78 HRESULT WINAPI
ShellItem::BindToHandler(IBindCtx
*pbc
, REFGUID rbhid
, REFIID riid
, void **ppvOut
)
80 FIXME("(%p,%p,%s,%p,%p)\n", this, pbc
, shdebugstr_guid(&rbhid
), riid
, ppvOut
);
87 HRESULT WINAPI
ShellItem::GetParent(IShellItem
**ppsi
)
89 LPITEMIDLIST parent_pidl
;
92 TRACE("(%p,%p)\n", this, ppsi
);
94 ret
= get_parent_pidl(&parent_pidl
);
97 ret
= SHCreateShellItem(NULL
, NULL
, parent_pidl
, ppsi
);
104 HRESULT WINAPI
ShellItem::GetDisplayName(SIGDN sigdnName
, LPWSTR
*ppszName
)
106 FIXME("(%p,%x,%p)\n", this, sigdnName
, ppszName
);
113 HRESULT WINAPI
ShellItem::GetAttributes(SFGAOF sfgaoMask
, SFGAOF
*psfgaoAttribs
)
115 CComPtr
<IShellFolder
> parent_folder
;
116 LPITEMIDLIST child_pidl
;
119 TRACE("(%p,%x,%p)\n", this, sfgaoMask
, psfgaoAttribs
);
121 ret
= get_parent_shellfolder(&parent_folder
);
124 child_pidl
= ILFindLastID(pidl
);
125 *psfgaoAttribs
= sfgaoMask
;
126 ret
= parent_folder
->GetAttributesOf(1, (LPCITEMIDLIST
*)&child_pidl
, psfgaoAttribs
);
132 HRESULT WINAPI
ShellItem::Compare(IShellItem
*oth
, SICHINTF hint
, int *piOrder
)
134 FIXME("(%p,%p,%x,%p)\n", this, oth
, hint
, piOrder
);
139 HRESULT WINAPI
ShellItem::GetClassID(CLSID
*pClassID
)
141 TRACE("(%p,%p)\n", this, pClassID
);
143 *pClassID
= CLSID_ShellItem
;
148 HRESULT WINAPI
ShellItem::SetIDList(LPCITEMIDLIST pidlx
)
150 LPITEMIDLIST new_pidl
;
152 TRACE("(%p,%p)\n", this, pidlx
);
154 new_pidl
= ILClone(pidlx
);
163 return E_OUTOFMEMORY
;
166 HRESULT WINAPI
ShellItem::GetIDList(LPITEMIDLIST
*ppidl
)
168 TRACE("(%p,%p)\n", this, ppidl
);
170 *ppidl
= ILClone(pidl
);
174 return E_OUTOFMEMORY
;
177 HRESULT WINAPI
SHCreateShellItem(LPCITEMIDLIST pidlParent
,
178 IShellFolder
*psfParent
, LPCITEMIDLIST pidl
, IShellItem
**ppsi
)
180 IShellItem
*newShellItem
;
181 LPITEMIDLIST new_pidl
;
182 CComPtr
<IPersistIDList
> newPersistIDList
;
185 TRACE("(%p,%p,%p,%p)\n", pidlParent
, psfParent
, pidl
, ppsi
);
191 else if (pidlParent
|| psfParent
)
193 LPITEMIDLIST temp_parent
=NULL
;
196 CComPtr
<IPersistFolder2
> ppf2Parent
;
198 if (FAILED(psfParent
->QueryInterface(IID_IPersistFolder2
, (void**)&ppf2Parent
)))
200 FIXME("couldn't get IPersistFolder2 interface of parent\n");
201 return E_NOINTERFACE
;
204 if (FAILED(ppf2Parent
->GetCurFolder(&temp_parent
)))
206 FIXME("couldn't get parent PIDL\n");
207 return E_NOINTERFACE
;
210 pidlParent
= temp_parent
;
213 new_pidl
= ILCombine(pidlParent
, pidl
);
217 return E_OUTOFMEMORY
;
221 new_pidl
= ILClone(pidl
);
223 return E_OUTOFMEMORY
;
226 ret
= ShellItem::_CreatorClass::CreateInstance(NULL
, IID_IShellItem
, (void**)&newShellItem
);
233 ret
= newShellItem
->QueryInterface(IID_IPersistIDList
, (void **)&newPersistIDList
);
239 ret
= newPersistIDList
->SetIDList(new_pidl
);
246 *ppsi
= newShellItem
;