ReactOS 0.4.15-dev-7998-gdb93cb1
CMruPidlList Class Reference
Inheritance diagram for CMruPidlList:
Collaboration diagram for CMruPidlList:

Public Member Functions

 CMruPidlList ()
 
 ~CMruPidlList () override
 
HRESULT GetEmptySlot (UINT *pnNodeSlot)
 
void EmptyNodeSlot (UINT nNodeSlot)
 
STDMETHODIMP QueryInterface (REFIID riid, void **ppvObj) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP InitList (UINT cMRUSize, HKEY hKey, LPCWSTR pszSubKey) override
 
STDMETHODIMP UsePidl (LPCITEMIDLIST pidl, UINT *pnNodeSlot) override
 
STDMETHODIMP QueryPidl (LPCITEMIDLIST pidl, UINT cSlots, UINT *pnNodeSlots, UINT *pcNodeSlots) override
 
STDMETHODIMP PruneKids (LPCITEMIDLIST pidl) override
 
- Public Member Functions inherited from CMruNode
 CMruNode ()
 
 CMruNode (CMruNode *pParent, UINT iSlot)
 
 ~CMruNode () override
 
CMruNodeGetParent ()
 
HRESULT BindToSlot (UINT iSlot, IShellFolder **ppSF)
 
HRESULT GetNode (BOOL bAdd, LPCITEMIDLIST pidl, CMruNode **pNewNode)
 
HRESULT GetNodeSlot (UINT *pnNodeSlot)
 
HRESULT SetNodeSlot (UINT nNodeSlot)
 
HRESULT RemoveLeast (UINT *pnNodeSlot)
 
HRESULT Clear (CMruPidlList *pList)
 
- Public Member Functions inherited from CMruLongList
 CMruLongList ()
 
 ~CMruLongList () override
 
- Public Member Functions inherited from CMruBase
 CMruBase ()
 
virtual ~CMruBase ()
 
STDMETHODIMP QueryInterface (REFIID riid, void **ppvObj) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP InitData (UINT cCapacity, UINT flags, HKEY hKey, LPCWSTR pszSubKey OPTIONAL, SLOTCOMPARE fnCompare OPTIONAL) override
 
STDMETHODIMP AddData (LPCVOID pvData, DWORD cbData, UINT *piSlot) override
 
STDMETHODIMP FindData (LPCVOID pvData, DWORD cbData, UINT *piSlot) override
 
STDMETHODIMP GetData (UINT iSlot, LPVOID pvData, DWORD cbData) override
 
STDMETHODIMP QueryInfo (UINT iSlot, UINT *piGotSlot, DWORD *pcbData) override
 
STDMETHODIMP Delete (UINT iSlot) override
 
virtual BOOL _IsEqual (const SLOTITEMDATA *pItem, LPCVOID pvData, UINT cbData) const
 
virtual DWORD _DeleteValue (LPCWSTR pszValue)
 
virtual HRESULT _InitSlots ()=0
 
virtual void _SaveSlots ()=0
 
virtual UINT _UpdateSlots (UINT iSlot)=0
 
virtual void _SlotString (UINT iSlot, LPWSTR psz, DWORD cch)=0
 
virtual HRESULT _GetSlot (UINT iSlot, UINT *puSlot)=0
 
virtual HRESULT _RemoveSlot (UINT iSlot, UINT *puSlot)=0
 

Protected Member Functions

BOOL _LoadNodeSlots ()
 
void _SaveNodeSlots ()
 
HRESULT _InitNodeSlots ()
 
- Protected Member Functions inherited from CMruNode
BOOL _InitLate ()
 
BOOL _IsEqual (SLOTITEMDATA *pItem, LPCVOID pvData, UINT cbData)
 
DWORD _DeleteValue (LPCWSTR pszValue) override
 
HRESULT _CreateNode (UINT iSlot, CMruNode **ppNewNode)
 
HRESULT _AddPidl (UINT iSlot, LPCITEMIDLIST pidl)
 
HRESULT _FindPidl (LPCITEMIDLIST pidl, UINT *piSlot)
 
HRESULT _GetPidlSlot (LPCITEMIDLIST pidl, BOOL bAdd, UINT *piSlot)
 
- Protected Member Functions inherited from CMruLongList
void _ImportShortList ()
 
HRESULT _InitSlots () override
 
void _SaveSlots () override
 
UINT _UpdateSlots (UINT iSlot) override
 
void _SlotString (UINT iSlot, LPWSTR psz, DWORD cch) override
 
HRESULT _GetSlot (UINT iSlot, UINT *puSlot) override
 
HRESULT _RemoveSlot (UINT iSlot, UINT *puSlot) override
 
- Protected Member Functions inherited from CMruBase
HRESULT _LoadItem (UINT iSlot)
 
