ReactOS 0.4.15-dev-8434-g155a7c7
CEnumMergedFolder Class Reference
Inheritance diagram for CEnumMergedFolder:
Collaboration diagram for CEnumMergedFolder:

Public Member Functions

 CEnumMergedFolder ()
 
virtual ~CEnumMergedFolder ()
 
int DsaDeleteCallback (LocalPidlInfo *info)
 
HRESULT SetSources (IShellFolder *userLocal, IShellFolder *allUSers)
 
HRESULT Begin (HWND hwndOwner, SHCONTF flags)
 
HRESULT FindPidlInList (HWND hwndOwner, LPCITEMIDLIST pcidl, LocalPidlInfo *pinfo)
 
HRESULT FindByName (HWND hwndOwner, LPCWSTR strParsingName, LocalPidlInfo *pinfo)
 
STDMETHOD() Next (ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched) override
 
STDMETHOD() Skip (ULONG celt) override
 
STDMETHOD() Reset () override
 
STDMETHOD() Clone (IEnumIDList **ppenum) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IEnumIDList
HRESULT Next ([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] PITEMID_CHILD *rgelt, [out] ULONG *pceltFetched)
 
HRESULT Skip ([in] ULONG celt)
 
HRESULT Reset ()
 
HRESULT Clone ([out] IEnumIDList **ppenum)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Static Public Member Functions

static int CALLBACK s_DsaDeleteCallback (void *pItem, void *pData)
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 

Private Attributes

CComPtr< IShellFolderm_UserLocalFolder
 
CComPtr< IShellFolderm_AllUSersFolder
 
HWND m_HwndOwner
 
SHCONTF m_Flags
 
HDSA m_hDsa
 
UINT m_hDsaIndex
 
UINT m_hDsaCount
 

Additional Inherited Members

- Public Types inherited from IEnumIDList
typedef IEnumIDListLPENUMIDLIST
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 37 of file CMergedFolder.cpp.

Constructor & Destructor Documentation

◆ CEnumMergedFolder()

CEnumMergedFolder::CEnumMergedFolder ( )

Definition at line 83 of file CMergedFolder.cpp.

83 :
87 m_Flags(0),
88 m_hDsa(NULL),
89 m_hDsaIndex(0),
91{
92}
CComPtr< IShellFolder > m_AllUSersFolder
CComPtr< IShellFolder > m_UserLocalFolder
#define NULL
Definition: types.h:112

◆ ~CEnumMergedFolder()

CEnumMergedFolder::~CEnumMergedFolder ( )
virtual

Definition at line 94 of file CMergedFolder.cpp.

