WinConfiguration.cpp 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "WinConfiguration.h"
  5. #include "Common.h"
  6. #include "Exceptions.h"
  7. #include "Bookmarks.h"
  8. #include "Terminal.h"
  9. #include "TextsWin.h"
  10. #include "WinInterface.h"
  11. #include "GUITools.h"
  12. #include "Tools.h"
  13. #include <ResourceModule.hpp>
  14. #include <LanguagesDEPfix.hpp>
  15. #include <InitGUID.h>
  16. #include <DragExt.h>
  17. //---------------------------------------------------------------------------
  18. #pragma package(smart_init)
  19. //---------------------------------------------------------------------------
  20. //---------------------------------------------------------------------------
  21. __fastcall TEditorPreferences::TEditorPreferences()
  22. {
  23. FData.FileMask = "*.*";
  24. FData.Editor = edInternal;
  25. FData.ExternalEditor = "";
  26. FData.ExternalEditorText = true;
  27. FData.MDIExternalEditor = false;
  28. FData.DetectMDIExternalEditor = true;
  29. }
  30. //---------------------------------------------------------------------------
  31. __fastcall TEditorPreferences::TEditorPreferences(const TEditorPreferences & Source)
  32. {
  33. FData.FileMask = Source.FData.FileMask;
  34. FData.Editor = Source.FData.Editor;
  35. FData.ExternalEditor = Source.FData.ExternalEditor;
  36. FData.ExternalEditorText = Source.FData.ExternalEditorText;
  37. FData.MDIExternalEditor = Source.FData.MDIExternalEditor;
  38. FData.DetectMDIExternalEditor = Source.FData.DetectMDIExternalEditor;
  39. }
  40. //---------------------------------------------------------------------------
  41. #define C(Property) (Property == rhp.Property)
  42. bool __fastcall TEditorPreferences::operator==(const TEditorPreferences & rhp) const
  43. {
  44. return
  45. C(FData.FileMask) &&
  46. C(FData.Editor) &&
  47. C(FData.ExternalEditor) &&
  48. C(FData.ExternalEditorText) &&
  49. C(FData.MDIExternalEditor) &&
  50. C(FData.DetectMDIExternalEditor) &&
  51. true;
  52. }
  53. #undef C
  54. //---------------------------------------------------------------------------
  55. bool __fastcall TEditorPreferences::Matches(const AnsiString FileName,
  56. bool Local, const TFileMasks::TParams & Params) const
  57. {
  58. return FData.FileMask.Matches(FileName, Local, false, &Params);
  59. }
  60. //---------------------------------------------------------------------------
  61. void __fastcall TEditorPreferences::LegacyDefaults()
  62. {
  63. FData.ExternalEditor = "notepad.exe";
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TEditorPreferences::Load(THierarchicalStorage * Storage, bool Legacy)
  67. {
  68. if (!Legacy)
  69. {
  70. FData.FileMask = Storage->ReadString("FileMask", FData.FileMask.Masks);
  71. }
  72. FData.Editor = (TEditor)Storage->ReadInteger("Editor", FData.Editor);
  73. FData.ExternalEditor = Storage->ReadString("ExternalEditor", FData.ExternalEditor);
  74. FData.ExternalEditorText = Storage->ReadBool("ExternalEditorText", FData.ExternalEditorText);
  75. FData.MDIExternalEditor = Storage->ReadBool("MDIExternalEditor", FData.MDIExternalEditor);
  76. FData.DetectMDIExternalEditor = Storage->ReadBool("DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TEditorPreferences::Save(THierarchicalStorage * Storage) const
  80. {
  81. Storage->WriteString("FileMask", FData.FileMask.Masks);
  82. Storage->WriteInteger("Editor", FData.Editor);
  83. Storage->WriteString("ExternalEditor", FData.ExternalEditor);
  84. Storage->WriteBool("ExternalEditorText", FData.ExternalEditorText);
  85. Storage->WriteBool("MDIExternalEditor", FData.MDIExternalEditor);
  86. Storage->WriteBool("DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
  87. }
  88. //---------------------------------------------------------------------------
  89. AnsiString __fastcall TEditorPreferences::GetName() const
  90. {
  91. if (FName.IsEmpty())
  92. {
  93. if (FData.Editor == edInternal)
  94. {
  95. FName = StripHotkey(LoadStr(INTERNAL_EDITOR_NAME));
  96. }
  97. else
  98. {
  99. AnsiString Program, Params, Dir;
  100. AnsiString ExternalEditor = FData.ExternalEditor;
  101. ReformatFileNameCommand(ExternalEditor);
  102. SplitCommand(ExternalEditor, Program, Params, Dir);
  103. FName = ExtractFileName(Program);
  104. int P = FName.LastDelimiter(".");
  105. if (P > 0)
  106. {
  107. FName.SetLength(P - 1);
  108. }
  109. if (FName.ByteType(1) == mbSingleByte)
  110. {
  111. if (FName.UpperCase() == FName)
  112. {
  113. FName = FName.LowerCase();
  114. }
  115. if (FName.LowerCase() == FName)
  116. {
  117. FName = FName.SubString(1, 1).UpperCase() +
  118. FName.SubString(2, FName.Length() - 1);
  119. }
  120. }
  121. }
  122. }
  123. return FName;
  124. }
  125. //---------------------------------------------------------------------------
  126. //---------------------------------------------------------------------------
  127. __fastcall TEditorList::TEditorList()
  128. {
  129. Init();
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TEditorList::Init()
  133. {
  134. FEditors = new TList();
  135. FModified = false;
  136. }
  137. //---------------------------------------------------------------------------
  138. __fastcall TEditorList::~TEditorList()
  139. {
  140. Clear();
  141. delete FEditors;
  142. }
  143. //---------------------------------------------------------------------
  144. void __fastcall TEditorList::Modify()
  145. {
  146. FModified = true;
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TEditorList::Saved()
  150. {
  151. FModified = false;
  152. }
  153. //---------------------------------------------------------------------------
  154. void __fastcall TEditorList::operator=(const TEditorList & rhl)
  155. {
  156. Clear();
  157. for (int Index = 0; Index < rhl.Count; Index++)
  158. {
  159. Add(new TEditorPreferences(*rhl.Editors[Index]));
  160. }
  161. // there should be comparison of with the assigned list, be we rely on caller
  162. // to do it instead (TWinConfiguration::SetEditorList)
  163. Modify();
  164. }
  165. //---------------------------------------------------------------------------
  166. bool __fastcall TEditorList::operator==(const TEditorList & rhl) const
  167. {
  168. bool Result = (Count == rhl.Count);
  169. if (Result)
  170. {
  171. int i = 0;
  172. while ((i < Count) && Result)
  173. {
  174. Result = (*Editors[i]) == (*rhl.Editors[i]);
  175. i++;
  176. }
  177. }
  178. return Result;
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TEditorList::Clear()
  182. {
  183. for (int i = 0; i < Count; i++)
  184. {
  185. delete Editors[i];
  186. }
  187. FEditors->Clear();
  188. }
  189. //---------------------------------------------------------------------------
  190. void __fastcall TEditorList::Add(TEditorPreferences * Editor)
  191. {
  192. Insert(Count, Editor);
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TEditorList::Insert(int Index, TEditorPreferences * Editor)
  196. {
  197. FEditors->Insert(Index, reinterpret_cast<TObject *>(Editor));
  198. Modify();
  199. }
  200. //---------------------------------------------------------------------------
  201. void __fastcall TEditorList::Change(int Index, TEditorPreferences * Editor)
  202. {
  203. if (!((*Editors[Index]) == *Editor))
  204. {
  205. delete Editors[Index];
  206. FEditors->Items[Index] = (reinterpret_cast<TObject *>(Editor));
  207. Modify();
  208. }
  209. else
  210. {
  211. delete Editor;
  212. }
  213. }
  214. //---------------------------------------------------------------------------
  215. void __fastcall TEditorList::Move(int CurIndex, int NewIndex)
  216. {
  217. if (CurIndex != NewIndex)
  218. {
  219. FEditors->Move(CurIndex, NewIndex);
  220. Modify();
  221. }
  222. }
  223. //---------------------------------------------------------------------------
  224. void __fastcall TEditorList::Delete(int Index)
  225. {
  226. assert((Index >= 0) && (Index < Count));
  227. delete Editors[Index];
  228. FEditors->Delete(Index);
  229. Modify();
  230. }
  231. //---------------------------------------------------------------------------
  232. const TEditorPreferences * __fastcall TEditorList::Find(
  233. const AnsiString FileName, bool Local, const TFileMasks::TParams & Params) const
  234. {
  235. const TEditorPreferences * Result = NULL;
  236. int i = 0;
  237. while ((i < FEditors->Count) && (Result == NULL))
  238. {
  239. Result = Editors[i];
  240. if (!Result->Matches(FileName, Local, Params))
  241. {
  242. Result = NULL;
  243. }
  244. i++;
  245. }
  246. return Result;
  247. }
  248. //---------------------------------------------------------------------------
  249. void __fastcall TEditorList::Load(THierarchicalStorage * Storage)
  250. {
  251. int Index = 0;
  252. bool Next;
  253. do
  254. {
  255. AnsiString Name = IntToStr(Index);
  256. TEditorPreferences * Editor = NULL;
  257. try
  258. {
  259. Next = Storage->OpenSubKey(Name, false);
  260. if (Next)
  261. {
  262. try
  263. {
  264. Editor = new TEditorPreferences();
  265. Editor->Load(Storage, false);
  266. }
  267. __finally
  268. {
  269. Storage->CloseSubKey();
  270. }
  271. }
  272. }
  273. catch(...)
  274. {
  275. delete Editor;
  276. throw;
  277. }
  278. if (Editor != NULL)
  279. {
  280. FEditors->Add(reinterpret_cast<TObject *>(Editor));
  281. }
  282. Index++;
  283. }
  284. while (Next);
  285. FModified = false;
  286. }
  287. //---------------------------------------------------------------------------
  288. void __fastcall TEditorList::Save(THierarchicalStorage * Storage) const
  289. {
  290. Storage->ClearSubKeys();
  291. for (int Index = 0; Index < Count; Index++)
  292. {
  293. if (Storage->OpenSubKey(IntToStr(Index), true))
  294. {
  295. try
  296. {
  297. Editors[Index]->Save(Storage);
  298. }
  299. __finally
  300. {
  301. Storage->CloseSubKey();
  302. }
  303. }
  304. }
  305. }
  306. //---------------------------------------------------------------------------
  307. int __fastcall TEditorList::GetCount() const
  308. {
  309. int X = FEditors->Count;
  310. return X;
  311. }
  312. //---------------------------------------------------------------------------
  313. const TEditorPreferences * __fastcall TEditorList::GetEditor(int Index) const
  314. {
  315. return reinterpret_cast<TEditorPreferences *>(FEditors->Items[Index]);
  316. }
  317. //---------------------------------------------------------------------------
  318. //---------------------------------------------------------------------------
  319. __fastcall TWinConfiguration::TWinConfiguration(): TCustomWinConfiguration()
  320. {
  321. FInvalidDefaultTranslation = false;
  322. FDDExtInstalled = -1;
  323. FBookmarks = new TBookmarks();
  324. FCustomCommands = new TCustomCommands();
  325. FEditorList = new TEditorList();
  326. Default();
  327. try
  328. {
  329. FDefaultTranslationFile = ::GetResourceModule(ModuleFileName().c_str());
  330. CheckTranslationVersion(FDefaultTranslationFile, true);
  331. }
  332. catch(Exception & E)
  333. {
  334. FInvalidDefaultTranslationMessage = E.Message;
  335. FInvalidDefaultTranslation = true;
  336. }
  337. }
  338. //---------------------------------------------------------------------------
  339. __fastcall TWinConfiguration::~TWinConfiguration()
  340. {
  341. if (!FTemporarySessionFile.IsEmpty()) DeleteFile(FTemporarySessionFile);
  342. ClearTemporaryLoginData();
  343. delete FBookmarks;
  344. delete FCustomCommands;
  345. delete FEditorList;
  346. }
  347. //---------------------------------------------------------------------------
  348. void __fastcall TWinConfiguration::Default()
  349. {
  350. FCustomCommandsDefaults = true;
  351. TCustomWinConfiguration::Default();
  352. FDDAllowMove = false;
  353. FDDAllowMoveInit = false;
  354. FDDTransferConfirmation = true;
  355. FDDTemporaryDirectory = "";
  356. FDDWarnLackOfTempSpace = true;
  357. FDDWarnLackOfTempSpaceRatio = 1.1;
  358. FDDExtEnabled = DDExtInstalled;
  359. FDDExtTimeout = 1000;
  360. FDeleteToRecycleBin = true;
  361. FSelectDirectories = false;
  362. FSelectMask = "*.*";
  363. FShowHiddenFiles = true;
  364. FShowInaccesibleDirectories = true;
  365. FConfirmDeleting = true;
  366. FConfirmRecycling = true;
  367. FConfirmClosingSession = true;
  368. FConfirmExitOnCompletion = true;
  369. FForceDeleteTempFolder = true;
  370. FDoubleClickAction = dcaEdit;
  371. FCopyOnDoubleClickConfirmation = false;
  372. FDimmHiddenFiles = true;
  373. FAutoStartSession = "";
  374. FExpertMode = true;
  375. FUseLocationProfiles = false;
  376. FDefaultDirIsHome = true;
  377. FDDDeleteDelay = 120;
  378. FTemporaryDirectoryCleanup = true;
  379. FConfirmTemporaryDirectoryCleanup = true;
  380. FPreservePanelState = true;
  381. FTheme = "OfficeXP";
  382. FPathInCaption = picShort;
  383. FMinimizeToTray = false;
  384. FBalloonNotifications = true;
  385. FNotificationsTimeout = 10;
  386. FNotificationsStickTime = 2;
  387. FCopyParamAutoSelectNotice = true;
  388. FSessionToolbarAutoShown = false;
  389. FLockToolbars = false;
  390. FAutoOpenInPutty = false;
  391. FEditor.FontName = "Courier New";
  392. FEditor.FontHeight = -12;
  393. FEditor.FontStyle = 0;
  394. FEditor.FontCharset = DEFAULT_CHARSET;
  395. FEditor.WordWrap = false;
  396. FEditor.FindText = "";
  397. FEditor.ReplaceText = "";
  398. FEditor.FindMatchCase = false;
  399. FEditor.FindWholeWord = false;
  400. FEditor.SingleEditor = false;
  401. FEditor.MaxEditors = 500;
  402. FEditor.EarlyClose = 2; // seconds
  403. FQueueView.Height = 100;
  404. FQueueView.Layout = "70,160,160,80,80,80";
  405. FQueueView.Show = qvHideWhenEmpty;
  406. FQueueView.LastHideShow = qvHideWhenEmpty;
  407. FQueueView.ToolBar = false;
  408. FUpdates.Period = 0;
  409. FUpdates.LastCheck = 0;
  410. FUpdates.HaveResults = false;
  411. FUpdates.ShownResults = false;
  412. FUpdates.ProxyHost = "";
  413. FUpdates.ProxyPort = 8080;
  414. FUpdates.Results.Reset();
  415. FLogWindowOnStartup = true;
  416. FLogWindowParams = "-1;-1;500;400";
  417. FScpExplorer.WindowParams = "-1;-1;600;400;0";
  418. FScpExplorer.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,1;20,0;150,0;125,0|0;1;8;2;3;4;5;6;7";
  419. FScpExplorer.ToolbarsLayout =
  420. "Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
  421. "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
  422. "Buttons_Visible=1,Buttons_DockedTo=TopDock,Buttons_LastDock=TopDock,Buttons_DockRow=2,Buttons_DockPos=0,Buttons_FloatLeft=0,Buttons_FloatTop=0,Buttons_FloatRightX=0,"
  423. "Selection_Visible=0,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=3,Selection_DockPos=0,Selection_FloatLeft=227,Selection_FloatTop=445,Selection_FloatRightX=0,"
  424. "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=6,Session_DockPos=0,Session_FloatLeft=39,Session_FloatTop=160,Session_FloatRightX=0,"
  425. "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=4,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
  426. "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=5,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
  427. "Address_Visible=1,Address_DockedTo=TopDock,Address_LastDock=TopDock,Address_DockRow=1,Address_DockPos=0,Address_FloatLeft=0,Address_FloatTop=0,Address_FloatRightX=0,"
  428. "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=4,Updates_DockPos=302,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
  429. "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=4,Transfer_DockPos=155,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0"
  430. "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=7,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0";
  431. FScpExplorer.StatusBar = true;
  432. AnsiString PersonalFolder;
  433. ::SpecialFolderLocation(CSIDL_PERSONAL, PersonalFolder);
  434. FScpExplorer.LastLocalTargetDirectory = PersonalFolder;
  435. FScpExplorer.ViewStyle = 0; /* vsIcon */
  436. FScpExplorer.ShowFullAddress = true;
  437. FScpExplorer.DriveView = true;
  438. FScpExplorer.DriveViewWidth = 180;
  439. FScpExplorer.SessionComboWidth = 114;
  440. FScpCommander.WindowParams = ((Screen->Width > 800) && (Screen->Height > 650)) ?
  441. "-1;-1;750;600;0" : "-1;-1;600;400;0";
  442. FScpCommander.LocalPanelWidth = 0.5;
  443. FScpCommander.SwappedPanels = false;
  444. FScpCommander.StatusBar = true;
  445. FScpCommander.CommandLine = false;
  446. FScpCommander.NortonLikeMode = nlOn;
  447. FScpCommander.PreserveLocalDirectory = false;
  448. // Toolbar_FloatRightX=1 makes keybar apper initialy "in column" when undocked
  449. FScpCommander.ToolbarsLayout =
  450. "Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
  451. "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=4,Session_DockPos=0,Session_FloatLeft=380,Session_FloatTop=197,Session_FloatRightX=0,"
  452. "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=1,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
  453. "Selection_Visible=1,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=1,Selection_DockPos=257,Selection_FloatLeft=0,Selection_FloatTop=0,Selection_FloatRightX=0,"
  454. "Command_Visible=0,Command_DockedTo=TopDock,Command_LastDock=TopDock,Command_DockRow=2,Command_DockPos=0,Command_FloatLeft=0,Command_FloatTop=0,Command_FloatRightX=0,"
  455. "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=3,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
  456. "Commands_Visible=1,Commands_DockedTo=TopDock,Commands_LastDock=TopDock,Commands_DockRow=1,Commands_DockPos=97,Commands_FloatLeft=0,Commands_FloatTop=0,Commands_FloatRightX=0,"
  457. "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
  458. "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=1,Updates_DockPos=535,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
  459. "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=1,Transfer_DockPos=388,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0,"
  460. "UploadDownload_Visible=0,UploadDownload_DockedTo=TopDock,UploadDownload_LastDock=TopDock,UploadDownload_DockRow=5,UploadDownload_DockPos=0,UploadDownload_FloatLeft=0,UploadDownload_FloatTop=0,UploadDownload_FloatRightX=0,"
  461. "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=6,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0"
  462. "RemotePath_Visible=1,RemotePath_DockedTo=RemoteTopDock,RemotePath_LastDock=RemoteTopDock,RemotePath_DockRow=0,RemotePath_DockPos=0,RemotePath_FloatLeft=0,RemotePath_FloatTop=0,RemotePath_FloatRightX=0,"
  463. "RemoteHistory_Visible=1,RemoteHistory_DockedTo=RemoteTopDock,RemoteHistory_LastDock=RemoteTopDock,RemoteHistory_DockRow=0,RemoteHistory_DockPos=135,RemoteHistory_FloatLeft=0,RemoteHistory_FloatTop=0,RemoteHistory_FloatRightX=0,"
  464. "RemoteNavigation_Visible=1,RemoteNavigation_DockedTo=RemoteTopDock,RemoteNavigation_LastDock=RemoteTopDock,RemoteNavigation_DockRow=0,RemoteNavigation_DockPos=215,RemoteNavigation_FloatLeft=0,RemoteNavigation_FloatTop=0,RemoteNavigation_FloatRightX=0,"
  465. "LocalPath_Visible=1,LocalPath_DockedTo=LocalTopDock,LocalPath_LastDock=LocalTopDock,LocalPath_DockRow=0,LocalPath_DockPos=0,LocalPath_FloatLeft=0,LocalPath_FloatTop=0,LocalPath_FloatRightX=0,"
  466. "LocalHistory_Visible=1,LocalHistory_DockedTo=LocalTopDock,LocalHistory_LastDock=LocalTopDock,LocalHistory_DockRow=0,LocalHistory_DockPos=135,LocalHistory_FloatLeft=0,LocalHistory_FloatTop=0,LocalHistory_FloatRightX=0,"
  467. "LocalNavigation_Visible=1,LocalNavigation_DockedTo=LocalTopDock,LocalNavigation_LastDock=LocalTopDock,LocalNavigation_DockRow=0,LocalNavigation_DockPos=215,LocalNavigation_FloatLeft=0,LocalNavigation_FloatTop=0,LocalNavigation_FloatRightX=0,"
  468. "Toolbar_Visible=1,Toolbar_DockedTo=BottomDock,Toolbar_LastDock=BottomDock,Toolbar_DockRow=0,Toolbar_DockPos=0,Toolbar_FloatLeft=0,Toolbar_FloatTop=0,Toolbar_FloatRightX=1";
  469. FScpCommander.CurrentPanel = osLocal;
  470. FScpCommander.CompareByTime = true;
  471. FScpCommander.CompareBySize = false;
  472. FScpCommander.SessionComboWidth = 114;
  473. FScpCommander.FullRowSelect = true;
  474. FScpCommander.RemotePanel.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,0;20,0;150,0;125,0|0;1;8;2;3;4;5;6;7";
  475. FScpCommander.RemotePanel.StatusBar = true;
  476. FScpCommander.RemotePanel.DriveView = false;
  477. FScpCommander.RemotePanel.DriveViewHeight = 100;
  478. FScpCommander.LocalPanel.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,0|0;1;2;3;4;5";
  479. FScpCommander.LocalPanel.StatusBar = true;
  480. FScpCommander.LocalPanel.DriveView = false;
  481. FScpCommander.LocalPanel.DriveViewHeight = 100;
  482. FBookmarks->Clear();
  483. }
  484. //---------------------------------------------------------------------------
  485. void __fastcall TWinConfiguration::DefaultLocalized()
  486. {
  487. TGUIConfiguration::DefaultLocalized();
  488. if (FCustomCommandsDefaults)
  489. {
  490. FCustomCommands->Clear();
  491. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_EXECUTE)] = "\"!\"";
  492. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_EXECUTE)] = 0;
  493. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_TOUCH)] = "touch \"!\"";
  494. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_TOUCH)] = ccApplyToDirectories | ccRecursive;
  495. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_TAR)] =
  496. FORMAT("tar -cz -f \"!?%s?archive.tgz!\" !&",
  497. (LoadStr(CUSTOM_COMMAND_TAR_ARCHIVE)));
  498. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_TAR)] = ccApplyToDirectories;
  499. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_UNTAR)] =
  500. FORMAT("tar -xz --directory=\"!?%s?.!\" -f \"!\"",
  501. (LoadStr(CUSTOM_COMMAND_UNTAR_DIRECTORY)));
  502. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_UNTAR)] = 0;
  503. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_GREP)] =
  504. FORMAT("grep \"!?%s?!\" !&", (LoadStr(CUSTOM_COMMAND_GREP_PATTERN)));
  505. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_GREP)] = ccShowResults;
  506. if (Win32Platform == VER_PLATFORM_WIN32_NT)
  507. {
  508. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_FC)] =
  509. "cmd /c fc \"!\" \"\!^!\" | more && pause";
  510. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_FC)] = ccLocal;
  511. }
  512. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_DF)] = "df";
  513. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_DF)] = ccShowResults;
  514. FCustomCommandsDefaults = true;
  515. FCustomCommandsModified = false;
  516. }
  517. }
  518. //---------------------------------------------------------------------------
  519. bool __fastcall TWinConfiguration::DetectRegistryStorage(HKEY RootKey)
  520. {
  521. bool Result = false;
  522. TRegistryStorage * Storage = new TRegistryStorage(RegistryStorageKey, RootKey);
  523. try
  524. {
  525. if (Storage->OpenRootKey(false))
  526. {
  527. Result = true;
  528. Storage->CloseSubKey();
  529. }
  530. }
  531. __finally
  532. {
  533. delete Storage;
  534. }
  535. return Result;
  536. }
  537. //---------------------------------------------------------------------------
  538. bool __fastcall TWinConfiguration::CanWriteToStorage()
  539. {
  540. bool Result = false;
  541. try
  542. {
  543. THierarchicalStorage * Storage = CreateScpStorage(false);
  544. try
  545. {
  546. Storage->AccessMode = smReadWrite;
  547. if (Storage->OpenSubKey(ConfigurationSubKey, true))
  548. {
  549. Storage->WriteBool("WriteTest", true);
  550. Storage->DeleteValue("WriteTest");
  551. }
  552. }
  553. __finally
  554. {
  555. delete Storage;
  556. }
  557. Result = true;
  558. }
  559. catch(...)
  560. {
  561. }
  562. return Result;
  563. }
  564. //---------------------------------------------------------------------------
  565. TStorage __fastcall TWinConfiguration::GetStorage()
  566. {
  567. if (FStorage == stDetect)
  568. {
  569. if (FindResourceEx(NULL, RT_RCDATA, "WINSCP_SESSION",
  570. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)))
  571. {
  572. FTemporarySessionFile =
  573. IncludeTrailingBackslash(SystemTemporaryDirectory()) + "winscps.tmp";
  574. DumpResourceToFile("WINSCP_SESSION", FTemporarySessionFile);
  575. FEmbeddedSessions = true;
  576. FTemporaryKeyFile =
  577. IncludeTrailingBackslash(SystemTemporaryDirectory()) + "winscpk.tmp";
  578. if (!DumpResourceToFile("WINSCP_KEY", FTemporaryKeyFile))
  579. {
  580. FTemporaryKeyFile = "";
  581. }
  582. }
  583. FStorage = stIniFile;
  584. if (!FileExists(IniFileStorageName))
  585. {
  586. if (DetectRegistryStorage(HKEY_CURRENT_USER) ||
  587. DetectRegistryStorage(HKEY_LOCAL_MACHINE) ||
  588. !CanWriteToStorage())
  589. {
  590. FStorage = stRegistry;
  591. }
  592. }
  593. }
  594. return TCustomWinConfiguration::GetStorage();
  595. }
  596. //---------------------------------------------------------------------------
  597. void __fastcall TWinConfiguration::Saved()
  598. {
  599. TCustomWinConfiguration::Saved();
  600. FBookmarks->ModifyAll(false);
  601. FCustomCommandsModified = false;
  602. FEditorList->Saved();
  603. }
  604. //---------------------------------------------------------------------------
  605. THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool SessionList)
  606. {
  607. if (SessionList && !FTemporarySessionFile.IsEmpty())
  608. {
  609. return new TIniFileStorage(FTemporarySessionFile);
  610. }
  611. else
  612. {
  613. return TCustomWinConfiguration::CreateScpStorage(SessionList);
  614. }
  615. }
  616. //---------------------------------------------------------------------------
  617. // duplicated from core\configuration.cpp
  618. #define LASTELEM(ELEM) \
  619. ELEM.SubString(ELEM.LastDelimiter(".>")+1, ELEM.Length() - ELEM.LastDelimiter(".>"))
  620. #define BLOCK(KEY, CANCREATE, BLOCK) \
  621. if (Storage->OpenSubKey(KEY, CANCREATE)) try { BLOCK } __finally { Storage->CloseSubKey(); }
  622. #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, VAR)
  623. #define REGCONFIG(CANCREATE) \
  624. BLOCK("Interface", CANCREATE, \
  625. KEYEX(Integer,DoubleClickAction, CopyOnDoubleClick); \
  626. KEY(Bool, CopyOnDoubleClickConfirmation); \
  627. KEY(Bool, DDAllowMove); \
  628. KEY(Bool, DDAllowMoveInit); \
  629. KEY(Bool, DDTransferConfirmation); \
  630. KEY(String, DDTemporaryDirectory); \
  631. KEY(Bool, DDWarnLackOfTempSpace); \
  632. KEY(Float, DDWarnLackOfTempSpaceRatio); \
  633. KEY(Bool, DeleteToRecycleBin); \
  634. KEY(Bool, DimmHiddenFiles); \
  635. KEY(Bool, SelectDirectories); \
  636. KEY(String, SelectMask); \
  637. KEY(Bool, ShowHiddenFiles); \
  638. KEY(Bool, ShowInaccesibleDirectories); \
  639. KEY(Bool, ConfirmDeleting); \
  640. KEY(Bool, ConfirmRecycling); \
  641. KEY(Bool, ConfirmClosingSession); \
  642. KEY(Bool, ConfirmExitOnCompletion); \
  643. KEY(String, AutoStartSession); \
  644. KEY(Bool, UseLocationProfiles); \
  645. KEY(Bool, ForceDeleteTempFolder); \
  646. KEY(Integer, LocaleSafe); \
  647. KEY(Bool, DDExtEnabled); \
  648. KEY(Integer, DDExtTimeout); \
  649. KEY(Bool, DefaultDirIsHome); \
  650. KEY(Bool, TemporaryDirectoryCleanup); \
  651. KEY(Bool, ConfirmTemporaryDirectoryCleanup); \
  652. KEY(Bool, PreservePanelState); \
  653. KEY(String, Theme); \
  654. KEY(Integer, PathInCaption); \
  655. KEY(Bool, MinimizeToTray); \
  656. KEY(Bool, BalloonNotifications); \
  657. KEY(Integer, NotificationsTimeout); \
  658. KEY(Integer, NotificationsStickTime); \
  659. KEY(Bool, CopyParamAutoSelectNotice); \
  660. KEY(Bool, SessionToolbarAutoShown); \
  661. KEY(Bool, LockToolbars); \
  662. KEY(Bool, AutoOpenInPutty); \
  663. ); \
  664. BLOCK("Interface\\Editor", CANCREATE, \
  665. KEY(String, Editor.FontName); \
  666. KEY(Integer, Editor.FontHeight); \
  667. KEY(Integer, Editor.FontStyle); \
  668. KEY(Integer, Editor.FontCharset); \
  669. KEY(Bool, Editor.WordWrap); \
  670. KEY(String, Editor.FindText); \
  671. KEY(String, Editor.ReplaceText); \
  672. KEY(Bool, Editor.FindMatchCase); \
  673. KEY(Bool, Editor.FindWholeWord); \
  674. KEY(Bool, Editor.SingleEditor); \
  675. KEY(Integer, Editor.MaxEditors); \
  676. KEY(Integer, Editor.EarlyClose); \
  677. ); \
  678. BLOCK("Interface\\QueueView", CANCREATE, \
  679. KEY(Integer, QueueView.Height); \
  680. KEY(String, QueueView.Layout); \
  681. KEY(Integer, QueueView.Show); \
  682. KEY(Integer, QueueView.LastHideShow); \
  683. KEY(Bool, QueueView.ToolBar); \
  684. ); \
  685. BLOCK("Interface\\Updates", CANCREATE, \
  686. KEY(Integer, FUpdates.Period); \
  687. KEY(DateTime, FUpdates.LastCheck); \
  688. KEY(Integer, FUpdates.HaveResults); \
  689. KEY(Integer, FUpdates.ShownResults); \
  690. KEY(String, FUpdates.ProxyHost); \
  691. KEY(Integer, FUpdates.ProxyPort); \
  692. KEY(Integer, FUpdates.Results.ForVersion); \
  693. KEY(Integer, FUpdates.Results.Version); \
  694. KEY(String, FUpdates.Results.Message); \
  695. KEY(Integer, FUpdates.Results.Critical); \
  696. KEY(String, FUpdates.Results.Release); \
  697. KEY(Bool, FUpdates.Results.Disabled); \
  698. KEY(String, FUpdates.Results.Url); \
  699. KEY(String, FUpdates.Results.UrlButton); \
  700. ); \
  701. BLOCK("Interface\\Explorer", CANCREATE, \
  702. KEY(String, ScpExplorer.ToolbarsLayout); \
  703. KEY(String, ScpExplorer.DirViewParams); \
  704. KEY(String, ScpExplorer.LastLocalTargetDirectory); \
  705. KEY(Bool, ScpExplorer.StatusBar); \
  706. KEY(String, ScpExplorer.WindowParams); \
  707. KEY(Integer, ScpExplorer.ViewStyle); \
  708. KEY(Bool, ScpExplorer.ShowFullAddress); \
  709. KEY(Bool, ScpExplorer.DriveView); \
  710. KEY(Integer, ScpExplorer.DriveViewWidth); \
  711. KEY(Integer, ScpExplorer.SessionComboWidth); \
  712. ); \
  713. BLOCK("Interface\\Commander", CANCREATE, \
  714. KEY(String, ScpCommander.ToolbarsLayout); \
  715. KEY(Integer, ScpCommander.CurrentPanel); \
  716. KEY(Float, ScpCommander.LocalPanelWidth); \
  717. KEY(Bool, ScpCommander.SwappedPanels); \
  718. KEY(Bool, ScpCommander.StatusBar); \
  719. KEY(Bool, ScpCommander.CommandLine); \
  720. KEY(String, ScpCommander.WindowParams); \
  721. KEYEX(Integer, ScpCommander.NortonLikeMode, ExplorerStyleSelection); \
  722. KEY(Bool, ScpCommander.PreserveLocalDirectory); \
  723. KEY(Bool, ScpCommander.CompareByTime); \
  724. KEY(Bool, ScpCommander.CompareBySize); \
  725. KEY(Integer, ScpCommander.SessionComboWidth); \
  726. KEY(Bool, ScpCommander.FullRowSelect); \
  727. ); \
  728. BLOCK("Interface\\Commander\\LocalPanel", CANCREATE, \
  729. KEY(String, ScpCommander.LocalPanel.DirViewParams); \
  730. KEY(Bool, ScpCommander.LocalPanel.StatusBar); \
  731. KEY(Bool, ScpCommander.LocalPanel.DriveView); \
  732. KEY(Integer, ScpCommander.LocalPanel.DriveViewHeight); \
  733. ); \
  734. BLOCK("Interface\\Commander\\RemotePanel", CANCREATE, \
  735. KEY(String, ScpCommander.RemotePanel.DirViewParams); \
  736. KEY(Bool, ScpCommander.RemotePanel.StatusBar); \
  737. KEY(Bool, ScpCommander.RemotePanel.DriveView); \
  738. KEY(Integer, ScpCommander.RemotePanel.DriveViewHeight); \
  739. ); \
  740. BLOCK("Logging", CANCREATE, \
  741. KEY(Bool, LogWindowOnStartup); \
  742. KEY(String, LogWindowParams); \
  743. );
  744. //---------------------------------------------------------------------------
  745. void __fastcall TWinConfiguration::SaveData(THierarchicalStorage * Storage, bool All)
  746. {
  747. TCustomWinConfiguration::SaveData(Storage, All);
  748. // duplicated from core\configuration.cpp
  749. #define KEYEX(TYPE, VAR, NAME) Storage->Write ## TYPE(LASTELEM(AnsiString(#NAME)), VAR)
  750. REGCONFIG(true);
  751. #undef KEYEX
  752. if (Storage->OpenSubKey("Bookmarks", true))
  753. {
  754. FBookmarks->Save(Storage, All);
  755. Storage->CloseSubKey();
  756. }
  757. if ((All && !FCustomCommandsDefaults) || FCustomCommandsModified)
  758. {
  759. if (Storage->OpenSubKey("CustomCommands", true))
  760. {
  761. Storage->WriteValues(FCustomCommands, true);
  762. Storage->CloseSubKey();
  763. }
  764. if (Storage->OpenSubKey("CustomCommandsParams", true))
  765. {
  766. Storage->ClearValues();
  767. for (int Index = 0; Index < FCustomCommands->Count; Index++)
  768. {
  769. Storage->WriteInteger(FCustomCommands->Names[Index],
  770. FCustomCommands->Params[FCustomCommands->Names[Index]]);
  771. }
  772. Storage->CloseSubKey();
  773. }
  774. }
  775. if ((All || FEditorList->Modified) &&
  776. Storage->OpenSubKey("Interface\\Editor", true))
  777. try
  778. {
  779. FEditorList->Save(Storage);
  780. }
  781. __finally
  782. {
  783. Storage->CloseSubKey();
  784. }
  785. }
  786. //---------------------------------------------------------------------------
  787. void __fastcall TWinConfiguration::Load()
  788. {
  789. FLegacyEditor = new TEditorPreferences();
  790. try
  791. {
  792. FLegacyEditor->LegacyDefaults();
  793. TCustomWinConfiguration::Load();
  794. int EditorCount = FEditorList->Count;
  795. if (EditorCount == 0)
  796. {
  797. TEditorPreferences * AlternativeEditor = NULL;
  798. try
  799. {
  800. if (FLegacyEditor->Data.Editor == edInternal)
  801. {
  802. if (!FLegacyEditor->Data.ExternalEditor.IsEmpty())
  803. {
  804. AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
  805. AlternativeEditor->Data.Editor = edExternal;
  806. FLegacyEditor->Data.ExternalEditor = "";
  807. }
  808. }
  809. else
  810. {
  811. if (FLegacyEditor->Data.ExternalEditor.IsEmpty())
  812. {
  813. FLegacyEditor->Data.Editor = edInternal;
  814. }
  815. else
  816. {
  817. AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
  818. AlternativeEditor->Data.Editor = edInternal;
  819. }
  820. }
  821. }
  822. catch(...)
  823. {
  824. delete AlternativeEditor;
  825. throw;
  826. }
  827. FEditorList->Add(FLegacyEditor);
  828. FLegacyEditor = NULL;
  829. if (AlternativeEditor != NULL)
  830. {
  831. FEditorList->Add(AlternativeEditor);
  832. }
  833. }
  834. }
  835. __finally
  836. {
  837. delete FLegacyEditor;
  838. FLegacyEditor = NULL;
  839. }
  840. }
  841. //---------------------------------------------------------------------------
  842. void __fastcall TWinConfiguration::LoadData(THierarchicalStorage * Storage)
  843. {
  844. TCustomWinConfiguration::LoadData(Storage);
  845. // duplicated from core\configuration.cpp
  846. #define KEYEX(TYPE, VAR, NAME) VAR = Storage->Read ## TYPE(LASTELEM(AnsiString(#NAME)), VAR)
  847. #pragma warn -eas
  848. REGCONFIG(false);
  849. #pragma warn +eas
  850. #undef KEYEX
  851. if (Storage->OpenSubKey("Bookmarks", false))
  852. {
  853. FBookmarks->Load(Storage);
  854. Storage->CloseSubKey();
  855. }
  856. if (Storage->OpenSubKey("CustomCommands", false))
  857. {
  858. FCustomCommands->Clear();
  859. Storage->ReadValues(FCustomCommands, true);
  860. Storage->CloseSubKey();
  861. if (Storage->OpenSubKey("CustomCommandsParams", false))
  862. {
  863. for (int Index = 0; Index < FCustomCommands->Count; Index++)
  864. {
  865. AnsiString Name = FCustomCommands->Names[Index];
  866. FCustomCommands->Params[Name] =
  867. Storage->ReadInteger(Name, FCustomCommands->Params[Name]);
  868. }
  869. Storage->CloseSubKey();
  870. }
  871. FCustomCommandsDefaults = false;
  872. }
  873. else if (FCustomCommandsModified)
  874. {
  875. FCustomCommands->Clear();
  876. FCustomCommandsDefaults = false;
  877. }
  878. FCustomCommandsModified = false;
  879. if (Storage->OpenSubKey("Interface\\Editor", false))
  880. try
  881. {
  882. FEditorList->Clear();
  883. FEditorList->Load(Storage);
  884. }
  885. __finally
  886. {
  887. Storage->CloseSubKey();
  888. }
  889. // load legacy editor configuration
  890. assert(FLegacyEditor != NULL);
  891. if (Storage->OpenSubKey("Interface\\Editor", false))
  892. {
  893. try
  894. {
  895. FLegacyEditor->Load(Storage, true);
  896. }
  897. __finally
  898. {
  899. Storage->CloseSubKey();
  900. }
  901. }
  902. }
  903. //---------------------------------------------------------------------------
  904. void __fastcall TWinConfiguration::LoadAdmin(THierarchicalStorage * Storage)
  905. {
  906. TConfiguration::LoadAdmin(Storage);
  907. FDisableOpenEdit = Storage->ReadBool("DisableOpenEdit", FDisableOpenEdit);
  908. }
  909. //---------------------------------------------------------------------------
  910. void __fastcall TWinConfiguration::ClearTemporaryLoginData()
  911. {
  912. if (!FTemporaryKeyFile.IsEmpty())
  913. {
  914. DeleteFile(FTemporaryKeyFile);
  915. FTemporaryKeyFile = "";
  916. }
  917. }
  918. //---------------------------------------------------------------------------
  919. bool __fastcall TWinConfiguration::GetDDExtInstalled()
  920. {
  921. if (FDDExtInstalled < 0)
  922. {
  923. void* DragExtRef;
  924. bool Result;
  925. Result = (CoCreateInstance(CLSID_ShellExtension, NULL,
  926. CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown,
  927. &DragExtRef) == S_OK);
  928. FDDExtInstalled = (Result ? 1 : 0);
  929. }
  930. return (FDDExtInstalled > 0);
  931. }
  932. //---------------------------------------------------------------------------
  933. void __fastcall TWinConfiguration::SetLogWindowOnStartup(bool value)
  934. {
  935. SET_CONFIG_PROPERTY(LogWindowOnStartup);
  936. }
  937. //---------------------------------------------------------------------------
  938. void __fastcall TWinConfiguration::SetLogWindowParams(AnsiString value)
  939. {
  940. SET_CONFIG_PROPERTY(LogWindowParams);
  941. }
  942. //---------------------------------------------------------------------------
  943. void __fastcall TWinConfiguration::SetDDAllowMove(bool value)
  944. {
  945. SET_CONFIG_PROPERTY(DDAllowMove);
  946. }
  947. //---------------------------------------------------------------------------
  948. void __fastcall TWinConfiguration::SetDDAllowMoveInit(bool value)
  949. {
  950. SET_CONFIG_PROPERTY(DDAllowMoveInit);
  951. }
  952. //---------------------------------------------------------------------------
  953. void __fastcall TWinConfiguration::SetDDTransferConfirmation(bool value)
  954. {
  955. SET_CONFIG_PROPERTY(DDTransferConfirmation);
  956. }
  957. //---------------------------------------------------------------------------
  958. void __fastcall TWinConfiguration::SetDDTemporaryDirectory(AnsiString value)
  959. {
  960. SET_CONFIG_PROPERTY(DDTemporaryDirectory);
  961. }
  962. //---------------------------------------------------------------------------
  963. void __fastcall TWinConfiguration::SetDDExtEnabled(bool value)
  964. {
  965. SET_CONFIG_PROPERTY(DDExtEnabled);
  966. }
  967. //---------------------------------------------------------------------------
  968. void __fastcall TWinConfiguration::SetDDExtTimeout(int value)
  969. {
  970. SET_CONFIG_PROPERTY(DDExtTimeout);
  971. }
  972. //---------------------------------------------------------------------------
  973. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpace(bool value)
  974. {
  975. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpace);
  976. }
  977. //---------------------------------------------------------------------------
  978. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpaceRatio(double value)
  979. {
  980. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpaceRatio);
  981. }
  982. //---------------------------------------------------------------------------
  983. void __fastcall TWinConfiguration::SetScpExplorer(TScpExplorerConfiguration value)
  984. {
  985. SET_CONFIG_PROPERTY(ScpExplorer);
  986. }
  987. //---------------------------------------------------------------------------
  988. void __fastcall TWinConfiguration::SetScpCommander(TScpCommanderConfiguration value)
  989. {
  990. SET_CONFIG_PROPERTY(ScpCommander);
  991. }
  992. //---------------------------------------------------------------------------
  993. void __fastcall TWinConfiguration::SetEditor(TEditorConfiguration value)
  994. {
  995. SET_CONFIG_PROPERTY(Editor);
  996. }
  997. //---------------------------------------------------------------------------
  998. void __fastcall TWinConfiguration::SetQueueView(TQueueViewConfiguration value)
  999. {
  1000. SET_CONFIG_PROPERTY(QueueView);
  1001. }
  1002. //---------------------------------------------------------------------------
  1003. TUpdatesConfiguration __fastcall TWinConfiguration::GetUpdates()
  1004. {
  1005. TUpdatesConfiguration Result;
  1006. {
  1007. TGuard Guard(FCriticalSection);
  1008. Result = FUpdates;
  1009. }
  1010. return Result;
  1011. }
  1012. //---------------------------------------------------------------------------
  1013. void __fastcall TWinConfiguration::SetUpdates(TUpdatesConfiguration value)
  1014. {
  1015. TGuard Guard(FCriticalSection);
  1016. // do not use SET_CONFIG_PROPERTY to avoid OnChange handler call (not synchronized)
  1017. FUpdates = value;
  1018. }
  1019. //---------------------------------------------------------------------------
  1020. void __fastcall TWinConfiguration::SetDeleteToRecycleBin(bool value)
  1021. {
  1022. SET_CONFIG_PROPERTY(DeleteToRecycleBin);
  1023. }
  1024. //---------------------------------------------------------------------------
  1025. void __fastcall TWinConfiguration::SetSelectDirectories(bool value)
  1026. {
  1027. SET_CONFIG_PROPERTY(SelectDirectories);
  1028. }
  1029. //---------------------------------------------------------------------------
  1030. void __fastcall TWinConfiguration::SetShowHiddenFiles(bool value)
  1031. {
  1032. SET_CONFIG_PROPERTY(ShowHiddenFiles);
  1033. }
  1034. //---------------------------------------------------------------------------
  1035. void __fastcall TWinConfiguration::SetShowInaccesibleDirectories(bool value)
  1036. {
  1037. SET_CONFIG_PROPERTY(ShowInaccesibleDirectories);
  1038. }
  1039. //---------------------------------------------------------------------------
  1040. void __fastcall TWinConfiguration::SetConfirmDeleting(bool value)
  1041. {
  1042. SET_CONFIG_PROPERTY(ConfirmDeleting);
  1043. }
  1044. //---------------------------------------------------------------------------
  1045. void __fastcall TWinConfiguration::SetConfirmRecycling(bool value)
  1046. {
  1047. SET_CONFIG_PROPERTY(ConfirmRecycling);
  1048. }
  1049. //---------------------------------------------------------------------------
  1050. void __fastcall TWinConfiguration::SetUseLocationProfiles(bool value)
  1051. {
  1052. SET_CONFIG_PROPERTY(UseLocationProfiles);
  1053. }
  1054. //---------------------------------------------------------------------------
  1055. void __fastcall TWinConfiguration::SetConfirmClosingSession(bool value)
  1056. {
  1057. SET_CONFIG_PROPERTY(ConfirmClosingSession);
  1058. }
  1059. //---------------------------------------------------------------------------
  1060. void __fastcall TWinConfiguration::SetConfirmExitOnCompletion(bool value)
  1061. {
  1062. SET_CONFIG_PROPERTY(ConfirmExitOnCompletion);
  1063. }
  1064. //---------------------------------------------------------------------------
  1065. void __fastcall TWinConfiguration::SetForceDeleteTempFolder(bool value)
  1066. {
  1067. SET_CONFIG_PROPERTY(ForceDeleteTempFolder);
  1068. }
  1069. //---------------------------------------------------------------------------
  1070. void __fastcall TWinConfiguration::SetDoubleClickAction(TDoubleClickAction value)
  1071. {
  1072. SET_CONFIG_PROPERTY(DoubleClickAction);
  1073. }
  1074. //---------------------------------------------------------------------------
  1075. void __fastcall TWinConfiguration::SetCopyOnDoubleClickConfirmation(bool value)
  1076. {
  1077. SET_CONFIG_PROPERTY(CopyOnDoubleClickConfirmation);
  1078. }
  1079. //---------------------------------------------------------------------------
  1080. void __fastcall TWinConfiguration::SetDimmHiddenFiles(bool value)
  1081. {
  1082. SET_CONFIG_PROPERTY(DimmHiddenFiles);
  1083. }
  1084. //---------------------------------------------------------------------------
  1085. void __fastcall TWinConfiguration::SetAutoStartSession(AnsiString value)
  1086. {
  1087. SET_CONFIG_PROPERTY(AutoStartSession);
  1088. }
  1089. //---------------------------------------------------------------------------
  1090. void __fastcall TWinConfiguration::SetExpertMode(bool value)
  1091. {
  1092. SET_CONFIG_PROPERTY(ExpertMode);
  1093. }
  1094. //---------------------------------------------------------------------------
  1095. void __fastcall TWinConfiguration::SetDefaultDirIsHome(bool value)
  1096. {
  1097. SET_CONFIG_PROPERTY(DefaultDirIsHome);
  1098. }
  1099. //---------------------------------------------------------------------------
  1100. void __fastcall TWinConfiguration::SetTemporaryDirectoryCleanup(bool value)
  1101. {
  1102. SET_CONFIG_PROPERTY(TemporaryDirectoryCleanup);
  1103. }
  1104. //---------------------------------------------------------------------------
  1105. void __fastcall TWinConfiguration::SetConfirmTemporaryDirectoryCleanup(bool value)
  1106. {
  1107. SET_CONFIG_PROPERTY(ConfirmTemporaryDirectoryCleanup);
  1108. }
  1109. //---------------------------------------------------------------------------
  1110. void __fastcall TWinConfiguration::SetPreservePanelState(bool value)
  1111. {
  1112. SET_CONFIG_PROPERTY(PreservePanelState);
  1113. }
  1114. //---------------------------------------------------------------------------
  1115. void __fastcall TWinConfiguration::SetTheme(AnsiString value)
  1116. {
  1117. SET_CONFIG_PROPERTY_EX(Theme, ConfigureInterface());
  1118. }
  1119. //---------------------------------------------------------------------------
  1120. void __fastcall TWinConfiguration::SetPathInCaption(TPathInCaption value)
  1121. {
  1122. SET_CONFIG_PROPERTY(PathInCaption);
  1123. }
  1124. //---------------------------------------------------------------------------
  1125. void __fastcall TWinConfiguration::SetMinimizeToTray(bool value)
  1126. {
  1127. SET_CONFIG_PROPERTY(MinimizeToTray);
  1128. }
  1129. //---------------------------------------------------------------------------
  1130. void __fastcall TWinConfiguration::SetBalloonNotifications(bool value)
  1131. {
  1132. SET_CONFIG_PROPERTY(BalloonNotifications);
  1133. }
  1134. //---------------------------------------------------------------------------
  1135. void __fastcall TWinConfiguration::SetNotificationsTimeout(unsigned int value)
  1136. {
  1137. SET_CONFIG_PROPERTY(NotificationsTimeout);
  1138. }
  1139. //---------------------------------------------------------------------------
  1140. void __fastcall TWinConfiguration::SetNotificationsStickTime(unsigned int value)
  1141. {
  1142. SET_CONFIG_PROPERTY(NotificationsStickTime);
  1143. }
  1144. //---------------------------------------------------------------------------
  1145. void __fastcall TWinConfiguration::SetCopyParamAutoSelectNotice(bool value)
  1146. {
  1147. SET_CONFIG_PROPERTY(CopyParamAutoSelectNotice);
  1148. }
  1149. //---------------------------------------------------------------------------
  1150. void __fastcall TWinConfiguration::SetSessionToolbarAutoShown(bool value)
  1151. {
  1152. SET_CONFIG_PROPERTY(SessionToolbarAutoShown);
  1153. }
  1154. //---------------------------------------------------------------------------
  1155. void __fastcall TWinConfiguration::SetLockToolbars(bool value)
  1156. {
  1157. SET_CONFIG_PROPERTY(LockToolbars);
  1158. }
  1159. //---------------------------------------------------------------------------
  1160. void __fastcall TWinConfiguration::SetAutoOpenInPutty(bool value)
  1161. {
  1162. SET_CONFIG_PROPERTY(AutoOpenInPutty);
  1163. }
  1164. //---------------------------------------------------------------------------
  1165. void __fastcall TWinConfiguration::SetCustomCommands(TCustomCommands * value)
  1166. {
  1167. assert(FCustomCommands);
  1168. if (!FCustomCommands->Equals(value))
  1169. {
  1170. FCustomCommands->Assign(value);
  1171. FCustomCommandsModified = true;
  1172. FCustomCommandsDefaults = false;
  1173. }
  1174. }
  1175. //---------------------------------------------------------------------------
  1176. void __fastcall TWinConfiguration::SetBookmarks(AnsiString Key,
  1177. TBookmarkList * value)
  1178. {
  1179. FBookmarks->Bookmarks[Key] = value;
  1180. Changed();
  1181. }
  1182. //---------------------------------------------------------------------------
  1183. TBookmarkList * __fastcall TWinConfiguration::GetBookmarks(AnsiString Key)
  1184. {
  1185. return FBookmarks->Bookmarks[Key];
  1186. }
  1187. //---------------------------------------------------------------------------
  1188. AnsiString __fastcall TWinConfiguration::GetDefaultKeyFile()
  1189. {
  1190. return (!FDefaultKeyFile.IsEmpty() ? FDefaultKeyFile : FTemporaryKeyFile);
  1191. }
  1192. //---------------------------------------------------------------------------
  1193. AnsiString __fastcall TWinConfiguration::TemporaryDir(bool Mask)
  1194. {
  1195. return UniqTempDir(ExpandFileName(ExpandEnvironmentVariables(DDTemporaryDirectory)),
  1196. "scp", Mask);
  1197. }
  1198. //---------------------------------------------------------------------------
  1199. TStrings * __fastcall TWinConfiguration::FindTemporaryFolders()
  1200. {
  1201. TStrings * Result = new TStringList();
  1202. try
  1203. {
  1204. TSearchRec SRec;
  1205. AnsiString Mask = TemporaryDir(true);
  1206. AnsiString Directory = ExtractFilePath(Mask);
  1207. if (FindFirst(Mask, faDirectory, SRec) == 0)
  1208. {
  1209. do
  1210. {
  1211. if (FLAGSET(SRec.Attr, faDirectory))
  1212. {
  1213. Result->Add(Directory + SRec.Name);
  1214. }
  1215. }
  1216. while (FindNext(SRec) == 0);
  1217. }
  1218. if (Result->Count == 0)
  1219. {
  1220. delete Result;
  1221. Result = NULL;
  1222. }
  1223. }
  1224. catch(...)
  1225. {
  1226. delete Result;
  1227. throw;
  1228. }
  1229. return Result;
  1230. }
  1231. //---------------------------------------------------------------------------
  1232. void __fastcall TWinConfiguration::CleanupTemporaryFolders(TStrings * Folders)
  1233. {
  1234. AnsiString ErrorList;
  1235. TStrings * F;
  1236. if (Folders == NULL)
  1237. {
  1238. F = FindTemporaryFolders();
  1239. }
  1240. else
  1241. {
  1242. F = Folders;
  1243. }
  1244. if (F != NULL)
  1245. {
  1246. try
  1247. {
  1248. for (int i = 0; i < F->Count; i++)
  1249. {
  1250. if (!DeleteDirectory(F->Strings[i]))
  1251. {
  1252. if (!ErrorList.IsEmpty())
  1253. {
  1254. ErrorList += "\n";
  1255. }
  1256. ErrorList += F->Strings[i];
  1257. }
  1258. }
  1259. }
  1260. __finally
  1261. {
  1262. if (Folders == NULL)
  1263. {
  1264. delete F;
  1265. }
  1266. }
  1267. if (!ErrorList.IsEmpty())
  1268. {
  1269. throw ExtException(LoadStr(CLEANUP_TEMP_ERROR), ErrorList);
  1270. }
  1271. }
  1272. }
  1273. //---------------------------------------------------------------------------
  1274. //---------------------------------------------------------------------------
  1275. #pragma warn -inl
  1276. //---------------------------------------------------------------------------
  1277. class TAsInheritedReader : public TReader
  1278. {
  1279. public:
  1280. __fastcall TAsInheritedReader(TStream * Stream, int BufSize) :
  1281. TReader(Stream, BufSize)
  1282. {
  1283. OnAncestorNotFound = AncestorNotFound;
  1284. }
  1285. virtual void __fastcall ReadPrefix(TFilerFlags & Flags, int & AChildPos)
  1286. {
  1287. TReader::ReadPrefix(Flags, AChildPos);
  1288. Flags << ffInherited;
  1289. }
  1290. void __fastcall AncestorNotFound(TReader * Reader,
  1291. const AnsiString ComponentName, TMetaClass * ComponentClass,
  1292. TComponent *& Component)
  1293. {
  1294. assert(!Component);
  1295. if (ComponentName.IsEmpty())
  1296. {
  1297. for (int Index = 0; Index < LookupRoot->ComponentCount; Index++)
  1298. {
  1299. Component = LookupRoot->Components[Index];
  1300. if (Component->Name.IsEmpty())
  1301. {
  1302. return;
  1303. }
  1304. }
  1305. Component = NULL;
  1306. }
  1307. }
  1308. };
  1309. //---------------------------------------------------------------------------
  1310. #pragma warn .inl
  1311. //---------------------------------------------------------------------------
  1312. bool __fastcall TWinConfiguration::InternalReloadComponentRes(const AnsiString ResName,
  1313. HANDLE HInst, TComponent * Instance)
  1314. {
  1315. HANDLE HRsrc;
  1316. bool Result;
  1317. if (!HInst)
  1318. {
  1319. HInst = HInstance;
  1320. }
  1321. HRsrc = FindResource(HInst, ResName.c_str(), RT_RCDATA);
  1322. Result = (HRsrc != 0);
  1323. if (Result)
  1324. {
  1325. TResourceStream * ResStream = new TResourceStream(
  1326. reinterpret_cast<int>(HInst), ResName, RT_RCDATA);
  1327. try
  1328. {
  1329. TReader * Reader;
  1330. Reader = new TAsInheritedReader(ResStream, 4096);
  1331. try
  1332. {
  1333. /*Instance =*/ Reader->ReadRootComponent(Instance);
  1334. }
  1335. __finally
  1336. {
  1337. delete Reader;
  1338. }
  1339. }
  1340. __finally
  1341. {
  1342. delete ResStream;
  1343. }
  1344. }
  1345. return Result;
  1346. }
  1347. //---------------------------------------------------------------------------
  1348. bool __fastcall TWinConfiguration::InitComponent(TComponent * Instance,
  1349. TClass RootAncestor, TClass ClassType)
  1350. {
  1351. bool Result = false;
  1352. if ((ClassType != __classid(TComponent)) && (ClassType != RootAncestor))
  1353. {
  1354. if (InitComponent(Instance, RootAncestor, ClassType->ClassParent()))
  1355. {
  1356. Result = true;
  1357. }
  1358. if (InternalReloadComponentRes(ClassType->ClassName(),
  1359. reinterpret_cast<HANDLE>(FindResourceHInstance(FindClassHInstance(ClassType))),
  1360. Instance))
  1361. {
  1362. Result = true;
  1363. }
  1364. }
  1365. return Result;
  1366. }
  1367. //---------------------------------------------------------------------------
  1368. LCID __fastcall TWinConfiguration::GetLocale()
  1369. {
  1370. if (!FLocale)
  1371. {
  1372. AnsiString ResourceModule = ::GetResourceModule(ModuleFileName().c_str());
  1373. if (!ResourceModule.IsEmpty())
  1374. {
  1375. AnsiString ResourceExt = ExtractFileExt(ResourceModule).UpperCase();
  1376. ResourceExt.Delete(1, 1);
  1377. TLanguages * Langs = LanguagesDEPF();
  1378. int Index, Count;
  1379. Count = Langs->Count;
  1380. Index = 0;
  1381. while ((Index < Count) && !FLocale)
  1382. {
  1383. if (Langs->Ext[Index] == ResourceExt)
  1384. {
  1385. FLocale = Langs->LocaleID[Index];
  1386. }
  1387. else if (Langs->Ext[Index].SubString(1, 2) == ResourceExt)
  1388. {
  1389. FLocale = MAKELANGID(PRIMARYLANGID(Langs->LocaleID[Index]),
  1390. SUBLANG_DEFAULT);
  1391. }
  1392. Index++;
  1393. }
  1394. }
  1395. }
  1396. return TCustomWinConfiguration::GetLocale();
  1397. }
  1398. //---------------------------------------------------------------------------
  1399. HINSTANCE __fastcall TWinConfiguration::LoadNewResourceModule(LCID ALocale,
  1400. AnsiString * FileName)
  1401. {
  1402. AnsiString FileNameStorage;
  1403. if (FileName == NULL)
  1404. {
  1405. FileName = &FileNameStorage;
  1406. }
  1407. HINSTANCE Instance = TCustomWinConfiguration::LoadNewResourceModule(ALocale, FileName);
  1408. if (Instance != NULL)
  1409. {
  1410. try
  1411. {
  1412. CheckTranslationVersion(*FileName, false);
  1413. }
  1414. catch(...)
  1415. {
  1416. FreeResourceModule(Instance);
  1417. throw;
  1418. }
  1419. }
  1420. return Instance;
  1421. }
  1422. //---------------------------------------------------------------------------
  1423. void __fastcall TWinConfiguration::SetResourceModule(HINSTANCE Instance)
  1424. {
  1425. TCustomWinConfiguration::SetResourceModule(Instance);
  1426. Busy(true);
  1427. try
  1428. {
  1429. int Count;
  1430. AnsiString OrigName;
  1431. int OrigLeft;
  1432. int OrigTop;
  1433. TForm * Form;
  1434. Count = Screen->FormCount;
  1435. for (int Index = 0; Index < Count; Index++)
  1436. {
  1437. Form = Screen->Forms[Index];
  1438. SendMessage(Form->Handle, WM_LOCALE_CHANGE, 0, 1);
  1439. }
  1440. ConfigureInterface();
  1441. for (int Index = 0; Index < Count; Index++)
  1442. {
  1443. Form = Screen->Forms[Index];
  1444. TComponent * Component;
  1445. for (int Index = 0; Index < Form->ComponentCount; Index++)
  1446. {
  1447. Component = Form->Components[Index];
  1448. if (dynamic_cast<TFrame*>(Component))
  1449. {
  1450. OrigName = Component->Name;
  1451. InitComponent(Component, __classid(TFrame), Component->ClassType());
  1452. Component->Name = OrigName;
  1453. }
  1454. }
  1455. OrigLeft = Form->Left;
  1456. OrigTop = Form->Top;
  1457. OrigName = Form->Name;
  1458. InitComponent(Form, __classid(TForm), Form->ClassType());
  1459. Form->Name = OrigName;
  1460. Form->Position = poDesigned;
  1461. Form->Left = OrigLeft;
  1462. Form->Top = OrigTop;
  1463. SendMessage(Form->Handle, WM_LOCALE_CHANGE, 1, 1);
  1464. }
  1465. TDataModule * DataModule;
  1466. Count = Screen->DataModuleCount;
  1467. for (int Index = 0; Index < Count; Index++)
  1468. {
  1469. DataModule = Screen->DataModules[Index];
  1470. OrigName = DataModule->Name;
  1471. InitComponent(DataModule, __classid(TDataModule), DataModule->ClassType());
  1472. DataModule->Name = OrigName;
  1473. }
  1474. }
  1475. __finally
  1476. {
  1477. Busy(false);
  1478. }
  1479. }
  1480. //---------------------------------------------------------------------------
  1481. void __fastcall TWinConfiguration::CheckTranslationVersion(const AnsiString FileName,
  1482. bool InternalLocaleOnError)
  1483. {
  1484. AnsiString TranslationProductVersion = GetFileProductVersion(FileName);
  1485. AnsiString TranslationProductName = GetFileProductName(FileName);
  1486. if ((ProductName != TranslationProductName) ||
  1487. (ProductVersion != TranslationProductVersion))
  1488. {
  1489. if (InternalLocaleOnError)
  1490. {
  1491. LocaleSafe = InternalLocale();
  1492. }
  1493. if (TranslationProductName.IsEmpty() || TranslationProductVersion.IsEmpty())
  1494. {
  1495. throw Exception(FMTLOAD(UNKNOWN_TRANSLATION, (FileName)));
  1496. }
  1497. else
  1498. {
  1499. throw Exception(FMTLOAD(INCOMPATIBLE_TRANSLATION,
  1500. (FileName, TranslationProductName, TranslationProductVersion)));
  1501. }
  1502. }
  1503. }
  1504. //---------------------------------------------------------------------------
  1505. void __fastcall TWinConfiguration::CheckDefaultTranslation()
  1506. {
  1507. if (InvalidDefaultTranslation)
  1508. {
  1509. MoreMessageDialog(FMTLOAD(INVALID_DEFAULT_TRANSLATION,
  1510. (FInvalidDefaultTranslationMessage)), NULL, qtWarning, qaOK, HELP_NONE);
  1511. }
  1512. }
  1513. //---------------------------------------------------------------------------
  1514. bool __fastcall TWinConfiguration::ConfirmRemoveDefaultTranslation()
  1515. {
  1516. bool Result =
  1517. InvalidDefaultTranslation &&
  1518. (MoreMessageDialog(FMTLOAD(REMOVE_DEFAULT_TRANSLATION,
  1519. (FInvalidDefaultTranslationMessage)), NULL, qtWarning,
  1520. qaOK | qaCancel, HELP_NONE) == qaOK);
  1521. return Result;
  1522. }
  1523. //---------------------------------------------------------------------------
  1524. const TEditorPreferences * __fastcall TWinConfiguration::DefaultEditorForFile(
  1525. const AnsiString FileName, bool Local, const TFileMasks::TParams & MaskParams)
  1526. {
  1527. return FEditorList->Find(FileName, Local, MaskParams);
  1528. }
  1529. //---------------------------------------------------------------------------
  1530. const TEditorList * __fastcall TWinConfiguration::GetEditorList()
  1531. {
  1532. return FEditorList;
  1533. }
  1534. //---------------------------------------------------------------------------
  1535. void __fastcall TWinConfiguration::SetEditorList(const TEditorList * value)
  1536. {
  1537. if (!(*FEditorList == *value))
  1538. {
  1539. *FEditorList = *value;
  1540. Changed();
  1541. }
  1542. }
  1543. //---------------------------------------------------------------------------
  1544. //---------------------------------------------------------------------------
  1545. int __fastcall TCustomCommands::GetParam(const AnsiString & Name)
  1546. {
  1547. int Index = IndexOfName(Name);
  1548. if (Index >= 0)
  1549. {
  1550. return int(Objects[Index]);
  1551. }
  1552. else
  1553. {
  1554. return 0;
  1555. }
  1556. }
  1557. //---------------------------------------------------------------------------
  1558. void __fastcall TCustomCommands::SetParam(const AnsiString & Name, int value)
  1559. {
  1560. int Index = IndexOfName(Name);
  1561. if (Index >= 0)
  1562. {
  1563. Objects[Index] = (TObject *)value;
  1564. }
  1565. else
  1566. {
  1567. Values[Name] = "";
  1568. Index = IndexOfName(Name);
  1569. assert(Index >= 0);
  1570. Objects[Index] = (TObject *)value;
  1571. }
  1572. }
  1573. //---------------------------------------------------------------------------
  1574. bool __fastcall TCustomCommands::Equals(TCustomCommands * Commands)
  1575. {
  1576. bool Result = TStringList::Equals(Commands);
  1577. if (Result)
  1578. {
  1579. int Index = 0;
  1580. while ((Index < Count) && Result)
  1581. {
  1582. if (Objects[Index] != Commands->Objects[Index])
  1583. {
  1584. Result = false;
  1585. }
  1586. Index++;
  1587. }
  1588. }
  1589. return Result;
  1590. }