ReactOS 0.4.15-dev-7924-g5949c20
CACLCustomMRU Class Reference

#include <ACLCustomMRU.h>

Inheritance diagram for CACLCustomMRU:
Collaboration diagram for CACLCustomMRU:

Public Member Functions

 CACLCustomMRU ()
 
 ~CACLCustomMRU ()
 
STDMETHODIMP Next (ULONG celt, LPWSTR *rgelt, ULONG *pceltFetched) override
 
STDMETHODIMP Skip (ULONG celt) override
 
STDMETHODIMP Reset () override
 
STDMETHODIMP Clone (IEnumString **ppenum) override
 
STDMETHODIMP Expand (LPCOLESTR pszExpand) override
 
STDMETHODIMP Initialize (LPCWSTR pwszMRURegKey, DWORD dwMax) override
 
STDMETHODIMP AddMRUString (LPCWSTR pwszEntry) override
 
- 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 ()
 
- Public Member Functions inherited from IEnumString
HRESULT Next ([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] LPOLESTR *rgelt, [out] ULONG *pceltFetched)
 
HRESULT RemoteNext ([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] LPOLESTR *rgelt, [out] ULONG *pceltFetched)
 
HRESULT Skip ([in] ULONG celt)
 
HRESULT Reset ()
 
HRESULT Clone ([out] IEnumString **ppenum)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Member Functions

void PersistMRU ()
 
HRESULT LoadTypedURLs (DWORD dwMax)
 
HRESULT LoadMRUList (DWORD dwMax)
 

Private Attributes

CRegKey m_Key
 
CStringW m_MRUList
 
CSimpleArray< CStringW > m_MRUData
 
bool m_bDirty
 
BOOL m_bTypedURLs
 
ULONG m_ielt
 

Additional Inherited Members

- Public Types inherited from IEnumString
typedef IEnumStringLPENUMSTRING
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- 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 11 of file ACLCustomMRU.h.

Constructor & Destructor Documentation

◆ CACLCustomMRU()

CACLCustomMRU::CACLCustomMRU ( )

Definition at line 13 of file ACLCustomMRU.cpp.

14 : m_bDirty(false), m_bTypedURLs(FALSE), m_ielt(0)
15{
16}
#define FALSE
Definition: types.h:117

◆ ~CACLCustomMRU()

CACLCustomMRU::~CACLCustomMRU ( )

Definition at line 18 of file ACLCustomMRU.cpp.

19{
20 PersistMRU();
21}

Member Function Documentation

◆ AddMRUString()

HRESULT STDMETHODCALLTYPE CACLCustomMRU::AddMRUString ( LPCWSTR  pwszEntry)
override

Definition at line 215 of file ACLCustomMRU.cpp.

216{
217 if (m_bTypedURLs)
218 return E_FAIL;
219
220 ATLASSERT(m_MRUData.GetSize() <= m_MRUList.GetLength());
221 m_bDirty = true;
222
223 CStringW NewElement = pwszEntry;
224 WCHAR Key[2] = { 0, 0 };
225 int Index = m_MRUData.Find(NewElement);
226 if (Index >= 0)
227 {
228 /* Move the key to the front */
229 Key[0] = Index + 'a';
232 return S_OK;
233 }
234
235 int TotalLen = m_MRUList.GetLength();
236 if (m_MRUData.GetSize() == TotalLen)
237 {
238 /* Find oldest element, move that to the front */
239 Key[0] = m_MRUList[TotalLen-1];
240 m_MRUList = Key + m_MRUList.Left(TotalLen-1);
241 Index = Key[0] - 'a';
242 }
243 else
244 {
245 /* Find the first empty entry */
246 for (Index = 0; Index < m_MRUData.GetSize(); ++Index)
247 {
248 if (m_MRUData[Index].IsEmpty())
249 break;
250 }
251 Key[0] = Index + 'a';
253 }
254 m_MRUData[Index] = NewElement;
255
256 PersistMRU();
257 return S_OK;
258}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
int GetLength() const noexcept
Definition: atlsimpstr.h:362
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:886
CStringT Left(int nCount) const
Definition: cstringt.h:776
CStringW m_MRUList
Definition: ACLCustomMRU.h:20
CSimpleArray< CStringW > m_MRUData
Definition: ACLCustomMRU.h:21
#define E_FAIL
Definition: ddrawi.h:102
@ IsEmpty
Definition: atl_ax.c:995
#define S_OK
Definition: intsafe.h:52
#define L(x)
Definition: ntvdm.h:50
_In_ WDFCOLLECTION _In_ ULONG Index
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ Clone()