HRESULT _AddItem (UINT iSlot, LPCVOID pvData, DWORD cbData)
 
HRESULT _GetItem (UINT iSlot, SLOTITEMDATA **ppItem)
 
void _DeleteItem (UINT iSlot)
 
HRESULT _GetSlotItem (UINT iSlot, SLOTITEMDATA **ppItem)
 
void _CheckUsedSlots ()
 
HRESULT _UseEmptySlot (UINT *piSlot)
 

Protected Attributes

LPBYTE m_pbNodeSlots = NULL
 
DWORD m_cMaxNodeSlots = 0
 
HANDLE m_hMutex = NULL
 
- Protected Attributes inherited from CMruNode
UINT m_iSlot = 0
 
CMruNodem_pParent = NULL
 
IShellFolderm_pShellFolder = NULL
 
- Protected Attributes inherited from CMruLongList
UINTm_puSlotData = NULL
 
- Protected Attributes inherited from CMruBase
LONG m_cRefs = 1
 
DWORD m_dwFlags = 0
 
BOOL m_bNeedSave = FALSE
 
BOOL m_bChecked = FALSE
 
HKEY m_hKey = NULL
 
DWORD m_cSlotRooms = 0
 
DWORD m_cSlots = 0
 
SLOTCOMPARE m_fnCompare = NULL
 
SLOTITEMDATAm_pSlots = NULL
 

Additional Inherited Members

- Static Public Member Functions inherited from CMruBase
static voidoperator new (size_t size)
 
static void operator delete (void *ptr)
 

Detailed Description

Definition at line 993 of file mrulist.cpp.

Constructor & Destructor Documentation

◆ CMruPidlList()

CMruPidlList::CMruPidlList ( )
inline

Definition at line 1007 of file mrulist.cpp.

1007{ }

◆ ~CMruPidlList()

CMruPidlList::~CMruPidlList ( )
override

Definition at line 1035 of file mrulist.cpp.

1036{
1038 if (m_hMutex)
1039 {
1041 m_hMutex = NULL;
1042 }
1043}
HANDLE m_hMutex
Definition: mrulist.cpp:1000
LPBYTE m_pbNodeSlots
Definition: mrulist.cpp:998
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
unsigned char * LPBYTE
Definition: typedefs.h:53

Member Function Documentation

◆ _InitNodeSlots()

HRESULT CMruPidlList::_InitNodeSlots ( )
protected

Definition at line 1076 of file mrulist.cpp.

1077{
1079 if (!m_pbNodeSlots)
1080 return E_OUTOFMEMORY;
1081
1083 m_bNeedSave = TRUE;
1085
1086 return S_OK;
1087}
BOOL m_bNeedSave
Definition: mrulist.cpp:97
DWORD m_cSlotRooms
Definition: mrulist.cpp:100
void _SaveNodeSlots()
Definition: mrulist.cpp:1070
BOOL _LoadNodeSlots()
Definition: mrulist.cpp:1061
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRUE
Definition: types.h:120
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define S_OK
Definition: intsafe.h:52
#define LPTR
Definition: winbase.h:381
unsigned char BYTE
Definition: xxhash.c:193

Referenced by InitList().

◆ _LoadNodeSlots()

BOOL CMruPidlList::_LoadNodeSlots ( )
protected

Definition at line 1061 of file mrulist.cpp.

1062{
1063 DWORD cbNodeSlots = m_cSlotRooms * sizeof(BYTE);
1064 if (SHGetValueW(m_hKey, NULL, L"NodeSlots", NULL, m_pbNodeSlots, &cbNodeSlots) != ERROR_SUCCESS)
1065 return FALSE;
1066 m_cMaxNodeSlots = cbNodeSlots / sizeof(BYTE);
1067 return TRUE;
1068}
HKEY m_hKey
Definition: mrulist.cpp:99
DWORD m_cMaxNodeSlots
Definition: mrulist.cpp:999
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95
#define L(x)
Definition: ntvdm.h:50

Referenced by _InitNodeSlots(), GetEmptySlot(), and PruneKids().

◆ _SaveNodeSlots()

void CMruPidlList::_SaveNodeSlots ( )
protected

Definition at line 1070 of file mrulist.cpp.

1071{
1072 DWORD cbNodeSlots = m_cMaxNodeSlots * sizeof(BYTE);
1073 SHSetValueW(m_hKey, NULL, L"NodeSlots", REG_BINARY, m_pbNodeSlots, cbNodeSlots);
1074}
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define REG_BINARY
Definition: nt_native.h:1496

Referenced by _InitNodeSlots(), GetEmptySlot(), and PruneKids().

◆ EmptyNodeSlot()

void CMruPidlList::EmptyNodeSlot ( UINT  nNodeSlot)

Definition at line 1265 of file mrulist.cpp.

