SessionData.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. //---------------------------------------------------------------------------
  2. #ifndef SessionDataH
  3. #define SessionDataH
  4. #include "Common.h"
  5. #include "Option.h"
  6. #include "FileBuffer.h"
  7. #include "NamedObjs.h"
  8. #include "HierarchicalStorage.h"
  9. #include "Configuration.h"
  10. #include <Xml.XMLIntf.hpp>
  11. //---------------------------------------------------------------------------
  12. #define SET_SESSION_PROPERTY(Property) \
  13. if (F##Property != value) { F##Property = value; Modify(); }
  14. //---------------------------------------------------------------------------
  15. enum TCipher { cipWarn, cip3DES, cipBlowfish, cipAES, cipDES, cipArcfour };
  16. #define CIPHER_COUNT (cipArcfour+1)
  17. // explicit values to skip obsoleted fsExternalSSH, fsExternalSFTP
  18. enum TFSProtocol { fsSCPonly = 0, fsSFTP = 1, fsSFTPonly = 2, fsFTP = 5, fsWebDAV = 6 };
  19. #define FSPROTOCOL_COUNT (fsWebDAV+1)
  20. enum TProxyMethod { pmNone, pmSocks4, pmSocks5, pmHTTP, pmTelnet, pmCmd };
  21. enum TSshProt { ssh1only, ssh1, ssh2, ssh2only };
  22. enum TKex { kexWarn, kexDHGroup1, kexDHGroup14, kexDHGEx, kexRSA };
  23. #define KEX_COUNT (kexRSA+1)
  24. enum TSshBug { sbIgnore1, sbPlainPW1, sbRSA1, sbHMAC2, sbDeriveKey2, sbRSAPad2,
  25. sbPKSessID2, sbRekey2, sbMaxPkt2, sbIgnore2 };
  26. #define BUG_COUNT (sbIgnore2+1)
  27. enum TSftpBug { sbSymlink, sbSignedTS };
  28. #define SFTP_BUG_COUNT (sbSignedTS+1)
  29. enum TPingType { ptOff, ptNullPacket, ptDummyCommand };
  30. enum TAddressFamily { afAuto, afIPv4, afIPv6 };
  31. enum TFtps { ftpsNone, ftpsImplicit, ftpsExplicitSsl, ftpsExplicitTls };
  32. // has to match SSL_VERSION_XXX constants in AsyncSslSocketLayer.h
  33. enum TTlsVersion { ssl2 = 2, ssl3 = 3, tls10 = 10, tls11 = 11, tls12 = 12 };
  34. enum TSessionSource { ssNone, ssStored, ssStoredModified };
  35. //---------------------------------------------------------------------------
  36. extern const wchar_t CipherNames[CIPHER_COUNT][10];
  37. extern const wchar_t KexNames[KEX_COUNT][20];
  38. extern const wchar_t SshProtList[][10];
  39. extern const wchar_t ProxyMethodList[][10];
  40. extern const TCipher DefaultCipherList[CIPHER_COUNT];
  41. extern const TKex DefaultKexList[KEX_COUNT];
  42. extern const wchar_t FSProtocolNames[FSPROTOCOL_COUNT][16];
  43. extern const int DefaultSendBuf;
  44. extern const UnicodeString AnonymousUserName;
  45. extern const UnicodeString AnonymousPassword;
  46. extern const int SshPortNumber;
  47. extern const int FtpPortNumber;
  48. extern const int FtpsImplicitPortNumber;
  49. extern const int HTTPPortNumber;
  50. extern const int HTTPSPortNumber;
  51. extern const int TelnetPortNumber;
  52. extern const UnicodeString PuttySshProtocol;
  53. extern const UnicodeString PuttyTelnetProtocol;
  54. //---------------------------------------------------------------------------
  55. class TStoredSessionList;
  56. //---------------------------------------------------------------------------
  57. class TSessionData : public TNamedObject
  58. {
  59. friend class TStoredSessionList;
  60. private:
  61. UnicodeString FHostName;
  62. int FPortNumber;
  63. UnicodeString FUserName;
  64. RawByteString FPassword;
  65. int FPingInterval;
  66. TPingType FPingType;
  67. bool FTryAgent;
  68. bool FAgentFwd;
  69. UnicodeString FListingCommand;
  70. bool FAuthTIS;
  71. bool FAuthKI;
  72. bool FAuthKIPassword;
  73. bool FAuthGSSAPI;
  74. bool FGSSAPIFwdTGT; // not supported anymore
  75. UnicodeString FGSSAPIServerRealm; // not supported anymore
  76. bool FChangeUsername;
  77. bool FCompression;
  78. TSshProt FSshProt;
  79. bool FSsh2DES;
  80. bool FSshNoUserAuth;
  81. TCipher FCiphers[CIPHER_COUNT];
  82. TKex FKex[KEX_COUNT];
  83. bool FClearAliases;
  84. TEOLType FEOLType;
  85. UnicodeString FPublicKeyFile;
  86. UnicodeString FPuttyProtocol;
  87. TFSProtocol FFSProtocol;
  88. bool FModified;
  89. UnicodeString FLocalDirectory;
  90. UnicodeString FRemoteDirectory;
  91. bool FLockInHome;
  92. bool FSpecial;
  93. bool FSynchronizeBrowsing;
  94. bool FUpdateDirectories;
  95. bool FCacheDirectories;
  96. bool FCacheDirectoryChanges;
  97. bool FPreserveDirectoryChanges;
  98. bool FSelected;
  99. TAutoSwitch FLookupUserGroups;
  100. UnicodeString FReturnVar;
  101. bool FScp1Compatibility;
  102. UnicodeString FShell;
  103. UnicodeString FSftpServer;
  104. int FTimeout;
  105. bool FUnsetNationalVars;
  106. bool FIgnoreLsWarnings;
  107. bool FTcpNoDelay;
  108. int FSendBuf;
  109. bool FSshSimple;
  110. TProxyMethod FProxyMethod;
  111. UnicodeString FProxyHost;
  112. int FProxyPort;
  113. UnicodeString FProxyUsername;
  114. RawByteString FProxyPassword;
  115. UnicodeString FProxyTelnetCommand;
  116. UnicodeString FProxyLocalCommand;
  117. TAutoSwitch FProxyDNS;
  118. bool FProxyLocalhost;
  119. int FFtpProxyLogonType;
  120. TAutoSwitch FBugs[BUG_COUNT];
  121. UnicodeString FCustomParam1;
  122. UnicodeString FCustomParam2;
  123. bool FResolveSymlinks;
  124. TDateTime FTimeDifference;
  125. int FSFTPDownloadQueue;
  126. int FSFTPUploadQueue;
  127. int FSFTPListingQueue;
  128. int FSFTPMaxVersion;
  129. unsigned long FSFTPMaxPacketSize;
  130. TDSTMode FDSTMode;
  131. TAutoSwitch FSFTPBugs[SFTP_BUG_COUNT];
  132. bool FDeleteToRecycleBin;
  133. bool FOverwrittenToRecycleBin;
  134. UnicodeString FRecycleBinPath;
  135. UnicodeString FPostLoginCommands;
  136. TAutoSwitch FSCPLsFullTime;
  137. TAutoSwitch FFtpListAll;
  138. bool FSslSessionReuse;
  139. TAddressFamily FAddressFamily;
  140. UnicodeString FRekeyData;
  141. unsigned int FRekeyTime;
  142. int FColor;
  143. bool FTunnel;
  144. UnicodeString FTunnelHostName;
  145. int FTunnelPortNumber;
  146. UnicodeString FTunnelUserName;
  147. RawByteString FTunnelPassword;
  148. UnicodeString FTunnelPublicKeyFile;
  149. int FTunnelLocalPortNumber;
  150. UnicodeString FTunnelPortFwd;
  151. UnicodeString FTunnelHostKey;
  152. bool FFtpPasvMode;
  153. TAutoSwitch FFtpForcePasvIp;
  154. TAutoSwitch FFtpUseMlsd;
  155. UnicodeString FFtpAccount;
  156. int FFtpPingInterval;
  157. TPingType FFtpPingType;
  158. TFtps FFtps;
  159. TTlsVersion FMinTlsVersion;
  160. TTlsVersion FMaxTlsVersion;
  161. TAutoSwitch FNotUtf;
  162. bool FIsWorkspace;
  163. UnicodeString FLink;
  164. UnicodeString FHostKey;
  165. UnicodeString FOrigHostName;
  166. int FOrigPortNumber;
  167. TProxyMethod FOrigProxyMethod;
  168. TSessionSource FSource;
  169. void __fastcall SetHostName(UnicodeString value);
  170. UnicodeString __fastcall GetHostNameExpanded();
  171. void __fastcall SetPortNumber(int value);
  172. void __fastcall SetUserName(UnicodeString value);
  173. UnicodeString __fastcall GetUserNameExpanded();
  174. void __fastcall SetPassword(UnicodeString value);
  175. UnicodeString __fastcall GetPassword() const;
  176. void __fastcall SetPasswordless(bool value);
  177. void __fastcall SetPingInterval(int value);
  178. void __fastcall SetTryAgent(bool value);
  179. void __fastcall SetAgentFwd(bool value);
  180. void __fastcall SetAuthTIS(bool value);
  181. void __fastcall SetAuthKI(bool value);
  182. void __fastcall SetAuthKIPassword(bool value);
  183. void __fastcall SetAuthGSSAPI(bool value);
  184. void __fastcall SetGSSAPIFwdTGT(bool value);
  185. void __fastcall SetGSSAPIServerRealm(UnicodeString value);
  186. void __fastcall SetChangeUsername(bool value);
  187. void __fastcall SetCompression(bool value);
  188. void __fastcall SetSshProt(TSshProt value);
  189. void __fastcall SetSsh2DES(bool value);
  190. void __fastcall SetSshNoUserAuth(bool value);
  191. void __fastcall SetCipher(int Index, TCipher value);
  192. TCipher __fastcall GetCipher(int Index) const;
  193. void __fastcall SetKex(int Index, TKex value);
  194. TKex __fastcall GetKex(int Index) const;
  195. void __fastcall SetPublicKeyFile(UnicodeString value);
  196. void __fastcall SetPuttyProtocol(UnicodeString value);
  197. bool __fastcall GetCanLogin();
  198. void __fastcall SetPingIntervalDT(TDateTime value);
  199. TDateTime __fastcall GetPingIntervalDT();
  200. TDateTime __fastcall GetFtpPingIntervalDT();
  201. void __fastcall SetTimeDifference(TDateTime value);
  202. void __fastcall SetPingType(TPingType value);
  203. UnicodeString __fastcall GetSessionName();
  204. bool __fastcall HasSessionName();
  205. UnicodeString __fastcall GetDefaultSessionName();
  206. UnicodeString __fastcall GetSessionUrl();
  207. void __fastcall SetFSProtocol(TFSProtocol value);
  208. UnicodeString __fastcall GetFSProtocolStr();
  209. void __fastcall SetLocalDirectory(UnicodeString value);
  210. void __fastcall SetRemoteDirectory(UnicodeString value);
  211. void __fastcall SetSynchronizeBrowsing(bool value);
  212. void __fastcall SetUpdateDirectories(bool value);
  213. void __fastcall SetCacheDirectories(bool value);
  214. void __fastcall SetCacheDirectoryChanges(bool value);
  215. void __fastcall SetPreserveDirectoryChanges(bool value);
  216. void __fastcall SetLockInHome(bool value);
  217. void __fastcall SetSpecial(bool value);
  218. UnicodeString __fastcall GetInfoTip();
  219. bool __fastcall GetDefaultShell();
  220. void __fastcall SetDetectReturnVar(bool value);
  221. bool __fastcall GetDetectReturnVar();
  222. void __fastcall SetListingCommand(UnicodeString value);
  223. void __fastcall SetClearAliases(bool value);
  224. void __fastcall SetDefaultShell(bool value);
  225. void __fastcall SetEOLType(TEOLType value);
  226. void __fastcall SetLookupUserGroups(TAutoSwitch value);
  227. void __fastcall SetReturnVar(UnicodeString value);
  228. void __fastcall SetScp1Compatibility(bool value);
  229. void __fastcall SetShell(UnicodeString value);
  230. void __fastcall SetSftpServer(UnicodeString value);
  231. void __fastcall SetTimeout(int value);
  232. void __fastcall SetUnsetNationalVars(bool value);
  233. void __fastcall SetIgnoreLsWarnings(bool value);
  234. void __fastcall SetTcpNoDelay(bool value);
  235. void __fastcall SetSendBuf(int value);
  236. void __fastcall SetSshSimple(bool value);
  237. UnicodeString __fastcall GetSshProtStr();
  238. bool __fastcall GetUsesSsh();
  239. void __fastcall SetCipherList(UnicodeString value);
  240. UnicodeString __fastcall GetCipherList() const;
  241. void __fastcall SetKexList(UnicodeString value);
  242. UnicodeString __fastcall GetKexList() const;
  243. void __fastcall SetProxyMethod(TProxyMethod value);
  244. void __fastcall SetProxyHost(UnicodeString value);
  245. void __fastcall SetProxyPort(int value);
  246. void __fastcall SetProxyUsername(UnicodeString value);
  247. void __fastcall SetProxyPassword(UnicodeString value);
  248. void __fastcall SetProxyTelnetCommand(UnicodeString value);
  249. void __fastcall SetProxyLocalCommand(UnicodeString value);
  250. void __fastcall SetProxyDNS(TAutoSwitch value);
  251. void __fastcall SetProxyLocalhost(bool value);
  252. UnicodeString __fastcall GetProxyPassword() const;
  253. void __fastcall SetFtpProxyLogonType(int value);
  254. void __fastcall SetBug(TSshBug Bug, TAutoSwitch value);
  255. TAutoSwitch __fastcall GetBug(TSshBug Bug) const;
  256. UnicodeString __fastcall GetSessionKey();
  257. void __fastcall SetCustomParam1(UnicodeString value);
  258. void __fastcall SetCustomParam2(UnicodeString value);
  259. void __fastcall SetResolveSymlinks(bool value);
  260. void __fastcall SetSFTPDownloadQueue(int value);
  261. void __fastcall SetSFTPUploadQueue(int value);
  262. void __fastcall SetSFTPListingQueue(int value);
  263. void __fastcall SetSFTPMaxVersion(int value);
  264. void __fastcall SetSFTPMaxPacketSize(unsigned long value);
  265. void __fastcall SetSFTPBug(TSftpBug Bug, TAutoSwitch value);
  266. TAutoSwitch __fastcall GetSFTPBug(TSftpBug Bug) const;
  267. void __fastcall SetSCPLsFullTime(TAutoSwitch value);
  268. void __fastcall SetFtpListAll(TAutoSwitch value);
  269. void __fastcall SetSslSessionReuse(bool value);
  270. UnicodeString __fastcall GetStorageKey();
  271. UnicodeString __fastcall GetInternalStorageKey();
  272. void __fastcall SetDSTMode(TDSTMode value);
  273. void __fastcall SetDeleteToRecycleBin(bool value);
  274. void __fastcall SetOverwrittenToRecycleBin(bool value);
  275. void __fastcall SetRecycleBinPath(UnicodeString value);
  276. void __fastcall SetPostLoginCommands(UnicodeString value);
  277. void __fastcall SetAddressFamily(TAddressFamily value);
  278. void __fastcall SetRekeyData(UnicodeString value);
  279. void __fastcall SetRekeyTime(unsigned int value);
  280. void __fastcall SetColor(int value);
  281. void __fastcall SetTunnel(bool value);
  282. void __fastcall SetTunnelHostName(UnicodeString value);
  283. void __fastcall SetTunnelPortNumber(int value);
  284. void __fastcall SetTunnelUserName(UnicodeString value);
  285. void __fastcall SetTunnelPassword(UnicodeString value);
  286. UnicodeString __fastcall GetTunnelPassword() const;
  287. void __fastcall SetTunnelPublicKeyFile(UnicodeString value);
  288. void __fastcall SetTunnelPortFwd(UnicodeString value);
  289. void __fastcall SetTunnelLocalPortNumber(int value);
  290. bool __fastcall GetTunnelAutoassignLocalPortNumber();
  291. void __fastcall SetTunnelHostKey(UnicodeString value);
  292. void __fastcall SetFtpPasvMode(bool value);
  293. void __fastcall SetFtpForcePasvIp(TAutoSwitch value);
  294. void __fastcall SetFtpUseMlsd(TAutoSwitch value);
  295. void __fastcall SetFtpAccount(UnicodeString value);
  296. void __fastcall SetFtpPingInterval(int value);
  297. void __fastcall SetFtpPingType(TPingType value);
  298. void __fastcall SetFtps(TFtps value);
  299. void __fastcall SetMinTlsVersion(TTlsVersion value);
  300. void __fastcall SetMaxTlsVersion(TTlsVersion value);
  301. void __fastcall SetNotUtf(TAutoSwitch value);
  302. void __fastcall SetIsWorkspace(bool value);
  303. void __fastcall SetLink(UnicodeString value);
  304. void __fastcall SetHostKey(UnicodeString value);
  305. TDateTime __fastcall GetTimeoutDT();
  306. void __fastcall SavePasswords(THierarchicalStorage * Storage, bool PuttyExport);
  307. UnicodeString __fastcall GetLocalName();
  308. UnicodeString __fastcall GetFolderName();
  309. void __fastcall Modify();
  310. UnicodeString __fastcall GetSource();
  311. void __fastcall DoLoad(THierarchicalStorage * Storage, bool & RewritePassword);
  312. UnicodeString __fastcall ReadXmlNode(_di_IXMLNode Node, const UnicodeString & Name, const UnicodeString & Default);
  313. int __fastcall ReadXmlNode(_di_IXMLNode Node, const UnicodeString & Name, int Default);
  314. static RawByteString __fastcall EncryptPassword(const UnicodeString & Password, UnicodeString Key);
  315. static UnicodeString __fastcall DecryptPassword(const RawByteString & Password, UnicodeString Key);
  316. static RawByteString __fastcall StronglyRecryptPassword(const RawByteString & Password, UnicodeString Key);
  317. __property UnicodeString InternalStorageKey = { read = GetInternalStorageKey };
  318. public:
  319. __fastcall TSessionData(UnicodeString aName);
  320. virtual __fastcall ~TSessionData();
  321. void __fastcall Default();
  322. void __fastcall NonPersistant();
  323. void __fastcall Load(THierarchicalStorage * Storage);
  324. void __fastcall ImportFromFilezilla(_di_IXMLNode Node, const UnicodeString & Path);
  325. void __fastcall Save(THierarchicalStorage * Storage, bool PuttyExport,
  326. const TSessionData * Default = NULL);
  327. void __fastcall SaveRecryptedPasswords(THierarchicalStorage * Storage);
  328. void __fastcall RecryptPasswords();
  329. bool __fastcall HasPassword();
  330. bool __fastcall HasAnyPassword();
  331. void __fastcall Remove();
  332. virtual void __fastcall Assign(TPersistent * Source);
  333. bool __fastcall ParseUrl(UnicodeString Url, TOptions * Options,
  334. TStoredSessionList * StoredSessions, bool & DefaultsOnly,
  335. UnicodeString * FileName, bool * AProtocolDefined, UnicodeString * MaskedUrl);
  336. bool __fastcall ParseOptions(TOptions * Options);
  337. void __fastcall ConfigureTunnel(int PortNumber);
  338. void __fastcall RollbackTunnel();
  339. void __fastcall ExpandEnvironmentVariables();
  340. bool __fastcall IsSame(const TSessionData * Default, bool AdvancedOnly);
  341. bool __fastcall IsInFolderOrWorkspace(UnicodeString Name);
  342. static void __fastcall ValidatePath(const UnicodeString Path);
  343. static void __fastcall ValidateName(const UnicodeString Name);
  344. static UnicodeString __fastcall ExtractLocalName(const UnicodeString & Name);
  345. static UnicodeString __fastcall ExtractFolderName(const UnicodeString & Name);
  346. static UnicodeString __fastcall ComposePath(const UnicodeString & Path, const UnicodeString & Name);
  347. __property UnicodeString HostName = { read=FHostName, write=SetHostName };
  348. __property UnicodeString HostNameExpanded = { read=GetHostNameExpanded };
  349. __property int PortNumber = { read=FPortNumber, write=SetPortNumber };
  350. __property UnicodeString UserName = { read=FUserName, write=SetUserName };
  351. __property UnicodeString UserNameExpanded = { read=GetUserNameExpanded };
  352. __property UnicodeString Password = { read=GetPassword, write=SetPassword };
  353. __property int PingInterval = { read=FPingInterval, write=SetPingInterval };
  354. __property bool TryAgent = { read=FTryAgent, write=SetTryAgent };
  355. __property bool AgentFwd = { read=FAgentFwd, write=SetAgentFwd };
  356. __property UnicodeString ListingCommand = { read = FListingCommand, write = SetListingCommand };
  357. __property bool AuthTIS = { read=FAuthTIS, write=SetAuthTIS };
  358. __property bool AuthKI = { read=FAuthKI, write=SetAuthKI };
  359. __property bool AuthKIPassword = { read=FAuthKIPassword, write=SetAuthKIPassword };
  360. __property bool AuthGSSAPI = { read=FAuthGSSAPI, write=SetAuthGSSAPI };
  361. __property bool GSSAPIFwdTGT = { read=FGSSAPIFwdTGT, write=SetGSSAPIFwdTGT };
  362. __property UnicodeString GSSAPIServerRealm = { read=FGSSAPIServerRealm, write=SetGSSAPIServerRealm };
  363. __property bool ChangeUsername = { read=FChangeUsername, write=SetChangeUsername };
  364. __property bool Compression = { read=FCompression, write=SetCompression };
  365. __property TSshProt SshProt = { read=FSshProt, write=SetSshProt };
  366. __property bool UsesSsh = { read = GetUsesSsh };
  367. __property bool Ssh2DES = { read=FSsh2DES, write=SetSsh2DES };
  368. __property bool SshNoUserAuth = { read=FSshNoUserAuth, write=SetSshNoUserAuth };
  369. __property TCipher Cipher[int Index] = { read=GetCipher, write=SetCipher };
  370. __property TKex Kex[int Index] = { read=GetKex, write=SetKex };
  371. __property UnicodeString PublicKeyFile = { read=FPublicKeyFile, write=SetPublicKeyFile };
  372. __property UnicodeString PuttyProtocol = { read=FPuttyProtocol, write=SetPuttyProtocol };
  373. __property TFSProtocol FSProtocol = { read=FFSProtocol, write=SetFSProtocol };
  374. __property UnicodeString FSProtocolStr = { read=GetFSProtocolStr };
  375. __property bool Modified = { read=FModified, write=FModified };
  376. __property bool CanLogin = { read=GetCanLogin };
  377. __property bool ClearAliases = { read = FClearAliases, write = SetClearAliases };
  378. __property TDateTime PingIntervalDT = { read = GetPingIntervalDT, write = SetPingIntervalDT };
  379. __property TDateTime TimeDifference = { read = FTimeDifference, write = SetTimeDifference };
  380. __property TPingType PingType = { read = FPingType, write = SetPingType };
  381. __property UnicodeString SessionName = { read=GetSessionName };
  382. __property UnicodeString DefaultSessionName = { read=GetDefaultSessionName };
  383. __property UnicodeString SessionUrl = { read=GetSessionUrl };
  384. __property UnicodeString LocalDirectory = { read=FLocalDirectory, write=SetLocalDirectory };
  385. __property UnicodeString RemoteDirectory = { read=FRemoteDirectory, write=SetRemoteDirectory };
  386. __property bool SynchronizeBrowsing = { read=FSynchronizeBrowsing, write=SetSynchronizeBrowsing };
  387. __property bool UpdateDirectories = { read=FUpdateDirectories, write=SetUpdateDirectories };
  388. __property bool CacheDirectories = { read=FCacheDirectories, write=SetCacheDirectories };
  389. __property bool CacheDirectoryChanges = { read=FCacheDirectoryChanges, write=SetCacheDirectoryChanges };
  390. __property bool PreserveDirectoryChanges = { read=FPreserveDirectoryChanges, write=SetPreserveDirectoryChanges };
  391. __property bool LockInHome = { read=FLockInHome, write=SetLockInHome };
  392. __property bool Special = { read=FSpecial, write=SetSpecial };
  393. __property bool Selected = { read=FSelected, write=FSelected };
  394. __property UnicodeString InfoTip = { read=GetInfoTip };
  395. __property bool DefaultShell = { read = GetDefaultShell, write = SetDefaultShell };
  396. __property bool DetectReturnVar = { read = GetDetectReturnVar, write = SetDetectReturnVar };
  397. __property TEOLType EOLType = { read = FEOLType, write = SetEOLType };
  398. __property TAutoSwitch LookupUserGroups = { read = FLookupUserGroups, write = SetLookupUserGroups };
  399. __property UnicodeString ReturnVar = { read = FReturnVar, write = SetReturnVar };
  400. __property bool Scp1Compatibility = { read = FScp1Compatibility, write = SetScp1Compatibility };
  401. __property UnicodeString Shell = { read = FShell, write = SetShell };
  402. __property UnicodeString SftpServer = { read = FSftpServer, write = SetSftpServer };
  403. __property int Timeout = { read = FTimeout, write = SetTimeout };
  404. __property TDateTime TimeoutDT = { read = GetTimeoutDT };
  405. __property bool UnsetNationalVars = { read = FUnsetNationalVars, write = SetUnsetNationalVars };
  406. __property bool IgnoreLsWarnings = { read=FIgnoreLsWarnings, write=SetIgnoreLsWarnings };
  407. __property bool TcpNoDelay = { read=FTcpNoDelay, write=SetTcpNoDelay };
  408. __property int SendBuf = { read=FSendBuf, write=SetSendBuf };
  409. __property bool SshSimple = { read=FSshSimple, write=SetSshSimple };
  410. __property UnicodeString SshProtStr = { read=GetSshProtStr };
  411. __property UnicodeString CipherList = { read=GetCipherList, write=SetCipherList };
  412. __property UnicodeString KexList = { read=GetKexList, write=SetKexList };
  413. __property TProxyMethod ProxyMethod = { read=FProxyMethod, write=SetProxyMethod };
  414. __property UnicodeString ProxyHost = { read=FProxyHost, write=SetProxyHost };
  415. __property int ProxyPort = { read=FProxyPort, write=SetProxyPort };
  416. __property UnicodeString ProxyUsername = { read=FProxyUsername, write=SetProxyUsername };
  417. __property UnicodeString ProxyPassword = { read=GetProxyPassword, write=SetProxyPassword };
  418. __property UnicodeString ProxyTelnetCommand = { read=FProxyTelnetCommand, write=SetProxyTelnetCommand };
  419. __property UnicodeString ProxyLocalCommand = { read=FProxyLocalCommand, write=SetProxyLocalCommand };
  420. __property TAutoSwitch ProxyDNS = { read=FProxyDNS, write=SetProxyDNS };
  421. __property bool ProxyLocalhost = { read=FProxyLocalhost, write=SetProxyLocalhost };
  422. __property int FtpProxyLogonType = { read=FFtpProxyLogonType, write=SetFtpProxyLogonType };
  423. __property TAutoSwitch Bug[TSshBug Bug] = { read=GetBug, write=SetBug };
  424. __property UnicodeString CustomParam1 = { read = FCustomParam1, write = SetCustomParam1 };
  425. __property UnicodeString CustomParam2 = { read = FCustomParam2, write = SetCustomParam2 };
  426. __property UnicodeString SessionKey = { read = GetSessionKey };
  427. __property bool ResolveSymlinks = { read = FResolveSymlinks, write = SetResolveSymlinks };
  428. __property int SFTPDownloadQueue = { read = FSFTPDownloadQueue, write = SetSFTPDownloadQueue };
  429. __property int SFTPUploadQueue = { read = FSFTPUploadQueue, write = SetSFTPUploadQueue };
  430. __property int SFTPListingQueue = { read = FSFTPListingQueue, write = SetSFTPListingQueue };
  431. __property int SFTPMaxVersion = { read = FSFTPMaxVersion, write = SetSFTPMaxVersion };
  432. __property unsigned long SFTPMaxPacketSize = { read = FSFTPMaxPacketSize, write = SetSFTPMaxPacketSize };
  433. __property TAutoSwitch SFTPBug[TSftpBug Bug] = { read=GetSFTPBug, write=SetSFTPBug };
  434. __property TAutoSwitch SCPLsFullTime = { read = FSCPLsFullTime, write = SetSCPLsFullTime };
  435. __property TAutoSwitch FtpListAll = { read = FFtpListAll, write = SetFtpListAll };
  436. __property bool SslSessionReuse = { read = FSslSessionReuse, write = SetSslSessionReuse };
  437. __property TDSTMode DSTMode = { read = FDSTMode, write = SetDSTMode };
  438. __property bool DeleteToRecycleBin = { read = FDeleteToRecycleBin, write = SetDeleteToRecycleBin };
  439. __property bool OverwrittenToRecycleBin = { read = FOverwrittenToRecycleBin, write = SetOverwrittenToRecycleBin };
  440. __property UnicodeString RecycleBinPath = { read = FRecycleBinPath, write = SetRecycleBinPath };
  441. __property UnicodeString PostLoginCommands = { read = FPostLoginCommands, write = SetPostLoginCommands };
  442. __property TAddressFamily AddressFamily = { read = FAddressFamily, write = SetAddressFamily };
  443. __property UnicodeString RekeyData = { read = FRekeyData, write = SetRekeyData };
  444. __property unsigned int RekeyTime = { read = FRekeyTime, write = SetRekeyTime };
  445. __property int Color = { read = FColor, write = SetColor };
  446. __property bool Tunnel = { read = FTunnel, write = SetTunnel };
  447. __property UnicodeString TunnelHostName = { read = FTunnelHostName, write = SetTunnelHostName };
  448. __property int TunnelPortNumber = { read = FTunnelPortNumber, write = SetTunnelPortNumber };
  449. __property UnicodeString TunnelUserName = { read = FTunnelUserName, write = SetTunnelUserName };
  450. __property UnicodeString TunnelPassword = { read = GetTunnelPassword, write = SetTunnelPassword };
  451. __property UnicodeString TunnelPublicKeyFile = { read = FTunnelPublicKeyFile, write = SetTunnelPublicKeyFile };
  452. __property bool TunnelAutoassignLocalPortNumber = { read = GetTunnelAutoassignLocalPortNumber };
  453. __property int TunnelLocalPortNumber = { read = FTunnelLocalPortNumber, write = SetTunnelLocalPortNumber };
  454. __property UnicodeString TunnelPortFwd = { read = FTunnelPortFwd, write = SetTunnelPortFwd };
  455. __property UnicodeString TunnelHostKey = { read = FTunnelHostKey, write = SetTunnelHostKey };
  456. __property bool FtpPasvMode = { read = FFtpPasvMode, write = SetFtpPasvMode };
  457. __property TAutoSwitch FtpForcePasvIp = { read = FFtpForcePasvIp, write = SetFtpForcePasvIp };
  458. __property TAutoSwitch FtpUseMlsd = { read = FFtpUseMlsd, write = SetFtpUseMlsd };
  459. __property UnicodeString FtpAccount = { read = FFtpAccount, write = SetFtpAccount };
  460. __property int FtpPingInterval = { read=FFtpPingInterval, write=SetFtpPingInterval };
  461. __property TDateTime FtpPingIntervalDT = { read=GetFtpPingIntervalDT };
  462. __property TPingType FtpPingType = { read = FFtpPingType, write = SetFtpPingType };
  463. __property TFtps Ftps = { read = FFtps, write = SetFtps };
  464. __property TTlsVersion MinTlsVersion = { read = FMinTlsVersion, write = SetMinTlsVersion };
  465. __property TTlsVersion MaxTlsVersion = { read = FMaxTlsVersion, write = SetMaxTlsVersion };
  466. __property TAutoSwitch NotUtf = { read = FNotUtf, write = SetNotUtf };
  467. __property bool IsWorkspace = { read = FIsWorkspace, write = SetIsWorkspace };
  468. __property UnicodeString Link = { read = FLink, write = SetLink };
  469. __property UnicodeString HostKey = { read = FHostKey, write = SetHostKey };
  470. __property UnicodeString StorageKey = { read = GetStorageKey };
  471. __property UnicodeString OrigHostName = { read = FOrigHostName };
  472. __property int OrigPortNumber = { read = FOrigPortNumber };
  473. __property UnicodeString LocalName = { read = GetLocalName };
  474. __property UnicodeString FolderName = { read = GetFolderName };
  475. __property UnicodeString Source = { read = GetSource };
  476. };
  477. //---------------------------------------------------------------------------
  478. class TStoredSessionList : public TNamedObjectList
  479. {
  480. public:
  481. __fastcall TStoredSessionList(bool aReadOnly = false);
  482. void __fastcall Load();
  483. void __fastcall Save(bool All, bool Explicit);
  484. void __fastcall Saved();
  485. void __fastcall ImportFromFilezilla(const UnicodeString FileName);
  486. void __fastcall Export(const UnicodeString FileName);
  487. void __fastcall Load(THierarchicalStorage * Storage, bool AsModified = false,
  488. bool UseDefaults = false);
  489. void __fastcall Save(THierarchicalStorage * Storage, bool All = false);
  490. void __fastcall SelectAll(bool Select);
  491. void __fastcall Import(TStoredSessionList * From, bool OnlySelected);
  492. void __fastcall RecryptPasswords(TStrings * RecryptPasswordErrors);
  493. TSessionData * __fastcall AtSession(int Index)
  494. { return (TSessionData*)AtObject(Index); }
  495. void __fastcall SelectSessionsToImport(TStoredSessionList * Dest, bool SSHOnly);
  496. void __fastcall Cleanup();
  497. void __fastcall UpdateStaticUsage();
  498. int __fastcall IndexOf(TSessionData * Data);
  499. TSessionData * __fastcall FindSame(TSessionData * Data);
  500. TSessionData * __fastcall NewSession(UnicodeString SessionName, TSessionData * Session);
  501. void __fastcall NewWorkspace(UnicodeString Name, TList * DataList);
  502. bool __fastcall IsFolder(const UnicodeString & Name);
  503. bool __fastcall IsWorkspace(const UnicodeString & Name);
  504. TSessionData * __fastcall ParseUrl(UnicodeString Url, TOptions * Options, bool & DefaultsOnly,
  505. UnicodeString * FileName = NULL, bool * ProtocolDefined = NULL, UnicodeString * MaskedUrl = NULL);
  506. bool __fastcall CanLogin(TSessionData * Data);
  507. void __fastcall GetFolderOrWorkspace(const UnicodeString & Name, TList * List);
  508. TStrings * __fastcall GetFolderOrWorkspaceList(const UnicodeString & Name);
  509. TStrings * __fastcall GetWorkspaces();
  510. bool __fastcall HasAnyWorkspace();
  511. virtual __fastcall ~TStoredSessionList();
  512. __property TSessionData * Sessions[int Index] = { read=AtSession };
  513. __property TSessionData * DefaultSettings = { read=FDefaultSettings, write=SetDefaultSettings };
  514. static void __fastcall ImportHostKeys(const UnicodeString TargetKey,
  515. const UnicodeString SourceKey, TStoredSessionList * Sessions,
  516. bool OnlySelected);
  517. private:
  518. TSessionData * FDefaultSettings;
  519. bool FReadOnly;
  520. void __fastcall SetDefaultSettings(TSessionData * value);
  521. void __fastcall DoSave(THierarchicalStorage * Storage, bool All,
  522. bool RecryptPasswordOnly, TStrings * RecryptPasswordErrors);
  523. void __fastcall DoSave(bool All, bool Explicit, bool RecryptPasswordOnly,
  524. TStrings * RecryptPasswordErrors);
  525. void __fastcall DoSave(THierarchicalStorage * Storage,
  526. TSessionData * Data, bool All, bool RecryptPasswordOnly,
  527. TSessionData * FactoryDefaults);
  528. TSessionData * __fastcall ResolveSessionData(TSessionData * Data);
  529. bool __fastcall IsFolderOrWorkspace(const UnicodeString & Name, bool Workspace);
  530. TSessionData * __fastcall CheckIsInFolderOrWorkspaceAndResolve(
  531. TSessionData * Data, const UnicodeString & Name);
  532. void __fastcall ImportLevelFromFilezilla(_di_IXMLNode Node, const UnicodeString & Path);
  533. };
  534. //---------------------------------------------------------------------------
  535. UnicodeString GetExpandedLogFileName(UnicodeString LogFileName, TSessionData * SessionData);
  536. bool __fastcall IsSshProtocol(TFSProtocol FSProtocol);
  537. //---------------------------------------------------------------------------
  538. #endif