ReactOS 0.4.16-dev-2175-g9420ab7
CRecycleBinFolderViewCB.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: shell32
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Recycle Bin virtual folder callback
5 * COPYRIGHT: Copyright 2026 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include <precomp.h>
9
11
13 : m_pShellView(NULL)
14 , m_pRecycleBin(NULL)
15 , m_nChangeNotif(0)
16{
17}
18
20{
23}
24
26{
27 m_pRecycleBin = pRecycleBin;
28 m_pShellView = psv;
29 m_pidlParent.Attach(ILClone(pidlParent));
30}
31
33{
34 if (!hwndView)
35 {
36 WARN("!hwndView\n");
37 return E_FAIL;
38 }
39
42
43 // Populate entries
44 INT iEntry = 0;
45 for (INT iDrive = 0; iDrive < RECYCLEBINMAXDRIVECOUNT; ++iDrive)
46 {
47 WCHAR szBinPath[MAX_PATH];
48 HRESULT hr = GetRecycleBinPathFromDriveNumber(iDrive, szBinPath);
49 if (FAILED(hr))
50 continue;
51 LPITEMIDLIST pidl = ILCreateFromPathW(szBinPath);
52 if (!pidl)
53 continue;
54 entries[iEntry].pidl = pidls[iEntry] = pidl;
55 entries[iEntry].fRecursive = FALSE;
56 ++iEntry;
57 }
58
59 // Register
61 const DWORD dwEvents =
73 iEntry, entries);
74 if (!m_nChangeNotif)
75 WARN("SHChangeNotifyRegister failed\n");
76
77 // Clean up
78 while (iEntry > 0)
79 ILFree(pidls[--iEntry]);
80
81 return m_nChangeNotif ? S_OK : E_FAIL;
82}
83
85{
86 ATLASSERT(ppidlNew);
87 *ppidlNew = NULL;
88
90 if (!SHGetPathFromIDListW(pidl, szPath))
91 {
92 ERR("!SHGetPathFromIDListW\n");
93 return E_FAIL;
94 }
95
96 CComHeapPtr<ITEMIDLIST> pidlChild;
99 if (!pidlChild)
100 {
101 ERR("!pidlChild\n");
102 return E_FAIL;
103 }
104
105 *ppidlNew = ILCombine(m_pidlParent, pidlChild);
106
107 return *ppidlNew ? S_OK : E_OUTOFMEMORY;
108}
109
111{
112 ATLASSERT(pidls);
113
114 HRESULT hr;
115 if (pidls[0])
116 {
117 m_pidls[0].Free();
118 hr = TranslatePidl(&m_pidls[0], pidls[0]);
120 pidls[0] = m_pidls[0];
121 }
122 if (pidls[1])
123 {
124 m_pidls[1].Free();
125 hr = TranslatePidl(&m_pidls[1], pidls[1]);
127 pidls[1] = m_pidls[1];
128 }
129}
130
133{
134 switch (uMsg)
135 {
136 case SFVM_QUERYFSNOTIFY: // Register change notification
137 {
138 // Now, we can get the view window
140 HWND hwndView;
141 HRESULT hr = m_pShellView->GetWindow(&hwndView);
143 return hr;
144 RegisterChangeNotify(hwndView);
145 return S_OK;
146 }
147 case SFVM_FSNOTIFY: // Change notification
148 {
150 return S_OK;
151 }
152 }
153 return E_NOTIMPL;
154}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define STDMETHODIMP
Definition: basetyps.h:43
#define SHV_CHANGE_NOTIFY
Definition: brfolder.cpp:20
EXTERN_C ULONG WINAPI SHChangeNotifyRegister(HWND hwnd, INT fSources, LONG wEventMask, UINT uMsg, INT cItems, SHChangeNotifyEntry *lpItems)
EXTERN_C BOOL WINAPI SHChangeNotifyDeregister(ULONG hNotify)
HRESULT RegisterChangeNotify(HWND hwndView)
void TranslateTwoPIDLs(PIDLIST_ABSOLUTE *pidls)
CComHeapPtr< ITEMIDLIST > m_pidlParent
void Initialize(CRecycleBin *pRecycleBin, IShellView *psv, LPCITEMIDLIST pidlParent)
CComHeapPtr< ITEMIDLIST > m_pidls[2]
STDMETHODIMP MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam) override
HRESULT TranslatePidl(LPITEMIDLIST *ppidlNew, LPCITEMIDLIST pidl)
HRESULT ParseRecycleBinPath(LPCWSTR lpszPath, LPBC pbc, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
EXTERN_C HRESULT GetRecycleBinPathFromDriveNumber(UINT Drive, LPWSTR Path)
Definition: recyclebin.c:352
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:30
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT GetWindow([out] HWND *phwnd)
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
LPCWSTR szPath
Definition: env.c:37
unsigned int UINT
Definition: ndis.h:50
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:238
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1108
#define RECYCLEBINMAXDRIVECOUNT
Definition: recyclebin.h:20
HRESULT hr
Definition: shlfolder.c:183
#define SHCNE_RMDIR
Definition: shlobj.h:1899
#define SHCNE_DELETE
Definition: shlobj.h:1897
#define SHCNE_MKDIR
Definition: shlobj.h:1898
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1908
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1895
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1907
#define SHCNE_UPDATEIMAGE
Definition: shlobj.h:1910
#define SHCNE_CREATE
Definition: shlobj.h:1896
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1912
#define SHCNRF_NewDelivery
Definition: shlobj.h:1944
#define SHCNRF_ShellLevel
Definition: shlobj.h:1942
#define SHCNE_ASSOCCHANGED
Definition: shlobj.h:1916
#define SHCNRF_InterruptLevel
Definition: shlobj.h:1941
#define SFVM_FSNOTIFY
Definition: shlobj.h:1312
#define SFVM_QUERYFSNOTIFY
Definition: shlobj.h:1321
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
PCIDLIST_ABSOLUTE pidl
Definition: shlobj.h:1891
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180