ReactOS 0.4.16-dev-320-g3bd9ddc
CMruBase Class Referenceabstract
Inheritance diagram for CMruBase:
Collaboration diagram for CMruBase:

Public Member Functions

 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
 

Static Public Member Functions

static voidoperator new (size_t size)
 
static void operator delete (void *ptr)
 

Protected Member Functions

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

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
 

Detailed Description

Definition at line 65 of file mrulist.cpp.

Constructor & Destructor Documentation

◆ CMruBase()

CMruBase::CMruBase ( )

Definition at line 130 of file mrulist.cpp.

131{
133}
static void SHDOCVW_LockModule(void)
Definition: shdocvw.h:59

◆ ~CMruBase()

CMruBase::~CMruBase ( )
virtual

Definition at line 135 of file mrulist.cpp.

136{
137 if (m_hKey)
138 {
140 m_hKey = NULL;
141 }
142
143 if (m_pSlots)
144 {
145 for (UINT iSlot = 0; iSlot < m_cSlots; ++iSlot)
146 {
147 m_pSlots[iSlot].pvData = ::LocalFree(m_pSlots[iSlot].pvData);
148 }
149
151 }
152
154}
#define RegCloseKey(hKey)
Definition: registry.h:49
HKEY m_hKey
Definition: mrulist.cpp:73
DWORD m_cSlots
Definition: mrulist.cpp:75
SLOTITEMDATA * m_pSlots
Definition: mrulist.cpp:77
#define NULL
Definition: types.h:112
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
unsigned int UINT
Definition: ndis.h:50
static void SHDOCVW_UnlockModule(void)
Definition: shdocvw.h:60
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749

Member Function Documentation

◆ _AddItem()

HRESULT CMruBase::_AddItem ( UINT  iSlot,
LPCVOID  pvData,
DWORD  cbData 
)
protected

Definition at line 248 of file mrulist.cpp.

249{
250 SLOTITEMDATA *pItem = &m_pSlots[iSlot];
251
252 WCHAR szBuff[12];
253 _SlotString(iSlot, szBuff, _countof(szBuff));
254
255 if (SHSetValueW(m_hKey, NULL, szBuff, REG_BINARY, pvData, cbData) != ERROR_SUCCESS)
256 return E_OUTOFMEMORY;
257
258 if (cbData >= pItem->cbData || !pItem->pvData)
259 {
260 ::LocalFree(pItem->pvData);
261 pItem->pvData = ::LocalAlloc(LPTR, cbData);
262 }
263
264 if (!pItem->pvData)
265 return E_FAIL;
266
267 pItem->cbData = cbData;
268 pItem->dwFlags = (SLOT_LOADED | SLOT_SET);
269 CopyMemory(pItem->pvData, pvData, cbData);
270 return S_OK;
271}
virtual void _SlotString(UINT iSlot, LPWSTR psz, DWORD cch)=0
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define S_OK
Definition: intsafe.h:52
#define SLOT_LOADED
Definition: mrulist.cpp:26
#define SLOT_SET
Definition: mrulist.cpp:27
#define REG_BINARY
Definition: nt_native.h:1496
#define _countof(array)
Definition: sndvol32.h:70
#define LPTR
Definition: winbase.h:407
#define CopyMemory
Definition: winbase.h:1735
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CMruNode::_AddPidl(), CMruLongList::_ImportShortList(), and AddData().

◆ _CheckUsedSlots()

void CMruBase::_CheckUsedSlots ( )
protected

Definition at line 239 of file mrulist.cpp.

240{
241 UINT iGotSlot;
242 for (UINT iSlot = 0; iSlot < m_cSlots; ++iSlot)
243 _GetSlot(iSlot, &iGotSlot);
244
246}
virtual HRESULT _GetSlot(UINT iSlot, UINT *puSlot)=0
BOOL m_bChecked
Definition: mrulist.cpp:72
#define TRUE
Definition: types.h:120

