From 7a78cfef8b87cdb92c276717979bea5a6c2e1bd8 Mon Sep 17 00:00:00 2001 From: Juergen Schmied Date: Sun, 11 Oct 1998 15:41:30 +0000 Subject: [PATCH] New class IDLList "Item ID List List" (internal). --- dlls/shell32/pidl.c | 135 ++++++++++++++++++++++++++++++++++++++++---- dlls/shell32/pidl.h | 74 ++++++++++++------------ 2 files changed, 160 insertions(+), 49 deletions(-) diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c index 67ccd94237a..9645a2ffdec 100644 --- a/dlls/shell32/pidl.c +++ b/dlls/shell32/pidl.c @@ -96,10 +96,6 @@ LPITEMIDLIST WINAPI ILClone (LPCITEMIDLIST pidl) { DWORD len; LPITEMIDLIST newpidl; - TRACE(pidl,"%p\n",pidl); - - pdump(pidl); - if (!pidl) return NULL; @@ -107,6 +103,10 @@ LPITEMIDLIST WINAPI ILClone (LPCITEMIDLIST pidl) newpidl = (LPITEMIDLIST)SHAlloc(len); if (newpidl) memcpy(newpidl,pidl,len); + + TRACE(pidl,"pidl=%p newpidl=%p\n",pidl, newpidl); + pdump(pidl); + return newpidl; } /************************************************************************* @@ -118,7 +118,6 @@ LPITEMIDLIST WINAPI ILClone (LPCITEMIDLIST pidl) LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl) { DWORD len; LPITEMIDLIST newpidl=NULL; - TRACE(pidl,"pidl=%p\n",pidl); if (pidl) { len = pidl->mkid.cb; @@ -128,6 +127,7 @@ LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl) ILGetNext(newpidl)->mkid.cb = 0x00; } } + TRACE(pidl,"pidl=%p newpidl=%p\n",pidl, newpidl); return newpidl; } @@ -224,8 +224,6 @@ DWORD WINAPI ILGetSize(LPITEMIDLIST pidl) { LPSHITEMID si = &(pidl->mkid); DWORD len=0; - /*TRACE(pidl,"pidl=%p\n",pidl);*/ - if (pidl) { while (si->cb) { len += si->cb; @@ -233,7 +231,7 @@ DWORD WINAPI ILGetSize(LPITEMIDLIST pidl) } len += 2; } - /*TRACE(pidl,"-- size=%lu\n",len);*/ + TRACE(pidl,"pidl=%p size=%lu\n",pidl, len); return len; } /************************************************************************* @@ -250,7 +248,7 @@ DWORD WINAPI ILGetSize(LPITEMIDLIST pidl) LPITEMIDLIST WINAPI ILGetNext(LPITEMIDLIST pidl) { LPITEMIDLIST nextpidl; -/* TRACE(pidl,"(pidl=%p)\n",pidl);*/ + TRACE(pidl,"(pidl=%p)\n",pidl); if(pidl) { nextpidl = (LPITEMIDLIST)(LPBYTE)(((LPBYTE)pidl) + pidl->mkid.cb); return nextpidl; @@ -467,7 +465,7 @@ DWORD WINAPI _ILGetFolderText(LPCITEMIDLIST pidl,LPSTR lpszPath, DWORD dwSize) DWORD dwCopied = 0; LPSTR pText; - TRACE(pidl,"(%p)\n",pidl); + TRACE(pidl,"(%p path=%p)\n",pidl, lpszPath); if(!pidl) { return 0; @@ -679,7 +677,7 @@ LPITEMIDLIST WINAPI _ILCreate(PIDLTYPE type, LPVOID pIn, UINT16 uInSize) /* the sizes of: cb(2), pidldata-1, szText+1, next cb(2) */ switch (type) { case PT_DRIVE: - uSize = 4 + 10; + uSize = 4 + 9; break; default: uSize = 4 + (sizeof(PIDLDATA)) + uInSize; @@ -798,3 +796,118 @@ LPSTR WINAPI _ILGetTextPointer(PIDLTYPE type, LPPIDLDATA pidldata) } return NULL; } + +/************************************************************************** + * IDLList "Item ID List List" + * + */ +static UINT32 IDLList_GetState(LPIDLLIST this); +static LPITEMIDLIST IDLList_GetElement(LPIDLLIST this, UINT32 nIndex); +static UINT32 IDLList_GetCount(LPIDLLIST this); +static BOOL32 IDLList_StoreItem(LPIDLLIST this, LPITEMIDLIST pidl); +static BOOL32 IDLList_AddItems(LPIDLLIST this, LPITEMIDLIST *apidl, UINT32 cidl); +static BOOL32 IDLList_InitList(LPIDLLIST this); +static void IDLList_CleanList(LPIDLLIST this); + +static IDLList_VTable idllvt = +{ IDLList_GetState, + IDLList_GetElement, + IDLList_GetCount, + IDLList_StoreItem, + IDLList_AddItems, + IDLList_InitList, + IDLList_CleanList +}; + +LPIDLLIST IDLList_Constructor (UINT32 uStep) +{ LPIDLLIST lpidll; + if (!(lpidll = (LPIDLLIST)HeapAlloc(GetProcessHeap(),0,sizeof(IDLList)))) + return NULL; + + lpidll->lpvtbl=&idllvt; + lpidll->uStep=uStep; + lpidll->dpa=NULL; + + TRACE (shell,"(%p)\n",lpidll); + return lpidll; +} +void IDLList_Destructor(LPIDLLIST this) +{ TRACE (shell,"(%p)\n",this); + IDLList_CleanList(this); +} + +static UINT32 IDLList_GetState(LPIDLLIST this) +{ TRACE (shell,"(%p)->(uStep=%u dpa=%p)\n",this, this->uStep, this->dpa); + + if (this->uStep == 0) + { if (this->dpa) + return(State_Init); + return(State_OutOfMem); + } + return(State_UnInit); +} +static LPITEMIDLIST IDLList_GetElement(LPIDLLIST this, UINT32 nIndex) +{ TRACE (shell,"(%p)->(index=%u)\n",this, nIndex); + return((LPITEMIDLIST)DPA_GetPtr(this->dpa, nIndex)); +} +static UINT32 IDLList_GetCount(LPIDLLIST this) +{ TRACE (shell,"(%p)\n",this); + return(IDLList_GetState(this)==State_Init ? DPA_GetPtrCount(this->dpa) : 0); +} +static BOOL32 IDLList_StoreItem(LPIDLLIST this, LPITEMIDLIST pidl) +{ TRACE (shell,"(%p)->(pidl=%p)\n",this, pidl); + if (pidl) + { if (IDLList_InitList(this) && DPA_InsertPtr(this->dpa, 0x7fff, (LPSTR)pidl)>=0) + return(TRUE); + ILFree(pidl); + } + IDLList_CleanList(this); + return(FALSE); +} +static BOOL32 IDLList_AddItems(LPIDLLIST this, LPITEMIDLIST *apidl, UINT32 cidl) +{ INT32 i; + TRACE (shell,"(%p)->(apidl=%p cidl=%u)\n",this, apidl, cidl); + + for (i=0; idpa = DPA_Create(this->uStep); + this->uStep = 0; + return(IDLList_InitList(this)); + } +} +static void IDLList_CleanList(LPIDLLIST this) +{ INT32 i; + TRACE (shell,"(%p)\n",this); + + if (this->uStep != 0) + { this->dpa = NULL; + this->uStep = 0; + return; + } + + if (!this->dpa) + { return; + } + + for (i=DPA_GetPtrCount(this->dpa)-1; i>=0; --i) + { ILFree(IDLList_GetElement(this,i)); + } + + DPA_Destroy(this->dpa); + this->dpa=NULL; +} diff --git a/dlls/shell32/pidl.h b/dlls/shell32/pidl.h index 03ca832ab5b..9112c2d4b9b 100644 --- a/dlls/shell32/pidl.h +++ b/dlls/shell32/pidl.h @@ -13,6 +13,7 @@ #ifndef __WINE_PIDL_H #define __WINE_PIDL_H + #include "shlobj.h" /* @@ -34,16 +35,17 @@ * file: see the PIDLDATA structure */ -#define PT_DESKTOP 0x0000 /*fixme*/ -#define PT_MYCOMP 0x001F -#define PT_SPECIAL 0x002E -#define PT_DRIVE 0x0023 -#define PT_FOLDER 0x0031 -#define PT_VALUE 0x0033 /*fixme*/ +#define PT_DESKTOP 0x00 /*fixme*/ +#define PT_MYCOMP 0x1F +#define PT_SPECIAL 0x2E +#define PT_DRIVE 0x23 +#define PT_FOLDER 0x31 +#define PT_VALUE 0x33 /*fixme*/ #pragma pack(1) -typedef WORD PIDLTYPE; - typedef struct tagPIDLDATA +typedef BYTE PIDLTYPE; + +typedef struct tagPIDLDATA { PIDLTYPE type; union { struct @@ -52,7 +54,8 @@ typedef WORD PIDLTYPE; DWORD dwSFGAO; } drive; struct - { DWORD dwFileSize; + { BYTE dummy; + DWORD dwFileSize; WORD uFileDate; WORD uFileTime; WORD uFileAttribs; @@ -62,39 +65,34 @@ typedef WORD PIDLTYPE; CHAR szText[1]; /* last entry, variable size */ } file, folder, generic; }u; -} - /* here starts my implementation*/ - PIDLDATA, *LPPIDLDATA; +} PIDLDATA, *LPPIDLDATA; #pragma pack(4) - LPITEMIDLIST WINAPI _ILCreateDesktop(); - LPITEMIDLIST WINAPI _ILCreateMyComputer(); - LPITEMIDLIST WINAPI _ILCreateDrive(LPCSTR); - LPITEMIDLIST WINAPI _ILCreateFolder(LPCSTR); - LPITEMIDLIST WINAPI _ILCreateValue(LPCSTR); - LPITEMIDLIST WINAPI _ILCreate(PIDLTYPE,LPVOID,UINT16); +LPITEMIDLIST WINAPI _ILCreateDesktop(); +LPITEMIDLIST WINAPI _ILCreateMyComputer(); +LPITEMIDLIST WINAPI _ILCreateDrive(LPCSTR); +LPITEMIDLIST WINAPI _ILCreateFolder(LPCSTR); +LPITEMIDLIST WINAPI _ILCreateValue(LPCSTR); +LPITEMIDLIST WINAPI _ILCreate(PIDLTYPE,LPVOID,UINT16); - BOOL32 WINAPI _ILGetDrive(LPCITEMIDLIST,LPSTR,UINT16); - DWORD WINAPI _ILGetItemText(LPCITEMIDLIST,LPSTR,UINT16); - DWORD WINAPI _ILGetFolderText(LPCITEMIDLIST,LPSTR,DWORD); - DWORD WINAPI _ILGetValueText(LPCITEMIDLIST,LPSTR,DWORD); - DWORD WINAPI _ILGetDataText(LPCITEMIDLIST,LPCITEMIDLIST,LPSTR,DWORD); - DWORD WINAPI _ILGetPidlPath(LPCITEMIDLIST,LPSTR,DWORD); - DWORD WINAPI _ILGetData(PIDLTYPE,LPCITEMIDLIST,LPVOID,UINT16); +BOOL32 WINAPI _ILGetDrive(LPCITEMIDLIST,LPSTR,UINT16); +DWORD WINAPI _ILGetItemText(LPCITEMIDLIST,LPSTR,UINT16); +DWORD WINAPI _ILGetFolderText(LPCITEMIDLIST,LPSTR,DWORD); +DWORD WINAPI _ILGetValueText(LPCITEMIDLIST,LPSTR,DWORD); +DWORD WINAPI _ILGetDataText(LPCITEMIDLIST,LPCITEMIDLIST,LPSTR,DWORD); +DWORD WINAPI _ILGetPidlPath(LPCITEMIDLIST,LPSTR,DWORD); +DWORD WINAPI _ILGetData(PIDLTYPE,LPCITEMIDLIST,LPVOID,UINT16); - BOOL32 WINAPI _ILIsDesktop(LPCITEMIDLIST); - BOOL32 WINAPI _ILIsMyComputer(LPCITEMIDLIST); - BOOL32 WINAPI _ILIsDrive(LPCITEMIDLIST); - BOOL32 WINAPI _ILIsFolder(LPCITEMIDLIST); - BOOL32 WINAPI _ILIsValue(LPCITEMIDLIST); +BOOL32 WINAPI _ILIsDesktop(LPCITEMIDLIST); +BOOL32 WINAPI _ILIsMyComputer(LPCITEMIDLIST); +BOOL32 WINAPI _ILIsDrive(LPCITEMIDLIST); +BOOL32 WINAPI _ILIsFolder(LPCITEMIDLIST); +BOOL32 WINAPI _ILIsValue(LPCITEMIDLIST); - BOOL32 WINAPI _ILHasFolders(LPSTR,LPCITEMIDLIST); +BOOL32 WINAPI _ILHasFolders(LPSTR,LPCITEMIDLIST); - LPPIDLDATA WINAPI _ILGetDataPointer(LPCITEMIDLIST); - LPSTR WINAPI _ILGetTextPointer(PIDLTYPE type, LPPIDLDATA pidldata); -/* - BOOL32 WINAPI _ILGetDesktop(LPCITEMIDLIST,LPSTR); - BOOL32 WINAPI _ILSeparatePathAndValue(LPITEMIDLIST,LPITEMIDLIST*,LPITEMIDLIST*); - BOOL32 WINAPI _ILGetValueType(LPCITEMIDLIST,LPCITEMIDLIST,LPDWORD); -*/ +LPPIDLDATA WINAPI _ILGetDataPointer(LPCITEMIDLIST); +LPSTR WINAPI _ILGetTextPointer(PIDLTYPE type, LPPIDLDATA pidldata); + +void pdump (LPCITEMIDLIST pidl); #endif