ReactOS 0.4.16-dev-2522-g97cc325
CMruNode Class Reference
Inheritance diagram for CMruNode:
Collaboration diagram for CMruNode:

Public Member Functions

 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 _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

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 728 of file mrulist.cpp.

Constructor & Destructor Documentation

◆ CMruNode() [1/2]

CMruNode::CMruNode ( )
inline

Definition at line 747 of file mrulist.cpp.

747{ }

Referenced by _CreateNode().

◆ CMruNode() [2/2]

CMruNode::CMruNode ( CMruNode pParent,
UINT  iSlot 
)

Definition at line 762 of file mrulist.cpp.

763{
764 m_iSlot = iSlot;
766 pParent->AddRef();
767}
CMruNode * m_pParent
Definition: mrulist.cpp:733
UINT m_iSlot
Definition: mrulist.cpp:732
ULONG __inline AddRef(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:826
FxObject * pParent
Definition: fxdpcapi.cpp:86

◆ ~CMruNode()

CMruNode::~CMruNode ( )
override

Definition at line 769 of file mrulist.cpp.

770{
771 if (m_pParent)
772 {
773 m_pParent->Release();
774 m_pParent = NULL;
775 }
776
777 if (m_pShellFolder)
778 {
781 }
782}
IShellFolder * m_pShellFolder
Definition: mrulist.cpp:734
#define NULL
Definition: types.h:112
ULONG Release()

Member Function Documentation

◆ _AddPidl()

HRESULT CMruNode::_AddPidl ( UINT  iSlot,
LPCITEMIDLIST  pidl 
)
protected

Definition at line 898 of file mrulist.cpp.

899{
900 return CMruBase::_AddItem(iSlot, pidl, sizeof(WORD) + pidl->mkid.cb);
901}
HRESULT _AddItem(UINT iSlot, LPCVOID pvData, DWORD cbData)
Definition: mrulist.cpp:248
unsigned short WORD
Definition: ntddk_ex.h:93

Referenced by _GetPidlSlot().

◆ _CreateNode()

HRESULT CMruNode::_CreateNode ( UINT  iSlot,
CMruNode **  ppNewNode 
)
protected

Definition at line 791 of file mrulist.cpp.

792{
793 CMruNode *pNewNode = new CMruNode(this, iSlot);
794 if (!pNewNode)
795 return E_OUTOFMEMORY;
796
797 WCHAR szSubKey[12];
798 _SlotString(iSlot, szSubKey, _countof(szSubKey));
799
800 HRESULT hr = pNewNode->InitData(m_cSlotRooms, 0, m_hKey, szSubKey, NULL);
801 if (FAILED(hr))
802 pNewNode->Release();
803 else
804 *ppNewNode = pNewNode;
805
806 return hr;
807}
HKEY m_hKey
Definition: mrulist.cpp:73
STDMETHODIMP InitData(UINT cCapacity, UINT flags, HKEY hKey, LPCWSTR pszSubKey OPTIONAL, SLOTCOMPARE fnCompare OPTIONAL) override
Definition: mrulist.cpp:274
DWORD m_cSlotRooms
Definition: mrulist.cpp:74
void _SlotString(UINT iSlot, LPWSTR psz, DWORD cch) override
Definition: mrulist.cpp:643
CMruNode()
Definition: mrulist.cpp:747
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hr
Definition: delayimp.cpp:573
#define FAILED(hr)
Definition: intsafe.h:51
#define _countof(array)
Definition: sndvol32.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Clear(), GetNode(), and RemoveLeast().

◆ _DeleteValue()

DWORD CMruNode::_DeleteValue ( LPCWSTR  pszValue)
overrideprotectedvirtual

Reimplemented from CMruBase.

Definition at line 903 of file mrulist.cpp.

904{
907}
virtual DWORD _DeleteValue(LPCWSTR pszValue)
Definition: mrulist.cpp:413
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783

◆ _FindPidl()

HRESULT CMruNode::_FindPidl ( LPCITEMIDLIST  pidl,
UINT piSlot 
)
protected

Definition at line 909 of file mrulist.cpp.

910{
911 return FindData(pidl, sizeof(WORD) + pidl->mkid.cb, piSlot);
912}
STDMETHODIMP FindData(LPCVOID pvData, DWORD cbData, UINT *piSlot) override
Definition: mrulist.cpp:323

Referenced by _GetPidlSlot().

◆ _GetPidlSlot()

HRESULT CMruNode::_GetPidlSlot ( LPCITEMIDLIST  pidl,
BOOL  bAdd,
UINT piSlot 
)
protected

Definition at line 914 of file mrulist.cpp.

915{
916 LPITEMIDLIST pidlFirst = ILCloneFirst(pidl);
917 if (!pidlFirst)
918 return E_OUTOFMEMORY;
919
920 UINT iSlot;
921 HRESULT hr = _FindPidl(pidlFirst, &iSlot);
922 if (SUCCEEDED(hr))
923 {
924 *piSlot = _UpdateSlots(iSlot);
925 hr = S_OK;
926 }
927 else if (bAdd)
928 {
929 *piSlot = _UpdateSlots(m_cSlots);
930 hr = _AddPidl(*piSlot, pidlFirst);
931 }
932
933 ILFree(pidlFirst);
934 return hr;
935}
DWORD m_cSlots
Definition: mrulist.cpp:75
UINT _UpdateSlots(UINT iSlot) override
Definition: mrulist.cpp:611
HRESULT _AddPidl(UINT iSlot, LPCITEMIDLIST pidl)
Definition: mrulist.cpp:898
HRESULT _FindPidl(LPCITEMIDLIST pidl, UINT *piSlot)
Definition: mrulist.cpp:909
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
unsigned int UINT
Definition: ndis.h:50
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl)
Definition: pidl.c:263
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by GetNode().