Referenced by _UseEmptySlot().

◆ _DeleteItem()

void CMruBase::_DeleteItem ( UINT  iSlot)
protected

Definition at line 229 of file mrulist.cpp.

230{
231 WCHAR szBuff[12];
232
233 _SlotString(iSlot, szBuff, _countof(szBuff));
234 _DeleteValue(szBuff);
235
236 m_pSlots[iSlot].pvData = ::LocalFree(m_pSlots[iSlot].pvData);
237}
virtual DWORD _DeleteValue(LPCWSTR pszValue)
Definition: mrulist.cpp:413

Referenced by CMruLongList::_ImportShortList(), and Delete().

◆ _DeleteValue()

DWORD CMruBase::_DeleteValue ( LPCWSTR  pszValue)
virtual

Reimplemented in CMruNode.

Definition at line 413 of file mrulist.cpp.

414{
415 return SHDeleteValueW(m_hKey, NULL, pszValue);
416}
DWORD WINAPI SHDeleteValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue)
Definition: reg.c:1762

Referenced by _DeleteItem(), and CMruNode::_DeleteValue().

◆ _GetItem()

HRESULT CMruBase::_GetItem ( UINT  iSlot,
SLOTITEMDATA **  ppItem 
)
protected

Definition at line 221 of file mrulist.cpp.

222{
223 HRESULT hr = _GetSlot(iSlot, &iSlot);
224 if (FAILED(hr))
225 return hr;
226 return _GetSlotItem(iSlot, ppItem);
227}
HRESULT _GetSlotItem(UINT iSlot, SLOTITEMDATA **ppItem)
Definition: mrulist.cpp:208
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183

Referenced by FindData(), and GetData().

◆ _GetSlot()

virtual HRESULT CMruBase::_GetSlot ( UINT  iSlot,
UINT puSlot 
)
pure virtual

Implemented in CMruShortList, and CMruLongList.

Referenced by _CheckUsedSlots(), _GetItem(), and QueryInfo().

◆ _GetSlotItem()

HRESULT CMruBase::_GetSlotItem ( UINT  iSlot,
SLOTITEMDATA **  ppItem 
)
protected

Definition at line 208 of file mrulist.cpp.

209{
210 if (!(m_pSlots[iSlot].dwFlags & SLOT_LOADED))
211 _LoadItem(iSlot);
212
213 SLOTITEMDATA *pItem = &m_pSlots[iSlot];
214 if (!pItem->pvData)
215 return E_OUTOFMEMORY;
216
217 *ppItem = pItem;
218 return S_OK;
219}
HRESULT _LoadItem(UINT iSlot)
Definition: mrulist.cpp:181
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by _GetItem(), CMruLongList::_ImportShortList(), CMruNode::BindToSlot(), and QueryInfo().

◆ _InitSlots()

virtual HRESULT CMruBase::_InitSlots ( )
pure virtual

Implemented in CMruShortList, and CMruLongList.

Referenced by InitData().

◆ _IsEqual()

BOOL CMruBase::_IsEqual ( const SLOTITEMDATA pItem,
LPCVOID  pvData,
UINT  cbData 
) const
virtual

Definition at line 386 of file mrulist.cpp.