STDMETHODIMP CACLCustomMRU::Clone ( IEnumString **  ppenum)
override

Implements IEnumString.

Definition at line 69 of file ACLCustomMRU.cpp.

70{
71 *ppenum = NULL;
72 return E_NOTIMPL;
73}
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112

◆ Expand()

STDMETHODIMP CACLCustomMRU::Expand ( LPCOLESTR  pszExpand)
override

Definition at line 75 of file ACLCustomMRU.cpp.

76{
77 return E_NOTIMPL;
78}

◆ Initialize()

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

Definition at line 149 of file ACLCustomMRU.cpp.

150{
151 m_ielt = 0;
152
153 LSTATUS Status = m_Key.Create(HKEY_CURRENT_USER, pwszMRURegKey);
154 if (Status != ERROR_SUCCESS)
156
157 m_MRUData.RemoveAll();
158 if (lstrcmpiW(pwszMRURegKey, TYPED_URLS_KEY) == 0)
159 {
161 return LoadTypedURLs(dwMax);
162 }
163 else
164 {
166 return LoadMRUList(dwMax);
167 }
168}
#define TYPED_URLS_KEY
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) noexcept
Definition: atlbase.h:1189
HRESULT LoadTypedURLs(DWORD dwMax)
CRegKey m_Key
Definition: ACLCustomMRU.h:19
HRESULT LoadMRUList(DWORD dwMax)
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define TRUE
Definition: types.h:120
Status
Definition: gdiplustypes.h:25
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define HKEY_CURRENT_USER
Definition: winreg.h:11

◆ LoadMRUList()

HRESULT CACLCustomMRU::LoadMRUList ( DWORD  dwMax)
private

Definition at line 170 of file ACLCustomMRU.cpp.

171{
172 dwMax = max(0, dwMax);
173 dwMax = min(29, dwMax);
174 while (dwMax--)
175 m_MRUData.Add(CStringW());
176
177 WCHAR MRUList[40];
178 ULONG nChars = _countof(MRUList);
179
180 LSTATUS Status = m_Key.QueryStringValue(L"MRUList", MRUList, &nChars);
181 if (Status != ERROR_SUCCESS)
182 return S_OK;
183
184 if (nChars > 0 && MRUList[nChars-1] == '\0')
185 nChars--;
186
187 if (nChars > (ULONG)m_MRUData.GetSize())
188 return S_OK;
189
190 for (ULONG n = 0; n < nChars; ++n)
191 {
192 if (MRUList[n] >= 'a' && MRUList[n] <= '}' && m_MRUList.Find(MRUList[n]) < 0)
193 {
194 WCHAR Key[2] = { MRUList[n], NULL };
195 WCHAR Value[MAX_PATH * 2];
196 ULONG nValueChars = _countof(Value);
197
198 m_MRUList += MRUList[n];
199 int Index = MRUList[n] - 'a';
200
201 if (Index < m_MRUData.GetSize())
202 {
203 Status = m_Key.QueryStringValue(Key, Value, &nValueChars);
204 if (Status == ERROR_SUCCESS)
205 {
206 m_MRUData[Index] = CStringW(Value, nValueChars);
207 }
208 }
209 }
210 }
211
212 return S_OK;
213}
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) noexcept
Definition: atlbase.h:1240
int Find(_In_ PCXSTR pszSub, _In_opt_ int iStart=0) const noexcept
Definition: cstringt.h:696
#define MAX_PATH
Definition: compat.h:34
GLdouble n
Definition: glext.h:7729
#define min(a, b)
Definition: monoChain.cc:55
CAtlStringW CStringW
Definition: atlstr.h:130
#define _countof(array)
Definition: sndvol32.h:68
#define max(a, b)
Definition: svc.c:63
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by Initialize().

◆ LoadTypedURLs()

HRESULT CACLCustomMRU::LoadTypedURLs ( DWORD  dwMax)
private

Definition at line 124 of file ACLCustomMRU.cpp.

125{
126 dwMax = max(0, dwMax);
127 dwMax = min(29, dwMax);
128
129 WCHAR szName[32];
130 CStringW strData;
132 for (DWORD i = 1; i <= dwMax; ++i)
133 {
134 // Build a registry value name
135 StringCbPrintfW(szName, sizeof(szName), L"url%lu", i);
136
137 // Read a registry value
138 status = RegQueryCStringW(m_Key, szName, strData);
139 if (status != ERROR_SUCCESS)
140 break;
141
142 m_MRUData.Add(strData);
143 }
144
145 return S_OK;
146}
static LSTATUS RegQueryCStringW(CRegKey &key, LPCWSTR pszValueName, CStringW &str)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const WCHAR szName[]
Definition: powrprof.c:45
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
Definition: ps.c:97

Referenced by Initialize().

◆ Next()

STDMETHODIMP CACLCustomMRU::Next ( ULONG  celt,
LPWSTR rgelt,
ULONG pceltFetched 
)
override

Definition at line 23 of file ACLCustomMRU.cpp.

24{
25 if (!pceltFetched || !rgelt)
26 return E_POINTER;
27
28 *pceltFetched = 0;
29 if (celt == 0)
30 return S_OK;
31
32 *rgelt = NULL;
33 if (INT(m_ielt) >= m_MRUData.GetSize())
34 return S_FALSE;
35
37
38 if (!m_bTypedURLs)
39 {
40 // Erase the last "\\1" etc. (indicates SW_* value)
41 INT ich = str.ReverseFind(L'\\');
42 if (ich >= 0)
43 str = str.Left(ich);
44 }
45
46 size_t cb = (str.GetLength() + 1) * sizeof(WCHAR);
48 if (!psz)
49 return S_FALSE;
50
51 CopyMemory(psz, (LPCWSTR)str, cb);
52 *rgelt = psz;
53 *pceltFetched = 1;
54 ++m_ielt;
55 return S_OK;
56}
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define INT
Definition: polytest.cpp:20
const WCHAR * str
int32_t INT
Definition: typedefs.h:58
#define CopyMemory
Definition: winbase.h:1710
#define S_FALSE
Definition: winerror.h:2357
#define E_POINTER
Definition: winerror.h:2365
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ PersistMRU()

void CACLCustomMRU::PersistMRU ( )
private

Definition at line 80 of file ACLCustomMRU.cpp.

81{
82 if (!m_bDirty || m_bTypedURLs)
83 return;
84
85 WCHAR Key[2] = { 0, 0 };
86
87 m_bDirty = false;
88
89 if (m_Key.m_hKey)
90 {
92 for (int Index = 0; Index < m_MRUList.GetLength(); ++Index)
93 {
94 Key[0] = Index + 'a';
96 }
97 }
98}
LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ) noexcept
Definition: atlbase.h:1315
HKEY m_hKey
Definition: atlbase.h:1115

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

◆ Reset()

STDMETHODIMP CACLCustomMRU::Reset ( )
override

Implements IEnumString.

Definition at line 63 of file ACLCustomMRU.cpp.

64{
65 m_ielt = 0;
66 return S_OK;
67}

◆ Skip()

STDMETHODIMP CACLCustomMRU::Skip ( ULONG  celt)
override

Implements IEnumString.

Definition at line 58 of file ACLCustomMRU.cpp.

59{
60 return E_NOTIMPL;
61}

Member Data Documentation

◆ m_bDirty

bool CACLCustomMRU::m_bDirty
private

Definition at line 22 of file ACLCustomMRU.h.

Referenced by AddMRUString(), and PersistMRU().

◆ m_bTypedURLs

BOOL CACLCustomMRU::m_bTypedURLs
private

Definition at line 23 of file ACLCustomMRU.h.

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

◆ m_ielt

ULONG CACLCustomMRU::m_ielt
private

Definition at line 24 of file ACLCustomMRU.h.

Referenced by Initialize(), Next(), and Reset().

◆ m_Key

CRegKey CACLCustomMRU::m_Key
private

Definition at line 19 of file ACLCustomMRU.h.

Referenced by Initialize(), LoadMRUList(), LoadTypedURLs(), and PersistMRU().

◆ m_MRUData

CSimpleArray<CStringW> CACLCustomMRU::m_MRUData
private

Definition at line 21 of file ACLCustomMRU.h.

Referenced by AddMRUString(), Initialize(), LoadMRUList(), LoadTypedURLs(), Next(), and PersistMRU().

◆ m_MRUList

CStringW CACLCustomMRU::m_MRUList
private

Definition at line 20 of file ACLCustomMRU.h.

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


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