95{
97}
static int CALLBACK s_DsaDeleteCallback(void *pItem, void *pData)
void WINAPI DSA_DestroyCallback(HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dsa.c:432

Member Function Documentation

◆ Begin()

HRESULT CEnumMergedFolder::Begin ( HWND  hwndOwner,
SHCONTF  flags 
)

Definition at line 124 of file CMergedFolder.cpp.

125{
126 HRESULT hr;
127 LPITEMIDLIST pidl = NULL;
128
129 if (m_hDsa && m_HwndOwner == hwndOwner && m_Flags == flags)
130 {
131 return Reset();
132 }
133
134 TRACE("Search conditions changed, recreating list...\n");
135
136 CComPtr<IEnumIDList> userLocal;
137 CComPtr<IEnumIDList> allUsers;
138
139 hr = m_UserLocalFolder->EnumObjects(hwndOwner, flags, &userLocal);
141 return hr;
142 hr = m_AllUSersFolder->EnumObjects(hwndOwner, flags, &allUsers);
144 return hr;
145
146 if (!m_hDsa)
147 {
148 m_hDsa = DSA_Create(sizeof(LocalPidlInfo), 10);
149 }
150
153 m_hDsaCount = 0;
154
155 // The sources are not ordered so load all of the items for the user folder first
156 TRACE("Loading Local entries...\n");
157 for (;;)
158 {
159 hr = userLocal->Next(1, &pidl, NULL);
161 return hr;
162
163 if (hr == S_FALSE)
164 break;
165
166 LPWSTR name;
167 STRRET str = { STRRET_WSTR };
168 hr = m_UserLocalFolder->GetDisplayNameOf(pidl, SHGDN_FORPARSING | SHGDN_INFOLDER, &str);
169 if (FAILED(hr))
170 return hr;
171 StrRetToStrW(&str, pidl, &name);
172
174 FALSE,
176 ILClone(pidl),
177 NULL,
178 name
179 };
180
181 ILFree(pidl);
182
183 TRACE("Inserting item %d with name %S\n", m_hDsaCount, name);
185 TRACE("New index: %d\n", idx);
186
187 m_hDsaCount++;
188 }
189
190 // Then load the items for the common folder
191 TRACE("Loading Common entries...\n");
192 for (;;)
193 {
194 hr = allUsers->Next(1, &pidl, NULL);
196 return hr;
197
198 if (hr == S_FALSE)
199 break;
200
201 LPWSTR name;
202 STRRET str = { STRRET_WSTR };
203 hr = m_AllUSersFolder->GetDisplayNameOf(pidl, SHGDN_FORPARSING | SHGDN_INFOLDER, &str);
204 if (FAILED(hr))
205 return hr;
206 StrRetToStrW(&str, pidl, &name);
207
209 FALSE,
211 ILClone(pidl),
212 NULL,
213 name
214 };
215
216 ILFree(pidl);
217
218 // Try to find an existing entry with the same name, and makr it as shared.
219 // FIXME: This is sub-optimal, a hash table would be a lot more efficient.
220 BOOL bShared = FALSE;
221 for (int i = 0; i < (int)m_hDsaCount; i++)
222 {
224
226 pInfo->parseName, lstrlenW(pInfo->parseName),
227 info.parseName, lstrlenW(info.parseName));
228
229 if (order == CSTR_EQUAL)
230 {
231 TRACE("Item name already exists! Marking '%S' as shared ...\n", name);
232 bShared = TRUE;
233 pInfo->shared = TRUE;
234 pInfo->pidl2 = info.pidl;
236 break;
237 }
238 }
239
240 // If an entry was not found, add a new one for this item
241 if (!bShared)
242 {
243 TRACE("Inserting item %d with name %S\n", m_hDsaCount, name);
245 TRACE("New index: %d\n", idx);
246
247 m_hDsaCount++;
248 }
249 }
250
251 m_HwndOwner = hwndOwner;
252 m_Flags = flags;
253
254 return Reset();
255}
STDMETHOD() Reset() override
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
#define lstrlenW
Definition: compat.h:750
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
LCID WINAPI GetThreadLocale(void)
Definition: locale.c:2800
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:4013
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1631
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
LPVOID WINAPI DSA_GetItemPtr(HDSA hdsa, INT nIndex)
Definition: dsa.c:162
VOID WINAPI DSA_EnumCallback(HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dsa.c:397
BOOL WINAPI DSA_DeleteAllItems(HDSA hdsa)
Definition: dsa.c:367
INT WINAPI DSA_InsertItem(HDSA hdsa, INT nIndex, LPVOID pSrc)
Definition: dsa.c:251
HDSA WINAPI DSA_Create(INT nSize, INT nGrow)
Definition: dsa.c:71
unsigned int BOOL
Definition: ntddk_ex.h:94
GLbitfield flags
Definition: glext.h:7161
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define FAILED(hr)
Definition: intsafe.h:51
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:940
#define DSA_APPEND
Definition: commctrl.h:4787
const WCHAR * str
HRESULT hr
Definition: shlfolder.c:183
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
@ STRRET_WSTR
Definition: shtypes.idl:85
#define TRACE(s)
Definition: solgame.cpp:4
LPITEMIDLIST pidl2
Definition: name.c:39
#define S_FALSE
Definition: winerror.h:2357
#define NORM_IGNORECASE
Definition: winnls.h:176
#define CSTR_EQUAL
Definition: winnls.h:456
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ Clone()

HRESULT STDMETHODCALLTYPE CEnumMergedFolder::Clone ( IEnumIDList **  ppenum)
override

Implements IEnumIDList.

Definition at line 376 of file CMergedFolder.cpp.

378{
380 return E_NOTIMPL;
381}
#define UNIMPLEMENTED
Definition: debug.h:118
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ DsaDeleteCallback()

int CEnumMergedFolder::DsaDeleteCallback ( LocalPidlInfo info)

Definition at line 99 of file CMergedFolder.cpp.

100{
101 ILFree(info->pidl);
102 if (info->pidl2)
103 ILFree(info->pidl2);
104 CoTaskMemFree((LPVOID)info->parseName);
105 return 0;
106}

Referenced by s_DsaDeleteCallback().

◆ FindByName()

HRESULT CEnumMergedFolder::FindByName ( HWND  hwndOwner,
LPCWSTR  strParsingName,
LocalPidlInfo pinfo 
)

Definition at line 295 of file CMergedFolder.cpp.

296{
297 if (!m_hDsa)
298 {
299 Begin(hwndOwner, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS);
300 }
301
302 TRACE("Searching for '%S' in a list of %d items\n", strParsingName, m_hDsaCount);
303
304 for (int i = 0; i < (int) m_hDsaCount; i++)
305 {
307 if (!pInfo)
308 return E_FAIL;
309
311 pInfo->parseName, lstrlenW(pInfo->parseName),
312 strParsingName, lstrlenW(strParsingName));
313 switch (order)
314 {
315 case CSTR_EQUAL:
316 *pinfo = *pInfo;
317 return S_OK;
318 default:
319 continue;
320 }
321 }
322
323 TRACE("Pidl not found\n");
325}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN Begin
Definition: acpixf.h:1301
#define E_FAIL
Definition: ddrawi.h:102
#define S_OK
Definition: intsafe.h:52
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

