Configuration.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //---------------------------------------------------------------------------
  2. #ifndef ConfigurationH
  3. #define ConfigurationH
  4. #include <set>
  5. #include "RemoteFiles.h"
  6. #include "FileBuffer.h"
  7. #include "HierarchicalStorage.h"
  8. //---------------------------------------------------------------------------
  9. #define SET_CONFIG_PROPERTY_EX(PROPERTY, APPLY) \
  10. if (PROPERTY != value) { F ## PROPERTY = value; Changed(); APPLY; }
  11. #define SET_CONFIG_PROPERTY(PROPERTY) \
  12. SET_CONFIG_PROPERTY_EX(PROPERTY, )
  13. //---------------------------------------------------------------------------
  14. class TCriticalSection;
  15. enum TAutoSwitch { asOn, asOff, asAuto };
  16. //---------------------------------------------------------------------------
  17. class TConfiguration : public TObject
  18. {
  19. private:
  20. bool FDontSave;
  21. bool FChanged;
  22. int FUpdating;
  23. TNotifyEvent FOnChange;
  24. void * FApplicationInfo;
  25. bool FLogging;
  26. bool FPermanentLogging;
  27. AnsiString FLogFileName;
  28. AnsiString FPermanentLogFileName;
  29. int FLogWindowLines;
  30. bool FLogFileAppend;
  31. int FLogProtocol;
  32. int FActualLogProtocol;
  33. bool FLogActions;
  34. bool FPermanentLogActions;
  35. bool FConfirmOverwriting;
  36. bool FConfirmResume;
  37. bool FAutoReadDirectoryAfterOp;
  38. int FSessionReopenAuto;
  39. int FSessionReopenBackground;
  40. int FSessionReopenTimeout;
  41. AnsiString FIniFileStorageName;
  42. int FTunnelLocalPortNumberLow;
  43. int FTunnelLocalPortNumberHigh;
  44. int FCacheDirectoryChangesMaxSize;
  45. bool FShowFtpWelcomeMessage;
  46. AnsiString FDefaultRandomSeedFile;
  47. AnsiString FRandomSeedFile;
  48. AnsiString FPuttyRegistryStorageKey;
  49. bool FDisablePasswordStoring;
  50. bool FForceBanners;
  51. bool FDisableAcceptingHostKeys;
  52. AnsiString __fastcall GetOSVersionStr();
  53. TVSFixedFileInfo *__fastcall GetFixedApplicationInfo();
  54. void * __fastcall GetApplicationInfo();
  55. virtual AnsiString __fastcall GetVersionStr();
  56. virtual AnsiString __fastcall GetVersion();
  57. AnsiString __fastcall GetProductVersion();
  58. AnsiString __fastcall GetProductName();
  59. AnsiString __fastcall GetCompanyName();
  60. AnsiString __fastcall TrimVersion(AnsiString Version);
  61. AnsiString __fastcall GetStoredSessionsSubKey();
  62. AnsiString __fastcall GetPuttySessionsKey();
  63. void __fastcall SetRandomSeedFile(AnsiString value);
  64. AnsiString __fastcall GetRandomSeedFileName();
  65. void __fastcall SetPuttyRegistryStorageKey(AnsiString value);
  66. AnsiString __fastcall GetSshHostKeysSubKey();
  67. AnsiString __fastcall GetRootKeyStr();
  68. AnsiString __fastcall GetConfigurationSubKey();
  69. TEOLType __fastcall GetLocalEOLType();
  70. void __fastcall SetLogging(bool value);
  71. void __fastcall SetLogFileName(AnsiString value);
  72. void __fastcall SetLogToFile(bool value);
  73. bool __fastcall GetLogToFile();
  74. void __fastcall SetLogWindowLines(int value);
  75. void __fastcall SetLogWindowComplete(bool value);
  76. bool __fastcall GetLogWindowComplete();
  77. void __fastcall SetLogFileAppend(bool value);
  78. void __fastcall SetLogProtocol(int value);
  79. void __fastcall SetLogActions(bool value);
  80. AnsiString __fastcall GetDefaultLogFileName();
  81. AnsiString __fastcall GetTimeFormat();
  82. void __fastcall SetStorage(TStorage value);
  83. AnsiString __fastcall GetRegistryStorageKey();
  84. AnsiString __fastcall GetIniFileStorageName();
  85. void __fastcall SetIniFileStorageName(AnsiString value);
  86. AnsiString __fastcall GetPartialExt() const;
  87. AnsiString __fastcall GetFileInfoString(const AnsiString Key);
  88. bool __fastcall GetGSSAPIInstalled();
  89. void __fastcall SetSessionReopenAuto(int value);
  90. void __fastcall SetSessionReopenBackground(int value);
  91. void __fastcall SetSessionReopenTimeout(int value);
  92. void __fastcall SetTunnelLocalPortNumberLow(int value);
  93. void __fastcall SetTunnelLocalPortNumberHigh(int value);
  94. void __fastcall SetCacheDirectoryChangesMaxSize(int value);
  95. void __fastcall SetShowFtpWelcomeMessage(bool value);
  96. int __fastcall GetCompoundVersion();
  97. void __fastcall UpdateActualLogProtocol();
  98. protected:
  99. TStorage FStorage;
  100. TCriticalSection * FCriticalSection;
  101. virtual TStorage __fastcall GetStorage();
  102. virtual void __fastcall Changed();
  103. virtual void __fastcall SaveData(THierarchicalStorage * Storage, bool All);
  104. virtual void __fastcall LoadData(THierarchicalStorage * Storage);
  105. virtual void __fastcall CopyData(THierarchicalStorage * Source, THierarchicalStorage * Target);
  106. virtual void __fastcall LoadAdmin(THierarchicalStorage * Storage);
  107. virtual AnsiString __fastcall GetDefaultKeyFile();
  108. virtual void __fastcall Saved();
  109. void __fastcall CleanupRegistry(AnsiString CleanupSubKey);
  110. AnsiString __fastcall BannerHash(const AnsiString & Banner);
  111. virtual bool __fastcall GetConfirmOverwriting();
  112. virtual void __fastcall SetConfirmOverwriting(bool value);
  113. bool __fastcall GetConfirmResume();
  114. void __fastcall SetConfirmResume(bool value);
  115. bool __fastcall GetAutoReadDirectoryAfterOp();
  116. void __fastcall SetAutoReadDirectoryAfterOp(bool value);
  117. virtual bool __fastcall GetRememberPassword();
  118. virtual AnsiString __fastcall ModuleFileName();
  119. AnsiString __fastcall GetFileFileInfoString(const AnsiString Key,
  120. const AnsiString FileName);
  121. void * __fastcall GetFileApplicationInfo(const AnsiString FileName);
  122. AnsiString __fastcall GetFileProductVersion(const AnsiString FileName);
  123. AnsiString __fastcall GetFileProductName(const AnsiString FileName);
  124. AnsiString __fastcall GetFileCompanyName(const AnsiString FileName);
  125. __property bool PermanentLogging = { read=FPermanentLogging, write=SetLogging };
  126. __property AnsiString PermanentLogFileName = { read=FPermanentLogFileName, write=SetLogFileName };
  127. __property bool PermanentLogActions = { read=FPermanentLogActions, write=SetLogActions };
  128. public:
  129. __fastcall TConfiguration();
  130. virtual __fastcall ~TConfiguration();
  131. virtual void __fastcall Default();
  132. virtual void __fastcall Load();
  133. virtual void __fastcall Save(bool All, bool Explicit);
  134. void __fastcall Export(const AnsiString FileName);
  135. void __fastcall CleanupConfiguration();
  136. void __fastcall CleanupIniFile();
  137. void __fastcall CleanupHostKeys();
  138. void __fastcall CleanupRandomSeedFile();
  139. void __fastcall BeginUpdate();
  140. void __fastcall EndUpdate();
  141. void __fastcall LoadDirectoryChangesCache(const AnsiString SessionKey,
  142. TRemoteDirectoryChangesCache * DirectoryChangesCache);
  143. void __fastcall SaveDirectoryChangesCache(const AnsiString SessionKey,
  144. TRemoteDirectoryChangesCache * DirectoryChangesCache);
  145. bool __fastcall ShowBanner(const AnsiString SessionKey, const AnsiString & Banner);
  146. void __fastcall NeverShowBanner(const AnsiString SessionKey, const AnsiString & Banner);
  147. virtual THierarchicalStorage * CreateScpStorage(bool SessionList);
  148. void __fastcall TemporaryLogging(const AnsiString ALogFileName);
  149. virtual AnsiString __fastcall EncryptPassword(AnsiString Password, AnsiString Key);
  150. virtual AnsiString __fastcall DecryptPassword(AnsiString Password, AnsiString Key);
  151. virtual AnsiString __fastcall StronglyRecryptPassword(AnsiString Password, AnsiString Key);
  152. __property TVSFixedFileInfo *FixedApplicationInfo = { read=GetFixedApplicationInfo };
  153. __property void * ApplicationInfo = { read=GetApplicationInfo };
  154. __property AnsiString StoredSessionsSubKey = {read=GetStoredSessionsSubKey};
  155. __property AnsiString PuttyRegistryStorageKey = { read=FPuttyRegistryStorageKey, write=SetPuttyRegistryStorageKey };
  156. __property AnsiString PuttySessionsKey = { read=GetPuttySessionsKey };
  157. __property AnsiString RandomSeedFile = { read=FRandomSeedFile, write=SetRandomSeedFile };
  158. __property AnsiString RandomSeedFileName = { read=GetRandomSeedFileName };
  159. __property AnsiString SshHostKeysSubKey = { read=GetSshHostKeysSubKey };
  160. __property AnsiString RootKeyStr = { read=GetRootKeyStr };
  161. __property AnsiString ConfigurationSubKey = { read=GetConfigurationSubKey };
  162. __property TEOLType LocalEOLType = { read = GetLocalEOLType };
  163. __property AnsiString VersionStr = { read=GetVersionStr };
  164. __property AnsiString Version = { read=GetVersion };
  165. __property int CompoundVersion = { read=GetCompoundVersion };
  166. __property AnsiString ProductVersion = { read=GetProductVersion };
  167. __property AnsiString ProductName = { read=GetProductName };
  168. __property AnsiString CompanyName = { read=GetCompanyName };
  169. __property AnsiString FileInfoString[AnsiString Key] = { read = GetFileInfoString };
  170. __property AnsiString OSVersionStr = { read = GetOSVersionStr };
  171. __property bool Logging = { read=FLogging, write=SetLogging };
  172. __property AnsiString LogFileName = { read=FLogFileName, write=SetLogFileName };
  173. __property bool LogToFile = { read=GetLogToFile, write=SetLogToFile };
  174. __property bool LogFileAppend = { read=FLogFileAppend, write=SetLogFileAppend };
  175. __property int LogProtocol = { read=FLogProtocol, write=SetLogProtocol };
  176. __property int ActualLogProtocol = { read=FActualLogProtocol };
  177. __property bool LogActions = { read=FLogActions, write=SetLogActions };
  178. __property int LogWindowLines = { read=FLogWindowLines, write=SetLogWindowLines };
  179. __property bool LogWindowComplete = { read=GetLogWindowComplete, write=SetLogWindowComplete };
  180. __property AnsiString DefaultLogFileName = { read=GetDefaultLogFileName };
  181. __property TNotifyEvent OnChange = { read = FOnChange, write = FOnChange };
  182. __property bool ConfirmOverwriting = { read = GetConfirmOverwriting, write = SetConfirmOverwriting};
  183. __property bool ConfirmResume = { read = GetConfirmResume, write = SetConfirmResume};
  184. __property bool AutoReadDirectoryAfterOp = { read = GetAutoReadDirectoryAfterOp, write = SetAutoReadDirectoryAfterOp};
  185. __property bool RememberPassword = { read = GetRememberPassword };
  186. __property AnsiString PartialExt = {read=GetPartialExt};
  187. __property int SessionReopenAuto = { read = FSessionReopenAuto, write = SetSessionReopenAuto };
  188. __property int SessionReopenBackground = { read = FSessionReopenBackground, write = SetSessionReopenBackground };
  189. __property int SessionReopenTimeout = { read = FSessionReopenTimeout, write = SetSessionReopenTimeout };
  190. __property int TunnelLocalPortNumberLow = { read = FTunnelLocalPortNumberLow, write = SetTunnelLocalPortNumberLow };
  191. __property int TunnelLocalPortNumberHigh = { read = FTunnelLocalPortNumberHigh, write = SetTunnelLocalPortNumberHigh };
  192. __property int CacheDirectoryChangesMaxSize = { read = FCacheDirectoryChangesMaxSize, write = SetCacheDirectoryChangesMaxSize };
  193. __property bool ShowFtpWelcomeMessage = { read = FShowFtpWelcomeMessage, write = SetShowFtpWelcomeMessage };
  194. __property AnsiString TimeFormat = { read = GetTimeFormat };
  195. __property TStorage Storage = { read=GetStorage, write=SetStorage };
  196. __property AnsiString RegistryStorageKey = { read=GetRegistryStorageKey };
  197. __property AnsiString IniFileStorageName = { read=GetIniFileStorageName, write=SetIniFileStorageName };
  198. __property AnsiString DefaultKeyFile = { read = GetDefaultKeyFile };
  199. __property bool DisablePasswordStoring = { read = FDisablePasswordStoring };
  200. __property bool ForceBanners = { read = FForceBanners };
  201. __property bool DisableAcceptingHostKeys = { read = FDisableAcceptingHostKeys };
  202. __property bool GSSAPIInstalled = { read = GetGSSAPIInstalled };
  203. };
  204. //---------------------------------------------------------------------------
  205. class TShortCuts
  206. {
  207. public:
  208. void __fastcall Add(TShortCut ShortCut);
  209. bool __fastcall Has(TShortCut ShortCut) const;
  210. private:
  211. std::set<TShortCut> FShortCuts;
  212. };
  213. //---------------------------------------------------------------------------
  214. #endif