387{
388 if (m_fnCompare)
389 return m_fnCompare(pvData, pItem->pvData, cbData) == 0;
390
391 switch (m_dwFlags & COMPARE_BY_MASK)
392 {
394 if (pItem->cbData != cbData)
395 return FALSE;
396 return memcmp(pvData, pItem->pvData, cbData) == 0;
397
399 return StrCmpIW((LPCWSTR)pvData, (LPCWSTR)pItem->pvData) == 0;
400
402 return StrCmpW((LPCWSTR)pvData, (LPCWSTR)pItem->pvData) == 0;
403
406
407 default:
408 ERR("0x%08X\n", m_dwFlags);
409 return FALSE;
410 }
411}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD m_dwFlags
Definition: mrulist.cpp:70
SLOTCOMPARE m_fnCompare
Definition: mrulist.cpp:76
#define FALSE
Definition: types.h:117
EXTERN_C BOOL WINAPI IEILIsEqual(_In_ LPCITEMIDLIST pidl1, _In_ LPCITEMIDLIST pidl2, _In_ BOOL bUnknown)
Definition: utility.cpp:84
int WINAPI StrCmpIW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:353
int WINAPI StrCmpW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:434
#define COMPARE_BY_STRCMPIW
Definition: mrulist.cpp:31
#define COMPARE_BY_MEMCMP
Definition: mrulist.cpp:30
#define COMPARE_BY_MASK
Definition: mrulist.cpp:34
#define COMPARE_BY_STRCMPW
Definition: mrulist.cpp:32
#define COMPARE_BY_IEILISEQUAL
Definition: mrulist.cpp:33
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by FindData().

◆ _LoadItem()

HRESULT CMruBase::_LoadItem ( UINT  iSlot)
protected

Definition at line 181 of file mrulist.cpp.

182{
183 DWORD cbData;
184 WCHAR szValue[12];
185
186 SLOTITEMDATA *pItem = &m_pSlots[iSlot];
187 _SlotString(iSlot, szValue, _countof(szValue));
188
189 if (SHGetValueW(m_hKey, NULL, szValue, NULL, NULL, &cbData) == ERROR_SUCCESS &&
190 cbData > 0)
191 {
192 pItem->pvData = ::LocalAlloc(LPTR, cbData);
193 if (pItem->pvData)
194 {
195 pItem->cbData = cbData;
196 if (SHGetValueW(m_hKey, NULL, szValue, NULL, pItem->pvData, &cbData) != ERROR_SUCCESS)
197 pItem->pvData = ::LocalFree(pItem->pvData);
198 }
199 }
200
201 pItem->dwFlags |= SLOT_LOADED;
202 if (!pItem->pvData)
203 return E_FAIL;
204
205 return S_OK;
206}
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

Referenced by _GetSlotItem().

◆ _RemoveSlot()

virtual HRESULT CMruBase::_RemoveSlot ( UINT  iSlot,
UINT puSlot 
)
pure virtual

Implemented in CMruShortList, and CMruLongList.

Referenced by Delete().

◆ _SaveSlots()

virtual void CMruBase::_SaveSlots ( )
pure virtual

Implemented in CMruShortList, and CMruLongList.

Referenced by STDMETHODIMP_().

◆ _SlotString()

virtual void CMruBase::_SlotString ( UINT  iSlot,
LPWSTR  psz,
DWORD  cch 
)
pure virtual

Implemented in CMruShortList, and CMruLongList.

Referenced by _AddItem(), _DeleteItem(), and _LoadItem().

◆ _UpdateSlots()

virtual UINT CMruBase::_UpdateSlots ( UINT  iSlot)
pure virtual

Implemented in CMruShortList, and CMruLongList.

Referenced by AddData().

◆ _UseEmptySlot()

HRESULT CMruBase::_UseEmptySlot ( UINT piSlot)
protected

Definition at line 418 of file mrulist.cpp.

419{
420 if (!m_bChecked)
422
423 if (!m_cSlotRooms)
424 return E_FAIL;
425
426 UINT iSlot = 0;
427 for (SLOTITEMDATA *pItem = m_pSlots; (pItem->dwFlags & SLOT_SET); ++pItem)
428 {
429 if (++iSlot >= m_cSlotRooms)
430 return E_FAIL;
431 }
432
433 m_pSlots[iSlot].dwFlags |= SLOT_SET;
434 *piSlot = iSlot;
435 ++m_cSlots;
436
437 return S_OK;
438}
void _CheckUsedSlots()
Definition: mrulist.cpp:239
DWORD m_cSlotRooms
Definition: mrulist.cpp:74

