Skip to content

Commit

Permalink
Bug 1893: Basic implementation of local tabs
Browse files Browse the repository at this point in the history
Source commit: fc01f97bd46c7581fcd9c9ebd5f45c345e50a0d6
  • Loading branch information
martinprikryl committed Nov 19, 2020
1 parent 248829a commit 7c0121b
Show file tree
Hide file tree
Showing 16 changed files with 512 additions and 276 deletions.
10 changes: 10 additions & 0 deletions source/core/RemoteFiles.cpp
Expand Up @@ -144,6 +144,16 @@ UnicodeString __fastcall ExtractFileName(const UnicodeString & Path, bool Unix)
}
}
//---------------------------------------------------------------------------
UnicodeString ExtractShortName(const UnicodeString & Path, bool Unix)
{
UnicodeString Result = ExtractFileName(Path, Unix);
if (Result.IsEmpty())
{
Result = Path;
}
return Result;
}
//---------------------------------------------------------------------------
bool __fastcall ExtractCommonPath(TStrings * Files, UnicodeString & Path)
{
DebugAssert(Files->Count > 0);
Expand Down
1 change: 1 addition & 0 deletions source/core/RemoteFiles.h
Expand Up @@ -547,6 +547,7 @@ UnicodeString __fastcall UnixCombinePaths(const UnicodeString & Path1, const Uni
UnicodeString __fastcall UnixExtractFileDir(const UnicodeString Path);
UnicodeString __fastcall UnixExtractFilePath(const UnicodeString Path);
UnicodeString __fastcall UnixExtractFileName(const UnicodeString Path);
UnicodeString ExtractShortName(const UnicodeString & Path, bool Unix);
UnicodeString __fastcall UnixExtractFileExt(const UnicodeString Path);
Boolean __fastcall UnixSamePath(const UnicodeString Path1, const UnicodeString Path2);
bool __fastcall UnixIsChildPath(UnicodeString Parent, UnicodeString Child);
Expand Down
36 changes: 32 additions & 4 deletions source/core/SessionData.cpp
Expand Up @@ -200,6 +200,7 @@ void __fastcall TSessionData::DefaultSettings()
// FS common
LocalDirectory = L"";
OtherLocalDirectory = L"";
RemoteDirectory = L"";
SynchronizeBrowsing = false;
UpdateDirectories = true;
Expand Down Expand Up @@ -318,6 +319,7 @@ void __fastcall TSessionData::NonPersistant()
PROPERTY(FSProtocol); \
PROPERTY(Ftps); \
PROPERTY(LocalDirectory); \
PROPERTY(OtherLocalDirectory); \
PROPERTY(RemoteDirectory); \
PROPERTY(Color); \
PROPERTY(SynchronizeBrowsing); \
Expand Down Expand Up @@ -516,6 +518,7 @@ void __fastcall TSessionData::CopyDirectoriesStateData(TSessionData * SourceData
{
RemoteDirectory = SourceData->RemoteDirectory;
LocalDirectory = SourceData->LocalDirectory;
OtherLocalDirectory = SourceData->OtherLocalDirectory;
SynchronizeBrowsing = SourceData->SynchronizeBrowsing;
}
//---------------------------------------------------------------------
Expand All @@ -524,6 +527,7 @@ bool __fastcall TSessionData::HasStateData()
return
!RemoteDirectory.IsEmpty() ||
!LocalDirectory.IsEmpty() ||
!OtherLocalDirectory.IsEmpty() ||
(Color != 0);
}
//---------------------------------------------------------------------
Expand Down Expand Up @@ -689,6 +693,7 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool PuttyI
FSProtocol = (TFSProtocol)Storage->ReadInteger(L"FSProtocol", FSProtocol);
LocalDirectory = Storage->ReadString(L"LocalDirectory", LocalDirectory);
OtherLocalDirectory = Storage->ReadString(L"OtherLocalDirectory", OtherLocalDirectory);
RemoteDirectory = Storage->ReadString(L"RemoteDirectory", RemoteDirectory);
SynchronizeBrowsing = Storage->ReadBool(L"SynchronizeBrowsing", SynchronizeBrowsing);
UpdateDirectories = Storage->ReadBool(L"UpdateDirectories", UpdateDirectories);
Expand Down Expand Up @@ -1056,6 +1061,7 @@ void __fastcall TSessionData::DoSave(THierarchicalStorage * Storage,
WRITE_DATA(String, PublicKeyFile);
WRITE_DATA(Integer, FSProtocol);
WRITE_DATA(String, LocalDirectory);
WRITE_DATA(String, OtherLocalDirectory);
WRITE_DATA(String, RemoteDirectory);
WRITE_DATA(Bool, SynchronizeBrowsing);
WRITE_DATA(Bool, UpdateDirectories);
Expand Down Expand Up @@ -2379,6 +2385,16 @@ bool __fastcall TSessionData::GetCanLogin()
{
return !FHostName.IsEmpty();
}
//---------------------------------------------------------------------
bool __fastcall TSessionData::GetIsLocalBrowser()
{
return !LocalDirectory.IsEmpty() && !OtherLocalDirectory.IsEmpty();
}
//---------------------------------------------------------------------
bool __fastcall TSessionData::GetCanOpen()
{
return CanLogin || IsLocalBrowser;
}
//---------------------------------------------------------------------------
UnicodeString __fastcall TSessionData::GetSessionKey()
{
Expand Down Expand Up @@ -2977,7 +2993,14 @@ void __fastcall TSessionData::SetRekeyTime(unsigned int value)
//---------------------------------------------------------------------
UnicodeString __fastcall TSessionData::GetDefaultSessionName()
{
if (!HostName.IsEmpty() && !UserName.IsEmpty())
if (IsLocalBrowser)
{
// See also TScpCommanderForm::GetLocalBrowserSessionTitle
UnicodeString Path1 = ExtractShortName(LocalDirectory, false);
UnicodeString Path2 = ExtractShortName(OtherLocalDirectory, false);
return FORMAT(L"%s - %s", (Path1, Path2));
}
else if (!HostName.IsEmpty() && !UserName.IsEmpty())
{
// If we ever choose to include port number,
// we have to escape IPv6 literals in HostName
Expand Down Expand Up @@ -3657,6 +3680,11 @@ void __fastcall TSessionData::SetLocalDirectory(UnicodeString value)
SET_SESSION_PROPERTY(LocalDirectory);
}
//---------------------------------------------------------------------
void __fastcall TSessionData::SetOtherLocalDirectory(const UnicodeString & value)
{
SET_SESSION_PROPERTY(OtherLocalDirectory);
}
//---------------------------------------------------------------------
UnicodeString __fastcall TSessionData::GetLocalDirectoryExpanded()
{
return ExpandFileName(::ExpandEnvironmentVariables(LocalDirectory));
Expand Down Expand Up @@ -5016,7 +5044,7 @@ TSessionData * __fastcall TStoredSessionList::CheckIsInFolderOrWorkspaceAndResol
{
Data = ResolveWorkspaceData(Data);

if ((Data != NULL) && Data->CanLogin &&
if ((Data != NULL) && Data->CanOpen &&
DebugAlwaysTrue(Data->Link.IsEmpty()))
{
return Data;
Expand Down Expand Up @@ -5207,10 +5235,10 @@ TSessionData * __fastcall TStoredSessionList::SaveWorkspaceData(TSessionData * D
return Result.release();
}
//---------------------------------------------------------------------
bool __fastcall TStoredSessionList::CanLogin(TSessionData * Data)
bool __fastcall TStoredSessionList::CanOpen(TSessionData * Data)
{
Data = ResolveWorkspaceData(Data);
return (Data != NULL) && Data->CanLogin;
return (Data != NULL) && Data->CanOpen;
}
//---------------------------------------------------------------------
UnicodeString GetExpandedLogFileName(UnicodeString LogFileName, TDateTime Started, TSessionData * SessionData)
Expand Down
9 changes: 8 additions & 1 deletion source/core/SessionData.h
Expand Up @@ -139,6 +139,7 @@ friend class TStoredSessionList;
bool FModified;
UnicodeString FLocalDirectory;
UnicodeString FRemoteDirectory;
UnicodeString FOtherLocalDirectory;
bool FLockInHome;
bool FSpecial;
bool FSynchronizeBrowsing;
Expand Down Expand Up @@ -281,6 +282,8 @@ friend class TStoredSessionList;

void __fastcall SetPuttyProtocol(UnicodeString value);
bool __fastcall GetCanLogin();
bool __fastcall GetCanOpen();
bool __fastcall GetIsLocalBrowser();
void __fastcall SetPingIntervalDT(TDateTime value);
TDateTime __fastcall GetPingIntervalDT();
TDateTime __fastcall GetFtpPingIntervalDT();
Expand All @@ -293,6 +296,7 @@ friend class TStoredSessionList;
void __fastcall SetFSProtocol(TFSProtocol value);
UnicodeString __fastcall GetFSProtocolStr();
void __fastcall SetLocalDirectory(UnicodeString value);
void __fastcall SetOtherLocalDirectory(const UnicodeString & value);
UnicodeString __fastcall GetLocalDirectoryExpanded();
void __fastcall SetRemoteDirectory(UnicodeString value);
void __fastcall SetSynchronizeBrowsing(bool value);
Expand Down Expand Up @@ -562,6 +566,8 @@ friend class TStoredSessionList;
__property UnicodeString FSProtocolStr = { read=GetFSProtocolStr };
__property bool Modified = { read=FModified, write=FModified };
__property bool CanLogin = { read=GetCanLogin };
__property bool CanOpen = { read=GetCanOpen };
__property bool IsLocalBrowser = { read=GetIsLocalBrowser };
__property bool ClearAliases = { read = FClearAliases, write = SetClearAliases };
__property TDateTime PingIntervalDT = { read = GetPingIntervalDT, write = SetPingIntervalDT };
__property TDateTime TimeDifference = { read = FTimeDifference, write = SetTimeDifference };
Expand All @@ -571,6 +577,7 @@ friend class TStoredSessionList;
__property UnicodeString DefaultSessionName = { read=GetDefaultSessionName };
__property UnicodeString LocalDirectory = { read=FLocalDirectory, write=SetLocalDirectory };
__property UnicodeString LocalDirectoryExpanded = { read = GetLocalDirectoryExpanded };
__property UnicodeString OtherLocalDirectory = { read=FOtherLocalDirectory, write=SetOtherLocalDirectory };
__property UnicodeString RemoteDirectory = { read=FRemoteDirectory, write=SetRemoteDirectory };
__property bool SynchronizeBrowsing = { read=FSynchronizeBrowsing, write=SetSynchronizeBrowsing };
__property bool UpdateDirectories = { read=FUpdateDirectories, write=SetUpdateDirectories };
Expand Down Expand Up @@ -721,7 +728,7 @@ class TStoredSessionList : public TNamedObjectList
TSessionData * __fastcall ParseUrl(UnicodeString Url, TOptions * Options, bool & DefaultsOnly,
UnicodeString * FileName = NULL, bool * ProtocolDefined = NULL, UnicodeString * MaskedUrl = NULL, int Flags = 0);
bool __fastcall IsUrl(UnicodeString Url);
bool __fastcall CanLogin(TSessionData * Data);
bool __fastcall CanOpen(TSessionData * Data);
void __fastcall GetFolderOrWorkspace(const UnicodeString & Name, TList * List);
TStrings * __fastcall GetFolderOrWorkspaceList(const UnicodeString & Name);
TStrings * __fastcall GetWorkspaces();
Expand Down

0 comments on commit 7c0121b

Please sign in to comment.