Configuration.h 11 KB

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