Explorar o código

Not enabling background transfers when encrypting files (part of Bug 1653)

Source commit: bef96595996cdee1e3f63441260e7584548a58c7
Martin Prikryl %!s(int64=7) %!d(string=hai) anos
pai
achega
c4ee38c79b

+ 1 - 1
source/core/SessionInfo.h

@@ -43,7 +43,7 @@ enum TFSCapability { fcUserGroupListing, fcModeChanging, fcGroupChanging,
   fcModeChangingUpload, fcPreservingTimestampUpload, fcShellAnyCommand,
   fcSecondaryShell, fcRemoveCtrlZUpload, fcRemoveBOMUpload, fcMoveToQueue,
   fcLocking, fcPreservingTimestampDirs, fcResumeSupport,
-  fcChangePassword, fsSkipTransfer, fsParallelTransfers,
+  fcChangePassword, fsSkipTransfer, fsParallelTransfers, fsBackgroundTransfers,
   fcCount };
 //---------------------------------------------------------------------------
 struct TFileSystemInfo

+ 8 - 1
source/core/Terminal.cpp

@@ -2044,7 +2044,14 @@ void __fastcall TTerminal::SaveCapabilities(TFileSystemInfo & FileSystemInfo)
 bool __fastcall TTerminal::GetIsCapable(TFSCapability Capability) const
 {
   DebugAssert(FFileSystem);
-  return FFileSystem->IsCapable(Capability);
+  switch (Capability)
+  {
+    case fsBackgroundTransfers:
+      return !IsEncryptingFiles();
+
+    default:
+      return FFileSystem->IsCapable(Capability);
+  }
 }
 //---------------------------------------------------------------------------
 UnicodeString __fastcall TTerminal::AbsolutePath(UnicodeString Path, bool Local)

+ 1 - 1
source/core/Terminal.h

@@ -589,7 +589,7 @@ public:
   UnicodeString __fastcall ChangeFileName(const TCopyParamType * CopyParam,
     UnicodeString FileName, TOperationSide Side, bool FirstLevel);
   UnicodeString __fastcall GetBaseFileName(UnicodeString FileName);