Referenced by CMruShortList::_UpdateSlots(), and CMruLongList::_UpdateSlots().

◆ AddData()

STDMETHODIMP CMruBase::AddData ( LPCVOID  pvData,
DWORD  cbData,
UINT piSlot 
)
override

Definition at line 300 of file mrulist.cpp.

301{
302 UINT iSlot;
303 HRESULT hr = FindData(pvData, cbData, &iSlot);
304 if (FAILED(hr))
305 {
306 iSlot = _UpdateSlots(m_cSlots);
307 hr = _AddItem(iSlot, pvData, cbData);
308 if (FAILED(hr))
309 return hr;
310 }
311 else
312 {
313 iSlot = _UpdateSlots(iSlot);
314 hr = S_OK;
315 }
316
317 if (piSlot)
318 *piSlot = iSlot;
319
320 return hr;
321}
virtual UINT _UpdateSlots(UINT iSlot)=0
STDMETHODIMP FindData(LPCVOID pvData, DWORD cbData, UINT *piSlot) override
Definition: mrulist.cpp:323
HRESULT _AddItem(UINT iSlot, LPCVOID pvData, DWORD cbData)
Definition: mrulist.cpp:248

◆ Delete()

STDMETHODIMP CMruBase::Delete ( UINT  iSlot)
override

Definition at line 375 of file mrulist.cpp.

376{
377 UINT uSlot;
378 HRESULT hr = _RemoveSlot(iSlot, &uSlot);
379 if (FAILED(hr))
380 return hr;
381
382 _DeleteItem(uSlot);
383 return hr;
384}
virtual HRESULT _RemoveSlot(UINT iSlot, UINT *puSlot)=0
void _DeleteItem(UINT iSlot)
Definition: mrulist.cpp:229

Referenced by CMruNode::Clear(), and CMruNode::RemoveLeast().

◆ FindData()

STDMETHODIMP CMruBase::FindData ( LPCVOID  pvData,
DWORD  cbData,
UINT piSlot 
)
override

Definition at line 323 of file mrulist.cpp.

324{
325 if (m_cSlots <= 0)
326 return E_FAIL;
327
328 UINT iSlot = 0;
329 SLOTITEMDATA *pItem;
330 while (FAILED(_GetItem(iSlot, &pItem)) || !_IsEqual(pItem, pvData, cbData))
331 {
332 if (++iSlot >= m_cSlots)
333 return E_FAIL;
334 }
335
336 *piSlot = iSlot;
337 return S_OK;
338}
HRESULT _GetItem(UINT iSlot, SLOTITEMDATA **ppItem)
Definition: mrulist.cpp:221
virtual BOOL _IsEqual(const SLOTITEMDATA *pItem, LPCVOID pvData, UINT cbData) const
Definition: mrulist.cpp:386

Referenced by CMruNode::_FindPidl(), and AddData().

◆ GetData()

STDMETHODIMP CMruBase::GetData ( UINT  iSlot,
LPVOID  pvData,
DWORD  cbData 
)
override

Definition at line 340 of file mrulist.cpp.

341{
342 SLOTITEMDATA *pItem;
343 HRESULT hr = _GetItem(iSlot, &pItem);
344 if (FAILED(hr))
345 return hr;
346
347 if (cbData < pItem->cbData)
349
350 CopyMemory(pvData, pItem->pvData, pItem->cbData);
351 return hr;
352}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

◆ InitData()

STDMETHODIMP CMruBase::InitData ( UINT  cCapacity,
UINT  flags,
HKEY  hKey,
LPCWSTR pszSubKey  OPTIONAL,
SLOTCOMPARE fnCompare  OPTIONAL 
)
override

Definition at line 274 of file mrulist.cpp.

