ReactOS 0.4.16-dev-197-g92996da
CMyDocsFolder.cpp
Go to the documentation of this file.
1/*
2 * Virtual MyDocuments Folder
3 *
4 * Copyright 2007 Johannes Anderwald
5 * Copyright 2009 Andrew Hill
6 *
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.
11 *
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.
16 *
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
20 */
21
22#include <precomp.h>
23
25
27{
29}
30
32{
33 if(m_pidlInner)
35}
36
38{
40
41 if (!m_pidlInner)
42 return E_OUTOFMEMORY;
43
44 return S_OK;
45}
46
48{
50
51 if (m_pisfInner)
52 return S_OK;
53
54
56 &CLSID_ShellFSFolder,
59
61 return hr;
62
63 return S_OK;
64}
65
67 ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes)
68{
70 if (FAILED(hr))
71 return hr;
72
73 return m_pisfInner->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes);
74}
75
76HRESULT WINAPI CMyDocsFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
77{
79 if (FAILED(hr))
80 return hr;
81
82 return m_pisfInner->EnumObjects(hwndOwner, dwFlags, ppEnumIDList);
83}
84
86{
88 if (FAILED(hr))
89 return hr;
90
91 return m_pisfInner->BindToObject(pidl, pbcReserved, riid, ppvOut);
92}
93
95{
97 if (FAILED(hr))
98 return hr;
99
100 return m_pisfInner->BindToStorage(pidl, pbcReserved, riid, ppvOut);
101}
102
104{
106 if (FAILED(hr))
107 return hr;
108
109 return m_pisfInner->CompareIDs(lParam, pidl1, pidl2);
110}
111
113{
115 if (FAILED(hr))
116 return hr;
117
118 return m_pisfInner->CreateViewObject(hwndOwner, riid, ppvOut);
119}
120
122{
123 static const DWORD dwMyDocumentsAttributes =
124 SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR | SFGAO_CANCOPY |
125 SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER | SFGAO_CANRENAME | SFGAO_CANDELETE;
126
128 if (FAILED(hr))
129 return hr;
130
131 if(cidl)
132 return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut);
133
134 if (!rgfInOut)
135 return E_INVALIDARG;
136
137 if (*rgfInOut == 0)
138 *rgfInOut = ~0;
139
140 *rgfInOut &= dwMyDocumentsAttributes;
141
142 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
143 *rgfInOut &= ~SFGAO_VALIDATE;
144
145 return S_OK;
146}
147
149 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
150{
152 if (FAILED(hr))
153 return hr;
154
155 return m_pisfInner->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut);
156}
157
159{
160 if (!strRet || !pidl)
161 return E_INVALIDARG;
162
164 if (FAILED(hr))
165 return hr;
166
167 /* If we got an fs item just forward to the fs folder */
168 if (!_ILIsSpecialFolder(pidl))
169 return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
170
171 /* The caller wants our path. Let fs folder handle it */
174 {
175 /* Give an empty pidl to the fs folder to make it tell us its path */
176 if (pidl->mkid.cb)
177 pidl = ILGetNext(pidl);
178 return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
179 }
180
181 ERR("Got empty pidl without SHGDN_FORPARSING\n");
182 return E_INVALIDARG;
183}
184
186 LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut)
187{
189 if (FAILED(hr))
190 return hr;
191
192 return m_pisfInner->SetNameOf(hwndOwner, pidl, lpName, dwFlags, pPidlOut);
193}
194
196{
198 if (FAILED(hr))
199 return hr;
200
201 return m_pisfInner->GetDefaultSearchGUID(pguid);
202}
203
205{
207 if (FAILED(hr))
208 return hr;
209
210 return m_pisfInner->EnumSearches(ppenum);
211}
212
214{
216 if (FAILED(hr))
217 return hr;
218
219 return m_pisfInner->GetDefaultColumn(dwRes, pSort, pDisplay);
220}
221
223{
225 if (FAILED(hr))
226 return hr;
227
228 return m_pisfInner->GetDefaultColumnState(iColumn, pcsFlags);
229}
230
232{
234 if (FAILED(hr))
235 return hr;
236
237 return m_pisfInner->GetDetailsEx(pidl, pscid, pv);
238}
239
241{
243 if (FAILED(hr))
244 return hr;
245
246 return m_pisfInner->GetDetailsOf(pidl, iColumn, psd);
247}
248
250{
252 if (FAILED(hr))
253 return hr;
254
255 return m_pisfInner->MapColumnToSCID(column, pscid);
256}
257
259{
260 if (!lpClassId)
261 return E_POINTER;
262
263 memcpy(lpClassId, &CLSID_MyDocuments, sizeof(GUID));
264
265 return S_OK;
266}
267
269{
270 if (m_pisfInner)
271 return E_INVALIDARG;
272
273 if (m_pidlInner)
275
276 m_pidlInner = ILClone(pidl);
277
278 if (!m_pidlInner)
279 return E_OUTOFMEMORY;
280
281 return EnsureFolder();
282}
283
285{
286 if (!pidl)
287 return E_POINTER;
288 *pidl = ILClone(m_pidlInner);
289 return S_OK;
290}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
static HRESULT SHELL32_CoCreateInitSF(LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidlChild, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
Definition: CFindFolder.cpp:13
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ERR(fmt,...)
Definition: precomp.h:57
STDMETHOD() GetDefaultSearchGUID(GUID *pguid) override
STDMETHOD() GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) override
STDMETHOD() CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) override
STDMETHOD() EnumSearches(IEnumExtraSearch **ppenum) override
STDMETHOD() CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) override
STDMETHOD() BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override
LPITEMIDLIST m_pidlInner
Definition: CMyDocsFolder.h:34
HRESULT EnsureFolder()
STDMETHOD() GetCurFolder(PIDLIST_ABSOLUTE *pidl) override
CComPtr< IShellFolder2 > m_pisfInner
Definition: CMyDocsFolder.h:33
STDMETHOD() GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) override
STDMETHOD() MapColumnToSCID(UINT column, SHCOLUMNID *pscid) override
STDMETHOD() GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) override
STDMETHOD() GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut) override
HRESULT WINAPI FinalConstruct()
STDMETHOD() GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) override
STDMETHOD() BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override
STDMETHOD() EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) override
STDMETHOD() GetClassID(CLSID *lpClassId) override
STDMETHOD() Initialize(PCIDLIST_ABSOLUTE pidl) override
STDMETHOD() GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) override
STDMETHOD() GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) override
STDMETHOD() ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes) override
STDMETHOD() SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) override
LPARAM lParam
Definition: combotst.c:139
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define GET_SHGDN_RELATION(dwFlags)
Definition: precomp.h:53
#define GET_SHGDN_FOR(dwFlags)
Definition: precomp.h:52
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static LPOLESTR
Definition: stg_prop.c:27
unsigned int UINT
Definition: ndis.h:50
interface IBindCtx * LPBC
Definition: objfwd.h:18
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237
BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:1998
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:872
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1658
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_PERSONAL
Definition: shlobj.h:2178
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
uint32_t ULONG
Definition: typedefs.h:59
_In_ LPCSTR lpName
Definition: winbase.h:2813
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define E_POINTER
Definition: winerror.h:2365
#define IID_PPV_ARG(Itype, ppType)