| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "WinConfiguration.h"
- #include "Common.h"
- #include "Exceptions.h"
- #include "Bookmarks.h"
- #include "Terminal.h"
- #include "TextsWin.h"
- #include "WinInterface.h"
- #include "GUITools.h"
- #include "Tools.h"
- #include <VCLCommon.h>
- #include <ResourceModule.hpp>
- #include <LanguagesDEPfix.hpp>
- #include <InitGUID.h>
- #include <DragExt.h>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- __fastcall TEditorPreferences::TEditorPreferences()
- {
- FData.FileMask = "*.*";
- FData.Editor = edInternal;
- FData.ExternalEditor = "";
- FData.ExternalEditorText = true;
- FData.MDIExternalEditor = false;
- FData.DetectMDIExternalEditor = true;
- }
- //---------------------------------------------------------------------------
- __fastcall TEditorPreferences::TEditorPreferences(const TEditorPreferences & Source)
- {
- FData.FileMask = Source.FData.FileMask;
- FData.Editor = Source.FData.Editor;
- FData.ExternalEditor = Source.FData.ExternalEditor;
- FData.ExternalEditorText = Source.FData.ExternalEditorText;
- FData.MDIExternalEditor = Source.FData.MDIExternalEditor;
- FData.DetectMDIExternalEditor = Source.FData.DetectMDIExternalEditor;
- }
- //---------------------------------------------------------------------------
- #define C(Property) (Property == rhp.Property)
- bool __fastcall TEditorPreferences::operator==(const TEditorPreferences & rhp) const
- {
- return
- C(FData.FileMask) &&
- C(FData.Editor) &&
- C(FData.ExternalEditor) &&
- C(FData.ExternalEditorText) &&
- C(FData.MDIExternalEditor) &&
- C(FData.DetectMDIExternalEditor) &&
- true;
- }
- #undef C
- //---------------------------------------------------------------------------
- bool __fastcall TEditorPreferences::Matches(const AnsiString FileName,
- bool Local, const TFileMasks::TParams & Params) const
- {
- return FData.FileMask.Matches(FileName, Local, false, &Params);
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorPreferences::LegacyDefaults()
- {
- FData.ExternalEditor = "notepad.exe";
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorPreferences::Load(THierarchicalStorage * Storage, bool Legacy)
- {
- if (!Legacy)
- {
- FData.FileMask = Storage->ReadString("FileMask", FData.FileMask.Masks);
- }
- FData.Editor = (TEditor)Storage->ReadInteger("Editor", FData.Editor);
- FData.ExternalEditor = Storage->ReadString("ExternalEditor", FData.ExternalEditor);
- FData.ExternalEditorText = Storage->ReadBool("ExternalEditorText", FData.ExternalEditorText);
- FData.MDIExternalEditor = Storage->ReadBool("MDIExternalEditor", FData.MDIExternalEditor);
- FData.DetectMDIExternalEditor = Storage->ReadBool("DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorPreferences::Save(THierarchicalStorage * Storage) const
- {
- Storage->WriteString("FileMask", FData.FileMask.Masks);
- Storage->WriteInteger("Editor", FData.Editor);
- Storage->WriteString("ExternalEditor", FData.ExternalEditor);
- Storage->WriteBool("ExternalEditorText", FData.ExternalEditorText);
- Storage->WriteBool("MDIExternalEditor", FData.MDIExternalEditor);
- Storage->WriteBool("DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
- }
- //---------------------------------------------------------------------------
- AnsiString __fastcall TEditorPreferences::GetName() const
- {
- if (FName.IsEmpty())
- {
- if (FData.Editor == edInternal)
- {
- FName = StripHotkey(LoadStr(INTERNAL_EDITOR_NAME));
- }
- else
- {
- AnsiString Program, Params, Dir;
- AnsiString ExternalEditor = FData.ExternalEditor;
- ReformatFileNameCommand(ExternalEditor);
- SplitCommand(ExternalEditor, Program, Params, Dir);
- FName = ExtractFileName(Program);
- int P = FName.LastDelimiter(".");
- if (P > 0)
- {
- FName.SetLength(P - 1);
- }
- if (FName.ByteType(1) == mbSingleByte)
- {
- if (FName.UpperCase() == FName)
- {
- FName = FName.LowerCase();
- }
- if (FName.LowerCase() == FName)
- {
- FName = FName.SubString(1, 1).UpperCase() +
- FName.SubString(2, FName.Length() - 1);
- }
- }
- }
- }
- return FName;
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- __fastcall TEditorList::TEditorList()
- {
- Init();
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Init()
- {
- FEditors = new TList();
- FModified = false;
- }
- //---------------------------------------------------------------------------
- __fastcall TEditorList::~TEditorList()
- {
- Clear();
- delete FEditors;
- }
- //---------------------------------------------------------------------
- void __fastcall TEditorList::Modify()
- {
- FModified = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Saved()
- {
- FModified = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::operator=(const TEditorList & rhl)
- {
- Clear();
- for (int Index = 0; Index < rhl.Count; Index++)
- {
- Add(new TEditorPreferences(*rhl.Editors[Index]));
- }
- // there should be comparison of with the assigned list, be we rely on caller
- // to do it instead (TWinConfiguration::SetEditorList)
- Modify();
- }
- //---------------------------------------------------------------------------
- bool __fastcall TEditorList::operator==(const TEditorList & rhl) const
- {
- bool Result = (Count == rhl.Count);
- if (Result)
- {
- int i = 0;
- while ((i < Count) && Result)
- {
- Result = (*Editors[i]) == (*rhl.Editors[i]);
- i++;
- }
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Clear()
- {
- for (int i = 0; i < Count; i++)
- {
- delete Editors[i];
- }
- FEditors->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Add(TEditorPreferences * Editor)
- {
- Insert(Count, Editor);
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Insert(int Index, TEditorPreferences * Editor)
- {
- FEditors->Insert(Index, reinterpret_cast<TObject *>(Editor));
- Modify();
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Change(int Index, TEditorPreferences * Editor)
- {
- if (!((*Editors[Index]) == *Editor))
- {
- delete Editors[Index];
- FEditors->Items[Index] = (reinterpret_cast<TObject *>(Editor));
- Modify();
- }
- else
- {
- delete Editor;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Move(int CurIndex, int NewIndex)
- {
- if (CurIndex != NewIndex)
- {
- FEditors->Move(CurIndex, NewIndex);
- Modify();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Delete(int Index)
- {
- assert((Index >= 0) && (Index < Count));
- delete Editors[Index];
- FEditors->Delete(Index);
- Modify();
- }
- //---------------------------------------------------------------------------
- const TEditorPreferences * __fastcall TEditorList::Find(
- const AnsiString FileName, bool Local, const TFileMasks::TParams & Params) const
- {
- const TEditorPreferences * Result = NULL;
- int i = 0;
- while ((i < FEditors->Count) && (Result == NULL))
- {
- Result = Editors[i];
- if (!Result->Matches(FileName, Local, Params))
- {
- Result = NULL;
- }
- i++;
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Load(THierarchicalStorage * Storage)
- {
- int Index = 0;
- bool Next;
- do
- {
- AnsiString Name = IntToStr(Index);
- TEditorPreferences * Editor = NULL;
- try
- {
- Next = Storage->OpenSubKey(Name, false);
- if (Next)
- {
- try
- {
- Editor = new TEditorPreferences();
- Editor->Load(Storage, false);
- }
- __finally
- {
- Storage->CloseSubKey();
- }
- }
- }
- catch(...)
- {
- delete Editor;
- throw;
- }
- if (Editor != NULL)
- {
- FEditors->Add(reinterpret_cast<TObject *>(Editor));
- }
- Index++;
- }
- while (Next);
- FModified = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TEditorList::Save(THierarchicalStorage * Storage) const
- {
- Storage->ClearSubKeys();
- for (int Index = 0; Index < Count; Index++)
- {
- if (Storage->OpenSubKey(IntToStr(Index), true))
- {
- try
- {
- Editors[Index]->Save(Storage);
- }
- __finally
- {
- Storage->CloseSubKey();
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- int __fastcall TEditorList::GetCount() const
- {
- int X = FEditors->Count;
- return X;
- }
- //---------------------------------------------------------------------------
- const TEditorPreferences * __fastcall TEditorList::GetEditor(int Index) const
- {
- return reinterpret_cast<TEditorPreferences *>(FEditors->Items[Index]);
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- __fastcall TWinConfiguration::TWinConfiguration(): TCustomWinConfiguration()
- {
- FInvalidDefaultTranslationMessage = "";
- FDDExtInstalled = -1;
- FBookmarks = new TBookmarks();
- FCustomCommands = new TCustomCommands();
- FEditorList = new TEditorList();
- FDefaultUpdatesPeriod = 0;
- Default();
- try
- {
- CheckTranslationVersion(::GetResourceModule(ModuleFileName().c_str()), true);
- }
- catch(Exception & E)
- {
- FInvalidDefaultTranslationMessage = E.Message;
- }
- }
- //---------------------------------------------------------------------------
- __fastcall TWinConfiguration::~TWinConfiguration()
- {
- if (!FTemporarySessionFile.IsEmpty()) DeleteFile(FTemporarySessionFile);
- ClearTemporaryLoginData();
- delete FBookmarks;
- delete FCustomCommands;
- delete FEditorList;
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::Default()
- {
- FCustomCommandsDefaults = true;
- TCustomWinConfiguration::Default();
- FDDAllowMove = false;
- FDDAllowMoveInit = false;
- FDDTransferConfirmation = true;
- FDDTemporaryDirectory = "";
- FDDWarnLackOfTempSpace = true;
- FDDWarnLackOfTempSpaceRatio = 1.1;
- FDDExtEnabled = DDExtInstalled;
- FDDExtTimeout = 1000;
- FDeleteToRecycleBin = true;
- FSelectDirectories = false;
- FSelectMask = "*.*";
- FShowHiddenFiles = true;
- FShowInaccesibleDirectories = true;
- FConfirmTransferring = true;
- FConfirmDeleting = true;
- FConfirmRecycling = true;
- FConfirmClosingSession = true;
- FConfirmExitOnCompletion = true;
- FDoubleClickAction = dcaEdit;
- FCopyOnDoubleClickConfirmation = false;
- FDimmHiddenFiles = true;
- FAutoStartSession = "";
- FExpertMode = true;
- FUseLocationProfiles = false;
- FDefaultDirIsHome = true;
- FDDDeleteDelay = 120;
- FTemporaryDirectoryCleanup = true;
- FConfirmTemporaryDirectoryCleanup = true;
- FPreservePanelState = true;
- FTheme = "OfficeXP";
- FPathInCaption = picShort;
- FMinimizeToTray = false;
- FBalloonNotifications = true;
- FNotificationsTimeout = 10;
- FNotificationsStickTime = 2;
- FCopyParamAutoSelectNotice = true;
- FSessionToolbarAutoShown = false;
- FLockToolbars = false;
- FAutoOpenInPutty = false;
- FEditor.FontName = "Courier New";
- FEditor.FontHeight = -12;
- FEditor.FontStyle = 0;
- FEditor.FontCharset = DEFAULT_CHARSET;
- FEditor.WordWrap = false;
- FEditor.FindText = "";
- FEditor.ReplaceText = "";
- FEditor.FindMatchCase = false;
- FEditor.FindWholeWord = false;
- FEditor.FindDown = true;
- FEditor.TabSize = 7;
- FEditor.MaxEditors = 500;
- FEditor.EarlyClose = 2; // seconds
- FQueueView.Height = 100;
- FQueueView.Layout = "70,160,160,80,80,80";
- FQueueView.Show = qvHideWhenEmpty;
- FQueueView.LastHideShow = qvHideWhenEmpty;
- FQueueView.ToolBar = false;
- FUpdates.Period = FDefaultUpdatesPeriod;
- FUpdates.LastCheck = 0;
- FUpdates.HaveResults = false;
- FUpdates.ShownResults = false;
- // for backward compatibility the default is decided based on value of ProxyHost
- FUpdates.ConnectionType = (TConnectionType)-1;
- FUpdates.ProxyHost = ""; // keep empty (see above)
- FUpdates.ProxyPort = 8080;
- FUpdates.Results.Reset();
- FLogWindowOnStartup = true;
- FLogWindowParams = "-1;-1;500;400";
- FScpExplorer.WindowParams = "-1;-1;600;400;0";
- 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";
- FScpExplorer.ToolbarsLayout =
- "Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
- "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
- "Buttons_Visible=1,Buttons_DockedTo=TopDock,Buttons_LastDock=TopDock,Buttons_DockRow=2,Buttons_DockPos=0,Buttons_FloatLeft=0,Buttons_FloatTop=0,Buttons_FloatRightX=0,"
- "Selection_Visible=0,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=3,Selection_DockPos=0,Selection_FloatLeft=227,Selection_FloatTop=445,Selection_FloatRightX=0,"
- "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=6,Session_DockPos=0,Session_FloatLeft=39,Session_FloatTop=160,Session_FloatRightX=0,"
- "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=4,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
- "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=5,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
- "Address_Visible=1,Address_DockedTo=TopDock,Address_LastDock=TopDock,Address_DockRow=1,Address_DockPos=0,Address_FloatLeft=0,Address_FloatTop=0,Address_FloatRightX=0,"
- "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=4,Updates_DockPos=302,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
- "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=4,Transfer_DockPos=155,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0"
- "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=7,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0";
- FScpExplorer.StatusBar = true;
- AnsiString PersonalFolder;
- ::SpecialFolderLocation(CSIDL_PERSONAL, PersonalFolder);
- FScpExplorer.LastLocalTargetDirectory = PersonalFolder;
- FScpExplorer.ViewStyle = 0; /* vsIcon */
- FScpExplorer.ShowFullAddress = true;
- FScpExplorer.DriveView = true;
- FScpExplorer.DriveViewWidth = 180;
- FScpCommander.WindowParams = ((Screen->Width > 900) && (Screen->Height > 700)) ?
- "-1;-1;850;650;0" : "-1;-1;600;400;0";
- FScpCommander.LocalPanelWidth = 0.5;
- FScpCommander.SwappedPanels = false;
- FScpCommander.StatusBar = true;
- FScpCommander.NortonLikeMode = nlOn;
- FScpCommander.PreserveLocalDirectory = false;
- // Toolbar_FloatRightX=1 makes keybar apper initialy "in column" when undocked
- FScpCommander.ToolbarsLayout =
- "Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
- "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=1,Session_DockPos=602,Session_FloatLeft=380,Session_FloatTop=197,Session_FloatRightX=0,"
- "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=1,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
- "Selection_Visible=1,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=1,Selection_DockPos=257,Selection_FloatLeft=0,Selection_FloatTop=0,Selection_FloatRightX=0,"
- "Command_Visible=0,Command_DockedTo=TopDock,Command_LastDock=TopDock,Command_DockRow=2,Command_DockPos=0,Command_FloatLeft=0,Command_FloatTop=0,Command_FloatRightX=0,"
- "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=3,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
- "Commands_Visible=1,Commands_DockedTo=TopDock,Commands_LastDock=TopDock,Commands_DockRow=1,Commands_DockPos=97,Commands_FloatLeft=0,Commands_FloatTop=0,Commands_FloatRightX=0,"
- "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
- "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=1,Updates_DockPos=557,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
- "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=1,Transfer_DockPos=411,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0,"
- "UploadDownload_Visible=0,UploadDownload_DockedTo=TopDock,UploadDownload_LastDock=TopDock,UploadDownload_DockRow=4,UploadDownload_DockPos=0,UploadDownload_FloatLeft=0,UploadDownload_FloatTop=0,UploadDownload_FloatRightX=0,"
- "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=5,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0,"
- "RemotePath_Visible=1,RemotePath_DockedTo=RemoteTopDock,RemotePath_LastDock=RemoteTopDock,RemotePath_DockRow=0,RemotePath_DockPos=0,RemotePath_FloatLeft=0,RemotePath_FloatTop=0,RemotePath_FloatRightX=0,"
- "RemoteHistory_Visible=1,RemoteHistory_DockedTo=RemoteTopDock,RemoteHistory_LastDock=RemoteTopDock,RemoteHistory_DockRow=0,RemoteHistory_DockPos=208,RemoteHistory_FloatLeft=0,RemoteHistory_FloatTop=0,RemoteHistory_FloatRightX=0,"
- "RemoteNavigation_Visible=1,RemoteNavigation_DockedTo=RemoteTopDock,RemoteNavigation_LastDock=RemoteTopDock,RemoteNavigation_DockRow=0,RemoteNavigation_DockPos=288,RemoteNavigation_FloatLeft=0,RemoteNavigation_FloatTop=0,RemoteNavigation_FloatRightX=0,"
- "LocalPath_Visible=1,LocalPath_DockedTo=LocalTopDock,LocalPath_LastDock=LocalTopDock,LocalPath_DockRow=0,LocalPath_DockPos=0,LocalPath_FloatLeft=0,LocalPath_FloatTop=0,LocalPath_FloatRightX=0,"
- "LocalHistory_Visible=1,LocalHistory_DockedTo=LocalTopDock,LocalHistory_LastDock=LocalTopDock,LocalHistory_DockRow=0,LocalHistory_DockPos=207,LocalHistory_FloatLeft=0,LocalHistory_FloatTop=0,LocalHistory_FloatRightX=0,"
- "LocalNavigation_Visible=1,LocalNavigation_DockedTo=LocalTopDock,LocalNavigation_LastDock=LocalTopDock,LocalNavigation_DockRow=0,LocalNavigation_DockPos=287,LocalNavigation_FloatLeft=0,LocalNavigation_FloatTop=0,LocalNavigation_FloatRightX=0,"
- "Toolbar_Visible=1,Toolbar_DockedTo=BottomDock,Toolbar_LastDock=BottomDock,Toolbar_DockRow=1,Toolbar_DockPos=0,Toolbar_FloatLeft=0,Toolbar_FloatTop=0,Toolbar_FloatRightX=1,"
- "CommandLine_Visible=0,CommandLine_DockedTo=BottomDock,CommandLine_LastDock=BottomDock,CommandLine_DockRow=0,CommandLine_DockPos=0,CommandLine_FloatLeft=0,CommandLine_FloatTop=0,CommandLine_FloatRightX=0";
- FScpCommander.CurrentPanel = osLocal;
- FScpCommander.CompareByTime = true;
- FScpCommander.CompareBySize = false;
- FScpCommander.FullRowSelect = true;
- 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";
- FScpCommander.RemotePanel.StatusBar = true;
- FScpCommander.RemotePanel.DriveView = false;
- FScpCommander.RemotePanel.DriveViewHeight = 100;
- FScpCommander.LocalPanel.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,0|0;1;2;3;4;5";
- FScpCommander.LocalPanel.StatusBar = true;
- FScpCommander.LocalPanel.DriveView = false;
- FScpCommander.LocalPanel.DriveViewHeight = 100;
- FBookmarks->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::DefaultLocalized()
- {
- TGUIConfiguration::DefaultLocalized();
- if (FCustomCommandsDefaults)
- {
- FCustomCommands->Clear();
- FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_EXECUTE)] = "\"./!\"";
- FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_EXECUTE)] = 0;
- FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_TOUCH)] = "touch \"!\"";
- FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_TOUCH)] = ccApplyToDirectories | ccRecursive;
- FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_TAR)] =
- FORMAT("tar -cz -f \"!?%s?archive.tgz!\" !&",
- (LoadStr(CUSTOM_COMMAND_TAR_ARCHIVE)));
- FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_TAR)] = ccApplyToDirectories;
- FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_UNTAR)] =
- FORMAT("tar -xz --directory=\"!?%s?.!\" -f \"!\"",
- (LoadStr(CUSTOM_COMMAND_UNTAR_DIRECTORY)));
- FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_UNTAR)] = 0;
- FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_GREP)] =
- FORMAT("grep \"!?%s?!\" !&", (LoadStr(CUSTOM_COMMAND_GREP_PATTERN)));
- FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_GREP)] = ccShowResults;
- if (Win32Platform == VER_PLATFORM_WIN32_NT)
- {
- FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_FC)] =
- "cmd /c fc \"!\" \"\!^!\" | more && pause";
- FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_FC)] = ccLocal;
- }
- FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_PRINT)] = "notepad.exe /p \"!\"";
- FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_PRINT)] = ccLocal;
- FCustomCommandsDefaults = true;
- FCustomCommandsModified = false;
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TWinConfiguration::DetectRegistryStorage(HKEY RootKey)
- {
- bool Result = false;
- TRegistryStorage * Storage = new TRegistryStorage(RegistryStorageKey, RootKey);
- try
- {
- if (Storage->OpenRootKey(false))
- {
- Result = true;
- Storage->CloseSubKey();
- }
- }
- __finally
- {
- delete Storage;
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TWinConfiguration::CanWriteToStorage()
- {
- bool Result = false;
- try
- {
- THierarchicalStorage * Storage = CreateScpStorage(false);
- try
- {
- Storage->AccessMode = smReadWrite;
- if (Storage->OpenSubKey(ConfigurationSubKey, true))
- {
- Storage->WriteBool("WriteTest", true);
- Storage->DeleteValue("WriteTest");
- }
- }
- __finally
- {
- delete Storage;
- }
- Result = true;
- }
- catch(...)
- {
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- TStorage __fastcall TWinConfiguration::GetStorage()
- {
- if (FStorage == stDetect)
- {
- if (FindResourceEx(NULL, RT_RCDATA, "WINSCP_SESSION",
- MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)))
- {
- FTemporarySessionFile =
- IncludeTrailingBackslash(SystemTemporaryDirectory()) + "winscps.tmp";
- DumpResourceToFile("WINSCP_SESSION", FTemporarySessionFile);
- FEmbeddedSessions = true;
- FTemporaryKeyFile =
- IncludeTrailingBackslash(SystemTemporaryDirectory()) + "winscpk.tmp";
- if (!DumpResourceToFile("WINSCP_KEY", FTemporaryKeyFile))
- {
- FTemporaryKeyFile = "";
- }
- }
- FStorage = stIniFile;
- if (!FileExists(IniFileStorageName))
- {
- if (DetectRegistryStorage(HKEY_CURRENT_USER) ||
- DetectRegistryStorage(HKEY_LOCAL_MACHINE) ||
- !CanWriteToStorage())
- {
- FStorage = stRegistry;
- }
- }
- }
- return TCustomWinConfiguration::GetStorage();
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::Saved()
- {
- TCustomWinConfiguration::Saved();
- FBookmarks->ModifyAll(false);
- FCustomCommandsModified = false;
- FEditorList->Saved();
- }
- //---------------------------------------------------------------------------
- THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool SessionList)
- {
- if (SessionList && !FTemporarySessionFile.IsEmpty())
- {
- return new TIniFileStorage(FTemporarySessionFile);
- }
- else
- {
- return TCustomWinConfiguration::CreateScpStorage(SessionList);
- }
- }
- //---------------------------------------------------------------------------
- // duplicated from core\configuration.cpp
- #define LASTELEM(ELEM) \
- ELEM.SubString(ELEM.LastDelimiter(".>")+1, ELEM.Length() - ELEM.LastDelimiter(".>"))
- #define BLOCK(KEY, CANCREATE, BLOCK) \
- if (Storage->OpenSubKey(KEY, CANCREATE, true)) try { BLOCK } __finally { Storage->CloseSubKey(); }
- #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, VAR)
- #define REGCONFIG(CANCREATE) \
- BLOCK("Interface", CANCREATE, \
- KEYEX(Integer,DoubleClickAction, CopyOnDoubleClick); \
- KEY(Bool, CopyOnDoubleClickConfirmation); \
- KEY(Bool, DDAllowMove); \
- KEY(Bool, DDAllowMoveInit); \
- KEY(Bool, DDTransferConfirmation); \
- KEY(String, DDTemporaryDirectory); \
- KEY(Bool, DDWarnLackOfTempSpace); \
- KEY(Float, DDWarnLackOfTempSpaceRatio); \
- KEY(Bool, DeleteToRecycleBin); \
- KEY(Bool, DimmHiddenFiles); \
- KEY(Bool, SelectDirectories); \
- KEY(String, SelectMask); \
- KEY(Bool, ShowHiddenFiles); \
- KEY(Bool, ShowInaccesibleDirectories); \
- KEY(Bool, ConfirmTransferring); \
- KEY(Bool, ConfirmDeleting); \
- KEY(Bool, ConfirmRecycling); \
- KEY(Bool, ConfirmClosingSession); \
- KEY(Bool, ConfirmExitOnCompletion); \
- KEY(String, AutoStartSession); \
- KEY(Bool, UseLocationProfiles); \
- KEY(Integer, LocaleSafe); \
- KEY(Bool, DDExtEnabled); \
- KEY(Integer, DDExtTimeout); \
- KEY(Bool, DefaultDirIsHome); \
- KEY(Bool, TemporaryDirectoryCleanup); \
- KEY(Bool, ConfirmTemporaryDirectoryCleanup); \
- KEY(Bool, PreservePanelState); \
- KEY(String, Theme); \
- KEY(Integer, PathInCaption); \
- KEY(Bool, MinimizeToTray); \
- KEY(Bool, BalloonNotifications); \
- KEY(Integer, NotificationsTimeout); \
- KEY(Integer, NotificationsStickTime); \
- KEY(Bool, CopyParamAutoSelectNotice); \
- KEY(Bool, SessionToolbarAutoShown); \
- KEY(Bool, LockToolbars); \
- KEY(Bool, AutoOpenInPutty); \
- KEY(Integer, LastMonitor); \
- ); \
- BLOCK("Interface\\Editor", CANCREATE, \
- KEY(String, Editor.FontName); \
- KEY(Integer, Editor.FontHeight); \
- KEY(Integer, Editor.FontStyle); \
- KEY(Integer, Editor.FontCharset); \
- KEY(Bool, Editor.WordWrap); \
- KEY(String, Editor.FindText); \
- KEY(String, Editor.ReplaceText); \
- KEY(Bool, Editor.FindMatchCase); \
- KEY(Bool, Editor.FindWholeWord); \
- KEY(Bool, Editor.FindDown); \
- KEY(Integer, Editor.TabSize); \
- KEY(Integer, Editor.MaxEditors); \
- KEY(Integer, Editor.EarlyClose); \
- ); \
- BLOCK("Interface\\QueueView", CANCREATE, \
- KEY(Integer, QueueView.Height); \
- KEY(String, QueueView.Layout); \
- KEY(Integer, QueueView.Show); \
- KEY(Integer, QueueView.LastHideShow); \
- KEY(Bool, QueueView.ToolBar); \
- ); \
- BLOCK("Interface\\Updates", CANCREATE, \
- KEY(Integer, FUpdates.Period); \
- KEY(DateTime, FUpdates.LastCheck); \
- KEY(Integer, FUpdates.HaveResults); \
- KEY(Integer, FUpdates.ShownResults); \
- KEY(Integer, FUpdates.ConnectionType); \
- KEY(String, FUpdates.ProxyHost); \
- KEY(Integer, FUpdates.ProxyPort); \
- KEY(Integer, FUpdates.Results.ForVersion); \
- KEY(Integer, FUpdates.Results.Version); \
- KEY(String, FUpdates.Results.Message); \
- KEY(Integer, FUpdates.Results.Critical); \
- KEY(String, FUpdates.Results.Release); \
- KEY(Bool, FUpdates.Results.Disabled); \
- KEY(String, FUpdates.Results.Url); \
- KEY(String, FUpdates.Results.UrlButton); \
- ); \
- BLOCK("Interface\\Explorer", CANCREATE, \
- KEY(String, ScpExplorer.ToolbarsLayout); \
- KEY(String, ScpExplorer.DirViewParams); \
- KEY(String, ScpExplorer.LastLocalTargetDirectory); \
- KEY(Bool, ScpExplorer.StatusBar); \
- KEY(String, ScpExplorer.WindowParams); \
- KEY(Integer, ScpExplorer.ViewStyle); \
- KEY(Bool, ScpExplorer.ShowFullAddress); \
- KEY(Bool, ScpExplorer.DriveView); \
- KEY(Integer, ScpExplorer.DriveViewWidth); \
- ); \
- BLOCK("Interface\\Commander", CANCREATE, \
- KEY(String, ScpCommander.ToolbarsLayout); \
- KEY(Integer, ScpCommander.CurrentPanel); \
- KEY(Float, ScpCommander.LocalPanelWidth); \
- KEY(Bool, ScpCommander.SwappedPanels); \
- KEY(Bool, ScpCommander.StatusBar); \
- KEY(String, ScpCommander.WindowParams); \
- KEYEX(Integer, ScpCommander.NortonLikeMode, ExplorerStyleSelection); \
- KEY(Bool, ScpCommander.PreserveLocalDirectory); \
- KEY(Bool, ScpCommander.CompareByTime); \
- KEY(Bool, ScpCommander.CompareBySize); \
- KEY(Bool, ScpCommander.FullRowSelect); \
- ); \
- BLOCK("Interface\\Commander\\LocalPanel", CANCREATE, \
- KEY(String, ScpCommander.LocalPanel.DirViewParams); \
- KEY(Bool, ScpCommander.LocalPanel.StatusBar); \
- KEY(Bool, ScpCommander.LocalPanel.DriveView); \
- KEY(Integer, ScpCommander.LocalPanel.DriveViewHeight); \
- ); \
- BLOCK("Interface\\Commander\\RemotePanel", CANCREATE, \
- KEY(String, ScpCommander.RemotePanel.DirViewParams); \
- KEY(Bool, ScpCommander.RemotePanel.StatusBar); \
- KEY(Bool, ScpCommander.RemotePanel.DriveView); \
- KEY(Integer, ScpCommander.RemotePanel.DriveViewHeight); \
- ); \
- BLOCK("Logging", CANCREATE, \
- KEY(Bool, LogWindowOnStartup); \
- KEY(String, LogWindowParams); \
- );
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SaveData(THierarchicalStorage * Storage, bool All)
- {
- TCustomWinConfiguration::SaveData(Storage, All);
- // duplicated from core\configuration.cpp
- #define KEYEX(TYPE, VAR, NAME) Storage->Write ## TYPE(LASTELEM(AnsiString(#NAME)), VAR)
- REGCONFIG(true);
- #undef KEYEX
- if (Storage->OpenSubKey("Bookmarks", true))
- {
- FBookmarks->Save(Storage, All);
- Storage->CloseSubKey();
- }
- if ((All && !FCustomCommandsDefaults) || FCustomCommandsModified)
- {
- if (Storage->OpenSubKey("CustomCommands", true))
- {
- Storage->WriteValues(FCustomCommands, true);
- Storage->CloseSubKey();
- }
- if (Storage->OpenSubKey("CustomCommandsParams", true))
- {
- Storage->ClearValues();
- for (int Index = 0; Index < FCustomCommands->Count; Index++)
- {
- Storage->WriteInteger(FCustomCommands->Names[Index],
- FCustomCommands->Params[FCustomCommands->Names[Index]]);
- }
- Storage->CloseSubKey();
- }
- }
- if ((All || FEditorList->Modified) &&
- Storage->OpenSubKey("Interface\\Editor", true, true))
- try
- {
- FEditorList->Save(Storage);
- }
- __finally
- {
- Storage->CloseSubKey();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::Load()
- {
- FLegacyEditor = new TEditorPreferences();
- try
- {
- FLegacyEditor->LegacyDefaults();
- TCustomWinConfiguration::Load();
- int EditorCount = FEditorList->Count;
- if (EditorCount == 0)
- {
- TEditorPreferences * AlternativeEditor = NULL;
- try
- {
- if (FLegacyEditor->Data.Editor == edInternal)
- {
- if (!FLegacyEditor->Data.ExternalEditor.IsEmpty())
- {
- AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
- AlternativeEditor->Data.Editor = edExternal;
- FLegacyEditor->Data.ExternalEditor = "";
- }
- }
- else
- {
- if (FLegacyEditor->Data.ExternalEditor.IsEmpty())
- {
- FLegacyEditor->Data.Editor = edInternal;
- }
- else
- {
- AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
- AlternativeEditor->Data.Editor = edInternal;
- }
- }
- }
- catch(...)
- {
- delete AlternativeEditor;
- throw;
- }
- FEditorList->Add(FLegacyEditor);
- FLegacyEditor = NULL;
- if (AlternativeEditor != NULL)
- {
- FEditorList->Add(AlternativeEditor);
- }
- }
- }
- __finally
- {
- delete FLegacyEditor;
- FLegacyEditor = NULL;
- }
- if (FUpdates.ConnectionType == -1)
- {
- FUpdates.ConnectionType = (FUpdates.ProxyHost.IsEmpty() ? ctAuto : ctProxy);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::LoadData(THierarchicalStorage * Storage)
- {
- TCustomWinConfiguration::LoadData(Storage);
- // duplicated from core\configuration.cpp
- #define KEYEX(TYPE, VAR, NAME) VAR = Storage->Read ## TYPE(LASTELEM(AnsiString(#NAME)), VAR)
- #pragma warn -eas
- REGCONFIG(false);
- #pragma warn +eas
- #undef KEYEX
- if (Storage->OpenSubKey("Bookmarks", false))
- {
- FBookmarks->Load(Storage);
- Storage->CloseSubKey();
- }
- if (Storage->OpenSubKey("CustomCommands", false))
- {
- FCustomCommands->Clear();
- Storage->ReadValues(FCustomCommands, true);
- Storage->CloseSubKey();
- if (Storage->OpenSubKey("CustomCommandsParams", false))
- {
- for (int Index = 0; Index < FCustomCommands->Count; Index++)
- {
- AnsiString Name = FCustomCommands->Names[Index];
- FCustomCommands->Params[Name] =
- Storage->ReadInteger(Name, FCustomCommands->Params[Name]);
- }
- Storage->CloseSubKey();
- }
- FCustomCommandsDefaults = false;
- }
- else if (FCustomCommandsModified)
- {
- FCustomCommands->Clear();
- FCustomCommandsDefaults = false;
- }
- FCustomCommandsModified = false;
- if (Storage->OpenSubKey("Interface\\Editor", false, true))
- try
- {
- FEditorList->Clear();
- FEditorList->Load(Storage);
- }
- __finally
- {
- Storage->CloseSubKey();
- }
- // load legacy editor configuration
- assert(FLegacyEditor != NULL);
- if (Storage->OpenSubKey("Interface\\Editor", false, true))
- {
- try
- {
- FLegacyEditor->Load(Storage, true);
- }
- __finally
- {
- Storage->CloseSubKey();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::LoadAdmin(THierarchicalStorage * Storage)
- {
- TCustomWinConfiguration::LoadAdmin(Storage);
- FDisableOpenEdit = Storage->ReadBool("DisableOpenEdit", FDisableOpenEdit);
- FDefaultUpdatesPeriod = Storage->ReadInteger("DefaultUpdatesPeriod", FDefaultUpdatesPeriod);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::ClearTemporaryLoginData()
- {
- if (!FTemporaryKeyFile.IsEmpty())
- {
- DeleteFile(FTemporaryKeyFile);
- FTemporaryKeyFile = "";
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TWinConfiguration::GetDDExtInstalled()
- {
- if (FDDExtInstalled < 0)
- {
- if (IsWin64())
- {
- // temporarily consider dragext always present on 64-bit system
- FDDExtInstalled = 1;
- }
- else
- {
- void * DragExtRef;
- bool Result;
- Result = (CoCreateInstance(CLSID_ShellExtension, NULL,
- CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown,
- &DragExtRef) == S_OK);
- FDDExtInstalled = (Result ? 1 : 0);
- if (Result)
- {
- reinterpret_cast<IUnknown *>(DragExtRef)->Release();
- CoFreeUnusedLibraries();
- }
- }
- }
- return (FDDExtInstalled > 0);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetLogWindowOnStartup(bool value)
- {
- SET_CONFIG_PROPERTY(LogWindowOnStartup);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetLogWindowParams(AnsiString value)
- {
- SET_CONFIG_PROPERTY(LogWindowParams);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDAllowMove(bool value)
- {
- SET_CONFIG_PROPERTY(DDAllowMove);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDAllowMoveInit(bool value)
- {
- SET_CONFIG_PROPERTY(DDAllowMoveInit);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDTransferConfirmation(bool value)
- {
- SET_CONFIG_PROPERTY(DDTransferConfirmation);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDTemporaryDirectory(AnsiString value)
- {
- SET_CONFIG_PROPERTY(DDTemporaryDirectory);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDExtEnabled(bool value)
- {
- SET_CONFIG_PROPERTY(DDExtEnabled);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDExtTimeout(int value)
- {
- SET_CONFIG_PROPERTY(DDExtTimeout);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpace(bool value)
- {
- SET_CONFIG_PROPERTY(DDWarnLackOfTempSpace);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpaceRatio(double value)
- {
- SET_CONFIG_PROPERTY(DDWarnLackOfTempSpaceRatio);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetScpExplorer(TScpExplorerConfiguration value)
- {
- SET_CONFIG_PROPERTY(ScpExplorer);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetScpCommander(TScpCommanderConfiguration value)
- {
- SET_CONFIG_PROPERTY(ScpCommander);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetEditor(TEditorConfiguration value)
- {
- SET_CONFIG_PROPERTY(Editor);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetQueueView(TQueueViewConfiguration value)
- {
- SET_CONFIG_PROPERTY(QueueView);
- }
- //---------------------------------------------------------------------------
- TUpdatesConfiguration __fastcall TWinConfiguration::GetUpdates()
- {
- TUpdatesConfiguration Result;
- {
- TGuard Guard(FCriticalSection);
- Result = FUpdates;
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetUpdates(TUpdatesConfiguration value)
- {
- TGuard Guard(FCriticalSection);
- // do not use SET_CONFIG_PROPERTY to avoid OnChange handler call (not synchronized)
- FUpdates = value;
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDeleteToRecycleBin(bool value)
- {
- SET_CONFIG_PROPERTY(DeleteToRecycleBin);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetSelectDirectories(bool value)
- {
- SET_CONFIG_PROPERTY(SelectDirectories);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetShowHiddenFiles(bool value)
- {
- SET_CONFIG_PROPERTY(ShowHiddenFiles);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetShowInaccesibleDirectories(bool value)
- {
- SET_CONFIG_PROPERTY(ShowInaccesibleDirectories);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetConfirmTransferring(bool value)
- {
- SET_CONFIG_PROPERTY(ConfirmTransferring);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetConfirmDeleting(bool value)
- {
- SET_CONFIG_PROPERTY(ConfirmDeleting);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetConfirmRecycling(bool value)
- {
- SET_CONFIG_PROPERTY(ConfirmRecycling);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetUseLocationProfiles(bool value)
- {
- SET_CONFIG_PROPERTY(UseLocationProfiles);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetConfirmClosingSession(bool value)
- {
- SET_CONFIG_PROPERTY(ConfirmClosingSession);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetConfirmExitOnCompletion(bool value)
- {
- SET_CONFIG_PROPERTY(ConfirmExitOnCompletion);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDoubleClickAction(TDoubleClickAction value)
- {
- SET_CONFIG_PROPERTY(DoubleClickAction);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetCopyOnDoubleClickConfirmation(bool value)
- {
- SET_CONFIG_PROPERTY(CopyOnDoubleClickConfirmation);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDimmHiddenFiles(bool value)
- {
- SET_CONFIG_PROPERTY(DimmHiddenFiles);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetAutoStartSession(AnsiString value)
- {
- SET_CONFIG_PROPERTY(AutoStartSession);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetExpertMode(bool value)
- {
- SET_CONFIG_PROPERTY(ExpertMode);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetDefaultDirIsHome(bool value)
- {
- SET_CONFIG_PROPERTY(DefaultDirIsHome);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetTemporaryDirectoryCleanup(bool value)
- {
- SET_CONFIG_PROPERTY(TemporaryDirectoryCleanup);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetConfirmTemporaryDirectoryCleanup(bool value)
- {
- SET_CONFIG_PROPERTY(ConfirmTemporaryDirectoryCleanup);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetPreservePanelState(bool value)
- {
- SET_CONFIG_PROPERTY(PreservePanelState);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetTheme(AnsiString value)
- {
- SET_CONFIG_PROPERTY_EX(Theme, ConfigureInterface());
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetPathInCaption(TPathInCaption value)
- {
- SET_CONFIG_PROPERTY(PathInCaption);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetMinimizeToTray(bool value)
- {
- SET_CONFIG_PROPERTY(MinimizeToTray);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetBalloonNotifications(bool value)
- {
- SET_CONFIG_PROPERTY(BalloonNotifications);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetNotificationsTimeout(unsigned int value)
- {
- SET_CONFIG_PROPERTY(NotificationsTimeout);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetNotificationsStickTime(unsigned int value)
- {
- SET_CONFIG_PROPERTY(NotificationsStickTime);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetCopyParamAutoSelectNotice(bool value)
- {
- SET_CONFIG_PROPERTY(CopyParamAutoSelectNotice);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetSessionToolbarAutoShown(bool value)
- {
- SET_CONFIG_PROPERTY(SessionToolbarAutoShown);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetLockToolbars(bool value)
- {
- SET_CONFIG_PROPERTY(LockToolbars);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetAutoOpenInPutty(bool value)
- {
- SET_CONFIG_PROPERTY(AutoOpenInPutty);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetCustomCommands(TCustomCommands * value)
- {
- assert(FCustomCommands);
- if (!FCustomCommands->Equals(value))
- {
- FCustomCommands->Assign(value);
- FCustomCommandsModified = true;
- FCustomCommandsDefaults = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetBookmarks(AnsiString Key,
- TBookmarkList * value)
- {
- FBookmarks->Bookmarks[Key] = value;
- Changed();
- }
- //---------------------------------------------------------------------------
- TBookmarkList * __fastcall TWinConfiguration::GetBookmarks(AnsiString Key)
- {
- return FBookmarks->Bookmarks[Key];
- }
- //---------------------------------------------------------------------------
- AnsiString __fastcall TWinConfiguration::GetDefaultKeyFile()
- {
- return (!FDefaultKeyFile.IsEmpty() ? FDefaultKeyFile : FTemporaryKeyFile);
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetLastMonitor(int value)
- {
- ::SetLastMonitor(value);
- }
- //---------------------------------------------------------------------------
- int __fastcall TWinConfiguration::GetLastMonitor()
- {
- return ::GetLastMonitor();
- }
- //---------------------------------------------------------------------------
- AnsiString __fastcall TWinConfiguration::TemporaryDir(bool Mask)
- {
- return UniqTempDir(ExpandFileName(ExpandEnvironmentVariables(DDTemporaryDirectory)),
- "scp", Mask);
- }
- //---------------------------------------------------------------------------
- TStrings * __fastcall TWinConfiguration::FindTemporaryFolders()
- {
- TStrings * Result = new TStringList();
- try
- {
- TSearchRec SRec;
- AnsiString Mask = TemporaryDir(true);
- AnsiString Directory = ExtractFilePath(Mask);
- if (FindFirst(Mask, faDirectory, SRec) == 0)
- {
- do
- {
- if (FLAGSET(SRec.Attr, faDirectory))
- {
- Result->Add(Directory + SRec.Name);
- }
- }
- while (FindNext(SRec) == 0);
- }
- if (Result->Count == 0)
- {
- delete Result;
- Result = NULL;
- }
- }
- catch(...)
- {
- delete Result;
- throw;
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::CleanupTemporaryFolders(TStrings * Folders)
- {
- AnsiString ErrorList;
- TStrings * F;
- if (Folders == NULL)
- {
- F = FindTemporaryFolders();
- }
- else
- {
- F = Folders;
- }
- if (F != NULL)
- {
- try
- {
- for (int i = 0; i < F->Count; i++)
- {
- if (!DeleteDirectory(F->Strings[i]))
- {
- if (!ErrorList.IsEmpty())
- {
- ErrorList += "\n";
- }
- ErrorList += F->Strings[i];
- }
- }
- }
- __finally
- {
- if (Folders == NULL)
- {
- delete F;
- }
- }
- if (!ErrorList.IsEmpty())
- {
- throw ExtException(LoadStr(CLEANUP_TEMP_ERROR), ErrorList);
- }
- }
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- #pragma warn -inl
- //---------------------------------------------------------------------------
- class TAsInheritedReader : public TReader
- {
- public:
- __fastcall TAsInheritedReader(TStream * Stream, int BufSize) :
- TReader(Stream, BufSize)
- {
- OnAncestorNotFound = AncestorNotFound;
- }
- virtual void __fastcall ReadPrefix(TFilerFlags & Flags, int & AChildPos)
- {
- TReader::ReadPrefix(Flags, AChildPos);
- Flags << ffInherited;
- }
- void __fastcall AncestorNotFound(TReader * Reader,
- const AnsiString ComponentName, TMetaClass * ComponentClass,
- TComponent *& Component)
- {
- assert(!Component);
- if (ComponentName.IsEmpty())
- {
- for (int Index = 0; Index < LookupRoot->ComponentCount; Index++)
- {
- Component = LookupRoot->Components[Index];
- if (Component->Name.IsEmpty())
- {
- return;
- }
- }
- Component = NULL;
- }
- }
- };
- //---------------------------------------------------------------------------
- #pragma warn .inl
- //---------------------------------------------------------------------------
- bool __fastcall TWinConfiguration::InternalReloadComponentRes(const AnsiString ResName,
- HANDLE HInst, TComponent * Instance)
- {
- HANDLE HRsrc;
- bool Result;
- if (!HInst)
- {
- HInst = HInstance;
- }
- HRsrc = FindResource(HInst, ResName.c_str(), RT_RCDATA);
- Result = (HRsrc != 0);
- if (Result)
- {
- TResourceStream * ResStream = new TResourceStream(
- reinterpret_cast<int>(HInst), ResName, RT_RCDATA);
- try
- {
- TReader * Reader;
- Reader = new TAsInheritedReader(ResStream, 4096);
- try
- {
- /*Instance =*/ Reader->ReadRootComponent(Instance);
- }
- __finally
- {
- delete Reader;
- }
- }
- __finally
- {
- delete ResStream;
- }
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TWinConfiguration::InitComponent(TComponent * Instance,
- TClass RootAncestor, TClass ClassType)
- {
- bool Result = false;
- if ((ClassType != __classid(TComponent)) && (ClassType != RootAncestor))
- {
- if (InitComponent(Instance, RootAncestor, ClassType->ClassParent()))
- {
- Result = true;
- }
- if (InternalReloadComponentRes(ClassType->ClassName(),
- reinterpret_cast<HANDLE>(FindResourceHInstance(FindClassHInstance(ClassType))),
- Instance))
- {
- Result = true;
- }
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- LCID __fastcall TWinConfiguration::GetLocale()
- {
- if (!FLocale)
- {
- AnsiString ResourceModule = ::GetResourceModule(ModuleFileName().c_str());
- if (!ResourceModule.IsEmpty())
- {
- AnsiString ResourceExt = ExtractFileExt(ResourceModule).UpperCase();
- ResourceExt.Delete(1, 1);
- TLanguages * Langs = LanguagesDEPF();
- int Index, Count;
- Count = Langs->Count;
- Index = 0;
- while ((Index < Count) && !FLocale)
- {
- if (Langs->Ext[Index] == ResourceExt)
- {
- FLocale = Langs->LocaleID[Index];
- }
- else if (Langs->Ext[Index].SubString(1, 2) == ResourceExt)
- {
- FLocale = MAKELANGID(PRIMARYLANGID(Langs->LocaleID[Index]),
- SUBLANG_DEFAULT);
- }
- Index++;
- }
- }
- }
- return TCustomWinConfiguration::GetLocale();
- }
- //---------------------------------------------------------------------------
- HINSTANCE __fastcall TWinConfiguration::LoadNewResourceModule(LCID ALocale,
- AnsiString * FileName)
- {
- AnsiString FileNameStorage;
- if (FileName == NULL)
- {
- FileName = &FileNameStorage;
- }
- HINSTANCE Instance = TCustomWinConfiguration::LoadNewResourceModule(ALocale, FileName);
- if (Instance != NULL)
- {
- try
- {
- CheckTranslationVersion(*FileName, false);
- }
- catch(...)
- {
- FreeResourceModule(Instance);
- throw;
- }
- }
- return Instance;
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetResourceModule(HINSTANCE Instance)
- {
- TCustomWinConfiguration::SetResourceModule(Instance);
- Busy(true);
- try
- {
- int Count;
- AnsiString OrigName;
- int OrigLeft;
- int OrigTop;
- TForm * Form;
- Count = Screen->FormCount;
- for (int Index = 0; Index < Count; Index++)
- {
- Form = Screen->Forms[Index];
- SendMessage(Form->Handle, WM_LOCALE_CHANGE, 0, 1);
- }
- ConfigureInterface();
- for (int Index = 0; Index < Count; Index++)
- {
- Form = Screen->Forms[Index];
- TComponent * Component;
- for (int Index = 0; Index < Form->ComponentCount; Index++)
- {
- Component = Form->Components[Index];
- if (dynamic_cast<TFrame*>(Component))
- {
- OrigName = Component->Name;
- InitComponent(Component, __classid(TFrame), Component->ClassType());
- Component->Name = OrigName;
- }
- }
- OrigLeft = Form->Left;
- OrigTop = Form->Top;
- OrigName = Form->Name;
- InitComponent(Form, __classid(TForm), Form->ClassType());
- Form->Name = OrigName;
- Form->Position = poDesigned;
- Form->Left = OrigLeft;
- Form->Top = OrigTop;
- SendMessage(Form->Handle, WM_LOCALE_CHANGE, 1, 1);
- }
- TDataModule * DataModule;
- Count = Screen->DataModuleCount;
- for (int Index = 0; Index < Count; Index++)
- {
- DataModule = Screen->DataModules[Index];
- OrigName = DataModule->Name;
- InitComponent(DataModule, __classid(TDataModule), DataModule->ClassType());
- DataModule->Name = OrigName;
- }
- }
- __finally
- {
- Busy(false);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::CheckTranslationVersion(const AnsiString FileName,
- bool InternalLocaleOnError)
- {
- AnsiString TranslationProductVersion = GetFileProductVersion(FileName);
- AnsiString TranslationProductName = GetFileProductName(FileName);
- if ((ProductName != TranslationProductName) ||
- (ProductVersion != TranslationProductVersion))
- {
- if (InternalLocaleOnError)
- {
- LocaleSafe = InternalLocale();
- }
- if (TranslationProductName.IsEmpty() || TranslationProductVersion.IsEmpty())
- {
- throw Exception(FMTLOAD(UNKNOWN_TRANSLATION, (FileName)));
- }
- else
- {
- throw Exception(FMTLOAD(INCOMPATIBLE_TRANSLATION,
- (FileName, TranslationProductName, TranslationProductVersion)));
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::CheckDefaultTranslation()
- {
- if (!FInvalidDefaultTranslationMessage.IsEmpty())
- {
- MoreMessageDialog(FMTLOAD(INVALID_DEFAULT_TRANSLATION,
- (FInvalidDefaultTranslationMessage)), NULL, qtWarning, qaOK, HELP_NONE);
- }
- }
- //---------------------------------------------------------------------------
- const TEditorPreferences * __fastcall TWinConfiguration::DefaultEditorForFile(
- const AnsiString FileName, bool Local, const TFileMasks::TParams & MaskParams)
- {
- return FEditorList->Find(FileName, Local, MaskParams);
- }
- //---------------------------------------------------------------------------
- const TEditorList * __fastcall TWinConfiguration::GetEditorList()
- {
- return FEditorList;
- }
- //---------------------------------------------------------------------------
- void __fastcall TWinConfiguration::SetEditorList(const TEditorList * value)
- {
- if (!(*FEditorList == *value))
- {
- *FEditorList = *value;
- Changed();
- }
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- int __fastcall TCustomCommands::GetParam(const AnsiString & Name)
- {
- int Index = IndexOfName(Name);
- if (Index >= 0)
- {
- return int(Objects[Index]);
- }
- else
- {
- return 0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCustomCommands::SetParam(const AnsiString & Name, int value)
- {
- int Index = IndexOfName(Name);
- if (Index >= 0)
- {
- Objects[Index] = (TObject *)value;
- }
- else
- {
- Values[Name] = "";
- Index = IndexOfName(Name);
- assert(Index >= 0);
- Objects[Index] = (TObject *)value;
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TCustomCommands::Equals(TCustomCommands * Commands)
- {
- bool Result = TStringList::Equals(Commands);
- if (Result)
- {
- int Index = 0;
- while ((Index < Count) && Result)
- {
- if (Objects[Index] != Commands->Objects[Index])
- {
- Result = false;
- }
- Index++;
- }
- }
- return Result;
- }
|