280{
282 m_fnCompare = fnCompare;
283 m_cSlotRooms = cCapacity;
284
285 if (pszSubKey)
287 else
289
290 if (!m_hKey)
291 return E_FAIL;
292
294 if (!m_pSlots)
295 return E_OUTOFMEMORY;
296
297 return _InitSlots();
298}
virtual HRESULT _InitSlots()=0
HKEY WINAPI SHRegDuplicateHKey(HKEY hKey)
Definition: reg.c:2214
FxAutoRegKey hKey
GLbitfield flags
Definition: glext.h:7161
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
LONG WINAPI RegCreateKeyExWrapW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)

Referenced by CMruNode::_CreateNode(), CMruLongList::_ImportShortList(), and CMruPidlList::InitList().

◆ operator delete()

static void CMruBase::operator delete ( void ptr)
inlinestatic

Definition at line 124 of file mrulist.cpp.

125 {
127 }
static PVOID ptr
Definition: dispmode.c:27

◆ operator new()

static void * CMruBase::operator new ( size_t  size)
inlinestatic

Definition at line 120 of file mrulist.cpp.

121 {
122 return ::LocalAlloc(LPTR, size);
123 }
GLsizeiptr size
Definition: glext.h:5919

◆ QueryInfo()

STDMETHODIMP CMruBase::QueryInfo ( UINT  iSlot,
UINT piGotSlot,
DWORD pcbData 
)
override

Definition at line 354 of file mrulist.cpp.

355{
356 UINT iGotSlot;
357 HRESULT hr = _GetSlot(iSlot, &iGotSlot);
358 if (FAILED(hr))
359 return hr;
360
361 if (piGotSlot)
362 *piGotSlot = iGotSlot;
363
364 if (pcbData)
365 {
366 SLOTITEMDATA *pItem;
367 hr = _GetSlotItem(iGotSlot, &pItem);
368 if (SUCCEEDED(hr))
369 *pcbData = pItem->cbData;
370 }
371
372 return hr;
373}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4950

◆ QueryInterface()

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

Definition at line 156 of file mrulist.cpp.

157{
158 if (!ppvObj)
159 return E_POINTER;
160 if (IsEqualGUID(riid, IID_IMruDataList) || IsEqualGUID(riid, IID_IUnknown))
161 {
162 *ppvObj = static_cast<IMruDataList*>(this);
163 AddRef();
164 return S_OK;
165 }
166 ERR("%s: E_NOINTERFACE\n", debugstr_guid(&riid));
167 return E_NOINTERFACE;
168}
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

◆ STDMETHODIMP_() [1/2]

CMruBase::STDMETHODIMP_ ( ULONG  )
inlineoverride

Definition at line 94 of file mrulist.cpp.

95 {
96 return ::InterlockedIncrement(&m_cRefs);
97 }
LONG m_cRefs
Definition: mrulist.cpp:69

◆ STDMETHODIMP_() [2/2]

CMruBase::STDMETHODIMP_ ( ULONG  )
override

Member Data Documentation

◆ m_bChecked

BOOL CMruBase::m_bChecked = FALSE
protected

Definition at line 72 of file mrulist.cpp.

Referenced by _CheckUsedSlots(), and _UseEmptySlot().

◆ m_bNeedSave

◆ m_cRefs

LONG CMruBase::m_cRefs = 1
protected

Definition at line 69 of file mrulist.cpp.

Referenced by STDMETHODIMP_(), and STDMETHODIMP_().

◆ m_cSlotRooms

◆ m_cSlots

◆ m_dwFlags

DWORD CMruBase::m_dwFlags = 0
protected

Definition at line 70 of file mrulist.cpp.

Referenced by _IsEqual(), and InitData().

◆ m_fnCompare

SLOTCOMPARE CMruBase::m_fnCompare = NULL
protected

Definition at line 76 of file mrulist.cpp.

Referenced by _IsEqual(), and InitData().

◆ m_hKey

◆ m_pSlots


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