shell32: Use standard list for IEnumIDList implementation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5669a710b2
commit
794efcceee
|
@ -39,42 +39,25 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|||
/**************************************************************************
|
||||
* AddToEnumList()
|
||||
*/
|
||||
BOOL AddToEnumList(IEnumIDListImpl *This, LPITEMIDLIST pidl)
|
||||
BOOL AddToEnumList(IEnumIDListImpl *list, LPITEMIDLIST pidl)
|
||||
{
|
||||
struct enumlist *pNew;
|
||||
struct pidl_enum_entry *pidl_entry;
|
||||
|
||||
TRACE("(%p)->(pidl=%p)\n",This,pidl);
|
||||
TRACE("(%p)->(pidl=%p)\n", list, pidl);
|
||||
|
||||
if (!This || !pidl)
|
||||
if (!list || !pidl)
|
||||
return FALSE;
|
||||
|
||||
pNew = SHAlloc(sizeof(*pNew));
|
||||
if(pNew)
|
||||
{
|
||||
/*set the next pointer */
|
||||
pNew->pNext = NULL;
|
||||
pNew->pidl = pidl;
|
||||
if (!(pidl_entry = SHAlloc(sizeof(*pidl_entry))))
|
||||
return FALSE;
|
||||
|
||||
/*is This the first item in the list? */
|
||||
if(!This->mpFirst)
|
||||
{
|
||||
This->mpFirst = pNew;
|
||||
This->mpCurrent = pNew;
|
||||
}
|
||||
pidl_entry->pidl = pidl;
|
||||
list_add_tail(&list->pidls, &pidl_entry->entry);
|
||||
if (!list->current)
|
||||
list->current = list_head(&list->pidls);
|
||||
|
||||
if(This->mpLast)
|
||||
{
|
||||
/*add the new item to the end of the list */
|
||||
This->mpLast->pNext = pNew;
|
||||
}
|
||||
|
||||
/*update the last item pointer */
|
||||
This->mpLast = pNew;
|
||||
TRACE("-- (%p)->(first=%p, last=%p)\n",This,This->mpFirst,This->mpLast);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* CreateFolderEnumList()
|
||||
|
@ -138,22 +121,6 @@ BOOL CreateFolderEnumList(IEnumIDListImpl *list, LPCWSTR lpszPath, DWORD dwFlags
|
|||
return succeeded;
|
||||
}
|
||||
|
||||
static BOOL DeleteList(IEnumIDListImpl *This)
|
||||
{
|
||||
struct enumlist *pDelete;
|
||||
|
||||
TRACE("(%p)->()\n",This);
|
||||
|
||||
while(This->mpFirst)
|
||||
{ pDelete = This->mpFirst;
|
||||
This->mpFirst = pDelete->pNext;
|
||||
SHFree(pDelete->pidl);
|
||||
SHFree(pDelete);
|
||||
}
|
||||
This->mpFirst = This->mpLast = This->mpCurrent = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline IEnumIDListImpl *impl_from_IEnumIDList(IEnumIDList *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IEnumIDListImpl, IEnumIDList_iface);
|
||||
|
@ -166,7 +133,7 @@ static HRESULT WINAPI IEnumIDList_fnQueryInterface(IEnumIDList *iface, REFIID ri
|
|||
{
|
||||
IEnumIDListImpl *This = impl_from_IEnumIDList(iface);
|
||||
|
||||
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
|
||||
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObj);
|
||||
|
||||
*ppvObj = NULL;
|
||||
|
||||
|
@ -177,12 +144,12 @@ static HRESULT WINAPI IEnumIDList_fnQueryInterface(IEnumIDList *iface, REFIID ri
|
|||
}
|
||||
|
||||
if (*ppvObj)
|
||||
{ IEnumIDList_AddRef((IEnumIDList*)*ppvObj);
|
||||
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
||||
{
|
||||
IUnknown_AddRef((IUnknown*)*ppvObj);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
TRACE("-- Interface: E_NOINTERFACE\n");
|
||||
WARN("interface %s is not supported\n", debugstr_guid(riid));
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
@ -198,6 +165,7 @@ static ULONG WINAPI IEnumIDList_fnAddRef(IEnumIDList *iface)
|
|||
|
||||
return refCount;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* IEnumIDList::Release
|
||||
*/
|
||||
|
@ -208,11 +176,19 @@ static ULONG WINAPI IEnumIDList_fnRelease(IEnumIDList *iface)
|
|||
|
||||
TRACE("(%p)->(%u)\n", This, refCount + 1);
|
||||
|
||||
if (!refCount) {
|
||||
TRACE(" destroying IEnumIDList(%p)\n",This);
|
||||
DeleteList(This);
|
||||
if (!refCount)
|
||||
{
|
||||
struct pidl_enum_entry *cur, *cur2;
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &This->pidls, struct pidl_enum_entry, entry)
|
||||
{
|
||||
list_remove(&cur->entry);
|
||||
SHFree(cur->pidl);
|
||||
SHFree(cur);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
return refCount;
|
||||
}
|
||||
|
||||
|
@ -221,44 +197,40 @@ static ULONG WINAPI IEnumIDList_fnRelease(IEnumIDList *iface)
|
|||
*/
|
||||
|
||||
static HRESULT WINAPI IEnumIDList_fnNext(IEnumIDList *iface, ULONG celt, LPITEMIDLIST *rgelt,
|
||||
ULONG *pceltFetched)
|
||||
ULONG *fetched)
|
||||
{
|
||||
IEnumIDListImpl *This = impl_from_IEnumIDList(iface);
|
||||
|
||||
ULONG i;
|
||||
HRESULT hr = S_OK;
|
||||
LPITEMIDLIST temp;
|
||||
ULONG i;
|
||||
|
||||
TRACE("(%p)->(%d,%p, %p)\n",This,celt,rgelt,pceltFetched);
|
||||
TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, fetched);
|
||||
|
||||
/* It is valid to leave pceltFetched NULL when celt is 1. Some of explorer's
|
||||
* subsystems actually use it (and so may a third party browser)
|
||||
*/
|
||||
if(pceltFetched)
|
||||
*pceltFetched = 0;
|
||||
if (fetched)
|
||||
*fetched = 0;
|
||||
|
||||
*rgelt=0;
|
||||
*rgelt = NULL;
|
||||
|
||||
if(celt > 1 && !pceltFetched)
|
||||
{ return E_INVALIDARG;
|
||||
}
|
||||
if (celt > 1 && !fetched)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if(celt > 0 && !This->mpCurrent)
|
||||
{ return S_FALSE;
|
||||
}
|
||||
if (celt > 0 && !This->current)
|
||||
return S_FALSE;
|
||||
|
||||
for (i = 0; i < celt; i++)
|
||||
{ if(!(This->mpCurrent))
|
||||
{
|
||||
if (!This->current)
|
||||
break;
|
||||
|
||||
temp = ILClone(This->mpCurrent->pidl);
|
||||
rgelt[i] = temp;
|
||||
This->mpCurrent = This->mpCurrent->pNext;
|
||||
}
|
||||
if(pceltFetched)
|
||||
{ *pceltFetched = i;
|
||||
rgelt[i] = ILClone(LIST_ENTRY(This->current, struct pidl_enum_entry, entry)->pidl);
|
||||
This->current = list_next(&This->pidls, This->current);
|
||||
}
|
||||
|
||||
if (fetched)
|
||||
*fetched = i;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -268,21 +240,24 @@ static HRESULT WINAPI IEnumIDList_fnNext(IEnumIDList *iface, ULONG celt, LPITEMI
|
|||
static HRESULT WINAPI IEnumIDList_fnSkip(IEnumIDList *iface, ULONG celt)
|
||||
{
|
||||
IEnumIDListImpl *This = impl_from_IEnumIDList(iface);
|
||||
|
||||
DWORD dwIndex;
|
||||
HRESULT hr = S_OK;
|
||||
ULONG i;
|
||||
|
||||
TRACE("(%p)->(%u)\n", This, celt);
|
||||
|
||||
for(dwIndex = 0; dwIndex < celt; dwIndex++)
|
||||
{ if(!This->mpCurrent)
|
||||
{ hr = S_FALSE;
|
||||
for (i = 0; i < celt; i++)
|
||||
{
|
||||
if (!This->current)
|
||||
{
|
||||
hr = S_FALSE;
|
||||
break;
|
||||
}
|
||||
This->mpCurrent = This->mpCurrent->pNext;
|
||||
This->current = list_next(&This->pidls, This->current);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* IEnumIDList::Reset
|
||||
*/
|
||||
|
@ -291,9 +266,10 @@ static HRESULT WINAPI IEnumIDList_fnReset(IEnumIDList *iface)
|
|||
IEnumIDListImpl *This = impl_from_IEnumIDList(iface);
|
||||
|
||||
TRACE("(%p)\n",This);
|
||||
This->mpCurrent = This->mpFirst;
|
||||
This->current = list_head(&This->pidls);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* IEnumIDList::Clone
|
||||
*/
|
||||
|
@ -301,7 +277,8 @@ static HRESULT WINAPI IEnumIDList_fnClone(IEnumIDList *iface, IEnumIDList **ppen
|
|||
{
|
||||
IEnumIDListImpl *This = impl_from_IEnumIDList(iface);
|
||||
|
||||
TRACE("(%p)->() to (%p)->() E_NOTIMPL\n",This,ppenum);
|
||||
FIXME("(%p)->(%p): stub\n",This, ppenum);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
@ -318,12 +295,14 @@ static const IEnumIDListVtbl eidlvt =
|
|||
|
||||
IEnumIDListImpl *IEnumIDList_Constructor(void)
|
||||
{
|
||||
IEnumIDListImpl *lpeidl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*lpeidl));
|
||||
IEnumIDListImpl *lpeidl = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpeidl));
|
||||
|
||||
if (lpeidl)
|
||||
{
|
||||
lpeidl->ref = 1;
|
||||
lpeidl->IEnumIDList_iface.lpVtbl = &eidlvt;
|
||||
lpeidl->ref = 1;
|
||||
list_init(&lpeidl->pidls);
|
||||
lpeidl->current = NULL;
|
||||
}
|
||||
|
||||
TRACE("-- (%p)->()\n",lpeidl);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "shlobj.h"
|
||||
#include "shellapi.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/list.h"
|
||||
|
||||
/*******************************************
|
||||
* global SHELL32.DLL variables
|
||||
|
@ -183,9 +184,9 @@ BOOL SHELL_IsShortcut(LPCITEMIDLIST) DECLSPEC_HIDDEN;
|
|||
|
||||
|
||||
/* IEnumIDList stuff */
|
||||
struct enumlist
|
||||
struct pidl_enum_entry
|
||||
{
|
||||
struct enumlist *pNext;
|
||||
struct list entry;
|
||||
LPITEMIDLIST pidl;
|
||||
};
|
||||
|
||||
|
@ -193,9 +194,8 @@ typedef struct
|
|||
{
|
||||
IEnumIDList IEnumIDList_iface;
|
||||
LONG ref;
|
||||
struct enumlist *mpFirst;
|
||||
struct enumlist *mpLast;
|
||||
struct enumlist *mpCurrent;
|
||||
struct list pidls;
|
||||
struct list *current;
|
||||
} IEnumIDListImpl;
|
||||
|
||||
/* Creates an IEnumIDList; add LPITEMIDLISTs to it with AddToEnumList. */
|
||||
|
|
Loading…
Reference in New Issue