ReactOS 0.4.15-dev-7998-gdb93cb1
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 91 of file mrulist.cpp.

Constructor & Destructor Documentation

◆ CMruBase()

CMruBase::CMruBase ( )

Definition at line 156 of file mrulist.cpp.

157{
159}
#define InterlockedIncrement
Definition: armddk.h:53
LONG SHDOCVW_refCount
Definition: shdocvw_main.c:44

◆ ~CMruBase()

CMruBase::~CMruBase ( )
virtual

Definition at line 161 of file mrulist.cpp.

162{
163 if (m_hKey)
164 {
166 m_hKey = NULL;
167 }
168
169 if (m_pSlots)
170 {
171 for (UINT iSlot = 0; iSlot < m_cSlots; ++iSlot)
172 {
173 m_pSlots[iSlot].pvData = ::LocalFree(m_pSlots[iSlot].pvData);
174 }
175
177 }
178
180}
#define InterlockedDecrement
Definition: armddk.h:52
#define RegCloseKey(hKey)
Definition: registry.h:49
HKEY m_hKey
Definition: mrulist.cpp:99
DWORD m_cSlots
Definition: mrulist.cpp:101
SLOTITEMDATA * m_pSlots
Definition: mrulist.cpp:103
#define NULL
Definition: types.h:112
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
unsigned int UINT
Definition: ndis.h:50
_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 274 of file mrulist.cpp.

275{
276 SLOTITEMDATA *pItem = &m_pSlots[iSlot];
277
278 WCHAR szBuff[12];
279 _SlotString(iSlot, szBuff, _countof(szBuff));
280
281 if (SHSetValueW(m_hKey, NULL, szBuff, REG_BINARY, pvData, cbData) != ERROR_SUCCESS)
282 return E_OUTOFMEMORY;
283
284 if (cbData >= pItem->cbData || !pItem->pvData)
285 {
286 ::LocalFree(pItem->pvData);
287 pItem->pvData = ::LocalAlloc(LPTR, cbData);
288 }
289
290 if (!pItem->pvData)
291 return E_FAIL;
292
293 pItem->cbData = cbData;
294 pItem->dwFlags = (SLOT_LOADED | SLOT_SET);
295 CopyMemory(pItem->pvData, pvData, cbData);
296 return S_OK;
297}
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:52
#define SLOT_SET
Definition: mrulist.cpp:53
#define REG_BINARY
Definition: nt_native.h:1496
#define _countof(array)
Definition: sndvol32.h:68
#define LPTR
Definition: winbase.h:381
#define CopyMemory
Definition: winbase.h:1710
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

◆ _CheckUsedSlots()

void CMruBase::_CheckUsedSlots ( )
protected

Definition at line 265 of file mrulist.cpp.

266{
267 UINT iGotSlot;
268 for (UINT iSlot = 0; iSlot < m_cSlots; ++iSlot)
269 _GetSlot(iSlot, &iGotSlot);
270
272}
virtual HRESULT _GetSlot(UINT iSlot, UINT *puSlot)=0
BOOL m_bChecked
Definition: mrulist.cpp:98
#define TRUE
Definition: types.h:120

Referenced by _UseEmptySlot().

◆ _DeleteItem()

void CMruBase::_DeleteItem ( UINT  iSlot)
protected

Definition at line 255 of file mrulist.cpp.

256{
257 WCHAR szBuff[12];
258
259 _SlotString(iSlot, szBuff, _countof(szBuff));
260 _DeleteValue(szBuff);
261
262 m_pSlots[iSlot].pvData = ::LocalFree(m_pSlots[iSlot].pvData);
263}
virtual DWORD _DeleteValue(LPCWSTR pszValue)
Definition: mrulist.cpp:439

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

◆ _DeleteValue()

DWORD CMruBase::_DeleteValue ( LPCWSTR  pszValue)
virtual

Reimplemented in CMruNode.

Definition at line 439 of file mrulist.cpp.

440{
441 return SHDeleteValueW(m_hKey, NULL, pszValue);
442}
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 247 of file mrulist.cpp.

248{
249 HRESULT hr = _GetSlot(iSlot, &iSlot);
250 if (FAILED(hr))
251 return hr;
252 return _GetSlotItem(iSlot, ppItem);
253}
HRESULT _GetSlotItem(UINT iSlot, SLOTITEMDATA **ppItem)
Definition: mrulist.cpp:234
#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 234 of file mrulist.cpp.

