ReactOS 0.4.16-dev-753-g705a985
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 967 of file mrulist.cpp.

Constructor & Destructor Documentation

◆ CMruPidlList()

CMruPidlList::CMruPidlList ( )
inline

Definition at line 981 of file mrulist.cpp.

981{ }

◆ ~CMruPidlList()

CMruPidlList::~CMruPidlList ( )
override

Definition at line 1009 of file mrulist.cpp.

1010{
1012 if (m_hMutex)
1013 {
1015 m_hMutex = NULL;
1016 }
1017}
HANDLE m_hMutex
Definition: mrulist.cpp:974
LPBYTE m_pbNodeSlots
Definition: mrulist.cpp:972
#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 1050 of file mrulist.cpp.

1051{
1053 if (!m_pbNodeSlots)
1054 return E_OUTOFMEMORY;
1055
1057 m_bNeedSave = TRUE;
1059
1060 return S_OK;
1061}
BOOL m_bNeedSave
Definition: mrulist.cpp:71
DWORD m_cSlotRooms
Definition: mrulist.cpp:74
void _SaveNodeSlots()
Definition: mrulist.cpp:1044
BOOL _LoadNodeSlots()
Definition: mrulist.cpp:1035
#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:407
unsigned char BYTE
Definition: xxhash.c:193

Referenced by InitList().

◆ _LoadNodeSlots()

BOOL CMruPidlList::_LoadNodeSlots ( )
protected

Definition at line 1035 of file mrulist.cpp.

1036{
1037 DWORD cbNodeSlots = m_cSlotRooms * sizeof(BYTE);
1038 if (SHGetValueW(m_hKey, NULL, L"NodeSlots", NULL, m_pbNodeSlots, &cbNodeSlots) != ERROR_SUCCESS)
1039 return FALSE;
1040 m_cMaxNodeSlots = cbNodeSlots / sizeof(BYTE);
1041 return TRUE;
1042}
HKEY m_hKey
Definition: mrulist.cpp:73
DWORD m_cMaxNodeSlots
Definition: mrulist.cpp:973
#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 1044 of file mrulist.cpp.

1045{
1046 DWORD cbNodeSlots = m_cMaxNodeSlots * sizeof(BYTE);
1047 SHSetValueW(m_hKey, NULL, L"NodeSlots", REG_BINARY, m_pbNodeSlots, cbNodeSlots);
1048}
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 1239 of file mrulist.cpp.

1240{
1241 m_pbNodeSlots[nNodeSlot - 1] = 0; // nNodeSlot is 1-base
1242 m_bNeedSave = TRUE;
1243}

◆ GetEmptySlot()

HRESULT CMruPidlList::GetEmptySlot ( UINT pnNodeSlot)

Definition at line 1063 of file mrulist.cpp.

1064{
1065 *pnNodeSlot = 0;
1066
1067 if (!_LoadNodeSlots())
1068 return E_FAIL;
1069
1071 {
1073 *pnNodeSlot = ++m_cMaxNodeSlots;
1075 return S_OK;
1076 }
1077
1078 for (UINT iNodeSlot = 0; iNodeSlot < m_cMaxNodeSlots; ++iNodeSlot)
1079 {
1080 if (m_pbNodeSlots[iNodeSlot] & SLOT_SET)
1081 continue;
1082
1083 m_pbNodeSlots[iNodeSlot] = SLOT_SET;
1084 *pnNodeSlot = iNodeSlot + 1; // nNodeSlot is 1-base
1086 return S_OK;
1087 }
1088
1089 HRESULT hr = E_FAIL;
1090 if (SUCCEEDED(RemoveLeast(pnNodeSlot)) && *pnNodeSlot)
1091 hr = S_OK;
1092
1094 return hr;
1095}
HRESULT RemoveLeast(UINT *pnNodeSlot)
Definition: mrulist.cpp:936
#define E_FAIL
Definition: ddrawi.h:102
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define SLOT_SET
Definition: mrulist.cpp:27
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 1097 of file mrulist.cpp.

1098{
1099 TRACE("%p -> %u %p %s\n", this, cMRUSize, hKey, debugstr_w(pszSubKey));
1100
1101 HRESULT hr = InitData(cMRUSize, 0, hKey, pszSubKey, NULL);
1102 if (FAILED(hr))
1103 {
1104 ERR("0x%08lX\n", hr);
1105 return hr;
1106 }
1107
1108 hr = _InitNodeSlots();
1109 if (FAILED(hr))
1110 {
1111 ERR("0x%08lX\n", hr);
1112 return hr;
1113 }
1114
1115 m_hMutex = ::CreateMutexW(NULL, FALSE, L"Shell.CMruPidlList");
1116 if (!m_hMutex)
1117 {
1119 ERR("0x%08lX\n", hr);
1120 }
1121
1122 return hr;
1123}
#define ERR(fmt,...)
Definition: precomp.h:57
STDMETHODIMP InitData(UINT cCapacity, UINT flags, HKEY hKey, LPCWSTR pszSubKey OPTIONAL, SLOTCOMPARE fnCompare OPTIONAL) override
Definition: mrulist.cpp:274
HRESULT _InitNodeSlots()
Definition: mrulist.cpp:1050
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 1208 of file mrulist.cpp.

