| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256 | 
							- //---------------------------------------------------------------------------
 
- #include <vcl.h>
 
- #pragma hdrstop
 
- #include <Common.h>
 
- #include "GUIConfiguration.h"
 
- #include "GUITools.h"
 
- #include <FileInfo.h>
 
- #include <TextsCore.h>
 
- #include <TextsWin.h>
 
- #include <Terminal.h>
 
- #include <CoreMain.h>
 
- #include <shlobj.h>
 
- //---------------------------------------------------------------------------
 
- #pragma package(smart_init)
 
- //---------------------------------------------------------------------------
 
- const int ccLocal = ccUser;
 
- const int ccShowResults = ccUser << 1;
 
- const int ccCopyResults = ccUser << 2;
 
- const int ccRemoteFiles = ccUser << 3;
 
- const int ccSet = 0x80000000;
 
- //---------------------------------------------------------------------------
 
- static const unsigned int AdditionaLanguageMask = 0xFFFFFF00;
 
- static const UnicodeString AdditionaLanguagePrefix(L"XX");
 
- //---------------------------------------------------------------------------
 
- TGUIConfiguration * GUIConfiguration = NULL;
 
- //---------------------------------------------------------------------------
 
- __fastcall TGUICopyParamType::TGUICopyParamType()
 
-   : TCopyParamType()
 
- {
 
-   GUIDefault();
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TGUICopyParamType::TGUICopyParamType(const TCopyParamType & Source)
 
-   : TCopyParamType(Source)
 
- {
 
-   GUIDefault();
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TGUICopyParamType::TGUICopyParamType(const TGUICopyParamType & Source)
 
-   : TCopyParamType(Source)
 
- {
 
-   GUIAssign(&Source);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUICopyParamType::Assign(const TCopyParamType * Source)
 
- {
 
-   TCopyParamType::Assign(Source);
 
-   const TGUICopyParamType * GUISource;
 
-   GUISource = dynamic_cast<const TGUICopyParamType *>(Source);
 
-   if (GUISource != NULL)
 
-   {
 
-     GUIAssign(GUISource);
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUICopyParamType::GUIAssign(const TGUICopyParamType * Source)
 
- {
 
-   Queue = Source->Queue;
 
-   QueueNoConfirmation = Source->QueueNoConfirmation;
 
-   QueueIndividually = Source->QueueIndividually;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUICopyParamType::Default()
 
- {
 
-   TCopyParamType::Default();
 
-   GUIDefault();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUICopyParamType::GUIDefault()
 
- {
 
-   Queue = false;
 
-   QueueNoConfirmation = true;
 
-   QueueIndividually = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUICopyParamType::Load(THierarchicalStorage * Storage)
 
- {
 
-   TCopyParamType::Load(Storage);
 
-   Queue = Storage->ReadBool(L"Queue", Queue);
 
-   QueueNoConfirmation = Storage->ReadBool(L"QueueNoConfirmation", QueueNoConfirmation);
 
-   QueueIndividually = Storage->ReadBool(L"QueueIndividually", QueueIndividually);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUICopyParamType::Save(THierarchicalStorage * Storage)
 
- {
 
-   TCopyParamType::Save(Storage);
 
-   Storage->WriteBool(L"Queue", Queue);
 
-   Storage->WriteBool(L"QueueNoConfirmation", QueueNoConfirmation);
 
-   Storage->WriteBool(L"QueueIndividually", QueueIndividually);
 
- }
 
- //---------------------------------------------------------------------------
 
- TGUICopyParamType & __fastcall TGUICopyParamType::operator =(const TCopyParamType & rhp)
 
- {
 
-   Assign(&rhp);
 
-   return *this;
 
- }
 
- //---------------------------------------------------------------------------
 
- TGUICopyParamType & __fastcall TGUICopyParamType::operator =(const TGUICopyParamType & rhp)
 
- {
 
-   Assign(&rhp);
 
-   return *this;
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamRuleData::Default()
 
- {
 
-   HostName = L"";
 
-   UserName = L"";
 
-   RemoteDirectory = L"";
 
-   LocalDirectory = L"";
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- __fastcall TCopyParamRule::TCopyParamRule()
 
- {
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TCopyParamRule::TCopyParamRule(const TCopyParamRuleData & Data)
 
- {
 
-   FData = Data;
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TCopyParamRule::TCopyParamRule(const TCopyParamRule & Source)
 
- {
 
-   FData.HostName = Source.FData.HostName;
 
-   FData.UserName = Source.FData.UserName;
 
-   FData.RemoteDirectory = Source.FData.RemoteDirectory;
 
-   FData.LocalDirectory = Source.FData.LocalDirectory;
 
- }
 
- //---------------------------------------------------------------------------
 
- #define C(Property) (Property == rhp.Property)
 
- bool __fastcall TCopyParamRule::operator==(const TCopyParamRule & rhp) const
 
- {
 
-   return
 
-     C(FData.HostName) &&
 
-     C(FData.UserName) &&
 
-     C(FData.RemoteDirectory) &&
 
-     C(FData.LocalDirectory) &&
 
-     true;
 
- }
 
- #undef C
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCopyParamRule::Match(const UnicodeString & Mask,
 
-   const UnicodeString & Value, bool Path, bool Local, int ForceDirectoryMasks) const
 
- {
 
-   bool Result;
 
-   if (Mask.IsEmpty())
 
-   {
 
-     Result = true;
 
-   }
 
-   else
 
-   {
 
-     TFileMasks M(ForceDirectoryMasks);
 
-     M.Masks = Mask;
 
-     if (Path)
 
-     {
 
-       Result = M.Matches(Value, Local, true);
 
-     }
 
-     else
 
-     {
 
-       Result = M.Matches(Value, false);
 
-     }
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCopyParamRule::Matches(const TCopyParamRuleData & Value) const
 
- {
 
-   return
 
-     Match(FData.HostName, Value.HostName, false, true, 0) &&
 
-     Match(FData.UserName, Value.UserName, false, true, 0) &&
 
-     Match(FData.RemoteDirectory, Value.RemoteDirectory, true, false, 1) &&
 
-     Match(FData.LocalDirectory, Value.LocalDirectory, true, true, 1);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamRule::Load(THierarchicalStorage * Storage)
 
- {
 
-   FData.HostName = Storage->ReadString(L"HostName", FData.HostName);
 
-   FData.UserName = Storage->ReadString(L"UserName", FData.UserName);
 
-   FData.RemoteDirectory = Storage->ReadString(L"RemoteDirectory", FData.RemoteDirectory);
 
-   FData.LocalDirectory = Storage->ReadString(L"LocalDirectory", FData.LocalDirectory);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamRule::Save(THierarchicalStorage * Storage) const
 
- {
 
-   Storage->WriteString(L"HostName", FData.HostName);
 
-   Storage->WriteString(L"UserName", FData.UserName);
 
-   Storage->WriteString(L"RemoteDirectory", FData.RemoteDirectory);
 
-   Storage->WriteString(L"LocalDirectory", FData.LocalDirectory);
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCopyParamRule::GetEmpty() const
 
- {
 
-   return
 
-     FData.HostName.IsEmpty() &&
 
-     FData.UserName.IsEmpty() &&
 
-     FData.RemoteDirectory.IsEmpty() &&
 
-     FData.LocalDirectory.IsEmpty();
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TCopyParamRule::GetInfoStr(UnicodeString Separator) const
 
- {
 
-   UnicodeString Result;
 
-   #define ADD(FMT, ELEM) \
 
-     if (!FData.ELEM.IsEmpty()) \
 
-       Result += (Result.IsEmpty() ? UnicodeString() : Separator) + FMTLOAD(FMT, (FData.ELEM));
 
-   ADD(COPY_RULE_HOSTNAME, HostName);
 
-   ADD(COPY_RULE_USERNAME, UserName);
 
-   ADD(COPY_RULE_REMOTE_DIR, RemoteDirectory);
 
-   ADD(COPY_RULE_LOCAL_DIR, LocalDirectory);
 
-   #undef ADD
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- UnicodeString TCopyParamList::FInvalidChars(L"/\\[]");
 
- //---------------------------------------------------------------------------
 
- __fastcall TCopyParamList::TCopyParamList()
 
- {
 
-   Init();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Init()
 
- {
 
-   FCopyParams = new TList();
 
-   FRules = new TList();
 
-   FNames = new TStringList();
 
-   FNameList = NULL;
 
-   FModified = false;
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TCopyParamList::~TCopyParamList()
 
- {
 
-   Clear();
 
-   delete FCopyParams;
 
-   delete FRules;
 
-   delete FNames;
 
-   delete FNameList;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Reset()
 
- {
 
-   SAFE_DESTROY(FNameList);
 
-   FModified = false;
 
- }
 
- //---------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Modify()
 
- {
 
-   SAFE_DESTROY(FNameList);
 
-   FModified = true;
 
- }
 
- //---------------------------------------------------------------------
 
- void __fastcall TCopyParamList::ValidateName(const UnicodeString Name)
 
- {
 
-   if (Name.LastDelimiter(FInvalidChars) > 0)
 
-   {
 
-     throw Exception(FMTLOAD(ITEM_NAME_INVALID, (Name, FInvalidChars)));
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- TCopyParamList & __fastcall TCopyParamList::operator=(const TCopyParamList & rhl)
 
- {
 
-   Clear();
 
-   for (int Index = 0; Index < rhl.Count; Index++)
 
-   {
 
-     TCopyParamType * CopyParam = new TCopyParamType(*rhl.CopyParams[Index]);
 
-     TCopyParamRule * Rule = NULL;
 
-     if (rhl.Rules[Index] != NULL)
 
-     {
 
-       Rule = new TCopyParamRule(*rhl.Rules[Index]);
 
-     }
 
-     Add(rhl.Names[Index], CopyParam, Rule);
 
-   }
 
-   // there should be comparison of with the assigned list, but we rely on caller
 
-   // to do it instead (TGUIConfiguration::SetCopyParamList)
 
-   Modify();
 
-   return *this;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCopyParamList::operator==(const TCopyParamList & rhl) const
 
- {
 
-   bool Result = (Count == rhl.Count);
 
-   if (Result)
 
-   {
 
-     int i = 0;
 
-     while ((i < Count) && Result)
 
-     {
 
-       Result =
 
-         (Names[i] == rhl.Names[i]) &&
 
-         CompareItem(i, rhl.CopyParams[i], rhl.Rules[i]);
 
-       i++;
 
-     }
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- int __fastcall TCopyParamList::IndexOfName(const UnicodeString Name) const
 
- {
 
-   return FNames->IndexOf(Name);
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCopyParamList::CompareItem(int Index,
 
-   const TCopyParamType * CopyParam, const TCopyParamRule * Rule) const
 
- {
 
-   return
 
-     ((*CopyParams[Index]) == *CopyParam) &&
 
-     ((Rules[Index] == NULL) ?
 
-       (Rule == NULL) :
 
-       ((Rule != NULL) && (*Rules[Index]) == (*Rule)));
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Clear()
 
- {
 
-   for (int i = 0; i < Count; i++)
 
-   {
 
-     delete CopyParams[i];
 
-     delete Rules[i];
 
-   }
 
-   FCopyParams->Clear();
 
-   FRules->Clear();
 
-   FNames->Clear();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Add(const UnicodeString Name,
 
-   TCopyParamType * CopyParam, TCopyParamRule * Rule)
 
- {
 
-   Insert(Count, Name, CopyParam, Rule);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Insert(int Index, const UnicodeString Name,
 
-   TCopyParamType * CopyParam, TCopyParamRule * Rule)
 
- {
 
-   DebugAssert(FNames->IndexOf(Name) < 0);
 
-   FNames->Insert(Index, Name);
 
-   DebugAssert(CopyParam != NULL);
 
-   FCopyParams->Insert(Index, reinterpret_cast<TObject *>(CopyParam));
 
-   FRules->Insert(Index, reinterpret_cast<TObject *>(Rule));
 
-   Modify();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Change(int Index, const UnicodeString Name,
 
-   TCopyParamType * CopyParam, TCopyParamRule * Rule)
 
- {
 
-   if ((Name != Names[Index]) || !CompareItem(Index, CopyParam, Rule))
 
-   {
 
-     FNames->Strings[Index] = Name;
 
-     delete CopyParams[Index];
 
-     FCopyParams->Items[Index] = (reinterpret_cast<TObject *>(CopyParam));
 
-     delete Rules[Index];
 
-     FRules->Items[Index] = (reinterpret_cast<TObject *>(Rule));
 
-     Modify();
 
-   }
 
-   else
 
-   {
 
-     delete CopyParam;
 
-     delete Rule;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Move(int CurIndex, int NewIndex)
 
- {
 
-   if (CurIndex != NewIndex)
 
-   {
 
-     FNames->Move(CurIndex, NewIndex);
 
-     FCopyParams->Move(CurIndex, NewIndex);
 
-     FRules->Move(CurIndex, NewIndex);
 
-     Modify();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Delete(int Index)
 
- {
 
-   DebugAssert((Index >= 0) && (Index < Count));
 
-   FNames->Delete(Index);
 
-   delete CopyParams[Index];
 
-   FCopyParams->Delete(Index);
 
-   delete Rules[Index];
 
-   FRules->Delete(Index);
 
-   Modify();
 
- }
 
- //---------------------------------------------------------------------------
 
- int __fastcall TCopyParamList::Find(const TCopyParamRuleData & Value) const
 
- {
 
-   int Result = -1;
 
-   int i = 0;
 
-   while ((i < FRules->Count) && (Result < 0))
 
-   {
 
-     if (FRules->Items[i] != NULL)
 
-     {
 
-       if (Rules[i]->Matches(Value))
 
-       {
 
-         Result = i;
 
-       }
 
-     }
 
-     i++;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Load(THierarchicalStorage * Storage, int ACount)
 
- {
 
-   for (int Index = 0; Index < ACount; Index++)
 
-   {
 
-     UnicodeString Name = IntToStr(Index);
 
-     TCopyParamRule * Rule = NULL;
 
-     TCopyParamType * CopyParam = new TCopyParamType();
 
-     try
 
-     {
 
-       if (Storage->OpenSubKey(Name, false))
 
-       {
 
-         try
 
-         {
 
-           Name = Storage->ReadString(L"Name", Name);
 
-           CopyParam->Load(Storage);
 
-           if (Storage->ReadBool(L"HasRule", false))
 
-           {
 
-             Rule = new TCopyParamRule();
 
-             Rule->Load(Storage);
 
-           }
 
-         }
 
-         __finally
 
-         {
 
-           Storage->CloseSubKey();
 
-         }
 
-       }
 
-     }
 
-     catch(...)
 
-     {
 
-       delete CopyParam;
 
-       delete Rule;
 
-       throw;
 
-     }
 
-     FCopyParams->Add(reinterpret_cast<TObject *>(CopyParam));
 
-     FRules->Add(reinterpret_cast<TObject *>(Rule));
 
-     FNames->Add(Name);
 
-   }
 
-   Reset();
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TCopyParamList::Save(THierarchicalStorage * Storage) const
 
- {
 
-   Storage->ClearSubKeys();
 
-   for (int Index = 0; Index < Count; Index++)
 
-   {
 
-     if (Storage->OpenSubKey(IntToStr(Index), true))
 
-     {
 
-       try
 
-       {
 
-         const TCopyParamType * CopyParam = CopyParams[Index];
 
-         const TCopyParamRule * Rule = Rules[Index];
 
-         Storage->WriteString(L"Name", Names[Index]);
 
-         CopyParam->Save(Storage);
 
-         Storage->WriteBool(L"HasRule", (Rule != NULL));
 
-         if (Rule != NULL)
 
-         {
 
-           Rule->Save(Storage);
 
-         }
 
-       }
 
-       __finally
 
-       {
 
-         Storage->CloseSubKey();
 
-       }
 
-     }
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- int __fastcall TCopyParamList::GetCount() const
 
- {
 
-   return FCopyParams->Count;
 
- }
 
- //---------------------------------------------------------------------------
 
- const TCopyParamRule * __fastcall TCopyParamList::GetRule(int Index) const
 
- {
 
-   return reinterpret_cast<TCopyParamRule *>(FRules->Items[Index]);
 
- }
 
- //---------------------------------------------------------------------------
 
- const TCopyParamType * __fastcall TCopyParamList::GetCopyParam(int Index) const
 
- {
 
-   return reinterpret_cast<TCopyParamType *>(FCopyParams->Items[Index]);
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TCopyParamList::GetName(int Index) const
 
- {
 
-   return FNames->Strings[Index];
 
- }
 
- //---------------------------------------------------------------------------
 
- TStrings * __fastcall TCopyParamList::GetNameList() const
 
- {
 
-   if (FNameList == NULL)
 
-   {
 
-     FNameList = new TStringList();
 
-     for (int i = 0; i < Count; i++)
 
-     {
 
-       FNameList->Add(FNames->Strings[i]);
 
-     }
 
-   }
 
-   return FNameList;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TCopyParamList::GetAnyRule() const
 
- {
 
-   bool Result = false;
 
-   int i = 0;
 
-   while ((i < Count) && !Result)
 
-   {
 
-     Result = (Rules[i] != NULL);
 
-     i++;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- __fastcall TGUIConfiguration::TGUIConfiguration(): TConfiguration()
 
- {
 
-   SetInitialLocale(0);
 
-   FLocales = CreateSortedStringList();
 
-   FLastLocalesExts = L"*";
 
-   FCopyParamList = new TCopyParamList();
 
-   CoreSetResourceModule(GetResourceModule());
 
- }
 
- //---------------------------------------------------------------------------
 
- __fastcall TGUIConfiguration::~TGUIConfiguration()
 
- {
 
-   delete FLocales;
 
-   delete FCopyParamList;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::Default()
 
- {
 
-   TConfiguration::Default();
 
-   // reset before call to DefaultLocalized()
 
-   FDefaultCopyParam.Default();
 
-   FCopyParamListDefaults = true;
 
-   DefaultLocalized();
 
-   FIgnoreCancelBeforeFinish = TDateTime(0, 0, 3, 0);
 
-   FContinueOnError = false;
 
-   FConfirmCommandSession = true;
 
-   FSynchronizeParams = TTerminal::spDefault;
 
-   FSynchronizeModeAuto = -1;
 
-   FSynchronizeMode = TTerminal::smRemote;
 
-   FMaxWatchDirectories = 500;
 
-   FSynchronizeOptions = soRecurse | soSynchronizeAsk;
 
-   FQueueTransfersLimit = 2;
 
-   FQueueKeepDoneItems = true;
 
-   FQueueKeepDoneItemsFor = 15;
 
-   FQueueAutoPopup = true;
 
-   FSessionRememberPassword = true;
 
-   UnicodeString ProgramsFolder;
 
-   SpecialFolderLocation(CSIDL_PROGRAM_FILES, ProgramsFolder);
 
-   FDefaultPuttyPathOnly = IncludeTrailingBackslash(ProgramsFolder) + L"PuTTY\\" + OriginalPuttyExecutable;
 
-   FDefaultPuttyPath = L"%PROGRAMFILES%\\PuTTY\\" + OriginalPuttyExecutable;
 
-   FPuttyPath = FormatCommand(FDefaultPuttyPath, L"");
 
-   PSftpPath = FormatCommand(L"%PROGRAMFILES%\\PuTTY\\psftp.exe", L"");
 
-   FPuttyPassword = false;
 
-   FTelnetForFtpInPutty = true;
 
-   FPuttySession = L"WinSCP temporary session";
 
-   FBeepOnFinish = false;
 
-   FBeepOnFinishAfter = TDateTime(0, 0, 30, 0);
 
-   FCopyParamCurrent = L"";
 
-   FKeepUpToDateChangeDelay = 500;
 
-   FChecksumAlg = L"sha1";
 
-   FSessionReopenAutoIdle = 9000;
 
-   FNewDirectoryProperties.Default();
 
-   FNewDirectoryProperties.Rights = TRights::rfDefault | TRights::rfExec;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::DefaultLocalized()
 
- {
 
-   if (FCopyParamListDefaults)
 
-   {
 
-     FCopyParamList->Clear();
 
-     // guard against "empty resource string" from obsolete traslations
 
-     // (DefaultLocalized is called for the first time before detection of
 
-     // obsolete translations)
 
-     if (!LoadStr(COPY_PARAM_PRESET_ASCII).IsEmpty())
 
-     {
 
-       TCopyParamType * CopyParam;
 
-       CopyParam = new TCopyParamType(FDefaultCopyParam);
 
-       CopyParam->TransferMode = tmAscii;
 
-       FCopyParamList->Add(LoadStr(COPY_PARAM_PRESET_ASCII), CopyParam, NULL);
 
-       CopyParam = new TCopyParamType(FDefaultCopyParam);
 
-       CopyParam->TransferMode = tmBinary;
 
-       FCopyParamList->Add(LoadStr(COPY_PARAM_PRESET_BINARY), CopyParam, NULL);
 
-       CopyParam = new TCopyParamType(FDefaultCopyParam);
 
-       CopyParam->NewerOnly = true;
 
-       FCopyParamList->Add(LoadStr(COPY_PARAM_NEWER_ONLY), CopyParam, NULL);
 
-       CopyParam = new TCopyParamType(FDefaultCopyParam);
 
-       CopyParam->IncludeFileMask = TFileMasks(FORMAT(L"%s */", (IncludeExcludeFileMasksDelimiter)));
 
-       FCopyParamList->Add(LoadStr(COPY_PARAM_PRESET_EXCLUDE_ALL_DIR), CopyParam, NULL);
 
-     }
 
-     FCopyParamList->Reset();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::UpdateStaticUsage()
 
- {
 
-   TConfiguration::UpdateStaticUsage();
 
-   Usage->Set(L"CopyParamsCount", (FCopyParamListDefaults ? 0 : FCopyParamList->Count));
 
-   Usage->Set(L"Putty", ExtractProgramName(PuttyPath));
 
- }
 
- //---------------------------------------------------------------------------
 
- // duplicated from core\configuration.cpp
 
- #define BLOCK(KEY, CANCREATE, BLOCK) \
 
-   if (Storage->OpenSubKey(KEY, CANCREATE, true)) try { BLOCK } __finally { Storage->CloseSubKey(); }
 
- #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, PropertyToKey(TEXT(#VAR)))
 
- #define REGCONFIG(CANCREATE) \
 
-   BLOCK(L"Interface", CANCREATE, \
 
-     KEY(Bool,     ContinueOnError); \
 
-     KEY(Bool,     ConfirmCommandSession); \
 
-     KEY(Integer,  SynchronizeParams); \
 
-     KEY(Integer,  SynchronizeOptions); \
 
-     KEY(Integer,  SynchronizeModeAuto); \
 
-     KEY(Integer,  SynchronizeMode); \
 
-     KEY(Integer,  MaxWatchDirectories); \
 
-     KEY(Integer,  QueueTransfersLimit); \
 
-     KEY(Integer,  QueueKeepDoneItems); \
 
-     KEY(Integer,  QueueKeepDoneItemsFor); \
 
-     KEY(Bool,     QueueAutoPopup); \
 
-     KEYEX(Bool,   SessionRememberPassword, L"QueueRememberPassword"); \
 
-     KEY(String,   PuttySession); \
 
-     KEY(String,   PuttyPath); \
 
-     KEY(Bool,     PuttyPassword); \
 
-     KEY(Bool,     TelnetForFtpInPutty); \
 
-     KEY(DateTime, IgnoreCancelBeforeFinish); \
 
-     KEY(Bool,     BeepOnFinish); \
 
-     KEY(DateTime, BeepOnFinishAfter); \
 
-     KEY(Integer,  KeepUpToDateChangeDelay); \
 
-     KEY(String,   ChecksumAlg); \
 
-     KEY(Integer,  SessionReopenAutoIdle); \
 
-   ); \
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SaveData(THierarchicalStorage * Storage, bool All)
 
- {
 
-   TConfiguration::SaveData(Storage, All);
 
-   // duplicated from core\configuration.cpp
 
-   #define KEYEX(TYPE, VAR, NAME) Storage->Write ## TYPE(NAME, VAR)
 
-   REGCONFIG(true);
 
-   #undef KEYEX
 
-   if (Storage->OpenSubKey(L"Interface\\CopyParam", true, true))
 
-   try
 
-   {
 
-     FDefaultCopyParam.Save(Storage);
 
-     if (FCopyParamListDefaults)
 
-     {
 
-       DebugAssert(!FCopyParamList->Modified);
 
-       Storage->WriteInteger(L"CopyParamList", -1);
 
-     }
 
-     else if (All || FCopyParamList->Modified)
 
-     {
 
-       Storage->WriteInteger(L"CopyParamList", FCopyParamList->Count);
 
-       FCopyParamList->Save(Storage);
 
-     }
 
-   }
 
-   __finally
 
-   {
 
-     Storage->CloseSubKey();
 
-   }
 
-   if (Storage->OpenSubKey(L"Interface\\NewDirectory2", true, true))
 
-   try
 
-   {
 
-     FNewDirectoryProperties.Save(Storage);
 
-   }
 
-   __finally
 
-   {
 
-     Storage->CloseSubKey();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::LoadData(THierarchicalStorage * Storage)
 
- {
 
-   TConfiguration::LoadData(Storage);
 
-   // duplicated from core\configuration.cpp
 
-   #define KEYEX(TYPE, VAR, NAME) VAR = Storage->Read ## TYPE(NAME, VAR)
 
-   #pragma warn -eas
 
-   REGCONFIG(false);
 
-   #pragma warn +eas
 
-   #undef KEYEX
 
-   if (Storage->OpenSubKey(L"Interface\\CopyParam", false, true))
 
-   try
 
-   {
 
-     // must be loaded before eventual setting defaults for CopyParamList
 
-     FDefaultCopyParam.Load(Storage);
 
-     int CopyParamListCount = Storage->ReadInteger(L"CopyParamList", -1);
 
-     FCopyParamListDefaults = (CopyParamListCount < 0);
 
-     if (!FCopyParamListDefaults)
 
-     {
 
-       FCopyParamList->Clear();
 
-       FCopyParamList->Load(Storage, CopyParamListCount);
 
-     }
 
-     else if (FCopyParamList->Modified)
 
-     {
 
-       FCopyParamList->Clear();
 
-       FCopyParamListDefaults = false;
 
-     }
 
-     FCopyParamList->Reset();
 
-   }
 
-   __finally
 
-   {
 
-     Storage->CloseSubKey();
 
-   }
 
-   // Make it compatible with versions prior to 3.7.1 that have not saved PuttyPath
 
-   // with quotes. First check for absence of quotes.
 
-   // Add quotes either if the path is set to default putty path (even if it does
 
-   // not exists) or when the path points to existing file (so there are no parameters
 
-   // yet in the string). Note that FileExists may display error dialog, but as
 
-   // it should be called only for custom users path, let's expect that the user
 
-   // can take care of it.
 
-   if ((FPuttyPath.SubString(1, 1) != L"\"") &&
 
-       (CompareFileName(ExpandEnvironmentVariables(FPuttyPath), FDefaultPuttyPathOnly) ||
 
-        FileExists(ApiPath(ExpandEnvironmentVariables(FPuttyPath)))))
 
-   {
 
-     FPuttyPath = FormatCommand(FPuttyPath, L"");
 
-   }
 
-   if (Storage->OpenSubKey(L"Interface\\NewDirectory2", false, true))
 
-   try
 
-   {
 
-     FNewDirectoryProperties.Load(Storage);
 
-   }
 
-   __finally
 
-   {
 
-     Storage->CloseSubKey();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::Saved()
 
- {
 
-   TConfiguration::Saved();
 
-   FCopyParamList->Reset();
 
- }
 
- //---------------------------------------------------------------------------
 
- //---------------------------------------------------------------------------
 
- HINSTANCE __fastcall TGUIConfiguration::LoadNewResourceModule(LCID ALocale,
 
-   UnicodeString & FileName)
 
- {
 
-   UnicodeString LibraryFileName;
 
-   HINSTANCE NewInstance = 0;
 
-   bool Internal = (ALocale == InternalLocale());
 
-   if (!Internal)
 
-   {
 
-     UnicodeString Module;
 
-     UnicodeString LocaleName;
 
-     Module = ModuleFileName();
 
-     if ((ALocale & AdditionaLanguageMask) != AdditionaLanguageMask)
 
-     {
 
-       wchar_t LocaleStr[4];
 
-       GetLocaleInfo(ALocale, LOCALE_SABBREVLANGNAME, LocaleStr, LENOF(LocaleStr));
 
-       LocaleName = LocaleStr;
 
-       DebugAssert(!LocaleName.IsEmpty());
 
-     }
 
-     else
 
-     {
 
-       LocaleName = AdditionaLanguagePrefix +
 
-         char(ALocale & ~AdditionaLanguageMask);
 
-     }
 
-     Module = ChangeFileExt(Module, UnicodeString(L".") + LocaleName);
 
-     // Look for a potential language/country translation
 
-     NewInstance = LoadLibraryEx(Module.c_str(), 0, LOAD_LIBRARY_AS_DATAFILE);
 
-     if (!NewInstance)
 
-     {
 
-       // Finally look for a language only translation
 
-       Module.SetLength(Module.Length() - 1);
 
-       NewInstance = LoadLibraryEx(Module.c_str(), 0, LOAD_LIBRARY_AS_DATAFILE);
 
-       if (NewInstance)
 
-       {
 
-         LibraryFileName = Module;
 
-       }
 
-     }
 
-     else
 
-     {
 
-       LibraryFileName = Module;
 
-     }
 
-   }
 
-   if (!NewInstance && !Internal)
 
-   {
 
-     throw Exception(FMTLOAD(LOCALE_LOAD_ERROR, (int(ALocale))));
 
-   }
 
-   else
 
-   {
 
-     if (Internal)
 
-     {
 
-       NewInstance = HInstance;
 
-     }
 
-   }
 
-   FileName = LibraryFileName;
 
-   return NewInstance;
 
- }
 
- //---------------------------------------------------------------------------
 
- LCID __fastcall TGUIConfiguration::InternalLocale()
 
- {
 
-   LCID Result;
 
-   if (GetTranslationCount(ApplicationInfo) > 0)
 
-   {
 
-     TTranslation Translation;
 
-     Translation = GetTranslation(ApplicationInfo, 0);
 
-     Result = MAKELANGID(PRIMARYLANGID(Translation.Language), SUBLANG_DEFAULT);
 
-   }
 
-   else
 
-   {
 
-     DebugFail();
 
-     Result = 0;
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- LCID __fastcall TGUIConfiguration::GetLocale()
 
- {
 
-   if (!FLocale)
 
-   {
 
-     SetInitialLocale(InternalLocale());
 
-   }
 
-   return FLocale;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetLocale(LCID value)
 
- {
 
-   SetLocaleInternal(value, false);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetLocaleSafe(LCID value)
 
- {
 
-   SetLocaleInternal(value, true);
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TGUIConfiguration::GetLocaleHex()
 
- {
 
-   return IntToHex(__int64(GUIConfiguration->Locale), 4);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetLocaleInternal(LCID value, bool Safe)
 
- {
 
-   if (Locale != value)
 
-   {
 
-     HINSTANCE Module;
 
-     UnicodeString FileName;
 
-     try
 
-     {
 
-       Module = LoadNewResourceModule(value, FileName);
 
-       DebugAssert(Module != NULL);
 
-     }
 
-     catch(...)
 
-     {
 
-       if (Safe)
 
-       {
 
-         // ignore any exception while loading locale
 
-         Module = NULL;
 
-       }
 
-       else
 
-       {
 
-         throw;
 
-       }
 
-     }
 
-     if (Module != NULL)
 
-     {
 
-       FLocale = value;
 
-       if (CanApplyLocaleImmediately)
 
-       {
 
-         FAppliedLocale = value;
 
-         SetResourceModule(Module);
 
-         FLocaleModuleName = FileName;
 
-       }
 
-     }
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TGUIConfiguration::GetCanApplyLocaleImmediately()
 
- {
 
-   return
 
-     (Screen->FormCount == 0) &&
 
-     (Screen->DataModuleCount == 0);
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TGUIConfiguration::LocaleCopyright()
 
- {
 
-   UnicodeString Result;
 
-   if ((FAppliedLocale == 0) || (FAppliedLocale == InternalLocale()))
 
-   {
 
-     DebugFail(); // we do not expect to get called with internal locale
 
-     Result = UnicodeString();
 
-   }
 
-   else
 
-   {
 
-     DebugAssert(!FLocaleModuleName.IsEmpty());
 
-     Result = GetFileFileInfoString(L"LegalCopyright", FLocaleModuleName);
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- UnicodeString __fastcall TGUIConfiguration::LocaleVersion()
 
- {
 
-   UnicodeString Result;
 
-   if ((FAppliedLocale == 0) || (FAppliedLocale == InternalLocale()))
 
-   {
 
-     // noop
 
-   }
 
-   else
 
-   {
 
-     Result = GetFileVersion(FLocaleModuleName);
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetInitialLocale(LCID value)
 
- {
 
-   FLocale = value;
 
-   FAppliedLocale = value;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::FreeResourceModule(HANDLE Instance)
 
- {
 
-   TLibModule * MainModule = FindModule(HInstance);
 
-   if ((unsigned)Instance != MainModule->Instance)
 
-   {
 
-     FreeLibrary(static_cast<HMODULE>(Instance));
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- HANDLE __fastcall TGUIConfiguration::ChangeToDefaultResourceModule()
 
- {
 
-   return ChangeResourceModule(NULL);
 
- }
 
- //---------------------------------------------------------------------------
 
- HANDLE __fastcall TGUIConfiguration::ChangeResourceModule(HANDLE Instance)
 
- {
 
-   if (Instance == NULL)
 
-   {
 
-     Instance = HInstance;
 
-   }
 
-   TLibModule * MainModule = FindModule(HInstance);
 
-   HANDLE Result = (HANDLE)MainModule->ResInstance;
 
-   MainModule->ResInstance = (unsigned)Instance;
 
-   CoreSetResourceModule(Instance);
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- HANDLE __fastcall TGUIConfiguration::GetResourceModule()
 
- {
 
-   return (HANDLE)FindModule(HInstance)->ResInstance;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetResourceModule(HINSTANCE Instance)
 
- {
 
-   HANDLE PrevHandle = ChangeResourceModule(Instance);
 
-   FreeResourceModule(PrevHandle);
 
-   DefaultLocalized();
 
- }
 
- //---------------------------------------------------------------------------
 
- TStrings * __fastcall TGUIConfiguration::GetLocales()
 
- {
 
-   UnicodeString LocalesExts;
 
-   TStringList * Exts = CreateSortedStringList();
 
-   try
 
-   {
 
-     int FindAttrs = faReadOnly | faArchive;
 
-     TSearchRecChecked SearchRec;
 
-     bool Found;
 
-     Found =
 
-       (FindFirstUnchecked(ChangeFileExt(ModuleFileName(), L".*"),
 
-          FindAttrs, SearchRec) == 0);
 
-     try
 
-     {
 
-       UnicodeString Ext;
 
-       while (Found)
 
-       {
 
-         Ext = ExtractFileExt(SearchRec.Name).UpperCase();
 
-         if ((Ext.Length() >= 3) && (Ext != L".EXE") && (Ext != L".COM") &&
 
-             (Ext != L".DLL") && (Ext != L".INI"))
 
-         {
 
-           Ext = Ext.SubString(2, Ext.Length() - 1);
 
-           LocalesExts += Ext;
 
-           Exts->Add(Ext);
 
-         }
 
-         Found = (FindNextChecked(SearchRec) == 0);
 
-       }
 
-     }
 
-     __finally
 
-     {
 
-       FindClose(SearchRec);
 
-     }
 
-     if (FLastLocalesExts != LocalesExts)
 
-     {
 
-       FLastLocalesExts = LocalesExts;
 
-       FLocales->Clear();
 
-       TLanguages * Langs = Languages();
 
-       int Ext, Index, Count;
 
-       wchar_t LocaleStr[255];
 
-       LCID Locale;
 
-       Count = Langs->Count;
 
-       Index = -1;
 
-       while (Index < Count)
 
-       {
 
-         if (Index >= 0)
 
-         {
 
-           Locale = Langs->LocaleID[Index];
 
-           Ext = Exts->IndexOf(Langs->Ext[Index]);
 
-           if (Ext < 0)
 
-           {
 
-             Ext = Exts->IndexOf(Langs->Ext[Index].SubString(1, 2));
 
-             if (Ext >= 0)
 
-             {
 
-               Locale = MAKELANGID(PRIMARYLANGID(Locale), SUBLANG_DEFAULT);
 
-             }
 
-           }
 
-           if (Ext >= 0)
 
-           {
 
-             Exts->Objects[Ext] = reinterpret_cast<TObject*>(Locale);
 
-           }
 
-           else
 
-           {
 
-             Locale = 0;
 
-           }
 
-         }
 
-         else
 
-         {
 
-           Locale = InternalLocale();
 
-         }
 
-         if (Locale)
 
-         {
 
-           UnicodeString Name;
 
-           GetLocaleInfo(Locale, LOCALE_SENGLANGUAGE,
 
-             LocaleStr, LENOF(LocaleStr));
 
-           Name = LocaleStr;
 
-           Name += L" - ";
 
-           // LOCALE_SNATIVELANGNAME
 
-           GetLocaleInfo(Locale, LOCALE_SLANGUAGE,
 
-             LocaleStr, LENOF(LocaleStr));
 
-           Name += LocaleStr;
 
-           FLocales->AddObject(Name, reinterpret_cast<TObject*>(Locale));
 
-         }
 
-         Index++;
 
-       }
 
-       for (int Index = 0; Index < Exts->Count; Index++)
 
-       {
 
-         if ((Exts->Objects[Index] == NULL) &&
 
-             (Exts->Strings[Index].Length() == 3) &&
 
-             SameText(Exts->Strings[Index].SubString(1, 2), AdditionaLanguagePrefix))
 
-         {
 
-           UnicodeString LangName = GetFileFileInfoString(L"LangName",
 
-             ChangeFileExt(ModuleFileName(), UnicodeString(L".") + Exts->Strings[Index]));
 
-           if (!LangName.IsEmpty())
 
-           {
 
-             FLocales->AddObject(LangName, reinterpret_cast<TObject*>(
 
-               AdditionaLanguageMask + Exts->Strings[Index][3]));
 
-           }
 
-         }
 
-       }
 
-     }
 
-   }
 
-   __finally
 
-   {
 
-     delete Exts;
 
-   }
 
-   return FLocales;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetDefaultCopyParam(const TGUICopyParamType & value)
 
- {
 
-   FDefaultCopyParam.Assign(&value);
 
-   Changed();
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TGUIConfiguration::GetRememberPassword()
 
- {
 
-   return SessionRememberPassword || PuttyPassword;
 
- }
 
- //---------------------------------------------------------------------------
 
- const TCopyParamList * __fastcall TGUIConfiguration::GetCopyParamList()
 
- {
 
-   return FCopyParamList;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetCopyParamList(const TCopyParamList * value)
 
- {
 
-   if (!(*FCopyParamList == *value))
 
-   {
 
-     *FCopyParamList = *value;
 
-     FCopyParamListDefaults = false;
 
-     Changed();
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
- int __fastcall TGUIConfiguration::GetCopyParamIndex()
 
- {
 
-   int Result;
 
-   if (FCopyParamCurrent.IsEmpty())
 
-   {
 
-     Result = -1;
 
-   }
 
-   else
 
-   {
 
-     Result = FCopyParamList->IndexOfName(FCopyParamCurrent);
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetCopyParamIndex(int value)
 
- {
 
-   UnicodeString Name;
 
-   if (value < 0)
 
-   {
 
-     Name = L"";
 
-   }
 
-   else
 
-   {
 
-     Name = FCopyParamList->Names[value];
 
-   }
 
-   CopyParamCurrent = Name;
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetCopyParamCurrent(UnicodeString value)
 
- {
 
-   SET_CONFIG_PROPERTY(CopyParamCurrent);
 
- }
 
- //---------------------------------------------------------------------------
 
- TGUICopyParamType __fastcall TGUIConfiguration::GetCurrentCopyParam()
 
- {
 
-   return CopyParamPreset[CopyParamCurrent];
 
- }
 
- //---------------------------------------------------------------------------
 
- TGUICopyParamType __fastcall TGUIConfiguration::GetCopyParamPreset(UnicodeString Name)
 
- {
 
-   TGUICopyParamType Result = FDefaultCopyParam;
 
-   if (!Name.IsEmpty())
 
-   {
 
-     int Index = FCopyParamList->IndexOfName(Name);
 
-     DebugAssert(Index >= 0);
 
-     if (Index >= 0)
 
-     {
 
-       const TCopyParamType * Preset = FCopyParamList->CopyParams[Index];
 
-       DebugAssert(Preset != NULL);
 
-       Result.Assign(Preset); // overwrite all but GUI options
 
-       // reset all options known not to be configurable per-preset
 
-       // kind of hack
 
-       Result.ResumeSupport = FDefaultCopyParam.ResumeSupport;
 
-       Result.ResumeThreshold = FDefaultCopyParam.ResumeThreshold;
 
-       Result.LocalInvalidChars = FDefaultCopyParam.LocalInvalidChars;
 
-     }
 
-   }
 
-   return Result;
 
- }
 
- //---------------------------------------------------------------------------
 
- bool __fastcall TGUIConfiguration::GetHasCopyParamPreset(UnicodeString Name)
 
- {
 
-   return Name.IsEmpty() || (FCopyParamList->IndexOfName(Name) >= 0);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetNewDirectoryProperties(
 
-   const TRemoteProperties & value)
 
- {
 
-   SET_CONFIG_PROPERTY(NewDirectoryProperties);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetQueueTransfersLimit(int value)
 
- {
 
-   SET_CONFIG_PROPERTY(QueueTransfersLimit);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetQueueKeepDoneItems(bool value)
 
- {
 
-   SET_CONFIG_PROPERTY(QueueKeepDoneItems);
 
- }
 
- //---------------------------------------------------------------------------
 
- void __fastcall TGUIConfiguration::SetQueueKeepDoneItemsFor(int value)
 
- {
 
-   SET_CONFIG_PROPERTY(QueueKeepDoneItemsFor);
 
- }
 
- //---------------------------------------------------------------------
 
- TStoredSessionList * __fastcall TGUIConfiguration::SelectPuttySessionsForImport(
 
-   TStoredSessionList * Sessions, UnicodeString & Error)
 
- {
 
-   std::unique_ptr<TStoredSessionList> ImportSessionList(new TStoredSessionList(true));
 
-   ImportSessionList->DefaultSettings = Sessions->DefaultSettings;
 
-   std::unique_ptr<TRegistryStorage> Storage(new TRegistryStorage(PuttySessionsKey));
 
-   Storage->ForceAnsi = true;
 
-   if (Storage->OpenRootKey(false))
 
-   {
 
-     ImportSessionList->Load(Storage.get(), false, true);
 
-   }
 
-   TSessionData * PuttySessionData =
 
-     (TSessionData *)ImportSessionList->FindByName(PuttySession);
 
-   if (PuttySessionData != NULL)
 
-   {
 
-     ImportSessionList->Remove(PuttySessionData);
 
-   }
 
-   if (ImportSessionList->Count > 0)
 
-   {
 
-     ImportSessionList->SelectSessionsToImport(Sessions, true);
 
-   }
 
-   else
 
-   {
 
-     Error = FMTLOAD(PUTTY_NO_SITES, (PuttySessionsKey));
 
-   }
 
-   return ImportSessionList.release();
 
- }
 
- //---------------------------------------------------------------------
 
- bool __fastcall TGUIConfiguration::AnyPuttySessionForImport(TStoredSessionList * Sessions)
 
- {
 
-   try
 
-   {
 
-     UnicodeString Error;
 
-     std::unique_ptr<TStoredSessionList> Sesssions(SelectPuttySessionsForImport(Sessions, Error));
 
-     return (Sesssions->Count > 0);
 
-   }
 
-   catch (...)
 
-   {
 
-     return false;
 
-   }
 
- }
 
- //---------------------------------------------------------------------------
 
 
  |