1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012-2017 - TortoiseGit
4 // Copyright (C) 2003-2011, 2017 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program 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
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #define ADMINDIRTIMEOUT 10000
25 #define DRIVETYPETIMEOUT 300000 // 5 min
27 #define DEFAULTMENUTOPENTRIES MENUSYNC|MENUCREATEREPOS|MENUCLONE|MENUCOMMIT
28 #define DEFAULTMENUEXTENTRIES MENUSVNIGNORE|MENUSTASHAPPLY|MENUSUBSYNC
30 typedef CComCritSecLock
<CComCriticalSection
> Locker
;
32 typedef enum tristate_t
34 /** state known to be false (the constant does not evaulate to false) */
36 /** state known to be true */
38 /** state could be true or false */
43 * \ingroup TortoiseShell
44 * Helper class which caches access to the registry. Also provides helper methods
45 * for checks against the settings stored in the registry.
55 dllFull
,// same as dll except it uses commandline git tool with all status modes supported
61 bool RefreshIfNeeded();
63 CacheType
GetCacheType();
65 unsigned __int64
GetMenuLayout();
66 unsigned __int64
GetMenuExt();
67 unsigned __int64
GetMenuMask();
69 bool IsProcessElevated();
70 BOOL
IsOnlyNonElevated();
73 BOOL
IsFolderOverlay();
74 BOOL
IsSimpleContext();
75 BOOL
HasShellMenuAccelerators();
76 BOOL
IsUnversionedAsModified();
77 BOOL
IsRecurseSubmodules();
78 BOOL
ShowUnversionedOverlay();
79 BOOL
ShowIgnoredOverlay();
81 BOOL
ShowExcludedAsNormal();
82 BOOL
HideMenusForUnversionedItems();
91 BOOL
IsContextPathAllowed(LPCTSTR path
);
92 BOOL
IsPathAllowed(LPCTSTR path
);
94 BOOL
HasGITAdminDir(LPCTSTR path
, BOOL bIsDir
, CString
* ProjectTopDir
= nullptr);
97 void ExcludeContextValid();
102 /// node in the lookup tree
107 /// default (path spec did not end a '?').
108 /// if this is not set, the default for all
109 /// sub-paths is !included.
110 /// This is a temporary setting an be invalid
111 /// after @ref PostProcessData
114 /// this is an "include" specification
117 /// if @ref recursive is not set, this is
118 /// the parent path status being passed down
119 /// combined with the information of other
120 /// entries for the same @ref path.
121 tristate_t subPathIncluded
;
123 /// do entries for sub-paths exist?
124 bool hasSubFolderEntries
;
127 /// For efficient folding, it is imperative that
128 /// "recursive" entries are first
129 bool operator<(const SEntry
& rhs
) const
131 int diff
= _wcsicmp(path
.c_str(), rhs
.path
.c_str());
132 return (diff
< 0) || ((diff
== 0) && recursive
&& !rhs
.recursive
);
135 friend bool operator<(const SEntry
& rhs
, const std::pair
<LPCTSTR
, size_t>& lhs
);
136 friend bool operator<(const std::pair
<LPCTSTR
, size_t>& lhs
, const SEntry
& rhs
);
140 /// lookup by path (all entries sorted by path)
141 typedef std::vector
<SEntry
> TData
;
144 /// registry keys plus cached last content
145 CRegStdString excludelist
;
146 tstring excludeliststr
;
148 CRegStdString includelist
;
149 tstring includeliststr
;
151 /// construct \ref data content
152 void AddEntry(const tstring
& s
, bool include
);
153 void AddEntries(const tstring
& s
, bool include
);
155 /// for all paths, have at least one entry in data
156 void PostProcessData();
158 /// lookup. default result is "unknown".
159 /// We must look for *every* parent path because of situations like:
160 /// excluded: C:, C:\some\deep\path
162 /// lookup for C:\some\deeper\path
163 tristate_t
IsPathAllowed(LPCTSTR path
, TData::const_iterator begin
, TData::const_iterator end
) const;
169 /// notify of (potential) registry settings
173 tristate_t
IsPathAllowed(LPCTSTR path
) const;
176 friend bool operator< (const CPathFilter::SEntry
& rhs
, const std::pair
<LPCTSTR
, size_t>& lhs
);
177 friend bool operator< (const std::pair
<LPCTSTR
, size_t>& lhs
, const CPathFilter::SEntry
& rhs
);
182 tstring sProjectRoot
;
187 CRegStdDWORD cachetype
;
188 CRegStdDWORD blockstatus
;
190 CRegStdDWORD onlynonelevated
;
191 CRegStdDWORD showrecursive
;
192 CRegStdDWORD folderoverlay
;
193 CRegStdDWORD getlocktop
;
194 CRegStdDWORD driveremote
;
195 CRegStdDWORD drivefixed
;
196 CRegStdDWORD drivecdrom
;
197 CRegStdDWORD driveremove
;
198 CRegStdDWORD drivefloppy
;
199 CRegStdDWORD driveram
;
200 CRegStdDWORD driveunknown
;
201 CRegStdDWORD menulayoutlow
; /* Fist level mask */
202 CRegStdDWORD menulayouthigh
;
203 CRegStdDWORD shellmenuaccelerators
;
204 CRegStdDWORD menuextlow
; /* ext menu mask */
205 CRegStdDWORD menuexthigh
;
206 CRegStdDWORD simplecontext
;
207 CRegStdDWORD menumasklow_lm
;
208 CRegStdDWORD menumaskhigh_lm
;
209 CRegStdDWORD menumasklow_cu
;
210 CRegStdDWORD menumaskhigh_cu
;
211 CRegStdDWORD unversionedasmodified
;
212 CRegStdDWORD recursesubmodules
;
213 CRegStdDWORD showunversionedoverlay
;
214 CRegStdDWORD showignoredoverlay
;
215 CRegStdDWORD excludedasnormal
;
216 CRegStdDWORD hidemenusforunversioneditems
;
218 CPathFilter pathFilter
;
220 ULONGLONG drivetypeticker
;
221 ULONGLONG menumaskticker
;
222 UINT drivetypecache
[27];
223 TCHAR drivetypepathcache
[MAX_PATH
]; // MAX_PATH ok.
225 TCHAR szThousandsSep
[5];
226 std::map
<tstring
, AdminDir_s
> admindircache
;
227 CRegStdString nocontextpaths
;
228 tstring excludecontextstr
;
229 std::vector
<tstring
> excontextvector
;
230 CComCriticalSection m_critSec
;
231 HANDLE m_registryChangeEvent
;
232 HKEY m_hNotifyRegKey
;
236 inline bool operator<(const ShellCache::CPathFilter::SEntry
& lhs
, const std::pair
<LPCTSTR
, size_t>& rhs
)
238 return _wcsnicmp(lhs
.path
.c_str(), rhs
.first
, rhs
.second
) < 0;
241 inline bool operator<(const std::pair
<LPCTSTR
, size_t>& lhs
, const ShellCache::CPathFilter::SEntry
& rhs
)
243 return _wcsnicmp(lhs
.first
, rhs
.path
.c_str(), lhs
.second
) < 0;