1266{
1267 m_pbNodeSlots[nNodeSlot - 1] = 0; // nNodeSlot is 1-base
1268 m_bNeedSave = TRUE;
1269}

◆ GetEmptySlot()

HRESULT CMruPidlList::GetEmptySlot ( UINT pnNodeSlot)

Definition at line 1089 of file mrulist.cpp.

1090{
1091 *pnNodeSlot = 0;
1092
1093 if (!_LoadNodeSlots())
1094 return E_FAIL;
1095
1097 {
1099 *pnNodeSlot = ++m_cMaxNodeSlots;
1101 return S_OK;
1102 }
1103
1104 for (UINT iNodeSlot = 0; iNodeSlot < m_cMaxNodeSlots; ++iNodeSlot)
1105 {
1106 if (m_pbNodeSlots[iNodeSlot] & SLOT_SET)
1107 continue;
1108
1109 m_pbNodeSlots[iNodeSlot] = SLOT_SET;
1110 *pnNodeSlot = iNodeSlot + 1; // nNodeSlot is 1-base
1112 return S_OK;
1113 }
1114
1115 HRESULT hr = E_FAIL;
1116 if (SUCCEEDED(RemoveLeast(pnNodeSlot)) && *pnNodeSlot)
1117 hr = S_OK;
1118
1120 return hr;
1121}
HRESULT RemoveLeast(UINT *pnNodeSlot)
Definition: mrulist.cpp:962
#define E_FAIL
Definition: ddrawi.h:102
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define SLOT_SET
Definition: mrulist.cpp:53
unsigned int UINT
Definition: ndis.h:50
HRESULT hr
Definition: shlfolder.c:183

Referenced by UsePidl().

◆ InitList()

STDMETHODIMP CMruPidlList::InitList ( UINT  cMRUSize,
HKEY  hKey,
LPCWSTR  pszSubKey 
)
override

Definition at line 1123 of file mrulist.cpp.

1124{
1125 TRACE("%p -> %u %p %s\n", this, cMRUSize, hKey, debugstr_w(pszSubKey));
1126
1127 HRESULT hr = InitData(cMRUSize, 0, hKey, pszSubKey, NULL);
1128 if (FAILED(hr))
1129 {
1130 ERR("0x%08lX\n", hr);
1131 return hr;
1132 }
1133
1134 hr = _InitNodeSlots();
1135 if (FAILED(hr))
1136 {
1137 ERR("0x%08lX\n", hr);
1138 return hr;
1139 }
1140
1141 m_hMutex = ::CreateMutexW(NULL, FALSE, L"Shell.CMruPidlList");
1142 if (!m_hMutex)
1143 {
1145 ERR("0x%08lX\n", hr);
1146 }
1147
1148 return hr;
1149}
#define ERR(fmt,...)
Definition: debug.h:110
STDMETHODIMP InitData(UINT cCapacity, UINT flags, HKEY hKey, LPCWSTR pszSubKey OPTIONAL, SLOTCOMPARE fnCompare OPTIONAL) override
Definition: mrulist.cpp:300
HRESULT _InitNodeSlots()
Definition: mrulist.cpp:1076
FxAutoRegKey hKey
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

◆ PruneKids()

STDMETHODIMP CMruPidlList::PruneKids ( LPCITEMIDLIST  pidl)
override

Definition at line 1234 of file mrulist.cpp.

1235{
1236 TRACE("%p -> %p\n", this, pidl);
1237
1239 HRESULT hr = mutex.Enter(m_hMutex);
1240 if (FAILED(hr))
1241 {
1242 ERR("0x%08lX\n", hr);
1243 return hr;
1244 }
1245
1246 if (!_LoadNodeSlots())
1247 return hr;
1248
1249 CMruNode *pNode;
1250 hr = GetNode(FALSE, pidl, &pNode);
1251 if (FAILED(hr))
1252 return hr;
1253
1254 if (hr == S_OK)
1255 hr = pNode->Clear(this);
1256 else
1257 hr = E_FAIL;
1258
1259 pNode->Release();
1260
1262 return hr;
1263}
HRESULT Clear(CMruPidlList *pList)
Definition: mrulist.cpp:1292
HRESULT GetNode(BOOL bAdd, LPCITEMIDLIST pidl, CMruNode **pNewNode)
Definition: mrulist.cpp:834
Definition: module.h:456

◆ QueryInterface()

STDMETHODIMP CMruPidlList::QueryInterface ( REFIID  riid,
void **  ppvObj 
)
override

Definition at line 1045 of file mrulist.cpp.

1046{
1047 if (!ppvObj)
1048 return E_POINTER;
1049
1050 if (::IsEqualGUID(riid, IID_IMruPidlList) || ::IsEqualGUID(riid, IID_IUnknown))
1051 {
1052 *ppvObj = static_cast<IMruPidlList*>(this);
1053 AddRef();
1054 return S_OK;
1055 }
1056
1057 ERR("%s: E_NOINTERFACE\n", debugstr_guid(&riid));
1058 return E_NOINTERFACE;
1059}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365

