Commit e51fe8e0 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

shell32: Use shared code to return column details from IShellFolder2::GetDetailsOf().

parent 506264be
/*
* Virtual Folder
* common definitions
......@@ -30,6 +29,8 @@ typedef struct {
int cxChar;
} shvheader;
HRESULT SHELL32_GetColumnDetails(const shvheader *data, int column, SHELLDETAILS *details);
#define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
#define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
......
......@@ -81,7 +81,7 @@ static inline IDesktopFolderImpl *impl_from_IPersist( IPersist *iface )
return (IDesktopFolderImpl *)((char*)iface - FIELD_OFFSET(IDesktopFolderImpl, lpVtblIPersist));
}
static const shvheader DesktopSFHeader[] = {
static const shvheader desktop_header[] = {
{IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
{IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
......@@ -89,7 +89,7 @@ static const shvheader DesktopSFHeader[] = {
{IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
};
#define DESKTOPSHELLVIEWCOLUMNS 5
#define DESKTOPSHELLVIEWCOLUMNS sizeof(desktop_header)/sizeof(shvheader)
/**************************************************************************
* ISF_Desktop_fnQueryInterface
......@@ -775,7 +775,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (
if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
return E_INVALIDARG;
*pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
*pcsFlags = desktop_header[iColumn].pcsFlags;
return S_OK;
}
......@@ -801,14 +801,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
return E_INVALIDARG;
if (!pidl)
{
psd->fmt = DesktopSFHeader[iColumn].fmt;
psd->cxChar = DesktopSFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid,
psd->str.u.cStr, MAX_PATH);
return S_OK;
}
return SHELL32_GetColumnDetails(desktop_header, iColumn, psd);
/* the data from the pidl */
psd->str.uType = STRRET_CSTR;
......
......@@ -86,14 +86,14 @@ static inline IMyComputerFolderImpl *impl_from_IPersistFolder2( IPersistFolder2
* IShellFolder [MyComputer] implementation
*/
static const shvheader MyComputerSFHeader[] = {
static const shvheader mycomputer_header[] = {
{IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
{IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
};
#define MYCOMPUTERSHELLVIEWCOLUMNS 4
#define MYCOMPUTERSHELLVIEWCOLUMNS sizeof(mycomputer_header)/sizeof(shvheader)
/**************************************************************************
* ISF_MyComputer_Constructor
......@@ -809,11 +809,13 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (
{
IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
TRACE ("(%p)\n", This);
TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
return E_INVALIDARG;
*pcsFlags = MyComputerSFHeader[iColumn].pcsFlags;
*pcsFlags = mycomputer_header[iColumn].pcsFlags;
return S_OK;
}
......@@ -826,11 +828,13 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface,
}
/* FIXME: drive size >4GB is rolling over */
static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface,
LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 *iface,
LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd)
{
IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
HRESULT hr;
char szPath[MAX_PATH];
ULARGE_INTEGER ulBytes;
HRESULT hr = S_OK;
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
......@@ -838,21 +842,11 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface,
return E_INVALIDARG;
if (!pidl)
{
psd->fmt = MyComputerSFHeader[iColumn].fmt;
psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid,
psd->str.u.cStr, MAX_PATH);
return S_OK;
}
else
{
char szPath[MAX_PATH];
ULARGE_INTEGER ulBytes;
return SHELL32_GetColumnDetails(mycomputer_header, iColumn, psd);
psd->str.u.cStr[0] = 0x00;
psd->str.u.cStr[0] = 0;
psd->str.uType = STRRET_CSTR;
switch (iColumn)
{
case 0: /* name */
......@@ -879,8 +873,6 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface,
}
break;
}
hr = S_OK;
}
return hr;
}
......
......@@ -65,20 +65,21 @@ typedef struct {
static const IShellFolder2Vtbl vt_ShellFolder2;
static const IPersistFolder2Vtbl vt_NP_PersistFolder2;
#define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = \
(class*)(((char*)name) - FIELD_OFFSET(IGenericSFImpl, lpVtblPersistFolder2))
static inline IGenericSFImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
{
return (IGenericSFImpl *)((char*)iface - FIELD_OFFSET(IGenericSFImpl, lpVtblPersistFolder2));
}
#define _IUnknown_(This) ((IUnknown*)&(This)->lpVtbl)
#define _IShellFolder_(This) ((IShellFolder*)&(This)->lpVtbl)
#define _IPersistFolder2_(This) (&(This)->lpVtblPersistFolder2)
static const shvheader NetworkPlacesSFHeader[] = {
static const shvheader networkplaces_header[] = {
{IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
{IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10}
};
#define NETWORKPLACESSHELLVIEWCOLUMNS 2
#define NETWORKPLACESSHELLVIEWCOLUMNS sizeof(networkplaces_header)/sizeof(shvheader)
/**************************************************************************
* ISF_NetworkPlaces_Constructor
......@@ -534,11 +535,13 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumnState (
{
IGenericSFImpl *This = (IGenericSFImpl *)iface;
TRACE ("(%p)\n", This);
TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
if (!pcsFlags || iColumn >= NETWORKPLACESSHELLVIEWCOLUMNS)
return E_INVALIDARG;
*pcsFlags = NetworkPlacesSFHeader[iColumn].pcsFlags;
*pcsFlags = networkplaces_header[iColumn].pcsFlags;
return S_OK;
}
......@@ -600,7 +603,7 @@ static const IShellFolder2Vtbl vt_ShellFolder2 = {
static HRESULT WINAPI INPFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface,
REFIID iid, LPVOID * ppvObj)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)\n", This);
......@@ -612,7 +615,7 @@ static HRESULT WINAPI INPFldr_PersistFolder2_QueryInterface (IPersistFolder2 * i
*/
static ULONG WINAPI INPFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(count=%u)\n", This, This->ref);
......@@ -624,7 +627,7 @@ static ULONG WINAPI INPFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
*/
static ULONG WINAPI INPFldr_PersistFolder2_Release (IPersistFolder2 * iface)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(count=%u)\n", This, This->ref);
......@@ -637,7 +640,7 @@ static ULONG WINAPI INPFldr_PersistFolder2_Release (IPersistFolder2 * iface)
static HRESULT WINAPI INPFldr_PersistFolder2_GetClassID (
IPersistFolder2 * iface, CLSID * lpClassId)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)\n", This);
......@@ -657,7 +660,7 @@ static HRESULT WINAPI INPFldr_PersistFolder2_GetClassID (
static HRESULT WINAPI INPFldr_PersistFolder2_Initialize (
IPersistFolder2 * iface, LPCITEMIDLIST pidl)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(%p)\n", This, pidl);
......@@ -670,7 +673,7 @@ static HRESULT WINAPI INPFldr_PersistFolder2_Initialize (
static HRESULT WINAPI INPFldr_PersistFolder2_GetCurFolder (
IPersistFolder2 * iface, LPITEMIDLIST * pidl)
{
_ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
IGenericSFImpl *This = impl_from_IPersistFolder2(iface);
TRACE ("(%p)->(%p)\n", This, pidl);
......
......@@ -303,14 +303,7 @@ static HRESULT WINAPI IShellFolder_Printers_fnGetDetailsOf (IShellFolder2 *iface
return E_NOTIMPL;
if (!pidl)
{
psd->fmt = printers_header[iColumn].fmt;
psd->cxChar = printers_header[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA (shell32_hInstance, printers_header[iColumn].colnameid,
psd->str.u.cStr, MAX_PATH);
return S_OK;
}
return SHELL32_GetColumnDetails(printers_header, iColumn, psd);
FIXME("unimplemented for supplied pidl\n");
......
......@@ -1315,7 +1315,9 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetDetailsOf(IShellFolder2* iface
HRESULT hr = E_FAIL;
struct passwd *pPasswd;
struct group *pGroup;
static const shvheader SFHeader[SHELLVIEWCOLUMNS] = {
struct stat statItem;
static const shvheader unixfs_header[SHELLVIEWCOLUMNS] = {
{IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
{IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
{IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
......@@ -1330,14 +1332,9 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetDetailsOf(IShellFolder2* iface
if (!psd || iColumn >= SHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl) {
psd->fmt = SFHeader[iColumn].fmt;
psd->cxChar = SFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA(shell32_hInstance, SFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
return S_OK;
} else {
struct stat statItem;
if (!pidl)
return SHELL32_GetColumnDetails(unixfs_header, iColumn, psd);
if (iColumn == 4 || iColumn == 5 || iColumn == 6) {
char szPath[FILENAME_MAX];
strcpy(szPath, This->m_pszPath);
......@@ -1346,8 +1343,10 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetDetailsOf(IShellFolder2* iface
if (stat(szPath, &statItem))
return E_INVALIDARG;
}
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);
......@@ -1383,7 +1382,6 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetDetailsOf(IShellFolder2* iface
if (pGroup) strcpy(psd->str.u.cStr, pGroup->gr_name);
break;
}
}
return hr;
}
......
......@@ -30,6 +30,8 @@
#include <stdio.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "winerror.h"
#include "windef.h"
......@@ -542,6 +544,16 @@ HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST p
return nReturn;
}
HRESULT SHELL32_GetColumnDetails(const shvheader *data, int column, SHELLDETAILS *details)
{
details->fmt = data[column].fmt;
details->cxChar = data[column].cxChar;
details->str.uType = STRRET_CSTR;
LoadStringA (shell32_hInstance, data[column].colnameid, details->str.u.cStr, MAX_PATH);
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