Configuration.h 10 KB

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