Configuration.h 10 KB

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