235{
236 if (!(m_pSlots[iSlot].dwFlags & SLOT_LOADED))
237 _LoadItem(iSlot);
238
239 SLOTITEMDATA *pItem = &m_pSlots[iSlot];
240 if (!pItem->pvData)
241 return E_OUTOFMEMORY;
242
243 *ppItem = pItem;
244 return S_OK;
245}
HRESULT _LoadItem(UINT iSlot)
Definition: mrulist.cpp:207
_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 412 of file mrulist.cpp.

413{
414 if (m_fnCompare)
415 return m_fnCompare(pvData, pItem->pvData, cbData) == 0;
416
417 switch (m_dwFlags & COMPARE_BY_MASK)
418 {
420 if (pItem->cbData != cbData)
421 return FALSE;
422 return memcmp(pvData, pItem->pvData, cbData) == 0;
423
425 return StrCmpIW((LPCWSTR)pvData, (LPCWSTR)pItem->pvData) == 0;
426
428 return StrCmpW((LPCWSTR)pvData, (LPCWSTR)pItem->pvData) == 0;
429
432
433 default:
434 ERR("0x%08X\n", m_dwFlags);
435 return FALSE;
436 }
437}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERR(fmt,...)
Definition: debug.h:110
DWORD m_dwFlags
Definition: mrulist.cpp:96
SLOTCOMPARE m_fnCompare
Definition: mrulist.cpp:102
#define FALSE
Definition: types.h:117
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:57
#define COMPARE_BY_MEMCMP
Definition: mrulist.cpp:56
BOOL IEILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, BOOL bUnknown)
Definition: mrulist.cpp:41
#define COMPARE_BY_MASK
Definition: mrulist.cpp:60
#define COMPARE_BY_STRCMPW
Definition: mrulist.cpp:58
#define COMPARE_BY_IEILISEQUAL
Definition: mrulist.cpp:59
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 207 of file mrulist.cpp.

208{
209 DWORD cbData;
210 WCHAR szValue[12];
211
212 SLOTITEMDATA *pItem = &m_pSlots[iSlot];
213 _SlotString(iSlot, szValue, _countof(szValue));
214
215 if (SHGetValueW(m_hKey, NULL, szValue, NULL, NULL, &cbData) == ERROR_SUCCESS &&
216 cbData > 0)
217 {
218 pItem->pvData = ::LocalAlloc(LPTR, cbData);
219 if (pItem->pvData)
220 {
221 pItem->cbData = cbData;
222 if (SHGetValueW(m_hKey, NULL, szValue, NULL, pItem->pvData, &cbData) != ERROR_SUCCESS)
223 pItem->pvData = ::LocalFree(pItem->pvData);
224 }
225 }
226
227 pItem->dwFlags |= SLOT_LOADED;
228 if (!pItem->pvData)
229 return E_FAIL;
230
231 return S_OK;
232}
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 444 of file mrulist.cpp.

445{
446 if (!m_bChecked)
448
449 if (!m_cSlotRooms)
450 return E_FAIL;
451
452 UINT iSlot = 0;
453 for (SLOTITEMDATA *pItem = m_pSlots; (pItem->dwFlags & SLOT_SET); ++pItem)
454 {
455 if (++iSlot >= m_cSlotRooms)
456 return E_FAIL;
457 }
458
459 m_pSlots[iSlot].dwFlags |= SLOT_SET;
460 *piSlot = iSlot;
461 ++m_cSlots;
462
463 return S_OK;
464}
void _CheckUsedSlots()
Definition: mrulist.cpp:265
DWORD m_cSlotRooms
Definition: mrulist.cpp:100

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

◆ AddData()

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

Definition at line 326 of file mrulist.cpp.

327{
328 UINT iSlot;
329 HRESULT hr = FindData(pvData, cbData, &iSlot);
330 if (FAILED(hr))
331 {
332 iSlot = _UpdateSlots(m_cSlots);
333 hr = _AddItem(iSlot, pvData, cbData);
334 if (FAILED(hr))
335 return hr;
336 }
337 else
338 {
339 iSlot = _UpdateSlots(iSlot);
340 hr = S_OK;
341 }
342
343 if (piSlot)
344 *piSlot = iSlot;
345
346 return hr;
347}
virtual UINT _UpdateSlots(UINT iSlot)=0
STDMETHODIMP FindData(LPCVOID pvData, DWORD cbData, UINT *piSlot) override
Definition: mrulist.cpp:349
HRESULT _AddItem(UINT iSlot, LPCVOID pvData, DWORD cbData)
Definition: mrulist.cpp:274

◆ Delete()

STDMETHODIMP CMruBase::Delete ( UINT  iSlot)
override

Definition at line 401 of file mrulist.cpp.