-  bool __fastcall IsEncryptingFiles() { return !FEncryptKey.IsEmpty(); }
+  bool __fastcall IsEncryptingFiles() const { return !FEncryptKey.IsEmpty(); }
   RawByteString __fastcall GetEncryptKey() { return FEncryptKey; }
 
   static UnicodeString __fastcall ExpandFileName(UnicodeString Path,

+ 16 - 5
source/forms/CustomScpExplorer.cpp

@@ -709,7 +709,7 @@ void __fastcall TCustomScpExplorerForm::UpdateQueueView()
 {
   ComponentVisible[fcQueueView] =
     (WinConfiguration->QueueView.Show == qvShow) ||
-    ((WinConfiguration->QueueView.Show == qvHideWhenEmpty) &&
+     ((WinConfiguration->QueueView.Show == qvHideWhenEmpty) &&
      (FQueueStatus != NULL) && (FQueueStatus->Count > 0));
 }
 //---------------------------------------------------------------------------
@@ -1069,6 +1069,7 @@ bool __fastcall TCustomScpExplorerForm::CopyParamDialog(
       ToTemp;
     Options |=
       FLAGMASK(ToTemp, coTemp) |
+      FLAGMASK(!Terminal->IsCapable[fsBackgroundTransfers], coDisableQueue) |
       coDoNotShowAgain;
     TUsableCopyParamAttrs UsableCopyParamAttrs = Terminal->UsableCopyParamAttrs(Params);
     int CopyParamAttrs = (Direction == tdToRemote ?
@@ -1113,7 +1114,7 @@ bool __fastcall TCustomScpExplorerForm::CopyParamDialog(
     }
   }
 
-  if (Result && CopyParam.Queue && !ToTemp)
+  if (Result && CopyParam.Queue && !ToTemp && Terminal->IsCapable[fsBackgroundTransfers])
   {
 
     Configuration->Usage->Inc(L"TransfersOnBackground");
@@ -2997,9 +2998,19 @@ void __fastcall TCustomScpExplorerForm::CustomExecuteFile(TOperationSide Side,
       TForm * Editor;
       try
       {
-        Editor = ShowEditorForm(FileName, this, FEditorManager->FileChanged,
+        TNotifyEvent OnFileChanged = NULL;
+        TNotifyEvent OnSaveAll = NULL;
+        TAnyModifiedEvent OnAnyModified = NULL;
+        // Edited files are uploaded in background queue, what we do not support with encrypted files
+        if (Terminal->IsCapable[fsBackgroundTransfers])
+        {
+          OnFileChanged = FEditorManager->FileChanged;
+          OnSaveAll = SaveAllInternalEditors;
+          OnAnyModified = AnyInternalEditorModified;
+        }
+        Editor = ShowEditorForm(FileName, this, OnFileChanged,
           FEditorManager->FileReload, FEditorManager->FileClosed,
-          SaveAllInternalEditors, AnyInternalEditorModified,
+          OnSaveAll, OnAnyModified,
           Caption, FStandaloneEditing, SessionColor, Terminal->SessionData->InternalEditorEncoding);
       }
       catch(...)
@@ -8050,7 +8061,7 @@ void __fastcall TCustomScpExplorerForm::UpdateControls()
       }
       EnableControl(RemoteDriveView, false);
     }
-    EnableControl(QueueView3, HasTerminal);
+    EnableControl(QueueView3, HasTerminal && Terminal->IsCapable[fsBackgroundTransfers]);
     QueueLabelUpdateStatus();
     reinterpret_cast<TTBCustomItem *>(GetComponent(fcRemotePathComboBox))->Enabled = HasTerminal;
   }

+ 21 - 4
source/forms/Editor.cpp

@@ -771,7 +771,7 @@ void __fastcall TEditorForm::EditorActionsUpdate(TBasicAction *Action,
   }
   else if (Action == SaveAllAction2)
   {
-    bool Enabled = !FStandaloneEditor;
+    bool Enabled = !EditorMemo->ReadOnly && !FStandaloneEditor;
     if (Enabled)
     {
       Enabled = IsFileModified();
@@ -783,6 +783,10 @@ void __fastcall TEditorForm::EditorActionsUpdate(TBasicAction *Action,
     }
     SaveAllAction2->Enabled = Enabled;
   }
+  else if (Action == ReplaceAction)
+  {
+    ReplaceAction->Enabled = !EditorMemo->ReadOnly;
+  }
   else if (Action == FindNextAction)
   {
     FindNextAction->Enabled =
@@ -1008,6 +1012,8 @@ void __fastcall TEditorForm::FileUploadComplete()
 //---------------------------------------------------------------------------
 void __fastcall TEditorForm::UpdateControls()
 {
+  EditorMemo->ReadOnly = (OnFileChanged == NULL);
+
   TPoint ACaretPos = EditorMemo->CaretPos;
 
   if (ACaretPos.x != FCaretPos.x || ACaretPos.y != FCaretPos.y)
@@ -1072,9 +1078,20 @@ void __fastcall TEditorForm::UpdateControls()
     StatusBar->Panels->Items[2]->Caption = Character;
   }
   StatusBar->Panels->Items[3]->Caption = FMTLOAD(EDITOR_ENCODING_STATUS, (FEncodingName));
-  StatusBar->Panels->Items[4]->Caption =
-    (FSaving ? LoadStr(EDITOR_SAVING) :
-      (IsFileModified() ? LoadStr(EDITOR_MODIFIED) : UnicodeString(L"")));
+  UnicodeString Status;
+  if (EditorMemo->ReadOnly)
+  {
+    Status = LoadStr(EDITOR_READONLY);
+  }
+  else if (FSaving)
+  {
+    Status = LoadStr(EDITOR_SAVING);
+  }
+  else if (IsFileModified())
+  {
+    Status = LoadStr(EDITOR_MODIFIED);
+  }
+  StatusBar->Panels->Items[4]->Caption = Status;
 
   EditorActions->UpdateAction(SaveAction);
 }

+ 4 - 4
source/forms/NonVisual.cpp

@@ -195,7 +195,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
     ScpExplorer->Terminal->IsCapable[fcLocking])
   // local selected operation
   UPD(LocalCopyAction, HasTerminal && EnabledLocalSelectedOperation)
-  UPD(LocalCopyQueueAction, HasTerminal && EnabledLocalSelectedOperation)
+  UPD(LocalCopyQueueAction, HasTerminal && EnabledLocalSelectedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
   UPD(LocalCopyNonQueueAction, HasTerminal && EnabledLocalSelectedOperation)
   UPD(LocalRenameAction, EnabledLocalSelectedOperation)
   UPD(LocalEditAction, EnabledLocalSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
@@ -207,12 +207,12 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
   UPD(LocalNewFileAction, !WinConfiguration->DisableOpenEdit)
   // local focused operation
   UPD(LocalCopyFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
-  UPD(LocalCopyFocusedQueueAction, HasTerminal && EnabledLocalFocusedOperation)
+  UPD(LocalCopyFocusedQueueAction, HasTerminal && EnabledLocalFocusedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
   UPD(LocalCopyFocusedNonQueueAction, HasTerminal && EnabledLocalFocusedOperation)
   UPD(LocalMoveFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
   // remote selected operation
   UPD(RemoteCopyAction, EnabledRemoteSelectedOperation)
-  UPD(RemoteCopyQueueAction, EnabledRemoteSelectedOperation)
+  UPD(RemoteCopyQueueAction, EnabledRemoteSelectedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
   UPD(RemoteCopyNonQueueAction, EnabledRemoteSelectedOperation)
   UPD(RemoteRenameAction, EnabledRemoteSelectedOperation &&
     ScpExplorer->Terminal->IsCapable[fcRename])
@@ -225,7 +225,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
   UPD(RemoteAddEditLinkAction2, ScpExplorer->CanAddEditLink(osRemote))
   // remote focused operation
   UPD(RemoteCopyFocusedAction, EnabledRemoteFocusedOperation)
-  UPD(RemoteCopyFocusedQueueAction, EnabledRemoteFocusedOperation)
+  UPD(RemoteCopyFocusedQueueAction, EnabledRemoteFocusedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
   UPD(RemoteCopyFocusedNonQueueAction, EnabledRemoteFocusedOperation)
   UPD(RemoteMoveFocusedAction, EnabledRemoteFocusedOperation)
   UPD(RemoteMoveToFocusedAction, EnabledFocusedOperation &&

+ 1 - 0
source/resource/TextsWin.h

@@ -608,6 +608,7 @@
 #define LOGIN_PUBLIC_KEY_TITLE  6008
 #define LOGIN_PUBLIC_KEY_FILTER 6009
 #define SYNCHRONIZE_CHECKLIST_CAPTION 6010
+#define EDITOR_READONLY         6011
 
 // 2xxx is reserved for TextsFileZilla.h
 

+ 1 - 0
source/resource/TextsWin1.rc

@@ -611,6 +611,7 @@ BEGIN
         LOGIN_PUBLIC_KEY_TITLE, "Select key to install into server"
         LOGIN_PUBLIC_KEY_FILTER, "PuTTY Private Key Files (*.ppk)|*.ppk|All Private Key Files (*.ppk;*.pem;*.key;id_*)|*.ppk;*.pem;*.key;id_*|All Files (*.*)|*.*"
         SYNCHRONIZE_CHECKLIST_CAPTION, "Synchronization checklist"
+        EDITOR_READONLY, "Read-only"
 
         WIN_VARIABLE_STRINGS, "WIN_VARIABLE"
         WINSCP_COPYRIGHT, "Copyright © 2000-2018 Martin Prikryl"