GUIConfiguration.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <LanguagesDEPfix.hpp>
  5. #include "GUIConfiguration.h"
  6. #include "GUITools.h"
  7. #include <Common.h>
  8. #include <FileInfo.h>
  9. #include <TextsCore.h>
  10. #include <Terminal.h>
  11. #include <CoreMain.h>
  12. #include <shlobj.h>
  13. //---------------------------------------------------------------------------
  14. #pragma package(smart_init)
  15. //---------------------------------------------------------------------------
  16. const int ccLocal = ccUser;
  17. const int ccShowResults = ccUser << 1;
  18. const int ccCopyResults = ccUser << 2;
  19. const int ccSet = 0x80000000;
  20. //---------------------------------------------------------------------------
  21. static const unsigned int AdditionaLanguageMask = 0xFFFFFF00;
  22. static const UnicodeString AdditionaLanguagePrefix(L"XX");
  23. //---------------------------------------------------------------------------
  24. __fastcall TGUICopyParamType::TGUICopyParamType()
  25. : TCopyParamType()
  26. {
  27. GUIDefault();
  28. }
  29. //---------------------------------------------------------------------------
  30. __fastcall TGUICopyParamType::TGUICopyParamType(const TCopyParamType & Source)
  31. : TCopyParamType(Source)
  32. {
  33. GUIDefault();
  34. }
  35. //---------------------------------------------------------------------------
  36. __fastcall TGUICopyParamType::TGUICopyParamType(const TGUICopyParamType & Source)
  37. : TCopyParamType(Source)
  38. {
  39. GUIAssign(&Source);
  40. }
  41. //---------------------------------------------------------------------------
  42. void __fastcall TGUICopyParamType::Assign(const TCopyParamType * Source)
  43. {
  44. TCopyParamType::Assign(Source);
  45. const TGUICopyParamType * GUISource;
  46. GUISource = dynamic_cast<const TGUICopyParamType *>(Source);
  47. if (GUISource != NULL)
  48. {
  49. GUIAssign(GUISource);
  50. }
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TGUICopyParamType::GUIAssign(const TGUICopyParamType * Source)
  54. {
  55. Queue = Source->Queue;
  56. QueueNoConfirmation = Source->QueueNoConfirmation;
  57. QueueIndividually = Source->QueueIndividually;
  58. }
  59. //---------------------------------------------------------------------------
  60. void __fastcall TGUICopyParamType::Default()
  61. {
  62. TCopyParamType::Default();
  63. GUIDefault();
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TGUICopyParamType::GUIDefault()
  67. {
  68. Queue = false;
  69. QueueNoConfirmation = true;
  70. QueueIndividually = false;
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TGUICopyParamType::Load(THierarchicalStorage * Storage)
  74. {
  75. TCopyParamType::Load(Storage);
  76. Queue = Storage->ReadBool(L"Queue", Queue);
  77. QueueNoConfirmation = Storage->ReadBool(L"QueueNoConfirmation", QueueNoConfirmation);
  78. QueueIndividually = Storage->ReadBool(L"QueueIndividually", QueueIndividually);
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TGUICopyParamType::Save(THierarchicalStorage * Storage)
  82. {
  83. TCopyParamType::Save(Storage);
  84. Storage->WriteBool(L"Queue", Queue);
  85. Storage->WriteBool(L"QueueNoConfirmation", QueueNoConfirmation);
  86. Storage->WriteBool(L"QueueIndividually", QueueIndividually);
  87. }
  88. //---------------------------------------------------------------------------
  89. TGUICopyParamType & __fastcall TGUICopyParamType::operator =(const TCopyParamType & rhp)
  90. {
  91. Assign(&rhp);
  92. return *this;
  93. }
  94. //---------------------------------------------------------------------------
  95. TGUICopyParamType & __fastcall TGUICopyParamType::operator =(const TGUICopyParamType & rhp)
  96. {
  97. Assign(&rhp);
  98. return *this;
  99. }
  100. //---------------------------------------------------------------------------
  101. //---------------------------------------------------------------------------
  102. void __fastcall TCopyParamRuleData::Default()
  103. {
  104. HostName = L"";
  105. UserName = L"";
  106. RemoteDirectory = L"";
  107. LocalDirectory = L"";
  108. }
  109. //---------------------------------------------------------------------------
  110. //---------------------------------------------------------------------------
  111. __fastcall TCopyParamRule::TCopyParamRule()
  112. {
  113. }
  114. //---------------------------------------------------------------------------
  115. __fastcall TCopyParamRule::TCopyParamRule(const TCopyParamRuleData & Data)
  116. {
  117. FData = Data;
  118. }
  119. //---------------------------------------------------------------------------
  120. __fastcall TCopyParamRule::TCopyParamRule(const TCopyParamRule & Source)
  121. {
  122. FData.HostName = Source.FData.HostName;
  123. FData.UserName = Source.FData.UserName;
  124. FData.RemoteDirectory = Source.FData.RemoteDirectory;
  125. FData.LocalDirectory = Source.FData.LocalDirectory;
  126. }
  127. //---------------------------------------------------------------------------
  128. #define C(Property) (Property == rhp.Property)
  129. bool __fastcall TCopyParamRule::operator==(const TCopyParamRule & rhp) const
  130. {
  131. return
  132. C(FData.HostName) &&
  133. C(FData.UserName) &&
  134. C(FData.RemoteDirectory) &&
  135. C(FData.LocalDirectory) &&
  136. true;
  137. }
  138. #undef C
  139. //---------------------------------------------------------------------------
  140. bool __fastcall TCopyParamRule::Match(const UnicodeString & Mask,
  141. const UnicodeString & Value, bool Path, bool Local) const
  142. {
  143. bool Result;
  144. if (Mask.IsEmpty())
  145. {
  146. Result = true;
  147. }
  148. else
  149. {
  150. TFileMasks M(Mask);
  151. if (Path)
  152. {
  153. Result = M.Matches(Value, Local, true);
  154. }
  155. else
  156. {
  157. Result = M.Matches(Value, false);
  158. }
  159. }
  160. return Result;
  161. }
  162. //---------------------------------------------------------------------------
  163. bool __fastcall TCopyParamRule::Matches(const TCopyParamRuleData & Value) const
  164. {
  165. return
  166. Match(FData.HostName, Value.HostName, false) &&
  167. Match(FData.UserName, Value.UserName, false) &&
  168. Match(FData.RemoteDirectory, Value.RemoteDirectory, true, false) &&
  169. Match(FData.LocalDirectory, Value.LocalDirectory, true, true);
  170. }
  171. //---------------------------------------------------------------------------
  172. void __fastcall TCopyParamRule::Load(THierarchicalStorage * Storage)
  173. {
  174. FData.HostName = Storage->ReadString(L"HostName", FData.HostName);
  175. FData.UserName = Storage->ReadString(L"UserName", FData.UserName);
  176. FData.RemoteDirectory = Storage->ReadString(L"RemoteDirectory", FData.RemoteDirectory);
  177. FData.LocalDirectory = Storage->ReadString(L"LocalDirectory", FData.LocalDirectory);
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TCopyParamRule::Save(THierarchicalStorage * Storage) const
  181. {
  182. Storage->WriteString(L"HostName", FData.HostName);
  183. Storage->WriteString(L"UserName", FData.UserName);
  184. Storage->WriteString(L"RemoteDirectory", FData.RemoteDirectory);
  185. Storage->WriteString(L"LocalDirectory", FData.LocalDirectory);
  186. }
  187. //---------------------------------------------------------------------------
  188. bool __fastcall TCopyParamRule::GetEmpty() const
  189. {
  190. return
  191. FData.HostName.IsEmpty() &&
  192. FData.UserName.IsEmpty() &&
  193. FData.RemoteDirectory.IsEmpty() &&
  194. FData.LocalDirectory.IsEmpty();
  195. }
  196. //---------------------------------------------------------------------------
  197. UnicodeString __fastcall TCopyParamRule::GetInfoStr(UnicodeString Separator) const
  198. {
  199. UnicodeString Result;
  200. #define ADD(FMT, ELEM) \
  201. if (!FData.ELEM.IsEmpty()) \
  202. Result += (Result.IsEmpty() ? UnicodeString() : Separator) + FMTLOAD(FMT, (FData.ELEM));
  203. ADD(COPY_RULE_HOSTNAME, HostName);
  204. ADD(COPY_RULE_USERNAME, UserName);
  205. ADD(COPY_RULE_REMOTE_DIR, RemoteDirectory);
  206. ADD(COPY_RULE_LOCAL_DIR, LocalDirectory);
  207. #undef ADD
  208. return Result;
  209. }
  210. //---------------------------------------------------------------------------
  211. //---------------------------------------------------------------------------
  212. UnicodeString TCopyParamList::FInvalidChars(L"/\\[]");
  213. //---------------------------------------------------------------------------
  214. __fastcall TCopyParamList::TCopyParamList()
  215. {
  216. Init();
  217. }
  218. //---------------------------------------------------------------------------
  219. void __fastcall TCopyParamList::Init()
  220. {
  221. FCopyParams = new TList();
  222. FRules = new TList();
  223. FNames = new TStringList();
  224. FNameList = NULL;
  225. FModified = false;
  226. }
  227. //---------------------------------------------------------------------------
  228. __fastcall TCopyParamList::~TCopyParamList()
  229. {
  230. Clear();
  231. delete FCopyParams;
  232. delete FRules;
  233. delete FNames;
  234. delete FNameList;
  235. }
  236. //---------------------------------------------------------------------------
  237. void __fastcall TCopyParamList::Reset()
  238. {
  239. SAFE_DESTROY(FNameList);
  240. FModified = false;
  241. }
  242. //---------------------------------------------------------------------
  243. void __fastcall TCopyParamList::Modify()
  244. {
  245. SAFE_DESTROY(FNameList);
  246. FModified = true;
  247. }
  248. //---------------------------------------------------------------------
  249. void __fastcall TCopyParamList::ValidateName(const UnicodeString Name)
  250. {
  251. if (Name.LastDelimiter(FInvalidChars) > 0)
  252. {
  253. throw Exception(FMTLOAD(ITEM_NAME_INVALID, (Name, FInvalidChars)));
  254. }
  255. }
  256. //---------------------------------------------------------------------------
  257. TCopyParamList & __fastcall TCopyParamList::operator=(const TCopyParamList & rhl)
  258. {
  259. Clear();
  260. for (int Index = 0; Index < rhl.Count; Index++)
  261. {
  262. TCopyParamType * CopyParam = new TCopyParamType(*rhl.CopyParams[Index]);
  263. TCopyParamRule * Rule = NULL;
  264. if (rhl.Rules[Index] != NULL)
  265. {
  266. Rule = new TCopyParamRule(*rhl.Rules[Index]);
  267. }
  268. Add(rhl.Names[Index], CopyParam, Rule);
  269. }
  270. // there should be comparison of with the assigned list, but we rely on caller
  271. // to do it instead (TGUIConfiguration::SetCopyParamList)
  272. Modify();
  273. return *this;
  274. }
  275. //---------------------------------------------------------------------------
  276. bool __fastcall TCopyParamList::operator==(const TCopyParamList & rhl) const
  277. {
  278. bool Result = (Count == rhl.Count);
  279. if (Result)
  280. {
  281. int i = 0;
  282. while ((i < Count) && Result)
  283. {
  284. Result =
  285. (Names[i] == rhl.Names[i]) &&
  286. CompareItem(i, rhl.CopyParams[i], rhl.Rules[i]);
  287. i++;
  288. }
  289. }
  290. return Result;
  291. }
  292. //---------------------------------------------------------------------------
  293. int __fastcall TCopyParamList::IndexOfName(const UnicodeString Name) const
  294. {
  295. return FNames->IndexOf(Name);
  296. }
  297. //---------------------------------------------------------------------------
  298. bool __fastcall TCopyParamList::CompareItem(int Index,
  299. const TCopyParamType * CopyParam, const TCopyParamRule * Rule) const
  300. {
  301. return
  302. ((*CopyParams[Index]) == *CopyParam) &&
  303. ((Rules[Index] == NULL) ?
  304. (Rule == NULL) :
  305. ((Rule != NULL) && (*Rules[Index]) == (*Rule)));
  306. }
  307. //---------------------------------------------------------------------------
  308. void __fastcall TCopyParamList::Clear()
  309. {
  310. for (int i = 0; i < Count; i++)
  311. {
  312. delete CopyParams[i];
  313. delete Rules[i];
  314. }
  315. FCopyParams->Clear();
  316. FRules->Clear();
  317. FNames->Clear();
  318. }
  319. //---------------------------------------------------------------------------
  320. void __fastcall TCopyParamList::Add(const UnicodeString Name,
  321. TCopyParamType * CopyParam, TCopyParamRule * Rule)
  322. {
  323. Insert(Count, Name, CopyParam, Rule);
  324. }
  325. //---------------------------------------------------------------------------
  326. void __fastcall TCopyParamList::Insert(int Index, const UnicodeString Name,
  327. TCopyParamType * CopyParam, TCopyParamRule * Rule)
  328. {
  329. assert(FNames->IndexOf(Name) < 0);
  330. FNames->Insert(Index, Name);
  331. assert(CopyParam != NULL);
  332. FCopyParams->Insert(Index, reinterpret_cast<TObject *>(CopyParam));
  333. FRules->Insert(Index, reinterpret_cast<TObject *>(Rule));
  334. Modify();
  335. }
  336. //---------------------------------------------------------------------------
  337. void __fastcall TCopyParamList::Change(int Index, const UnicodeString Name,
  338. TCopyParamType * CopyParam, TCopyParamRule * Rule)
  339. {
  340. if ((Name != Names[Index]) || !CompareItem(Index, CopyParam, Rule))
  341. {
  342. FNames->Strings[Index] = Name;
  343. delete CopyParams[Index];
  344. FCopyParams->Items[Index] = (reinterpret_cast<TObject *>(CopyParam));
  345. delete Rules[Index];
  346. FRules->Items[Index] = (reinterpret_cast<TObject *>(Rule));
  347. Modify();
  348. }
  349. else
  350. {
  351. delete CopyParam;
  352. delete Rule;
  353. }
  354. }
  355. //---------------------------------------------------------------------------
  356. void __fastcall TCopyParamList::Move(int CurIndex, int NewIndex)
  357. {
  358. if (CurIndex != NewIndex)
  359. {
  360. FNames->Move(CurIndex, NewIndex);
  361. FCopyParams->Move(CurIndex, NewIndex);
  362. FRules->Move(CurIndex, NewIndex);
  363. Modify();
  364. }
  365. }
  366. //---------------------------------------------------------------------------
  367. void __fastcall TCopyParamList::Delete(int Index)
  368. {
  369. assert((Index >= 0) && (Index < Count));
  370. FNames->Delete(Index);
  371. delete CopyParams[Index];
  372. FCopyParams->Delete(Index);
  373. delete Rules[Index];
  374. FRules->Delete(Index);
  375. Modify();
  376. }
  377. //---------------------------------------------------------------------------
  378. int __fastcall TCopyParamList::Find(const TCopyParamRuleData & Value) const
  379. {
  380. int Result = -1;
  381. int i = 0;
  382. while ((i < FRules->Count) && (Result < 0))
  383. {
  384. if (FRules->Items[i] != NULL)
  385. {
  386. if (Rules[i]->Matches(Value))
  387. {
  388. Result = i;
  389. }
  390. }
  391. i++;
  392. }
  393. return Result;
  394. }
  395. //---------------------------------------------------------------------------
  396. void __fastcall TCopyParamList::Load(THierarchicalStorage * Storage, int ACount)
  397. {
  398. for (int Index = 0; Index < ACount; Index++)
  399. {
  400. UnicodeString Name = IntToStr(Index);
  401. TCopyParamRule * Rule = NULL;
  402. TCopyParamType * CopyParam = new TCopyParamType();
  403. try
  404. {
  405. if (Storage->OpenSubKey(Name, false))
  406. {
  407. try
  408. {
  409. Name = Storage->ReadString(L"Name", Name);
  410. CopyParam->Load(Storage);
  411. if (Storage->ReadBool(L"HasRule", false))
  412. {
  413. Rule = new TCopyParamRule();
  414. Rule->Load(Storage);
  415. }
  416. }
  417. __finally
  418. {
  419. Storage->CloseSubKey();
  420. }
  421. }
  422. }
  423. catch(...)
  424. {
  425. delete CopyParam;
  426. delete Rule;
  427. throw;
  428. }
  429. FCopyParams->Add(reinterpret_cast<TObject *>(CopyParam));
  430. FRules->Add(reinterpret_cast<TObject *>(Rule));
  431. FNames->Add(Name);
  432. }
  433. Reset();
  434. }
  435. //---------------------------------------------------------------------------
  436. void __fastcall TCopyParamList::Save(THierarchicalStorage * Storage) const
  437. {
  438. Storage->ClearSubKeys();
  439. for (int Index = 0; Index < Count; Index++)
  440. {
  441. if (Storage->OpenSubKey(IntToStr(Index), true))
  442. {
  443. try
  444. {
  445. const TCopyParamType * CopyParam = CopyParams[Index];
  446. const TCopyParamRule * Rule = Rules[Index];
  447. Storage->WriteString(L"Name", Names[Index]);
  448. CopyParam->Save(Storage);
  449. Storage->WriteBool(L"HasRule", (Rule != NULL));
  450. if (Rule != NULL)
  451. {
  452. Rule->Save(Storage);
  453. }
  454. }
  455. __finally
  456. {
  457. Storage->CloseSubKey();
  458. }
  459. }
  460. }
  461. }
  462. //---------------------------------------------------------------------------
  463. int __fastcall TCopyParamList::GetCount() const
  464. {
  465. return FCopyParams->Count;
  466. }
  467. //---------------------------------------------------------------------------
  468. const TCopyParamRule * __fastcall TCopyParamList::GetRule(int Index) const
  469. {
  470. return reinterpret_cast<TCopyParamRule *>(FRules->Items[Index]);
  471. }
  472. //---------------------------------------------------------------------------
  473. const TCopyParamType * __fastcall TCopyParamList::GetCopyParam(int Index) const
  474. {
  475. return reinterpret_cast<TCopyParamType *>(FCopyParams->Items[Index]);
  476. }
  477. //---------------------------------------------------------------------------
  478. UnicodeString __fastcall TCopyParamList::GetName(int Index) const
  479. {
  480. return FNames->Strings[Index];
  481. }
  482. //---------------------------------------------------------------------------
  483. TStrings * __fastcall TCopyParamList::GetNameList() const
  484. {
  485. if (FNameList == NULL)
  486. {
  487. FNameList = new TStringList();
  488. for (int i = 0; i < Count; i++)
  489. {
  490. FNameList->Add(FNames->Strings[i]);
  491. }
  492. }
  493. return FNameList;
  494. }
  495. //---------------------------------------------------------------------------
  496. bool __fastcall TCopyParamList::GetAnyRule() const
  497. {
  498. bool Result = false;
  499. int i = 0;
  500. while ((i < Count) && !Result)
  501. {
  502. Result = (Rules[i] != NULL);
  503. i++;
  504. }
  505. return Result;
  506. }
  507. //---------------------------------------------------------------------------
  508. //---------------------------------------------------------------------------
  509. __fastcall TGUIConfiguration::TGUIConfiguration(): TConfiguration()
  510. {
  511. FLocale = 0;
  512. FLocales = new TStringList();
  513. FLastLocalesExts = L"*";
  514. dynamic_cast<TStringList*>(FLocales)->Sorted = true;
  515. dynamic_cast<TStringList*>(FLocales)->CaseSensitive = false;
  516. FCopyParamList = new TCopyParamList();
  517. CoreSetResourceModule(GetResourceModule());
  518. }
  519. //---------------------------------------------------------------------------
  520. __fastcall TGUIConfiguration::~TGUIConfiguration()
  521. {
  522. delete FLocales;
  523. delete FCopyParamList;
  524. }
  525. //---------------------------------------------------------------------------
  526. void __fastcall TGUIConfiguration::Default()
  527. {
  528. TConfiguration::Default();
  529. // reset before call to DefaultLocalized()
  530. FDefaultCopyParam.Default();
  531. FCopyParamListDefaults = true;
  532. DefaultLocalized();
  533. FIgnoreCancelBeforeFinish = TDateTime(0, 0, 3, 0);
  534. FContinueOnError = false;
  535. FConfirmCommandSession = true;
  536. FSynchronizeParams = TTerminal::spNoConfirmation | TTerminal::spPreviewChanges;
  537. FSynchronizeModeAuto = -1;
  538. FSynchronizeMode = TTerminal::smRemote;
  539. FMaxWatchDirectories = 500;
  540. FSynchronizeOptions = soRecurse | soSynchronizeAsk;
  541. FQueueTransfersLimit = 2;
  542. FQueueKeepDoneItems = true;
  543. FQueueKeepDoneItemsFor = 15;
  544. FQueueAutoPopup = true;
  545. FSessionRememberPassword = false;
  546. UnicodeString ProgramsFolder;
  547. SpecialFolderLocation(CSIDL_PROGRAM_FILES, ProgramsFolder);
  548. FDefaultPuttyPathOnly = IncludeTrailingBackslash(ProgramsFolder) + L"PuTTY\\putty.exe";
  549. FDefaultPuttyPath = FormatCommand(L"%PROGRAMFILES%\\PuTTY\\putty.exe", L"");
  550. FPuttyPath = FDefaultPuttyPath;
  551. PSftpPath = FormatCommand(L"%PROGRAMFILES%\\PuTTY\\psftp.exe", L"");
  552. FPuttyPassword = false;
  553. FTelnetForFtpInPutty = true;
  554. FPuttySession = L"WinSCP temporary session";
  555. FBeepOnFinish = false;
  556. FBeepOnFinishAfter = TDateTime(0, 0, 30, 0);
  557. FCopyParamCurrent = L"";
  558. FKeepUpToDateChangeDelay = 500;
  559. FChecksumAlg = L"md5";
  560. FSessionReopenAutoIdle = 9000;
  561. FNewDirectoryProperties.Default();
  562. FNewDirectoryProperties.Rights = TRights::rfDefault | TRights::rfExec;
  563. }
  564. //---------------------------------------------------------------------------
  565. void __fastcall TGUIConfiguration::DefaultLocalized()
  566. {
  567. if (FCopyParamListDefaults)
  568. {
  569. FCopyParamList->Clear();
  570. // guard against "empty resource string" from obsolete traslations
  571. // (DefaultLocalized is called for the first time before detection of
  572. // obsolete translations)
  573. if (!LoadStr(COPY_PARAM_PRESET_ASCII).IsEmpty())
  574. {
  575. TCopyParamType * CopyParam;
  576. CopyParam = new TCopyParamType(FDefaultCopyParam);
  577. CopyParam->TransferMode = tmAscii;
  578. FCopyParamList->Add(LoadStr(COPY_PARAM_PRESET_ASCII), CopyParam, NULL);
  579. CopyParam = new TCopyParamType(FDefaultCopyParam);
  580. CopyParam->TransferMode = tmBinary;
  581. FCopyParamList->Add(LoadStr(COPY_PARAM_PRESET_BINARY), CopyParam, NULL);
  582. CopyParam = new TCopyParamType(FDefaultCopyParam);
  583. CopyParam->NewerOnly = true;
  584. FCopyParamList->Add(LoadStr(COPY_PARAM_NEWER_ONLY), CopyParam, NULL);
  585. }
  586. FCopyParamList->Reset();
  587. }
  588. }
  589. //---------------------------------------------------------------------------
  590. void __fastcall TGUIConfiguration::UpdateStaticUsage()
  591. {
  592. Usage->Set(L"CopyParamsCount", (FCopyParamListDefaults ? 0 : FCopyParamList->Count));
  593. }
  594. //---------------------------------------------------------------------------
  595. // duplicated from core\configuration.cpp
  596. #define BLOCK(KEY, CANCREATE, BLOCK) \
  597. if (Storage->OpenSubKey(KEY, CANCREATE, true)) try { BLOCK } __finally { Storage->CloseSubKey(); }
  598. #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, PropertyToKey(TEXT(#VAR)))
  599. #define REGCONFIG(CANCREATE) \
  600. BLOCK(L"Interface", CANCREATE, \
  601. KEY(Bool, ContinueOnError); \
  602. KEY(Bool, ConfirmCommandSession); \
  603. KEY(Integer, SynchronizeParams); \
  604. KEY(Integer, SynchronizeOptions); \
  605. KEY(Integer, SynchronizeModeAuto); \
  606. KEY(Integer, SynchronizeMode); \
  607. KEY(Integer, MaxWatchDirectories); \
  608. KEY(Integer, QueueTransfersLimit); \
  609. KEY(Integer, QueueKeepDoneItems); \
  610. KEY(Integer, QueueKeepDoneItemsFor); \
  611. KEY(Bool, QueueAutoPopup); \
  612. KEYEX(Bool, SessionRememberPassword, L"QueueRememberPassword"); \
  613. KEY(String, PuttySession); \
  614. KEY(String, PuttyPath); \
  615. KEY(Bool, PuttyPassword); \
  616. KEY(Bool, TelnetForFtpInPutty); \
  617. KEY(DateTime, IgnoreCancelBeforeFinish); \
  618. KEY(Bool, BeepOnFinish); \
  619. KEY(DateTime, BeepOnFinishAfter); \
  620. KEY(Integer, KeepUpToDateChangeDelay); \
  621. KEY(String, ChecksumAlg); \
  622. KEY(Integer, SessionReopenAutoIdle); \
  623. ); \
  624. //---------------------------------------------------------------------------
  625. void __fastcall TGUIConfiguration::SaveData(THierarchicalStorage * Storage, bool All)
  626. {
  627. TConfiguration::SaveData(Storage, All);
  628. // duplicated from core\configuration.cpp
  629. #define KEYEX(TYPE, VAR, NAME) Storage->Write ## TYPE(NAME, VAR)
  630. REGCONFIG(true);
  631. #undef KEYEX
  632. if (Storage->OpenSubKey(L"Interface\\CopyParam", true, true))
  633. try
  634. {
  635. FDefaultCopyParam.Save(Storage);
  636. if (FCopyParamListDefaults)
  637. {
  638. assert(!FCopyParamList->Modified);
  639. Storage->WriteInteger(L"CopyParamList", -1);
  640. }
  641. else if (All || FCopyParamList->Modified)
  642. {
  643. Storage->WriteInteger(L"CopyParamList", FCopyParamList->Count);
  644. FCopyParamList->Save(Storage);
  645. }
  646. }
  647. __finally
  648. {
  649. Storage->CloseSubKey();
  650. }
  651. if (Storage->OpenSubKey(L"Interface\\NewDirectory2", true, true))
  652. try
  653. {
  654. FNewDirectoryProperties.Save(Storage);
  655. }
  656. __finally
  657. {
  658. Storage->CloseSubKey();
  659. }
  660. }
  661. //---------------------------------------------------------------------------
  662. void __fastcall TGUIConfiguration::LoadData(THierarchicalStorage * Storage)
  663. {
  664. TConfiguration::LoadData(Storage);
  665. // duplicated from core\configuration.cpp
  666. #define KEYEX(TYPE, VAR, NAME) VAR = Storage->Read ## TYPE(NAME, VAR)
  667. #pragma warn -eas
  668. REGCONFIG(false);
  669. #pragma warn +eas
  670. #undef KEYEX
  671. if (Storage->OpenSubKey(L"Interface\\CopyParam", false, true))
  672. try
  673. {
  674. // must be loaded before eventual setting defaults for CopyParamList
  675. FDefaultCopyParam.Load(Storage);
  676. int CopyParamListCount = Storage->ReadInteger(L"CopyParamList", -1);
  677. FCopyParamListDefaults = (CopyParamListCount < 0);
  678. if (!FCopyParamListDefaults)
  679. {
  680. FCopyParamList->Clear();
  681. FCopyParamList->Load(Storage, CopyParamListCount);
  682. }
  683. else if (FCopyParamList->Modified)
  684. {
  685. FCopyParamList->Clear();
  686. FCopyParamListDefaults = false;
  687. }
  688. FCopyParamList->Reset();
  689. }
  690. __finally
  691. {
  692. Storage->CloseSubKey();
  693. }
  694. // Make it compatible with versions prior to 3.7.1 that have not saved PuttyPath
  695. // with quotes. First check for absence of quotes.
  696. // Add quotes either if the path is set to default putty path (even if it does
  697. // not exists) or when the path points to existing file (so there are no parameters
  698. // yet in the string). Note that FileExists may display error dialog, but as
  699. // it should be called only for custom users path, let's expect that the user
  700. // can take care of it.
  701. if ((FPuttyPath.SubString(1, 1) != L"\"") &&
  702. (CompareFileName(ExpandEnvironmentVariables(FPuttyPath), FDefaultPuttyPathOnly) ||
  703. FileExists(ExpandEnvironmentVariables(FPuttyPath))))
  704. {
  705. FPuttyPath = FormatCommand(FPuttyPath, L"");
  706. }
  707. if (Storage->OpenSubKey(L"Interface\\NewDirectory2", false, true))
  708. try
  709. {
  710. FNewDirectoryProperties.Load(Storage);
  711. }
  712. __finally
  713. {
  714. Storage->CloseSubKey();
  715. }
  716. }
  717. //---------------------------------------------------------------------------
  718. void __fastcall TGUIConfiguration::Saved()
  719. {
  720. TConfiguration::Saved();
  721. FCopyParamList->Reset();
  722. }
  723. //---------------------------------------------------------------------------
  724. //---------------------------------------------------------------------------
  725. HINSTANCE __fastcall TGUIConfiguration::LoadNewResourceModule(LCID ALocale,
  726. UnicodeString * FileName)
  727. {
  728. UnicodeString LibraryFileName;
  729. HINSTANCE NewInstance = 0;
  730. bool Internal = (ALocale == InternalLocale());
  731. if (!Internal)
  732. {
  733. UnicodeString Module;
  734. UnicodeString LocaleName;
  735. Module = ModuleFileName();
  736. if ((ALocale & AdditionaLanguageMask) != AdditionaLanguageMask)
  737. {
  738. wchar_t LocaleStr[4];
  739. GetLocaleInfo(ALocale, LOCALE_SABBREVLANGNAME, LocaleStr, LENOF(LocaleStr));
  740. LocaleName = LocaleStr;
  741. assert(!LocaleName.IsEmpty());
  742. }
  743. else
  744. {
  745. LocaleName = AdditionaLanguagePrefix +
  746. char(ALocale & ~AdditionaLanguageMask);
  747. }
  748. Module = ChangeFileExt(Module, UnicodeString(L".") + LocaleName);
  749. // Look for a potential language/country translation
  750. NewInstance = LoadLibraryEx(Module.c_str(), 0, LOAD_LIBRARY_AS_DATAFILE);
  751. if (!NewInstance)
  752. {
  753. // Finally look for a language only translation
  754. Module.SetLength(Module.Length() - 1);
  755. NewInstance = LoadLibraryEx(Module.c_str(), 0, LOAD_LIBRARY_AS_DATAFILE);
  756. if (NewInstance)
  757. {
  758. LibraryFileName = Module;
  759. }
  760. }
  761. else
  762. {
  763. LibraryFileName = Module;
  764. }
  765. }
  766. if (!NewInstance && !Internal)
  767. {
  768. throw Exception(FMTLOAD(LOCALE_LOAD_ERROR, (int(ALocale))));
  769. }
  770. else
  771. {
  772. if (Internal)
  773. {
  774. NewInstance = HInstance;
  775. }
  776. }
  777. if (FileName != NULL)
  778. {
  779. *FileName = LibraryFileName;
  780. }
  781. return NewInstance;
  782. }
  783. //---------------------------------------------------------------------------
  784. LCID __fastcall TGUIConfiguration::InternalLocale()
  785. {
  786. LCID Result;
  787. if (GetTranslationCount(ApplicationInfo) > 0)
  788. {
  789. TTranslation Translation;
  790. Translation = GetTranslation(ApplicationInfo, 0);
  791. Result = MAKELANGID(PRIMARYLANGID(Translation.Language), SUBLANG_DEFAULT);
  792. }
  793. else
  794. {
  795. assert(false);
  796. Result = 0;
  797. }
  798. return Result;
  799. }
  800. //---------------------------------------------------------------------------
  801. LCID __fastcall TGUIConfiguration::GetLocale()
  802. {
  803. if (!FLocale)
  804. {
  805. FLocale = InternalLocale();
  806. }
  807. return FLocale;
  808. }
  809. //---------------------------------------------------------------------------
  810. void __fastcall TGUIConfiguration::SetLocale(LCID value)
  811. {
  812. if (Locale != value)
  813. {
  814. HINSTANCE Module = LoadNewResourceModule(value);
  815. if (Module != NULL)
  816. {
  817. FLocale = value;
  818. SetResourceModule(Module);
  819. }
  820. else
  821. {
  822. assert(false);
  823. }
  824. }
  825. }
  826. //---------------------------------------------------------------------------
  827. void __fastcall TGUIConfiguration::SetLocaleSafe(LCID value)
  828. {
  829. if (Locale != value)
  830. {
  831. HINSTANCE Module;
  832. try
  833. {
  834. Module = LoadNewResourceModule(value);
  835. }
  836. catch(...)
  837. {
  838. // ignore any exception while loading locale
  839. Module = NULL;
  840. }
  841. if (Module != NULL)
  842. {
  843. FLocale = value;
  844. SetResourceModule(Module);
  845. }
  846. }
  847. }
  848. //---------------------------------------------------------------------------
  849. void __fastcall TGUIConfiguration::FreeResourceModule(HANDLE Instance)
  850. {
  851. TLibModule * MainModule = FindModule(HInstance);
  852. if ((unsigned)Instance != MainModule->Instance)
  853. {
  854. FreeLibrary(static_cast<HMODULE>(Instance));
  855. }
  856. }
  857. //---------------------------------------------------------------------------
  858. HANDLE __fastcall TGUIConfiguration::ChangeResourceModule(HANDLE Instance)
  859. {
  860. if (Instance == NULL)
  861. {
  862. Instance = HInstance;
  863. }
  864. TLibModule * MainModule = FindModule(HInstance);
  865. HANDLE Result = (HANDLE)MainModule->ResInstance;
  866. MainModule->ResInstance = (unsigned)Instance;
  867. CoreSetResourceModule(Instance);
  868. return Result;
  869. }
  870. //---------------------------------------------------------------------------
  871. HANDLE __fastcall TGUIConfiguration::GetResourceModule()
  872. {
  873. return (HANDLE)FindModule(HInstance)->ResInstance;
  874. }
  875. //---------------------------------------------------------------------------
  876. void __fastcall TGUIConfiguration::SetResourceModule(HINSTANCE Instance)
  877. {
  878. HANDLE PrevHandle = ChangeResourceModule(Instance);
  879. FreeResourceModule(PrevHandle);
  880. DefaultLocalized();
  881. }
  882. //---------------------------------------------------------------------------
  883. TStrings * __fastcall TGUIConfiguration::GetLocales()
  884. {
  885. UnicodeString LocalesExts;
  886. TStringList * Exts = new TStringList();
  887. try
  888. {
  889. Exts->Sorted = true;
  890. Exts->CaseSensitive = false;
  891. int FindAttrs = faReadOnly | faArchive;
  892. TSearchRec SearchRec;
  893. bool Found;
  894. Found = (bool)(FindFirst(ChangeFileExt(ModuleFileName(), L".*"),
  895. FindAttrs, SearchRec) == 0);
  896. try
  897. {
  898. UnicodeString Ext;
  899. while (Found)
  900. {
  901. Ext = ExtractFileExt(SearchRec.Name).UpperCase();
  902. if ((Ext.Length() >= 3) && (Ext != L".EXE") && (Ext != L".COM") &&
  903. (Ext != L".DLL") && (Ext != L".INI"))
  904. {
  905. Ext = Ext.SubString(2, Ext.Length() - 1);
  906. LocalesExts += Ext;
  907. Exts->Add(Ext);
  908. }
  909. Found = (FindNextChecked(SearchRec) == 0);
  910. }
  911. }
  912. __finally
  913. {
  914. FindClose(SearchRec);
  915. }
  916. if (FLastLocalesExts != LocalesExts)
  917. {
  918. FLastLocalesExts = LocalesExts;
  919. FLocales->Clear();
  920. TLanguages * Langs = LanguagesDEPF();
  921. int Ext, Index, Count;
  922. wchar_t LocaleStr[255];
  923. LCID Locale;
  924. Count = Langs->Count;
  925. Index = -1;
  926. while (Index < Count)
  927. {
  928. if (Index >= 0)
  929. {
  930. Locale = Langs->LocaleID[Index];
  931. Ext = Exts->IndexOf(Langs->Ext[Index]);
  932. if (Ext < 0)
  933. {
  934. Ext = Exts->IndexOf(Langs->Ext[Index].SubString(1, 2));
  935. if (Ext >= 0)
  936. {
  937. Locale = MAKELANGID(PRIMARYLANGID(Locale), SUBLANG_DEFAULT);
  938. }
  939. }
  940. if (Ext >= 0)
  941. {
  942. Exts->Objects[Ext] = reinterpret_cast<TObject*>(Locale);
  943. }
  944. else
  945. {
  946. Locale = 0;
  947. }
  948. }
  949. else
  950. {
  951. Locale = InternalLocale();
  952. }
  953. if (Locale)
  954. {
  955. UnicodeString Name;
  956. GetLocaleInfo(Locale, LOCALE_SENGLANGUAGE,
  957. LocaleStr, LENOF(LocaleStr));
  958. Name = LocaleStr;
  959. Name += L" - ";
  960. // LOCALE_SNATIVELANGNAME
  961. GetLocaleInfo(Locale, LOCALE_SLANGUAGE,
  962. LocaleStr, LENOF(LocaleStr));
  963. Name += LocaleStr;
  964. FLocales->AddObject(Name, reinterpret_cast<TObject*>(Locale));
  965. }
  966. Index++;
  967. }
  968. for (int Index = 0; Index < Exts->Count; Index++)
  969. {
  970. if ((Exts->Objects[Index] == NULL) &&
  971. (Exts->Strings[Index].Length() == 3) &&
  972. SameText(Exts->Strings[Index].SubString(1, 2), AdditionaLanguagePrefix))
  973. {
  974. UnicodeString LangName = GetFileFileInfoString(L"LangName",
  975. ChangeFileExt(ModuleFileName(), UnicodeString(L".") + Exts->Strings[Index]));
  976. if (!LangName.IsEmpty())
  977. {
  978. FLocales->AddObject(LangName, reinterpret_cast<TObject*>(
  979. AdditionaLanguageMask + Exts->Strings[Index][3]));
  980. }
  981. }
  982. }
  983. }
  984. }
  985. __finally
  986. {
  987. delete Exts;
  988. }
  989. return FLocales;
  990. }
  991. //---------------------------------------------------------------------------
  992. void __fastcall TGUIConfiguration::SetDefaultCopyParam(const TGUICopyParamType & value)
  993. {
  994. FDefaultCopyParam.Assign(&value);
  995. Changed();
  996. }
  997. //---------------------------------------------------------------------------
  998. bool __fastcall TGUIConfiguration::GetRememberPassword()
  999. {
  1000. return SessionRememberPassword || PuttyPassword;
  1001. }
  1002. //---------------------------------------------------------------------------
  1003. const TCopyParamList * __fastcall TGUIConfiguration::GetCopyParamList()
  1004. {
  1005. return FCopyParamList;
  1006. }
  1007. //---------------------------------------------------------------------------
  1008. void __fastcall TGUIConfiguration::SetCopyParamList(const TCopyParamList * value)
  1009. {
  1010. if (!(*FCopyParamList == *value))
  1011. {
  1012. *FCopyParamList = *value;
  1013. FCopyParamListDefaults = false;
  1014. Changed();
  1015. }
  1016. }
  1017. //---------------------------------------------------------------------------
  1018. int __fastcall TGUIConfiguration::GetCopyParamIndex()
  1019. {
  1020. int Result;
  1021. if (FCopyParamCurrent.IsEmpty())
  1022. {
  1023. Result = -1;
  1024. }
  1025. else
  1026. {
  1027. Result = FCopyParamList->IndexOfName(FCopyParamCurrent);
  1028. }
  1029. return Result;
  1030. }
  1031. //---------------------------------------------------------------------------
  1032. void __fastcall TGUIConfiguration::SetCopyParamIndex(int value)
  1033. {
  1034. UnicodeString Name;
  1035. if (value < 0)
  1036. {
  1037. Name = L"";
  1038. }
  1039. else
  1040. {
  1041. Name = FCopyParamList->Names[value];
  1042. }
  1043. CopyParamCurrent = Name;
  1044. }
  1045. //---------------------------------------------------------------------------
  1046. void __fastcall TGUIConfiguration::SetCopyParamCurrent(UnicodeString value)
  1047. {
  1048. SET_CONFIG_PROPERTY(CopyParamCurrent);
  1049. }
  1050. //---------------------------------------------------------------------------
  1051. TGUICopyParamType __fastcall TGUIConfiguration::GetCurrentCopyParam()
  1052. {
  1053. return CopyParamPreset[CopyParamCurrent];
  1054. }
  1055. //---------------------------------------------------------------------------
  1056. TGUICopyParamType __fastcall TGUIConfiguration::GetCopyParamPreset(UnicodeString Name)
  1057. {
  1058. TGUICopyParamType Result = FDefaultCopyParam;
  1059. if (!Name.IsEmpty())
  1060. {
  1061. int Index = FCopyParamList->IndexOfName(Name);
  1062. assert(Index >= 0);
  1063. if (Index >= 0)
  1064. {
  1065. const TCopyParamType * Preset = FCopyParamList->CopyParams[Index];
  1066. assert(Preset != NULL);
  1067. Result.Assign(Preset); // overwrite all but GUI options
  1068. // reset all options known not to be configurable per-preset
  1069. // kind of hack
  1070. Result.ResumeSupport = FDefaultCopyParam.ResumeSupport;
  1071. Result.ResumeThreshold = FDefaultCopyParam.ResumeThreshold;
  1072. Result.LocalInvalidChars = FDefaultCopyParam.LocalInvalidChars;
  1073. }
  1074. }
  1075. return Result;
  1076. }
  1077. //---------------------------------------------------------------------------
  1078. bool __fastcall TGUIConfiguration::GetHasCopyParamPreset(UnicodeString Name)
  1079. {
  1080. return Name.IsEmpty() || (FCopyParamList->IndexOfName(Name) >= 0);
  1081. }
  1082. //---------------------------------------------------------------------------
  1083. void __fastcall TGUIConfiguration::SetNewDirectoryProperties(
  1084. const TRemoteProperties & value)
  1085. {
  1086. SET_CONFIG_PROPERTY(NewDirectoryProperties);
  1087. }
  1088. //---------------------------------------------------------------------------
  1089. void __fastcall TGUIConfiguration::SetQueueTransfersLimit(int value)
  1090. {
  1091. SET_CONFIG_PROPERTY(QueueTransfersLimit);
  1092. }
  1093. //---------------------------------------------------------------------------
  1094. void __fastcall TGUIConfiguration::SetQueueKeepDoneItems(bool value)
  1095. {
  1096. SET_CONFIG_PROPERTY(QueueKeepDoneItems);
  1097. }
  1098. //---------------------------------------------------------------------------
  1099. void __fastcall TGUIConfiguration::SetQueueKeepDoneItemsFor(int value)
  1100. {
  1101. SET_CONFIG_PROPERTY(QueueKeepDoneItemsFor);
  1102. }
  1103. //---------------------------------------------------------------------
  1104. TStoredSessionList * __fastcall TGUIConfiguration::SelectPuttySessionsForImport(
  1105. TStoredSessionList * Sessions)
  1106. {
  1107. std::auto_ptr<TStoredSessionList> ImportSessionList(new TStoredSessionList(true));
  1108. ImportSessionList->DefaultSettings = Sessions->DefaultSettings;
  1109. std::auto_ptr<TRegistryStorage> Storage(new TRegistryStorage(PuttySessionsKey));
  1110. Storage->ForceAnsi = true;
  1111. if (Storage->OpenRootKey(false))
  1112. {
  1113. ImportSessionList->Load(Storage.get(), false, true);
  1114. }
  1115. TSessionData * PuttySessionData =
  1116. (TSessionData *)ImportSessionList->FindByName(PuttySession);
  1117. if (PuttySessionData != NULL)
  1118. {
  1119. ImportSessionList->Remove(PuttySessionData);
  1120. }
  1121. ImportSessionList->SelectSessionsToImport(Sessions, true);
  1122. return ImportSessionList.release();
  1123. }
  1124. //---------------------------------------------------------------------
  1125. bool __fastcall TGUIConfiguration::AnyPuttySessionForImport(TStoredSessionList * Sessions)
  1126. {
  1127. try
  1128. {
  1129. std::auto_ptr<TStoredSessionList> Sesssions(SelectPuttySessionsForImport(Sessions));
  1130. return (Sesssions->Count > 0);
  1131. }
  1132. catch (...)
  1133. {
  1134. return false;
  1135. }
  1136. }
  1137. //---------------------------------------------------------------------
  1138. TStoredSessionList * __fastcall TGUIConfiguration::SelectFilezillaSessionsForImport(
  1139. TStoredSessionList * Sessions)
  1140. {
  1141. std::auto_ptr<TStoredSessionList> ImportSessionList(new TStoredSessionList(true));
  1142. ImportSessionList->DefaultSettings = Sessions->DefaultSettings;
  1143. UnicodeString AppDataPath = GetShellFolderPath(CSIDL_APPDATA);
  1144. UnicodeString FilezillaSiteManagerFile =
  1145. IncludeTrailingBackslash(AppDataPath) + L"FileZilla\\sitemanager.xml";
  1146. if (FileExists(FilezillaSiteManagerFile))
  1147. {
  1148. ImportSessionList->ImportFromFilezilla(FilezillaSiteManagerFile);
  1149. ImportSessionList->SelectSessionsToImport(Sessions, true);
  1150. }
  1151. return ImportSessionList.release();
  1152. }
  1153. //---------------------------------------------------------------------
  1154. bool __fastcall TGUIConfiguration::AnyFilezillaSessionForImport(TStoredSessionList * Sessions)
  1155. {
  1156. try
  1157. {
  1158. std::auto_ptr<TStoredSessionList> Sesssions(SelectFilezillaSessionsForImport(Sessions));
  1159. return (Sesssions->Count > 0);
  1160. }
  1161. catch (...)
  1162. {
  1163. return false;
  1164. }
  1165. }
  1166. //---------------------------------------------------------------------------