◆ FindPidlInList()

HRESULT CEnumMergedFolder::FindPidlInList ( HWND  hwndOwner,
LPCITEMIDLIST  pcidl,
LocalPidlInfo pinfo 
)

Definition at line 257 of file CMergedFolder.cpp.

258{
259 HRESULT hr;
260
261 if (!m_hDsa)
262 {
263 Begin(hwndOwner, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS);
264 }
265
266 TRACE("Searching for pidl { cb=%d } in a list of %d items\n", pcidl->mkid.cb, m_hDsaCount);
267
268 for (int i = 0; i < (int)m_hDsaCount; i++)
269 {
271 if (!pInfo)
272 return E_FAIL;
273
274 TRACE("Comparing with item at %d with parent %p and pidl { cb=%d }\n", i, pInfo->parent, pInfo->pidl->mkid.cb);
275
276 hr = pInfo->parent->CompareIDs(0, pInfo->pidl, pcidl);
278 return hr;
279
280 if (hr == S_OK)
281 {
282 *pinfo = *pInfo;
283 return S_OK;
284 }
285 else
286 {
287 TRACE("Comparison returned %d\n", (int) (short) (hr & 0xFFFF));
288 }
289 }
290
291 TRACE("Pidl not found\n");
293}
HRESULT CompareIDs([in] LPARAM lParam, [in] PCUIDLIST_RELATIVE pidl1, [in] PCUIDLIST_RELATIVE pidl2)
LPITEMIDLIST pidl
IShellFolder * parent

◆ Next()

HRESULT STDMETHODCALLTYPE CEnumMergedFolder::Next ( ULONG  celt,
LPITEMIDLIST rgelt,
ULONG pceltFetched 
)
override

Definition at line 327 of file CMergedFolder.cpp.

