Selaa lähdekoodia

Warning when a server hostkey is not known when generating a code. + Not including the /console switch in a generated command-line. + Separate display for an executable path, when generating a command-line.

Source commit: c5d567b484faa13254ac912dd59b6c835b760ac3
Martin Prikryl 9 vuotta sitten
vanhempi
sitoutus
ca5efae8d6

+ 26 - 4
source/forms/GenerateUrl.cpp

@@ -70,11 +70,14 @@ void __fastcall TGenerateUrlDialog::UpdateControls()
 {
   if (!FChanging)
   {
+    UnicodeString ExeName = Application->ExeName;
     Caption = LoadStr(IsFileUrl() ? GENERATE_URL_FILE_TITLE : GENERATE_URL_SESSION_TITLE);
 
     ScriptSheet->TabVisible = !IsFileUrl();
     AssemblySheet->TabVisible = !IsFileUrl();
 
+    bool HostKeyUnknown = FData->UsesSsh && FData->HostKey.IsEmpty();
+
     UnicodeString ResultGroupCaption;
     if (OptionsPageControl->ActivePage == UrlSheet)
     {
@@ -82,11 +85,31 @@ void __fastcall TGenerateUrlDialog::UpdateControls()
     }
     else if (OptionsPageControl->ActivePage == ScriptSheet)
     {
-      ResultGroupCaption = ScriptFormatCombo->Items->Strings[ScriptFormatCombo->ItemIndex];
+      UnicodeString ScriptDescription;
+      if (ScriptFormatCombo->ItemIndex == sfCommandLine)
+      {
+        ResultGroupCaption = LoadStr(GENERATE_URL_COMMANDLINE_LABEL);
+        ScriptDescription = FMTLOAD(GENERATE_URL_COMMANDLINE_DESC, (FORMAT("\"%s\"", (ExeName)))) + L"\n";
+      }
+      else
+      {
+        ResultGroupCaption = ScriptFormatCombo->Items->Strings[ScriptFormatCombo->ItemIndex];
+      }
+      if (HostKeyUnknown)
+      {
+        ScriptDescription += LoadStr(GENERATE_URL_HOSTKEY_UNKNOWN) + L"\n";
+      }
+      ScriptDescriptionLabel->Caption = ScriptDescription;
     }
     else if (DebugAlwaysTrue(OptionsPageControl->ActivePage == AssemblySheet))
     {
       ResultGroupCaption = LoadStr(GENERATE_URL_CODE);
+      UnicodeString AssemblyDescription;
+      if (HostKeyUnknown)
+      {
+        AssemblyDescription += LoadStr(GENERATE_URL_HOSTKEY_UNKNOWN) + L"\n";
+      }
+      AssemblyDescriptionLabel->Caption = AssemblyDescription;
     }
     ResultGroup->Caption = ResultGroupCaption;
 
@@ -123,7 +146,6 @@ void __fastcall TGenerateUrlDialog::UpdateControls()
     }
     else if (OptionsPageControl->ActivePage == ScriptSheet)
     {
-      UnicodeString ExeName = Application->ExeName;
       UnicodeString BaseExeName = ExtractFileBaseName(ExeName);
       UnicodeString OpenCommand = FData->GenerateOpenCommandArgs();
       UnicodeString CommandPlaceholder1 = FMTLOAD(GENERATE_URL_COMMAND, (1));
@@ -173,8 +195,8 @@ void __fastcall TGenerateUrlDialog::UpdateControls()
       {
         Result =
           FORMAT(
-            L"\"%s\" /console /log=%s.log /ini=nul /command \"open %s\" \"%s\" \"%s\" \"exit\"",
-            (ExeName, BaseExeName, EscapeParam(OpenCommand), CommandPlaceholder1, CommandPlaceholder2));
+            L"/log=%s.log /ini=nul /command \"open %s\" \"%s\" \"%s\" \"exit\"",
+            (BaseExeName, EscapeParam(OpenCommand), CommandPlaceholder1, CommandPlaceholder2));
         WordWrap = true;
         FixedWidth = false;
       }

+ 18 - 0
source/forms/GenerateUrl.dfm

@@ -103,6 +103,15 @@ object GenerateUrlDialog: TGenerateUrlDialog
         Caption = '&Format:'
         FocusControl = ScriptFormatCombo
       end
+      object ScriptDescriptionLabel: TLabel
+        Left = 11
+        Top = 32
+        Width = 446
+        Height = 42
+        AutoSize = False
+        Caption = 'ScriptDescriptionLabel'
+        WordWrap = True
+      end
       object ScriptFormatCombo: TComboBox
         Left = 112
         Top = 5
@@ -128,6 +137,15 @@ object GenerateUrlDialog: TGenerateUrlDialog
         Caption = '&Language:'
         FocusControl = AssemblyLanguageCombo
       end
+      object AssemblyDescriptionLabel: TLabel
+        Left = 11
+        Top = 32
+        Width = 446
+        Height = 42
+        AutoSize = False
+        Caption = 'AssemblyDescriptionLabel'
+        WordWrap = True
+      end
       object AssemblyLanguageCombo: TComboBox
         Left = 112
         Top = 5

+ 2 - 0
source/forms/GenerateUrl.h

@@ -32,6 +32,8 @@ __published:
   TComboBox *ScriptFormatCombo;
   TLabel *Label1;
   TComboBox *AssemblyLanguageCombo;
+  TLabel *ScriptDescriptionLabel;
+  TLabel *AssemblyDescriptionLabel;
   void __fastcall ControlChange(TObject *Sender);
   void __fastcall ClipboardButtonClick(TObject *Sender);
   void __fastcall HelpButtonClick(TObject *Sender);

+ 3 - 0
source/resource/TextsWin.h

@@ -553,6 +553,9 @@
 #define TIPS_MESSAGE            1955
 #define TIPS_TITLE              1956
 #define CUSTOM_COMMAND_HINT_LONG 1957
+#define GENERATE_URL_COMMANDLINE_LABEL 1958
+#define GENERATE_URL_COMMANDLINE_DESC 1959
+#define GENERATE_URL_HOSTKEY_UNKNOWN 1960
 
 // 2xxx is reserved for TextsFileZilla.h
 

+ 3 - 0
source/resource/TextsWin1.rc

@@ -556,6 +556,9 @@ BEGIN
         TIPS_MESSAGE, "Tip %d of %d"
         TIPS_TITLE, "Tips"
         CUSTOM_COMMAND_HINT_LONG, "Execute custom command '%s' as '%s'"
+        GENERATE_URL_COMMANDLINE_LABEL, "Command-line arguments"
+        GENERATE_URL_COMMANDLINE_DESC, "Command-line arguments for %s"
+        GENERATE_URL_HOSTKEY_UNKNOWN, "A server host key is not known. Please connect at least once, before generating the code."
 
         WIN_VARIABLE_STRINGS, "WIN_VARIABLE"
         WINSCP_COPYRIGHT, "Copyright © 2000-2016 Martin Prikryl"