402{
403 UINT uSlot;
404 HRESULT hr = _RemoveSlot(iSlot, &uSlot);
405 if (FAILED(hr))
406 return hr;
407
408 _DeleteItem(uSlot);
409 return hr;
410}
virtual HRESULT _RemoveSlot(UINT iSlot, UINT *puSlot)=0
void _DeleteItem(UINT iSlot)
Definition: mrulist.cpp:255

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

◆ FindData()

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

Definition at line 349 of file mrulist.cpp.

350{
351 if (m_cSlots <= 0)
352 return E_FAIL;
353
354 UINT iSlot = 0;
355 SLOTITEMDATA *pItem;
356 while (FAILED(_GetItem(iSlot, &pItem)) || !_IsEqual(pItem, pvData, cbData))
357 {
358 if (++iSlot >= m_cSlots)
359 return E_FAIL;
360 }
361
362 *piSlot = iSlot;
363 return S_OK;
364}
HRESULT _GetItem(UINT iSlot, SLOTITEMDATA **ppItem)
Definition: mrulist.cpp:247
virtual BOOL _IsEqual(const SLOTITEMDATA *pItem, LPCVOID pvData, UINT cbData) const
Definition: mrulist.cpp:412

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

◆ GetData()

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

Definition at line 366 of file mrulist.cpp.

367{
368 SLOTITEMDATA *pItem;
369 HRESULT hr = _GetItem(iSlot, &pItem);
370 if (FAILED(hr))
371 return hr;
372
373 if (cbData < pItem->cbData)
375
376 CopyMemory(pvData, pItem->pvData, pItem->cbData);
377 return hr;
378}
#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 300 of file mrulist.cpp.

306{
308 m_fnCompare = fnCompare;
309 m_cSlotRooms = cCapacity;
310
311 if (pszSubKey)
313 else
315
316 if (!m_hKey)
317 return E_FAIL;
318
320 if (!m_pSlots)
321 return E_OUTOFMEMORY;
322
323 return _InitSlots();
324}
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 150 of file mrulist.cpp.

151 {
153 }
static PVOID ptr
Definition: dispmode.c:27

◆ operator new()

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

Definition at line 146 of file mrulist.cpp.

147 {
148 return ::LocalAlloc(LPTR, size);
149 }
GLsizeiptr size
Definition: glext.h:5919

◆ QueryInfo()

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

Definition at line 380 of file mrulist.cpp.

381{
382 UINT iGotSlot;
383 HRESULT hr = _GetSlot(iSlot, &iGotSlot);
384 if (FAILED(hr))
385 return hr;
386
387 if (piGotSlot)
388 *piGotSlot = iGotSlot;
389
390 if (pcbData)
391 {
392 SLOTITEMDATA *pItem;
393 hr = _GetSlotItem(iGotSlot, &pItem);
394 if (SUCCEEDED(hr))
395 *pcbData = pItem->cbData;
396 }
397
398 return hr;
399}
#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 182 of file mrulist.cpp.

183{
184 if (!ppvObj)
185 return E_POINTER;
186 if (IsEqualGUID(riid, IID_IMruDataList) || IsEqualGUID(riid, IID_IUnknown))
187 {
188 *ppvObj = static_cast<IMruDataList*>(this);
189 AddRef();
190 return S_OK;
191 }
192 ERR("%s: E_NOINTERFACE\n", debugstr_guid(&riid));
193 return E_NOINTERFACE;
194}
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 120 of file mrulist.cpp.

121 {
122 return ::InterlockedIncrement(&m_cRefs);
123 }
LONG m_cRefs
Definition: mrulist.cpp:95

◆ STDMETHODIMP_() [2/2]

CMruBase::STDMETHODIMP_ ( ULONG  )
override

Member Data Documentation

◆ m_bChecked

BOOL CMruBase::m_bChecked = FALSE
protected

Definition at line 98 of file mrulist.cpp.

Referenced by _CheckUsedSlots(), and _UseEmptySlot().

◆ m_bNeedSave

◆ m_cRefs

LONG CMruBase::m_cRefs = 1
protected

Definition at line 95 of file mrulist.cpp.

Referenced by STDMETHODIMP_(), and STDMETHODIMP_().

◆ m_cSlotRooms

◆ m_cSlots

◆ m_dwFlags

DWORD CMruBase::m_dwFlags = 0
protected

Definition at line 96 of file mrulist.cpp.

Referenced by _IsEqual(), and InitData().

◆ m_fnCompare

SLOTCOMPARE CMruBase::m_fnCompare = NULL
protected

Definition at line 102 of file mrulist.cpp.

Referenced by _IsEqual(), and InitData().

◆ m_hKey

◆ m_pSlots


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