Commit 7b597d4c authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Unicode-ify the icon cache and SHGetFileInfo.

parent fefc8c62
...@@ -151,7 +151,6 @@ static ULONG WINAPI IExtractIconW_fnRelease(IExtractIconW * iface) ...@@ -151,7 +151,6 @@ static ULONG WINAPI IExtractIconW_fnRelease(IExtractIconW * iface)
} }
WCHAR swShell32Name[MAX_PATH]; WCHAR swShell32Name[MAX_PATH];
char sShell32Name[MAX_PATH];
/************************************************************************** /**************************************************************************
* IExtractIconW_GetIconLocation * IExtractIconW_GetIconLocation
......
...@@ -53,7 +53,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); ...@@ -53,7 +53,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
typedef struct typedef struct
{ {
LPSTR sSourceFile; /* file (not path!) containing the icon */ LPWSTR sSourceFile; /* file (not path!) containing the icon */
DWORD dwSourceIndex; /* index within the file, if it is a resoure ID it will be negated */ DWORD dwSourceIndex; /* index within the file, if it is a resoure ID it will be negated */
DWORD dwListIndex; /* index within the iconlist */ DWORD dwListIndex; /* index within the iconlist */
DWORD dwFlags; /* GIL_* flags */ DWORD dwFlags; /* GIL_* flags */
...@@ -83,7 +83,7 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam) ...@@ -83,7 +83,7 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
if (((LPSIC_ENTRY)p1)->dwSourceIndex != ((LPSIC_ENTRY)p2)->dwSourceIndex) /* first the faster one*/ if (((LPSIC_ENTRY)p1)->dwSourceIndex != ((LPSIC_ENTRY)p2)->dwSourceIndex) /* first the faster one*/
return 1; return 1;
if (strcasecmp(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile)) if (strcmpiW(((LPSIC_ENTRY)p1)->sSourceFile,((LPSIC_ENTRY)p2)->sSourceFile))
return 1; return 1;
return 0; return 0;
...@@ -94,17 +94,17 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam) ...@@ -94,17 +94,17 @@ static INT CALLBACK SIC_CompareEntries( LPVOID p1, LPVOID p2, LPARAM lparam)
* NOTES * NOTES
* appends an icon pair to the end of the cache * appends an icon pair to the end of the cache
*/ */
static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon) static INT SIC_IconAppend (LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallIcon, HICON hBigIcon)
{ LPSIC_ENTRY lpsice; { LPSIC_ENTRY lpsice;
INT ret, index, index1; INT ret, index, index1;
char path[MAX_PATH]; WCHAR path[MAX_PATH];
TRACE("%s %i %p %p\n", sSourceFile, dwSourceIndex, hSmallIcon ,hBigIcon); TRACE("%s %i %p %p\n", debugstr_w(sSourceFile), dwSourceIndex, hSmallIcon ,hBigIcon);
lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY)); lpsice = (LPSIC_ENTRY) SHAlloc (sizeof (SIC_ENTRY));
GetFullPathNameA(sSourceFile, MAX_PATH, path, NULL); GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, strlen(path)+1 ); lpsice->sSourceFile = HeapAlloc( GetProcessHeap(), 0, (strlenW(path)+1)*sizeof(WCHAR) );
strcpy( lpsice->sSourceFile, path ); strcpyW( lpsice->sSourceFile, path );
lpsice->dwSourceIndex = dwSourceIndex; lpsice->dwSourceIndex = dwSourceIndex;
...@@ -139,16 +139,16 @@ static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIc ...@@ -139,16 +139,16 @@ static INT SIC_IconAppend (LPCSTR sSourceFile, INT dwSourceIndex, HICON hSmallIc
* NOTES * NOTES
* gets small/big icon by number from a file * gets small/big icon by number from a file
*/ */
static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex) static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex)
{ HICON hiconLarge=0; { HICON hiconLarge=0;
HICON hiconSmall=0; HICON hiconSmall=0;
PrivateExtractIconsA( sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, 0, 1, 0 ); PrivateExtractIconsW( sSourceFile, dwSourceIndex, 32, 32, &hiconLarge, 0, 1, 0 );
PrivateExtractIconsA( sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, 0, 1, 0 ); PrivateExtractIconsW( sSourceFile, dwSourceIndex, 16, 16, &hiconSmall, 0, 1, 0 );
if ( !hiconLarge || !hiconSmall) if ( !hiconLarge || !hiconSmall)
{ {
WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, sSourceFile, hiconLarge, hiconSmall); WARN("failure loading icon %i from %s (%p %p)\n", dwSourceIndex, debugstr_w(sSourceFile), hiconLarge, hiconSmall);
return -1; return -1;
} }
return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge); return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge);
...@@ -164,15 +164,16 @@ static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex) ...@@ -164,15 +164,16 @@ static INT SIC_LoadIcon (LPCSTR sSourceFile, INT dwSourceIndex)
* look in the cache for a proper icon. if not available the icon is taken * look in the cache for a proper icon. if not available the icon is taken
* from the file and cached * from the file and cached
*/ */
INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex ) INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex )
{ SIC_ENTRY sice; {
SIC_ENTRY sice;
INT ret, index = INVALID_INDEX; INT ret, index = INVALID_INDEX;
char path[MAX_PATH]; WCHAR path[MAX_PATH];
TRACE("%s %i\n", sSourceFile, dwSourceIndex); TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
GetFullPathNameA(sSourceFile, MAX_PATH, path, NULL); GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
sice.sSourceFile = path; sice.sSourceFile = path;
sice.dwSourceIndex = dwSourceIndex; sice.dwSourceIndex = dwSourceIndex;
EnterCriticalSection(&SHELL32_SicCS); EnterCriticalSection(&SHELL32_SicCS);
...@@ -202,10 +203,10 @@ INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex ) ...@@ -202,10 +203,10 @@ INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex )
* NOTES * NOTES
* retrieves the specified icon from the iconcache. if not found tries to load the icon * retrieves the specified icon from the iconcache. if not found tries to load the icon
*/ */
static HICON WINE_UNUSED SIC_GetIcon (LPCSTR sSourceFile, INT dwSourceIndex, BOOL bSmallIcon ) static HICON WINE_UNUSED SIC_GetIcon (LPCWSTR sSourceFile, INT dwSourceIndex, BOOL bSmallIcon )
{ INT index; { INT index;
TRACE("%s %i\n", sSourceFile, dwSourceIndex); TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
index = SIC_GetIconIndex(sSourceFile, dwSourceIndex); index = SIC_GetIconIndex(sSourceFile, dwSourceIndex);
...@@ -259,7 +260,7 @@ BOOL SIC_Initialize(void) ...@@ -259,7 +260,7 @@ BOOL SIC_Initialize(void)
hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 16, 16,LR_SHARED); hSm = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 16, 16,LR_SHARED);
hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 32, 32,LR_SHARED); hLg = LoadImageA(shell32_hInstance, MAKEINTRESOURCEA(0), IMAGE_ICON, 32, 32,LR_SHARED);
} }
SIC_IconAppend (sShell32Name, index, hSm, hLg); SIC_IconAppend (swShell32Name, index, hSm, hLg);
} }
TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList); TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList);
...@@ -327,8 +328,8 @@ BOOL PidlToSicIndex ( ...@@ -327,8 +328,8 @@ BOOL PidlToSicIndex (
UINT uFlags, UINT uFlags,
int * pIndex) int * pIndex)
{ {
IExtractIconA *ei; IExtractIconW *ei;
char szIconFile[MAX_PATH]; /* file containing the icon */ WCHAR szIconFile[MAX_PATH]; /* file containing the icon */
INT iSourceIndex; /* index or resID(negated) in this file */ INT iSourceIndex; /* index or resID(negated) in this file */
BOOL ret = FALSE; BOOL ret = FALSE;
UINT dwFlags = 0; UINT dwFlags = 0;
...@@ -337,12 +338,12 @@ BOOL PidlToSicIndex ( ...@@ -337,12 +338,12 @@ BOOL PidlToSicIndex (
if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&ei))) if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&ei)))
{ {
if (SUCCEEDED(IExtractIconA_GetIconLocation(ei, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags))) if (SUCCEEDED(IExtractIconW_GetIconLocation(ei, uFlags, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
{ {
*pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex); *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
ret = TRUE; ret = TRUE;
} }
IExtractIconA_Release(ei); IExtractIconW_Release(ei);
} }
if (INVALID_INDEX == *pIndex) /* default icon when failed */ if (INVALID_INDEX == *pIndex) /* default icon when failed */
...@@ -383,19 +384,27 @@ int WINAPI SHMapPIDLToSystemImageListIndex( ...@@ -383,19 +384,27 @@ int WINAPI SHMapPIDLToSystemImageListIndex(
*/ */
INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc) INT WINAPI Shell_GetCachedImageIndexA(LPCSTR szPath, INT nIndex, BOOL bSimulateDoc)
{ {
INT ret, len;
LPWSTR szTemp;
WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc); WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_a(szPath), nIndex, bSimulateDoc);
return SIC_GetIconIndex(szPath, nIndex);
len = MultiByteToWideChar( CP_ACP, 0, szPath, -1, NULL, 0 );
szTemp = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, szPath, -1, szTemp, len );
ret = SIC_GetIconIndex( szTemp, nIndex );
HeapFree( GetProcessHeap(), 0, szTemp );
return ret;
} }
INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc) INT WINAPI Shell_GetCachedImageIndexW(LPCWSTR szPath, INT nIndex, BOOL bSimulateDoc)
{ INT ret; {
LPSTR sTemp = HEAP_strdupWtoA (GetProcessHeap(),0,szPath);
WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc); WARN("(%s,%08x,%08x) semi-stub.\n",debugstr_w(szPath), nIndex, bSimulateDoc);
ret = SIC_GetIconIndex(sTemp, nIndex); return SIC_GetIconIndex(szPath, nIndex);
HeapFree(GetProcessHeap(),0,sTemp);
return ret;
} }
INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc) INT WINAPI Shell_GetCachedImageIndexAW(LPCVOID szPath, INT nIndex, BOOL bSimulateDoc)
......
...@@ -53,7 +53,7 @@ BOOL WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList) ...@@ -53,7 +53,7 @@ BOOL WINAPI Shell_GetImageList(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList)
BOOL SIC_Initialize(void); BOOL SIC_Initialize(void);
void SIC_Destroy(void); void SIC_Destroy(void);
BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int * pIndex); BOOL PidlToSicIndex (IShellFolder * sh, LPCITEMIDLIST pidl, BOOL bBigIcon, UINT uFlags, int * pIndex);
INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex ); INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex );
/* Classes Root */ /* Classes Root */
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, DWORD len, BOOL bPrependDot); BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, DWORD len, BOOL bPrependDot);
...@@ -234,6 +234,5 @@ typedef UINT (*SHELL_ExecuteW32)(const WCHAR *lpCmd, void *env, BOOL shWait, ...@@ -234,6 +234,5 @@ typedef UINT (*SHELL_ExecuteW32)(const WCHAR *lpCmd, void *env, BOOL shWait,
BOOL WINAPI ShellExecuteExW32(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc); BOOL WINAPI ShellExecuteExW32(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc);
extern WCHAR swShell32Name[MAX_PATH]; extern WCHAR swShell32Name[MAX_PATH];
extern char sShell32Name[MAX_PATH];
#endif #endif
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