Browse Source

/rawtransfersettings command-line switch to configure any transfer settings using a raw format as in an INI file + Using the switch when starting "Keep remote directory up to date" in a new window

Source commit: 2cb6ac32ec67b89eede9d4b2e45f91ddbc3f8061
Martin Prikryl 7 years ago
parent
commit
2dca484bb8

+ 2 - 2
source/forms/CustomScpExplorer.cpp

@@ -5442,12 +5442,12 @@ void __fastcall TCustomScpExplorerForm::SynchronizeInNewWindow(
 
   std::unique_ptr<TStringList> Options(new TStringList());
   std::unique_ptr<TOptionsStorage> OptionsStorage(new TOptionsStorage(Options.get(), true));
-  GUIConfiguration->SaveCopyParam(OptionsStorage.get(), CopyParams, &Defaults);
+  CopyParams->Save(OptionsStorage.get(), &Defaults);
 
   if (Options->Count > 0)
   {
     AdditionalParams +=
-      FORMAT(L" %s%s", (TProgramParams::FormatSwitch(RAW_CONFIG_SWITCH), StringsToParams(Options.get())));
+      FORMAT(L" %s%s", (TProgramParams::FormatSwitch(RAWTRANSFERSETTINGS_SWITCH), StringsToParams(Options.get())));
   }
 
   ExecuteNewInstance(SessionName, AdditionalParams);

+ 1 - 0
source/resource/TextsWin.h

@@ -288,6 +288,7 @@
 #define ENCRYPT_KEY_GENERATED   1579
 #define LOCATION_PROFILE_HINT   1580
 #define USAGE_INFO              1581
+#define USAGE_RAWTRANSFERSETTINGS 1582
 
 #define WIN_FORMS_STRINGS       1600
 #define COPY_FILE               1605

+ 3 - 2
source/resource/TextsWin1.rc

@@ -263,7 +263,7 @@ BEGIN
         USAGE_COMMAND, "Executes list of script commands."
         USAGE_PARAMETER, "Passes list of parameters to script."
         USAGE_INI, "Path to configuration INI-file."
-        USAGE_RAWCONFIG, "Configures any settings using raw format as in an INI file."
+        USAGE_RAWCONFIG, "Configures any settings using a raw format as in an INI file."
         USAGE_BATCHSETTINGS, "Updates settings of sites matching a mask using a raw format as in an INI file."
         USAGE_LOG, "Turns on session logging to file."
         USAGE_LOGLEVEL, "Logging level (0..2), add * to enable password logging."
@@ -276,7 +276,7 @@ BEGIN
         USAGE_IMPLICIT, "Implicit TLS/SSL (FTP protocol only)."
         USAGE_EXPLICIT, "Explicit TLS/SSL (FTP protocol only)."
         USAGE_TIMEOUT, "Server response timeout."
-        USAGE_RAWSETTINGS, "Configures any session settings using raw format as in an INI file."
+        USAGE_RAWSETTINGS, "Configures any session settings using a raw format as in an INI file."
         USAGE_UPDATE, "Queries application homepage for updates."
         USAGE_HELP, "Prints this usage."
         USAGE_KEYGEN, "Converts private key to .ppk format or edits key. Use %s to specify output file. Use %s to change or set passphrase. Use %s to change or set comment."
@@ -293,6 +293,7 @@ BEGIN
         ENCRYPT_KEY_GENERATED, "**Encryption key was generated.**\n\nYou should safely backup the generated encryption key. If you lose it, you won't be able to read your files."
         LOCATION_PROFILE_HINT, "Open location profile \"%s\".|Local directory:\n  %s|Remote directory:\n  %s"
         USAGE_INFO, "Prints list of supported ciphers and algorithms."
+        USAGE_RAWTRANSFERSETTINGS, "Configures any transfer settings using a raw format as in an INI file."
 
         WIN_FORMS_STRINGS, "WIN_FORMS_STRINGS"
         COPY_FILE, "%s file '%s' to %s:"

+ 2 - 0
source/windows/ConsoleRunner.cpp

@@ -2208,6 +2208,7 @@ void __fastcall Usage(TConsole * Console)
   PrintUsageSyntax(Console,
     FORMAT(L"[/%s=<inifile>]", (LowerCase(INI_SWITCH))));
   PrintUsageSyntax(Console, FORMAT(L"[/%s config1=value1 config2=value2 ...]", (LowerCase(RAW_CONFIG_SWITCH))));
+  PrintUsageSyntax(Console, FORMAT(L"[/%s setting1=value1 setting2=value2 ...]", (LowerCase(RAWTRANSFERSETTINGS_SWITCH))));
   PrintUsageSyntax(Console, L"/batchsettings <site_mask> setting1=value1 setting2=value2 ...");
   PrintUsageSyntax(Console, FORMAT(L"/%s keyfile [/%s=output] [/%s] [/%s=comment]",
     (LowerCase(KEYGEN_SWITCH), LowerCase(KEYGEN_OUTPUT_SWITCH), LowerCase(KEYGEN_CHANGE_PASSPHRASE_SWITCH), LowerCase(KEYGEN_COMMENT_SWITCH))));
@@ -2252,6 +2253,7 @@ void __fastcall Usage(TConsole * Console)
   RegisterSwitch(SwitchesUsage, L"/xmlgroups", USAGE_XMLGROUPS);
   RegisterSwitch(SwitchesUsage, TProgramParams::FormatSwitch(INI_SWITCH) + L"=", USAGE_INI);
   RegisterSwitch(SwitchesUsage, TProgramParams::FormatSwitch(RAW_CONFIG_SWITCH), USAGE_RAWCONFIG);
+  RegisterSwitch(SwitchesUsage, TProgramParams::FormatSwitch(RAWTRANSFERSETTINGS_SWITCH), USAGE_RAWTRANSFERSETTINGS);
   RegisterSwitch(SwitchesUsage, L"/batchsettings", USAGE_BATCHSETTINGS);
   UnicodeString KeyGenDesc =
     FMTLOAD(USAGE_KEYGEN, (

+ 5 - 10
source/windows/GUIConfiguration.cpp

@@ -665,16 +665,6 @@ bool __fastcall TGUIConfiguration::DoSaveCopyParam(THierarchicalStorage * Storag
   return Result;
 }
 //---------------------------------------------------------------------------
-bool __fastcall TGUIConfiguration::SaveCopyParam(THierarchicalStorage * Storage, const TCopyParamType * CopyParam, const TCopyParamType * Defaults)
-{
-  bool Result = DoSaveCopyParam(Storage, CopyParam, Defaults);
-  if (Result)
-  {
-    Storage->CloseSubKey();
-  }
-  return Result;
-}
-//---------------------------------------------------------------------------
 void __fastcall TGUIConfiguration::SaveData(THierarchicalStorage * Storage, bool All)
 {
   TConfiguration::SaveData(Storage, All);
@@ -735,6 +725,11 @@ bool __fastcall TGUIConfiguration::LoadCopyParam(THierarchicalStorage * Storage,
   return Result;
 }
 //---------------------------------------------------------------------------
+void __fastcall TGUIConfiguration::LoadDefaultCopyParam(THierarchicalStorage * Storage)
+{
+  FDefaultCopyParam.Load(Storage);
+}
+//---------------------------------------------------------------------------
 void __fastcall TGUIConfiguration::LoadData(THierarchicalStorage * Storage)
 {
   TConfiguration::LoadData(Storage);

+ 1 - 1
source/windows/GUIConfiguration.h

@@ -240,8 +240,8 @@ public:
   virtual __fastcall ~TGUIConfiguration();
   virtual void __fastcall Default();
   virtual void __fastcall UpdateStaticUsage();
-  bool __fastcall SaveCopyParam(THierarchicalStorage * Storage, const TCopyParamType * CopyParam, const TCopyParamType * Defaults);
   bool __fastcall LoadCopyParam(THierarchicalStorage * Storage, TCopyParamType * CopyParam);
+  void __fastcall LoadDefaultCopyParam(THierarchicalStorage * Storage);
 
   HANDLE __fastcall ChangeToDefaultResourceModule();
   HANDLE __fastcall ChangeResourceModule(HANDLE Instance);

+ 7 - 0
source/windows/WinMain.cpp

@@ -760,6 +760,13 @@ int __fastcall Execute()
     }
   }
 
+  std::unique_ptr<TStrings> RawSettings(new TStringList());
+  if (Params->FindSwitch(RAWTRANSFERSETTINGS_SWITCH, RawSettings.get()))
+  {
+    std::unique_ptr<TOptionsStorage> OptionsStorage(new TOptionsStorage(RawSettings.get(), false));
+    GUIConfiguration->LoadDefaultCopyParam(OptionsStorage.get());
+  }
+
   TConsoleMode Mode = cmNone;
   if (Params->FindSwitch(L"help") || Params->FindSwitch(L"h") || Params->FindSwitch(L"?"))
   {