331{
332 if (pceltFetched)
333 *pceltFetched = 0;
334
336 return S_FALSE;
337
338 for (int i = 0; i < (int)celt;)
339 {
341 if (!tinfo)
342 return E_FAIL;
343
344 LocalPidlInfo info = *tinfo;
345
346 TRACE("Returning next item at %d with parent %p and pidl { cb=%d }\n", m_hDsaIndex, info.parent, info.pidl->mkid.cb);
347
348 // FIXME: ILClone shouldn't be needed here! This should be causing leaks
349 if (rgelt) rgelt[i] = ILClone(info.pidl);
350 i++;
351
352 m_hDsaIndex++;
354 {
355 if (pceltFetched)
356 *pceltFetched = i;
357 return (i == (int)celt) ? S_OK : S_FALSE;
358 }
359 }
360
361 if (pceltFetched) *pceltFetched = celt;
362 return S_OK;
363}

Referenced by Skip().

◆ Reset()

HRESULT STDMETHODCALLTYPE CEnumMergedFolder::Reset ( )
override

Implements IEnumIDList.

Definition at line 370 of file CMergedFolder.cpp.

371{
372 m_hDsaIndex = 0;
373 return S_OK;
374}

Referenced by Begin().

◆ s_DsaDeleteCallback()

int CALLBACK CEnumMergedFolder::s_DsaDeleteCallback ( void pItem,
void pData 
)
static

Definition at line 108 of file CMergedFolder.cpp.

109{
111 LocalPidlInfo * item = (LocalPidlInfo*) pItem;
112 return mf->DsaDeleteCallback(item);
113}
int DsaDeleteCallback(LocalPidlInfo *info)
static ATOM item
Definition: dde.c:856
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by Begin(), and ~CEnumMergedFolder().

◆ SetSources()

HRESULT CEnumMergedFolder::SetSources ( IShellFolder userLocal,
IShellFolder allUSers 
)

Definition at line 115 of file CMergedFolder.cpp.

116{
117 m_UserLocalFolder = userLocal;
118 m_AllUSersFolder = allUSers;
119
120 TRACE("SetSources %p %p\n", userLocal, allUSers);
121 return S_OK;
122}

◆ Skip()

HRESULT STDMETHODCALLTYPE CEnumMergedFolder::Skip ( ULONG  celt)
override

Implements IEnumIDList.

Definition at line 365 of file CMergedFolder.cpp.

366{
367 return Next(celt, NULL, NULL);
368}
STDMETHOD() Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched) override

Member Data Documentation

◆ m_AllUSersFolder

CComPtr<IShellFolder> CEnumMergedFolder::m_AllUSersFolder
private

Definition at line 44 of file CMergedFolder.cpp.

Referenced by Begin(), and SetSources().

◆ m_Flags

SHCONTF CEnumMergedFolder::m_Flags
private

Definition at line 47 of file CMergedFolder.cpp.

Referenced by Begin().

◆ m_hDsa

HDSA CEnumMergedFolder::m_hDsa
private

Definition at line 49 of file CMergedFolder.cpp.

Referenced by Begin(), FindByName(), FindPidlInList(), Next(), and ~CEnumMergedFolder().

◆ m_hDsaCount

UINT CEnumMergedFolder::m_hDsaCount
private

Definition at line 51 of file CMergedFolder.cpp.

Referenced by Begin(), FindByName(), FindPidlInList(), and Next().

◆ m_hDsaIndex

UINT CEnumMergedFolder::m_hDsaIndex
private

Definition at line 50 of file CMergedFolder.cpp.

Referenced by Next(), and Reset().

◆ m_HwndOwner

HWND CEnumMergedFolder::m_HwndOwner
private

Definition at line 46 of file CMergedFolder.cpp.

Referenced by Begin().

◆ m_UserLocalFolder

CComPtr<IShellFolder> CEnumMergedFolder::m_UserLocalFolder
private

Definition at line 43 of file CMergedFolder.cpp.

Referenced by Begin(), and SetSources().


The documentation for this class was generated from the following file: