CA-362354: Account for non-exe files when saving SSH client path

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2022-01-07 16:45:00 +00:00 committed by Danilo Del Busso
parent dc282732d3
commit 34876461fc
3 changed files with 33 additions and 14 deletions

View File

@ -60,32 +60,39 @@ namespace XenAdmin.Dialogs.OptionsPages
public bool IsValidToSave()
{
if (radioButtonPutty.Checked && !File.Exists(textBoxPutty.Text))
{
return false;
}
if (radioButtonOpenSsh.Checked && !File.Exists(textBoxOpenSsh.Text))
{
return false;
}
return true;
return !(radioButtonPutty.Checked && !File.Exists(textBoxPutty.Text) ||
radioButtonOpenSsh.Checked && !File.Exists(textBoxOpenSsh.Text) ||
textBoxPutty.Text.Length > 0 && !textBoxPutty.Text.ToLower().EndsWith(".exe") ||
textBoxOpenSsh.Text.Length > 0 && !textBoxOpenSsh.Text.ToLower().EndsWith(".exe"));
}
public void ShowValidationMessages()
{
if (radioButtonPutty.Checked && !File.Exists(textBoxPutty.Text))
var message = string.Empty;
if (textBoxPutty.Text.Length > 0 && !textBoxPutty.Text.ToLower().EndsWith(".exe"))
{
_tooltipControl = textBoxPutty;
message = Messages.EXTERNAl_TOOLS_FILE_INVALID;
}
else if (textBoxOpenSsh.Text.Length > 0 && !textBoxOpenSsh.Text.ToLower().EndsWith(".exe"))
{
_tooltipControl = textBoxOpenSsh;
message = Messages.EXTERNAl_TOOLS_FILE_INVALID;
}
else if (radioButtonPutty.Checked && !File.Exists(textBoxPutty.Text))
{
_tooltipControl = textBoxPutty;
message = Messages.FILE_NOT_FOUND;
}
else if (radioButtonOpenSsh.Checked && !File.Exists(textBoxOpenSsh.Text))
{
_tooltipControl = textBoxOpenSsh;
message = Messages.FILE_NOT_FOUND;
}
if (_tooltipControl != null)
{
tooltipValidation.ToolTipTitle = Messages.FILE_NOT_FOUND;
tooltipValidation.ToolTipTitle = message;
HelpersGUI.ShowBalloonMessage(_tooltipControl, tooltipValidation);
}
}

View File

@ -19,7 +19,7 @@ namespace XenAdmin {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Messages {
@ -16870,6 +16870,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to File is invalid. Please select an .exe file..
/// </summary>
public static string EXTERNAl_TOOLS_FILE_INVALID {
get {
return ResourceManager.GetString("EXTERNAl_TOOLS_FILE_INVALID", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Select SSH console.
/// </summary>

View File

@ -5899,6 +5899,9 @@ Would you like to eject these ISOs before continuing?</value>
<data name="EXTERNAL_TOOLS_DETAILS" xml:space="preserve">
<value>Manage external tools</value>
</data>
<data name="EXTERNAl_TOOLS_FILE_INVALID" xml:space="preserve">
<value>File is invalid. Please select an .exe file.</value>
</data>
<data name="EXTERNAL_TOOLS_OPEN_FILE_TITLE" xml:space="preserve">
<value>Select SSH console</value>
</data>
@ -14761,4 +14764,4 @@ Any disk in your VM's DVD drive will be ejected when installing {1}.</value>
<data name="YOU_ARE_HERE" xml:space="preserve">
<value>You are here</value>
</data>
</root>
</root>