WinConfiguration.cpp 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664
  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 <VCLCommon.h>
  14. #include <ResourceModule.hpp>
  15. #include <LanguagesDEPfix.hpp>
  16. #include <InitGUID.h>
  17. #include <DragExt.h>
  18. //---------------------------------------------------------------------------
  19. #pragma package(smart_init)
  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. FInvalidDefaultTranslationMessage = "";
  322. FDDExtInstalled = -1;
  323. FBookmarks = new TBookmarks();
  324. FCustomCommands = new TCustomCommands();
  325. FEditorList = new TEditorList();
  326. FDefaultUpdatesPeriod = 0;
  327. Default();
  328. try
  329. {
  330. CheckTranslationVersion(::GetResourceModule(ModuleFileName().c_str()), true);
  331. }
  332. catch(Exception & E)
  333. {
  334. FInvalidDefaultTranslationMessage = E.Message;
  335. }
  336. }
  337. //---------------------------------------------------------------------------
  338. __fastcall TWinConfiguration::~TWinConfiguration()
  339. {
  340. if (!FTemporarySessionFile.IsEmpty()) DeleteFile(FTemporarySessionFile);
  341. ClearTemporaryLoginData();
  342. delete FBookmarks;
  343. delete FCustomCommands;
  344. delete FEditorList;
  345. }
  346. //---------------------------------------------------------------------------
  347. void __fastcall TWinConfiguration::Default()
  348. {
  349. FCustomCommandsDefaults = true;
  350. TCustomWinConfiguration::Default();
  351. FDDAllowMove = false;
  352. FDDAllowMoveInit = false;
  353. FDDTransferConfirmation = true;
  354. FDDTemporaryDirectory = "";
  355. FDDWarnLackOfTempSpace = true;
  356. FDDWarnLackOfTempSpaceRatio = 1.1;
  357. FDDExtEnabled = DDExtInstalled;
  358. FDDExtTimeout = 1000;
  359. FDeleteToRecycleBin = true;
  360. FSelectDirectories = false;
  361. FSelectMask = "*.*";
  362. FShowHiddenFiles = true;
  363. FShowInaccesibleDirectories = true;
  364. FConfirmTransferring = true;
  365. FConfirmDeleting = true;
  366. FConfirmRecycling = true;
  367. FConfirmClosingSession = true;
  368. FConfirmExitOnCompletion = true;
  369. FDoubleClickAction = dcaEdit;
  370. FCopyOnDoubleClickConfirmation = false;
  371. FDimmHiddenFiles = true;
  372. FAutoStartSession = "";
  373. FExpertMode = true;
  374. FUseLocationProfiles = false;
  375. FDefaultDirIsHome = true;
  376. FDDDeleteDelay = 120;
  377. FTemporaryDirectoryCleanup = true;
  378. FConfirmTemporaryDirectoryCleanup = true;
  379. FPreservePanelState = true;
  380. FTheme = "OfficeXP";
  381. FPathInCaption = picShort;
  382. FMinimizeToTray = false;
  383. FBalloonNotifications = true;
  384. FNotificationsTimeout = 10;
  385. FNotificationsStickTime = 2;
  386. FCopyParamAutoSelectNotice = true;
  387. FSessionToolbarAutoShown = false;
  388. FLockToolbars = false;
  389. FAutoOpenInPutty = false;
  390. FEditor.FontName = "Courier New";
  391. FEditor.FontHeight = -12;
  392. FEditor.FontStyle = 0;
  393. FEditor.FontCharset = DEFAULT_CHARSET;
  394. FEditor.WordWrap = false;
  395. FEditor.FindText = "";
  396. FEditor.ReplaceText = "";
  397. FEditor.FindMatchCase = false;
  398. FEditor.FindWholeWord = false;
  399. FEditor.FindDown = true;
  400. FEditor.TabSize = 7;
  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 = FDefaultUpdatesPeriod;
  409. FUpdates.LastCheck = 0;
  410. FUpdates.HaveResults = false;
  411. FUpdates.ShownResults = false;
  412. // for backward compatibility the default is decided based on value of ProxyHost
  413. FUpdates.ConnectionType = (TConnectionType)-1;
  414. FUpdates.ProxyHost = ""; // keep empty (see above)
  415. FUpdates.ProxyPort = 8080;
  416. FUpdates.Results.Reset();
  417. FLogWindowOnStartup = true;
  418. FLogWindowParams = "-1;-1;500;400";
  419. FScpExplorer.WindowParams = "-1;-1;600;400;0";
  420. 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";
  421. FScpExplorer.ToolbarsLayout =
  422. "Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
  423. "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
  424. "Buttons_Visible=1,Buttons_DockedTo=TopDock,Buttons_LastDock=TopDock,Buttons_DockRow=2,Buttons_DockPos=0,Buttons_FloatLeft=0,Buttons_FloatTop=0,Buttons_FloatRightX=0,"
  425. "Selection_Visible=0,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=3,Selection_DockPos=0,Selection_FloatLeft=227,Selection_FloatTop=445,Selection_FloatRightX=0,"
  426. "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=6,Session_DockPos=0,Session_FloatLeft=39,Session_FloatTop=160,Session_FloatRightX=0,"
  427. "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=4,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
  428. "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=5,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
  429. "Address_Visible=1,Address_DockedTo=TopDock,Address_LastDock=TopDock,Address_DockRow=1,Address_DockPos=0,Address_FloatLeft=0,Address_FloatTop=0,Address_FloatRightX=0,"
  430. "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=4,Updates_DockPos=302,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
  431. "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=4,Transfer_DockPos=155,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0"
  432. "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=7,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0";
  433. FScpExplorer.StatusBar = true;
  434. AnsiString PersonalFolder;
  435. ::SpecialFolderLocation(CSIDL_PERSONAL, PersonalFolder);
  436. FScpExplorer.LastLocalTargetDirectory = PersonalFolder;
  437. FScpExplorer.ViewStyle = 0; /* vsIcon */
  438. FScpExplorer.ShowFullAddress = true;
  439. FScpExplorer.DriveView = true;
  440. FScpExplorer.DriveViewWidth = 180;
  441. FScpCommander.WindowParams = ((Screen->Width > 900) && (Screen->Height > 700)) ?
  442. "-1;-1;850;650;0" : "-1;-1;600;400;0";
  443. FScpCommander.LocalPanelWidth = 0.5;
  444. FScpCommander.SwappedPanels = false;
  445. FScpCommander.StatusBar = true;
  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=1,Session_DockPos=602,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=557,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
  459. "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=1,Transfer_DockPos=411,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0,"
  460. "UploadDownload_Visible=0,UploadDownload_DockedTo=TopDock,UploadDownload_LastDock=TopDock,UploadDownload_DockRow=4,UploadDownload_DockPos=0,UploadDownload_FloatLeft=0,UploadDownload_FloatTop=0,UploadDownload_FloatRightX=0,"
  461. "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=5,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=208,RemoteHistory_FloatLeft=0,RemoteHistory_FloatTop=0,RemoteHistory_FloatRightX=0,"
  464. "RemoteNavigation_Visible=1,RemoteNavigation_DockedTo=RemoteTopDock,RemoteNavigation_LastDock=RemoteTopDock,RemoteNavigation_DockRow=0,RemoteNavigation_DockPos=288,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=207,LocalHistory_FloatLeft=0,LocalHistory_FloatTop=0,LocalHistory_FloatRightX=0,"
  467. "LocalNavigation_Visible=1,LocalNavigation_DockedTo=LocalTopDock,LocalNavigation_LastDock=LocalTopDock,LocalNavigation_DockRow=0,LocalNavigation_DockPos=287,LocalNavigation_FloatLeft=0,LocalNavigation_FloatTop=0,LocalNavigation_FloatRightX=0,"
  468. "Toolbar_Visible=1,Toolbar_DockedTo=BottomDock,Toolbar_LastDock=BottomDock,Toolbar_DockRow=1,Toolbar_DockPos=0,Toolbar_FloatLeft=0,Toolbar_FloatTop=0,Toolbar_FloatRightX=1,"
  469. "CommandLine_Visible=0,CommandLine_DockedTo=BottomDock,CommandLine_LastDock=BottomDock,CommandLine_DockRow=0,CommandLine_DockPos=0,CommandLine_FloatLeft=0,CommandLine_FloatTop=0,CommandLine_FloatRightX=0";
  470. FScpCommander.CurrentPanel = osLocal;
  471. FScpCommander.CompareByTime = true;
  472. FScpCommander.CompareBySize = false;
  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_PRINT)] = "notepad.exe /p \"!\"";
  513. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_PRINT)] = ccLocal;
  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, true)) 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, ConfirmTransferring); \
  640. KEY(Bool, ConfirmDeleting); \
  641. KEY(Bool, ConfirmRecycling); \
  642. KEY(Bool, ConfirmClosingSession); \
  643. KEY(Bool, ConfirmExitOnCompletion); \
  644. KEY(String, AutoStartSession); \
  645. KEY(Bool, UseLocationProfiles); \
  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. KEY(Integer, LastMonitor); \
  664. ); \
  665. BLOCK("Interface\\Editor", CANCREATE, \
  666. KEY(String, Editor.FontName); \
  667. KEY(Integer, Editor.FontHeight); \
  668. KEY(Integer, Editor.FontStyle); \
  669. KEY(Integer, Editor.FontCharset); \
  670. KEY(Bool, Editor.WordWrap); \
  671. KEY(String, Editor.FindText); \
  672. KEY(String, Editor.ReplaceText); \
  673. KEY(Bool, Editor.FindMatchCase); \
  674. KEY(Bool, Editor.FindWholeWord); \
  675. KEY(Bool, Editor.FindDown); \
  676. KEY(Integer, Editor.TabSize); \
  677. KEY(Integer, Editor.MaxEditors); \
  678. KEY(Integer, Editor.EarlyClose); \
  679. ); \
  680. BLOCK("Interface\\QueueView", CANCREATE, \
  681. KEY(Integer, QueueView.Height); \
  682. KEY(String, QueueView.Layout); \
  683. KEY(Integer, QueueView.Show); \
  684. KEY(Integer, QueueView.LastHideShow); \
  685. KEY(Bool, QueueView.ToolBar); \
  686. ); \
  687. BLOCK("Interface\\Updates", CANCREATE, \
  688. KEY(Integer, FUpdates.Period); \
  689. KEY(DateTime, FUpdates.LastCheck); \
  690. KEY(Integer, FUpdates.HaveResults); \
  691. KEY(Integer, FUpdates.ShownResults); \
  692. KEY(Integer, FUpdates.ConnectionType); \
  693. KEY(String, FUpdates.ProxyHost); \
  694. KEY(Integer, FUpdates.ProxyPort); \
  695. KEY(Integer, FUpdates.Results.ForVersion); \
  696. KEY(Integer, FUpdates.Results.Version); \
  697. KEY(String, FUpdates.Results.Message); \
  698. KEY(Integer, FUpdates.Results.Critical); \
  699. KEY(String, FUpdates.Results.Release); \
  700. KEY(Bool, FUpdates.Results.Disabled); \
  701. KEY(String, FUpdates.Results.Url); \
  702. KEY(String, FUpdates.Results.UrlButton); \
  703. ); \
  704. BLOCK("Interface\\Explorer", CANCREATE, \
  705. KEY(String, ScpExplorer.ToolbarsLayout); \
  706. KEY(String, ScpExplorer.DirViewParams); \
  707. KEY(String, ScpExplorer.LastLocalTargetDirectory); \
  708. KEY(Bool, ScpExplorer.StatusBar); \
  709. KEY(String, ScpExplorer.WindowParams); \
  710. KEY(Integer, ScpExplorer.ViewStyle); \
  711. KEY(Bool, ScpExplorer.ShowFullAddress); \
  712. KEY(Bool, ScpExplorer.DriveView); \
  713. KEY(Integer, ScpExplorer.DriveViewWidth); \
  714. ); \
  715. BLOCK("Interface\\Commander", CANCREATE, \
  716. KEY(String, ScpCommander.ToolbarsLayout); \
  717. KEY(Integer, ScpCommander.CurrentPanel); \
  718. KEY(Float, ScpCommander.LocalPanelWidth); \
  719. KEY(Bool, ScpCommander.SwappedPanels); \
  720. KEY(Bool, ScpCommander.StatusBar); \
  721. KEY(String, ScpCommander.WindowParams); \
  722. KEYEX(Integer, ScpCommander.NortonLikeMode, ExplorerStyleSelection); \
  723. KEY(Bool, ScpCommander.PreserveLocalDirectory); \
  724. KEY(Bool, ScpCommander.CompareByTime); \
  725. KEY(Bool, ScpCommander.CompareBySize); \
  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, 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. if (FUpdates.ConnectionType == -1)
  841. {
  842. FUpdates.ConnectionType = (FUpdates.ProxyHost.IsEmpty() ? ctAuto : ctProxy);
  843. }
  844. }
  845. //---------------------------------------------------------------------------
  846. void __fastcall TWinConfiguration::LoadData(THierarchicalStorage * Storage)
  847. {
  848. TCustomWinConfiguration::LoadData(Storage);
  849. // duplicated from core\configuration.cpp
  850. #define KEYEX(TYPE, VAR, NAME) VAR = Storage->Read ## TYPE(LASTELEM(AnsiString(#NAME)), VAR)
  851. #pragma warn -eas
  852. REGCONFIG(false);
  853. #pragma warn +eas
  854. #undef KEYEX
  855. if (Storage->OpenSubKey("Bookmarks", false))
  856. {
  857. FBookmarks->Load(Storage);
  858. Storage->CloseSubKey();
  859. }
  860. if (Storage->OpenSubKey("CustomCommands", false))
  861. {
  862. FCustomCommands->Clear();
  863. Storage->ReadValues(FCustomCommands, true);
  864. Storage->CloseSubKey();
  865. if (Storage->OpenSubKey("CustomCommandsParams", false))
  866. {
  867. for (int Index = 0; Index < FCustomCommands->Count; Index++)
  868. {
  869. AnsiString Name = FCustomCommands->Names[Index];
  870. FCustomCommands->Params[Name] =
  871. Storage->ReadInteger(Name, FCustomCommands->Params[Name]);
  872. }
  873. Storage->CloseSubKey();
  874. }
  875. FCustomCommandsDefaults = false;
  876. }
  877. else if (FCustomCommandsModified)
  878. {
  879. FCustomCommands->Clear();
  880. FCustomCommandsDefaults = false;
  881. }
  882. FCustomCommandsModified = false;
  883. if (Storage->OpenSubKey("Interface\\Editor", false, true))
  884. try
  885. {
  886. FEditorList->Clear();
  887. FEditorList->Load(Storage);
  888. }
  889. __finally
  890. {
  891. Storage->CloseSubKey();
  892. }
  893. // load legacy editor configuration
  894. assert(FLegacyEditor != NULL);
  895. if (Storage->OpenSubKey("Interface\\Editor", false, true))
  896. {
  897. try
  898. {
  899. FLegacyEditor->Load(Storage, true);
  900. }
  901. __finally
  902. {
  903. Storage->CloseSubKey();
  904. }
  905. }
  906. }
  907. //---------------------------------------------------------------------------
  908. void __fastcall TWinConfiguration::LoadAdmin(THierarchicalStorage * Storage)
  909. {
  910. TCustomWinConfiguration::LoadAdmin(Storage);
  911. FDisableOpenEdit = Storage->ReadBool("DisableOpenEdit", FDisableOpenEdit);
  912. FDefaultUpdatesPeriod = Storage->ReadInteger("DefaultUpdatesPeriod", FDefaultUpdatesPeriod);
  913. }
  914. //---------------------------------------------------------------------------
  915. void __fastcall TWinConfiguration::ClearTemporaryLoginData()
  916. {
  917. if (!FTemporaryKeyFile.IsEmpty())
  918. {
  919. DeleteFile(FTemporaryKeyFile);
  920. FTemporaryKeyFile = "";
  921. }
  922. }
  923. //---------------------------------------------------------------------------
  924. bool __fastcall TWinConfiguration::GetDDExtInstalled()
  925. {
  926. if (FDDExtInstalled < 0)
  927. {
  928. if (IsWin64())
  929. {
  930. // temporarily consider dragext always present on 64-bit system
  931. FDDExtInstalled = 1;
  932. }
  933. else
  934. {
  935. void * DragExtRef;
  936. bool Result;
  937. Result = (CoCreateInstance(CLSID_ShellExtension, NULL,
  938. CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown,
  939. &DragExtRef) == S_OK);
  940. FDDExtInstalled = (Result ? 1 : 0);
  941. if (Result)
  942. {
  943. reinterpret_cast<IUnknown *>(DragExtRef)->Release();
  944. CoFreeUnusedLibraries();
  945. }
  946. }
  947. }
  948. return (FDDExtInstalled > 0);
  949. }
  950. //---------------------------------------------------------------------------
  951. void __fastcall TWinConfiguration::SetLogWindowOnStartup(bool value)
  952. {
  953. SET_CONFIG_PROPERTY(LogWindowOnStartup);
  954. }
  955. //---------------------------------------------------------------------------
  956. void __fastcall TWinConfiguration::SetLogWindowParams(AnsiString value)
  957. {
  958. SET_CONFIG_PROPERTY(LogWindowParams);
  959. }
  960. //---------------------------------------------------------------------------
  961. void __fastcall TWinConfiguration::SetDDAllowMove(bool value)
  962. {
  963. SET_CONFIG_PROPERTY(DDAllowMove);
  964. }
  965. //---------------------------------------------------------------------------
  966. void __fastcall TWinConfiguration::SetDDAllowMoveInit(bool value)
  967. {
  968. SET_CONFIG_PROPERTY(DDAllowMoveInit);
  969. }
  970. //---------------------------------------------------------------------------
  971. void __fastcall TWinConfiguration::SetDDTransferConfirmation(bool value)
  972. {
  973. SET_CONFIG_PROPERTY(DDTransferConfirmation);
  974. }
  975. //---------------------------------------------------------------------------
  976. void __fastcall TWinConfiguration::SetDDTemporaryDirectory(AnsiString value)
  977. {
  978. SET_CONFIG_PROPERTY(DDTemporaryDirectory);
  979. }
  980. //---------------------------------------------------------------------------
  981. void __fastcall TWinConfiguration::SetDDExtEnabled(bool value)
  982. {
  983. SET_CONFIG_PROPERTY(DDExtEnabled);
  984. }
  985. //---------------------------------------------------------------------------
  986. void __fastcall TWinConfiguration::SetDDExtTimeout(int value)
  987. {
  988. SET_CONFIG_PROPERTY(DDExtTimeout);
  989. }
  990. //---------------------------------------------------------------------------
  991. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpace(bool value)
  992. {
  993. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpace);
  994. }
  995. //---------------------------------------------------------------------------
  996. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpaceRatio(double value)
  997. {
  998. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpaceRatio);
  999. }
  1000. //---------------------------------------------------------------------------
  1001. void __fastcall TWinConfiguration::SetScpExplorer(TScpExplorerConfiguration value)
  1002. {
  1003. SET_CONFIG_PROPERTY(ScpExplorer);
  1004. }
  1005. //---------------------------------------------------------------------------
  1006. void __fastcall TWinConfiguration::SetScpCommander(TScpCommanderConfiguration value)
  1007. {
  1008. SET_CONFIG_PROPERTY(ScpCommander);
  1009. }
  1010. //---------------------------------------------------------------------------
  1011. void __fastcall TWinConfiguration::SetEditor(TEditorConfiguration value)
  1012. {
  1013. SET_CONFIG_PROPERTY(Editor);
  1014. }
  1015. //---------------------------------------------------------------------------
  1016. void __fastcall TWinConfiguration::SetQueueView(TQueueViewConfiguration value)
  1017. {
  1018. SET_CONFIG_PROPERTY(QueueView);
  1019. }
  1020. //---------------------------------------------------------------------------
  1021. TUpdatesConfiguration __fastcall TWinConfiguration::GetUpdates()
  1022. {
  1023. TUpdatesConfiguration Result;
  1024. {
  1025. TGuard Guard(FCriticalSection);
  1026. Result = FUpdates;
  1027. }
  1028. return Result;
  1029. }
  1030. //---------------------------------------------------------------------------
  1031. void __fastcall TWinConfiguration::SetUpdates(TUpdatesConfiguration value)
  1032. {
  1033. TGuard Guard(FCriticalSection);
  1034. // do not use SET_CONFIG_PROPERTY to avoid OnChange handler call (not synchronized)
  1035. FUpdates = value;
  1036. }
  1037. //---------------------------------------------------------------------------
  1038. void __fastcall TWinConfiguration::SetDeleteToRecycleBin(bool value)
  1039. {
  1040. SET_CONFIG_PROPERTY(DeleteToRecycleBin);
  1041. }
  1042. //---------------------------------------------------------------------------
  1043. void __fastcall TWinConfiguration::SetSelectDirectories(bool value)
  1044. {
  1045. SET_CONFIG_PROPERTY(SelectDirectories);
  1046. }
  1047. //---------------------------------------------------------------------------
  1048. void __fastcall TWinConfiguration::SetShowHiddenFiles(bool value)
  1049. {
  1050. SET_CONFIG_PROPERTY(ShowHiddenFiles);
  1051. }
  1052. //---------------------------------------------------------------------------
  1053. void __fastcall TWinConfiguration::SetShowInaccesibleDirectories(bool value)
  1054. {
  1055. SET_CONFIG_PROPERTY(ShowInaccesibleDirectories);
  1056. }
  1057. //---------------------------------------------------------------------------
  1058. void __fastcall TWinConfiguration::SetConfirmTransferring(bool value)
  1059. {
  1060. SET_CONFIG_PROPERTY(ConfirmTransferring);
  1061. }
  1062. //---------------------------------------------------------------------------
  1063. void __fastcall TWinConfiguration::SetConfirmDeleting(bool value)
  1064. {
  1065. SET_CONFIG_PROPERTY(ConfirmDeleting);
  1066. }
  1067. //---------------------------------------------------------------------------
  1068. void __fastcall TWinConfiguration::SetConfirmRecycling(bool value)
  1069. {
  1070. SET_CONFIG_PROPERTY(ConfirmRecycling);
  1071. }
  1072. //---------------------------------------------------------------------------
  1073. void __fastcall TWinConfiguration::SetUseLocationProfiles(bool value)
  1074. {
  1075. SET_CONFIG_PROPERTY(UseLocationProfiles);
  1076. }
  1077. //---------------------------------------------------------------------------
  1078. void __fastcall TWinConfiguration::SetConfirmClosingSession(bool value)
  1079. {
  1080. SET_CONFIG_PROPERTY(ConfirmClosingSession);
  1081. }
  1082. //---------------------------------------------------------------------------
  1083. void __fastcall TWinConfiguration::SetConfirmExitOnCompletion(bool value)
  1084. {
  1085. SET_CONFIG_PROPERTY(ConfirmExitOnCompletion);
  1086. }
  1087. //---------------------------------------------------------------------------
  1088. void __fastcall TWinConfiguration::SetDoubleClickAction(TDoubleClickAction value)
  1089. {
  1090. SET_CONFIG_PROPERTY(DoubleClickAction);
  1091. }
  1092. //---------------------------------------------------------------------------
  1093. void __fastcall TWinConfiguration::SetCopyOnDoubleClickConfirmation(bool value)
  1094. {
  1095. SET_CONFIG_PROPERTY(CopyOnDoubleClickConfirmation);
  1096. }
  1097. //---------------------------------------------------------------------------
  1098. void __fastcall TWinConfiguration::SetDimmHiddenFiles(bool value)
  1099. {
  1100. SET_CONFIG_PROPERTY(DimmHiddenFiles);
  1101. }
  1102. //---------------------------------------------------------------------------
  1103. void __fastcall TWinConfiguration::SetAutoStartSession(AnsiString value)
  1104. {
  1105. SET_CONFIG_PROPERTY(AutoStartSession);
  1106. }
  1107. //---------------------------------------------------------------------------
  1108. void __fastcall TWinConfiguration::SetExpertMode(bool value)
  1109. {
  1110. SET_CONFIG_PROPERTY(ExpertMode);
  1111. }
  1112. //---------------------------------------------------------------------------
  1113. void __fastcall TWinConfiguration::SetDefaultDirIsHome(bool value)
  1114. {
  1115. SET_CONFIG_PROPERTY(DefaultDirIsHome);
  1116. }
  1117. //---------------------------------------------------------------------------
  1118. void __fastcall TWinConfiguration::SetTemporaryDirectoryCleanup(bool value)
  1119. {
  1120. SET_CONFIG_PROPERTY(TemporaryDirectoryCleanup);
  1121. }
  1122. //---------------------------------------------------------------------------
  1123. void __fastcall TWinConfiguration::SetConfirmTemporaryDirectoryCleanup(bool value)
  1124. {
  1125. SET_CONFIG_PROPERTY(ConfirmTemporaryDirectoryCleanup);
  1126. }
  1127. //---------------------------------------------------------------------------
  1128. void __fastcall TWinConfiguration::SetPreservePanelState(bool value)
  1129. {
  1130. SET_CONFIG_PROPERTY(PreservePanelState);
  1131. }
  1132. //---------------------------------------------------------------------------
  1133. void __fastcall TWinConfiguration::SetTheme(AnsiString value)
  1134. {
  1135. SET_CONFIG_PROPERTY_EX(Theme, ConfigureInterface());
  1136. }
  1137. //---------------------------------------------------------------------------
  1138. void __fastcall TWinConfiguration::SetPathInCaption(TPathInCaption value)
  1139. {
  1140. SET_CONFIG_PROPERTY(PathInCaption);
  1141. }
  1142. //---------------------------------------------------------------------------
  1143. void __fastcall TWinConfiguration::SetMinimizeToTray(bool value)
  1144. {
  1145. SET_CONFIG_PROPERTY(MinimizeToTray);
  1146. }
  1147. //---------------------------------------------------------------------------
  1148. void __fastcall TWinConfiguration::SetBalloonNotifications(bool value)
  1149. {
  1150. SET_CONFIG_PROPERTY(BalloonNotifications);
  1151. }
  1152. //---------------------------------------------------------------------------
  1153. void __fastcall TWinConfiguration::SetNotificationsTimeout(unsigned int value)
  1154. {
  1155. SET_CONFIG_PROPERTY(NotificationsTimeout);
  1156. }
  1157. //---------------------------------------------------------------------------
  1158. void __fastcall TWinConfiguration::SetNotificationsStickTime(unsigned int value)
  1159. {
  1160. SET_CONFIG_PROPERTY(NotificationsStickTime);
  1161. }
  1162. //---------------------------------------------------------------------------
  1163. void __fastcall TWinConfiguration::SetCopyParamAutoSelectNotice(bool value)
  1164. {
  1165. SET_CONFIG_PROPERTY(CopyParamAutoSelectNotice);
  1166. }
  1167. //---------------------------------------------------------------------------
  1168. void __fastcall TWinConfiguration::SetSessionToolbarAutoShown(bool value)
  1169. {
  1170. SET_CONFIG_PROPERTY(SessionToolbarAutoShown);
  1171. }
  1172. //---------------------------------------------------------------------------
  1173. void __fastcall TWinConfiguration::SetLockToolbars(bool value)
  1174. {
  1175. SET_CONFIG_PROPERTY(LockToolbars);
  1176. }
  1177. //---------------------------------------------------------------------------
  1178. void __fastcall TWinConfiguration::SetAutoOpenInPutty(bool value)
  1179. {
  1180. SET_CONFIG_PROPERTY(AutoOpenInPutty);
  1181. }
  1182. //---------------------------------------------------------------------------
  1183. void __fastcall TWinConfiguration::SetCustomCommands(TCustomCommands * value)
  1184. {
  1185. assert(FCustomCommands);
  1186. if (!FCustomCommands->Equals(value))
  1187. {
  1188. FCustomCommands->Assign(value);
  1189. FCustomCommandsModified = true;
  1190. FCustomCommandsDefaults = false;
  1191. }
  1192. }
  1193. //---------------------------------------------------------------------------
  1194. void __fastcall TWinConfiguration::SetBookmarks(AnsiString Key,
  1195. TBookmarkList * value)
  1196. {
  1197. FBookmarks->Bookmarks[Key] = value;
  1198. Changed();
  1199. }
  1200. //---------------------------------------------------------------------------
  1201. TBookmarkList * __fastcall TWinConfiguration::GetBookmarks(AnsiString Key)
  1202. {
  1203. return FBookmarks->Bookmarks[Key];
  1204. }
  1205. //---------------------------------------------------------------------------
  1206. AnsiString __fastcall TWinConfiguration::GetDefaultKeyFile()
  1207. {
  1208. return (!FDefaultKeyFile.IsEmpty() ? FDefaultKeyFile : FTemporaryKeyFile);
  1209. }
  1210. //---------------------------------------------------------------------------
  1211. void __fastcall TWinConfiguration::SetLastMonitor(int value)
  1212. {
  1213. ::SetLastMonitor(value);
  1214. }
  1215. //---------------------------------------------------------------------------
  1216. int __fastcall TWinConfiguration::GetLastMonitor()
  1217. {
  1218. return ::GetLastMonitor();
  1219. }
  1220. //---------------------------------------------------------------------------
  1221. AnsiString __fastcall TWinConfiguration::TemporaryDir(bool Mask)
  1222. {
  1223. return UniqTempDir(ExpandFileName(ExpandEnvironmentVariables(DDTemporaryDirectory)),
  1224. "scp", Mask);
  1225. }
  1226. //---------------------------------------------------------------------------
  1227. TStrings * __fastcall TWinConfiguration::FindTemporaryFolders()
  1228. {
  1229. TStrings * Result = new TStringList();
  1230. try
  1231. {
  1232. TSearchRec SRec;
  1233. AnsiString Mask = TemporaryDir(true);
  1234. AnsiString Directory = ExtractFilePath(Mask);
  1235. if (FindFirst(Mask, faDirectory, SRec) == 0)
  1236. {
  1237. do
  1238. {
  1239. if (FLAGSET(SRec.Attr, faDirectory))
  1240. {
  1241. Result->Add(Directory + SRec.Name);
  1242. }
  1243. }
  1244. while (FindNext(SRec) == 0);
  1245. }
  1246. if (Result->Count == 0)
  1247. {
  1248. delete Result;
  1249. Result = NULL;
  1250. }
  1251. }
  1252. catch(...)
  1253. {
  1254. delete Result;
  1255. throw;
  1256. }
  1257. return Result;
  1258. }
  1259. //---------------------------------------------------------------------------
  1260. void __fastcall TWinConfiguration::CleanupTemporaryFolders(TStrings * Folders)
  1261. {
  1262. AnsiString ErrorList;
  1263. TStrings * F;
  1264. if (Folders == NULL)
  1265. {
  1266. F = FindTemporaryFolders();
  1267. }
  1268. else
  1269. {
  1270. F = Folders;
  1271. }
  1272. if (F != NULL)
  1273. {
  1274. try
  1275. {
  1276. for (int i = 0; i < F->Count; i++)
  1277. {
  1278. if (!DeleteDirectory(F->Strings[i]))
  1279. {
  1280. if (!ErrorList.IsEmpty())
  1281. {
  1282. ErrorList += "\n";
  1283. }
  1284. ErrorList += F->Strings[i];
  1285. }
  1286. }
  1287. }
  1288. __finally
  1289. {
  1290. if (Folders == NULL)
  1291. {
  1292. delete F;
  1293. }
  1294. }
  1295. if (!ErrorList.IsEmpty())
  1296. {
  1297. throw ExtException(LoadStr(CLEANUP_TEMP_ERROR), ErrorList);
  1298. }
  1299. }
  1300. }
  1301. //---------------------------------------------------------------------------
  1302. //---------------------------------------------------------------------------
  1303. #pragma warn -inl
  1304. //---------------------------------------------------------------------------
  1305. class TAsInheritedReader : public TReader
  1306. {
  1307. public:
  1308. __fastcall TAsInheritedReader(TStream * Stream, int BufSize) :
  1309. TReader(Stream, BufSize)
  1310. {
  1311. OnAncestorNotFound = AncestorNotFound;
  1312. }
  1313. virtual void __fastcall ReadPrefix(TFilerFlags & Flags, int & AChildPos)
  1314. {
  1315. TReader::ReadPrefix(Flags, AChildPos);
  1316. Flags << ffInherited;
  1317. }
  1318. void __fastcall AncestorNotFound(TReader * Reader,
  1319. const AnsiString ComponentName, TMetaClass * ComponentClass,
  1320. TComponent *& Component)
  1321. {
  1322. assert(!Component);
  1323. if (ComponentName.IsEmpty())
  1324. {
  1325. for (int Index = 0; Index < LookupRoot->ComponentCount; Index++)
  1326. {
  1327. Component = LookupRoot->Components[Index];
  1328. if (Component->Name.IsEmpty())
  1329. {
  1330. return;
  1331. }
  1332. }
  1333. Component = NULL;
  1334. }
  1335. }
  1336. };
  1337. //---------------------------------------------------------------------------
  1338. #pragma warn .inl
  1339. //---------------------------------------------------------------------------
  1340. bool __fastcall TWinConfiguration::InternalReloadComponentRes(const AnsiString ResName,
  1341. HANDLE HInst, TComponent * Instance)
  1342. {
  1343. HANDLE HRsrc;
  1344. bool Result;
  1345. if (!HInst)
  1346. {
  1347. HInst = HInstance;
  1348. }
  1349. HRsrc = FindResource(HInst, ResName.c_str(), RT_RCDATA);
  1350. Result = (HRsrc != 0);
  1351. if (Result)
  1352. {
  1353. TResourceStream * ResStream = new TResourceStream(
  1354. reinterpret_cast<int>(HInst), ResName, RT_RCDATA);
  1355. try
  1356. {
  1357. TReader * Reader;
  1358. Reader = new TAsInheritedReader(ResStream, 4096);
  1359. try
  1360. {
  1361. /*Instance =*/ Reader->ReadRootComponent(Instance);
  1362. }
  1363. __finally
  1364. {
  1365. delete Reader;
  1366. }
  1367. }
  1368. __finally
  1369. {
  1370. delete ResStream;
  1371. }
  1372. }
  1373. return Result;
  1374. }
  1375. //---------------------------------------------------------------------------
  1376. bool __fastcall TWinConfiguration::InitComponent(TComponent * Instance,
  1377. TClass RootAncestor, TClass ClassType)
  1378. {
  1379. bool Result = false;
  1380. if ((ClassType != __classid(TComponent)) && (ClassType != RootAncestor))
  1381. {
  1382. if (InitComponent(Instance, RootAncestor, ClassType->ClassParent()))
  1383. {
  1384. Result = true;
  1385. }
  1386. if (InternalReloadComponentRes(ClassType->ClassName(),
  1387. reinterpret_cast<HANDLE>(FindResourceHInstance(FindClassHInstance(ClassType))),
  1388. Instance))
  1389. {
  1390. Result = true;
  1391. }
  1392. }
  1393. return Result;
  1394. }
  1395. //---------------------------------------------------------------------------
  1396. LCID __fastcall TWinConfiguration::GetLocale()
  1397. {
  1398. if (!FLocale)
  1399. {
  1400. AnsiString ResourceModule = ::GetResourceModule(ModuleFileName().c_str());
  1401. if (!ResourceModule.IsEmpty())
  1402. {
  1403. AnsiString ResourceExt = ExtractFileExt(ResourceModule).UpperCase();
  1404. ResourceExt.Delete(1, 1);
  1405. TLanguages * Langs = LanguagesDEPF();
  1406. int Index, Count;
  1407. Count = Langs->Count;
  1408. Index = 0;
  1409. while ((Index < Count) && !FLocale)
  1410. {
  1411. if (Langs->Ext[Index] == ResourceExt)
  1412. {
  1413. FLocale = Langs->LocaleID[Index];
  1414. }
  1415. else if (Langs->Ext[Index].SubString(1, 2) == ResourceExt)
  1416. {
  1417. FLocale = MAKELANGID(PRIMARYLANGID(Langs->LocaleID[Index]),
  1418. SUBLANG_DEFAULT);
  1419. }
  1420. Index++;
  1421. }
  1422. }
  1423. }
  1424. return TCustomWinConfiguration::GetLocale();
  1425. }
  1426. //---------------------------------------------------------------------------
  1427. HINSTANCE __fastcall TWinConfiguration::LoadNewResourceModule(LCID ALocale,
  1428. AnsiString * FileName)
  1429. {
  1430. AnsiString FileNameStorage;
  1431. if (FileName == NULL)
  1432. {
  1433. FileName = &FileNameStorage;
  1434. }
  1435. HINSTANCE Instance = TCustomWinConfiguration::LoadNewResourceModule(ALocale, FileName);
  1436. if (Instance != NULL)
  1437. {
  1438. try
  1439. {
  1440. CheckTranslationVersion(*FileName, false);
  1441. }
  1442. catch(...)
  1443. {
  1444. FreeResourceModule(Instance);
  1445. throw;
  1446. }
  1447. }
  1448. return Instance;
  1449. }
  1450. //---------------------------------------------------------------------------
  1451. void __fastcall TWinConfiguration::SetResourceModule(HINSTANCE Instance)
  1452. {
  1453. TCustomWinConfiguration::SetResourceModule(Instance);
  1454. Busy(true);
  1455. try
  1456. {
  1457. int Count;
  1458. AnsiString OrigName;
  1459. int OrigLeft;
  1460. int OrigTop;
  1461. TForm * Form;
  1462. Count = Screen->FormCount;
  1463. for (int Index = 0; Index < Count; Index++)
  1464. {
  1465. Form = Screen->Forms[Index];
  1466. SendMessage(Form->Handle, WM_LOCALE_CHANGE, 0, 1);
  1467. }
  1468. ConfigureInterface();
  1469. for (int Index = 0; Index < Count; Index++)
  1470. {
  1471. Form = Screen->Forms[Index];
  1472. TComponent * Component;
  1473. for (int Index = 0; Index < Form->ComponentCount; Index++)
  1474. {
  1475. Component = Form->Components[Index];
  1476. if (dynamic_cast<TFrame*>(Component))
  1477. {
  1478. OrigName = Component->Name;
  1479. InitComponent(Component, __classid(TFrame), Component->ClassType());
  1480. Component->Name = OrigName;
  1481. }
  1482. }
  1483. OrigLeft = Form->Left;
  1484. OrigTop = Form->Top;
  1485. OrigName = Form->Name;
  1486. InitComponent(Form, __classid(TForm), Form->ClassType());
  1487. Form->Name = OrigName;
  1488. Form->Position = poDesigned;
  1489. Form->Left = OrigLeft;
  1490. Form->Top = OrigTop;
  1491. SendMessage(Form->Handle, WM_LOCALE_CHANGE, 1, 1);
  1492. }
  1493. TDataModule * DataModule;
  1494. Count = Screen->DataModuleCount;
  1495. for (int Index = 0; Index < Count; Index++)
  1496. {
  1497. DataModule = Screen->DataModules[Index];
  1498. OrigName = DataModule->Name;
  1499. InitComponent(DataModule, __classid(TDataModule), DataModule->ClassType());
  1500. DataModule->Name = OrigName;
  1501. }
  1502. }
  1503. __finally
  1504. {
  1505. Busy(false);
  1506. }
  1507. }
  1508. //---------------------------------------------------------------------------
  1509. void __fastcall TWinConfiguration::CheckTranslationVersion(const AnsiString FileName,
  1510. bool InternalLocaleOnError)
  1511. {
  1512. AnsiString TranslationProductVersion = GetFileProductVersion(FileName);
  1513. AnsiString TranslationProductName = GetFileProductName(FileName);
  1514. if ((ProductName != TranslationProductName) ||
  1515. (ProductVersion != TranslationProductVersion))
  1516. {
  1517. if (InternalLocaleOnError)
  1518. {
  1519. LocaleSafe = InternalLocale();
  1520. }
  1521. if (TranslationProductName.IsEmpty() || TranslationProductVersion.IsEmpty())
  1522. {
  1523. throw Exception(FMTLOAD(UNKNOWN_TRANSLATION, (FileName)));
  1524. }
  1525. else
  1526. {
  1527. throw Exception(FMTLOAD(INCOMPATIBLE_TRANSLATION,
  1528. (FileName, TranslationProductName, TranslationProductVersion)));
  1529. }
  1530. }
  1531. }
  1532. //---------------------------------------------------------------------------
  1533. void __fastcall TWinConfiguration::CheckDefaultTranslation()
  1534. {
  1535. if (!FInvalidDefaultTranslationMessage.IsEmpty())
  1536. {
  1537. MoreMessageDialog(FMTLOAD(INVALID_DEFAULT_TRANSLATION,
  1538. (FInvalidDefaultTranslationMessage)), NULL, qtWarning, qaOK, HELP_NONE);
  1539. }
  1540. }
  1541. //---------------------------------------------------------------------------
  1542. const TEditorPreferences * __fastcall TWinConfiguration::DefaultEditorForFile(
  1543. const AnsiString FileName, bool Local, const TFileMasks::TParams & MaskParams)
  1544. {
  1545. return FEditorList->Find(FileName, Local, MaskParams);
  1546. }
  1547. //---------------------------------------------------------------------------
  1548. const TEditorList * __fastcall TWinConfiguration::GetEditorList()
  1549. {
  1550. return FEditorList;
  1551. }
  1552. //---------------------------------------------------------------------------
  1553. void __fastcall TWinConfiguration::SetEditorList(const TEditorList * value)
  1554. {
  1555. if (!(*FEditorList == *value))
  1556. {
  1557. *FEditorList = *value;
  1558. Changed();
  1559. }
  1560. }
  1561. //---------------------------------------------------------------------------
  1562. //---------------------------------------------------------------------------
  1563. int __fastcall TCustomCommands::GetParam(const AnsiString & Name)
  1564. {
  1565. int Index = IndexOfName(Name);
  1566. if (Index >= 0)
  1567. {
  1568. return int(Objects[Index]);
  1569. }
  1570. else
  1571. {
  1572. return 0;
  1573. }
  1574. }
  1575. //---------------------------------------------------------------------------
  1576. void __fastcall TCustomCommands::SetParam(const AnsiString & Name, int value)
  1577. {
  1578. int Index = IndexOfName(Name);
  1579. if (Index >= 0)
  1580. {
  1581. Objects[Index] = (TObject *)value;
  1582. }
  1583. else
  1584. {
  1585. Values[Name] = "";
  1586. Index = IndexOfName(Name);
  1587. assert(Index >= 0);
  1588. Objects[Index] = (TObject *)value;
  1589. }
  1590. }
  1591. //---------------------------------------------------------------------------
  1592. bool __fastcall TCustomCommands::Equals(TCustomCommands * Commands)
  1593. {
  1594. bool Result = TStringList::Equals(Commands);
  1595. if (Result)
  1596. {
  1597. int Index = 0;
  1598. while ((Index < Count) && Result)
  1599. {
  1600. if (Objects[Index] != Commands->Objects[Index])
  1601. {
  1602. Result = false;
  1603. }
  1604. Index++;
  1605. }
  1606. }
  1607. return Result;
  1608. }