Skip to content

Commit

Permalink
Merge branch 'main' into far3-dev-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellukashov committed Apr 10, 2024
2 parents f7b7cf1 + ec4a6ff commit eaf0976
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 65 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ set(OPENSSL_COMPILE_FLAGS
-DOPENSSL_NO_ERR
-DOPENSSL_NO_CAMELLIA
-DOPENSSL_NO_DEPRECATED_3_0
-DOPENSSL_NO_PINSHARED
)

if(MSVC)
Expand Down
9 changes: 7 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
https://github.com/FarGroup/FarManager/issues/816

Thanks to ssvine https://github.com/ssvine
* gh-448 Crash on directory copy
* gh-449 Fix SFTP crash when resuming copy from local to remote
* gh-447 Fix crash when trying to copy parent directory entry
* gh-446 Fix Alt-F12 history navigation
* gh-445 Relax file naming restrictions
* gh-444 Fix regression: closing FTP does not completely clear the session
* gh-443 Several crashes
* gh-440 WebDAV: Crashes on connection
* gh-442 Fix several crashes
* gh-441 Fix WebDAV and S3 crash under some conditions


## [24.3.1.599] - 2024-03-22
Expand Down
14 changes: 9 additions & 5 deletions README.RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NetBox: SFTP/FTP(S)/SCP/WebDAV клиент для Far Manager 2.0/3.0

1. Общие сведения о плагине

