ReactOS  0.4.13-dev-651-g5dbc677
CACLCustomMRU Class Reference

#include <ACLCustomMRU.h>

Inheritance diagram for CACLCustomMRU:
Collaboration diagram for CACLCustomMRU:

Public Member Functions

 CACLCustomMRU ()
 
 ~CACLCustomMRU ()
 
virtual HRESULT STDMETHODCALLTYPE Initialize (LPCWSTR pwszMRURegKey, DWORD dwMax)
 
virtual HRESULT STDMETHODCALLTYPE AddMRUString (LPCWSTR pwszEntry)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 

Private Member Functions

void PersistMRU ()
 

Private Attributes

CRegKey m_Key
 
CStringW m_MRUList
 
CSimpleArray< CStringW > m_MRUData
 
bool m_bDirty
 

Additional Inherited Members

- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 10 of file ACLCustomMRU.h.

Constructor & Destructor Documentation

◆ CACLCustomMRU()

CACLCustomMRU::CACLCustomMRU ( )

Definition at line 10 of file ACLCustomMRU.cpp.

11  :m_bDirty(false)
12 {
13 }

◆ ~CACLCustomMRU()

CACLCustomMRU::~CACLCustomMRU ( )

Definition at line 15 of file ACLCustomMRU.cpp.

16 {
17  PersistMRU();
18  m_Key.Close();
19 }
LONG Close()
Definition: atlbase.h:1053
CRegKey m_Key
Definition: ACLCustomMRU.h:16

Member Function Documentation

◆ AddMRUString()

HRESULT STDMETHODCALLTYPE CACLCustomMRU::AddMRUString ( LPCWSTR  pwszEntry)
virtual

Definition at line 91 of file ACLCustomMRU.cpp.

92 {
93  ATLASSERT(m_MRUData.GetSize() <= m_MRUList.GetLength());
94 
95  m_bDirty = true;
96 
97  CStringW NewElement = pwszEntry;
98  WCHAR Key[2] = { 0, 0 };
99  int Index = m_MRUData.Find(NewElement);
100  if (Index >= 0)
101  {
102  /* Move the key to the front */
103  Key[0] = Index + 'a';
104  m_MRUList.Replace(Key, L"");
105  m_MRUList = Key + m_MRUList;
106  return S_OK;
107  }
108 
109  int TotalLen = m_MRUList.GetLength();
110  if (m_MRUData.GetSize() == TotalLen)
111  {
112  /* Find oldest element, move that to the front */
113  Key[0] = m_MRUList[TotalLen-1];
114  m_MRUList = Key + m_MRUList.Left(TotalLen-1);
115  Index = Key[0] - 'a';
116  }
117  else
118  {
119  /* Find the first empty entry */
120  for (Index = 0; Index < m_MRUData.GetSize(); ++Index)
121  {
122  if (m_MRUData[Index].IsEmpty())
123  break;
124  }
125  Key[0] = Index + 'a';
126  m_MRUList = Key + m_MRUList;
127  }
128  m_MRUData[Index] = NewElement;
129 
130  PersistMRU();
131  return S_OK;
132 }
int GetLength() const
Definition: atlsimpstr.h:356
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
CSimpleArray< CStringW > m_MRUData
Definition: ACLCustomMRU.h:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
static const WCHAR L[]
Definition: oid.c:1250
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:696
#define S_OK
Definition: intsafe.h:59
CStringT Left(int nCount) const
Definition: cstringt.h:643
CStringW m_MRUList
Definition: ACLCustomMRU.h:17

◆ Initialize()

HRESULT STDMETHODCALLTYPE CACLCustomMRU::Initialize ( LPCWSTR  pwszMRURegKey,
DWORD  dwMax 
)
virtual

Definition at line 41 of file ACLCustomMRU.cpp.