◆ QueryPidl()

STDMETHODIMP CMruPidlList::QueryPidl ( LPCITEMIDLIST  pidl,
UINT  cSlots,
UINT pnNodeSlots,
UINT pcNodeSlots 
)
override

Definition at line 1187 of file mrulist.cpp.

1192{
1193 TRACE("%p -> %p %u %p %p\n", this, pidl, cSlots, pnNodeSlots, pcNodeSlots);
1194
1196 HRESULT hr = mutex.Enter(m_hMutex);
1197 if (FAILED(hr))
1198 {
1199 ERR("0x%08lX\n", hr);
1200 return hr;
1201 }
1202
1203 *pcNodeSlots = 0;
1204
1205 CMruNode *pNode;
1206 hr = GetNode(FALSE, pidl, &pNode);
1207 if (FAILED(hr))
1208 {
1209 ERR("0x%08lX\n", hr);
1210 return hr;
1211 }
1212
1213 while (pNode && *pcNodeSlots < cSlots)
1214 {
1215 CMruNode *pParent = pNode->GetParent();
1216 if (SUCCEEDED(pNode->GetNodeSlot(&pnNodeSlots[*pcNodeSlots])))
1217 ++(*pcNodeSlots);
1218 else if (hr == S_OK && !*pcNodeSlots)
1219 hr = S_FALSE;
1220
1221 pNode->Release();
1222 pNode = pParent;
1223 }
1224
1225 if (pNode)
1226 pNode->Release();
1227
1228 if (SUCCEEDED(hr) && !*pcNodeSlots)
1229 hr = E_FAIL;
1230
1231 return hr;
1232}
HRESULT GetNodeSlot(UINT *pnNodeSlot)
Definition: mrulist.cpp:905
CMruNode * GetParent()
Definition: mrulist.cpp:809
FxObject * pParent
Definition: fxdpcapi.cpp:86
#define S_FALSE
Definition: winerror.h:2357

◆ STDMETHODIMP_() [1/2]

CMruPidlList::STDMETHODIMP_ ( ULONG  )
inlineoverride

Definition at line 1015 of file mrulist.cpp.

1016 {
1017 return CMruBase::AddRef();
1018 }

◆ STDMETHODIMP_() [2/2]

CMruPidlList::STDMETHODIMP_ ( ULONG  )
inlineoverride

Definition at line 1019 of file mrulist.cpp.

1020 {
1021 return CMruBase::Release();
1022 }

◆ UsePidl()

STDMETHODIMP CMruPidlList::UsePidl ( LPCITEMIDLIST  pidl,
UINT pnNodeSlot 
)
override

Definition at line 1151 of file mrulist.cpp.

1152{
1153 TRACE("%p -> %p %p\n", this, pidl, pnNodeSlot);
1154
1156 HRESULT hr = mutex.Enter(m_hMutex);
1157 if (FAILED(hr))
1158 {
1159 ERR("0x%08lX\n", hr);
1160 return hr;
1161 }
1162
1163 *pnNodeSlot = 0;
1164
1165 CMruNode *pNode;
1166 hr = GetNode(TRUE, pidl, &pNode);
1167 if (FAILED(hr))
1168 {
1169 ERR("0x%08lX\n", hr);
1170 return hr;
1171 }
1172
1173 hr = pNode->GetNodeSlot(pnNodeSlot);
1174 if (FAILED(hr))
1175 {
1176 hr = GetEmptySlot(pnNodeSlot);
1177 if (SUCCEEDED(hr))
1178 {
1179 hr = pNode->SetNodeSlot(*pnNodeSlot);
1180 }
1181 }
1182
1183 pNode->Release();
1184 return hr;
1185}
HRESULT SetNodeSlot(UINT nNodeSlot)
Definition: mrulist.cpp:915
HRESULT GetEmptySlot(UINT *pnNodeSlot)
Definition: mrulist.cpp:1089

Member Data Documentation

◆ m_cMaxNodeSlots

DWORD CMruPidlList::m_cMaxNodeSlots = 0
protected

Definition at line 999 of file mrulist.cpp.

Referenced by _LoadNodeSlots(), _SaveNodeSlots(), and GetEmptySlot().

◆ m_hMutex

HANDLE CMruPidlList::m_hMutex = NULL
protected

Definition at line 1000 of file mrulist.cpp.

Referenced by InitList(), PruneKids(), QueryPidl(), UsePidl(), and ~CMruPidlList().

◆ m_pbNodeSlots

LPBYTE CMruPidlList::m_pbNodeSlots = NULL
protected

The documentation for this class was generated from the following file: