ReactOS  0.4.13-dev-79-gcd489d8
CFolderItems.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: shell32
3  * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4  * PURPOSE: FolderItem(s) implementation
5  * COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
11 
12 
14 {
15 }
16 
18 {
19 }
20 
22 {
23  m_idlist.Attach(ILClone(idlist));
24  m_Folder = folder;
25  return S_OK;
26 }
27 
28 // *** FolderItem methods ***
30 {
31  TRACE("(%p, %p)\n", this, ppid);
32  return m_Folder->get_Application(ppid);
33 }
34 
36 {
37  TRACE("(%p, %p)\n", this, ppid);
38  if (ppid)
39  {
40  *ppid = m_Folder;
41  m_Folder->AddRef();
42  }
43  return E_NOTIMPL;
44 }
45 
47 {
48  TRACE("(%p, %p)\n", this, pbs);
49 
50  *pbs = NULL;
51 
53  LPCITEMIDLIST last_part;
56  return hr;
57 
58  STRRET strret;
59  hr = Parent->GetDisplayNameOf(last_part, SHGDN_INFOLDER, &strret);
60  if (!FAILED_UNEXPECTEDLY(hr))
61  hr = StrRetToBSTR(&strret, last_part, pbs);
62 
63  return hr;
64 }
65 
67 {
68  TRACE("(%p, %s)\n", this, wine_dbgstr_w(bs));
69  return E_NOTIMPL;
70 }
71 
73 {
74  CComPtr<IShellFolder> psfDesktop;
75 
76  HRESULT hr = SHGetDesktopFolder(&psfDesktop);
77  if (!SUCCEEDED(hr))
78  return hr;
79 
80  STRRET strret;
81  hr = psfDesktop->GetDisplayNameOf(m_idlist, SHGDN_FORPARSING, &strret);
83  return hr;
84 
85  return StrRetToBSTR(&strret, NULL, pbs);
86 }
87 
89 {
90  TRACE("(%p, %p)\n", this, ppid);
91  return E_NOTIMPL;
92 }
93 
95 {
96  TRACE("(%p, %p)\n", this, ppid);
97  return E_NOTIMPL;
98 }
99 
101 {
102  TRACE("(%p, %p)\n", this, pb);
103  return E_NOTIMPL;
104 }
105 
107 {
108  TRACE("(%p, %p)\n", this, pb);
109  return E_NOTIMPL;
110 }
111 
113 {
114  TRACE("(%p, %p)\n", this, pb);
115  return E_NOTIMPL;
116 }
117 
119 {
120  TRACE("(%p, %p)\n", this, pb);
121  return E_NOTIMPL;
122 }
123 
125 {
126  TRACE("(%p, %p)\n", this, pdt);
127  return E_NOTIMPL;
128 }
129 
131 {
132  TRACE("(%p, %f)\n", this, dt);
133  return E_NOTIMPL;
134 }
135 
137 {
138  TRACE("(%p, %p)\n", this, pul);
139  return E_NOTIMPL;
140 }
141 
143 {
144  TRACE("(%p, %p)\n", this, pbs);
145  return E_NOTIMPL;
146 }
147 
149 {
150  if (!ppfic)
151  return E_POINTER;
153  HRESULT hr = verbs->Init(m_idlist);
154  if (FAILED_UNEXPECTEDLY(hr))
155  {
156  delete verbs;
157  return hr;
158  }
159  verbs->AddRef();
160  *ppfic = verbs;
161  return S_OK;
162 }
163 
165 {
166  TRACE("(%p, %s)\n", this, wine_dbgstr_variant(&vVerb));
167  return E_NOTIMPL;
168 }
169 
170 
171 
173  :m_Count(-1)
174 {
175 }
176 
178 {
179 }
180 
182 {
183  CComPtr<IShellFolder> psfDesktop, psfTarget;
184 
185  m_idlist.Attach(ILClone(idlist));
186 
187  HRESULT hr = SHGetDesktopFolder(&psfDesktop);
188  if (FAILED_UNEXPECTEDLY(hr))
189  return hr;
190 
191  hr = psfDesktop->BindToObject(m_idlist, NULL, IID_PPV_ARG(IShellFolder, &psfTarget));
192  if (FAILED_UNEXPECTEDLY(hr))
193  return hr;
194 
195  hr = psfTarget->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &m_EnumIDList);
196 
197  if (FAILED_UNEXPECTEDLY(hr))
198  return hr;
199 
200  m_Folder = parent;
201  return S_OK;
202 }
203 
204 // *** FolderItems methods ***
206 {
207  if (!m_EnumIDList)
208  return E_FAIL;
209 
210  if (!plCount)
211  return E_POINTER;
212 
213  if (m_Count == -1)
214  {
215  long count = 0;
216 
217  HRESULT hr = m_EnumIDList->Reset();
218  if (FAILED_UNEXPECTEDLY(hr))
219  return hr;
220 
222  while ((hr = m_EnumIDList->Next(1, &Pidl, 0)) != S_FALSE)
223  {
224  count++;
225  Pidl.Free();
226  }
227  m_Count = count;
228  }
229  *plCount = m_Count;
230 
231  return S_OK;
232 }
233 
235 {
236  TRACE("(%p, %p)\n", this, ppid);
237  return m_Folder->get_Application(ppid);
238 }
239 
241 {
242  TRACE("(%p, %p)\n", this, ppid);
243 
244  if (ppid)
245  *ppid = NULL;
246 
247  return E_NOTIMPL;
248 }
249 
251 {
252  if (!m_EnumIDList)
253  return E_FAIL;
254 
255  if (V_VT(&index) == VT_I2)
257 
258  if (V_VT(&index) == VT_I4)
259  {
260  ULONG count = V_UI4(&index);
261 
262  HRESULT hr = m_EnumIDList->Reset();
263  if (FAILED_UNEXPECTEDLY(hr))
264  return hr;
265 
266  hr = m_EnumIDList->Skip(count);
267 
268  if (FAILED_UNEXPECTEDLY(hr))
269  return hr;
270 
272  hr = m_EnumIDList->Next(1, &spPidl, 0);
273  if (FAILED_UNEXPECTEDLY(hr))
274  return hr;
275  hr = ShellObjectCreatorInit<CFolderItem>(m_Folder, static_cast<LPITEMIDLIST>(spPidl), IID_PPV_ARG(FolderItem, ppid));
276  if (FAILED_UNEXPECTEDLY(hr))
277  return hr;
278  return hr;
279  }
280  else if (V_VT(&index) == VT_BSTR)
281  {
282  if (!V_BSTR(&index))
283  return S_FALSE;
284 
285  HRESULT hr = m_Folder->ParseName(V_BSTR(&index), ppid);
286  if (FAILED_UNEXPECTEDLY(hr))
287  return hr;
288  return hr;
289  }
290 
291  FIXME("Index type %d not handled.\n", V_VT(&index));
292  return E_NOTIMPL;
293 }
294 
296 {
297  return ShellObjectCreatorInit<CFolderItems>(static_cast<LPITEMIDLIST>(m_idlist), m_Folder, IID_FolderItems, reinterpret_cast<void**>(ppunk));
298 }
299 
CComPtr< Folder > m_Folder
Definition: CFolderItems.h:65
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:965
Definition: compat.h:1939
Definition: fci.c:115
CComHeapPtr< ITEMIDLIST > m_idlist
Definition: CFolderItems.h:18
HRESULT hr
Definition: shlfolder.c:183
virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch **ppid)
virtual HRESULT STDMETHODCALLTYPE get_Size(LONG *pul)
CComPtr< Folder > m_Folder
Definition: CFolderItems.h:19
GLuint GLuint GLsizei count
Definition: gl.h:1545
virtual HRESULT STDMETHODCALLTYPE Verbs(FolderItemVerbs **ppfic)
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define wine_dbgstr_w
Definition: kernel32.h:34
double DATE
Definition: compat.h:1894
HRESULT Initialize(Folder *folder, LPITEMIDLIST idlist)
HRESULT Initialize(LPITEMIDLIST idlist, Folder *parent)
virtual HRESULT STDMETHODCALLTYPE put_ModifyDate(DATE dt)
virtual HRESULT STDMETHODCALLTYPE get_GetFolder(IDispatch **ppid)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:716
OLECHAR * BSTR
Definition: compat.h:1934
virtual HRESULT STDMETHODCALLTYPE get_IsLink(VARIANT_BOOL *pb)
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
short VARIANT_BOOL
Definition: compat.h:1931
long LONG
Definition: pedump.c:60
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_FALSE
Definition: winerror.h:2357
virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppid)
virtual HRESULT STDMETHODCALLTYPE InvokeVerb(VARIANT vVerb)
smooth NULL
Definition: ftsmooth.c:416
virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch **ppid)
GLuint index
Definition: glext.h:6031
struct CFFOLDER folder
Definition: fdi.c:110
coclass Shell32::ShellFolderViewOC FolderItem
virtual HRESULT STDMETHODCALLTYPE get_Path(BSTR *pbs)
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
CComPtr< IEnumIDList > m_EnumIDList
Definition: CFolderItems.h:64
r parent
Definition: btrfs.c:2659
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define V_UI4(A)
Definition: oleauto.h:270
virtual HRESULT STDMETHODCALLTYPE Item(VARIANT index, FolderItem **ppid)
virtual HRESULT STDMETHODCALLTYPE get_Type(BSTR *pbs)
#define V_VT(A)
Definition: oleauto.h:211
virtual HRESULT STDMETHODCALLTYPE put_Name(BSTR bs)
HRESULT WINAPI StrRetToBSTR(STRRET *lpStrRet, LPCITEMIDLIST pidl, BSTR *pBstrOut)
Definition: string.c:1686
virtual HRESULT STDMETHODCALLTYPE get_ModifyDate(DATE *pdt)
#define V_BSTR(A)
Definition: oleauto.h:226
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1323
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define E_NOTIMPL
Definition: ddrawi.h:99
WINE_DEFAULT_DEBUG_CHANNEL(shell)
virtual HRESULT STDMETHODCALLTYPE get_IsBrowsable(VARIANT_BOOL *pb)
virtual HRESULT STDMETHODCALLTYPE _NewEnum(IUnknown **ppunk)
virtual HRESULT STDMETHODCALLTYPE get_Name(BSTR *pbs)
virtual HRESULT STDMETHODCALLTYPE get_IsFolder(VARIANT_BOOL *pb)
unsigned int ULONG
Definition: retypes.h:1
HRESULT Init(LPITEMIDLIST idlist)
CComHeapPtr< ITEMIDLIST > m_idlist
Definition: CFolderItems.h:63
virtual HRESULT STDMETHODCALLTYPE get_Count(long *plCount)
#define E_POINTER
Definition: winerror.h:2365
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
virtual HRESULT STDMETHODCALLTYPE get_Application(IDispatch **ppid)
virtual HRESULT STDMETHODCALLTYPE get_IsFileSystem(VARIANT_BOOL *pb)
Definition: compat.h:1938
virtual HRESULT STDMETHODCALLTYPE get_GetLink(IDispatch **ppid)
#define SUCCEEDED(hr)
Definition: intsafe.h:57