Configuration.h 11 KB

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