◆ _InitLate()

BOOL CMruNode::_InitLate ( )
protected

Definition at line 861 of file mrulist.cpp.

862{
863 if (!m_pShellFolder)
864 {
865 if (m_pParent)
867 else
869 }
870 return !!m_pShellFolder;
871}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT BindToSlot(UINT iSlot, IShellFolder **ppSF)
Definition: mrulist.cpp:848

Referenced by GetNode().

◆ _IsEqual() [1/2]

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

Reimplemented from CMruBase.

Definition at line 111 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}
#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
int WINAPI StrCmpW(const WCHAR *str, const WCHAR *comp)
Definition: string.c:450
int WINAPI StrCmpIW(const WCHAR *str, const WCHAR *comp)
Definition: string.c:456
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
EXTERN_C BOOL WINAPI IEILIsEqual(_In_ LPCITEMIDLIST pidl1, _In_ LPCITEMIDLIST pidl2, _In_ BOOL bUnknown)
Definition: utility.cpp:132
#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
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ _IsEqual() [2/2]

BOOL CMruNode::_IsEqual ( SLOTITEMDATA pItem,
LPCVOID  pvData,
UINT  cbData 
)
protected

Definition at line 873 of file mrulist.cpp.

874{
875 return m_pShellFolder->CompareIDs(0x10000000,
876 (LPITEMIDLIST)pItem->pvData,
877 (LPCITEMIDLIST)pvData) == 0;
878}
HRESULT CompareIDs([in] LPARAM lParam, [in] PCUIDLIST_RELATIVE pidl1, [in] PCUIDLIST_RELATIVE pidl2)

◆ BindToSlot()

HRESULT CMruNode::BindToSlot ( UINT  iSlot,
IShellFolder **  ppSF 
)

Definition at line 848 of file mrulist.cpp.

849{
850 SLOTITEMDATA *pItem;
851 HRESULT hr = _GetSlotItem(iSlot, &pItem);
852 if (FAILED(hr))
853 return hr;
854
856 NULL,
857 IID_IShellFolder,
858 (void **)ppSF);
859}
HRESULT _GetSlotItem(UINT iSlot, SLOTITEMDATA **ppItem)
Definition: mrulist.cpp:208
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)

Referenced by _InitLate().

◆ Clear()

HRESULT CMruNode::Clear ( CMruPidlList pList)

Definition at line 1267 of file mrulist.cpp.

1268{
1269 UINT uSlot, nNodeSlot;
1270 HRESULT hr;
1271
1272 while (SUCCEEDED(_GetSlot(0, &uSlot)))
1273 {
1274 CMruNode *pNode;
1275 hr = _CreateNode(uSlot, &pNode);
1276 if (SUCCEEDED(hr))
1277 {
1278 hr = pNode->GetNodeSlot(&nNodeSlot);
1279 if (SUCCEEDED(hr))
1280 pList->EmptyNodeSlot(nNodeSlot);
1281
1282 pNode->Clear(pList);
1283 pNode->Release();
1284 }
1285 Delete(0);
1286 }
1287
1288 return S_OK;
1289}
STDMETHODIMP Delete(UINT iSlot) override
Definition: mrulist.cpp:375
HRESULT _GetSlot(UINT iSlot, UINT *puSlot) override
Definition: mrulist.cpp:648
HRESULT Clear(CMruPidlList *pList)
Definition: mrulist.cpp:1267
HRESULT _CreateNode(UINT iSlot, CMruNode **ppNewNode)
Definition: mrulist.cpp:791
HRESULT GetNodeSlot(UINT *pnNodeSlot)
Definition: mrulist.cpp:880
FxChildList * pList

Referenced by Clear(), and CMruPidlList::PruneKids().

◆ GetNode()

HRESULT CMruNode::GetNode ( BOOL  bAdd,
LPCITEMIDLIST  pidl,
CMruNode **  pNewNode 
)

Definition at line 809 of file mrulist.cpp.

