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