OSDN Git Service

initial icon overlay support using the wingit lib
[tortoisegit/TortoiseGitJp.git] / src / TortoiseShell / ShellCache.h
1 // ToroiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - Stefan Kueng\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 #include "registry.h"\r
21 #include "Globals.h"\r
22 #include "GitAdminDir.h"\r
23 \r
24 #define REGISTRYTIMEOUT 2000\r
25 #define EXCLUDELISTTIMEOUT 5000\r
26 #define ADMINDIRTIMEOUT 10000\r
27 #define DRIVETYPETIMEOUT 300000         // 5 min\r
28 #define NUMBERFMTTIMEOUT 300000\r
29 #define MENUTIMEOUT 100\r
30 \r
31 typedef CComCritSecLock<CComCriticalSection> Locker;\r
32 \r
33 /**\r
34  * \ingroup TortoiseShell\r
35  * Helper class which caches access to the registry. Also provides helper methods\r
36  * for checks against the settings stored in the registry.\r
37  */\r
38 class ShellCache\r
39 {\r
40 public:\r
41         enum CacheType\r
42         {\r
43                 none,\r
44                 exe,\r
45                 dll\r
46         };\r
47         ShellCache()\r
48         {\r
49                 cachetype = CRegStdWORD(_T("Software\\ToroiseGit\\CacheType"), GetSystemMetrics(SM_REMOTESESSION) ? dll : exe);\r
50                 showrecursive = CRegStdWORD(_T("Software\\ToroiseGit\\RecursiveOverlay"), TRUE);\r
51                 folderoverlay = CRegStdWORD(_T("Software\\ToroiseGit\\FolderOverlay"), TRUE);\r
52                 driveremote = CRegStdWORD(_T("Software\\ToroiseGit\\DriveMaskRemote"));\r
53                 drivefixed = CRegStdWORD(_T("Software\\ToroiseGit\\DriveMaskFixed"), TRUE);\r
54                 drivecdrom = CRegStdWORD(_T("Software\\ToroiseGit\\DriveMaskCDROM"));\r
55                 driveremove = CRegStdWORD(_T("Software\\ToroiseGit\\DriveMaskRemovable"));\r
56                 drivefloppy = CRegStdWORD(_T("Software\\ToroiseGit\\DriveMaskFloppy"));\r
57                 driveram = CRegStdWORD(_T("Software\\ToroiseGit\\DriveMaskRAM"));\r
58                 driveunknown = CRegStdWORD(_T("Software\\ToroiseGit\\DriveMaskUnknown"));\r
59                 excludelist = CRegStdString(_T("Software\\ToroiseGit\\OverlayExcludeList"));\r
60                 includelist = CRegStdString(_T("Software\\ToroiseGit\\OverlayIncludeList"));\r
61                 simplecontext = CRegStdWORD(_T("Software\\ToroiseGit\\SimpleContext"), FALSE);\r
62                 unversionedasmodified = CRegStdWORD(_T("Software\\ToroiseGit\\UnversionedAsModified"), FALSE);\r
63                 showunversionedoverlay = CRegStdWORD(_T("Software\\ToroiseGit\\ShowUnversionedOverlay"), TRUE);\r
64                 showignoredoverlay = CRegStdWORD(_T("Software\\ToroiseGit\\ShowIgnoredOverlay"), TRUE);\r
65                 getlocktop = CRegStdWORD(_T("Software\\ToroiseGit\\GetLockTop"), TRUE);\r
66                 excludedasnormal = CRegStdWORD(_T("Software\\ToroiseGit\\ShowExcludedAsNormal"), TRUE);\r
67                 cachetypeticker = GetTickCount();\r
68                 recursiveticker = cachetypeticker;\r
69                 folderoverlayticker = cachetypeticker;\r
70                 driveticker = cachetypeticker;\r
71                 drivetypeticker = cachetypeticker;\r
72                 langticker = cachetypeticker;\r
73                 columnrevformatticker = cachetypeticker;\r
74                 excludelistticker = cachetypeticker;\r
75                 includelistticker = cachetypeticker;\r
76                 simplecontextticker = cachetypeticker;\r
77                 unversionedasmodifiedticker = cachetypeticker;\r
78                 showunversionedoverlayticker = cachetypeticker;\r
79                 showignoredoverlayticker = cachetypeticker;\r
80                 admindirticker = cachetypeticker;\r
81                 columnseverywhereticker = cachetypeticker;\r
82                 getlocktopticker = cachetypeticker;\r
83                 excludedasnormalticker = cachetypeticker;\r
84                 excontextticker = cachetypeticker;\r
85                 menulayoutlow = CRegStdWORD(_T("Software\\ToroiseGit\\ContextMenuEntries"),               MENUCREATEREPOS|MENUCLONE|MENUUPDATE|MENUCOMMIT);\r
86                 menulayouthigh = CRegStdWORD(_T("Software\\ToroiseGit\\ContextMenuEntrieshigh"), (MENUCREATEREPOS|MENUCLONE|MENUUPDATE|MENUCOMMIT)>>32);\r
87                 menumasklow_lm = CRegStdWORD(_T("Software\\ToroiseGit\\ContextMenuEntriesMaskLow"), 0, FALSE, HKEY_LOCAL_MACHINE);\r
88                 menumaskhigh_lm = CRegStdWORD(_T("Software\\ToroiseGit\\ContextMenuEntriesMaskHigh"), 0, FALSE, HKEY_LOCAL_MACHINE);\r
89                 menumasklow_cu = CRegStdWORD(_T("Software\\ToroiseGit\\ContextMenuEntriesMaskLow"), 0);\r
90                 menumaskhigh_cu = CRegStdWORD(_T("Software\\ToroiseGit\\ContextMenuEntriesMaskHigh"), 0);\r
91                 langid = CRegStdWORD(_T("Software\\ToroiseGit\\LanguageID"), 1033);\r
92                 blockstatus = CRegStdWORD(_T("Software\\ToroiseGit\\BlockStatus"), 0);\r
93                 columnseverywhere = CRegStdWORD(_T("Software\\ToroiseGit\\ColumnsEveryWhere"), FALSE);\r
94                 for (int i=0; i<27; i++)\r
95                 {\r
96                         drivetypecache[i] = (UINT)-1;\r
97                 }\r
98                 // A: and B: are floppy disks\r
99                 drivetypecache[0] = DRIVE_REMOVABLE;\r
100                 drivetypecache[1] = DRIVE_REMOVABLE;\r
101                 TCHAR szBuffer[5];\r
102                 columnrevformatticker = GetTickCount();\r
103                 SecureZeroMemory(&columnrevformat, sizeof(NUMBERFMT));\r
104                 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, &szDecSep[0], sizeof(szDecSep));\r
105                 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, &szThousandsSep[0], sizeof(szThousandsSep));\r
106                 columnrevformat.lpDecimalSep = szDecSep;\r
107                 columnrevformat.lpThousandSep = szThousandsSep;\r
108                 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, &szBuffer[0], sizeof(szBuffer));\r
109                 columnrevformat.Grouping = _ttoi(szBuffer);\r
110                 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER, &szBuffer[0], sizeof(szBuffer));\r
111                 columnrevformat.NegativeOrder = _ttoi(szBuffer);\r
112                 sAdminDirCacheKey.reserve(MAX_PATH);            // MAX_PATH as buffer reservation ok.\r
113                 nocontextpaths = CRegStdString(_T("Software\\ToroiseGit\\NoContextPaths"), _T(""));\r
114                 m_critSec.Init();\r
115         }\r
116         void ForceRefresh()\r
117         {\r
118                 cachetype.read();\r
119                 showrecursive.read();\r
120                 folderoverlay.read();\r
121                 driveremote.read();\r
122                 drivefixed.read();\r
123                 drivecdrom.read();\r
124                 driveremove.read();\r
125                 drivefloppy.read();\r
126                 driveram.read();\r
127                 driveunknown.read();\r
128                 excludelist.read();\r
129                 includelist.read();\r
130                 simplecontext.read();\r
131                 unversionedasmodified.read();\r
132                 showunversionedoverlay.read();\r
133                 showignoredoverlay.read();\r
134                 excludedasnormal.read();\r
135                 menulayoutlow.read();\r
136                 menulayouthigh.read();\r
137                 langid.read();\r
138                 blockstatus.read();\r
139                 columnseverywhere.read();\r
140                 getlocktop.read();\r
141                 menumasklow_lm.read();\r
142                 menumaskhigh_lm.read();\r
143                 menumasklow_cu.read();\r
144                 menumaskhigh_cu.read();\r
145                 nocontextpaths.read();\r
146         }\r
147         CacheType GetCacheType()\r
148         {\r
149 return dll;\r
150                 if ((GetTickCount() - REGISTRYTIMEOUT) > cachetypeticker)\r
151                 {\r
152                         cachetypeticker = GetTickCount();\r
153                         cachetype.read();\r
154                 }\r
155                 return CacheType(DWORD((cachetype)));\r
156         }\r
157         DWORD BlockStatus()\r
158         {\r
159                 if ((GetTickCount() - REGISTRYTIMEOUT) > blockstatusticker)\r
160                 {\r
161                         blockstatusticker = GetTickCount();\r
162                         blockstatus.read();\r
163                 }\r
164                 return (blockstatus);\r
165         }\r
166         unsigned __int64 GetMenuLayout()\r
167         {\r
168                 if ((GetTickCount() - REGISTRYTIMEOUT) > layoutticker)\r
169                 {\r
170                         layoutticker = GetTickCount();\r
171                         menulayoutlow.read();\r
172                         menulayouthigh.read();\r
173                 }\r
174                 unsigned __int64 temp = unsigned __int64(DWORD(menulayouthigh))<<32;\r
175                 temp |= unsigned __int64(DWORD(menulayoutlow));\r
176                 return temp;\r
177         }\r
178         unsigned __int64 GetMenuMask()\r
179         {\r
180                 if ((GetTickCount() - REGISTRYTIMEOUT) > menumaskticker)\r
181                 {\r
182                         menumaskticker = GetTickCount();\r
183                         menumasklow_lm.read();\r
184                         menumaskhigh_lm.read();\r
185                         menumasklow_cu.read();\r
186                         menumaskhigh_cu.read();\r
187                 }\r
188                 DWORD low = (DWORD)menumasklow_lm | (DWORD)menumasklow_cu;\r
189                 DWORD high = (DWORD)menumaskhigh_lm | (DWORD)menumaskhigh_cu;\r
190                 unsigned __int64 temp = unsigned __int64(high)<<32;\r
191                 temp |= unsigned __int64(low);\r
192                 return temp;\r
193         }\r
194         BOOL IsRecursive()\r
195         {\r
196                 if ((GetTickCount() - REGISTRYTIMEOUT)>recursiveticker)\r
197                 {\r
198                         recursiveticker = GetTickCount();\r
199                         showrecursive.read();\r
200                 }\r
201                 return (showrecursive);\r
202         }\r
203         BOOL IsFolderOverlay()\r
204         {\r
205                 if ((GetTickCount() - REGISTRYTIMEOUT)>folderoverlayticker)\r
206                 {\r
207                         folderoverlayticker = GetTickCount();\r
208                         folderoverlay.read();\r
209                 }\r
210                 return (folderoverlay);\r
211         }\r
212         BOOL IsSimpleContext()\r
213         {\r
214                 if ((GetTickCount() - REGISTRYTIMEOUT)>simplecontextticker)\r
215                 {\r
216                         simplecontextticker = GetTickCount();\r
217                         simplecontext.read();\r
218                 }\r
219                 return (simplecontext!=0);\r
220         }\r
221         BOOL IsUnversionedAsModified()\r
222         {\r
223                 if ((GetTickCount() - REGISTRYTIMEOUT)>unversionedasmodifiedticker)\r
224                 {\r
225                         unversionedasmodifiedticker = GetTickCount();\r
226                         unversionedasmodified.read();\r
227                 }\r
228                 return (unversionedasmodified);\r
229         }\r
230         BOOL ShowUnversionedOverlay()\r
231         {\r
232                 if ((GetTickCount() - REGISTRYTIMEOUT)>showunversionedoverlayticker)\r
233                 {\r
234                         showunversionedoverlayticker = GetTickCount();\r
235                         showunversionedoverlay.read();\r
236                 }\r
237                 return (showunversionedoverlay);\r
238         }\r
239         BOOL ShowIgnoredOverlay()\r
240         {\r
241                 if ((GetTickCount() - REGISTRYTIMEOUT)>showignoredoverlayticker)\r
242                 {\r
243                         showignoredoverlayticker = GetTickCount();\r
244                         showignoredoverlay.read();\r
245                 }\r
246                 return (showignoredoverlay);\r
247         }\r
248         BOOL IsGetLockTop()\r
249         {\r
250                 if ((GetTickCount() - REGISTRYTIMEOUT)>getlocktopticker)\r
251                 {\r
252                         getlocktopticker = GetTickCount();\r
253                         getlocktop.read();\r
254                 }\r
255                 return (getlocktop);\r
256         }\r
257         BOOL ShowExcludedAsNormal()\r
258         {\r
259                 if ((GetTickCount() - REGISTRYTIMEOUT)>excludedasnormalticker)\r
260                 {\r
261                         excludedasnormalticker = GetTickCount();\r
262                         excludedasnormal.read();\r
263                 }\r
264                 return (excludedasnormal);\r
265         }\r
266         BOOL IsRemote()\r
267         {\r
268                 DriveValid();\r
269                 return (driveremote);\r
270         }\r
271         BOOL IsFixed()\r
272         {\r
273                 DriveValid();\r
274                 return (drivefixed);\r
275         }\r
276         BOOL IsCDRom()\r
277         {\r
278                 DriveValid();\r
279                 return (drivecdrom);\r
280         }\r
281         BOOL IsRemovable()\r
282         {\r
283                 DriveValid();\r
284                 return (driveremove);\r
285         }\r
286         BOOL IsRAM()\r
287         {\r
288                 DriveValid();\r
289                 return (driveram);\r
290         }\r
291         BOOL IsUnknown()\r
292         {\r
293                 DriveValid();\r
294                 return (driveunknown);\r
295         }\r
296         BOOL IsContextPathAllowed(LPCTSTR path)\r
297         {\r
298                 Locker lock(m_critSec);\r
299                 ExcludeContextValid();\r
300                 for (std::vector<stdstring>::iterator I = excontextvector.begin(); I != excontextvector.end(); ++I)\r
301                 {\r
302                         if (I->empty())\r
303                                 continue;\r
304                         if (I->size() && I->at(I->size()-1)=='*')\r
305                         {\r
306                                 stdstring str = I->substr(0, I->size()-1);\r
307                                 if (_tcsnicmp(str.c_str(), path, str.size())==0)\r
308                                         return FALSE;\r
309                         }\r
310                         else if (_tcsicmp(I->c_str(), path)==0)\r
311                                 return FALSE;\r
312                 }\r
313                 return TRUE;\r
314         }\r
315         BOOL IsPathAllowed(LPCTSTR path)\r
316         {\r
317                 Locker lock(m_critSec);\r
318                 IncludeListValid();\r
319                 for (std::vector<stdstring>::iterator I = invector.begin(); I != invector.end(); ++I)\r
320                 {\r
321                         if (I->empty())\r
322                                 continue;\r
323                         if (I->at(I->size()-1)=='*')\r
324                         {\r
325                                 stdstring str = I->substr(0, I->size()-1);\r
326                                 if (_tcsnicmp(str.c_str(), path, str.size())==0)\r
327                                         return TRUE;\r
328                                 if (str.size() && (str.at(str.size()-1) == '\\') && (_tcsnicmp(str.c_str(), path, str.size()-1)==0))\r
329                                         return TRUE;\r
330                         }\r
331                         else if (_tcsicmp(I->c_str(), path)==0)\r
332                                 return TRUE;\r
333                         else if ((I->at(I->size()-1) == '\\') && \r
334                                 ((_tcsnicmp(I->c_str(), path, I->size())==0) || (_tcsicmp(I->c_str(), path)==0)) )\r
335                                 return TRUE;\r
336 \r
337                 }\r
338                 UINT drivetype = 0;\r
339                 int drivenumber = PathGetDriveNumber(path);\r
340                 if ((drivenumber >=0)&&(drivenumber < 25))\r
341                 {\r
342                         drivetype = drivetypecache[drivenumber];\r
343                         if ((drivetype == -1)||((GetTickCount() - DRIVETYPETIMEOUT)>drivetypeticker))\r
344                         {\r
345                                 if ((drivenumber == 0)||(drivenumber == 1))\r
346                                         drivetypecache[drivenumber] = DRIVE_REMOVABLE;\r
347                                 else\r
348                                 {\r
349                                         drivetypeticker = GetTickCount();\r
350                                         TCHAR pathbuf[MAX_PATH+4];              // MAX_PATH ok here. PathStripToRoot works with partial paths too.\r
351                                         _tcsncpy_s(pathbuf, MAX_PATH+4, path, MAX_PATH+3);\r
352                                         PathStripToRoot(pathbuf);\r
353                                         PathAddBackslash(pathbuf);\r
354                                         ATLTRACE2(_T("GetDriveType for %s, Drive %d\n"), pathbuf, drivenumber);\r
355                                         drivetype = GetDriveType(pathbuf);\r
356                                         drivetypecache[drivenumber] = drivetype;\r
357                                 }\r
358                         }\r
359                 }\r
360                 else\r
361                 {\r
362                         TCHAR pathbuf[MAX_PATH+4];              // MAX_PATH ok here. PathIsUNCServer works with partial paths too.\r
363                         _tcsncpy_s(pathbuf, MAX_PATH+4, path, MAX_PATH+3);\r
364                         if (PathIsUNCServer(pathbuf))\r
365                                 drivetype = DRIVE_REMOTE;\r
366                         else\r
367                         {\r
368                                 PathStripToRoot(pathbuf);\r
369                                 PathAddBackslash(pathbuf);\r
370                                 if (_tcsncmp(pathbuf, drivetypepathcache, MAX_PATH-1)==0)               // MAX_PATH ok.\r
371                                         drivetype = drivetypecache[26];\r
372                                 else\r
373                                 {\r
374                                         ATLTRACE2(_T("GetDriveType for %s\n"), pathbuf);\r
375                                         drivetype = GetDriveType(pathbuf);\r
376                                         drivetypecache[26] = drivetype;\r
377                                         _tcsncpy_s(drivetypepathcache, MAX_PATH, pathbuf, MAX_PATH);                    // MAX_PATH ok.\r
378                                 } \r
379                         }\r
380                 }\r
381                 if ((drivetype == DRIVE_REMOVABLE)&&(!IsRemovable()))\r
382                         return FALSE;\r
383                 if ((drivetype == DRIVE_REMOVABLE)&&(drivefloppy == 0)&&((drivenumber==0)||(drivenumber==1)))\r
384                         return FALSE;\r
385                 if ((drivetype == DRIVE_FIXED)&&(!IsFixed()))\r
386                         return FALSE;\r
387                 if (((drivetype == DRIVE_REMOTE)||(drivetype == DRIVE_NO_ROOT_DIR))&&(!IsRemote()))\r
388                         return FALSE;\r
389                 if ((drivetype == DRIVE_CDROM)&&(!IsCDRom()))\r
390                         return FALSE;\r
391                 if ((drivetype == DRIVE_RAMDISK)&&(!IsRAM()))\r
392                         return FALSE;\r
393                 if ((drivetype == DRIVE_UNKNOWN)&&(IsUnknown()))\r
394                         return FALSE;\r
395 \r
396                 ExcludeListValid();\r
397                 for (std::vector<stdstring>::iterator I = exvector.begin(); I != exvector.end(); ++I)\r
398                 {\r
399                         if (I->empty())\r
400                                 continue;\r
401                         if (I->size() && I->at(I->size()-1)=='*')\r
402                         {\r
403                                 stdstring str = I->substr(0, I->size()-1);\r
404                                 if (_tcsnicmp(str.c_str(), path, str.size())==0)\r
405                                         return FALSE;\r
406                         }\r
407                         else if (_tcsicmp(I->c_str(), path)==0)\r
408                                 return FALSE;\r
409                 }\r
410                 return TRUE;\r
411         }\r
412         DWORD GetLangID()\r
413         {\r
414                 if ((GetTickCount() - REGISTRYTIMEOUT) > langticker)\r
415                 {\r
416                         langticker = GetTickCount();\r
417                         langid.read();\r
418                 }\r
419                 return (langid);\r
420         }\r
421         NUMBERFMT * GetNumberFmt()\r
422         {\r
423                 if ((GetTickCount() - NUMBERFMTTIMEOUT) > columnrevformatticker)\r
424                 {\r
425                         TCHAR szBuffer[5];\r
426                         columnrevformatticker = GetTickCount();\r
427                         SecureZeroMemory(&columnrevformat, sizeof(NUMBERFMT));\r
428                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, &szDecSep[0], sizeof(szDecSep));\r
429                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, &szThousandsSep[0], sizeof(szThousandsSep));\r
430                         columnrevformat.lpDecimalSep = szDecSep;\r
431                         columnrevformat.lpThousandSep = szThousandsSep;\r
432                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, &szBuffer[0], sizeof(szBuffer));\r
433                         columnrevformat.Grouping = _ttoi(szBuffer);\r
434                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER, &szBuffer[0], sizeof(szBuffer));\r
435                         columnrevformat.NegativeOrder = _ttoi(szBuffer);\r
436                 }\r
437                 return &columnrevformat;\r
438         }\r
439         BOOL HasSVNAdminDir(LPCTSTR path, BOOL bIsDir, CString *ProjectTopDir = NULL)\r
440         {\r
441                 size_t len = _tcslen(path);\r
442                 TCHAR * buf = new TCHAR[len+1];\r
443                 _tcscpy_s(buf, len+1, path);\r
444                 if (! bIsDir)\r
445                 {\r
446                         TCHAR * ptr = _tcsrchr(buf, '\\');\r
447                         if (ptr != 0)\r
448                         {\r
449                                 *ptr = 0;\r
450                         }\r
451                 }\r
452                 if ((GetTickCount() - ADMINDIRTIMEOUT) < admindirticker)\r
453                 {\r
454                         std::map<stdstring, AdminDir_s>::iterator iter;\r
455                         sAdminDirCacheKey.assign(buf);\r
456                         if ((iter = admindircache.find(sAdminDirCacheKey)) != admindircache.end())\r
457                         {\r
458                                 delete [] buf;\r
459                                 if (ProjectTopDir && iter->second.bHasAdminDir)\r
460                                         *ProjectTopDir = iter->second.sProjectRoot.c_str();\r
461                                 return iter->second.bHasAdminDir;\r
462                         }\r
463                 }\r
464                 CString sProjectRoot;\r
465                 BOOL hasAdminDir = g_GitAdminDir.HasAdminDir(buf, true, &sProjectRoot);\r
466                 admindirticker = GetTickCount();\r
467                 Locker lock(m_critSec);\r
468 \r
469                 AdminDir_s &ad = admindircache[buf];\r
470                 ad.bHasAdminDir = hasAdminDir;\r
471                 if (hasAdminDir)\r
472                 {\r
473                         ad.sProjectRoot.assign(sProjectRoot);\r
474 \r
475                         if (ProjectTopDir)\r
476                                 *ProjectTopDir = sProjectRoot;\r
477                 }\r
478 \r
479                 delete [] buf;\r
480                 return hasAdminDir;\r
481         }\r
482         bool IsColumnsEveryWhere()\r
483         {\r
484                 if ((GetTickCount() - REGISTRYTIMEOUT) > columnseverywhereticker)\r
485                 {\r
486                         columnseverywhereticker = GetTickCount();\r
487                         columnseverywhere.read();\r
488                 } \r
489                 return !!(DWORD)columnseverywhere;\r
490         }\r
491 private:\r
492         void DriveValid()\r
493         {\r
494                 if ((GetTickCount() - REGISTRYTIMEOUT)>driveticker)\r
495                 {\r
496                         driveticker = GetTickCount();\r
497                         driveremote.read();\r
498                         drivefixed.read();\r
499                         drivecdrom.read();\r
500                         driveremove.read();\r
501                         drivefloppy.read();\r
502                 }\r
503         }\r
504         void ExcludeContextValid()\r
505         {\r
506                 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>excontextticker)\r
507                 {\r
508                         Locker lock(m_critSec);\r
509                         excontextticker = GetTickCount();\r
510                         nocontextpaths.read();\r
511                         if (excludecontextstr.compare((stdstring)nocontextpaths)==0)\r
512                                 return;\r
513                         excludecontextstr = (stdstring)nocontextpaths;\r
514                         excontextvector.clear();\r
515                         size_t pos = 0, pos_ant = 0;\r
516                         pos = excludecontextstr.find(_T("\n"), pos_ant);\r
517                         while (pos != stdstring::npos)\r
518                         {\r
519                                 stdstring token = excludecontextstr.substr(pos_ant, pos-pos_ant);\r
520                                 excontextvector.push_back(token);\r
521                                 pos_ant = pos+1;\r
522                                 pos = excludecontextstr.find(_T("\n"), pos_ant);\r
523                         }\r
524                         if (!excludecontextstr.empty())\r
525                         {\r
526                                 excontextvector.push_back(excludecontextstr.substr(pos_ant, excludecontextstr.size()-1));\r
527                         }\r
528                         excludecontextstr = (stdstring)nocontextpaths;\r
529                 }\r
530         }\r
531         void ExcludeListValid()\r
532         {\r
533                 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>excludelistticker)\r
534                 {\r
535                         Locker lock(m_critSec);\r
536                         excludelistticker = GetTickCount();\r
537                         excludelist.read();\r
538                         if (excludeliststr.compare((stdstring)excludelist)==0)\r
539                                 return;\r
540                         excludeliststr = (stdstring)excludelist;\r
541                         exvector.clear();\r
542                         size_t pos = 0, pos_ant = 0;\r
543                         pos = excludeliststr.find(_T("\n"), pos_ant);\r
544                         while (pos != stdstring::npos)\r
545                         {\r
546                                 stdstring token = excludeliststr.substr(pos_ant, pos-pos_ant);\r
547                                 exvector.push_back(token);\r
548                                 pos_ant = pos+1;\r
549                                 pos = excludeliststr.find(_T("\n"), pos_ant);\r
550                         }\r
551                         if (!excludeliststr.empty())\r
552                         {\r
553                                 exvector.push_back(excludeliststr.substr(pos_ant, excludeliststr.size()-1));\r
554                         }\r
555                         excludeliststr = (stdstring)excludelist;\r
556                 }\r
557         }\r
558         void IncludeListValid()\r
559         {\r
560                 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>includelistticker)\r
561                 {\r
562                         Locker lock(m_critSec);\r
563                         includelistticker = GetTickCount();\r
564                         includelist.read();\r
565                         if (includeliststr.compare((stdstring)includelist)==0)\r
566                                 return;\r
567                         includeliststr = (stdstring)includelist;\r
568                         invector.clear();\r
569                         size_t pos = 0, pos_ant = 0;\r
570                         pos = includeliststr.find(_T("\n"), pos_ant);\r
571                         while (pos != stdstring::npos)\r
572                         {\r
573                                 stdstring token = includeliststr.substr(pos_ant, pos-pos_ant);\r
574                                 invector.push_back(token);\r
575                                 pos_ant = pos+1;\r
576                                 pos = includeliststr.find(_T("\n"), pos_ant);\r
577                         }\r
578                         if (!includeliststr.empty())\r
579                         {\r
580                                 invector.push_back(includeliststr.substr(pos_ant, includeliststr.size()-1));\r
581                         }\r
582                         includeliststr = (stdstring)includelist;\r
583                 }\r
584         }\r
585 \r
586         struct AdminDir_s\r
587         {\r
588                 BOOL bHasAdminDir;\r
589                 stdstring sProjectRoot;\r
590         };\r
591 \r
592         CRegStdWORD cachetype;\r
593         CRegStdWORD blockstatus;\r
594         CRegStdWORD langid;\r
595         CRegStdWORD showrecursive;\r
596         CRegStdWORD folderoverlay;\r
597         CRegStdWORD getlocktop;\r
598         CRegStdWORD driveremote;\r
599         CRegStdWORD drivefixed;\r
600         CRegStdWORD drivecdrom;\r
601         CRegStdWORD driveremove;\r
602         CRegStdWORD drivefloppy;\r
603         CRegStdWORD driveram;\r
604         CRegStdWORD driveunknown;\r
605         CRegStdWORD menulayoutlow;\r
606         CRegStdWORD menulayouthigh;\r
607         CRegStdWORD simplecontext;\r
608         CRegStdWORD menumasklow_lm;\r
609         CRegStdWORD menumaskhigh_lm;\r
610         CRegStdWORD menumasklow_cu;\r
611         CRegStdWORD menumaskhigh_cu;\r
612         CRegStdWORD unversionedasmodified;\r
613         CRegStdWORD showunversionedoverlay;\r
614         CRegStdWORD showignoredoverlay;\r
615         CRegStdWORD excludedasnormal;\r
616         CRegStdString excludelist;\r
617         CRegStdWORD columnseverywhere;\r
618         stdstring excludeliststr;\r
619         std::vector<stdstring> exvector;\r
620         CRegStdString includelist;\r
621         stdstring includeliststr;\r
622         std::vector<stdstring> invector;\r
623         DWORD cachetypeticker;\r
624         DWORD recursiveticker;\r
625         DWORD folderoverlayticker;\r
626         DWORD getlocktopticker;\r
627         DWORD driveticker;\r
628         DWORD drivetypeticker;\r
629         DWORD layoutticker;\r
630         DWORD menumaskticker;\r
631         DWORD langticker;\r
632         DWORD blockstatusticker;\r
633         DWORD columnrevformatticker;\r
634         DWORD excludelistticker;\r
635         DWORD includelistticker;\r
636         DWORD simplecontextticker;\r
637         DWORD unversionedasmodifiedticker;\r
638         DWORD showunversionedoverlayticker;\r
639         DWORD showignoredoverlayticker;\r
640         DWORD excludedasnormalticker;\r
641         DWORD columnseverywhereticker;\r
642         UINT  drivetypecache[27];\r
643         TCHAR drivetypepathcache[MAX_PATH];             // MAX_PATH ok.\r
644         NUMBERFMT columnrevformat;\r
645         TCHAR szDecSep[5];\r
646         TCHAR szThousandsSep[5];\r
647         std::map<stdstring, AdminDir_s> admindircache;\r
648         stdstring sAdminDirCacheKey;\r
649         CRegStdString nocontextpaths;\r
650         stdstring excludecontextstr;\r
651         std::vector<stdstring> excontextvector;\r
652         DWORD excontextticker;\r
653         DWORD admindirticker;\r
654         CComCriticalSection m_critSec;\r
655 };\r