ReactOS 0.4.15-dev-5666-gc548b97
CEnumIDListBase.cpp
Go to the documentation of this file.
1/*
2 * IEnumIDList
3 *
4 * Copyright 1998 Juergen Schmied <juergen.schmied@metronet.de>
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "precomp.h"
22
24
26 mpFirst(NULL),
27 mpLast(NULL),
28 mpCurrent(NULL)
29{
30}
31
33{
34 DeleteList();
35}
36
37/**************************************************************************
38 * AddToEnumList()
39 */
41{
42 ENUMLIST *pNew;
43
44 TRACE("(%p)->(pidl=%p)\n", this, pidl);
45
46 if (!pidl)
47 return FALSE;
48
49 pNew = static_cast<ENUMLIST *>(SHAlloc(sizeof(ENUMLIST)));
50 if (pNew)
51 {
52 /*set the next pointer */
53 pNew->pNext = NULL;
54 pNew->pidl = pidl;
55
56 /*is This the first item in the list? */
57 if (!mpFirst)
58 {
59 mpFirst = pNew;
60 mpCurrent = pNew;
61 }
62
63 if (mpLast)
64 {
65 /*add the new item to the end of the list */
66 mpLast->pNext = pNew;
67 }
68
69 /*update the last item pointer */
70 mpLast = pNew;
71 TRACE("-- (%p)->(first=%p, last=%p)\n", this, mpFirst, mpLast);
72 return TRUE;
73 }
74 return FALSE;
75}
76
77/**************************************************************************
78* DeleteList()
79*/
81{
82 ENUMLIST *pDelete;
83
84 TRACE("(%p)->()\n", this);
85
86 while (mpFirst)
87 {
88 pDelete = mpFirst;
89 mpFirst = pDelete->pNext;
90 SHFree(pDelete->pidl);
91 SHFree(pDelete);
92 }
93 mpFirst = NULL;
94 mpLast = NULL;
96 return TRUE;
97}
98
99/**************************************************************************
100 * HasItemWithCLSID()
101 */
103{
104 ENUMLIST *pCur;
105 IID *ptr = _ILGetGUIDPointer(pidl);
106
107 if (ptr)
108 {
109 REFIID refid = *ptr;
110 pCur = mpFirst;
111
112 while(pCur)
113 {
114 LPGUID curid = _ILGetGUIDPointer(pCur->pidl);
115 if (curid && IsEqualGUID(*curid, refid))
116 {
117 return TRUE;
118 }
119 pCur = pCur->pNext;
120 }
121 }
122
123 return FALSE;
124}
125
127{
128 LPITEMIDLIST pidl;
129 DWORD dwFetched;
130
131 if (!pEnum)
132 return E_INVALIDARG;
133
134 pEnum->Reset();
135
136 while((S_OK == pEnum->Next(1, &pidl, &dwFetched)) && dwFetched)
137 AddToEnumList(pidl);
138
139 return S_OK;
140}
141
142/**************************************************************************
143 * IEnumIDList_fnNext
144 */
145
147 ULONG celt,
148 LPITEMIDLIST * rgelt,
149 ULONG *pceltFetched)
150{
151 ULONG i;
152 HRESULT hr = S_OK;
154
155 TRACE("(%p)->(%d,%p, %p)\n", this, celt, rgelt, pceltFetched);
156
157/* It is valid to leave pceltFetched NULL when celt is 1. Some of explorer's
158 * subsystems actually use it (and so may a third party browser)
159 */
160 if(pceltFetched)
161 *pceltFetched = 0;
162
163 *rgelt=0;
164
165 if(celt > 1 && !pceltFetched)
166 { return E_INVALIDARG;
167 }
168
169 if(celt > 0 && !mpCurrent)
170 { return S_FALSE;
171 }
172
173 for(i = 0; i < celt; i++)
174 { if(!mpCurrent)
175 break;
176
178 rgelt[i] = temp;
180 }
181 if(pceltFetched)
182 { *pceltFetched = i;
183 }
184
185 return hr;
186}
187
188/**************************************************************************
189* IEnumIDList_fnSkip
190*/
192 ULONG celt)
193{
194 DWORD dwIndex;
195 HRESULT hr = S_OK;
196
197 TRACE("(%p)->(%u)\n", this, celt);
198
199 for(dwIndex = 0; dwIndex < celt; dwIndex++)
200 { if(!mpCurrent)
201 { hr = S_FALSE;
202 break;
203 }
205 }
206 return hr;
207}
208
209/**************************************************************************
210* IEnumIDList_fnReset
211*/
213{
214 TRACE("(%p)\n", this);
216 return S_OK;
217}
218
219/**************************************************************************
220* IEnumIDList_fnClone
221*/
223{
224 TRACE("(%p)->() to (%p)->() E_NOTIMPL\n", this, ppenum);
225 return E_NOTIMPL;
226}
227
228/**************************************************************************
229 * IEnumIDList_Folder_Constructor
230 *
231 */
233{
234 return ShellObjectCreator<CEnumIDListBase>(IID_PPV_ARG(IEnumIDList, enumerator));
235}
HRESULT IEnumIDList_Constructor(IEnumIDList **enumerator)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched)
virtual HRESULT STDMETHODCALLTYPE Clone(IEnumIDList **ppenum)
virtual HRESULT STDMETHODCALLTYPE Reset()
ENUMLIST * mpLast
ENUMLIST * mpCurrent
BOOL HasItemWithCLSID(LPITEMIDLIST pidl)
ENUMLIST * mpFirst
BOOL AddToEnumList(LPITEMIDLIST pidl)
virtual ~CEnumIDListBase()
HRESULT AppendItemsFromEnumerator(IEnumIDList *pEnum)
virtual HRESULT STDMETHODCALLTYPE Skip(ULONG celt)
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
SINGLE_LIST_ENTRY * pCur
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
HRESULT Next([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] PITEMID_CHILD *rgelt, [out] ULONG *pceltFetched)
HRESULT Reset()
#define S_OK
Definition: intsafe.h:52
unsigned int ULONG
Definition: retypes.h:1
static PVOID ptr
Definition: dispmode.c:27
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2325
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
static calc_node_t temp
Definition: rpn_ieee.c:38
HRESULT hr
Definition: shlfolder.c:183
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define TRACE(s)
Definition: solgame.cpp:4
ENUMLIST * pNext
LPITEMIDLIST pidl
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define IID_PPV_ARG(Itype, ppType)