Commit aef981df authored by Alexandre Julliard's avatar Alexandre Julliard

shell32: Share more code between the various IShellFolder_GetDetailsOf implementations.

parent 70043501
......@@ -760,40 +760,32 @@ static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 *iface, LPCI
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
PIDLCPanelStruct* pcpanel;
HRESULT hr;
TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl) {
psd->fmt = ControlPanelSFHeader[iColumn].fmt;
psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
return S_OK;
} else {
psd->str.u.cStr[0] = 0x00;
psd->str.uType = STRRET_CSTR;
switch(iColumn) {
case 0: /* name */
hr = IShellFolder2_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* comment */
pcpanel = _ILGetCPanelPointer(pidl);
if (pcpanel)
lstrcpyA(psd->str.u.cStr, pcpanel->szName+pcpanel->offsComment);
else
_ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
if (!pidl)
return SHELL32_GetColumnDetails(ControlPanelSFHeader, iColumn, psd);
break;
}
hr = S_OK;
}
psd->str.u.cStr[0] = 0x00;
psd->str.uType = STRRET_CSTR;
switch(iColumn)
{
case 1: /* comment */
pcpanel = _ILGetCPanelPointer(pidl);
return hr;
if (pcpanel)
lstrcpyA(psd->str.u.cStr, pcpanel->szName+pcpanel->offsComment);
else
_ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
break;
default:
return shellfolder_get_file_details( iface, pidl, ControlPanelSFHeader, iColumn, psd );
}
return S_OK;
}
static HRESULT WINAPI ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2 *iface, UINT column,
SHCOLUMNID *pscid)
......
......@@ -43,29 +43,20 @@
#include "shell32_main.h"
#include "xdg.h"
#include "pidl.h"
#include "shfldr.h"
WINE_DEFAULT_DEBUG_CHANNEL(recyclebin);
typedef struct
{
int column_name_id;
const GUID *fmtId;
DWORD pid;
int pcsFlags;
int fmt;
int cxChars;
} columninfo;
static const columninfo RecycleBinColumns[] =
{
{IDS_SHV_COLUMN1, &FMTID_Storage, PID_STG_NAME, SHCOLSTATE_TYPE_STR|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
{IDS_SHV_COLUMN_DELFROM, &FMTID_Displaced, PID_DISPLACED_FROM, SHCOLSTATE_TYPE_STR|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
{IDS_SHV_COLUMN_DELDATE, &FMTID_Displaced, PID_DISPLACED_DATE, SHCOLSTATE_TYPE_DATE|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20},
{IDS_SHV_COLUMN2, &FMTID_Storage, PID_STG_SIZE, SHCOLSTATE_TYPE_INT|SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 20},
{IDS_SHV_COLUMN3, &FMTID_Storage, PID_STG_STORAGETYPE,SHCOLSTATE_TYPE_INT|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20},
{IDS_SHV_COLUMN4, &FMTID_Storage, PID_STG_WRITETIME, SHCOLSTATE_TYPE_DATE|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20},
/* {"creation time", &FMTID_Storage, PID_STG_CREATETIME, SHCOLSTATE_TYPE_DATE, LVCFMT_LEFT, 20}, */
/* {"attribs", &FMTID_Storage, PID_STG_ATTRIBUTES, SHCOLSTATE_TYPE_STR, LVCFMT_LEFT, 20}, */
static const shvheader RecycleBinColumns[] =
{
{&FMTID_Storage, PID_STG_NAME, IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
{&FMTID_Displaced, PID_DISPLACED_FROM, IDS_SHV_COLUMN_DELFROM, SHCOLSTATE_TYPE_STR|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
{&FMTID_Displaced, PID_DISPLACED_DATE, IDS_SHV_COLUMN_DELDATE, SHCOLSTATE_TYPE_DATE|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20},
{&FMTID_Storage, PID_STG_SIZE, IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_INT|SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 20},
{&FMTID_Storage, PID_STG_STORAGETYPE,IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_INT|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20},
{&FMTID_Storage, PID_STG_WRITETIME, IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE|SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 20},
/* {&FMTID_Storage, PID_STG_CREATETIME, "creation time", SHCOLSTATE_TYPE_DATE, LVCFMT_LEFT, 20}, */
/* {&FMTID_Storage, PID_STG_ATTRIBUTES, "attribs", SHCOLSTATE_TYPE_STR, LVCFMT_LEFT, 20}, */
};
#define COLUMN_NAME 0
......@@ -613,14 +604,8 @@ static HRESULT WINAPI RecycleBin_GetDetailsOf(IShellFolder2 *iface, LPCITEMIDLIS
TRACE("(%p, %p, %d, %p)\n", This, pidl, iColumn, pDetails);
if (iColumn >= COLUMNS_COUNT)
return E_FAIL;
pDetails->fmt = RecycleBinColumns[iColumn].fmt;
pDetails->cxChar = RecycleBinColumns[iColumn].cxChars;
if (pidl == NULL)
{
pDetails->str.uType = STRRET_WSTR;
LoadStringW(shell32_hInstance, RecycleBinColumns[iColumn].column_name_id, buffer, MAX_PATH);
return SHStrDupW(buffer, &pDetails->str.u.pOleStr);
}
if (!pidl) return SHELL32_GetColumnDetails( RecycleBinColumns, iColumn, pDetails );
if (iColumn == COLUMN_NAME)
return RecycleBin_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL, &pDetails->str);
......@@ -659,9 +644,8 @@ static HRESULT WINAPI RecycleBin_MapColumnToSCID(IShellFolder2 *iface, UINT iCol
TRACE("(%p, %d, %p)\n", This, iColumn, pscid);
if (iColumn>=COLUMNS_COUNT)
return E_INVALIDARG;
pscid->fmtid = *RecycleBinColumns[iColumn].fmtId;
pscid->pid = RecycleBinColumns[iColumn].pid;
return S_OK;
return shellfolder_map_column_to_scid(RecycleBinColumns, iColumn, pscid);
}
static const IShellFolder2Vtbl recycleBinVtbl =
......
......@@ -35,6 +35,8 @@ typedef struct {
HRESULT SHELL32_GetColumnDetails(const shvheader *data, int column, SHELLDETAILS *details) DECLSPEC_HIDDEN;
HRESULT shellfolder_map_column_to_scid(const shvheader *data, UINT column, SHCOLUMNID *scid) DECLSPEC_HIDDEN;
HRESULT shellfolder_get_file_details(IShellFolder2 *iface, LPCITEMIDLIST pidl, const shvheader *header,
int column, SHELLDETAILS *psd) DECLSPEC_HIDDEN;
#define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
#define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
......
......@@ -802,8 +802,6 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
{
IDesktopFolderImpl *This = impl_from_IShellFolder2(iface);
HRESULT hr = S_OK;
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
if (!psd || iColumn >= ARRAY_SIZE(desktop_header))
......@@ -812,29 +810,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
if (!pidl)
return SHELL32_GetColumnDetails(desktop_header, iColumn, psd);
/* the data from the pidl */
psd->str.uType = STRRET_CSTR;
switch (iColumn)
{
case 0: /* name */
hr = IShellFolder2_GetDisplayNameOf(iface, pidl,
SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* size */
_ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 2: /* type */
_ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 3: /* date */
_ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 4: /* attributes */
_ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
break;
}
return hr;
return shellfolder_get_file_details( iface, pidl, desktop_header, iColumn, psd );
}
static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID(IShellFolder2 *iface, UINT column, SHCOLUMNID *scid)
......
......@@ -965,46 +965,15 @@ IShellFolder_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl,
UINT iColumn, SHELLDETAILS * psd)
{
IGenericSFImpl *This = impl_from_IShellFolder2(iface);
HRESULT hr = E_FAIL;
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl) {
/* the header titles */
psd->fmt = GenericSFHeader[iColumn].fmt;
psd->cxChar = GenericSFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA (shell32_hInstance, GenericSFHeader[iColumn].colnameid,
psd->str.u.cStr, MAX_PATH);
return S_OK;
} else {
hr = S_OK;
psd->str.uType = STRRET_CSTR;
/* the data from the pidl */
switch (iColumn) {
case 0: /* name */
hr = IShellFolder2_GetDisplayNameOf (iface, pidl,
SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* size */
_ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 2: /* type */
_ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 3: /* date */
_ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 4: /* attributes */
_ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
break;
}
}
if (!pidl) return SHELL32_GetColumnDetails(GenericSFHeader, iColumn, psd);
return hr;
return shellfolder_get_file_details( iface, pidl, GenericSFHeader, iColumn, psd );
}
static HRESULT WINAPI
......
......@@ -834,13 +834,6 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 *iface,
switch (iColumn)
{
case 0: /* name */
hr = IShellFolder2_GetDisplayNameOf (iface, pidl,
SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* type */
_ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 2: /* total size */
if (_ILIsDrive (pidl))
{
......@@ -857,6 +850,9 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 *iface,
StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
}
break;
default:
return shellfolder_get_file_details( iface, pidl, mycomputer_header, iColumn, psd );
}
return hr;
......
......@@ -1492,7 +1492,6 @@ static HRESULT WINAPI ShellFolder2_GetDetailsOf(IShellFolder2* iface,
struct passwd *pPasswd;
struct group *pGroup;
struct stat statItem;
HRESULT hr = S_OK;
TRACE("(%p)->(%p %d %p)\n", This, pidl, iColumn, psd);
......@@ -1510,23 +1509,13 @@ static HRESULT WINAPI ShellFolder2_GetDetailsOf(IShellFolder2* iface,
if (stat(szPath, &statItem))
return E_INVALIDARG;
}
else return shellfolder_get_file_details( iface, pidl, unixfs_header, iColumn, psd );
psd->str.u.cStr[0] = '\0';
psd->str.uType = STRRET_CSTR;
switch (iColumn) {
case 0:
hr = IShellFolder2_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL|SHGDN_INFOLDER, &psd->str);
break;
case 1:
_ILGetFileSize(pidl, psd->str.u.cStr, MAX_PATH);
break;
case 2:
_ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
break;
case 3:
_ILGetFileDate(pidl, psd->str.u.cStr, MAX_PATH);
break;
switch (iColumn)
{
case 4:
psd->str.u.cStr[0] = S_ISDIR(statItem.st_mode) ? 'd' : '-';
psd->str.u.cStr[1] = (statItem.st_mode & S_IRUSR) ? 'r' : '-';
......@@ -1549,8 +1538,7 @@ static HRESULT WINAPI ShellFolder2_GetDetailsOf(IShellFolder2* iface,
if (pGroup) strcpy(psd->str.u.cStr, pGroup->gr_name);
break;
}
return hr;
return S_OK;
}
static HRESULT WINAPI ShellFolder2_MapColumnToSCID(IShellFolder2* iface, UINT column, SHCOLUMNID *scid)
......
......@@ -580,6 +580,30 @@ HRESULT shellfolder_map_column_to_scid(const shvheader *header, UINT column, SHC
return S_OK;
}
HRESULT shellfolder_get_file_details(IShellFolder2 *iface, LPCITEMIDLIST pidl, const shvheader *header,
int column, SHELLDETAILS *psd)
{
psd->str.uType = STRRET_CSTR;
switch (header[column].pid)
{
case PID_STG_NAME:
return IShellFolder2_GetDisplayNameOf( iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str );
case PID_STG_SIZE:
_ILGetFileSize( pidl, psd->str.u.cStr, MAX_PATH );
break;
case PID_STG_STORAGETYPE:
_ILGetFileType( pidl, psd->str.u.cStr, MAX_PATH );
break;
case PID_STG_WRITETIME:
_ILGetFileDate( pidl, psd->str.u.cStr, MAX_PATH );
break;
case PID_STG_ATTRIBUTES:
_ILGetFileAttributes( pidl, psd->str.u.cStr, MAX_PATH );
break;
}
return S_OK;
}
/***********************************************************************
* SHCreateLinks
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment