ReactOS 0.4.16-dev-2522-g97cc325
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)
 
virtual BOOL _IsEqual (const SLOTITEMDATA *pItem, LPCVOID pvData, UINT cbData) const
 
- 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 968 of file mrulist.cpp.

Constructor & Destructor Documentation

◆ CMruPidlList()

CMruPidlList::CMruPidlList ( )
inline

Definition at line 982 of file mrulist.cpp.

982{ }

◆ ~CMruPidlList()

CMruPidlList::~CMruPidlList ( )
override

Definition at line 1010 of file mrulist.cpp.

1011{
1013 if (m_hMutex)
1014 {
1016 m_hMutex = NULL;
1017 }
1018}
HANDLE m_hMutex
Definition: mrulist.cpp:975
LPBYTE m_pbNodeSlots
Definition: mrulist.cpp:973
#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 1051 of file mrulist.cpp.

1052{
1054 if (!m_pbNodeSlots)
1055 return E_OUTOFMEMORY;
1056
1058 m_bNeedSave = TRUE;
1060
1061 return S_OK;
1062}
BOOL m_bNeedSave
Definition: mrulist.cpp:71
DWORD m_cSlotRooms
Definition: mrulist.cpp:74
void _SaveNodeSlots()
Definition: mrulist.cpp:1045
BOOL _LoadNodeSlots()
Definition: mrulist.cpp:1036
#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: minwinbase.h:93
unsigned char BYTE
Definition: xxhash.c:193

Referenced by InitList().

◆ _LoadNodeSlots()

BOOL CMruPidlList::_LoadNodeSlots ( )
protected

Definition at line 1036 of file mrulist.cpp.

1037{
1038 DWORD cbNodeSlots = m_cSlotRooms * sizeof(BYTE);
1039 if (SHGetValueW(m_hKey, NULL, L"NodeSlots", NULL, m_pbNodeSlots, &cbNodeSlots) != ERROR_SUCCESS)
1040 return FALSE;
1041 m_cMaxNodeSlots = cbNodeSlots / sizeof(BYTE);
1042 return TRUE;
1043}
HKEY m_hKey
Definition: mrulist.cpp:73
DWORD m_cMaxNodeSlots
Definition: mrulist.cpp:974
#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
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95

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

◆ _SaveNodeSlots()

void CMruPidlList::_SaveNodeSlots ( )
protected

Definition at line 1045 of file mrulist.cpp.

1046{
1047 DWORD cbNodeSlots = m_cMaxNodeSlots * sizeof(BYTE);
1048 SHSetValueW(m_hKey, NULL, L"NodeSlots", REG_BINARY, m_pbNodeSlots, cbNodeSlots);
1049}
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:1499

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

◆ EmptyNodeSlot()

void CMruPidlList::EmptyNodeSlot ( UINT  nNodeSlot)

Definition at line 1240 of file mrulist.cpp.

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

◆ GetEmptySlot()

HRESULT CMruPidlList::GetEmptySlot ( UINT pnNodeSlot)

Definition at line 1064 of file mrulist.cpp.

1065{
1066 *pnNodeSlot = 0;
1067
1068 if (!_LoadNodeSlots())
1069 return E_FAIL;
1070
1072 {
1074 *pnNodeSlot = ++m_cMaxNodeSlots;
1076 return S_OK;
1077 }
1078
1079 for (UINT iNodeSlot = 0; iNodeSlot < m_cMaxNodeSlots; ++iNodeSlot)
1080 {
1081 if (m_pbNodeSlots[iNodeSlot] & SLOT_SET)
1082 continue;
1083
1084 m_pbNodeSlots[iNodeSlot] = SLOT_SET;
1085 *pnNodeSlot = iNodeSlot + 1; // nNodeSlot is 1-base
1087 return S_OK;
1088 }
1089
1090 HRESULT hr = E_FAIL;
1091 if (SUCCEEDED(RemoveLeast(pnNodeSlot)) && *pnNodeSlot)
1092 hr = S_OK;
1093
1095 return hr;
1096}
HRESULT RemoveLeast(UINT *pnNodeSlot)
Definition: mrulist.cpp:937
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:573
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define SLOT_SET
Definition: mrulist.cpp:27
unsigned int UINT
Definition: ndis.h:50

Referenced by UsePidl().

◆ InitList()

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

Definition at line 1098 of file mrulist.cpp.

1099{
1100 TRACE("%p -> %u %p %s\n", this, cMRUSize, hKey, debugstr_w(pszSubKey));
1101
1102 HRESULT hr = InitData(cMRUSize, 0, hKey, pszSubKey, NULL);
1103 if (FAILED(hr))
1104 {
1105 ERR("0x%08lX\n", hr);
1106 return hr;
1107 }
1108
1109 hr = _InitNodeSlots();
1110 if (FAILED(hr))
1111 {
1112 ERR("0x%08lX\n", hr);
1113 return hr;
1114 }
1115
1116 m_hMutex = ::CreateMutexW(NULL, FALSE, L"Shell.CMruPidlList");
1117 if (!m_hMutex)
1118 {
1120 ERR("0x%08lX\n", hr);
1121 }
1122
1123 return hr;
1124}
#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:1051
FxAutoRegKey hKey
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
_In_opt_ LPCSTR pszSubKey
Definition: shlwapi.h:783
#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:525
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ PruneKids()

STDMETHODIMP CMruPidlList::PruneKids ( LPCITEMIDLIST  pidl)
override

Definition at line 1209 of file mrulist.cpp.

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

◆ QueryInterface()

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

Definition at line 1020 of file mrulist.cpp.

1021{
1022 if (!ppvObj)
1023 return E_POINTER;
1024
1025 if (::IsEqualGUID(riid, IID_IMruPidlList) || ::IsEqualGUID(riid, IID_IUnknown))
1026 {
1027 *ppvObj = static_cast<IMruPidlList*>(this);
1028 AddRef();
1029 return S_OK;
1030 }
1031
1032 ERR("%s: E_NOINTERFACE\n", debugstr_guid(&riid));
1033 return E_NOINTERFACE;
1034}
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:83
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480

◆ QueryPidl()

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

Definition at line 1162 of file mrulist.cpp.

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

◆ STDMETHODIMP_() [1/2]

CMruPidlList::STDMETHODIMP_ ( ULONG  )
inlineoverride

Definition at line 990 of file mrulist.cpp.

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

◆ STDMETHODIMP_() [2/2]

CMruPidlList::STDMETHODIMP_ ( ULONG  )
inlineoverride

Definition at line 994 of file mrulist.cpp.

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

◆ UsePidl()

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

Definition at line 1126 of file mrulist.cpp.

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

Member Data Documentation

◆ m_cMaxNodeSlots

DWORD CMruPidlList::m_cMaxNodeSlots = 0
protected

Definition at line 974 of file mrulist.cpp.

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

◆ m_hMutex

HANDLE CMruPidlList::m_hMutex = NULL
protected

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