Commit cc15fcc4 authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

shell32: Unicode'ify ISFHelper interface.

parent 46ecb15c
......@@ -46,8 +46,8 @@ DECLARE_INTERFACE_(ISFHelper,IUnknown)
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** ISFHelper methods ***/
STDMETHOD(GetUniqueName)(THIS_ LPSTR lpName, UINT uLen) PURE;
STDMETHOD(AddFolder)(THIS_ HWND hwnd, LPCSTR lpName, LPITEMIDLIST * ppidlOut) PURE;
STDMETHOD(GetUniqueName)(THIS_ LPWSTR lpName, UINT uLen) PURE;
STDMETHOD(AddFolder)(THIS_ HWND hwnd, LPCWSTR lpName, LPITEMIDLIST * ppidlOut) PURE;
STDMETHOD(DeleteItems)(THIS_ UINT cidl, LPCITEMIDLIST * apidl) PURE;
STDMETHOD(CopyItems)(THIS_ IShellFolder * pSFFrom, UINT cidl, LPCITEMIDLIST * apidl) PURE;
};
......
......@@ -1064,20 +1064,21 @@ static ULONG WINAPI ISFHelper_fnRelease (ISFHelper * iface)
*/
static HRESULT WINAPI
ISFHelper_fnGetUniqueName (ISFHelper * iface, LPSTR lpName, UINT uLen)
ISFHelper_fnGetUniqueName (ISFHelper * iface, LPWSTR pwszName, UINT uLen)
{
IGenericSFImpl *This = impl_from_ISFHelper(iface);
IEnumIDList *penum;
HRESULT hr;
char szText[MAX_PATH];
const char *szNewFolder = "New Folder";
WCHAR wszText[MAX_PATH];
const WCHAR wszNewFolder[] = {'N','e','w',' ','F','o','l','d','e','r',0 };
const WCHAR wszFormat[] = {'%','s',' ','%','d',0 };
TRACE ("(%p)(%s %u)\n", This, lpName, uLen);
TRACE ("(%p)(%p %u)\n", This, pwszName, uLen);
if (uLen < strlen (szNewFolder) + 4)
if (uLen < sizeof(wszNewFolder)/sizeof(WCHAR) + 3)
return E_POINTER;
strcpy (lpName, szNewFolder);
lstrcpynW (pwszName, wszNewFolder, uLen);
hr = IShellFolder_fnEnumObjects (_IShellFolder2_ (This), 0,
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum);
......@@ -1090,9 +1091,9 @@ next:
IEnumIDList_Reset (penum);
while (S_OK == IEnumIDList_Next (penum, 1, &pidl, &dwFetched) &&
dwFetched) {
_ILSimpleGetText (pidl, szText, MAX_PATH);
if (0 == strcasecmp (szText, lpName)) {
sprintf (lpName, "%s %d", szNewFolder, i++);
_ILSimpleGetTextW (pidl, wszText, MAX_PATH);
if (0 == lstrcmpiW (wszText, pwszName)) {
snprintfW (pwszName, uLen, wszFormat, wszNewFolder, i++);
if (i > 99) {
hr = E_FAIL;
break;
......@@ -1113,40 +1114,41 @@ next:
*/
static HRESULT WINAPI
ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCSTR lpName,
ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCWSTR pwszName,
LPITEMIDLIST * ppidlOut)
{
IGenericSFImpl *This = impl_from_ISFHelper(iface);
char lpstrNewDir[MAX_PATH];
WCHAR wszNewDir[MAX_PATH];
DWORD bRes;
HRESULT hres = E_FAIL;
TRACE ("(%p)(%s %p)\n", This, lpName, ppidlOut);
TRACE ("(%p)(%s %p)\n", This, debugstr_w(pwszName), ppidlOut);
if (!WideCharToMultiByte(CP_ACP, 0, This->sPathTarget, -1, lpstrNewDir, MAX_PATH, NULL, NULL))
lpstrNewDir[0] = '\0';
PathAppendA(lpstrNewDir, lpName);
wszNewDir[0] = 0;
if (This->sPathTarget)
lstrcpynW(wszNewDir, This->sPathTarget, MAX_PATH);
PathAppendW(wszNewDir, pwszName);
bRes = CreateDirectoryA (lpstrNewDir, NULL);
bRes = CreateDirectoryW (wszNewDir, NULL);
if (bRes) {
SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHA, lpstrNewDir, NULL);
SHChangeNotify (SHCNE_MKDIR, SHCNF_PATHW, wszNewDir, NULL);
hres = S_OK;
if (ppidlOut)
hres = _ILCreateFromPathA(lpstrNewDir, ppidlOut);
hres = _ILCreateFromPathW(wszNewDir, ppidlOut);
} else {
char lpstrText[128 + MAX_PATH];
char lpstrTempText[128];
char lpstrCaption[256];
WCHAR wszText[128 + MAX_PATH];
WCHAR wszTempText[128];
WCHAR wszCaption[256];
/* Cannot Create folder because of permissions */
LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_DENIED, lpstrTempText,
sizeof (lpstrTempText));
LoadStringA (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, lpstrCaption,
sizeof (lpstrCaption));
sprintf (lpstrText, lpstrTempText, lpstrNewDir);
MessageBoxA (hwnd, lpstrText, lpstrCaption, MB_OK | MB_ICONEXCLAMATION);
LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_DENIED, wszTempText,
sizeof (wszTempText));
LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, wszCaption,
sizeof (wszCaption));
sprintfW (wszText, wszTempText, wszNewDir);
MessageBoxW (hwnd, wszText, wszCaption, MB_OK | MB_ICONEXCLAMATION);
}
return hres;
......
......@@ -1680,7 +1680,7 @@ static ULONG WINAPI UnixFolder_ISFHelper_Release(ISFHelper* iface)
STATIC_CAST(IShellFolder2, ADJUST_THIS(UnixFolder, ISFHelper, iface)));
}
static HRESULT WINAPI UnixFolder_ISFHelper_GetUniqueName(ISFHelper* iface, LPSTR lpName, UINT uLen)
static HRESULT WINAPI UnixFolder_ISFHelper_GetUniqueName(ISFHelper* iface, LPWSTR pwszName, UINT uLen)
{
UnixFolder *This = ADJUST_THIS(UnixFolder, ISFHelper, iface);
IEnumIDList *pEnum;
......@@ -1688,23 +1688,26 @@ static HRESULT WINAPI UnixFolder_ISFHelper_GetUniqueName(ISFHelper* iface, LPSTR
LPITEMIDLIST pidlElem;
DWORD dwFetched;
int i;
static const char szNewFolder[] = "New Folder";
static const WCHAR wszNewFolder[] = { 'N','e','w',' ','F','o','l','d','e','r', 0 };
static const WCHAR wszFormat[] = { '%','s',' ','%','d',0 };
TRACE("(iface=%p, lpName=%p, uLen=%u)\n", iface, lpName, uLen);
TRACE("(iface=%p, pwszName=%p, uLen=%u)\n", iface, pwszName, uLen);
if (uLen < sizeof(szNewFolder)+3)
if (uLen < sizeof(wszNewFolder)/sizeof(WCHAR)+3)
return E_INVALIDARG;
hr = IShellFolder2_EnumObjects(STATIC_CAST(IShellFolder2, This), 0,
SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN, &pEnum);
if (SUCCEEDED(hr)) {
lstrcpyA(lpName, szNewFolder);
lstrcpynW(pwszName, wszNewFolder, uLen);
IEnumIDList_Reset(pEnum);
i = 2;
while ((IEnumIDList_Next(pEnum, 1, &pidlElem, &dwFetched) == S_OK) && (dwFetched == 1)) {
if (!strcasecmp(_ILGetTextPointer(pidlElem), lpName)) {
WCHAR wszTemp[MAX_PATH];
_ILSimpleGetTextW(pidlElem, wszTemp, MAX_PATH);
if (!lstrcmpiW(wszTemp, pwszName)) {
IEnumIDList_Reset(pEnum);
sprintf(lpName, "%s %d", szNewFolder, i++);
snprintfW(pwszName, uLen, wszFormat, wszNewFolder, i++);
if (i > 99) {
hr = E_FAIL;
break;
......@@ -1716,20 +1719,26 @@ static HRESULT WINAPI UnixFolder_ISFHelper_GetUniqueName(ISFHelper* iface, LPSTR
return hr;
}
static HRESULT WINAPI UnixFolder_ISFHelper_AddFolder(ISFHelper* iface, HWND hwnd, LPCSTR pszName,
static HRESULT WINAPI UnixFolder_ISFHelper_AddFolder(ISFHelper* iface, HWND hwnd, LPCWSTR pwszName,
LPITEMIDLIST* ppidlOut)
{
UnixFolder *This = ADJUST_THIS(UnixFolder, ISFHelper, iface);
char szNewDir[FILENAME_MAX];
int cBaseLen;
TRACE("(iface=%p, hwnd=%p, pszName=%s, ppidlOut=%p)\n", iface, hwnd, pszName, ppidlOut);
TRACE("(iface=%p, hwnd=%p, pwszName=%s, ppidlOut=%p)\n",
iface, hwnd, debugstr_w(pwszName), ppidlOut);
if (ppidlOut)
*ppidlOut = NULL;
lstrcpyA(szNewDir, This->m_pszPath);
lstrcatA(szNewDir, pszName);
if (!This->m_pszPath || !(This->m_dwAttributes & SFGAO_FILESYSTEM))
return E_FAIL;
lstrcpynA(szNewDir, This->m_pszPath, FILENAME_MAX);
cBaseLen = lstrlenA(szNewDir);
WideCharToMultiByte(CP_UNIXCP, 0, pwszName, -1, szNewDir+cBaseLen, FILENAME_MAX-cBaseLen, 0, 0);
if (mkdir(szNewDir, 0755)) {
char szMessage[256 + FILENAME_MAX];
char szCaption[256];
......@@ -1742,11 +1751,9 @@ static HRESULT WINAPI UnixFolder_ISFHelper_AddFolder(ISFHelper* iface, HWND hwnd
return E_FAIL;
} else {
LPITEMIDLIST pidlRelative;
WCHAR wszName[MAX_PATH];
/* Inform the shell */
MultiByteToWideChar(CP_UNIXCP, 0, pszName, -1, wszName, MAX_PATH);
if (UNIXFS_path_to_pidl(This, wszName, &pidlRelative)) {
if (UNIXFS_path_to_pidl(This, pwszName, &pidlRelative)) {
LPITEMIDLIST pidlAbsolute = ILCombine(This->m_pidlLocation, pidlRelative);
if (ppidlOut)
*ppidlOut = pidlRelative;
......
......@@ -193,14 +193,14 @@ static void DoNewFolder(
{
BgCmImpl *This = (BgCmImpl *)iface;
ISFHelper * psfhlp;
char szName[MAX_PATH];
WCHAR wszName[MAX_PATH];
IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (LPVOID*)&psfhlp);
if (psfhlp)
{
LPITEMIDLIST pidl;
ISFHelper_GetUniqueName(psfhlp, szName, MAX_PATH);
ISFHelper_AddFolder(psfhlp, 0, szName, &pidl);
ISFHelper_GetUniqueName(psfhlp, wszName, MAX_PATH);
ISFHelper_AddFolder(psfhlp, 0, wszName, &pidl);
if(psv)
{
......
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