42 {
43  LSTATUS Status = m_Key.Create(HKEY_CURRENT_USER, pwszMRURegKey);
44  if (Status != ERROR_SUCCESS)
45  return HRESULT_FROM_WIN32(Status);
46 
47  m_MRUData.RemoveAll();
48  dwMax = max(0, dwMax);
49  dwMax = min(29, dwMax);
50  while (dwMax--)
51  m_MRUData.Add(CStringW());
52 
53  WCHAR MRUList[40];
54  ULONG nChars = _countof(MRUList);
55 
56  Status = m_Key.QueryStringValue(L"MRUList", MRUList, &nChars);
57  if (Status != ERROR_SUCCESS)
58  return S_OK;
59 
60  if (nChars > 0 && MRUList[nChars-1] == '\0')
61  nChars--;
62 
63  if (nChars > (ULONG)m_MRUData.GetSize())
64  return S_OK;
65 
66  for (ULONG n = 0; n < nChars; ++n)
67  {
68  if (MRUList[n] >= 'a' && MRUList[n] <= '}' && m_MRUList.Find(MRUList[n]) < 0)
69  {
70  WCHAR Key[2] = { MRUList[n], NULL };
71  WCHAR Value[MAX_PATH * 2];
72  ULONG nValueChars = _countof(Value);
73 
74  m_MRUList += MRUList[n];
75  int Index = MRUList[n] - 'a';
76 
77  if (Index < m_MRUData.GetSize())
78  {
79  Status = m_Key.QueryStringValue(Key, Value, &nValueChars);
80  if (Status == ERROR_SUCCESS)
81  {
82  m_MRUData[Index] = CStringW(Value, nValueChars);
83  }
84  }
85  }
86  }
87 
88  return S_OK;
89 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define max(a, b)
Definition: svc.c:63
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
#define _countof(array)
Definition: fontsub.cpp:30
#define HKEY_CURRENT_USER
Definition: winreg.h:11
GLdouble n
Definition: glext.h:7729
CSimpleArray< CStringW > m_MRUData
Definition: ACLCustomMRU.h:18
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const UCHAR Index[8]
Definition: usbohci.c:18
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars)
Definition: atlbase.h:1149
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
static const WCHAR L[]
Definition: oid.c:1250
LONG Create(HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass=REG_NONE, DWORD dwOptions=REG_OPTION_NON_VOLATILE, REGSAM samDesired=KEY_READ|KEY_WRITE, LPSECURITY_ATTRIBUTES lpSecAttr=NULL, LPDWORD lpdwDisposition=NULL)
Definition: atlbase.h:1091
Status
Definition: gdiplustypes.h:24
#define S_OK
Definition: intsafe.h:59
#define min(a, b)
Definition: monoChain.cc:55
int Find(_In_ PCXSTR pszSub, _In_opt_ int iStart=0) const
Definition: cstringt.h:563
unsigned int ULONG
Definition: retypes.h:1
CAtlStringW CStringW
Definition: atlstr.h:130
CRegKey m_Key
Definition: ACLCustomMRU.h:16
CStringW m_MRUList
Definition: ACLCustomMRU.h:17

◆ PersistMRU()

void CACLCustomMRU::PersistMRU ( )
private

Definition at line 21 of file ACLCustomMRU.cpp.

22 {
23  WCHAR Key[2] = { 0, 0 };
24 
25  if (!m_bDirty)
26  return;
27  m_bDirty = false;
28 
29  if (m_Key.m_hKey)
30  {
31  m_Key.SetStringValue(L"MRUList", m_MRUList);
32  for (int Index = 0; Index < m_MRUList.GetLength(); ++Index)
33  {
34  Key[0] = Index + 'a';
36  }
37  }
38 }
int GetLength() const
Definition: atlsimpstr.h:356
CSimpleArray< CStringW > m_MRUData
Definition: ACLCustomMRU.h:18
HKEY m_hKey
Definition: atlbase.h:1013
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
static const WCHAR L[]
Definition: oid.c:1250
CRegKey m_Key
Definition: ACLCustomMRU.h:16
LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ)
Definition: atlbase.h:1224
CStringW m_MRUList
Definition: ACLCustomMRU.h:17

Referenced by AddMRUString(), and ~CACLCustomMRU().

Member Data Documentation

◆ m_bDirty

bool CACLCustomMRU::m_bDirty
private

Definition at line 19 of file ACLCustomMRU.h.

Referenced by AddMRUString(), and PersistMRU().

◆ m_Key

CRegKey CACLCustomMRU::m_Key
private

Definition at line 16 of file ACLCustomMRU.h.

Referenced by Initialize(), PersistMRU(), and ~CACLCustomMRU().

◆ m_MRUData

CSimpleArray<CStringW> CACLCustomMRU::m_MRUData
private

Definition at line 18 of file ACLCustomMRU.h.

Referenced by AddMRUString(), Initialize(), and PersistMRU().

◆ m_MRUList

CStringW CACLCustomMRU::m_MRUList
private

Definition at line 17 of file ACLCustomMRU.h.

Referenced by AddMRUString(), Initialize(), and PersistMRU().


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