static const shvheader GenericSFHeader[] = {
- {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
+ {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 15},
{IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
- {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
- {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
- {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
+ {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 10},
+ {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 12},
+ {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 10}
};
#define GENERICSHELLVIEWCOLUMNS 5
pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, szElement);
if (pidlTemp != NULL)
{
+ /* We are creating an id list without ensuring that the items exist.
+ If we have a remaining path, this must be a folder.
+ We have to do it now because it is set as a file by default */
+ if (szNext)
+ {
+ pidlTemp->mkid.abID[0] = PT_FOLDER;
+ }
hr = S_OK;
}
else
TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", this, pidl, pbc,
shdebugstr_guid(&riid), ppvOut);
- return SHELL32_BindToChild(pidlRoot, sPathTarget, pidl, riid, ppvOut);
+ return SHELL32_BindToFS(pidlRoot, sPathTarget, pidl, riid, ppvOut);
}
/**************************************************************************
PCUIDLIST_RELATIVE pidl1,
PCUIDLIST_RELATIVE pidl2)
{
- int nReturn;
+ LPPIDLDATA pData1 = _ILGetDataPointer(pidl1);
+ LPPIDLDATA pData2 = _ILGetDataPointer(pidl2);
+ FileStructW* pDataW1 = _ILGetFileStructW(pidl1);
+ FileStructW* pDataW2 = _ILGetFileStructW(pidl2);
+ BOOL bIsFolder1 = _ILIsFolder(pidl1);
+ BOOL bIsFolder2 = _ILIsFolder(pidl2);
+ LPWSTR pExtension1, pExtension2;
+
+ if (!pDataW1 || !pDataW2 || LOWORD(lParam) >= GENERICSHELLVIEWCOLUMNS)
+ return E_INVALIDARG;
- TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", this, lParam, pidl1, pidl2);
- nReturn = SHELL32_CompareIDs(this, lParam, pidl1, pidl2);
- TRACE("-- %i\n", nReturn);
- return nReturn;
+ /* When sorting between a File and a Folder, the Folder gets sorted first */
+ if (bIsFolder1 != bIsFolder2)
+ {
+ return MAKE_COMPARE_HRESULT(bIsFolder1 ? -1 : 1);
+ }
+
+ int result;
+ switch (LOWORD(lParam))
+ {
+ case 0: /* Name */
+ result = wcsicmp(pDataW1->wszName, pDataW2->wszName);
+ break;
+ case 2: /* Type */
+ pExtension1 = PathFindExtensionW(pDataW1->wszName);
+ pExtension2 = PathFindExtensionW(pDataW2->wszName);
+ result = wcsicmp(pExtension1, pExtension2);
+ break;
+ case 1: /* Size */
+ result = pData1->u.file.dwFileSize - pData2->u.file.dwFileSize;
+ break;
+ case 3: /* Modified */
+ result = pData1->u.file.uFileDate - pData2->u.file.uFileDate;
+ if (result == 0)
+ result = pData1->u.file.uFileTime - pData2->u.file.uFileTime;
+ break;
+ case 4: /* Attributes */
+ return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
+ }
+ return MAKE_COMPARE_HRESULT(result);
}
/**************************************************************************
}
else if (IsEqualIID (riid, IID_IShellView))
{
- hr = IShellView_Constructor ((IShellFolder *)this, &pShellView);
- if (pShellView)
- {
- hr = pShellView->QueryInterface(riid, ppvOut);
- }
+ hr = CDefView_Constructor(this, riid, ppvOut);
}
}
TRACE("-- (%p)->(interface=%p)\n", this, ppvOut);
REFIID riid, UINT * prgfInOut,
LPVOID * ppvOut)
{
- LPITEMIDLIST pidl;
- IUnknown *pObj = NULL;
+ LPVOID pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
hr = IDataObject_Constructor (hwndOwner, pidlRoot, (LPCITEMIDLIST*)&pidlRoot, 1, (IDataObject **)&pObj);
}
}
- else if (IsEqualIID (riid, IID_IExtractIconA) && (cidl == 1))
- {
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconA_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
- }
- else if (IsEqualIID (riid, IID_IExtractIconW) && (cidl == 1))
+ else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
{
- pidl = ILCombine (pidlRoot, apidl[0]);
- pObj = IExtractIconW_Constructor (pidl);
- SHFree (pidl);
- hr = S_OK;
+ hr = GenericExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
}
else if (IsEqualIID (riid, IID_IDropTarget))
{
else if ((IsEqualIID(riid, IID_IShellLinkW) ||
IsEqualIID(riid, IID_IShellLinkA)) && (cidl == 1))
{
- pidl = ILCombine (pidlRoot, apidl[0]);
- hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
- SHFree (pidl);
+ hr = IShellLink_ConstructFromFile(this, apidl[0], riid, &pObj);
}
else
hr = E_NOINTERFACE;
HRESULT WINAPI CFSFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl,
DWORD dwFlags, LPSTRRET strRet)
{
- LPWSTR pszPath;
-
- HRESULT hr = S_OK;
- int len = 0;
-
- TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl, dwFlags, strRet);
- pdump(pidl);
-
if (!pidl || !strRet)
return E_INVALIDARG;
- pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
- if (!pszPath)
- return E_OUTOFMEMORY;
-
- if (_ILIsDesktop(pidl)) /* empty pidl */
+ /* If it is a complex pidl, let the child handle it */
+ if (!_ILIsPidlSimple (pidl)) /* complex pidl */
{
- if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
- (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
- {
- if (sPathTarget)
- lstrcpynW(pszPath, sPathTarget, MAX_PATH);
- }
- else
- hr = E_INVALIDARG; /* pidl has to contain exactly one non null SHITEMID */
+ return SHELL32_GetDisplayNameOfChild(this, pidl, dwFlags, strRet);
}
- else if (_ILIsPidlSimple(pidl))
+ else if (!pidl->mkid.cb) /* empty pidl */
{
- if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
- (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) &&
- sPathTarget)
+ /* If it is an empty pidl return only the path of the folder */
+ if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
+ (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) &&
+ sPathTarget)
{
- lstrcpynW(pszPath, sPathTarget, MAX_PATH);
- PathAddBackslashW(pszPath);
- len = wcslen(pszPath);
+ return SHSetStrRet(strRet, sPathTarget);
}
- _ILSimpleGetTextW(pidl, pszPath + len, MAX_PATH + 1 - len);
- if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
- } else
- hr = SHELL32_GetDisplayNameOfChild(this, pidl, dwFlags, pszPath, MAX_PATH);
+ return E_INVALIDARG;
+ }
+
+ int len = 0;
+ LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
+ if (!pszPath)
+ return E_OUTOFMEMORY;
- if (SUCCEEDED(hr)) {
- /* Win9x always returns ANSI strings, NT always returns Unicode strings */
- if (GetVersion() & 0x80000000)
- {
- strRet->uType = STRRET_CSTR;
- if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->cStr, MAX_PATH,
- NULL, NULL))
- strRet->cStr[0] = '\0';
- CoTaskMemFree(pszPath);
- }
- else
- {
- strRet->uType = STRRET_WSTR;
- strRet->pOleStr = pszPath;
- }
- } else
- CoTaskMemFree(pszPath);
+ if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
+ (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) &&
+ sPathTarget)
+ {
+ lstrcpynW(pszPath, sPathTarget, MAX_PATH);
+ PathAddBackslashW(pszPath);
+ len = wcslen(pszPath);
+ }
+ _ILSimpleGetTextW(pidl, pszPath + len, MAX_PATH + 1 - len);
+ if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
+
+ strRet->uType = STRRET_WSTR;
+ strRet->pOleStr = pszPath;
TRACE ("-- (%p)->(%s)\n", this, strRet->uType == STRRET_CSTR ? strRet->cStr : debugstr_w(strRet->pOleStr));
- return hr;
+ return S_OK;
}
/**************************************************************************
/* 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.cStr, MAX_PATH);
- return S_OK;
+ return SHSetStrRet(&psd->str, GenericSFHeader[iColumn].colnameid);
}
else
{
return E_NOTIMPL;
}
-/****************************************************************************
- * ISFHelper for IShellFolder implementation
- */
-
-/****************************************************************************
- * CFSFolder::GetUniqueName
- *
- * creates a unique folder name
- */
-
-HRESULT WINAPI CFSFolder::GetUniqueName(LPWSTR pwszName, UINT uLen)
-{
- CComPtr<IEnumIDList> penum;
- HRESULT hr;
- WCHAR wszText[MAX_PATH];
- WCHAR wszNewFolder[25];
- const WCHAR wszFormat[] = L"%s %d";
-
- LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder));
-
- TRACE ("(%p)(%p %u)\n", this, pwszName, uLen);
-
- if (uLen < _countof(wszNewFolder) + 3)
- return E_POINTER;
-
- lstrcpynW (pwszName, wszNewFolder, uLen);
-
- hr = EnumObjects(0, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum);
- if (penum)
- {
- LPITEMIDLIST pidl;
- DWORD dwFetched;
- int i = 1;
-
-next:
- penum->Reset ();
- while (S_OK == penum->Next(1, &pidl, &dwFetched) && dwFetched)
- {
- _ILSimpleGetTextW(pidl, wszText, MAX_PATH);
- if (0 == lstrcmpiW(wszText, pwszName))
- {
- _snwprintf(pwszName, uLen, wszFormat, wszNewFolder, i++);
- if (i > 99)
- {
- hr = E_FAIL;
- break;
- }
- goto next;
- }
- }
- }
- return hr;
-}
-
-/****************************************************************************
- * CFSFolder::AddFolder
- *
- * adds a new folder.
- */
-
-HRESULT WINAPI CFSFolder::AddFolder(HWND hwnd, LPCWSTR pwszName,
- LPITEMIDLIST * ppidlOut)
-{
- WCHAR wszNewDir[MAX_PATH];
- DWORD bRes;
- HRESULT hres = E_FAIL;
-
- TRACE ("(%p)(%s %p)\n", this, debugstr_w(pwszName), ppidlOut);
-
- wszNewDir[0] = 0;
- if (sPathTarget)
- lstrcpynW(wszNewDir, sPathTarget, MAX_PATH);
- PathAppendW(wszNewDir, pwszName);
-
- bRes = CreateDirectoryW(wszNewDir, NULL);
- if (bRes)
- {
- SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, wszNewDir, NULL);
-
- hres = S_OK;
-
- if (ppidlOut)
- hres = _ILCreateFromPathW(wszNewDir, ppidlOut);
- }
- else
- {
- WCHAR wszText[128 + MAX_PATH];
- WCHAR wszTempText[128];
- WCHAR wszCaption[256];
-
- /* Cannot Create folder because of permissions */
- LoadStringW(shell32_hInstance, IDS_CREATEFOLDER_DENIED, wszTempText,
- _countof(wszTempText));
- LoadStringW(shell32_hInstance, IDS_CREATEFOLDER_CAPTION, wszCaption,
- _countof(wszCaption));
- swprintf(wszText, wszTempText, wszNewDir);
- MessageBoxW(hwnd, wszText, wszCaption, MB_OK | MB_ICONEXCLAMATION);
- }
-
- return hres;
-}
-
/****************************************************************************
* BuildPathsList
*
return pwszPathsList;
}
-/****************************************************************************
- * CFSFolder::DeleteItems
- *
- * deletes items in folder
- */
-HRESULT WINAPI CFSFolder::DeleteItems(UINT cidl, LPCITEMIDLIST *apidl)
-{
- UINT i;
- SHFILEOPSTRUCTW op;
- WCHAR wszPath[MAX_PATH];
- WCHAR *wszPathsList;
- HRESULT ret;
- WCHAR *wszCurrentPath;
-
- TRACE ("(%p)(%u %p)\n", this, cidl, apidl);
- if (cidl == 0) return S_OK;
-
- if (sPathTarget)
- lstrcpynW(wszPath, sPathTarget, MAX_PATH);
- else
- wszPath[0] = '\0';
- PathAddBackslashW(wszPath);
- wszPathsList = BuildPathsList(wszPath, cidl, apidl);
-
- ZeroMemory(&op, sizeof(op));
- op.hwnd = GetActiveWindow();
- op.wFunc = FO_DELETE;
- op.pFrom = wszPathsList;
- op.fFlags = FOF_ALLOWUNDO;
- if (SHFileOperationW(&op))
- {
- WARN("SHFileOperation failed\n");
- ret = E_FAIL;
- }
- else
- ret = S_OK;
-
- /* we currently need to manually send the notifies */
- wszCurrentPath = wszPathsList;
- for (i = 0; i < cidl; i++)
- {
- LONG wEventId;
-
- if (_ILIsFolder(apidl[i]))
- wEventId = SHCNE_RMDIR;
- else if (_ILIsValue(apidl[i]))
- wEventId = SHCNE_DELETE;
- else
- continue;
-
- /* check if file exists */
- if (GetFileAttributesW(wszCurrentPath) == INVALID_FILE_ATTRIBUTES)
- {
- LPITEMIDLIST pidl = ILCombine(pidlRoot, apidl[i]);
- SHChangeNotify(wEventId, SHCNF_IDLIST, pidl, NULL);
- SHFree(pidl);
- }
-
- wszCurrentPath += wcslen(wszCurrentPath) + 1;
- }
- HeapFree(GetProcessHeap(), 0, wszPathsList);
- return ret;
-}
-
/****************************************************************************
* CFSFolder::CopyItems
*
LPWSTR pszSrc, pszTarget, pszSrcList, pszTargetList, pszFileName;
int res, length;
HRESULT hr;
- STRRET strRet;
TRACE ("(%p)->(%p,%u,%p)\n", this, pSFFrom, cidl, apidl);
return hr;
}
- hr = pSFFrom->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strRet);
- if (FAILED(hr))
- {
- SHFree(pidl);
- return hr;
- }
+ hr = SHGetPathFromIDListW(pidl, szSrcPath);
+ SHFree(pidl);
- hr = StrRetToBufW(&strRet, pidl, szSrcPath, MAX_PATH);
if (FAILED(hr))
- {
- SHFree(pidl);
return hr;
- }
- SHFree(pidl);
pszSrc = PathAddBackslashW(szSrcPath);
if (fAcceptFmt) { /* Does our interpretation of the keystate ... */
*pdwEffect = KeyStateToDropEffect (dwKeyState);
-
+
if (*pdwEffect == DROPEFFECT_NONE)
*pdwEffect = dwEffect;
{
TRACE("(%p) object dropped, effect %u\n", this, *pdwEffect);
+ if (!pdwEffect)
+ return E_INVALIDARG;
+
+ QueryDrop(dwKeyState, pdwEffect);
+
BOOL fIsOpAsync = FALSE;
CComPtr<IAsyncOperation> pAsyncOperation;
hr = E_FAIL;
break;
}
- hr = IShellLink_ConstructFromFile(NULL, IID_IPersistFile, ILCombine(pidl, apidl[i]), (LPVOID*)&ppf);
+ hr = IShellLink_ConstructFromFile(this, apidl[i], IID_PPV_ARG(IPersistFile, &ppf));
if (FAILED(hr)) {
ERR("Error constructing link from file");
break;
TRACE("CFSFolder::_GetDropTarget entered\n");
- if (_ILGetGUIDPointer (pidl) || _ILIsFolder (pidl))
+ if (_ILIsFolder (pidl))
return this->BindToObject(pidl, NULL, IID_IDropTarget, ppvOut);
STRRET strFile;