static BOOL should_notify( LPCITEMIDLIST changed, LPCITEMIDLIST watched, BOOL sub ) { TRACE("%p %p %d\n", changed, watched, sub ); if ( !watched ) return FALSE; if (ILIsEqual( watched, changed ) ) return TRUE; if( sub && ILIsParent( watched, changed, TRUE ) ) return TRUE; return FALSE; }
static void test_printers_folder(void) { IShellFolder2 *folder; IPersistFolder2 *pf; SHELLDETAILS details; SHCOLSTATEF state; LPITEMIDLIST pidl1, pidl2; HRESULT hr; INT i; CoInitialize( NULL ); hr = CoCreateInstance(&CLSID_Printers, NULL, CLSCTX_INPROC_SERVER, &IID_IShellFolder2, (void**)&folder); if (hr != S_OK) { win_skip("Failed to created IShellFolder2 for Printers folder\n"); CoUninitialize(); return; } if (0) { /* crashes on XP */ hr = IShellFolder2_GetDetailsOf(folder, NULL, 0, NULL); hr = IShellFolder2_GetDefaultColumnState(folder, 0, NULL); hr = IPersistFolder2_GetCurFolder(pf, NULL); } /* 5 columns defined */ hr = IShellFolder2_GetDetailsOf(folder, NULL, 6, &details); ok(hr == E_NOTIMPL, "got 0x%08x\n", hr); hr = IShellFolder2_GetDefaultColumnState(folder, 6, &state); ok(broken(hr == E_NOTIMPL) || hr == E_INVALIDARG /* Win7 */, "got 0x%08x\n", hr); hr = IShellFolder2_GetDetailsOf(folder, NULL, 0, &details); ok(hr == S_OK || broken(E_NOTIMPL) /* W2K */, "got 0x%08x\n", hr); /* test every column if method is implemented */ if (hr == S_OK) { ok(details.str.uType == STRRET_WSTR, "got %d\n", details.str.uType); for(i = 0; i < 6; i++) { hr = IShellFolder2_GetDetailsOf(folder, NULL, i, &details); ok(hr == S_OK, "got 0x%08x\n", hr); /* all columns are left-aligned */ ok(details.fmt == LVCFMT_LEFT, "got 0x%x\n", details.fmt); /* can't be on w9x at this point, IShellFolder2 unsupported there, check present for running Wine with w9x setup */ if (SHELL_OsIsUnicode()) SHFree(details.str.u.pOleStr); hr = IShellFolder2_GetDefaultColumnState(folder, i, &state); ok(hr == S_OK, "got 0x%08x\n", hr); /* all columns are string except document count */ if (i == 1) ok(state == (SHCOLSTATE_TYPE_INT | SHCOLSTATE_ONBYDEFAULT), "got 0x%x\n", state); else ok(state == (SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT), "got 0x%x\n", state); } } /* default pidl */ hr = IShellFolder2_QueryInterface(folder, &IID_IPersistFolder2, (void**)&pf); ok(hr == S_OK, "got 0x%08x\n", hr); /* not initialized */ pidl1 = (void*)0xdeadbeef; hr = IPersistFolder2_GetCurFolder(pf, &pidl1); ok(hr == S_FALSE, "got 0x%08x\n", hr); ok(pidl1 == NULL, "got %p\n", pidl1); hr = SHGetSpecialFolderLocation(NULL, CSIDL_PRINTERS, &pidl2); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IPersistFolder2_Initialize(pf, pidl2); ok(hr == S_OK, "got 0x%08x\n", hr); hr = IPersistFolder2_GetCurFolder(pf, &pidl1); ok(hr == S_OK, "got 0x%08x\n", hr); ok(ILIsEqual(pidl1, pidl2), "expected same PIDL\n"); IPersistFolder2_Release(pf); ILFree(pidl1); ILFree(pidl2); IShellFolder2_Release(folder); CoUninitialize(); }
static VOID TestCommandLine( _In_ INT ExpectedRet, _In_ INT ExpectedCsidl, _In_ DWORD ExpectedFlags, _In_ PCWSTR ExpectedFileName, _In_ PCWSTR PidlPath) { EXPLORER_INFO Info; PVOID Ret; ULONG i; FillMemory(&Info, sizeof(Info), 0x55); Info.dwFlags = 0x00000000; Ret = SHExplorerParseCmdLine(&Info); if (ExpectedRet == -1) ok(Ret == Info.pidl, "Ret = %p, expected %p\n", Ret, Info.pidl); else ok(Ret == (PVOID)ExpectedRet, "Ret = %p, expected %p\n", Ret, (PVOID)ExpectedRet); if (ExpectedFileName == NULL) ok(Info.FileName == InvalidPointer, "FileName = %p\n", Info.FileName); else { ok(Info.FileName != NULL && Info.FileName != InvalidPointer, "FileName = %p\n", Info.FileName); if (Info.FileName != NULL && Info.FileName != InvalidPointer) { ok(!wcscmp(Info.FileName, ExpectedFileName), "FileName = %ls, expected %ls\n", Info.FileName, ExpectedFileName); LocalFree(Info.FileName); } } if (ExpectedCsidl == PIDL_IS_UNTOUCHED) ok(Info.pidl == InvalidPointer, "pidl = %p\n", Info.pidl); else if (ExpectedCsidl == PIDL_IS_NULL) ok(Info.pidl == NULL, "pidl = %p\n", Info.pidl); else { PIDLIST_ABSOLUTE ExpectedPidl; HRESULT hr; ok(Info.pidl != NULL, "pidl = %p\n", Info.pidl); if (Info.pidl != NULL && Info.pidl != InvalidPointer) { if (ExpectedCsidl == PIDL_IS_PATH) { ExpectedPidl = SHSimpleIDListFromPath(PidlPath); hr = ExpectedPidl == NULL ? E_FAIL : S_OK; ok(ExpectedPidl != NULL, "SHSimpleIDListFromPath failed\n"); } else { hr = SHGetFolderLocation(NULL, ExpectedCsidl, NULL, 0, &ExpectedPidl); ok(hr == S_OK, "SHGetFolderLocation returned %08lx\n", hr); } if (SUCCEEDED(hr)) { ok(ILIsEqual(Info.pidl, ExpectedPidl), "Unexpected pidl value\n"); ILFree(ExpectedPidl); } ILFree(Info.pidl); } } ok(Info.dwFlags == ExpectedFlags, "dwFlags = %08lx, expected %08lx\n", Info.dwFlags, ExpectedFlags); for (i = 0; i < sizeof(Info.Unknown) / sizeof(Info.Unknown[0]); i++) ok(Info.Unknown[i] == 0x55555555, "Unknown[%lu] = %08lx\n", i, Info.Unknown[i]); }
bool operator==(const ItemIDList& lhs, const ItemIDList& rhs) { return ILIsEqual(lhs, rhs) == TRUE; }
static void update_path_box(explorer_info *info) { COMBOBOXEXITEMW item; COMBOBOXEXITEMW main_item; IShellFolder *desktop; IPersistFolder2 *persist; LPITEMIDLIST desktop_pidl; IEnumIDList *ids; ImageList_Remove((HIMAGELIST)info->icon_list,-1); SendMessageW(info->path_box,CB_RESETCONTENT,0,0); SHGetDesktopFolder(&desktop); IShellFolder_QueryInterface(desktop,&IID_IPersistFolder2,(void**)&persist); IPersistFolder2_GetCurFolder(persist,&desktop_pidl); IPersistFolder2_Release(persist); persist = NULL; /*Add Desktop*/ item.iItem = -1; item.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_LPARAM; item.iIndent = 0; create_combobox_item(desktop,desktop_pidl,info->icon_list,&item); item.lParam = (LPARAM)desktop_pidl; SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item); if(ILIsEqual(info->pidl,desktop_pidl)) main_item = item; else CoTaskMemFree(item.pszText); /*Add all direct subfolders of Desktop*/ if(SUCCEEDED(IShellFolder_EnumObjects(desktop,NULL,SHCONTF_FOLDERS,&ids)) && ids!=NULL) { LPITEMIDLIST curr_pidl=NULL; HRESULT hres; item.iIndent = 1; while(1) { ILFree(curr_pidl); curr_pidl=NULL; hres = IEnumIDList_Next(ids,1,&curr_pidl,NULL); if(FAILED(hres) || hres == S_FALSE) break; if(!create_combobox_item(desktop,curr_pidl,info->icon_list,&item)) WINE_WARN("Could not create a combobox item\n"); else { LPITEMIDLIST full_pidl = ILCombine(desktop_pidl,curr_pidl); item.lParam = (LPARAM)full_pidl; SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item); if(ILIsEqual(full_pidl,info->pidl)) main_item = item; else if(ILIsParent(full_pidl,info->pidl,FALSE)) { /*add all parents of the pidl passed in*/ LPITEMIDLIST next_pidl = ILFindChild(full_pidl,info->pidl); IShellFolder *curr_folder = NULL, *temp; hres = IShellFolder_BindToObject(desktop,curr_pidl,NULL, &IID_IShellFolder, (void**)&curr_folder); if(FAILED(hres)) WINE_WARN("Could not get an IShellFolder\n"); while(!ILIsEmpty(next_pidl)) { LPITEMIDLIST first = ILCloneFirst(next_pidl); CoTaskMemFree(item.pszText); if(!create_combobox_item(curr_folder,first, info->icon_list,&item)) { WINE_WARN("Could not create a combobox item\n"); break; } ++item.iIndent; full_pidl = ILCombine(full_pidl,first); item.lParam = (LPARAM)full_pidl; SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item); temp=NULL; hres = IShellFolder_BindToObject(curr_folder,first,NULL, &IID_IShellFolder, (void**)&temp); if(FAILED(hres)) { WINE_WARN("Could not get an IShellFolder\n"); break; } IShellFolder_Release(curr_folder); curr_folder = temp; ILFree(first); next_pidl = ILGetNext(next_pidl); } memcpy(&main_item,&item,sizeof(item)); if(curr_folder) IShellFolder_Release(curr_folder); item.iIndent = 1; } else CoTaskMemFree(item.pszText); } } ILFree(curr_pidl); IEnumIDList_Release(ids); } else WINE_WARN("Could not enumerate the desktop\n"); SendMessageW(info->path_box,CBEM_SETITEMW,0,(LPARAM)&main_item); CoTaskMemFree(main_item.pszText); }
bool operator!= ( const Path& lhs, const Path& rhs ) { return (ILIsEqual(lhs.backend(),rhs.backend()) == FALSE); }
bool CDeskBand::Filter(LPTSTR filter) { bool bReturn = false; IServiceProvider * pServiceProvider; if (SUCCEEDED(m_pSite->QueryInterface(IID_IServiceProvider, (LPVOID*)&pServiceProvider))) { IShellBrowser * pShellBrowser; if (SUCCEEDED(pServiceProvider->QueryService(SID_SShellBrowser, IID_IShellBrowser, (LPVOID*)&pShellBrowser))) { IShellView * pShellView; if (SUCCEEDED(pShellBrowser->QueryActiveShellView(&pShellView))) { IFolderView * pFolderView; if (SUCCEEDED(pShellView->QueryInterface(IID_IFolderView, (LPVOID*)&pFolderView))) { // hooray! we got the IFolderView interface! // that means the explorer is active and well :) IShellFolderView * pShellFolderView; if (SUCCEEDED(pShellView->QueryInterface(IID_IShellFolderView, (LPVOID*)&pShellFolderView))) { // the first thing we do is to deselect all already selected entries pFolderView->SelectItem(NULL, SVSI_DESELECTOTHERS); // but we also need the IShellFolder interface because // we need its GetDisplayNameOf() method IPersistFolder2 * pPersistFolder; if (SUCCEEDED(pFolderView->GetFolder(IID_IPersistFolder2, (LPVOID*)&pPersistFolder))) { LPITEMIDLIST curFolder; pPersistFolder->GetCurFolder(&curFolder); if (ILIsEqual(m_currentFolder, curFolder)) { CoTaskMemFree(curFolder); } else { CoTaskMemFree(m_currentFolder); m_currentFolder = curFolder; for (size_t i=0; i<m_noShows.size(); ++i) { CoTaskMemFree(m_noShows[i]); } m_noShows.clear(); } IShellFolder * pShellFolder; if (SUCCEEDED(pPersistFolder->QueryInterface(IID_IShellFolder, (LPVOID*)&pShellFolder))) { // our next task is to enumerate all the // items in the folder view and select those // which match the text in the edit control bool bUseRegex = (filter[0] == '\\'); try { const std::tr1::wregex regCheck(&filter[1], std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript); } catch (std::exception) { bUseRegex = false; } if (!bUseRegex) { // force the filter to lowercase TCHAR * pString = filter; while (*pString) { *pString = _totlower(*pString); pString++; } } int nCount = 0; if (SUCCEEDED(pFolderView->ItemCount(SVGIO_ALLVIEW, &nCount))) { pShellFolderView->SetRedraw(FALSE); HWND listView = GetListView32(pShellView); LRESULT viewType = 0; if (listView) { // inserting items in the list view if the list view is set to // e.g., LV_VIEW_LIST is painfully slow. So save the current view // and set it to LV_VIEW_DETAILS (which is much faster for inserting) // and restore the view after we're done. viewType = SendMessage(listView, LVM_GETVIEW, 0, 0); SendMessage(listView, LVM_SETVIEW, LV_VIEW_DETAILS, 0); } std::vector<LPITEMIDLIST> noShows; for (int i=0; i<nCount; ++i) { LPITEMIDLIST pidl; if (SUCCEEDED(pFolderView->Item(i, &pidl))) { if (CheckDisplayName(pShellFolder, pidl, filter, bUseRegex)) { // remove now shown items which are in the no-show list // this is necessary since we don't get a notification // if the shell refreshes its view for (std::vector<LPITEMIDLIST>::iterator it = m_noShows.begin(); it != m_noShows.end(); ++it ) { if (HRESULT_CODE(pShellFolder->CompareIDs(SHCIDS_CANONICALONLY, *it, pidl))==0) { m_noShows.erase(it); break; } } CoTaskMemFree(pidl); } else { UINT puItem = 0; if (pShellFolderView->RemoveObject(pidl, &puItem) == S_OK) { i--; nCount--; noShows.push_back(pidl); } } } } // now add all those items again which were removed by a previous filter string // but don't match this new one //pShellFolderView->SetObjectCount(5000, SFVSOC_INVALIDATE_ALL|SFVSOC_NOSCROLL); for (size_t i=0; i<m_noShows.size(); ++i) { LPITEMIDLIST pidlNoShow = m_noShows[i]; if (CheckDisplayName(pShellFolder, pidlNoShow, filter, bUseRegex)) { m_noShows.erase(m_noShows.begin() + i); i--; UINT puItem = (UINT)i; pShellFolderView->AddObject(pidlNoShow, &puItem); CoTaskMemFree(pidlNoShow); } } for (size_t i=0; i<noShows.size(); ++i) { m_noShows.push_back(noShows[i]); } if (listView) { SendMessage(listView, LVM_SETVIEW, viewType, 0); } pShellFolderView->SetRedraw(TRUE); } pShellFolder->Release(); } pPersistFolder->Release(); } pShellFolderView->Release(); } pFolderView->Release(); } pShellView->Release(); } pShellBrowser->Release(); } pServiceProvider->Release(); } return bReturn; }
static VOID TestCommandLine( _In_ INT ExpectedRet, _In_ INT ExpectedCsidl, _In_ DWORD ExpectedFlags, _In_ PCWSTR ExpectedFileName, _In_ PCWSTR PidlPath, _Out_opt_ PUINT PWriteEnd) { EXPLORER_INFO Info; UINT Ret; ULONG i; PDWORD InfoWords = (PDWORD) &Info; FillMemory(&Info, sizeof(Info), 0x55); Info.dwFlags = 0x00000000; Ret = SHExplorerParseCmdLine(&Info); // Special case for empty cmdline: Ret is the PIDL for the selected folder. if (ExpectedRet == -1) ok((LPITEMIDLIST) Ret == Info.pidl, "Ret = %x, expected %p\n", Ret, Info.pidl); else ok(Ret == ExpectedRet, "Ret = %x, expected %p\n", Ret, (PVOID) ExpectedRet); if (ExpectedFileName == NULL) ok(Info.FileName == InvalidPointer, "FileName = %p\n", Info.FileName); else { ok(Info.FileName != NULL && Info.FileName != InvalidPointer, "FileName = %p\n", Info.FileName); if (Info.FileName != NULL && Info.FileName != InvalidPointer) { ok(!wcscmp(Info.FileName, ExpectedFileName), "FileName = %ls, expected %ls\n", Info.FileName, ExpectedFileName); LocalFree(Info.FileName); } } ok(Info.dwFlags == ExpectedFlags, "dwFlags = %08lx, expected %08lx\n", Info.dwFlags, ExpectedFlags); if (ExpectedCsidl == PIDL_IS_UNTOUCHED) ok(Info.pidl == InvalidPointer, "pidl = %p\n", Info.pidl); else if (ExpectedCsidl == PIDL_IS_NULL) ok(Info.pidl == NULL, "pidl = %p\n", Info.pidl); else { PIDLIST_ABSOLUTE ExpectedPidl; HRESULT hr; ok(Info.pidl != NULL, "pidl = %p\n", Info.pidl); if (Info.pidl != NULL && Info.pidl != InvalidPointer) { WCHAR pidlPathName[MAX_PATH] = L""; if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555) { SHGetPathFromIDListW(Info.pidl, pidlPathName); } if (ExpectedCsidl == PIDL_PATH_EQUALS_PATH) { ok(wcsicmp(pidlPathName, PidlPath) == 0, "Path from pidl does not match; pidlPathName=%S\n", pidlPathName); } else if (ExpectedCsidl == PIDL_IS_EMPTY) { ok(wcslen(pidlPathName) == 0, "Unexpected non-empty path from pidl; pidlPathName=%S\n", pidlPathName); } else { if (ExpectedCsidl == PIDL_IS_PATH) { ExpectedPidl = SHSimpleIDListFromPath(PidlPath); hr = ExpectedPidl == NULL ? E_FAIL : S_OK; ok(ExpectedPidl != NULL, "SHSimpleIDListFromPath(%S) failed. pidlPathName=%S\n", PidlPath, pidlPathName); if (SUCCEEDED(hr)) { ok(ILIsEqual(Info.pidl, ExpectedPidl), "Unexpected pidl value %p; pidlPathName=%S PidlPath=%S\n", Info.pidl, pidlPathName, PidlPath); ILFree(ExpectedPidl); } } else { hr = SHGetFolderLocation(NULL, ExpectedCsidl, NULL, 0, &ExpectedPidl); ok(hr == S_OK, "SHGetFolderLocation returned %08lx\n", hr); if (SUCCEEDED(hr)) { BOOL eq = ILIsEqual(Info.pidl, ExpectedPidl); ILFree(ExpectedPidl); ok(eq, "Unexpected pidl value %p; pidlPathName=%S CSIDL=%d\n", Info.pidl, pidlPathName, ExpectedCsidl); } } } if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555) ILFree(Info.pidl); } } for (i = 0; i < sizeof(Info) / sizeof(DWORD); i++) { switch (i*4) { case 0x00: // FileName case 0x04: // pidl case 0x08: // dwFlags case 0x20: // pidlRoot case 0x34: // guidInproc (1/4) case 0x38: // guidInproc (2/4) case 0x3C: // guidInproc (3/4) case 0x40: // guidInproc (4/4) break; default: ok(InfoWords[i] == 0x55555555, "Word 0x%02lx has been set to 0x%08lx\n", i * 4, InfoWords[i]); } } if (PWriteEnd) { PBYTE data = (PBYTE)&Info; *PWriteEnd = 0; for (i = sizeof(Info); i > 0; i--) { if (data[i - 1] != 0x55) { *PWriteEnd = i; break; } } } }