OSDN Git Service

Add Setting Dialog
[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                 if ((GetTickCount() - REGISTRYTIMEOUT) > cachetypeticker)\r
150                 {\r
151                         cachetypeticker = GetTickCount();\r
152                         cachetype.read();\r
153                 }\r
154                 return CacheType(DWORD((cachetype)));\r
155         }\r
156         DWORD BlockStatus()\r
157         {\r
158                 if ((GetTickCount() - REGISTRYTIMEOUT) > blockstatusticker)\r
159                 {\r
160                         blockstatusticker = GetTickCount();\r
161                         blockstatus.read();\r
162                 }\r
163                 return (blockstatus);\r
164         }\r
165         unsigned __int64 GetMenuLayout()\r
166         {\r
167                 if ((GetTickCount() - REGISTRYTIMEOUT) > layoutticker)\r
168                 {\r
169                         layoutticker = GetTickCount();\r
170                         menulayoutlow.read();\r
171                         menulayouthigh.read();\r
172                 }\r
173                 unsigned __int64 temp = unsigned __int64(DWORD(menulayouthigh))<<32;\r
174                 temp |= unsigned __int64(DWORD(menulayoutlow));\r
175                 return temp;\r
176         }\r
177         unsigned __int64 GetMenuMask()\r
178         {\r
179                 if ((GetTickCount() - REGISTRYTIMEOUT) > menumaskticker)\r
180                 {\r
181                         menumaskticker = GetTickCount();\r
182                         menumasklow_lm.read();\r
183                         menumaskhigh_lm.read();\r
184                         menumasklow_cu.read();\r
185                         menumaskhigh_cu.read();\r
186                 }\r
187                 DWORD low = (DWORD)menumasklow_lm | (DWORD)menumasklow_cu;\r
188                 DWORD high = (DWORD)menumaskhigh_lm | (DWORD)menumaskhigh_cu;\r
189                 unsigned __int64 temp = unsigned __int64(high)<<32;\r
190                 temp |= unsigned __int64(low);\r
191                 return temp;\r
192         }\r
193         BOOL IsRecursive()\r
194         {\r
195                 if ((GetTickCount() - REGISTRYTIMEOUT)>recursiveticker)\r
196                 {\r
197                         recursiveticker = GetTickCount();\r
198                         showrecursive.read();\r
199                 }\r
200                 return (showrecursive);\r
201         }\r
202         BOOL IsFolderOverlay()\r
203         {\r
204                 if ((GetTickCount() - REGISTRYTIMEOUT)>folderoverlayticker)\r
205                 {\r
206                         folderoverlayticker = GetTickCount();\r
207                         folderoverlay.read();\r
208                 }\r
209                 return (folderoverlay);\r
210         }\r
211         BOOL IsSimpleContext()\r
212         {\r
213                 if ((GetTickCount() - REGISTRYTIMEOUT)>simplecontextticker)\r
214                 {\r
215                         simplecontextticker = GetTickCount();\r
216                         simplecontext.read();\r
217                 }\r
218                 return (simplecontext!=0);\r
219         }\r
220         BOOL IsUnversionedAsModified()\r
221         {\r
222                 if ((GetTickCount() - REGISTRYTIMEOUT)>unversionedasmodifiedticker)\r
223                 {\r
224                         unversionedasmodifiedticker = GetTickCount();\r
225                         unversionedasmodified.read();\r
226                 }\r
227                 return (unversionedasmodified);\r
228         }\r
229         BOOL ShowUnversionedOverlay()\r
230         {\r
231                 if ((GetTickCount() - REGISTRYTIMEOUT)>showunversionedoverlayticker)\r
232                 {\r
233                         showunversionedoverlayticker = GetTickCount();\r
234                         showunversionedoverlay.read();\r
235                 }\r
236                 return (showunversionedoverlay);\r
237         }\r
238         BOOL ShowIgnoredOverlay()\r
239         {\r
240                 if ((GetTickCount() - REGISTRYTIMEOUT)>showignoredoverlayticker)\r
241                 {\r
242                         showignoredoverlayticker = GetTickCount();\r
243                         showignoredoverlay.read();\r
244                 }\r
245                 return (showignoredoverlay);\r
246         }\r
247         BOOL IsGetLockTop()\r
248         {\r
249                 if ((GetTickCount() - REGISTRYTIMEOUT)>getlocktopticker)\r
250                 {\r
251                         getlocktopticker = GetTickCount();\r
252                         getlocktop.read();\r
253                 }\r
254                 return (getlocktop);\r
255         }\r
256         BOOL ShowExcludedAsNormal()\r
257         {\r
258                 if ((GetTickCount() - REGISTRYTIMEOUT)>excludedasnormalticker)\r
259                 {\r
260                         excludedasnormalticker = GetTickCount();\r
261                         excludedasnormal.read();\r
262                 }\r
263                 return (excludedasnormal);\r
264         }\r
265         BOOL IsRemote()\r
266         {\r
267                 DriveValid();\r
268                 return (driveremote);\r
269         }\r
270         BOOL IsFixed()\r
271         {\r
272                 DriveValid();\r
273                 return (drivefixed);\r
274         }\r
275         BOOL IsCDRom()\r
276         {\r
277                 DriveValid();\r
278                 return (drivecdrom);\r
279         }\r
280         BOOL IsRemovable()\r
281         {\r
282                 DriveValid();\r
283                 return (driveremove);\r
284         }\r
285         BOOL IsRAM()\r
286         {\r
287                 DriveValid();\r
288                 return (driveram);\r
289         }\r
290         BOOL IsUnknown()\r
291         {\r
292                 DriveValid();\r
293                 return (driveunknown);\r
294         }\r
295         BOOL IsContextPathAllowed(LPCTSTR path)\r
296         {\r
297                 Locker lock(m_critSec);\r
298                 ExcludeContextValid();\r
299                 for (std::vector<stdstring>::iterator I = excontextvector.begin(); I != excontextvector.end(); ++I)\r
300                 {\r
301                         if (I->empty())\r
302                                 continue;\r
303                         if (I->size() && I->at(I->size()-1)=='*')\r
304                         {\r
305                                 stdstring str = I->substr(0, I->size()-1);\r
306                                 if (_tcsnicmp(str.c_str(), path, str.size())==0)\r
307                                         return FALSE;\r
308                         }\r
309                         else if (_tcsicmp(I->c_str(), path)==0)\r
310                                 return FALSE;\r
311                 }\r
312                 return TRUE;\r
313         }\r
314         BOOL IsPathAllowed(LPCTSTR path)\r
315         {\r
316                 Locker lock(m_critSec);\r
317                 IncludeListValid();\r
318                 for (std::vector<stdstring>::iterator I = invector.begin(); I != invector.end(); ++I)\r
319                 {\r
320                         if (I->empty())\r
321                                 continue;\r
322                         if (I->at(I->size()-1)=='*')\r
323                         {\r
324                                 stdstring str = I->substr(0, I->size()-1);\r
325                                 if (_tcsnicmp(str.c_str(), path, str.size())==0)\r
326                                         return TRUE;\r
327                                 if (str.size() && (str.at(str.size()-1) == '\\') && (_tcsnicmp(str.c_str(), path, str.size()-1)==0))\r
328                                         return TRUE;\r
329                         }\r
330                         else if (_tcsicmp(I->c_str(), path)==0)\r
331                                 return TRUE;\r
332                         else if ((I->at(I->size()-1) == '\\') && \r
333                                 ((_tcsnicmp(I->c_str(), path, I->size())==0) || (_tcsicmp(I->c_str(), path)==0)) )\r
334                                 return TRUE;\r
335 \r
336                 }\r
337                 UINT drivetype = 0;\r
338                 int drivenumber = PathGetDriveNumber(path);\r
339                 if ((drivenumber >=0)&&(drivenumber < 25))\r
340                 {\r
341                         drivetype = drivetypecache[drivenumber];\r
342                         if ((drivetype == -1)||((GetTickCount() - DRIVETYPETIMEOUT)>drivetypeticker))\r
343                         {\r
344                                 if ((drivenumber == 0)||(drivenumber == 1))\r
345                                         drivetypecache[drivenumber] = DRIVE_REMOVABLE;\r
346                                 else\r
347                                 {\r
348                                         drivetypeticker = GetTickCount();\r
349                                         TCHAR pathbuf[MAX_PATH+4];              // MAX_PATH ok here. PathStripToRoot works with partial paths too.\r
350                                         _tcsncpy_s(pathbuf, MAX_PATH+4, path, MAX_PATH+3);\r
351                                         PathStripToRoot(pathbuf);\r
352                                         PathAddBackslash(pathbuf);\r
353                                         ATLTRACE2(_T("GetDriveType for %s, Drive %d\n"), pathbuf, drivenumber);\r
354                                         drivetype = GetDriveType(pathbuf);\r
355                                         drivetypecache[drivenumber] = drivetype;\r
356                                 }\r
357                         }\r
358                 }\r
359                 else\r
360                 {\r
361                         TCHAR pathbuf[MAX_PATH+4];              // MAX_PATH ok here. PathIsUNCServer works with partial paths too.\r
362                         _tcsncpy_s(pathbuf, MAX_PATH+4, path, MAX_PATH+3);\r
363                         if (PathIsUNCServer(pathbuf))\r
364                                 drivetype = DRIVE_REMOTE;\r
365                         else\r
366                         {\r
367                                 PathStripToRoot(pathbuf);\r
368                                 PathAddBackslash(pathbuf);\r
369                                 if (_tcsncmp(pathbuf, drivetypepathcache, MAX_PATH-1)==0)               // MAX_PATH ok.\r
370                                         drivetype = drivetypecache[26];\r
371                                 else\r
372                                 {\r
373                                         ATLTRACE2(_T("GetDriveType for %s\n"), pathbuf);\r
374                                         drivetype = GetDriveType(pathbuf);\r
375                                         drivetypecache[26] = drivetype;\r
376                                         _tcsncpy_s(drivetypepathcache, MAX_PATH, pathbuf, MAX_PATH);                    // MAX_PATH ok.\r
377                                 } \r
378                         }\r
379                 }\r
380                 if ((drivetype == DRIVE_REMOVABLE)&&(!IsRemovable()))\r
381                         return FALSE;\r
382                 if ((drivetype == DRIVE_REMOVABLE)&&(drivefloppy == 0)&&((drivenumber==0)||(drivenumber==1)))\r
383                         return FALSE;\r
384                 if ((drivetype == DRIVE_FIXED)&&(!IsFixed()))\r
385                         return FALSE;\r
386                 if (((drivetype == DRIVE_REMOTE)||(drivetype == DRIVE_NO_ROOT_DIR))&&(!IsRemote()))\r
387                         return FALSE;\r
388                 if ((drivetype == DRIVE_CDROM)&&(!IsCDRom()))\r
389                         return FALSE;\r
390                 if ((drivetype == DRIVE_RAMDISK)&&(!IsRAM()))\r
391                         return FALSE;\r
392                 if ((drivetype == DRIVE_UNKNOWN)&&(IsUnknown()))\r
393                         return FALSE;\r
394 \r
395                 ExcludeListValid();\r
396                 for (std::vector<stdstring>::iterator I = exvector.begin(); I != exvector.end(); ++I)\r
397                 {\r
398                         if (I->empty())\r
399                                 continue;\r
400                         if (I->size() && I->at(I->size()-1)=='*')\r
401                         {\r
402                                 stdstring str = I->substr(0, I->size()-1);\r
403                                 if (_tcsnicmp(str.c_str(), path, str.size())==0)\r
404                                         return FALSE;\r
405                         }\r
406                         else if (_tcsicmp(I->c_str(), path)==0)\r
407                                 return FALSE;\r
408                 }\r
409                 return TRUE;\r
410         }\r
411         DWORD GetLangID()\r
412         {\r
413                 if ((GetTickCount() - REGISTRYTIMEOUT) > langticker)\r
414                 {\r
415                         langticker = GetTickCount();\r
416                         langid.read();\r
417                 }\r
418                 return (langid);\r
419         }\r
420         NUMBERFMT * GetNumberFmt()\r
421         {\r
422                 if ((GetTickCount() - NUMBERFMTTIMEOUT) > columnrevformatticker)\r
423                 {\r
424                         TCHAR szBuffer[5];\r
425                         columnrevformatticker = GetTickCount();\r
426                         SecureZeroMemory(&columnrevformat, sizeof(NUMBERFMT));\r
427                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, &szDecSep[0], sizeof(szDecSep));\r
428                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, &szThousandsSep[0], sizeof(szThousandsSep));\r
429                         columnrevformat.lpDecimalSep = szDecSep;\r
430                         columnrevformat.lpThousandSep = szThousandsSep;\r
431                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, &szBuffer[0], sizeof(szBuffer));\r
432                         columnrevformat.Grouping = _ttoi(szBuffer);\r
433                         GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER, &szBuffer[0], sizeof(szBuffer));\r
434                         columnrevformat.NegativeOrder = _ttoi(szBuffer);\r
435                 }\r
436                 return &columnrevformat;\r
437         }\r
438         BOOL HasSVNAdminDir(LPCTSTR path, BOOL bIsDir)\r
439         {\r
440                 size_t len = _tcslen(path);\r
441                 TCHAR * buf = new TCHAR[len+1];\r
442                 _tcscpy_s(buf, len+1, path);\r
443                 if (! bIsDir)\r
444                 {\r
445                         TCHAR * ptr = _tcsrchr(buf, '\\');\r
446                         if (ptr != 0)\r
447                         {\r
448                                 *ptr = 0;\r
449                         }\r
450                 }\r
451                 if ((GetTickCount() - ADMINDIRTIMEOUT) < admindirticker)\r
452                 {\r
453                         std::map<stdstring, BOOL>::iterator iter;\r
454                         sAdminDirCacheKey.assign(buf);\r
455                         if ((iter = admindircache.find(sAdminDirCacheKey)) != admindircache.end())\r
456                         {\r
457                                 delete [] buf;\r
458                                 return iter->second;\r
459                         }\r
460                 }\r
461                 BOOL hasAdminDir = g_GitAdminDir.HasAdminDir(buf, true);\r
462                 admindirticker = GetTickCount();\r
463                 Locker lock(m_critSec);\r
464                 admindircache[buf] = hasAdminDir;\r
465                 delete [] buf;\r
466                 return hasAdminDir;\r
467         }\r
468         bool IsColumnsEveryWhere()\r
469         {\r
470                 if ((GetTickCount() - REGISTRYTIMEOUT) > columnseverywhereticker)\r
471                 {\r
472                         columnseverywhereticker = GetTickCount();\r
473                         columnseverywhere.read();\r
474                 } \r
475                 return !!(DWORD)columnseverywhere;\r
476         }\r
477 private:\r
478         void DriveValid()\r
479         {\r
480                 if ((GetTickCount() - REGISTRYTIMEOUT)>driveticker)\r
481                 {\r
482                         driveticker = GetTickCount();\r
483                         driveremote.read();\r
484                         drivefixed.read();\r
485                         drivecdrom.read();\r
486                         driveremove.read();\r
487                         drivefloppy.read();\r
488                 }\r
489         }\r
490         void ExcludeContextValid()\r
491         {\r
492                 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>excontextticker)\r
493                 {\r
494                         Locker lock(m_critSec);\r
495                         excontextticker = GetTickCount();\r
496                         nocontextpaths.read();\r
497                         if (excludecontextstr.compare((stdstring)nocontextpaths)==0)\r
498                                 return;\r
499                         excludecontextstr = (stdstring)nocontextpaths;\r
500                         excontextvector.clear();\r
501                         size_t pos = 0, pos_ant = 0;\r
502                         pos = excludecontextstr.find(_T("\n"), pos_ant);\r
503                         while (pos != stdstring::npos)\r
504                         {\r
505                                 stdstring token = excludecontextstr.substr(pos_ant, pos-pos_ant);\r
506                                 excontextvector.push_back(token);\r
507                                 pos_ant = pos+1;\r
508                                 pos = excludecontextstr.find(_T("\n"), pos_ant);\r
509                         }\r
510                         if (!excludecontextstr.empty())\r
511                         {\r
512                                 excontextvector.push_back(excludecontextstr.substr(pos_ant, excludecontextstr.size()-1));\r
513                         }\r
514                         excludecontextstr = (stdstring)nocontextpaths;\r
515                 }\r
516         }\r
517         void ExcludeListValid()\r
518         {\r
519                 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>excludelistticker)\r
520                 {\r
521                         Locker lock(m_critSec);\r
522                         excludelistticker = GetTickCount();\r
523                         excludelist.read();\r
524                         if (excludeliststr.compare((stdstring)excludelist)==0)\r
525                                 return;\r
526                         excludeliststr = (stdstring)excludelist;\r
527                         exvector.clear();\r
528                         size_t pos = 0, pos_ant = 0;\r
529                         pos = excludeliststr.find(_T("\n"), pos_ant);\r
530                         while (pos != stdstring::npos)\r
531                         {\r
532                                 stdstring token = excludeliststr.substr(pos_ant, pos-pos_ant);\r
533                                 exvector.push_back(token);\r
534                                 pos_ant = pos+1;\r
535                                 pos = excludeliststr.find(_T("\n"), pos_ant);\r
536                         }\r
537                         if (!excludeliststr.empty())\r
538                         {\r
539                                 exvector.push_back(excludeliststr.substr(pos_ant, excludeliststr.size()-1));\r
540                         }\r
541                         excludeliststr = (stdstring)excludelist;\r
542                 }\r
543         }\r
544         void IncludeListValid()\r
545         {\r
546                 if ((GetTickCount() - EXCLUDELISTTIMEOUT)>includelistticker)\r
547                 {\r
548                         Locker lock(m_critSec);\r
549                         includelistticker = GetTickCount();\r
550                         includelist.read();\r
551                         if (includeliststr.compare((stdstring)includelist)==0)\r
552                                 return;\r
553                         includeliststr = (stdstring)includelist;\r
554                         invector.clear();\r
555                         size_t pos = 0, pos_ant = 0;\r
556                         pos = includeliststr.find(_T("\n"), pos_ant);\r
557                         while (pos != stdstring::npos)\r
558                         {\r
559                                 stdstring token = includeliststr.substr(pos_ant, pos-pos_ant);\r
560                                 invector.push_back(token);\r
561                                 pos_ant = pos+1;\r
562                                 pos = includeliststr.find(_T("\n"), pos_ant);\r
563                         }\r
564                         if (!includeliststr.empty())\r
565                         {\r
566                                 invector.push_back(includeliststr.substr(pos_ant, includeliststr.size()-1));\r
567                         }\r
568                         includeliststr = (stdstring)includelist;\r
569                 }\r
570         }\r
571         CRegStdWORD cachetype;\r
572         CRegStdWORD blockstatus;\r
573         CRegStdWORD langid;\r
574         CRegStdWORD showrecursive;\r
575         CRegStdWORD folderoverlay;\r
576         CRegStdWORD getlocktop;\r
577         CRegStdWORD driveremote;\r
578         CRegStdWORD drivefixed;\r
579         CRegStdWORD drivecdrom;\r
580         CRegStdWORD driveremove;\r
581         CRegStdWORD drivefloppy;\r
582         CRegStdWORD driveram;\r
583         CRegStdWORD driveunknown;\r
584         CRegStdWORD menulayoutlow;\r
585         CRegStdWORD menulayouthigh;\r
586         CRegStdWORD simplecontext;\r
587         CRegStdWORD menumasklow_lm;\r
588         CRegStdWORD menumaskhigh_lm;\r
589         CRegStdWORD menumasklow_cu;\r
590         CRegStdWORD menumaskhigh_cu;\r
591         CRegStdWORD unversionedasmodified;\r
592         CRegStdWORD showunversionedoverlay;\r
593         CRegStdWORD showignoredoverlay;\r
594         CRegStdWORD excludedasnormal;\r
595         CRegStdString excludelist;\r
596         CRegStdWORD columnseverywhere;\r
597         stdstring excludeliststr;\r
598         std::vector<stdstring> exvector;\r
599         CRegStdString includelist;\r
600         stdstring includeliststr;\r
601         std::vector<stdstring> invector;\r
602         DWORD cachetypeticker;\r
603         DWORD recursiveticker;\r
604         DWORD folderoverlayticker;\r
605         DWORD getlocktopticker;\r
606         DWORD driveticker;\r
607         DWORD drivetypeticker;\r
608         DWORD layoutticker;\r
609         DWORD menumaskticker;\r
610         DWORD langticker;\r
611         DWORD blockstatusticker;\r
612         DWORD columnrevformatticker;\r
613         DWORD excludelistticker;\r
614         DWORD includelistticker;\r
615         DWORD simplecontextticker;\r
616         DWORD unversionedasmodifiedticker;\r
617         DWORD showunversionedoverlayticker;\r
618         DWORD showignoredoverlayticker;\r
619         DWORD excludedasnormalticker;\r
620         DWORD columnseverywhereticker;\r
621         UINT  drivetypecache[27];\r
622         TCHAR drivetypepathcache[MAX_PATH];             // MAX_PATH ok.\r
623         NUMBERFMT columnrevformat;\r
624         TCHAR szDecSep[5];\r
625         TCHAR szThousandsSep[5];\r
626         std::map<stdstring, BOOL> admindircache;\r
627         stdstring sAdminDirCacheKey;\r
628         CRegStdString nocontextpaths;\r
629         stdstring excludecontextstr;\r
630         std::vector<stdstring> excontextvector;\r
631         DWORD excontextticker;\r
632         DWORD admindirticker;\r
633         CComCriticalSection m_critSec;\r
634 };\r