Плагин реализует клиентскую часть протоколов SFTP, FTP, SCP, FTPS и WebDAV.
Плагин реализует клиентскую часть протоколов SFTP, FTP, SCP, FTPS, WebDAV и S3.
SFTP, FTP, SCP, FTPS протоколы реализованы на основе плагина WinSCP [http://winscp.net/eng/download.php/](http://winscp.net/eng/download.php/)
Поддержка протокола WebDAV реализована на основе библиотеки neon [http://www.webdav.org/neon/](http://www.webdav.org/neon/).
Парсер xml работает c помощью библиотеки TinyXML [http://sourceforge.net/projects/tinyxml/] (http://sourceforge.net/projects/tinyxml/).
Expand All @@ -12,24 +12,28 @@ NetBox: SFTP/FTP(S)/SCP/WebDAV клиент для Far Manager 2.0/3.0

Доступ к удалённому серверу возможен как через собственное хранилище сессий, так и через префикс.

Возможны два варианта использования префикса:
Возможны три варианта использования префикса:
a. NetBox:Protocol://[[User]:[Password]@]HostName[:Port][/Path]

где Protocol - имя протокола (ftp/ftps/sftp/http/https)
где Protocol - имя протокола (ftp|ftps|ftpes|ssh|scp|sftp|dav|davs|http|https|s3|s3plain)
User - имя пользователя
Password - пароль пользователя
HostName - имя хоста
Port - номер порта
Path - путь

b. (sftp|ftp|scp|ftps|http|https)://[[User]:[Password]@]HostName[:Port][/Path]
где (sftp|ftp|scp|ftps|http|https) - имя протокола
b. (sftp|ftp|scp|ftps|webdav|s3)://[[User]:[Password]@]HostName[:Port][/Path]
где (sftp|ftp|scp|ftps|webdav|s3) - имя протокола
User - имя пользователя
Password - пароль пользователя
HostName - имя хоста
Port - номер порта
Path - путь

c. NetBox:SessionName[/Path]
где SessionName - сохранённое имя сессии
Path - путь

Особенности работы с FTP серверами допускающими анонимный логин.

ВНИМАНИЕ!
Expand Down
2 changes: 1 addition & 1 deletion src/NetBox/FarDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ bool TFarDialog::HotKey(uint32_t Key, uint32_t ControlState) const
{
bool Result = false;
char HotKey = 0;
if ((ControlState & ALTMASK) &&
if (CheckControlMaskSet(ControlState, ALTMASK) &&
('A' <= Key) && (Key <= 'Z'))
{
Result = true;
Expand Down
3 changes: 2 additions & 1 deletion src/NetBox/FarPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,8 @@ TFarPanelInfo ** TCustomFarFileSystem::GetPanelInfo(int32_t Another)
{
DebugAssert(false);
}
FPanelInfo[bAnother] = new TFarPanelInfo(Info, !bAnother ? this : nullptr);
const bool SetOwner = !bAnother || (GetOppositeFileSystem() == this);
FPanelInfo[bAnother] = new TFarPanelInfo(Info, SetOwner ? this : nullptr);
}
return &FPanelInfo[bAnother];
}
Expand Down
9 changes: 9 additions & 0 deletions src/NetBox/FarPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ constexpr const DWORD CTRLMASK = (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED);
constexpr const DWORD SHIFTMASK = (SHIFT_PRESSED);
constexpr const wchar_t * SHORTCUT_DELIMITER = L"\1";

template<typename... TMasks>
bool CheckControlMaskSet(DWORD State, TMasks... Masks)
{
const auto CtlState = State & RMASK;
// 1) check all individual masks are present in the ctl state
// 2) check all bits that are not in any mask are cleared
return ((CtlState & Masks) && ...) && !(CtlState & ~(Masks | ...));
}

class TCustomFarFileSystem;
class TFarPanelModes;
class TFarKeyBarTitles;
Expand Down
20 changes: 10 additions & 10 deletions src/NetBox/WinSCPDialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ bool TTabbedDialog::Key(TFarDialogItem * /*Item*/, intptr_t KeyCode)
bool Result = false;
const WORD Key = KeyCode & 0xFFFF;
const WORD ControlState = nb::ToWord(KeyCode >> 16);
if ((((Key == VK_NEXT) || (Key == VK_NUMPAD3)) && (ControlState & CTRLMASK) != 0) ||
(((Key == VK_PRIOR) || (Key == VK_NUMPAD9)) && (ControlState & CTRLMASK) != 0))
if ((((Key == VK_NEXT) || (Key == VK_NUMPAD3)) && CheckControlMaskSet(ControlState, CTRLMASK)) ||
(((Key == VK_PRIOR) || (Key == VK_NUMPAD9)) && CheckControlMaskSet(ControlState, CTRLMASK)))
{
int32_t NewTab = FTab;
do
Expand Down Expand Up @@ -7524,7 +7524,7 @@ void TSynchronizeChecklistDialog::AddColumn(UnicodeString & List,
Width--;
}
List += Value.SubString(Scroll + 1, Width);
if (!Header && (Len - Scroll > Width))
if (!AHeader && (Len - Scroll > Width))
{
List += L'}';
FCanScrollRight = true;
Expand Down Expand Up @@ -7881,10 +7881,10 @@ bool TSynchronizeChecklistDialog::Key(TFarDialogItem * Item, intptr_t KeyCode)
const WORD ControlState = nb::ToWord(KeyCode >> 16);
if (ListBox->Focused())
{
if (((Key == VK_ADD) && (ControlState & SHIFTMASK) != 0) ||
((Key == VK_SUBTRACT) && (ControlState & SHIFTMASK) != 0))
if (((Key == VK_ADD) && CheckControlMaskSet(ControlState, SHIFTMASK)) ||
((Key == VK_SUBTRACT) && CheckControlMaskSet(ControlState, SHIFTMASK)))
{
CheckAll((Key == VK_ADD) && (ControlState & SHIFTMASK) != 0);
CheckAll((Key == VK_ADD) && CheckControlMaskSet(ControlState, SHIFTMASK));
Result = true;
}
else if ((Key == VK_SPACE) || (Key == VK_INSERT) ||
Expand Down Expand Up @@ -7913,7 +7913,7 @@ bool TSynchronizeChecklistDialog::Key(TFarDialogItem * Item, intptr_t KeyCode)
}
Result = true;
}
else if ((Key == VK_LEFT) && (ControlState & ALTMASK) != 0)
else if ((Key == VK_LEFT) && CheckControlMaskSet(ControlState, ALTMASK))
{
if (FScroll > 0)
{
Expand All @@ -7922,7 +7922,7 @@ bool TSynchronizeChecklistDialog::Key(TFarDialogItem * Item, intptr_t KeyCode)
}
Result = true;
}
else if (Key == VK_RIGHT)
else if ((Key == VK_RIGHT) && CheckControlMaskSet(ControlState, ALTMASK))
{
if (FCanScrollRight)
{
Expand Down Expand Up @@ -8648,15 +8648,15 @@ bool TQueueDialog::Key(TFarDialogItem * /*Item*/, intptr_t KeyCode)
}
Result = true;
}
else if ((Key == VK_UP) && (ControlState & CTRLMASK) != 0)
else if ((Key == VK_UP) && CheckControlMaskSet(ControlState, CTRLMASK))
{
if (MoveUpButton->GetEnabled())
{
DoButton = MoveUpButton;
}
Result = true;
}
else if ((Key == VK_DOWN) && (ControlState & CTRLMASK) != 0)
else if ((Key == VK_DOWN) && CheckControlMaskSet(ControlState, CTRLMASK))
{
if (MoveDownButton->GetEnabled())
{
Expand Down
57 changes: 26 additions & 31 deletions src/NetBox/WinSCPFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,7 @@ bool TWinSCPFileSystem::ProcessKeyEx(int32_t Key, uint32_t ControlState)
TFarPanelInfo * const * PanelInfo = GetPanelInfo();
const TFarPanelItem * Focused = PanelInfo && *PanelInfo ? (*PanelInfo)->GetFocusedItem() : nullptr;

if ((Key == 'W') && (ControlState & SHIFTMASK) &&
(ControlState & ALTMASK))
if ((Key == 'W') && CheckControlMaskSet(ControlState, SHIFTMASK, ALTMASK))
{
GetWinSCPPlugin()->CommandsMenu(true);
Handled = true;
Expand All @@ -930,13 +929,13 @@ bool TWinSCPFileSystem::ProcessKeyEx(int32_t Key, uint32_t ControlState)
Data = cast_to<TSessionData>(ToObj(Focused->GetUserData()));
}

if ((Key == 'F') && (ControlState & CTRLMASK))
if ((Key == 'F') && CheckControlMaskSet(ControlState, CTRLMASK))
{
InsertSessionNameOnCommandLine();
Handled = true;
}

if ((Key == VK_RETURN) && (ControlState & CTRLMASK))
if ((Key == VK_RETURN) && CheckControlMaskSet(ControlState, CTRLMASK))
{
InsertSessionNameOnCommandLine();
Handled = true;
Expand All @@ -957,14 +956,14 @@ bool TWinSCPFileSystem::ProcessKeyEx(int32_t Key, uint32_t ControlState)
Handled = true;
}

if (Key == VK_F4 && (ControlState & SHIFTMASK))
if (Key == VK_F4 && CheckControlMaskSet(ControlState, SHIFTMASK))
{
EditConnectSession(nullptr, true);
Handled = true;
}

if (((Key == VK_F5) || (Key == VK_F6)) &&
(ControlState & SHIFTMASK))
CheckControlMaskSet(ControlState, SHIFTMASK))
{
if (Data != nullptr)
{
Expand All @@ -973,7 +972,7 @@ bool TWinSCPFileSystem::ProcessKeyEx(int32_t Key, uint32_t ControlState)
Handled = true;
}

if (Key == 'R' && (ControlState & CTRLMASK))
if (Key == 'R' && CheckControlMaskSet(ControlState, CTRLMASK))
{
DeleteStoredSessions();
if (UpdatePanel())
Expand All @@ -985,78 +984,74 @@ bool TWinSCPFileSystem::ProcessKeyEx(int32_t Key, uint32_t ControlState)
}
else if (Connected())
{
if ((Key == 'F') && (ControlState & CTRLMASK))
if ((Key == 'F') && CheckControlMaskSet(ControlState, CTRLMASK, ALTMASK))
{
InsertFileNameOnCommandLine(true);
Handled = true;
}

if ((Key == VK_RETURN) && (ControlState & CTRLMASK))
if ((Key == VK_RETURN) && CheckControlMaskSet(ControlState, CTRLMASK))
{
InsertFileNameOnCommandLine(false);
Handled = true;
}

if ((Key == 'R') && (ControlState & CTRLMASK))
if ((Key == 'R') && CheckControlMaskSet(ControlState, CTRLMASK))
{
FReloadDirectory = true;
}

if ((Key == 'A') && (ControlState & CTRLMASK))
if ((Key == 'A') && CheckControlMaskSet(ControlState, CTRLMASK))
{
FileProperties();
Handled = true;
}

if ((Key == 'G') && (ControlState & CTRLMASK))
if ((Key == 'G') && CheckControlMaskSet(ControlState, CTRLMASK))
{
ApplyCommand();
Handled = true;
}

if ((Key == 'Q') && (ControlState & SHIFTMASK) &&
(ControlState & ALTMASK))
if ((Key == 'Q') && CheckControlMaskSet(ControlState, SHIFTMASK, ALTMASK))
{
QueueShow(false);
Handled = true;
}

if ((Key == 'B') && (ControlState & CTRLMASK) &&
(ControlState & ALTMASK))
if ((Key == 'B') && CheckControlMaskSet(ControlState, CTRLMASK, ALTMASK))
{
ToggleSynchronizeBrowsing();
Handled = true;
}

if ((Key == VK_INSERT) && (((ControlState & ALTMASK) && (ControlState & SHIFTMASK)) ||
(((ControlState & CTRLMASK) && (ControlState & ALTMASK)))))
if ((Key == VK_INSERT) && CheckControlMaskSet(ControlState, ALTMASK, SHIFTMASK))
{
CopyFullFileNamesToClipboard();
Handled = true;
}

if ((Key == VK_F6) && (ControlState & ALTMASK) && !(ControlState & SHIFTMASK))
if ((Key == VK_F6) && CheckControlMaskSet(ControlState, ALTMASK))
{
RemoteCreateLink();
Handled = true;
}

if (Focused && ((Key == VK_F5) || (Key == VK_F6)) &&
(ControlState & SHIFTMASK) && !(ControlState & ALTMASK))
CheckControlMaskSet(ControlState, SHIFTMASK))
{
TransferFiles((Key == VK_F6));
Handled = true;
}

if (Focused && (Key == VK_F6) &&
((ControlState & SHIFTMASK) && (ControlState & ALTMASK)))
CheckControlMaskSet(ControlState, SHIFTMASK, ALTMASK))
{
RenameFile();
Handled = true;
}

if ((Key == VK_F12) && (ControlState & SHIFTMASK) &&
(ControlState & ALTMASK))
if ((Key == VK_F12) && CheckControlMaskSet(ControlState, SHIFTMASK, ALTMASK))
{
OpenDirectory(false);
Handled = true;
Expand All @@ -1071,8 +1066,8 @@ bool TWinSCPFileSystem::ProcessKeyEx(int32_t Key, uint32_t ControlState)

// Return to session panel
if (Focused && !Handled && !IsConnectedDirectly() &&
((Key == VK_RETURN) && (Focused->GetFileName() == PARENTDIRECTORY) ||
(Key == VK_PRIOR) && (ControlState & CTRLMASK)) && FLastPath == ROOTDIRECTORY)
((Key == VK_RETURN) && (ControlState == 0) && (Focused->GetFileName() == PARENTDIRECTORY) ||
(Key == VK_PRIOR) && CheckControlMaskSet(ControlState, CTRLMASK)) && FLastPath == ROOTDIRECTORY)
{
SetDirectoryEx(PARENTDIRECTORY, 0);
if (UpdatePanel())
Expand Down Expand Up @@ -1937,7 +1932,7 @@ void TWinSCPFileSystem::InsertTokenOnCommandLine(const UnicodeString & Token, bo

void TWinSCPFileSystem::InsertSessionNameOnCommandLine()
{
TFarPanelInfo * const * PanelInfo = GetPanelInfo();
TFarPanelInfo * const * PanelInfo = IsActiveFileSystem() ? GetPanelInfo(): GetAnotherPanelInfo();
const TFarPanelItem * Focused = PanelInfo && *PanelInfo ? (*PanelInfo)->GetFocusedItem() : nullptr;

if (Focused != nullptr)
Expand All @@ -1962,7 +1957,7 @@ void TWinSCPFileSystem::InsertSessionNameOnCommandLine()

void TWinSCPFileSystem::InsertFileNameOnCommandLine(bool Full)
{
TFarPanelInfo * const * PanelInfo = GetPanelInfo();
TFarPanelInfo * const * PanelInfo = IsActiveFileSystem() ? GetPanelInfo(): GetAnotherPanelInfo();
const TFarPanelItem * Focused = PanelInfo && *PanelInfo ? (*PanelInfo)->GetFocusedItem() : nullptr;

if (Focused != nullptr)
Expand Down Expand Up @@ -2724,8 +2719,7 @@ int32_t TWinSCPFileSystem::UploadFiles(bool Move, OPERATION_MODES OpMode, bool E
bool Confirmed = (OpMode & OPM_SILENT);
bool Ask = !Confirmed;

TGUICopyParamType CopyParam;
CopyParam.Default();
TGUICopyParamType CopyParam(GetGUIConfiguration()->GetDefaultCopyParam());

if (Edit)
{
Expand Down Expand Up @@ -4119,8 +4113,8 @@ void TWinSCPFileSystem::MultipleEdit()
}
}

void TWinSCPFileSystem::MultipleEdit(const UnicodeString & Directory,
const UnicodeString & AFileName, const TRemoteFile * AFile)
void TWinSCPFileSystem::MultipleEdit(const UnicodeString Directory,
const UnicodeString AFileName, const TRemoteFile * AFile)
{
DebugAssert(AFile);
TEditHistory EditHistory;
Expand Down Expand Up @@ -4226,6 +4220,7 @@ void TWinSCPFileSystem::MultipleEdit(const UnicodeString & Directory,
UnicodeString TempDir;
TGUICopyParamType CopyParam(GetGUIConfiguration()->GetDefaultCopyParam());
EditViewCopyParam(CopyParam);
FLastEditCopyParam = CopyParam;

std::unique_ptr<TStrings> FileList(std::make_unique<TStringList>());
DebugAssert(!FNoProgressFinish);
Expand Down
2 changes: 1 addition & 1 deletion src/NetBox/WinSCPFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class TWinSCPFileSystem final : public TCustomFarFileSystem
const UnicodeString & RealFileName, UnicodeString & DestPath);
void LogAuthentication(TTerminal * Terminal, const UnicodeString & Msg);
void MultipleEdit();
void MultipleEdit(const UnicodeString & Directory, const UnicodeString & AFileName, const TRemoteFile * AFile);
void MultipleEdit(const UnicodeString Directory, const UnicodeString AFileName, const TRemoteFile * AFile);
void EditViewCopyParam(TCopyParamType & CopyParam);
bool SynchronizeBrowsing(const UnicodeString & NewPath);
bool IsEditHistoryEmpty() const;
Expand Down
3 changes: 1 addition & 2 deletions src/NetBox/WinSCPPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ int32_t TWinSCPPlugin::ProcessEditorInputEx(const INPUT_RECORD * Rec)
if ((Rec->EventType == KEY_EVENT) &&
Rec->Event.KeyEvent.bKeyDown &&
(Rec->Event.KeyEvent.uChar.AsciiChar == 'W') &&
(FLAGSET(Rec->Event.KeyEvent.dwControlKeyState, ALTMASK)) &&
(FLAGSET(Rec->Event.KeyEvent.dwControlKeyState, SHIFTMASK)))
CheckControlMaskSet(Rec->Event.KeyEvent.dwControlKeyState, ALTMASK, SHIFTMASK))
{
CommandsMenu(false);
Result = 1;
Expand Down
Loading

0 comments on commit eaf0976

Please sign in to comment.