810{
811 if (!pidl || !pidl->mkid.cb)
812 {
813 *ppNewNode = this;
814 AddRef();
815 return S_OK;
816 }
817
818 if (!_InitLate())
819 return E_FAIL;
820
821 UINT iSlot;
822 HRESULT hr = _GetPidlSlot(pidl, bAdd, &iSlot);
823 if (FAILED(hr))
824 {
825 if (!bAdd)
826 {
827 *ppNewNode = this;
828 AddRef();
829 return S_FALSE;
830 }
831 return hr;
832 }
833
834 CMruNode *pNewNode;
835 hr = _CreateNode(iSlot, &pNewNode);
836 if (SUCCEEDED(hr))
837 {
838 _SaveSlots();
839
840 LPCITEMIDLIST pidl2 = (LPCITEMIDLIST)((LPBYTE)pidl + pidl->mkid.cb);
841 pNewNode->GetNode(bAdd, pidl2, ppNewNode);
842 pNewNode->Release();
843 }
844
845 return hr;
846}
void _SaveSlots() override
Definition: mrulist.cpp:601
HRESULT _GetPidlSlot(LPCITEMIDLIST pidl, BOOL bAdd, UINT *piSlot)
Definition: mrulist.cpp:914
BOOL _InitLate()
Definition: mrulist.cpp:861
HRESULT GetNode(BOOL bAdd, LPCITEMIDLIST pidl, CMruNode **pNewNode)
Definition: mrulist.cpp:809
#define E_FAIL
Definition: ddrawi.h:102
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:83
unsigned char * LPBYTE
Definition: typedefs.h:53
#define S_FALSE
Definition: winerror.h:3451

Referenced by GetNode(), CMruPidlList::PruneKids(), CMruPidlList::QueryPidl(), and CMruPidlList::UsePidl().

◆ GetNodeSlot()

HRESULT CMruNode::GetNodeSlot ( UINT pnNodeSlot)

Definition at line 880 of file mrulist.cpp.

881{
882 DWORD dwData, cbData = sizeof(dwData);
883 DWORD error = SHGetValueW(m_hKey, NULL, L"NodeSlot", NULL, &dwData, (pnNodeSlot ? &cbData : NULL));
884 if (error != ERROR_SUCCESS)
885 return E_FAIL;
886 *pnNodeSlot = (UINT)dwData;
887 return S_OK;
888}
#define ERROR_SUCCESS
Definition: deptool.c:10
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
#define error(str)
Definition: mkdosfs.c:1605
static HANDLE ULONG_PTR dwData
Definition: pipe.c:83

Referenced by Clear(), CMruPidlList::QueryPidl(), RemoveLeast(), and CMruPidlList::UsePidl().

◆ GetParent()

CMruNode * CMruNode::GetParent ( )

Definition at line 784 of file mrulist.cpp.

785{
786 if (m_pParent)
787 m_pParent->AddRef();
788 return m_pParent;
789}

Referenced by CMruPidlList::QueryPidl().

◆ RemoveLeast()

HRESULT CMruNode::RemoveLeast ( UINT pnNodeSlot)

Definition at line 937 of file mrulist.cpp.

938{
939 if (!m_cSlots)
940 {
941 GetNodeSlot(pnNodeSlot);
942 return S_FALSE;
943 }
944
945 UINT uSlot;
946 HRESULT hr = _GetSlot(m_cSlots - 1, &uSlot);
947 if (FAILED(hr))
948 return hr;
949
950 CMruNode *pNode;
951 hr = _CreateNode(uSlot, &pNode);
952 if (SUCCEEDED(hr))
953 {
954 hr = pNode->RemoveLeast(pnNodeSlot);
955 pNode->Release();
956 }
957
958 if (hr == S_FALSE)
959 {
960 Delete(m_cSlots - 1);
961 if (m_cSlots || SUCCEEDED(GetNodeSlot(0)))
962 return S_OK;
963 }
964
965 return hr;
966}
HRESULT RemoveLeast(UINT *pnNodeSlot)
Definition: mrulist.cpp:937

Referenced by CMruPidlList::GetEmptySlot(), and RemoveLeast().

◆ SetNodeSlot()

HRESULT CMruNode::SetNodeSlot ( UINT  nNodeSlot)

Definition at line 890 of file mrulist.cpp.

891{
892 DWORD dwData = nNodeSlot;
893 if (SHSetValueW(m_hKey, NULL, L"NodeSlot", REG_DWORD, &dwData, sizeof(dwData)) != ERROR_SUCCESS)
894 return E_FAIL;
895 return S_OK;
896}
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define REG_DWORD
Definition: sdbapi.c:615

Referenced by CMruPidlList::UsePidl().

Member Data Documentation

◆ m_iSlot

UINT CMruNode::m_iSlot = 0
protected

Definition at line 732 of file mrulist.cpp.

Referenced by _InitLate(), and CMruNode().

◆ m_pParent

CMruNode* CMruNode::m_pParent = NULL
protected

Definition at line 733 of file mrulist.cpp.

Referenced by _InitLate(), CMruNode(), GetParent(), and ~CMruNode().

◆ m_pShellFolder

IShellFolder* CMruNode::m_pShellFolder = NULL
protected

Definition at line 734 of file mrulist.cpp.

Referenced by _InitLate(), _IsEqual(), BindToSlot(), and ~CMruNode().


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