WinConfiguration.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "WinConfiguration.h"
  5. #include "Common.h"
  6. #include "Bookmarks.h"
  7. #include "TextsWin.h"
  8. #include <stdio.h>
  9. //---------------------------------------------------------------------------
  10. #define CSIDL_PERSONAL 0x0005 // My Documents
  11. #define CSIDL_PROGRAM_FILES 0x0026 // C:\Program Files
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. //---------------------------------------------------------------------------
  15. const char ShellCommandFileNamePattern[] = "!.!";
  16. //---------------------------------------------------------------------------
  17. __fastcall TWinConfiguration::TWinConfiguration(): TGUIConfiguration()
  18. {
  19. FBookmarks = new TBookmarks();
  20. FCommandsHistory = new TStringList();
  21. FCustomCommands = new TStringList();
  22. Default();
  23. }
  24. //---------------------------------------------------------------------------
  25. __fastcall TWinConfiguration::~TWinConfiguration()
  26. {
  27. if (!FTemporarySessionFile.IsEmpty()) DeleteFile(FTemporarySessionFile);
  28. ClearTemporaryLoginData();
  29. delete FBookmarks;
  30. delete FCommandsHistory;
  31. delete FCustomCommands;
  32. }
  33. //---------------------------------------------------------------------------
  34. void __fastcall TWinConfiguration::Default()
  35. {
  36. TGUIConfiguration::Default();
  37. FInterface = ifCommander;
  38. FDDAllowMove = false;
  39. FDDTransferConfirmation = true;
  40. FDDTemporaryDirectory = "";
  41. FDDWarnLackOfTempSpace = true;
  42. FDDWarnLackOfTempSpaceRatio = 1.1;
  43. FDeleteToRecycleBin = true;
  44. FMaskHistory = "";
  45. FSelectDirectories = false;
  46. FSelectMask = "*.*";
  47. FShowHiddenFiles = true;
  48. FShowInaccesibleDirectories = true;
  49. FShowAdvancedLoginOptions = false;
  50. FConfirmDeleting = true;
  51. FConfirmClosingSession = true;
  52. FCopyOnDoubleClick = false;
  53. FCopyOnDoubleClickConfirmation = false;
  54. FDimmHiddenFiles = true;
  55. FAutoStartSession = "";
  56. FExpertMode = true;
  57. FUseLocationProfiles = true;
  58. FContinueOnError = false;
  59. FPuttySession = "WinSCP temporary session";
  60. AnsiString ProgramsFolder;
  61. SpecialFolderLocation(CSIDL_PROGRAM_FILES, ProgramsFolder);
  62. FPuttyPath = IncludeTrailingBackslash(ProgramsFolder) + "PuTTY\\putty.exe";
  63. FEditor.Editor = edInternal;
  64. FEditor.ExternalEditor = "notepad.exe";
  65. FEditor.FontName = "Courier New";
  66. FEditor.FontHeight = -12;
  67. FEditor.FontStyle = 0;
  68. FEditor.FontCharset = DEFAULT_CHARSET;
  69. FEditor.WordWrap = false;
  70. FEditor.FindText = "";
  71. FEditor.ReplaceText = "";
  72. FEditor.FindMatchCase = false;
  73. FEditor.FindWholeWord = false;
  74. FLogView = lvNone;
  75. FLogWindowOnStartup = true;
  76. FLogWindowParams = "-1;-1;500;400";
  77. FScpExplorer.WindowParams = "-1;-1;600;400;0";
  78. FScpExplorer.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,1|0;1;2;3;4;5";
  79. FScpExplorer.CoolBarLayout = "6,0,1,196,6;2,1,0,531,5;5,1,1,103,4;3,0,1,127,3;4,1,0,636,2;1,1,1,636,1;0,1,1,636,0";
  80. FScpExplorer.StatusBar = true;
  81. AnsiString PersonalFolder;
  82. SpecialFolderLocation(CSIDL_PERSONAL, PersonalFolder);
  83. FScpExplorer.LastLocalTargetDirectory = PersonalFolder;
  84. FScpExplorer.ViewStyle = 0; /* vsIcon */
  85. FScpExplorer.ShowFullAddress = true;
  86. FScpCommander.WindowParams = "-1;-1;600;400;0";
  87. FScpCommander.LocalPanelWidth = 0.5;
  88. FScpCommander.StatusBar = true;
  89. FScpCommander.ToolBar = true;
  90. FScpCommander.ExplorerStyleSelection = false;
  91. FScpCommander.PreserveLocalDirectory = false;
  92. FScpCommander.CoolBarLayout = "5,0,0,219,6;1,1,0,319,5;4,0,0,227,4;3,1,0,136,3;6,1,0,121,2;2,1,1,67,1;0,1,1,649,0";
  93. FScpCommander.CurrentPanel = osLocal;
  94. FScpCommander.RemotePanel.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,0|0;1;2;3;4;5";
  95. FScpCommander.RemotePanel.StatusBar = true;
  96. FScpCommander.RemotePanel.CoolBarLayout = "2,1,0,137,2;1,1,0,86,1;0,1,1,91,0";
  97. FScpCommander.LocalPanel.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,0|0;1;2;3;4;5";
  98. FScpCommander.LocalPanel.StatusBar = true;
  99. FScpCommander.LocalPanel.CoolBarLayout = "2,1,0,137,2;1,1,0,86,1;0,1,1,91,0";
  100. FBookmarks->Clear();
  101. FCommandsHistory->Clear();
  102. FCommandsHistoryModified = false;
  103. FCustomCommands->Clear();
  104. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_EXECUTE)] =
  105. FORMAT("\"%s\"", (CustomCommandFileNamePattern));
  106. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_TOUCH)] =
  107. FORMAT("touch \"%s\"", (CustomCommandFileNamePattern));
  108. FCustomCommandsModified = false;
  109. }
  110. //---------------------------------------------------------------------------
  111. TStorage __fastcall TWinConfiguration::GetStorage()
  112. {
  113. if (FStorage == stDetect)
  114. {
  115. if (FindResourceEx(NULL, RT_RCDATA, "WINSCP_SESSION",
  116. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)))
  117. {
  118. FTemporarySessionFile = GetTemporaryPath() + "winscp3s.tmp";
  119. DumpResourceToFile("WINSCP_SESSION", FTemporarySessionFile);
  120. FEmbeddedSessions = true;
  121. FTemporaryKeyFile = GetTemporaryPath() + "winscp3k.tmp";
  122. if (!DumpResourceToFile("WINSCP_KEY", FTemporaryKeyFile))
  123. {
  124. FTemporaryKeyFile = "";
  125. }
  126. }
  127. }
  128. return TGUIConfiguration::GetStorage();
  129. }
  130. //---------------------------------------------------------------------------
  131. void __fastcall TWinConfiguration::ModifyAll()
  132. {
  133. TGUIConfiguration::ModifyAll();
  134. FBookmarks->ModifyAll(true);
  135. FCommandsHistoryModified = true;
  136. FCustomCommandsModified = true;
  137. }
  138. //---------------------------------------------------------------------------
  139. THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool SessionList)
  140. {
  141. if (SessionList && !FTemporarySessionFile.IsEmpty())
  142. {
  143. return new TIniFileStorage(FTemporarySessionFile);
  144. }
  145. else
  146. {
  147. return TGUIConfiguration::CreateScpStorage(SessionList);
  148. }
  149. }
  150. //---------------------------------------------------------------------------
  151. // duplicated from core\configuration.cpp
  152. #define LASTELEM(ELEM) \
  153. ELEM.SubString(ELEM.LastDelimiter(".>")+1, ELEM.Length() - ELEM.LastDelimiter(".>"))
  154. #define BLOCK(KEY, CANCREATE, BLOCK) \
  155. if (Storage->OpenSubKey(KEY, CANCREATE)) try { BLOCK } __finally { Storage->CloseSubKey(); }
  156. #define REGCONFIG(CANCREATE) \
  157. BLOCK("Interface", CANCREATE, \
  158. KEY(Bool, CopyOnDoubleClick); \
  159. KEY(Bool, CopyOnDoubleClickConfirmation); \
  160. KEY(Bool, DDAllowMove); \
  161. KEY(Bool, DDTransferConfirmation); \
  162. KEY(String, DDTemporaryDirectory); \
  163. KEY(Bool, DDWarnLackOfTempSpace); \
  164. KEY(Float, DDWarnLackOfTempSpaceRatio); \
  165. KEY(Bool, DeleteToRecycleBin); \
  166. KEY(Bool, DimmHiddenFiles); \
  167. KEY(Integer, Interface); \
  168. KEY(String, MaskHistory); \
  169. KEY(Bool, SelectDirectories); \
  170. KEY(String, SelectMask); \
  171. KEY(Bool, ShowHiddenFiles); \
  172. KEY(Bool, ShowInaccesibleDirectories); \
  173. KEY(Bool, ShowAdvancedLoginOptions); \
  174. KEY(Bool, ConfirmDeleting); \
  175. KEY(Bool, ConfirmClosingSession); \
  176. KEY(String, AutoStartSession); \
  177. KEY(Bool, UseLocationProfiles); \
  178. KEY(Bool, ContinueOnError); \
  179. KEY(String, PuttyPath); \
  180. KEY(String, PuttySession); \
  181. ); \
  182. BLOCK("Interface\\Editor", CANCREATE, \
  183. KEY(Integer, Editor.Editor); \
  184. KEY(String, Editor.ExternalEditor); \
  185. KEY(String, Editor.FontName); \
  186. KEY(Integer, Editor.FontHeight); \
  187. KEY(Integer, Editor.FontStyle); \
  188. KEY(Integer, Editor.FontCharset); \
  189. KEY(Bool, Editor.WordWrap); \
  190. KEY(String, Editor.FindText); \
  191. KEY(String, Editor.ReplaceText); \
  192. KEY(Bool, Editor.FindMatchCase); \
  193. KEY(Bool, Editor.FindWholeWord); \
  194. ); \
  195. BLOCK("Interface\\Explorer", CANCREATE, \
  196. KEY(String, ScpExplorer.CoolBarLayout); \
  197. KEY(String, ScpExplorer.DirViewParams); \
  198. KEY(String, ScpExplorer.LastLocalTargetDirectory); \
  199. KEY(Bool, ScpExplorer.StatusBar); \
  200. KEY(String, ScpExplorer.WindowParams); \
  201. KEY(Integer, ScpExplorer.ViewStyle); \
  202. KEY(Bool, ScpExplorer.ShowFullAddress); \
  203. ); \
  204. BLOCK("Interface\\Commander", CANCREATE, \
  205. KEY(String, ScpCommander.CoolBarLayout); \
  206. KEY(Integer, ScpCommander.CurrentPanel); \
  207. KEY(Float, ScpCommander.LocalPanelWidth); \
  208. KEY(Bool, ScpCommander.StatusBar); \
  209. KEY(Bool, ScpCommander.ToolBar); \
  210. KEY(String, ScpCommander.WindowParams); \
  211. KEY(Bool, ScpCommander.ExplorerStyleSelection); \
  212. KEY(Bool, ScpCommander.PreserveLocalDirectory); \
  213. ); \
  214. BLOCK("Interface\\Commander\\LocalPanel", CANCREATE, \
  215. KEY(String, ScpCommander.LocalPanel.CoolBarLayout); \
  216. KEY(String, ScpCommander.LocalPanel.DirViewParams); \
  217. KEY(Bool, ScpCommander.LocalPanel.StatusBar); \
  218. ); \
  219. BLOCK("Interface\\Commander\\RemotePanel", CANCREATE, \
  220. KEY(String, ScpCommander.RemotePanel.CoolBarLayout); \
  221. KEY(String, ScpCommander.RemotePanel.DirViewParams); \
  222. KEY(Bool, ScpCommander.RemotePanel.StatusBar); \
  223. ); \
  224. BLOCK("Logging", CANCREATE, \
  225. KEY(Integer, LogView); \
  226. KEY(Bool, LogWindowOnStartup); \
  227. KEY(String, LogWindowParams); \
  228. );
  229. //---------------------------------------------------------------------------
  230. void __fastcall TWinConfiguration::SaveSpecial(THierarchicalStorage * Storage)
  231. {
  232. TGUIConfiguration::SaveSpecial(Storage);
  233. // duplicated from core\configuration.cpp
  234. #define KEY(TYPE, VAR) Storage->Write ## TYPE(LASTELEM(AnsiString(#VAR)), VAR)
  235. REGCONFIG(true);
  236. #undef KEY
  237. if (Storage->OpenSubKey("Bookmarks", true))
  238. {
  239. FBookmarks->Save(Storage);
  240. Storage->CloseSubKey();
  241. }
  242. if (FCommandsHistoryModified && Storage->OpenSubKey("Commands", true))
  243. {
  244. Storage->WriteValues(FCommandsHistory);
  245. Storage->CloseSubKey();
  246. FCommandsHistoryModified = false;
  247. }
  248. if (FCustomCommandsModified && Storage->OpenSubKey("CustomCommands", true))
  249. {
  250. Storage->WriteValues(FCustomCommands, true);
  251. Storage->CloseSubKey();
  252. FCustomCommandsModified = false;
  253. }
  254. }
  255. //---------------------------------------------------------------------------
  256. void __fastcall TWinConfiguration::LoadSpecial(THierarchicalStorage * Storage)
  257. {
  258. TGUIConfiguration::LoadSpecial(Storage);
  259. // duplicated from core\configuration.cpp
  260. #define KEY(TYPE, VAR) VAR = Storage->Read ## TYPE(LASTELEM(AnsiString(#VAR)), VAR)
  261. #pragma warn -eas
  262. REGCONFIG(false);
  263. #pragma warn +eas
  264. #undef KEY
  265. if (Storage->OpenSubKey("Bookmarks", false))
  266. {
  267. FBookmarks->Load(Storage);
  268. Storage->CloseSubKey();
  269. }
  270. if (Storage->OpenSubKey("Commands", false))
  271. {
  272. FCommandsHistory->Clear();
  273. Storage->ReadValues(FCommandsHistory);
  274. Storage->CloseSubKey();
  275. }
  276. else if (FCommandsHistoryModified)
  277. {
  278. FCommandsHistory->Clear();
  279. }
  280. FCommandsHistoryModified = false;
  281. if (Storage->OpenSubKey("CustomCommands", false))
  282. {
  283. FCustomCommands->Clear();
  284. Storage->ReadValues(FCustomCommands, true);
  285. Storage->CloseSubKey();
  286. }
  287. else if (FCustomCommandsModified)
  288. {
  289. FCustomCommands->Clear();
  290. }
  291. FCustomCommandsModified = false;
  292. }
  293. //---------------------------------------------------------------------------
  294. void __fastcall TWinConfiguration::LoadAdmin(THierarchicalStorage * Storage)
  295. {
  296. TConfiguration::LoadAdmin(Storage);
  297. FDisableOpenEdit = Storage->ReadBool("DisableOpenEdit", FDisableOpenEdit);
  298. }
  299. //---------------------------------------------------------------------------
  300. void __fastcall TWinConfiguration::ClearTemporaryLoginData()
  301. {
  302. if (!FTemporaryKeyFile.IsEmpty())
  303. {
  304. DeleteFile(FTemporaryKeyFile);
  305. FTemporaryKeyFile = "";
  306. }
  307. }
  308. //---------------------------------------------------------------------------
  309. bool __fastcall TWinConfiguration::DumpResourceToFile(
  310. const AnsiString ResName, const AnsiString FileName)
  311. {
  312. HRSRC Resource;
  313. Resource = FindResourceEx(NULL, RT_RCDATA, ResName.c_str(),
  314. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
  315. if (Resource)
  316. {
  317. unsigned long Size = SizeofResource(NULL, Resource);
  318. if (!Size)
  319. {
  320. throw Exception(FORMAT("Cannot get size of resource %s", (ResName)));
  321. }
  322. void * Content = LoadResource(NULL, Resource);
  323. if (!Content)
  324. {
  325. throw Exception(FORMAT("Cannot read resource %s", (ResName)));
  326. }
  327. Content = LockResource(Content);
  328. if (!Content)
  329. {
  330. throw Exception(FORMAT("Cannot lock resource %s", (ResName)));
  331. }
  332. FILE * f = fopen(FileName.c_str(), "wb");
  333. if (!f)
  334. {
  335. throw Exception(FORMAT("Cannot create file %s", (FileName)));
  336. }
  337. if (fwrite(Content, 1, Size, f) != Size)
  338. {
  339. throw Exception(FORMAT("Cannot write to file %s", (FileName)));
  340. }
  341. fclose(f);
  342. }
  343. return (Resource != NULL);
  344. }
  345. //---------------------------------------------------------------------------
  346. void __fastcall TWinConfiguration::RestoreForm(AnsiString Data, TCustomForm * Form)
  347. {
  348. assert(Form);
  349. if (!Data.IsEmpty())
  350. {
  351. TRect Bounds = Form->BoundsRect;
  352. Bounds.Left = StrToIntDef(CutToChar(Data, ';', true), Bounds.Left);
  353. Bounds.Top = StrToIntDef(CutToChar(Data, ';', true), Bounds.Top);
  354. Bounds.Right = StrToIntDef(CutToChar(Data, ';', true), Bounds.Right);
  355. Bounds.Bottom = StrToIntDef(CutToChar(Data, ';', true), Bounds.Bottom);
  356. TWindowState State = (TWindowState)StrToIntDef(CutToChar(Data, ';', true), (int)wsNormal);
  357. ((TForm*)Form)->WindowState = State;
  358. if (State == wsNormal)
  359. {
  360. if (Bounds.Width() > Screen->Width) Bounds.Right -= (Bounds.Width() - Screen->Width);
  361. if (Bounds.Height() > Screen->Height) Bounds.Bottom -= (Bounds.Height() - Screen->Height);
  362. Form->BoundsRect = Bounds;
  363. #define POS_RANGE(x, prop) (x < 0) || (x > Screen->prop)
  364. if (POS_RANGE(Bounds.Left, Width - 20) || POS_RANGE(Bounds.Top, Height - 40))
  365. {
  366. ((TForm*)Form)->Position = poDefaultPosOnly;
  367. }
  368. else
  369. {
  370. ((TForm*)Form)->Position = poDesigned;
  371. }
  372. #undef POS_RANGE
  373. }
  374. }
  375. else if (((TForm*)Form)->Position == poDesigned)
  376. {
  377. ((TForm*)Form)->Position = poDefaultPosOnly;
  378. }
  379. }
  380. //---------------------------------------------------------------------------
  381. AnsiString __fastcall TWinConfiguration::StoreForm(TCustomForm * Form)
  382. {
  383. assert(Form);
  384. return FORMAT("%d;%d;%d;%d;%d", ((int)Form->BoundsRect.Left, (int)Form->BoundsRect.Top,
  385. (int)Form->BoundsRect.Right, (int)Form->BoundsRect.Bottom,
  386. (int)Form->WindowState));
  387. }
  388. //---------------------------------------------------------------------
  389. void __fastcall TWinConfiguration::SetLogView(TLogView value)
  390. {
  391. SET_CONFIG_PROPERTY(LogView);
  392. }
  393. //---------------------------------------------------------------------------
  394. void __fastcall TWinConfiguration::SetLogWindowOnStartup(bool value)
  395. {
  396. SET_CONFIG_PROPERTY(LogWindowOnStartup);
  397. }
  398. //---------------------------------------------------------------------------
  399. void __fastcall TWinConfiguration::SetLogWindowParams(AnsiString value)
  400. {
  401. SET_CONFIG_PROPERTY(LogWindowParams);
  402. }
  403. //---------------------------------------------------------------------------
  404. void __fastcall TWinConfiguration::SetDDAllowMove(bool value)
  405. {
  406. SET_CONFIG_PROPERTY(DDAllowMove);
  407. }
  408. //---------------------------------------------------------------------------
  409. void __fastcall TWinConfiguration::SetDDTransferConfirmation(bool value)
  410. {
  411. SET_CONFIG_PROPERTY(DDTransferConfirmation);
  412. }
  413. //---------------------------------------------------------------------------
  414. void __fastcall TWinConfiguration::SetDDTemporaryDirectory(AnsiString value)
  415. {
  416. SET_CONFIG_PROPERTY(DDTemporaryDirectory);
  417. }
  418. //---------------------------------------------------------------------------
  419. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpace(bool value)
  420. {
  421. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpace);
  422. }
  423. //---------------------------------------------------------------------------
  424. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpaceRatio(double value)
  425. {
  426. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpaceRatio);
  427. }
  428. //---------------------------------------------------------------------------
  429. void __fastcall TWinConfiguration::SetMaskHistory(AnsiString value)
  430. {
  431. SET_CONFIG_PROPERTY(MaskHistory);
  432. }
  433. //---------------------------------------------------------------------------
  434. void __fastcall TWinConfiguration::SetScpExplorer(TScpExplorerConfiguration value)
  435. {
  436. SET_CONFIG_PROPERTY(ScpExplorer);
  437. }
  438. //---------------------------------------------------------------------------
  439. void __fastcall TWinConfiguration::SetScpCommander(TScpCommanderConfiguration value)
  440. {
  441. SET_CONFIG_PROPERTY(ScpCommander);
  442. }
  443. //---------------------------------------------------------------------------
  444. void __fastcall TWinConfiguration::SetEditor(TEditorConfiguration value)
  445. {
  446. SET_CONFIG_PROPERTY(Editor);
  447. }
  448. //---------------------------------------------------------------------------
  449. void __fastcall TWinConfiguration::SetInterface(TInterface value)
  450. {
  451. SET_CONFIG_PROPERTY(Interface);
  452. }
  453. //---------------------------------------------------------------------------
  454. void __fastcall TWinConfiguration::SetDeleteToRecycleBin(bool value)
  455. {
  456. SET_CONFIG_PROPERTY(DeleteToRecycleBin);
  457. }
  458. //---------------------------------------------------------------------------
  459. void __fastcall TWinConfiguration::SetSelectDirectories(bool value)
  460. {
  461. SET_CONFIG_PROPERTY(SelectDirectories);
  462. }
  463. //---------------------------------------------------------------------------
  464. void __fastcall TWinConfiguration::SetShowHiddenFiles(bool value)
  465. {
  466. SET_CONFIG_PROPERTY(ShowHiddenFiles);
  467. }
  468. //---------------------------------------------------------------------------
  469. void __fastcall TWinConfiguration::SetShowInaccesibleDirectories(bool value)
  470. {
  471. SET_CONFIG_PROPERTY(ShowInaccesibleDirectories);
  472. }
  473. //---------------------------------------------------------------------------
  474. void __fastcall TWinConfiguration::SetShowAdvancedLoginOptions(bool value)
  475. {
  476. SET_CONFIG_PROPERTY(ShowAdvancedLoginOptions);
  477. }
  478. //---------------------------------------------------------------------------
  479. void __fastcall TWinConfiguration::SetConfirmDeleting(bool value)
  480. {
  481. SET_CONFIG_PROPERTY(ConfirmDeleting);
  482. }
  483. //---------------------------------------------------------------------------
  484. void __fastcall TWinConfiguration::SetUseLocationProfiles(bool value)
  485. {
  486. SET_CONFIG_PROPERTY(UseLocationProfiles);
  487. }
  488. //---------------------------------------------------------------------------
  489. void __fastcall TWinConfiguration::SetContinueOnError(bool value)
  490. {
  491. SET_CONFIG_PROPERTY(ContinueOnError);
  492. }
  493. //---------------------------------------------------------------------------
  494. void __fastcall TWinConfiguration::SetConfirmClosingSession(bool value)
  495. {
  496. SET_CONFIG_PROPERTY(ConfirmClosingSession);
  497. }
  498. //---------------------------------------------------------------------------
  499. void __fastcall TWinConfiguration::SetCopyOnDoubleClick(bool value)
  500. {
  501. SET_CONFIG_PROPERTY(CopyOnDoubleClick);
  502. }
  503. //---------------------------------------------------------------------------
  504. void __fastcall TWinConfiguration::SetCopyOnDoubleClickConfirmation(bool value)
  505. {
  506. SET_CONFIG_PROPERTY(CopyOnDoubleClickConfirmation);
  507. }
  508. //---------------------------------------------------------------------------
  509. void __fastcall TWinConfiguration::SetDimmHiddenFiles(bool value)
  510. {
  511. SET_CONFIG_PROPERTY(DimmHiddenFiles);
  512. }
  513. //---------------------------------------------------------------------------
  514. void __fastcall TWinConfiguration::SetAutoStartSession(AnsiString value)
  515. {
  516. SET_CONFIG_PROPERTY(AutoStartSession);
  517. }
  518. //---------------------------------------------------------------------------
  519. void __fastcall TWinConfiguration::SetExpertMode(bool value)
  520. {
  521. SET_CONFIG_PROPERTY(ExpertMode);
  522. }
  523. //---------------------------------------------------------------------------
  524. void __fastcall TWinConfiguration::SetPuttyPath(const AnsiString value)
  525. {
  526. SET_CONFIG_PROPERTY(PuttyPath);
  527. }
  528. //---------------------------------------------------------------------------
  529. void __fastcall TWinConfiguration::SetPuttySession(const AnsiString value)
  530. {
  531. SET_CONFIG_PROPERTY(PuttySession);
  532. }
  533. //---------------------------------------------------------------------------
  534. void __fastcall TWinConfiguration::SetCommandsHistory(TStrings * value)
  535. {
  536. assert(FCommandsHistory);
  537. if (!FCommandsHistory->Equals(value))
  538. {
  539. FCommandsHistory->Assign(value);
  540. FCommandsHistoryModified = true;
  541. }
  542. }
  543. //---------------------------------------------------------------------------
  544. void __fastcall TWinConfiguration::SetCustomCommands(TStrings * value)
  545. {
  546. assert(FCustomCommands);
  547. if (!FCustomCommands->Equals(value))
  548. {
  549. FCustomCommands->Assign(value);
  550. FCustomCommandsModified = true;
  551. }
  552. }
  553. //---------------------------------------------------------------------------
  554. void __fastcall TWinConfiguration::SetBookmarks(AnsiString Key,
  555. TBookmarkList * value)
  556. {
  557. FBookmarks->Bookmarks[Key] = value;
  558. Changed();
  559. }
  560. //---------------------------------------------------------------------------
  561. TBookmarkList * __fastcall TWinConfiguration::GetBookmarks(AnsiString Key)
  562. {
  563. return FBookmarks->Bookmarks[Key];
  564. }
  565. //---------------------------------------------------------------------------
  566. void TWinConfiguration::ReformatFileNameCommand(AnsiString & Command)
  567. {
  568. AnsiString Program, Params, Dir;
  569. SplitCommand(Command, Program, Params, Dir);
  570. if (Params.Pos(ShellCommandFileNamePattern) == 0)
  571. {
  572. Params = Params + (Params.IsEmpty() ? "" : " ") + ShellCommandFileNamePattern;
  573. }
  574. Command = FormatCommand(Program, Params);
  575. }
  576. //---------------------------------------------------------------------------
  577. AnsiString __fastcall TWinConfiguration::GetDefaultKeyFile()
  578. {
  579. return FTemporaryKeyFile;
  580. }