1209{
1210 TRACE("%p -> %p\n", this, pidl);
1211
1213 HRESULT hr = mutex.Enter(m_hMutex);
1214 if (FAILED(hr))
1215 {
1216 ERR("0x%08lX\n", hr);
1217 return hr;
1218 }
1219
1220 if (!_LoadNodeSlots())
1221 return hr;
1222
1223 CMruNode *pNode;
1224 hr = GetNode(FALSE, pidl, &pNode);
1225 if (FAILED(hr))
1226 return hr;
1227
1228 if (hr == S_OK)
1229 hr = pNode->Clear(this);
1230 else
1231 hr = E_FAIL;
1232
1233 pNode->Release();
1234
1236 return hr;
1237}
HRESULT Clear(CMruPidlList *pList)
Definition: mrulist.cpp:1266
HRESULT GetNode(BOOL bAdd, LPCITEMIDLIST pidl, CMruNode **pNewNode)
Definition: mrulist.cpp:808
Definition: module.h:456

◆ QueryInterface()

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

Definition at line 1019 of file mrulist.cpp.

1020{
1021 if (!ppvObj)
1022 return E_POINTER;
1023
1024 if (::IsEqualGUID(riid, IID_IMruPidlList) || ::IsEqualGUID(riid, IID_IUnknown))
1025 {
1026 *ppvObj = static_cast<IMruPidlList*>(this);
1027 AddRef();
1028 return S_OK;
1029 }
1030
1031 ERR("%s: E_NOINTERFACE\n", debugstr_guid(&riid));
1032 return E_NOINTERFACE;
1033}
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 1161 of file mrulist.cpp.

1166{
1167 TRACE("%p -> %p %u %p %p\n", this, pidl, cSlots, pnNodeSlots, pcNodeSlots);
1168
1170 HRESULT hr = mutex.Enter(m_hMutex);
1171 if (FAILED(hr))
1172 {
1173 ERR("0x%08lX\n", hr);
1174 return hr;
1175 }
1176
1177 *pcNodeSlots = 0;
1178
1179 CMruNode *pNode;
1180 hr = GetNode(FALSE, pidl, &pNode);
1181 if (FAILED(hr))
1182 {
1183 ERR("0x%08lX\n", hr);
1184 return hr;
1185 }
1186
1187 while (pNode && *pcNodeSlots < cSlots)
1188 {
1189 CMruNode *pParent = pNode->GetParent();
1190 if (SUCCEEDED(pNode->GetNodeSlot(&pnNodeSlots[*pcNodeSlots])))
1191 ++(*pcNodeSlots);
1192 else if (hr == S_OK && !*pcNodeSlots)
1193 hr = S_FALSE;
1194
1195 pNode->Release();
1196 pNode = pParent;
1197 }
1198
1199 if (pNode)
1200 pNode->Release();
1201
1202 if (SUCCEEDED(hr) && !*pcNodeSlots)
1203 hr = E_FAIL;
1204
1205 return hr;
1206}
HRESULT GetNodeSlot(UINT *pnNodeSlot)
Definition: mrulist.cpp:879
CMruNode * GetParent()
Definition: mrulist.cpp:783
FxObject * pParent
Definition: fxdpcapi.cpp:86
#define S_FALSE
Definition: winerror.h:2357

◆ STDMETHODIMP_() [1/2]

CMruPidlList::STDMETHODIMP_ ( ULONG  )
inlineoverride

Definition at line 989 of file mrulist.cpp.

990 {
991 return CMruBase::AddRef();
992 }

◆ STDMETHODIMP_() [2/2]

CMruPidlList::STDMETHODIMP_ ( ULONG  )
inlineoverride

Definition at line 993 of file mrulist.cpp.

994 {
995 return CMruBase::Release();
996 }

◆ UsePidl()

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

Definition at line 1125 of file mrulist.cpp.

1126{
1127 TRACE("%p -> %p %p\n", this, pidl, pnNodeSlot);
1128
1130 HRESULT hr = mutex.Enter(m_hMutex);
1131 if (FAILED(hr))
1132 {
1133 ERR("0x%08lX\n", hr);
1134 return hr;
1135 }
1136
1137 *pnNodeSlot = 0;
1138
1139 CMruNode *pNode;
1140 hr = GetNode(TRUE, pidl, &pNode);
1141 if (FAILED(hr))
1142 {
1143 ERR("0x%08lX\n", hr);
1144 return hr;
1145 }
1146
1147 hr = pNode->GetNodeSlot(pnNodeSlot);
1148 if (FAILED(hr))
1149 {
1150 hr = GetEmptySlot(pnNodeSlot);
1151 if (SUCCEEDED(hr))
1152 {
1153 hr = pNode->SetNodeSlot(*pnNodeSlot);
1154 }
1155 }
1156
1157 pNode->Release();
1158 return hr;
1159}
HRESULT SetNodeSlot(UINT nNodeSlot)
Definition: mrulist.cpp:889
HRESULT GetEmptySlot(UINT *pnNodeSlot)
Definition: mrulist.cpp:1063

Member Data Documentation

◆ m_cMaxNodeSlots

DWORD CMruPidlList::m_cMaxNodeSlots = 0
protected

Definition at line 973 of file mrulist.cpp.

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

◆ m_hMutex

HANDLE CMruPidlList::m_hMutex = NULL
protected

Definition at line 974 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: