ReactOS 0.4.16-dev-197-g92996da
globalfoldersettings.cpp
Go to the documentation of this file.
1/*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include "precomp.h"
22
23#define DEFBROWSERSTREAM L"Settings"
24#define DEFAULT_VID GUID_NULL // We don't support WebView
25#define CURRENT_VERSION ( DEFFOLDERSETTINGS::VER_XP )
26
27template<class S, class D> static void CopyTo(const S &Src, D &Dst)
28{
29 Dst.FolderSettings = Src.FolderSettings;
30}
31
33{
34 if ((int)fs.ViewMode < FVM_AUTO || (int)fs.ViewMode > FVM_LAST)
36
39}
40
42{
44}
45
47{
48 C_ASSERT(FIELD_OFFSET(DEFFOLDERSETTINGS, FolderSettings) == 4);
51
52 *(UINT*)&dfs = FALSE; // Set all unknown flags to FALSE
53 dfs.Statusbar = TRUE;
56 dfs.vid = DEFAULT_VID;
58 dfs.Counter = 0;
59 dfs.ViewPriority = VIEW_PRIORITY_CACHEMISS;
60}
61
63{
66 CopyTo(dfs, *this);
67}
68
70{
71}
72
74{
75}
76
78{
79 return Save(NULL);
80}
81
83{
86 CopyTo(sbfs, dfs);
87 return Save(&dfs);
88}
89
91{
92 HKEY hStreamsKey = SHGetShellKey(SHKEY_Key_Explorer, L"Streams", FALSE);
93 if (hStreamsKey)
94 {
95 DWORD cb = sizeof(DEFFOLDERSETTINGS);
97 SRRF_RT_REG_BINARY, NULL, &dfs, &cb);
98 RegCloseKey(hStreamsKey);
100 {
102 {
104 }
106 {
107 dfs.vid = DEFAULT_VID;
108 }
109 if (cb <= FIELD_OFFSET(DEFFOLDERSETTINGS, ViewPriority))
110 {
112 }
113 dfs.ViewPriority = VIEW_PRIORITY_STALECACHEHIT;
114 EnsureValid(dfs);
115 return S_OK;
116 }
117 }
119 return S_FALSE;
120}
121
123{
124 HKEY hStreamsKey = SHGetShellKey(SHKEY_Key_Explorer, L"Streams", TRUE);
125 if (!hStreamsKey)
126 return E_FAIL;
127
129 if (!pFDS)
130 {
133 }
134 else
135 {
136 DWORD cb = sizeof(DEFFOLDERSETTINGS);
138 }
139 RegCloseKey(hStreamsKey);
140 return hr;
141}
142
144{
145 if (cb != sizeof(DEFFOLDERSETTINGS) || !pFDS)
146 return E_INVALIDARG;
147 return Load(*pFDS);
148}
149
151{
152 // NULL pFDS means reset
153 if (cb != sizeof(DEFFOLDERSETTINGS) && pFDS)
154 return E_INVALIDARG;
155 return Save(pFDS);
156}
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define RegCloseKey(hKey)
Definition: registry.h:49
#define D(d)
Definition: builtin.c:4557
static HRESULT ResetBrowserSettings()
static HRESULT Load(DEFFOLDERSETTINGS &dfs)
STDMETHOD() Get(struct DEFFOLDERSETTINGS *pFDS, UINT cb) override
static HRESULT Save(const DEFFOLDERSETTINGS *pFDS)
static HRESULT SaveBrowserSettings(const SBFOLDERSETTINGS &sbfs)
STDMETHOD() Set(const struct DEFFOLDERSETTINGS *pFDS, UINT cb, UINT unknown) override
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
HKEY WINAPI SHGetShellKey(DWORD flags, LPCWSTR sub_key, BOOL create)
Definition: ordinal.c:4601
DWORD WINAPI SHDeleteValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue)
Definition: reg.c:1762
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
unsigned long DWORD
Definition: ntddk_ex.h:95
static void CopyTo(const S &Src, D &Dst)
static void EnsureValid(FOLDERSETTINGS &fs)
#define DEFAULT_VID
static void InitializeDefaults(DEFFOLDERSETTINGS &dfs)
#define CURRENT_VERSION
#define DEFBROWSERSTREAM
#define S_OK
Definition: intsafe.h:52
#define C_ASSERT(e)
Definition: intsafe.h:73
#define Dst
Definition: mesh.h:153
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
@ SHKEY_Key_Explorer
Definition: ordinal.c:2806
unsigned int UINT
Definition: ndis.h:50
#define REG_BINARY
Definition: nt_native.h:1496
#define L(x)
Definition: ntvdm.h:50
#define err(...)
HRESULT HResultFromWin32(DWORD hr)
Definition: shellutils.h:70
HRESULT hr
Definition: shlfolder.c:183
LSTATUS WINAPI SHRegGetValueW(_In_ HKEY hkey, _In_opt_ LPCWSTR pszSubKey, _In_opt_ LPCWSTR pszValue, _In_ SRRF srrfFlags, _Out_opt_ LPDWORD pdwType, _Out_writes_bytes_to_opt_(*pcbData, *pcbData) LPVOID pvData, _Inout_opt_ LPDWORD pcbData)
#define SRRF_RT_REG_BINARY
Definition: shlwapi.h:244
@ FWF_NOSCROLL
Definition: shobjidl.idl:652
@ FWF_OWNERDATA
Definition: shobjidl.idl:645
@ FWF_NOENUMREFRESH
Definition: shobjidl.idl:661
@ FWF_NOCLIENTEDGE
Definition: shobjidl.idl:651
@ FWF_TRANSPARENT
Definition: shobjidl.idl:650
@ FWF_NOVISIBLE
Definition: shobjidl.idl:656
@ FWF_DESKTOP
Definition: shobjidl.idl:647
@ FWF_NOSUBFOLDERS
Definition: shobjidl.idl:649
@ FVM_AUTO
Definition: shobjidl.idl:678
@ FVM_LAST
Definition: shobjidl.idl:688
SHELLVIEWID vid
Definition: shlobj_undoc.h:158
FOLDERSETTINGS FolderSettings
Definition: shlobj_undoc.h:157
Definition: movable.cpp:9
Definition: ffs.h:70
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
#define S_FALSE
Definition: winerror.h:2357