mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
resharper code reformat (to allow standard code style going forward)
This commit is contained in:
@@ -21,7 +21,8 @@ namespace mRemoteNG.App
|
||||
{
|
||||
if (Settings.Default.OverrideFIPSCheck)
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "OverrideFIPSCheck is set. Will skip check...", true);
|
||||
messageCollector.AddMessage(MessageClass.InformationMsg, "OverrideFIPSCheck is set. Will skip check...",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,7 +35,12 @@ namespace mRemoteNG.App
|
||||
//About to pop up a message, let's not block it...
|
||||
FrmSplashScreen.getInstance().Close();
|
||||
|
||||
var ShouldIStayOrShouldIGo = CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected, errorText, "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.OkCancel, ESysIcons.Warning, ESysIcons.Warning);
|
||||
var ShouldIStayOrShouldIGo = CTaskDialog.MessageBox(Application.ProductName,
|
||||
Language.strCompatibilityProblemDetected, errorText, "",
|
||||
"",
|
||||
Language.strCheckboxDoNotShowThisMessageAgain,
|
||||
ETaskDialogButtons.OkCancel, ESysIcons.Warning,
|
||||
ESysIcons.Warning);
|
||||
if (CTaskDialog.VerificationChecked && ShouldIStayOrShouldIGo == DialogResult.OK)
|
||||
{
|
||||
messageCollector.AddMessage(MessageClass.ErrorMsg, "User requests that FIPS check be overridden", true);
|
||||
@@ -58,7 +64,8 @@ namespace mRemoteNG.App
|
||||
|
||||
private static bool FipsPolicyEnabledForServer2008AndNewer()
|
||||
{
|
||||
var regKey = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy");
|
||||
var regKey =
|
||||
Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Lsa\\FIPSAlgorithmPolicy");
|
||||
var fipsPolicy = regKey?.GetValue("Enabled");
|
||||
if (fipsPolicy == null) return false;
|
||||
fipsPolicy = Convert.ToInt32(fipsPolicy);
|
||||
@@ -83,9 +90,14 @@ namespace mRemoteNG.App
|
||||
}
|
||||
|
||||
if (proccesses.Length <= 0) return;
|
||||
CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected, string.Format(Language.strCompatibilityLenovoAutoScrollUtilityDetected, Application.ProductName), "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.Ok, ESysIcons.Warning, ESysIcons.Warning);
|
||||
CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected,
|
||||
string.Format(Language.strCompatibilityLenovoAutoScrollUtilityDetected,
|
||||
Application.ProductName), "",
|
||||
"", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.Ok,
|
||||
ESysIcons.Warning,
|
||||
ESysIcons.Warning);
|
||||
if (CTaskDialog.VerificationChecked)
|
||||
Settings.Default.CompatibilityWarnLenovoAutoScrollUtility = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,92 +17,101 @@ using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Export
|
||||
{
|
||||
public static void ExportToFile(ConnectionInfo selectedNode, ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var saveFilter = new SaveFilter();
|
||||
|
||||
using (var exportForm = new ExportForm())
|
||||
{
|
||||
if (selectedNode?.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode as ContainerInfo;
|
||||
else if (selectedNode?.GetTreeNodeType() == TreeNodeType.Connection)
|
||||
{
|
||||
if (selectedNode.Parent.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode.Parent;
|
||||
exportForm.SelectedConnection = selectedNode;
|
||||
}
|
||||
|
||||
if (exportForm.ShowDialog(FrmMain.Default) != DialogResult.OK)
|
||||
return;
|
||||
public static class Export
|
||||
{
|
||||
public static void ExportToFile(ConnectionInfo selectedNode, ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var saveFilter = new SaveFilter();
|
||||
|
||||
ConnectionInfo exportTarget;
|
||||
switch (exportForm.Scope)
|
||||
{
|
||||
case ExportForm.ExportScope.SelectedFolder:
|
||||
exportTarget = exportForm.SelectedFolder;
|
||||
break;
|
||||
using (var exportForm = new ExportForm())
|
||||
{
|
||||
if (selectedNode?.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode as ContainerInfo;
|
||||
else if (selectedNode?.GetTreeNodeType() == TreeNodeType.Connection)
|
||||
{
|
||||
if (selectedNode.Parent.GetTreeNodeType() == TreeNodeType.Container)
|
||||
exportForm.SelectedFolder = selectedNode.Parent;
|
||||
exportForm.SelectedConnection = selectedNode;
|
||||
}
|
||||
|
||||
if (exportForm.ShowDialog(FrmMain.Default) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
ConnectionInfo exportTarget;
|
||||
switch (exportForm.Scope)
|
||||
{
|
||||
case ExportForm.ExportScope.SelectedFolder:
|
||||
exportTarget = exportForm.SelectedFolder;
|
||||
break;
|
||||
case ExportForm.ExportScope.SelectedConnection:
|
||||
exportTarget = exportForm.SelectedConnection;
|
||||
break;
|
||||
default:
|
||||
exportTarget = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
saveFilter.SaveUsername = exportForm.IncludeUsername;
|
||||
saveFilter.SavePassword = exportForm.IncludePassword;
|
||||
saveFilter.SaveDomain = exportForm.IncludeDomain;
|
||||
saveFilter.SaveInheritance = exportForm.IncludeInheritance;
|
||||
saveFilter.SaveCredentialId = exportForm.IncludeAssignedCredential;
|
||||
|
||||
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveFilter, exportTarget);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
exportTarget = exportForm.SelectedConnection;
|
||||
break;
|
||||
default:
|
||||
exportTarget = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
saveFilter.SaveUsername = exportForm.IncludeUsername;
|
||||
saveFilter.SavePassword = exportForm.IncludePassword;
|
||||
saveFilter.SaveDomain = exportForm.IncludeDomain;
|
||||
saveFilter.SaveInheritance = exportForm.IncludeInheritance;
|
||||
saveFilter.SaveCredentialId = exportForm.IncludeAssignedCredential;
|
||||
|
||||
SaveExportFile(exportForm.FileName, exportForm.SaveFormat, saveFilter, exportTarget);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("App.Export.ExportToFile() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExportFile(string fileName, SaveFormat saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISerializer<ConnectionInfo, string> serializer;
|
||||
switch (saveFormat)
|
||||
{
|
||||
case SaveFormat.mRXML:
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExportFile(string fileName,
|
||||
SaveFormat saveFormat,
|
||||
SaveFilter saveFilter,
|
||||
ConnectionInfo exportTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISerializer<ConnectionInfo, string> serializer;
|
||||
switch (saveFormat)
|
||||
{
|
||||
case SaveFormat.mRXML:
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var rootNode = exportTarget.GetRootParent() as RootNodeInfo;
|
||||
var rootNode = exportTarget.GetRootParent() as RootNodeInfo;
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
rootNode?.PasswordString.ConvertToSecureString() ?? new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString(),
|
||||
saveFilter);
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
|
||||
break;
|
||||
case SaveFormat.mRCSV:
|
||||
serializer = new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialProviderCatalog);
|
||||
cryptographyProvider,
|
||||
rootNode?.PasswordString
|
||||
.ConvertToSecureString() ??
|
||||
new RootNodeInfo(RootNodeType
|
||||
.Connection)
|
||||
.PasswordString
|
||||
.ConvertToSecureString(),
|
||||
saveFilter);
|
||||
serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
|
||||
}
|
||||
var serializedData = serializer.Serialize(exportTarget);
|
||||
var fileDataProvider = new FileDataProvider(fileName);
|
||||
case SaveFormat.mRCSV:
|
||||
serializer =
|
||||
new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialProviderCatalog);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null);
|
||||
}
|
||||
|
||||
var serializedData = serializer.Serialize(exportTarget);
|
||||
var fileDataProvider = new FileDataProvider(fileName);
|
||||
fileDataProvider.Save(serializedData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,10 @@ namespace mRemoteNG.App
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName), Language.strImportFileFailedMainInstruction,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
|
||||
MessageBox.Show(string.Format(Language.strImportFileFailedContent, fileName),
|
||||
Language.strImportFileFailedMainInstruction,
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
|
||||
MessageBoxDefaultButton.Button1);
|
||||
Runtime.MessageCollector.AddExceptionMessage("Unable to import file.", ex);
|
||||
}
|
||||
}
|
||||
@@ -59,7 +61,9 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromActiveDirectory(string ldapPath, ContainerInfo importDestinationContainer, bool importSubOu)
|
||||
public static void ImportFromActiveDirectory(string ldapPath,
|
||||
ContainerInfo importDestinationContainer,
|
||||
bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -72,7 +76,9 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts, ProtocolType protocol, ContainerInfo importDestinationContainer)
|
||||
public static void ImportFromPortScan(IEnumerable<ScanHost> hosts,
|
||||
ProtocolType protocol,
|
||||
ContainerInfo importDestinationContainer)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class ConnectionsFileInfo
|
||||
public static class ConnectionsFileInfo
|
||||
{
|
||||
public static readonly string DefaultConnectionsPath = SettingsFileInfo.SettingsPath;
|
||||
public static readonly string DefaultConnectionsFile = "confCons.xml";
|
||||
|
||||
@@ -9,45 +9,53 @@ using static System.Environment;
|
||||
|
||||
namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class GeneralAppInfo
|
||||
{
|
||||
public const string UrlHome = "https://www.mremoteng.org/";
|
||||
public const string UrlDonate = "https://mremoteng.org/contribute/";
|
||||
public const string UrlForum = "https://www.reddit.com/r/mRemoteNG/";
|
||||
public const string UrlBugs = "https://bugs.mremoteng.org/";
|
||||
public static string ApplicationVersion = Application.ProductVersion;
|
||||
public static class GeneralAppInfo
|
||||
{
|
||||
public const string UrlHome = "https://www.mremoteng.org/";
|
||||
public const string UrlDonate = "https://mremoteng.org/contribute/";
|
||||
public const string UrlForum = "https://www.reddit.com/r/mRemoteNG/";
|
||||
public const string UrlBugs = "https://bugs.mremoteng.org/";
|
||||
public static string ApplicationVersion = Application.ProductVersion;
|
||||
public static readonly string ProductName = Application.ProductName;
|
||||
public static readonly string Copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false)).Copyright;
|
||||
|
||||
public static readonly string Copyright =
|
||||
((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
|
||||
typeof(AssemblyCopyrightAttribute), false))
|
||||
.Copyright;
|
||||
|
||||
public static readonly string HomePath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
//public static string ReportingFilePath = "";
|
||||
public static readonly string PuttyPath = HomePath + "\\PuTTYNG.exe";
|
||||
|
||||
//public static string ReportingFilePath = "";
|
||||
public static readonly string PuttyPath = HomePath + "\\PuTTYNG.exe";
|
||||
|
||||
public static string UserAgent
|
||||
{
|
||||
get
|
||||
{
|
||||
var details = new List<string>
|
||||
{
|
||||
"compatible",
|
||||
OSVersion.Platform == PlatformID.Win32NT
|
||||
? $"Windows NT {OSVersion.Version.Major}.{OSVersion.Version.Minor}"
|
||||
: OSVersion.VersionString
|
||||
};
|
||||
if (Is64BitProcess)
|
||||
{
|
||||
details.Add("WOW64");
|
||||
}
|
||||
details.Add(Thread.CurrentThread.CurrentUICulture.Name);
|
||||
details.Add($".NET CLR {Environment.Version}");
|
||||
var detailsString = string.Join("; ", details.ToArray());
|
||||
{
|
||||
get
|
||||
{
|
||||
var details = new List<string>
|
||||
{
|
||||
"compatible",
|
||||
OSVersion.Platform == PlatformID.Win32NT
|
||||
? $"Windows NT {OSVersion.Version.Major}.{OSVersion.Version.Minor}"
|
||||
: OSVersion.VersionString
|
||||
};
|
||||
if (Is64BitProcess)
|
||||
{
|
||||
details.Add("WOW64");
|
||||
}
|
||||
|
||||
return $"Mozilla/5.0 ({detailsString}) {ProductName}/{ApplicationVersion}";
|
||||
}
|
||||
}
|
||||
details.Add(Thread.CurrentThread.CurrentUICulture.Name);
|
||||
details.Add($".NET CLR {Environment.Version}");
|
||||
var detailsString = string.Join("; ", details.ToArray());
|
||||
|
||||
public static Version GetApplicationVersion()
|
||||
{
|
||||
return $"Mozilla/5.0 ({detailsString}) {ProductName}/{ApplicationVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
public static Version GetApplicationVersion()
|
||||
{
|
||||
System.Version.TryParse(ApplicationVersion, out var v);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,22 @@ namespace mRemoteNG.App.Info
|
||||
{
|
||||
public static class SettingsFileInfo
|
||||
{
|
||||
private static readonly string ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConnectionInfo))?.Location);
|
||||
private static readonly string ExePath =
|
||||
Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConnectionInfo))?.Location);
|
||||
|
||||
public static string SettingsPath =>
|
||||
Runtime.IsPortableEdition
|
||||
? ExePath
|
||||
: Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Application.ProductName;
|
||||
|
||||
public static string SettingsPath => Runtime.IsPortableEdition ? ExePath : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Application.ProductName;
|
||||
public static string LayoutFileName { get; } = "pnlLayout.xml";
|
||||
public static string ExtAppsFilesName { get; } = "extApps.xml";
|
||||
public static string ThemesFileName { get; } = "Themes.xml";
|
||||
public static string ThemeFolder { get; } = SettingsPath != null ? Path.Combine(SettingsPath, "Themes") : String.Empty;
|
||||
public static string InstalledThemeFolder { get; } = ExePath != null ? Path.Combine(ExePath, "Themes") : String.Empty;
|
||||
|
||||
public static string ThemeFolder { get; } =
|
||||
SettingsPath != null ? Path.Combine(SettingsPath, "Themes") : String.Empty;
|
||||
|
||||
public static string InstalledThemeFolder { get; } =
|
||||
ExePath != null ? Path.Combine(ExePath, "Themes") : String.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace mRemoteNG.App.Info
|
||||
@@ -27,7 +28,9 @@ namespace mRemoteNG.App.Info
|
||||
|
||||
private static string GetChannelFileName(string channel)
|
||||
{
|
||||
return Runtime.IsPortableEdition ? GetChannelFileNamePortableEdition(channel) : GetChannelFileNameNormalEdition(channel);
|
||||
return Runtime.IsPortableEdition
|
||||
? GetChannelFileNamePortableEdition(channel)
|
||||
: GetChannelFileNameNormalEdition(channel);
|
||||
}
|
||||
|
||||
private static string GetChannelFileNameNormalEdition(string channel)
|
||||
@@ -62,7 +65,8 @@ namespace mRemoteNG.App.Info
|
||||
|
||||
private static Uri GetUpdateTxtUri(string channel)
|
||||
{
|
||||
return new Uri(new Uri(Settings.Default.UpdateAddress), new Uri(GetChannelFileName(channel), UriKind.Relative));
|
||||
return new Uri(new Uri(Settings.Default.UpdateAddress),
|
||||
new Uri(GetChannelFileName(channel), UriKind.Relative));
|
||||
}
|
||||
|
||||
private static bool IsValidChannel(string s)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
public ConnectionIconLoader(string folderPath)
|
||||
{
|
||||
if(string.IsNullOrEmpty(folderPath))
|
||||
if (string.IsNullOrEmpty(folderPath))
|
||||
throw new ArgumentException($"{nameof(folderPath)} must be a valid folder path.");
|
||||
|
||||
_path = folderPath;
|
||||
|
||||
@@ -3,14 +3,16 @@ using mRemoteNG.Config.Connections;
|
||||
|
||||
namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
public class CredsAndConsSetup
|
||||
public class CredsAndConsSetup
|
||||
{
|
||||
public void LoadCredsAndCons()
|
||||
{
|
||||
new SaveConnectionsOnEdit(Runtime.ConnectionsService);
|
||||
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation && !File.Exists(Runtime.ConnectionsService.GetStartupConnectionFileName()))
|
||||
Runtime.ConnectionsService.NewConnectionsFile(Runtime.ConnectionsService.GetStartupConnectionFileName());
|
||||
if (Settings.Default.FirstStart && !Settings.Default.LoadConsFromCustomLocation &&
|
||||
!File.Exists(Runtime.ConnectionsService.GetStartupConnectionFileName()))
|
||||
Runtime.ConnectionsService.NewConnectionsFile(Runtime.ConnectionsService
|
||||
.GetStartupConnectionFileName());
|
||||
|
||||
Runtime.LoadConnections();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
public class MessageCollectorSetup
|
||||
{
|
||||
public static void SetupMessageCollector(MessageCollector messageCollector, IList<IMessageWriter> messageWriterList)
|
||||
public static void SetupMessageCollector(MessageCollector messageCollector,
|
||||
IList<IMessageWriter> messageWriterList)
|
||||
{
|
||||
messageCollector.CollectionChanged += (o, args) =>
|
||||
{
|
||||
@@ -37,34 +38,37 @@ namespace mRemoteNG.App.Initialization
|
||||
private static IMessageWriter BuildTextLogMessageWriter()
|
||||
{
|
||||
return new MessageTypeFilterDecorator(
|
||||
new LogMessageTypeFilteringOptions(),
|
||||
new TextLogMessageWriter(Logger.Instance)
|
||||
);
|
||||
new LogMessageTypeFilteringOptions(),
|
||||
new TextLogMessageWriter(Logger.Instance)
|
||||
);
|
||||
}
|
||||
|
||||
private static IMessageWriter BuildNotificationPanelMessageWriter()
|
||||
{
|
||||
|
||||
return new OnlyLogMessageFilter(
|
||||
new MessageTypeFilterDecorator(
|
||||
new NotificationPanelMessageFilteringOptions(),
|
||||
new MessageFocusDecorator(
|
||||
Windows.ErrorsForm,
|
||||
new NotificationPanelSwitchOnMessageFilteringOptions(),
|
||||
new NotificationPanelMessageWriter(Windows.ErrorsForm)
|
||||
)
|
||||
)
|
||||
);
|
||||
new MessageTypeFilterDecorator(
|
||||
new
|
||||
NotificationPanelMessageFilteringOptions(),
|
||||
new MessageFocusDecorator(
|
||||
Windows.ErrorsForm,
|
||||
new
|
||||
NotificationPanelSwitchOnMessageFilteringOptions(),
|
||||
new
|
||||
NotificationPanelMessageWriter(Windows
|
||||
.ErrorsForm)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static IMessageWriter BuildPopupMessageWriter()
|
||||
{
|
||||
return new OnlyLogMessageFilter(
|
||||
new MessageTypeFilterDecorator(
|
||||
new PopupMessageFilteringOptions(),
|
||||
new PopupMessageWriter()
|
||||
)
|
||||
);
|
||||
new MessageTypeFilterDecorator(
|
||||
new PopupMessageFilteringOptions(),
|
||||
new PopupMessageWriter()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,8 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary=True").Get())
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem WHERE Primary=True")
|
||||
.Get())
|
||||
{
|
||||
var managementObject = (ManagementObject)o;
|
||||
osVersion = Convert.ToString(managementObject.GetPropertyValue("Caption")).Trim();
|
||||
@@ -54,6 +55,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Error retrieving operating system information from WMI.", ex);
|
||||
}
|
||||
|
||||
var osData = string.Join(" ", osVersion, servicePack);
|
||||
return osData;
|
||||
}
|
||||
@@ -65,6 +67,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
servicePack = $"Service Pack {servicePackNumber}";
|
||||
}
|
||||
|
||||
return servicePack;
|
||||
}
|
||||
|
||||
@@ -73,7 +76,8 @@ namespace mRemoteNG.App.Initialization
|
||||
var architecture = string.Empty;
|
||||
try
|
||||
{
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_Processor WHERE DeviceID=\'CPU0\'").Get())
|
||||
foreach (var o in new ManagementObjectSearcher("SELECT * FROM Win32_Processor WHERE DeviceID=\'CPU0\'")
|
||||
.Get())
|
||||
{
|
||||
var managementObject = (ManagementObject)o;
|
||||
var addressWidth = Convert.ToInt32(managementObject.GetPropertyValue("AddressWidth"));
|
||||
@@ -84,6 +88,7 @@ namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Error retrieving operating system address width from WMI.", ex);
|
||||
}
|
||||
|
||||
return architecture;
|
||||
}
|
||||
|
||||
@@ -110,7 +115,8 @@ namespace mRemoteNG.App.Initialization
|
||||
|
||||
private void LogCultureData()
|
||||
{
|
||||
var data = $"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
|
||||
var data =
|
||||
$"System Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}";
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, data, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ using System.Windows.Forms;
|
||||
using log4net;
|
||||
using log4net.Appender;
|
||||
using log4net.Config;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public class Logger
|
||||
public class Logger
|
||||
{
|
||||
public static readonly Logger Instance = new Logger();
|
||||
|
||||
@@ -42,6 +43,7 @@ namespace mRemoteNG.App
|
||||
fileAppender.File = path;
|
||||
fileAppender.ActivateOptions();
|
||||
}
|
||||
|
||||
Log = LogManager.GetLogger("Logger");
|
||||
}
|
||||
|
||||
@@ -56,7 +58,8 @@ namespace mRemoteNG.App
|
||||
|
||||
private static string GetLogPathNormalEdition()
|
||||
{
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Application.ProductName);
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
Application.ProductName);
|
||||
}
|
||||
|
||||
private static string GetLogPathPortableEdition()
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace mRemoteNG.App
|
||||
public static class NativeMethods
|
||||
{
|
||||
#region Functions
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool AppendMenu(IntPtr hMenu, int uFlags, IntPtr uIDNewItem, string lpNewItem);
|
||||
|
||||
@@ -19,7 +20,10 @@ namespace mRemoteNG.App
|
||||
internal static extern IntPtr CreatePopupMenu();
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
internal static extern IntPtr FindWindowEx(IntPtr parentHandle,
|
||||
IntPtr childAfter,
|
||||
string lclassName,
|
||||
string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr GetForegroundWindow();
|
||||
@@ -28,7 +32,11 @@ namespace mRemoteNG.App
|
||||
internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool InsertMenu(IntPtr hMenu, int uPosition, int uFlags, IntPtr uIDNewItem, string lpNewItem);
|
||||
internal static extern bool InsertMenu(IntPtr hMenu,
|
||||
int uPosition,
|
||||
int uFlags,
|
||||
IntPtr uIDNewItem,
|
||||
string lpNewItem);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern int IsIconic(IntPtr hWnd);
|
||||
@@ -55,7 +63,10 @@ namespace mRemoteNG.App
|
||||
internal static extern IntPtr SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, string lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr SendMessage([In] IntPtr hWnd, [In] uint msg, [Out] StringBuilder wParam, [In] IntPtr lParam);
|
||||
internal static extern IntPtr SendMessage([In] IntPtr hWnd,
|
||||
[In] uint msg,
|
||||
[Out] StringBuilder wParam,
|
||||
[In] IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
|
||||
@@ -64,7 +75,11 @@ namespace mRemoteNG.App
|
||||
internal static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern bool SetMenuItemBitmaps(IntPtr hMenu, int uPosition, int uFlags, IntPtr hBitmapUnchecked, IntPtr hBitmapChecked);
|
||||
internal static extern bool SetMenuItemBitmaps(IntPtr hMenu,
|
||||
int uPosition,
|
||||
int uFlags,
|
||||
IntPtr hBitmapUnchecked,
|
||||
IntPtr hBitmapChecked);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
internal static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
|
||||
@@ -93,9 +108,11 @@ namespace mRemoteNG.App
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
internal static extern bool CloseHandle(IntPtr handle);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Structures
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct WINDOWPOS
|
||||
{
|
||||
@@ -131,9 +148,11 @@ namespace mRemoteNG.App
|
||||
public long right;
|
||||
public long bottom;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
public static int MAKELONG(int wLow, int wHigh)
|
||||
{
|
||||
return wLow | wHigh << 16;
|
||||
@@ -163,28 +182,37 @@ namespace mRemoteNG.App
|
||||
{
|
||||
return HIWORD(value.ToInt32());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
|
||||
public const int TRUE = 1;
|
||||
|
||||
#region GetWindowLong
|
||||
|
||||
public const int GWL_STYLE = (-16);
|
||||
|
||||
#endregion
|
||||
|
||||
#region AppendMenu / ModifyMenu / DeleteMenu / RemoveMenu
|
||||
|
||||
public const int MF_BYCOMMAND = 0x0;
|
||||
public const int MF_BYPOSITION = 0x400;
|
||||
public const int MF_STRING = 0x0;
|
||||
public const int MF_POPUP = 0x10;
|
||||
public const int MF_SEPARATOR = 0x800;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WM_LBUTTONDOWN / WM_LBUTTONUP
|
||||
|
||||
public const int MK_LBUTTON = 0x1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowWindow
|
||||
|
||||
public const uint SW_HIDE = 0;
|
||||
public const uint SW_SHOWNORMAL = 1;
|
||||
public const uint SW_SHOWMINIMIZED = 2;
|
||||
@@ -196,9 +224,11 @@ namespace mRemoteNG.App
|
||||
public const uint SW_SHOWMINNOACTIVE = 7;
|
||||
public const uint SW_SHOWNA = 8;
|
||||
public const uint SW_RESTORE = 9;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetWindowPos / WM_WINDOWPOSCHANGING / WM_WINDOWPOSCHANGED
|
||||
|
||||
/// <summary>
|
||||
/// Retains the current size (ignores the cx and cy parameters).
|
||||
/// </summary>
|
||||
@@ -283,15 +313,19 @@ namespace mRemoteNG.App
|
||||
///
|
||||
/// </summary>
|
||||
public const int SWP_STATECHANGED = 0x8000;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Placement Flags (WPF)
|
||||
|
||||
public const uint WPF_SETMINPOSITION = 0x1;
|
||||
public const uint WPF_RESTORETOMAXIMIZED = 0x2;
|
||||
public const uint WPF_ASYNCWINDOWPLACEMENT = 0x4;
|
||||
|
||||
#endregion
|
||||
|
||||
#region WM_ACTIVATE
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -309,9 +343,11 @@ namespace mRemoteNG.App
|
||||
/// windows use different input queues, the message is sent asynchronously, so the window is activated immediately.
|
||||
/// </summary>
|
||||
public const int WA_CLICKACTIVE = 0x2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Messages
|
||||
|
||||
/// <summary>
|
||||
/// Sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible.
|
||||
/// </summary>
|
||||
@@ -466,29 +502,38 @@ namespace mRemoteNG.App
|
||||
/// Sent to the first window in the clipboard viewer chain when a window is being removed from the chain.
|
||||
/// </summary>
|
||||
public const int WM_CHANGECBCHAIN = 0x30D;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Styles
|
||||
|
||||
public const int WS_MAXIMIZE = 0x1000000;
|
||||
public const int WS_VISIBLE = 0x10000000;
|
||||
public const int WS_CHILD = 0x40000000;
|
||||
public const int WS_EX_MDICHILD = 0x40;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual Key Codes
|
||||
|
||||
public const int VK_CONTROL = 0x11;
|
||||
public const int VK_C = 0x67;
|
||||
|
||||
#endregion
|
||||
|
||||
#region EM
|
||||
|
||||
public const uint ECM_FIRST = 0x1500;
|
||||
public const uint EM_SETCUEBANNER = ECM_FIRST + 1;
|
||||
public const uint EM_GETCUEBANNER = ECM_FIRST + 2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region LB
|
||||
|
||||
public const int LB_ERR = -1;
|
||||
public const int LB_SELECTSTRING = 0x18C;
|
||||
|
||||
#endregion
|
||||
|
||||
#region TCM
|
||||
|
||||
@@ -67,9 +67,12 @@ namespace mRemoteNG.App
|
||||
var currentProcess = Process.GetCurrentProcess();
|
||||
foreach (var enumeratedProcess in Process.GetProcessesByName(currentProcess.ProcessName))
|
||||
{
|
||||
if (enumeratedProcess.Id != currentProcess.Id && enumeratedProcess.MainModule.FileName == currentProcess.MainModule.FileName && enumeratedProcess.MainWindowHandle != IntPtr.Zero)
|
||||
if (enumeratedProcess.Id != currentProcess.Id &&
|
||||
enumeratedProcess.MainModule.FileName == currentProcess.MainModule.FileName &&
|
||||
enumeratedProcess.MainWindowHandle != IntPtr.Zero)
|
||||
windowHandle = enumeratedProcess.MainWindowHandle;
|
||||
}
|
||||
|
||||
return windowHandle;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,17 @@ namespace mRemoteNG.App
|
||||
public static MessageCollector MessageCollector { get; } = new MessageCollector();
|
||||
public static NotificationAreaIcon NotificationAreaIcon { get; set; }
|
||||
public static ExternalToolsService ExternalToolsService { get; } = new ExternalToolsService();
|
||||
public static SecureString EncryptionKey { get; set; } = new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
|
||||
public static SecureString EncryptionKey { get; set; } =
|
||||
new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
|
||||
public static ICredentialRepositoryList CredentialProviderCatalog { get; } = new CredentialRepositoryList();
|
||||
public static ConnectionsService ConnectionsService { get; } = new ConnectionsService(PuttySessionsManager.Instance);
|
||||
|
||||
public static ConnectionsService ConnectionsService { get; } =
|
||||
new ConnectionsService(PuttySessionsManager.Instance);
|
||||
|
||||
#region Connections Loading/Saving
|
||||
|
||||
public static void LoadConnectionsAsync()
|
||||
{
|
||||
var t = new Thread(LoadConnectionsBGd);
|
||||
@@ -106,8 +112,14 @@ namespace mRemoteNG.App
|
||||
if (Settings.Default.UseSQLServer)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex);
|
||||
var commandButtons = string.Join("|", Language.strCommandTryAgain, Language.strCommandOpenConnectionFile, string.Format(Language.strCommandExitProgram, Application.ProductName));
|
||||
CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed, Language.strLoadFromSqlFailedContent, MiscTools.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, ESysIcons.Error, ESysIcons.Error);
|
||||
var commandButtons = string.Join("|", Language.strCommandTryAgain,
|
||||
Language.strCommandOpenConnectionFile,
|
||||
string.Format(Language.strCommandExitProgram,
|
||||
Application.ProductName));
|
||||
CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed,
|
||||
Language.strLoadFromSqlFailedContent,
|
||||
MiscTools.GetExceptionMessageRecursive(ex), "", "",
|
||||
commandButtons, false, ESysIcons.Error, ESysIcons.Error);
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
case 0:
|
||||
@@ -122,9 +134,13 @@ namespace mRemoteNG.App
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ex is FileNotFoundException && !withDialog)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), ex, MessageClass.InformationMsg);
|
||||
MessageCollector.AddExceptionMessage(
|
||||
string.Format(Language.strConnectionsFileCouldNotBeLoadedNew,
|
||||
connectionFileName), ex,
|
||||
MessageClass.InformationMsg);
|
||||
|
||||
string[] commandButtons =
|
||||
{
|
||||
@@ -140,13 +156,13 @@ namespace mRemoteNG.App
|
||||
try
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
GeneralAppInfo.ProductName,
|
||||
Language.ConnectionFileNotFound,
|
||||
"", "", "", "", "",
|
||||
string.Join(" | ", commandButtons),
|
||||
ETaskDialogButtons.None,
|
||||
ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
|
||||
switch (CTaskDialog.CommandButtonResult)
|
||||
{
|
||||
@@ -167,17 +183,24 @@ namespace mRemoteNG.App
|
||||
Application.Exit();
|
||||
answered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), exc, MessageClass.InformationMsg);
|
||||
MessageCollector.AddExceptionMessage(
|
||||
string
|
||||
.Format(Language.strConnectionsFileCouldNotBeLoadedNew,
|
||||
connectionFileName), exc,
|
||||
MessageClass.InformationMsg);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MessageCollector.AddExceptionStackTrace(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionFileName), ex);
|
||||
MessageCollector.AddExceptionStackTrace(
|
||||
string.Format(Language.strConnectionsFileCouldNotBeLoaded,
|
||||
connectionFileName), ex);
|
||||
if (connectionFileName != ConnectionsService.GetStartupConnectionFileName())
|
||||
{
|
||||
LoadConnections(withDialog);
|
||||
@@ -185,12 +208,16 @@ namespace mRemoteNG.App
|
||||
else
|
||||
{
|
||||
MessageBox.Show(FrmMain.Default,
|
||||
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, ConnectionsService.GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
|
||||
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine,
|
||||
Application.ProductName,
|
||||
ConnectionsService.GetStartupConnectionFileName(),
|
||||
MiscTools.GetExceptionMessageRecursive(ex)),
|
||||
@"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
@@ -25,7 +26,10 @@ namespace mRemoteNG.App
|
||||
ProgramRoot.CloseSingletonInstanceMutex();
|
||||
}
|
||||
|
||||
public static void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
public static void Cleanup(Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
FrmMain frmMain)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -58,9 +62,13 @@ namespace mRemoteNG.App
|
||||
Runtime.ConnectionsService.SaveConnections();
|
||||
}
|
||||
|
||||
private static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
private static void SaveSettings(Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
FrmMain frmMain)
|
||||
{
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip, frmMain);
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip,
|
||||
frmMain);
|
||||
}
|
||||
|
||||
private static void UnregisterBrowsers()
|
||||
|
||||
@@ -37,15 +37,16 @@ namespace mRemoteNG.App
|
||||
|
||||
public void InitializeProgram(MessageCollector messageCollector)
|
||||
{
|
||||
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " +
|
||||
Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
var startupLogger = new StartupDataLogger(messageCollector);
|
||||
startupLogger.LogStartupData();
|
||||
CompatibilityChecker.CheckCompatibility(messageCollector);
|
||||
ParseCommandLineArgs(messageCollector);
|
||||
IeBrowserEmulation.Register();
|
||||
_connectionIconLoader.GetConnectionIcons();
|
||||
DefaultConnectionInfo.Instance.LoadFrom(Settings.Default, a=>"ConDefault"+a);
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, a=>"InhDefault"+a);
|
||||
DefaultConnectionInfo.Instance.LoadFrom(Settings.Default, a => "ConDefault" + a);
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(Settings.Default, a => "InhDefault" + a);
|
||||
}
|
||||
|
||||
private static void ParseCommandLineArgs(MessageCollector messageCollector)
|
||||
@@ -59,7 +60,8 @@ namespace mRemoteNG.App
|
||||
messageCollector.AddMessage(MessageClass.DebugMsg, "Determining if we need a database syncronizer");
|
||||
if (!Settings.Default.UseSQLServer) return;
|
||||
messageCollector.AddMessage(MessageClass.DebugMsg, "Creating database syncronizer");
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer = new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker());
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer =
|
||||
new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker());
|
||||
Runtime.ConnectionsService.RemoteConnectionsSyncronizer.Enable();
|
||||
}
|
||||
|
||||
@@ -74,7 +76,12 @@ namespace mRemoteNG.App
|
||||
return;
|
||||
}
|
||||
|
||||
var nextUpdateCheck = Convert.ToDateTime(Settings.Default.CheckForUpdatesLastCheck.Add(TimeSpan.FromDays(Convert.ToDouble(Settings.Default.CheckForUpdatesFrequencyDays))));
|
||||
var nextUpdateCheck =
|
||||
Convert.ToDateTime(Settings.Default.CheckForUpdatesLastCheck.Add(
|
||||
TimeSpan
|
||||
.FromDays(Convert.ToDouble(Settings
|
||||
.Default
|
||||
.CheckForUpdatesFrequencyDays))));
|
||||
if (!Settings.Default.UpdatePending && DateTime.UtcNow < nextUpdateCheck)
|
||||
{
|
||||
return;
|
||||
@@ -100,6 +107,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Error != null)
|
||||
{
|
||||
throw e.Error;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class SupportedCultures : Dictionary<string, string>
|
||||
{
|
||||
{
|
||||
private static SupportedCultures _Instance;
|
||||
|
||||
private static SupportedCultures SingletonInstance
|
||||
@@ -19,7 +19,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
|
||||
|
||||
private SupportedCultures()
|
||||
private SupportedCultures()
|
||||
{
|
||||
foreach (var CultureName in Settings.Default.SupportedUICultures.Split(','))
|
||||
{
|
||||
@@ -30,7 +30,8 @@ namespace mRemoteNG.App
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Print($"An exception occurred while adding the culture {CultureName} to the list of supported cultures. {ex.StackTrace}");
|
||||
Debug.Print(
|
||||
$"An exception occurred while adding the culture {CultureName} to the list of supported cultures. {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,51 +42,52 @@ namespace mRemoteNG.App
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static bool IsNameSupported(string CultureName)
|
||||
{
|
||||
return SingletonInstance.ContainsKey(CultureName);
|
||||
}
|
||||
|
||||
public static bool IsNativeNameSupported(string CultureNativeName)
|
||||
{
|
||||
return SingletonInstance.ContainsValue(CultureNativeName);
|
||||
}
|
||||
|
||||
public static string get_CultureName(string CultureNativeName)
|
||||
{
|
||||
var Names = new string[SingletonInstance.Count + 1];
|
||||
var NativeNames = new string[SingletonInstance.Count + 1];
|
||||
public static bool IsNameSupported(string CultureName)
|
||||
{
|
||||
return SingletonInstance.ContainsKey(CultureName);
|
||||
}
|
||||
|
||||
public static bool IsNativeNameSupported(string CultureNativeName)
|
||||
{
|
||||
return SingletonInstance.ContainsValue(CultureNativeName);
|
||||
}
|
||||
|
||||
public static string get_CultureName(string CultureNativeName)
|
||||
{
|
||||
var Names = new string[SingletonInstance.Count + 1];
|
||||
var NativeNames = new string[SingletonInstance.Count + 1];
|
||||
|
||||
SingletonInstance.Keys.CopyTo(Names, 0);
|
||||
SingletonInstance.Values.CopyTo(NativeNames, 0);
|
||||
|
||||
for (var Index = 0; Index <= SingletonInstance.Count; Index++)
|
||||
{
|
||||
if (NativeNames[Index] == CultureNativeName)
|
||||
{
|
||||
return Names[Index];
|
||||
}
|
||||
}
|
||||
|
||||
throw (new KeyNotFoundException());
|
||||
}
|
||||
|
||||
public static string get_CultureNativeName(string CultureName)
|
||||
{
|
||||
return SingletonInstance[CultureName];
|
||||
}
|
||||
|
||||
|
||||
for (var Index = 0; Index <= SingletonInstance.Count; Index++)
|
||||
{
|
||||
if (NativeNames[Index] == CultureNativeName)
|
||||
{
|
||||
return Names[Index];
|
||||
}
|
||||
}
|
||||
|
||||
throw (new KeyNotFoundException());
|
||||
}
|
||||
|
||||
public static string get_CultureNativeName(string CultureName)
|
||||
{
|
||||
return SingletonInstance[CultureName];
|
||||
}
|
||||
|
||||
public static List<string> CultureNativeNames
|
||||
{
|
||||
get
|
||||
{
|
||||
var ValueList = new List<string>();
|
||||
foreach (var Value in SingletonInstance.Values)
|
||||
{
|
||||
ValueList.Add(Value);
|
||||
}
|
||||
return ValueList;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
get
|
||||
{
|
||||
var ValueList = new List<string>();
|
||||
foreach (var Value in SingletonInstance.Values)
|
||||
{
|
||||
ValueList.Add(Value);
|
||||
}
|
||||
|
||||
return ValueList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ using System.Security.Cryptography;
|
||||
#if !PORTABLE
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
#else
|
||||
#else
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endif
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
@@ -66,7 +67,12 @@ namespace mRemoteNG.App.Update
|
||||
SetProxySettings(shouldWeUseProxy, proxyAddress, port, useAuthentication, username, password);
|
||||
}
|
||||
|
||||
public void SetProxySettings(bool useProxy, string address, int port, bool useAuthentication, string username, string password)
|
||||
public void SetProxySettings(bool useProxy,
|
||||
string address,
|
||||
int port,
|
||||
bool useAuthentication,
|
||||
string username,
|
||||
string password)
|
||||
{
|
||||
if (useProxy && !string.IsNullOrEmpty(address))
|
||||
{
|
||||
@@ -107,7 +113,8 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (CurrentUpdateInfo == null || !CurrentUpdateInfo.IsValid)
|
||||
{
|
||||
throw new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().");
|
||||
throw new InvalidOperationException(
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling GetChangeLogAsync().");
|
||||
}
|
||||
|
||||
if (IsGetChangeLogRunning)
|
||||
@@ -131,27 +138,29 @@ namespace mRemoteNG.App.Update
|
||||
if (CurrentUpdateInfo == null || !CurrentUpdateInfo.IsValid)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().");
|
||||
"CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().");
|
||||
}
|
||||
#if !PORTABLE
|
||||
CurrentUpdateInfo.UpdateFilePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "msi"));
|
||||
CurrentUpdateInfo.UpdateFilePath =
|
||||
Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "msi"));
|
||||
#else
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||
FileName = CurrentUpdateInfo.FileName,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
CurrentUpdateInfo.UpdateFilePath = sfd.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress, CurrentUpdateInfo.UpdateFilePath);
|
||||
DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress,
|
||||
CurrentUpdateInfo.UpdateFilePath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -191,7 +200,9 @@ namespace mRemoteNG.App.Update
|
||||
}
|
||||
|
||||
private static DownloadStringCompletedEventArgs NewDownloadStringCompletedEventArgs(string result,
|
||||
Exception exception, bool cancelled, object userToken)
|
||||
Exception exception,
|
||||
bool cancelled,
|
||||
object userToken)
|
||||
{
|
||||
var type = typeof(DownloadStringCompletedEventArgs);
|
||||
const BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
@@ -201,7 +212,7 @@ namespace mRemoteNG.App.Update
|
||||
|
||||
if (constructor == null)
|
||||
return null;
|
||||
return (DownloadStringCompletedEventArgs) constructor.Invoke(arguments);
|
||||
return (DownloadStringCompletedEventArgs)constructor.Invoke(arguments);
|
||||
}
|
||||
|
||||
private DownloadStringCompletedEventArgs DownloadString(Uri address)
|
||||
@@ -326,11 +337,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetUpdateInfoCompletedEventEvent, value);
|
||||
GetUpdateInfoCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(GetUpdateInfoCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetUpdateInfoCompletedEventEvent, value);
|
||||
GetUpdateInfoCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(GetUpdateInfoCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,11 +353,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetChangeLogCompletedEventEvent, value);
|
||||
GetChangeLogCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(GetChangeLogCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetChangeLogCompletedEventEvent, value);
|
||||
GetChangeLogCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(GetChangeLogCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,11 +369,15 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Combine(DownloadUpdateProgressChangedEventEvent, value);
|
||||
DownloadUpdateProgressChangedEventEvent =
|
||||
(DownloadProgressChangedEventHandler)Delegate.Combine(DownloadUpdateProgressChangedEventEvent,
|
||||
value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Remove(DownloadUpdateProgressChangedEventEvent, value);
|
||||
DownloadUpdateProgressChangedEventEvent =
|
||||
(DownloadProgressChangedEventHandler)Delegate.Remove(DownloadUpdateProgressChangedEventEvent,
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,11 +387,13 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
add
|
||||
{
|
||||
DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(DownloadUpdateCompletedEventEvent, value);
|
||||
DownloadUpdateCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Combine(DownloadUpdateCompletedEventEvent, value);
|
||||
}
|
||||
remove
|
||||
{
|
||||
DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(DownloadUpdateCompletedEventEvent, value);
|
||||
DownloadUpdateCompletedEventEvent =
|
||||
(AsyncCompletedEventHandler)Delegate.Remove(DownloadUpdateCompletedEventEvent, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ namespace mRemoteNG.App.Update
|
||||
public class UpdateFile
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Local
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
public Dictionary<string, string> Items { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
public Dictionary<string, string> Items { get; } =
|
||||
new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public UpdateFile(string content)
|
||||
{
|
||||
FromString(content);
|
||||
@@ -24,8 +28,8 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (string.IsNullOrEmpty(content)) return;
|
||||
|
||||
char[] keyValueSeparators = { ':', '=' };
|
||||
char[] commentCharacters = { '#', ';', '\'' };
|
||||
char[] keyValueSeparators = {':', '='};
|
||||
char[] commentCharacters = {'#', ';', '\''};
|
||||
|
||||
// no separators means no valid update data...
|
||||
if (content.Trim().IndexOfAny(keyValueSeparators) == -1) return;
|
||||
@@ -47,7 +51,7 @@ namespace mRemoteNG.App.Update
|
||||
continue;
|
||||
|
||||
// make sure we have valid data in both parts before adding to the collection. If either part is empty, then it's not valid data.
|
||||
if(string.IsNullOrEmpty(parts[0].Trim()) || string.IsNullOrEmpty(parts[1].Trim()))
|
||||
if (string.IsNullOrEmpty(parts[0].Trim()) || string.IsNullOrEmpty(parts[1].Trim()))
|
||||
continue;
|
||||
|
||||
Items.Add(parts[0].Trim(), parts[1].Trim());
|
||||
@@ -83,13 +87,14 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
var value = GetString("dURL");
|
||||
var sv = value.Split('/');
|
||||
return sv[sv.Length-1];
|
||||
return sv[sv.Length - 1];
|
||||
}
|
||||
|
||||
public string GetChecksum(string key = "Checksum")
|
||||
{
|
||||
return GetString(key).Replace(" ", "").ToUpperInvariant();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||
|
||||
namespace mRemoteNG.App.Update
|
||||
@@ -43,6 +44,7 @@ namespace mRemoteNG.App.Update
|
||||
newInfo.Checksum = updateFile.GetChecksum();
|
||||
newInfo.IsValid = newInfo.CheckIfValid();
|
||||
}
|
||||
|
||||
return newInfo;
|
||||
}
|
||||
|
||||
@@ -50,11 +52,11 @@ namespace mRemoteNG.App.Update
|
||||
{
|
||||
if (string.IsNullOrEmpty(Version.ToString()))
|
||||
return false;
|
||||
if(string.IsNullOrEmpty(DownloadAddress.AbsoluteUri))
|
||||
if (string.IsNullOrEmpty(DownloadAddress.AbsoluteUri))
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(ChangeLogAddress.AbsoluteUri))
|
||||
return false;
|
||||
#if false
|
||||
#if false
|
||||
if (string.IsNullOrEmpty(ImageAddress.AbsoluteUri))
|
||||
return false;
|
||||
if (string.IsNullOrEmpty(ImageLinkAddress.AbsoluteUri))
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace mRemoteNG.App
|
||||
internal static SSHTransferWindow SshtransferForm { get; private set; } = new SSHTransferWindow();
|
||||
|
||||
|
||||
|
||||
public static void Show(WindowType windowType)
|
||||
{
|
||||
try
|
||||
@@ -55,6 +54,7 @@ namespace mRemoteNG.App
|
||||
{
|
||||
optionsForm.ShowDialog(dockPanel);
|
||||
}
|
||||
|
||||
break;
|
||||
case WindowType.SSHTransfer:
|
||||
if (SshtransferForm == null || SshtransferForm.IsDisposed)
|
||||
@@ -90,7 +90,8 @@ namespace mRemoteNG.App
|
||||
_ultravncscForm.Show(dockPanel);
|
||||
break;
|
||||
case WindowType.ComponentsCheck:
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Showing ComponentsCheck window", true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Showing ComponentsCheck window", true);
|
||||
if (_componentscheckForm == null || _componentscheckForm.IsDisposed)
|
||||
_componentscheckForm = new ComponentsCheckWindow();
|
||||
_componentscheckForm.Show(dockPanel);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
namespace mRemoteNG.Config
|
||||
{
|
||||
public enum ConfirmCloseEnum
|
||||
{
|
||||
Unspecified = 0,
|
||||
Never = 1,
|
||||
Exit = 2,
|
||||
Multiple = 3,
|
||||
All = 4
|
||||
}
|
||||
public enum ConfirmCloseEnum
|
||||
{
|
||||
Unspecified = 0,
|
||||
Never = 1,
|
||||
Exit = 2,
|
||||
Multiple = 3,
|
||||
All = 4
|
||||
}
|
||||
}
|
||||
@@ -36,10 +36,11 @@ namespace mRemoteNG.Config.Connections
|
||||
/// </summary>
|
||||
public string NewSourcePath { get; }
|
||||
|
||||
public ConnectionsLoadedEventArgs(
|
||||
Optional<ConnectionTreeModel> previousTreeModelModel, ConnectionTreeModel newTreeModelModel,
|
||||
bool previousSourceWasDatabase, bool newSourceIsDatabase,
|
||||
string newSourcePath)
|
||||
public ConnectionsLoadedEventArgs(Optional<ConnectionTreeModel> previousTreeModelModel,
|
||||
ConnectionTreeModel newTreeModelModel,
|
||||
bool previousSourceWasDatabase,
|
||||
bool newSourceIsDatabase,
|
||||
string newSourcePath)
|
||||
{
|
||||
if (previousTreeModelModel == null)
|
||||
throw new ArgumentNullException(nameof(previousTreeModelModel));
|
||||
@@ -55,4 +56,4 @@ namespace mRemoteNG.Config.Connections
|
||||
NewSourcePath = newSourcePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,10 @@ namespace mRemoteNG.Config.Connections
|
||||
public bool UsingDatabase { get; }
|
||||
public string ConnectionFileName { get; }
|
||||
|
||||
public ConnectionsSavedEventArgs(ConnectionTreeModel modelThatWasSaved, bool previouslyUsingDatabase, bool usingDatabase, string connectionFileName)
|
||||
public ConnectionsSavedEventArgs(ConnectionTreeModel modelThatWasSaved,
|
||||
bool previouslyUsingDatabase,
|
||||
bool usingDatabase,
|
||||
string connectionFileName)
|
||||
{
|
||||
if (modelThatWasSaved == null)
|
||||
throw new ArgumentNullException(nameof(modelThatWasSaved));
|
||||
@@ -21,4 +24,4 @@ namespace mRemoteNG.Config.Connections
|
||||
ConnectionFileName = connectionFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,11 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
public void Save(ConnectionTreeModel connectionTreeModel, string propertyNameTrigger = "")
|
||||
{
|
||||
var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat(_saveFilter, Runtime.CredentialProviderCatalog);
|
||||
var csvConnectionsSerializer =
|
||||
new CsvConnectionsSerializerMremotengFormat(_saveFilter, Runtime.CredentialProviderCatalog);
|
||||
var dataProvider = new FileDataProvider(_connectionFileName);
|
||||
var csvContent = csvConnectionsSerializer.Serialize(connectionTreeModel);
|
||||
dataProvider.Save(csvContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@ using mRemoteNG.Config.DatabaseConnectors;
|
||||
|
||||
namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
public delegate void ConnectionsUpdateAvailableEventHandler(object sender, ConnectionsUpdateAvailableEventArgs args);
|
||||
public delegate void
|
||||
ConnectionsUpdateAvailableEventHandler(object sender, ConnectionsUpdateAvailableEventArgs args);
|
||||
|
||||
public class ConnectionsUpdateAvailableEventArgs : EventArgs
|
||||
{
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
_updateChecker.UpdateCheckStarted += OnUpdateCheckStarted;
|
||||
_updateChecker.UpdateCheckFinished += OnUpdateCheckFinished;
|
||||
_updateChecker.ConnectionsUpdateAvailable += (sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
|
||||
_updateChecker.ConnectionsUpdateAvailable +=
|
||||
(sender, args) => ConnectionsUpdateAvailable?.Invoke(sender, args);
|
||||
_updateTimer.Elapsed += (sender, args) => _updateChecker.IsUpdateAvailableAsync();
|
||||
ConnectionsUpdateAvailable += Load;
|
||||
}
|
||||
@@ -81,6 +82,7 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool itIsSafeToAlsoFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToAlsoFreeManagedObjects) return;
|
||||
|
||||
@@ -48,9 +48,11 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
_sqlConnector.Connect();
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Unable to connect to Sql DB to check for updates." + Environment.NewLine + e.Message, true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Unable to connect to Sql DB to check for updates." +
|
||||
Environment.NewLine + e.Message, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +65,9 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
private bool CheckIfIAmTheLastOneUpdated(DateTime lastUpdateInDb)
|
||||
{
|
||||
DateTime lastSqlUpdateWithoutMilliseconds = new DateTime(LastUpdateTime.Ticks - (LastUpdateTime.Ticks % TimeSpan.TicksPerSecond), LastUpdateTime.Kind);
|
||||
DateTime lastSqlUpdateWithoutMilliseconds =
|
||||
new DateTime(LastUpdateTime.Ticks - (LastUpdateTime.Ticks % TimeSpan.TicksPerSecond),
|
||||
LastUpdateTime.Kind);
|
||||
return lastUpdateInDb == lastSqlUpdateWithoutMilliseconds;
|
||||
}
|
||||
|
||||
@@ -80,20 +84,25 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Error executing Sql query to get updates from the DB." + Environment.NewLine + ex.Message, true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Error executing Sql query to get updates from the DB." +
|
||||
Environment.NewLine + ex.Message, true);
|
||||
}
|
||||
|
||||
_lastDatabaseUpdateTime = lastUpdateInDb;
|
||||
return lastUpdateInDb;
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler UpdateCheckStarted;
|
||||
|
||||
private void RaiseUpdateCheckStartedEvent()
|
||||
{
|
||||
UpdateCheckStarted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event UpdateCheckFinishedEventHandler UpdateCheckFinished;
|
||||
|
||||
private void RaiseUpdateCheckFinishedEvent(bool updateAvailable)
|
||||
{
|
||||
var args = new ConnectionsUpdateCheckFinishedEventArgs {UpdateAvailable = updateAvailable};
|
||||
@@ -101,6 +110,7 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
|
||||
public event ConnectionsUpdateAvailableEventHandler ConnectionsUpdateAvailable;
|
||||
|
||||
private void RaiseConnectionsUpdateAvailableEvent()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg, "Remote connection update is available");
|
||||
|
||||
@@ -19,9 +19,11 @@ namespace mRemoteNG.Config.Connections
|
||||
connectionsService.ConnectionsLoaded += ConnectionsServiceOnConnectionsLoaded;
|
||||
}
|
||||
|
||||
private void ConnectionsServiceOnConnectionsLoaded(object sender, ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
|
||||
private void ConnectionsServiceOnConnectionsLoaded(object sender,
|
||||
ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
|
||||
{
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged += ConnectionTreeModelOnCollectionChanged;
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged +=
|
||||
ConnectionTreeModelOnCollectionChanged;
|
||||
connectionsLoadedEventArgs.NewConnectionTreeModel.PropertyChanged += ConnectionTreeModelOnPropertyChanged;
|
||||
|
||||
foreach (var oldTree in connectionsLoadedEventArgs.PreviousConnectionTreeModel)
|
||||
@@ -31,12 +33,15 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectionTreeModelOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
private void ConnectionTreeModelOnPropertyChanged(object sender,
|
||||
PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
{
|
||||
SaveConnectionOnEdit(propertyChangedEventArgs.PropertyName);
|
||||
}
|
||||
|
||||
private void ConnectionTreeModelOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
|
||||
private void ConnectionTreeModelOnCollectionChanged(object sender,
|
||||
NotifyCollectionChangedEventArgs
|
||||
notifyCollectionChangedEventArgs)
|
||||
{
|
||||
SaveConnectionOnEdit();
|
||||
}
|
||||
@@ -51,4 +56,4 @@ namespace mRemoteNG.Config.Connections
|
||||
_connectionsService.SaveConnectionsAsync(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,4 @@
|
||||
mRCSV,
|
||||
SQL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,20 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsLoader : IConnectionsLoader
|
||||
{
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> _localConnectionPropertiesDeserializer;
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>>
|
||||
_localConnectionPropertiesDeserializer;
|
||||
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public Func<Optional<SecureString>> AuthenticationRequestor { get; set; } =
|
||||
() => MiscTools.PasswordDialog("", false);
|
||||
|
||||
public SqlConnectionsLoader(
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDataProvider<string> dataProvider)
|
||||
{
|
||||
_localConnectionPropertiesDeserializer = localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
_localConnectionPropertiesDeserializer =
|
||||
localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
_dataProvider = dataProvider.ThrowIfNull(nameof(dataProvider));
|
||||
}
|
||||
|
||||
@@ -60,7 +63,9 @@ namespace mRemoteNG.Config.Connections
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var cipherText = metaData.Protected;
|
||||
var authenticator = new PasswordAuthenticator(cryptographyProvider, cipherText, AuthenticationRequestor);
|
||||
var authenticated = authenticator.Authenticate(new RootNodeInfo(RootNodeType.Connection).DefaultPassword.ConvertToSecureString());
|
||||
var authenticated =
|
||||
authenticator.Authenticate(new RootNodeInfo(RootNodeType.Connection).DefaultPassword
|
||||
.ConvertToSecureString());
|
||||
|
||||
if (authenticated)
|
||||
return authenticator.LastAuthenticatedPassword;
|
||||
@@ -74,10 +79,10 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
rootNode
|
||||
.GetRecursiveChildList()
|
||||
.Join(localConnectionProperties,
|
||||
con => con.ConstantID,
|
||||
locals => locals.ConnectionId,
|
||||
(con, locals) => new {Connection = con, LocalProperties = locals})
|
||||
.Join(localConnectionProperties,
|
||||
con => con.ConstantID,
|
||||
locals => locals.ConnectionId,
|
||||
(con, locals) => new {Connection = con, LocalProperties = locals})
|
||||
.ForEach(x =>
|
||||
{
|
||||
x.Connection.PleaseConnect = x.LocalProperties.Connected;
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace mRemoteNG.Config.Connections
|
||||
private readonly ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> _localPropertiesSerializer;
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public SqlConnectionsSaver(
|
||||
SaveFilter saveFilter,
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> localPropertieSerializer,
|
||||
IDataProvider<string> localPropertiesDataProvider)
|
||||
public SqlConnectionsSaver(SaveFilter saveFilter,
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>
|
||||
localPropertieSerializer,
|
||||
IDataProvider<string> localPropertiesDataProvider)
|
||||
{
|
||||
if (saveFilter == null)
|
||||
throw new ArgumentNullException(nameof(saveFilter));
|
||||
@@ -49,14 +49,15 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
if (PropertyIsLocalOnly(propertyNameTrigger))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
|
||||
$"Property {propertyNameTrigger} is local only. Not saving to database.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.DebugMsg,
|
||||
$"Property {propertyNameTrigger} is local only. Not saving to database.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SqlUserIsReadOnly())
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Trying to save connection tree but the SQL read only checkbox is checked, aborting!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Trying to save connection tree but the SQL read only checkbox is checked, aborting!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,7 +70,8 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
if (!databaseVersionVerifier.VerifyDatabaseVersion(metaData.ConfVersion))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strErrorConnectionListSaveFailed);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
Language.strErrorConnectionListSaveFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,22 +139,25 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
sqlQuery =
|
||||
new SqlCommand(
|
||||
"INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" +
|
||||
MiscTools.PrepareValueForDB(rootTreeNode.Name) + "\', 0, \'" + strProtected + "\'," +
|
||||
ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")",
|
||||
sqlDatabaseConnector.SqlConnection);
|
||||
"INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" +
|
||||
MiscTools.PrepareValueForDB(rootTreeNode.Name) + "\', 0, \'" + strProtected + "\'," +
|
||||
ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) +
|
||||
")",
|
||||
sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"UpdateRootNodeTable: rootTreeNode was null. Could not insert!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"UpdateRootNodeTable: rootTreeNode was null. Could not insert!");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateConnectionsTable(RootNodeInfo rootTreeNode, SqlDatabaseConnector sqlDatabaseConnector)
|
||||
{
|
||||
var cryptoProvider = new LegacyRijndaelCryptographyProvider();
|
||||
var serializer = new DataTableSerializer(_saveFilter, cryptoProvider, rootTreeNode.PasswordString.ConvertToSecureString());
|
||||
var serializer = new DataTableSerializer(_saveFilter, cryptoProvider,
|
||||
rootTreeNode.PasswordString.ConvertToSecureString());
|
||||
var dataTable = serializer.Serialize(rootTreeNode);
|
||||
var dataProvider = new SqlDataProvider(sqlDatabaseConnector);
|
||||
|
||||
@@ -165,14 +170,16 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
var sqlQuery = new SqlCommand("DELETE FROM tblUpdate", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
sqlQuery = new SqlCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + MiscTools.DBDate(DateTime.Now) + "\')", sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery = new SqlCommand(
|
||||
"INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + MiscTools.DBDate(DateTime.Now) +
|
||||
"\')",
|
||||
sqlDatabaseConnector.SqlConnection);
|
||||
sqlQuery.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
private bool SqlUserIsReadOnly()
|
||||
{
|
||||
return mRemoteNG.Settings.Default.SQLReadOnly;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,4 @@ namespace mRemoteNG.Config.Connections
|
||||
return password;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,17 @@ namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
var cryptographyProvider = new CryptoProviderFactoryFromSettings().Build();
|
||||
var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
|
||||
cryptographyProvider,
|
||||
connectionTreeModel.RootNodes.OfType<RootNodeInfo>().First().PasswordString.ConvertToSecureString(),
|
||||
_saveFilter);
|
||||
var xmlConnectionsSerializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer)
|
||||
{
|
||||
UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile
|
||||
};
|
||||
cryptographyProvider,
|
||||
connectionTreeModel
|
||||
.RootNodes.OfType<RootNodeInfo>()
|
||||
.First().PasswordString
|
||||
.ConvertToSecureString(),
|
||||
_saveFilter);
|
||||
var xmlConnectionsSerializer =
|
||||
new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer)
|
||||
{
|
||||
UseFullEncryption = mRemoteNG.Settings.Default.EncryptCompleteConnectionsFile
|
||||
};
|
||||
var xml = xmlConnectionsSerializer.Serialize(connectionTreeModel);
|
||||
|
||||
var fileDataProvider = new FileDataProviderWithRollingBackup(_connectionFileName);
|
||||
@@ -51,4 +55,4 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,14 @@ namespace mRemoteNG.Config
|
||||
private readonly IEqualityComparer<ICredentialRecord> _credentialComparer = new CredentialDomainUserComparer();
|
||||
|
||||
// maps a connectioninfo (by its id) to the credential object that was harvested
|
||||
public Dictionary<Guid, ICredentialRecord> ConnectionToCredentialMap { get; } = new Dictionary<Guid, ICredentialRecord>();
|
||||
public Dictionary<Guid, ICredentialRecord> ConnectionToCredentialMap { get; } =
|
||||
new Dictionary<Guid, ICredentialRecord>();
|
||||
|
||||
public IEnumerable<ICredentialRecord> Harvest(XDocument xDocument, SecureString decryptionKey)
|
||||
{
|
||||
if (xDocument == null)
|
||||
throw new ArgumentNullException(nameof(xDocument));
|
||||
|
||||
|
||||
var cryptoProvider = new CryptoProviderFactoryFromXml(xDocument.Root).Build();
|
||||
|
||||
foreach (var element in xDocument.Descendants("Node"))
|
||||
@@ -37,7 +38,9 @@ namespace mRemoteNG.Config
|
||||
|
||||
if (ConnectionToCredentialMap.Values.Contains(newCredential, _credentialComparer))
|
||||
{
|
||||
var existingCredential = ConnectionToCredentialMap.Values.First(record => _credentialComparer.Equals(newCredential, record));
|
||||
var existingCredential =
|
||||
ConnectionToCredentialMap.Values.First(record =>
|
||||
_credentialComparer.Equals(newCredential, record));
|
||||
ConnectionToCredentialMap.Add(connectionId, existingCredential);
|
||||
}
|
||||
else
|
||||
@@ -47,21 +50,24 @@ namespace mRemoteNG.Config
|
||||
return ConnectionToCredentialMap.Values.Distinct(_credentialComparer);
|
||||
}
|
||||
|
||||
private ICredentialRecord BuildCredential(XElement element, ICryptographyProvider cryptographyProvider, SecureString decryptionKey)
|
||||
private ICredentialRecord BuildCredential(XElement element,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
SecureString decryptionKey)
|
||||
{
|
||||
var credential = new CredentialRecord
|
||||
{
|
||||
Title = $"{element.Attribute("Username")?.Value}\\{element.Attribute("Domain")?.Value}",
|
||||
Username = element.Attribute("Username")?.Value,
|
||||
Domain = element.Attribute("Domain")?.Value,
|
||||
Password = cryptographyProvider.Decrypt(element.Attribute("Password")?.Value, decryptionKey).ConvertToSecureString()
|
||||
Password = cryptographyProvider.Decrypt(element.Attribute("Password")?.Value, decryptionKey)
|
||||
.ConvertToSecureString()
|
||||
};
|
||||
return credential;
|
||||
}
|
||||
|
||||
private static bool EntryHasSomeCredentialData(XElement e)
|
||||
{
|
||||
return e.Attribute("Username")?.Value != "" ||
|
||||
return e.Attribute("Username")?.Value != "" ||
|
||||
e.Attribute("Domain")?.Value != "" ||
|
||||
e.Attribute("Password")?.Value != "";
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly ISecureDeserializer<string, IEnumerable<ICredentialRecord>> _deserializer;
|
||||
|
||||
public CredentialRecordLoader(IDataProvider<string> dataProvider, ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
public CredentialRecordLoader(IDataProvider<string> dataProvider,
|
||||
ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly ISecureSerializer<IEnumerable<ICredentialRecord>, string> _serializer;
|
||||
|
||||
public CredentialRecordSaver(IDataProvider<string> dataProvider, ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
|
||||
public CredentialRecordSaver(IDataProvider<string> dataProvider,
|
||||
ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace mRemoteNG.Config
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly CredentialRepositoryListDeserializer _deserializer;
|
||||
|
||||
public CredentialRepositoryListLoader(IDataProvider<string> dataProvider, CredentialRepositoryListDeserializer deserializer)
|
||||
public CredentialRepositoryListLoader(IDataProvider<string> dataProvider,
|
||||
CredentialRepositoryListDeserializer deserializer)
|
||||
{
|
||||
if (dataProvider == null)
|
||||
throw new ArgumentNullException(nameof(dataProvider));
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace mRemoteNG.Config
|
||||
_dataProvider.Save(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,14 @@ namespace mRemoteNG.Config.DataProviders
|
||||
if (WeDontNeedToBackup(fileName))
|
||||
return;
|
||||
|
||||
var backupFileName = string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, DateTime.Now);
|
||||
var backupFileName =
|
||||
string.Format(mRemoteNG.Settings.Default.BackupFileNameFormat, fileName, DateTime.Now);
|
||||
File.Copy(fileName, backupFileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(Language.strConnectionsFileBackupFailed, ex, MessageClass.WarningMsg);
|
||||
Runtime.MessageCollector.AddExceptionMessage(Language.strConnectionsFileBackupFailed, ex,
|
||||
MessageClass.WarningMsg);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace mRemoteNG.Config.DataProviders
|
||||
return;
|
||||
|
||||
var filesToDelete = files
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
.OrderByDescending(s => s)
|
||||
.Skip(maxBackupsToKeep);
|
||||
|
||||
foreach (var file in filesToDelete)
|
||||
{
|
||||
|
||||
@@ -22,12 +22,15 @@ namespace mRemoteNG.Config.DataProviders
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Could not load file. File does not exist '{FilePath}'", ex);
|
||||
Runtime.MessageCollector.AddExceptionStackTrace(
|
||||
$"Could not load file. File does not exist '{FilePath}'",
|
||||
ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace($"Failed to load file {FilePath}", ex);
|
||||
}
|
||||
|
||||
return fileContents;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
public interface IDataProvider<TFormat>
|
||||
{
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
if (SqlUserIsReadOnly())
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Trying to save connections but the SQL read only checkbox is checked, aborting!");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Trying to save connections but the SQL read only checkbox is checked, aborting!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +63,6 @@ namespace mRemoteNG.Config.DataProviders
|
||||
private bool SqlUserIsReadOnly()
|
||||
{
|
||||
return mRemoteNG.Settings.Default.SQLReadOnly;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,4 @@
|
||||
CredentialsRejected,
|
||||
UnknownError
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,4 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
return new SqlDatabaseConnector(sqlHost, sqlCatalog, sqlUsername, sqlPassword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,10 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
/// </summary>
|
||||
public class SqlDatabaseConnectionTester
|
||||
{
|
||||
public async Task<ConnectionTestResult> TestConnectivity(string server, string database, string username, string password)
|
||||
public async Task<ConnectionTestResult> TestConnectivity(string server,
|
||||
string database,
|
||||
string username,
|
||||
string password)
|
||||
{
|
||||
using (var sqlConnector = new SqlDatabaseConnector(server, database, username, password))
|
||||
{
|
||||
@@ -35,4 +38,4 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
public class SqlDatabaseConnector : IDatabaseConnector
|
||||
{
|
||||
public SqlConnection SqlConnection { get; private set; } = default(SqlConnection);
|
||||
public SqlConnection SqlConnection { get; private set; } = default(SqlConnection);
|
||||
private string _sqlConnectionString = "";
|
||||
private readonly string _sqlHost;
|
||||
private readonly string _sqlCatalog;
|
||||
@@ -45,7 +45,8 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
|
||||
private void BuildSqlConnectionStringWithCustomCredentials()
|
||||
{
|
||||
_sqlConnectionString = $"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};User Id={_sqlUsername};Password={_sqlPassword}";
|
||||
_sqlConnectionString =
|
||||
$"Data Source={_sqlHost};Initial Catalog={_sqlCatalog};User Id={_sqlUsername};Password={_sqlPassword}";
|
||||
}
|
||||
|
||||
private void BuildSqlConnectionStringWithDefaultCredentials()
|
||||
@@ -77,6 +78,7 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
private void Dispose(bool itIsSafeToFreeManagedObjects)
|
||||
{
|
||||
if (!itIsSafeToFreeManagedObjects) return;
|
||||
|
||||
@@ -7,29 +7,29 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class ActiveDirectoryImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class ActiveDirectoryImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string ldapPath, ContainerInfo destinationContainer)
|
||||
{
|
||||
Import(ldapPath, destinationContainer, false);
|
||||
}
|
||||
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
|
||||
var connectionTreeModel = deserializer.Deserialize();
|
||||
public static void Import(string ldapPath, ContainerInfo destinationContainer, bool importSubOu)
|
||||
{
|
||||
try
|
||||
{
|
||||
ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
var deserializer = new ActiveDirectoryDeserializer(ldapPath, importSubOu);
|
||||
var connectionTreeModel = deserializer.Deserialize();
|
||||
var importedRootNode = connectionTreeModel.RootNodes.First();
|
||||
if (importedRootNode == null) return;
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,16 +19,17 @@ namespace mRemoteNG.Config.Import
|
||||
}
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePath}");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"Unable to import file. File does not exist. Path: {filePath}");
|
||||
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new CsvConnectionsDeserializerMremotengFormat();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(filePath) };
|
||||
var rootImportContainer = new ContainerInfo {Name = Path.GetFileNameWithoutExtension(filePath)};
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,28 +10,29 @@ using mRemoteNG.Messages;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class MRemoteNGXmlImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!File.Exists(fileName))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {fileName}");
|
||||
if (!File.Exists(fileName))
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
$"Unable to import file. File does not exist. Path: {fileName}");
|
||||
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var xmlString = dataProvider.Load();
|
||||
var xmlConnectionsDeserializer = new XmlConnectionsDeserializer();
|
||||
var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(xmlString, true);
|
||||
|
||||
var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
var rootImportContainer = new ContainerInfo {Name = Path.GetFileNameWithoutExtension(fileName)};
|
||||
rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
|
||||
destinationContainer.AddChild(rootImportContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,18 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
|
||||
public PortScanImporter(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
public PortScanImporter(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
|
||||
public void Import(IEnumerable<ScanHost> hosts, ContainerInfo destinationContainer)
|
||||
{
|
||||
var deserializer = new PortScanDeserializer(_targetProtocolType);
|
||||
{
|
||||
var deserializer = new PortScanDeserializer(_targetProtocolType);
|
||||
var connectionTreeModel = deserializer.Deserialize(hosts);
|
||||
|
||||
var importedRootNode = connectionTreeModel.RootNodes.First();
|
||||
@@ -27,5 +27,5 @@ namespace mRemoteNG.Config.Import
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class PuttyConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var xmlContent = dataProvider.Load();
|
||||
|
||||
@@ -21,5 +21,5 @@ namespace mRemoteNG.Config.Import
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
||||
{
|
||||
public class RemoteDesktopConnectionImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string fileName, ContainerInfo destinationContainer)
|
||||
{
|
||||
{
|
||||
var dataProvider = new FileDataProvider(fileName);
|
||||
var content = dataProvider.Load();
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace mRemoteNG.Config.Import
|
||||
var connectionTreeModel = deserializer.Deserialize(content);
|
||||
|
||||
var importedConnection = connectionTreeModel.RootNodes.First().Children.First();
|
||||
|
||||
|
||||
if (importedConnection == null) return;
|
||||
importedConnection.Name = Path.GetFileNameWithoutExtension(fileName);
|
||||
destinationContainer.AddChild(importedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ using mRemoteNG.Container;
|
||||
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
public class RemoteDesktopConnectionManagerImporter : IConnectionImporter<string>
|
||||
{
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var fileContent = dataProvider.Load();
|
||||
|
||||
@@ -21,5 +21,5 @@ namespace mRemoteNG.Config.Import
|
||||
var childrenToAdd = importedRootNode.Children.ToArray();
|
||||
destinationContainer.AddChildRange(childrenToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,37 +5,42 @@ using System.Web;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using System.Text;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public abstract class AbstractPuttySessionsProvider
|
||||
{
|
||||
{
|
||||
public virtual RootPuttySessionsNodeInfo RootInfo { get; } = new RootPuttySessionsNodeInfo();
|
||||
|
||||
protected virtual List<PuttySessionInfo> Sessions
|
||||
{
|
||||
get { return RootInfo.Children.OfType<PuttySessionInfo>().ToList(); }
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
public abstract string[] GetSessionNames(bool raw = false);
|
||||
public abstract PuttySessionInfo GetSession(string sessionName);
|
||||
|
||||
public virtual IEnumerable<PuttySessionInfo> GetSessions()
|
||||
{
|
||||
var sessionNamesFromProvider = GetSessionNames(true);
|
||||
public abstract PuttySessionInfo GetSession(string sessionName);
|
||||
|
||||
public virtual IEnumerable<PuttySessionInfo> GetSessions()
|
||||
{
|
||||
var sessionNamesFromProvider = GetSessionNames(true);
|
||||
foreach (var sessionName in GetSessionNamesToAdd(sessionNamesFromProvider))
|
||||
{
|
||||
var sessionInfo = GetSession(sessionName);
|
||||
AddSession(sessionInfo);
|
||||
}
|
||||
foreach (var session in GetSessionToRemove(sessionNamesFromProvider))
|
||||
{
|
||||
RemoveSession(session);
|
||||
}
|
||||
{
|
||||
var sessionInfo = GetSession(sessionName);
|
||||
AddSession(sessionInfo);
|
||||
}
|
||||
|
||||
foreach (var session in GetSessionToRemove(sessionNamesFromProvider))
|
||||
{
|
||||
RemoveSession(session);
|
||||
}
|
||||
|
||||
RootInfo.SortRecursive();
|
||||
return Sessions;
|
||||
}
|
||||
return Sessions;
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetSessionNamesToAdd(IEnumerable<string> sessionNamesFromProvider)
|
||||
{
|
||||
@@ -47,7 +52,9 @@ namespace mRemoteNG.Config.Putty
|
||||
private IEnumerable<PuttySessionInfo> GetSessionToRemove(IEnumerable<string> sessionNamesFromProvider)
|
||||
{
|
||||
var currentlyKnownSessionNames = Sessions.Select(session => session.Name);
|
||||
var normalizedSessionNames = sessionNamesFromProvider.Select(name => HttpUtility.UrlDecode(name, Encoding.GetEncoding("iso-8859-1")));
|
||||
var normalizedSessionNames =
|
||||
sessionNamesFromProvider.Select(name =>
|
||||
HttpUtility.UrlDecode(name, Encoding.GetEncoding("iso-8859-1")));
|
||||
var sessionNamesToRemove = currentlyKnownSessionNames.Except(normalizedSessionNames);
|
||||
return Sessions.Where(session => sessionNamesToRemove.Contains(session.Name));
|
||||
}
|
||||
@@ -57,29 +64,43 @@ namespace mRemoteNG.Config.Putty
|
||||
if (string.IsNullOrEmpty(sessionInfo?.Name) || Sessions.Any(child => child.Name == sessionInfo.Name))
|
||||
return;
|
||||
RootInfo.AddChild(sessionInfo);
|
||||
RaisePuttySessionCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, sessionInfo));
|
||||
RaisePuttySessionCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
|
||||
sessionInfo));
|
||||
}
|
||||
|
||||
protected virtual void RemoveSession(PuttySessionInfo sessionInfo)
|
||||
{
|
||||
if (!Sessions.Contains(sessionInfo)) return;
|
||||
RootInfo.RemoveChild(sessionInfo);
|
||||
RaisePuttySessionCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, sessionInfo));
|
||||
RaisePuttySessionCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
|
||||
sessionInfo));
|
||||
}
|
||||
|
||||
public virtual void StartWatcher() { }
|
||||
|
||||
public virtual void StopWatcher() { }
|
||||
|
||||
public virtual void StartWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StopWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public delegate void PuttySessionChangedEventHandler(object sender, PuttySessionChangedEventArgs e);
|
||||
|
||||
public delegate void PuttySessionChangedEventHandler(object sender, PuttySessionChangedEventArgs e);
|
||||
|
||||
public event PuttySessionChangedEventHandler PuttySessionChanged;
|
||||
protected virtual void RaiseSessionChangedEvent(PuttySessionChangedEventArgs args)
|
||||
{
|
||||
|
||||
protected virtual void RaiseSessionChangedEvent(PuttySessionChangedEventArgs args)
|
||||
{
|
||||
PuttySessionChanged?.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler PuttySessionsCollectionChanged;
|
||||
|
||||
protected void RaisePuttySessionCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
PuttySessionsCollectionChanged?.Invoke(this, args);
|
||||
|
||||
@@ -3,74 +3,80 @@ using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsManager
|
||||
{
|
||||
{
|
||||
public static PuttySessionsManager Instance { get; } = new PuttySessionsManager();
|
||||
|
||||
private readonly List<AbstractPuttySessionsProvider> _providers = new List<AbstractPuttySessionsProvider>();
|
||||
|
||||
public IEnumerable<AbstractPuttySessionsProvider> Providers
|
||||
{
|
||||
get { return _providers; }
|
||||
}
|
||||
|
||||
public List<RootPuttySessionsNodeInfo> RootPuttySessionsNodes { get; } = new List<RootPuttySessionsNodeInfo>();
|
||||
public List<RootPuttySessionsNodeInfo> RootPuttySessionsNodes { get; } = new List<RootPuttySessionsNodeInfo>();
|
||||
|
||||
private PuttySessionsManager()
|
||||
{
|
||||
AddProvider(new PuttySessionsRegistryProvider());
|
||||
private PuttySessionsManager()
|
||||
{
|
||||
AddProvider(new PuttySessionsRegistryProvider());
|
||||
AddProvider(new PuttySessionsXmingProvider());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Public Methods
|
||||
public void AddSessions()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
AddSessionsFromProvider(provider);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider puttySessionProvider)
|
||||
{
|
||||
puttySessionProvider.ThrowIfNull(nameof(puttySessionProvider));
|
||||
public void AddSessions()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
AddSessionsFromProvider(provider);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSessionsFromProvider(AbstractPuttySessionsProvider puttySessionProvider)
|
||||
{
|
||||
puttySessionProvider.ThrowIfNull(nameof(puttySessionProvider));
|
||||
|
||||
var rootTreeNode = puttySessionProvider.RootInfo;
|
||||
puttySessionProvider.GetSessions();
|
||||
puttySessionProvider.GetSessions();
|
||||
|
||||
if (!RootPuttySessionsNodes.Contains(rootTreeNode) && rootTreeNode.HasChildren())
|
||||
RootPuttySessionsNodes.Add(rootTreeNode);
|
||||
rootTreeNode.SortRecursive();
|
||||
}
|
||||
|
||||
public void StartWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StartWatcher();
|
||||
provider.PuttySessionChanged += PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StopWatcher();
|
||||
provider.PuttySessionChanged -= PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StartWatcher();
|
||||
provider.PuttySessionChanged += PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopWatcher()
|
||||
{
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
provider.StopWatcher();
|
||||
provider.PuttySessionChanged -= PuttySessionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProvider(AbstractPuttySessionsProvider newProvider)
|
||||
{
|
||||
if (_providers.Contains(newProvider)) return;
|
||||
_providers.Add(newProvider);
|
||||
newProvider.PuttySessionsCollectionChanged += RaisePuttySessionCollectionChangedEvent;
|
||||
RaiseSessionProvidersCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newProvider));
|
||||
RaiseSessionProvidersCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
|
||||
newProvider));
|
||||
}
|
||||
|
||||
public void AddProviders(IEnumerable<AbstractPuttySessionsProvider> newProviders)
|
||||
@@ -84,48 +90,58 @@ namespace mRemoteNG.Config.Putty
|
||||
if (!_providers.Contains(providerToRemove)) return;
|
||||
_providers.Remove(providerToRemove);
|
||||
providerToRemove.PuttySessionsCollectionChanged -= RaisePuttySessionCollectionChangedEvent;
|
||||
RaiseSessionProvidersCollectionChangedEvent(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, providerToRemove));
|
||||
RaiseSessionProvidersCollectionChangedEvent(
|
||||
new
|
||||
NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
|
||||
providerToRemove));
|
||||
}
|
||||
|
||||
public void PuttySessionChanged(object sender, PuttySessionChangedEventArgs e)
|
||||
{
|
||||
AddSessions();
|
||||
}
|
||||
{
|
||||
AddSessions();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
private string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
if (!IsProviderEnabled(provider))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sessionNames.AddRange(provider.GetSessionNames(raw));
|
||||
}
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
private bool IsProviderEnabled(AbstractPuttySessionsProvider puttySessionsProvider)
|
||||
{
|
||||
|
||||
private string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var provider in Providers)
|
||||
{
|
||||
if (!IsProviderEnabled(provider))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sessionNames.AddRange(provider.GetSessionNames(raw));
|
||||
}
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
private bool IsProviderEnabled(AbstractPuttySessionsProvider puttySessionsProvider)
|
||||
{
|
||||
var enabled = true;
|
||||
if (PuttyTypeDetector.GetPuttyType() == PuttyTypeDetector.PuttyType.Xming)
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsRegistryProvider)
|
||||
enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsXmingProvider)
|
||||
enabled = false;
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
if (PuttyTypeDetector.GetPuttyType() == PuttyTypeDetector.PuttyType.Xming)
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsRegistryProvider)
|
||||
enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (puttySessionsProvider is PuttySessionsXmingProvider)
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Classes
|
||||
|
||||
public class SessionList : StringConverter
|
||||
{
|
||||
public static string[] Names
|
||||
@@ -134,29 +150,32 @@ namespace mRemoteNG.Config.Putty
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
return new StandardValuesCollection(Names);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
{
|
||||
return new StandardValuesCollection(Names);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event NotifyCollectionChangedEventHandler PuttySessionsCollectionChanged;
|
||||
|
||||
protected void RaisePuttySessionCollectionChangedEvent(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
PuttySessionsCollectionChanged?.Invoke(sender, args);
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler SessionProvidersCollectionChanged;
|
||||
|
||||
protected void RaiseSessionProvidersCollectionChangedEvent(NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
SessionProvidersCollectionChanged?.Invoke(this, args);
|
||||
|
||||
@@ -14,30 +14,34 @@ using mRemoteNG.Messages;
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsRegistryProvider : AbstractPuttySessionsProvider
|
||||
{
|
||||
{
|
||||
private const string PuttySessionsKey = "Software\\SimonTatham\\PuTTY\\Sessions";
|
||||
private static ManagementEventWatcher _eventWatcher;
|
||||
|
||||
#region Public Methods
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
|
||||
if (sessionsKey == null) return new string[] {};
|
||||
if (sessionsKey == null) return new string[] { };
|
||||
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var sessionName in sessionsKey.GetSubKeyNames())
|
||||
{
|
||||
sessionNames.Add(raw ? sessionName : HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"), Encoding.GetEncoding("iso-8859-1")));
|
||||
}
|
||||
|
||||
if (raw && !sessionNames.Contains("Default%20Settings"))
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
else if (!raw && !sessionNames.Contains("Default Settings"))
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
foreach (var sessionName in sessionsKey.GetSubKeyNames())
|
||||
{
|
||||
sessionNames.Add(raw
|
||||
? sessionName
|
||||
: HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"),
|
||||
Encoding.GetEncoding("iso-8859-1")));
|
||||
}
|
||||
|
||||
if (raw && !sessionNames.Contains("Default%20Settings"))
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
else if (!raw && !sessionNames.Contains("Default Settings"))
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sessionName))
|
||||
@@ -45,35 +49,35 @@ namespace mRemoteNG.Config.Putty
|
||||
|
||||
var sessionsKey = Registry.CurrentUser.OpenSubKey(PuttySessionsKey);
|
||||
var sessionKey = sessionsKey?.OpenSubKey(sessionName);
|
||||
if (sessionKey == null) return null;
|
||||
if (sessionKey == null) return null;
|
||||
|
||||
sessionName = HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"), Encoding.GetEncoding("iso-8859-1"));
|
||||
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionKey.GetValue("HostName")?.ToString() ?? "",
|
||||
Username = sessionKey.GetValue("UserName")?.ToString() ?? ""
|
||||
};
|
||||
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionKey.GetValue("HostName")?.ToString() ?? "",
|
||||
Username = sessionKey.GetValue("UserName")?.ToString() ?? ""
|
||||
};
|
||||
|
||||
|
||||
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol")?.ToString())
|
||||
? "ssh"
|
||||
var protocol = string.IsNullOrEmpty(sessionKey.GetValue("Protocol")?.ToString())
|
||||
? "ssh"
|
||||
: sessionKey.GetValue("Protocol").ToString();
|
||||
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
int.TryParse(sessionKey.GetValue("SshProt")?.ToString(), out var sshVersion);
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
int.TryParse(sessionKey.GetValue("SshProt")?.ToString(), out var sshVersion);
|
||||
/* Per PUTTY.H in PuTTYNG & PuTTYNG Upstream (PuTTY proper currently)
|
||||
* expect 0 for SSH1, 3 for SSH2 ONLY
|
||||
* 1 for SSH1 with a 2 fallback
|
||||
@@ -82,53 +86,56 @@ namespace mRemoteNG.Config.Putty
|
||||
* default to SSH2 if any other value is received
|
||||
*/
|
||||
sessionInfo.Protocol = sshVersion == 1 || sshVersion == 0 ? ProtocolType.SSH1 : ProtocolType.SSH2;
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
int.TryParse(sessionKey.GetValue("PortNumber")?.ToString(), out var portNumber);
|
||||
if (portNumber == default(int))
|
||||
sessionInfo.SetDefaultPort();
|
||||
else
|
||||
sessionInfo.Port = portNumber;
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null) return;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null) return;
|
||||
|
||||
try
|
||||
{
|
||||
var currentUserSid = WindowsIdentity.GetCurrent().User?.Value;
|
||||
var key = string.Join("\\", currentUserSid, PuttySessionsKey).Replace("\\", "\\\\");
|
||||
var query = new WqlEventQuery($"SELECT * FROM RegistryTreeChangeEvent WHERE Hive = \'HKEY_USERS\' AND RootPath = \'{key}\'");
|
||||
_eventWatcher = new ManagementEventWatcher(query);
|
||||
_eventWatcher.EventArrived += OnManagementEventArrived;
|
||||
_eventWatcher.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttySessions.Watcher.StartWatching() failed.", ex, MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
if (_eventWatcher == null) return;
|
||||
_eventWatcher.Stop();
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
var query = new WqlEventQuery(
|
||||
$"SELECT * FROM RegistryTreeChangeEvent WHERE Hive = \'HKEY_USERS\' AND RootPath = \'{key}\'");
|
||||
_eventWatcher = new ManagementEventWatcher(query);
|
||||
_eventWatcher.EventArrived += OnManagementEventArrived;
|
||||
_eventWatcher.Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttySessions.Watcher.StartWatching() failed.", ex,
|
||||
MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
if (_eventWatcher == null) return;
|
||||
_eventWatcher.Stop();
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnManagementEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
private void OnManagementEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,339 +12,374 @@ using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionsXmingProvider : AbstractPuttySessionsProvider
|
||||
{
|
||||
public override RootPuttySessionsNodeInfo RootInfo { get; } = new RootPuttySessionsNodeInfo { Name = "Xming Putty Sessions" };
|
||||
public class PuttySessionsXmingProvider : AbstractPuttySessionsProvider
|
||||
{
|
||||
public override RootPuttySessionsNodeInfo RootInfo { get; } =
|
||||
new RootPuttySessionsNodeInfo {Name = "Xming Putty Sessions"};
|
||||
|
||||
private const string RegistrySessionNameFormat = "{0} [registry]";
|
||||
private const string RegistrySessionNamePattern = "(.*)\\ \\[registry\\]";
|
||||
private static readonly PuttySessionsRegistryProvider PuttySessionsRegistryProvider = new PuttySessionsRegistryProvider();
|
||||
|
||||
private static readonly PuttySessionsRegistryProvider PuttySessionsRegistryProvider =
|
||||
new PuttySessionsRegistryProvider();
|
||||
|
||||
private static FileSystemWatcher _eventWatcher;
|
||||
|
||||
#region Public Methods
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return new string[] {};
|
||||
}
|
||||
|
||||
public override string[] GetSessionNames(bool raw = false)
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return new string[] { };
|
||||
}
|
||||
|
||||
var sessionNames = new List<string>();
|
||||
foreach (var sessionName in Directory.GetFiles(sessionsFolderPath))
|
||||
{
|
||||
var sessionFileName = Path.GetFileName(sessionName);
|
||||
// ReSharper disable once ConstantConditionalAccessQualifier
|
||||
sessionNames.Add(raw ? sessionFileName : System.Web.HttpUtility.UrlDecode(sessionFileName?.Replace("+", "%2B")));
|
||||
}
|
||||
foreach (var sessionName in Directory.GetFiles(sessionsFolderPath))
|
||||
{
|
||||
var sessionFileName = Path.GetFileName(sessionName);
|
||||
// ReSharper disable once ConstantConditionalAccessQualifier
|
||||
sessionNames.Add(raw
|
||||
? sessionFileName
|
||||
: System.Web.HttpUtility.UrlDecode(sessionFileName?.Replace("+", "%2B")));
|
||||
}
|
||||
|
||||
if (raw)
|
||||
{
|
||||
if (!sessionNames.Contains("Default%20Settings")) // Do not localize
|
||||
{
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sessionNames.Contains("Default Settings"))
|
||||
{
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
}
|
||||
}
|
||||
if (raw)
|
||||
{
|
||||
if (!sessionNames.Contains("Default%20Settings")) // Do not localize
|
||||
{
|
||||
sessionNames.Insert(0, "Default%20Settings");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sessionNames.Contains("Default Settings"))
|
||||
{
|
||||
sessionNames.Insert(0, "Default Settings");
|
||||
}
|
||||
}
|
||||
|
||||
var registrySessionNames = PuttySessionsRegistryProvider.GetSessionNames(raw).Select(sessionName => string.Format(RegistrySessionNameFormat, sessionName)).ToList();
|
||||
var registrySessionNames = PuttySessionsRegistryProvider.GetSessionNames(raw)
|
||||
.Select(sessionName =>
|
||||
string
|
||||
.Format(RegistrySessionNameFormat,
|
||||
sessionName)).ToList();
|
||||
|
||||
sessionNames.AddRange(registrySessionNames);
|
||||
sessionNames.Sort();
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
sessionNames.AddRange(registrySessionNames);
|
||||
sessionNames.Sort();
|
||||
|
||||
return sessionNames.ToArray();
|
||||
}
|
||||
|
||||
public override PuttySessionInfo GetSession(string sessionName)
|
||||
{
|
||||
var registrySessionName = GetRegistrySessionName(sessionName);
|
||||
if (!string.IsNullOrEmpty(registrySessionName))
|
||||
{
|
||||
return ModifyRegistrySessionInfo(PuttySessionsRegistryProvider.GetSession(registrySessionName));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(registrySessionName))
|
||||
{
|
||||
return ModifyRegistrySessionInfo(PuttySessionsRegistryProvider.GetSession(registrySessionName));
|
||||
}
|
||||
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var sessionFile = Path.Combine(sessionsFolderPath, sessionName);
|
||||
if (!File.Exists(sessionFile))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
sessionName = System.Web.HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));
|
||||
if (!File.Exists(sessionFile))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
sessionName = System.Web.HttpUtility.UrlDecode(sessionName.Replace("+", "%2B"));
|
||||
|
||||
var sessionFileReader = new SessionFileReader(sessionFile);
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionFileReader.GetValue("HostName"),
|
||||
Username = sessionFileReader.GetValue("UserName")
|
||||
};
|
||||
var protocol = sessionFileReader.GetValue("Protocol") ?? "ssh";
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
object sshVersionObject = sessionFileReader.GetValue("SshProt");
|
||||
if (sshVersionObject != null)
|
||||
{
|
||||
var sshVersion = Convert.ToInt32(sshVersionObject);
|
||||
sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionInfo.Protocol = ProtocolType.SSH2;
|
||||
}
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
sessionInfo.Port = Convert.ToInt32(sessionFileReader.GetValue("PortNumber"));
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var sessionInfo = new PuttySessionInfo
|
||||
{
|
||||
PuttySession = sessionName,
|
||||
Name = sessionName,
|
||||
Hostname = sessionFileReader.GetValue("HostName"),
|
||||
Username = sessionFileReader.GetValue("UserName")
|
||||
};
|
||||
var protocol = sessionFileReader.GetValue("Protocol") ?? "ssh";
|
||||
switch (protocol.ToLowerInvariant())
|
||||
{
|
||||
case "raw":
|
||||
sessionInfo.Protocol = ProtocolType.RAW;
|
||||
break;
|
||||
case "rlogin":
|
||||
sessionInfo.Protocol = ProtocolType.Rlogin;
|
||||
break;
|
||||
case "serial":
|
||||
return null;
|
||||
case "ssh":
|
||||
object sshVersionObject = sessionFileReader.GetValue("SshProt");
|
||||
if (sshVersionObject != null)
|
||||
{
|
||||
var sshVersion = Convert.ToInt32(sshVersionObject);
|
||||
sessionInfo.Protocol = sshVersion >= 2 ? ProtocolType.SSH2 : ProtocolType.SSH1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionInfo.Protocol = ProtocolType.SSH2;
|
||||
}
|
||||
|
||||
break;
|
||||
case "telnet":
|
||||
sessionInfo.Protocol = ProtocolType.Telnet;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
sessionInfo.Port = Convert.ToInt32(sessionFileReader.GetValue("PortNumber"));
|
||||
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public override void StartWatcher()
|
||||
{
|
||||
if (_eventWatcher != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var sessionsFolderPath = GetSessionsFolderPath();
|
||||
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, $"XmingPortablePuttySessions.Watcher.StartWatching() failed: '{sessionsFolderPath}' does not exist.", true);
|
||||
return;
|
||||
}
|
||||
if (!Directory.Exists(sessionsFolderPath))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
$"XmingPortablePuttySessions.Watcher.StartWatching() failed: '{sessionsFolderPath}' does not exist.",
|
||||
true);
|
||||
return;
|
||||
}
|
||||
|
||||
_eventWatcher = new FileSystemWatcher(sessionsFolderPath)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
|
||||
};
|
||||
_eventWatcher.Changed += OnFileSystemEventArrived;
|
||||
_eventWatcher.Created += OnFileSystemEventArrived;
|
||||
_eventWatcher.Deleted += OnFileSystemEventArrived;
|
||||
_eventWatcher.Renamed += OnFileSystemEventArrived;
|
||||
_eventWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(
|
||||
"XmingPortablePuttySessions.Watcher.StartWatching() failed.",
|
||||
ex, MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
PuttySessionsRegistryProvider.StopWatcher();
|
||||
PuttySessionsRegistryProvider.PuttySessionChanged -= OnRegistrySessionChanged;
|
||||
|
||||
if (_eventWatcher == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eventWatcher.EnableRaisingEvents = false;
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
|
||||
_eventWatcher = new FileSystemWatcher(sessionsFolderPath)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
|
||||
};
|
||||
_eventWatcher.Changed += OnFileSystemEventArrived;
|
||||
_eventWatcher.Created += OnFileSystemEventArrived;
|
||||
_eventWatcher.Deleted += OnFileSystemEventArrived;
|
||||
_eventWatcher.Renamed += OnFileSystemEventArrived;
|
||||
_eventWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("XmingPortablePuttySessions.Watcher.StartWatching() failed.", ex, MessageClass.WarningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopWatcher()
|
||||
{
|
||||
PuttySessionsRegistryProvider.StopWatcher();
|
||||
PuttySessionsRegistryProvider.PuttySessionChanged -= OnRegistrySessionChanged;
|
||||
|
||||
if (_eventWatcher == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_eventWatcher.EnableRaisingEvents = false;
|
||||
_eventWatcher.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private Methods
|
||||
private static string GetPuttyConfPath()
|
||||
{
|
||||
var puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? mRemoteNG.Settings.Default.CustomPuttyPath : App.Info.GeneralAppInfo.PuttyPath;
|
||||
puttyPath = Path.GetDirectoryName(puttyPath);
|
||||
|
||||
private static string GetPuttyConfPath()
|
||||
{
|
||||
var puttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath
|
||||
? mRemoteNG.Settings.Default.CustomPuttyPath
|
||||
: App.Info.GeneralAppInfo.PuttyPath;
|
||||
puttyPath = Path.GetDirectoryName(puttyPath);
|
||||
return string.IsNullOrEmpty(puttyPath) ? null : Path.Combine(puttyPath, "putty.conf");
|
||||
}
|
||||
|
||||
private static string GetSessionsFolderPath()
|
||||
{
|
||||
}
|
||||
|
||||
private static string GetSessionsFolderPath()
|
||||
{
|
||||
var puttyConfPath = GetPuttyConfPath();
|
||||
var sessionFileReader = new PuttyConfFileReader(puttyConfPath);
|
||||
var basePath = Environment.ExpandEnvironmentVariables(sessionFileReader.GetValue("sshk&sess"));
|
||||
return Path.Combine(basePath, "sessions");
|
||||
}
|
||||
|
||||
private static string GetRegistrySessionName(string sessionName)
|
||||
{
|
||||
return Path.Combine(basePath, "sessions");
|
||||
}
|
||||
|
||||
private static string GetRegistrySessionName(string sessionName)
|
||||
{
|
||||
var regex = new Regex(RegistrySessionNamePattern);
|
||||
|
||||
var matches = regex.Matches(sessionName);
|
||||
if (matches.Count < 1)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (matches.Count < 1)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var groups = matches[0].Groups;
|
||||
return groups.Count < 1 ? string.Empty : groups[1].Value;
|
||||
}
|
||||
|
||||
private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
|
||||
{
|
||||
if (sessionInfo == null)
|
||||
return null;
|
||||
return groups.Count < 1 ? string.Empty : groups[1].Value;
|
||||
}
|
||||
|
||||
private static PuttySessionInfo ModifyRegistrySessionInfo(PuttySessionInfo sessionInfo)
|
||||
{
|
||||
if (sessionInfo == null)
|
||||
return null;
|
||||
|
||||
sessionInfo.Name = string.Format(RegistrySessionNameFormat, sessionInfo.Name);
|
||||
sessionInfo.PuttySession = string.Format(RegistrySessionNameFormat, sessionInfo.PuttySession);
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
private void OnFileSystemEventArrived(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
private void OnRegistrySessionChanged(object sender, PuttySessionChangedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
sessionInfo.Name = string.Format(RegistrySessionNameFormat, sessionInfo.Name);
|
||||
sessionInfo.PuttySession = string.Format(RegistrySessionNameFormat, sessionInfo.PuttySession);
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
private void OnFileSystemEventArrived(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
|
||||
private void OnRegistrySessionChanged(object sender, PuttySessionChangedEventArgs e)
|
||||
{
|
||||
RaiseSessionChangedEvent(new PuttySessionChangedEventArgs());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private Classes
|
||||
private class PuttyConfFileReader
|
||||
{
|
||||
public PuttyConfFileReader(string puttyConfFile)
|
||||
{
|
||||
_puttyConfFile = puttyConfFile;
|
||||
}
|
||||
|
||||
private string _puttyConfFile;
|
||||
private bool _configurationLoaded;
|
||||
private Dictionary<string, string> _configuration = new Dictionary<string, string>();
|
||||
|
||||
private void LoadConfiguration()
|
||||
{
|
||||
_configurationLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_puttyConfFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var streamReader = new StreamReader(_puttyConfFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
line = line.Trim();
|
||||
if (line == string.Empty)
|
||||
{
|
||||
continue; // Blank line
|
||||
}
|
||||
if (line.Substring(0, 1) == ";")
|
||||
{
|
||||
continue; // Comment
|
||||
}
|
||||
|
||||
private class PuttyConfFileReader
|
||||
{
|
||||
public PuttyConfFileReader(string puttyConfFile)
|
||||
{
|
||||
_puttyConfFile = puttyConfFile;
|
||||
}
|
||||
|
||||
private string _puttyConfFile;
|
||||
private bool _configurationLoaded;
|
||||
private Dictionary<string, string> _configuration = new Dictionary<string, string>();
|
||||
|
||||
private void LoadConfiguration()
|
||||
{
|
||||
_configurationLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_puttyConfFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var streamReader = new StreamReader(_puttyConfFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
line = line.Trim();
|
||||
if (line == string.Empty)
|
||||
{
|
||||
continue; // Blank line
|
||||
}
|
||||
|
||||
if (line.Substring(0, 1) == ";")
|
||||
{
|
||||
continue; // Comment
|
||||
}
|
||||
|
||||
var parts = line.Split(new[] {'='}, 2);
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (_configuration.ContainsKey(parts[0]))
|
||||
{
|
||||
continue; // As per http://www.straightrunning.com/XmingNotes/portableputty.php only first entry is used
|
||||
}
|
||||
_configuration.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttyConfFileReader.LoadConfiguration() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_configurationLoaded)
|
||||
{
|
||||
LoadConfiguration();
|
||||
}
|
||||
return !_configuration.ContainsKey(setting) ? string.Empty : _configuration[setting];
|
||||
}
|
||||
}
|
||||
|
||||
private class SessionFileReader
|
||||
{
|
||||
public SessionFileReader(string sessionFile)
|
||||
{
|
||||
_sessionFile = sessionFile;
|
||||
}
|
||||
|
||||
private string _sessionFile;
|
||||
private bool _sessionInfoLoaded;
|
||||
private Dictionary<string, string> _sessionInfo = new Dictionary<string, string>();
|
||||
|
||||
private void LoadSessionInfo()
|
||||
{
|
||||
_sessionInfoLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_sessionFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var streamReader = new StreamReader(_sessionFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_configuration.ContainsKey(parts[0]))
|
||||
{
|
||||
continue; // As per http://www.straightrunning.com/XmingNotes/portableputty.php only first entry is used
|
||||
}
|
||||
|
||||
_configuration.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("PuttyConfFileReader.LoadConfiguration() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_configurationLoaded)
|
||||
{
|
||||
LoadConfiguration();
|
||||
}
|
||||
|
||||
return !_configuration.ContainsKey(setting) ? string.Empty : _configuration[setting];
|
||||
}
|
||||
}
|
||||
|
||||
private class SessionFileReader
|
||||
{
|
||||
public SessionFileReader(string sessionFile)
|
||||
{
|
||||
_sessionFile = sessionFile;
|
||||
}
|
||||
|
||||
private string _sessionFile;
|
||||
private bool _sessionInfoLoaded;
|
||||
private Dictionary<string, string> _sessionInfo = new Dictionary<string, string>();
|
||||
|
||||
private void LoadSessionInfo()
|
||||
{
|
||||
_sessionInfoLoaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(_sessionFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var streamReader = new StreamReader(_sessionFile))
|
||||
{
|
||||
do
|
||||
{
|
||||
var line = streamReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var parts = line.Split('\\');
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_sessionInfo.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("SessionFileReader.LoadSessionInfo() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_sessionInfoLoaded)
|
||||
{
|
||||
LoadSessionInfo();
|
||||
}
|
||||
return !_sessionInfo.ContainsKey(setting) ? string.Empty : _sessionInfo[setting];
|
||||
}
|
||||
}
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_sessionInfo.Add(parts[0], parts[1]);
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("SessionFileReader.LoadSessionInfo() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValue(string setting)
|
||||
{
|
||||
if (!_sessionInfoLoaded)
|
||||
{
|
||||
LoadSessionInfo();
|
||||
}
|
||||
|
||||
return !_sessionInfo.ContainsKey(setting) ? string.Empty : _sessionInfo[setting];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
{
|
||||
public ConnectionTreeModel Deserialize(string serializedData)
|
||||
{
|
||||
var lines = serializedData.Split(new []{"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var lines = serializedData.Split(new[] {"\r\n", "\r", "\n"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
var csvHeaders = new List<string>();
|
||||
// used to map a connectioninfo to it's parent's GUID
|
||||
var parentMapping = new Dictionary<ConnectionInfo, string>();
|
||||
@@ -55,9 +55,9 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
|
||||
// search for parent in the list by GUID
|
||||
var parent = parentMapping
|
||||
.Keys
|
||||
.OfType<ContainerInfo>()
|
||||
.FirstOrDefault(info => info.ConstantID == node.Value);
|
||||
.Keys
|
||||
.OfType<ContainerInfo>()
|
||||
.FirstOrDefault(info => info.ConstantID == node.Value);
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
private ConnectionInfo ParseConnectionInfo(IList<string> headers, string[] connectionCsv)
|
||||
{
|
||||
var nodeType = headers.Contains("NodeType")
|
||||
? (TreeNodeType)Enum.Parse(typeof(TreeNodeType), connectionCsv[headers.IndexOf("NodeType")], true)
|
||||
? (TreeNodeType)Enum.Parse(typeof(TreeNodeType), connectionCsv[headers.IndexOf("NodeType")], true)
|
||||
: TreeNodeType.Connection;
|
||||
|
||||
var nodeId = headers.Contains("Id")
|
||||
@@ -87,27 +87,48 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
: new ContainerInfo(nodeId);
|
||||
|
||||
connectionRecord.Name = headers.Contains("Name") ? connectionCsv[headers.IndexOf("Name")] : "";
|
||||
connectionRecord.Description = headers.Contains("Description") ? connectionCsv[headers.IndexOf("Description")] : "";
|
||||
connectionRecord.Description =
|
||||
headers.Contains("Description") ? connectionCsv[headers.IndexOf("Description")] : "";
|
||||
connectionRecord.Icon = headers.Contains("Icon") ? connectionCsv[headers.IndexOf("Icon")] : "";
|
||||
connectionRecord.Panel = headers.Contains("Panel") ? connectionCsv[headers.IndexOf("Panel")] : "";
|
||||
connectionRecord.Username = headers.Contains("Username") ? connectionCsv[headers.IndexOf("Username")] : "";
|
||||
connectionRecord.Password = headers.Contains("Password") ? connectionCsv[headers.IndexOf("Password")] : "";
|
||||
connectionRecord.Domain = headers.Contains("Domain") ? connectionCsv[headers.IndexOf("Domain")] : "";
|
||||
connectionRecord.Hostname = headers.Contains("Hostname") ? connectionCsv[headers.IndexOf("Hostname")] : "";
|
||||
connectionRecord.PuttySession = headers.Contains("PuttySession") ? connectionCsv[headers.IndexOf("PuttySession")] : "";
|
||||
connectionRecord.LoadBalanceInfo = headers.Contains("LoadBalanceInfo") ? connectionCsv[headers.IndexOf("LoadBalanceInfo")] : "";
|
||||
connectionRecord.PreExtApp = headers.Contains("PreExtApp") ? connectionCsv[headers.IndexOf("PreExtApp")] : "";
|
||||
connectionRecord.PostExtApp = headers.Contains("PostExtApp") ? connectionCsv[headers.IndexOf("PostExtApp")] : "";
|
||||
connectionRecord.MacAddress = headers.Contains("MacAddress") ? connectionCsv[headers.IndexOf("MacAddress")] : "";
|
||||
connectionRecord.UserField = headers.Contains("UserField") ? connectionCsv[headers.IndexOf("UserField")] : "";
|
||||
connectionRecord.PuttySession =
|
||||
headers.Contains("PuttySession") ? connectionCsv[headers.IndexOf("PuttySession")] : "";
|
||||
connectionRecord.LoadBalanceInfo = headers.Contains("LoadBalanceInfo")
|
||||
? connectionCsv[headers.IndexOf("LoadBalanceInfo")]
|
||||
: "";
|
||||
connectionRecord.PreExtApp =
|
||||
headers.Contains("PreExtApp") ? connectionCsv[headers.IndexOf("PreExtApp")] : "";
|
||||
connectionRecord.PostExtApp =
|
||||
headers.Contains("PostExtApp") ? connectionCsv[headers.IndexOf("PostExtApp")] : "";
|
||||
connectionRecord.MacAddress =
|
||||
headers.Contains("MacAddress") ? connectionCsv[headers.IndexOf("MacAddress")] : "";
|
||||
connectionRecord.UserField =
|
||||
headers.Contains("UserField") ? connectionCsv[headers.IndexOf("UserField")] : "";
|
||||
connectionRecord.ExtApp = headers.Contains("ExtApp") ? connectionCsv[headers.IndexOf("ExtApp")] : "";
|
||||
connectionRecord.VNCProxyUsername = headers.Contains("VNCProxyUsername") ? connectionCsv[headers.IndexOf("VNCProxyUsername")] : "";
|
||||
connectionRecord.VNCProxyPassword = headers.Contains("VNCProxyPassword") ? connectionCsv[headers.IndexOf("VNCProxyPassword")] : "";
|
||||
connectionRecord.RDGatewayUsername = headers.Contains("RDGatewayUsername") ? connectionCsv[headers.IndexOf("RDGatewayUsername")] : "";
|
||||
connectionRecord.RDGatewayPassword = headers.Contains("RDGatewayPassword") ? connectionCsv[headers.IndexOf("RDGatewayPassword")] : "";
|
||||
connectionRecord.RDGatewayDomain = headers.Contains("RDGatewayDomain") ? connectionCsv[headers.IndexOf("RDGatewayDomain")] : "";
|
||||
connectionRecord.VNCProxyIP = headers.Contains("VNCProxyIP") ? connectionCsv[headers.IndexOf("VNCProxyIP")] : "";
|
||||
connectionRecord.RDGatewayHostname = headers.Contains("RDGatewayHostname") ? connectionCsv[headers.IndexOf("RDGatewayHostname")] : "";
|
||||
connectionRecord.VNCProxyUsername = headers.Contains("VNCProxyUsername")
|
||||
? connectionCsv[headers.IndexOf("VNCProxyUsername")]
|
||||
: "";
|
||||
connectionRecord.VNCProxyPassword = headers.Contains("VNCProxyPassword")
|
||||
? connectionCsv[headers.IndexOf("VNCProxyPassword")]
|
||||
: "";
|
||||
connectionRecord.RDGatewayUsername = headers.Contains("RDGatewayUsername")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayUsername")]
|
||||
: "";
|
||||
connectionRecord.RDGatewayPassword = headers.Contains("RDGatewayPassword")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayPassword")]
|
||||
: "";
|
||||
connectionRecord.RDGatewayDomain = headers.Contains("RDGatewayDomain")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayDomain")]
|
||||
: "";
|
||||
connectionRecord.VNCProxyIP =
|
||||
headers.Contains("VNCProxyIP") ? connectionCsv[headers.IndexOf("VNCProxyIP")] : "";
|
||||
connectionRecord.RDGatewayHostname = headers.Contains("RDGatewayHostname")
|
||||
? connectionCsv[headers.IndexOf("RDGatewayHostname")]
|
||||
: "";
|
||||
|
||||
if (headers.Contains("Protocol"))
|
||||
{
|
||||
@@ -234,6 +255,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("RedirectPrinters")], out value))
|
||||
connectionRecord.RedirectPrinters = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("RedirectClipboard"))
|
||||
{
|
||||
bool value;
|
||||
@@ -333,6 +355,7 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
}
|
||||
|
||||
#region Inheritance
|
||||
|
||||
if (headers.Contains("InheritCacheBitmaps"))
|
||||
{
|
||||
bool value;
|
||||
@@ -672,7 +695,8 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
if (headers.Contains("InheritRDGatewayUseConnectionCredentials"))
|
||||
{
|
||||
bool value;
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")], out value))
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritRDGatewayUseConnectionCredentials")],
|
||||
out value))
|
||||
connectionRecord.Inheritance.RDGatewayUseConnectionCredentials = value;
|
||||
}
|
||||
|
||||
@@ -717,9 +741,10 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritSoundQuality")], out value))
|
||||
connectionRecord.Inheritance.SoundQuality = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
return connectionRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,15 @@ using System.Text;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.Csv
|
||||
{
|
||||
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo,string>
|
||||
public class CsvConnectionsSerializerMremotengFormat : ISerializer<ConnectionInfo, string>
|
||||
{
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ICredentialRepositoryList _credentialRepositoryList;
|
||||
|
||||
public Version Version { get; } = new Version(2, 7);
|
||||
|
||||
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter, ICredentialRepositoryList credentialRepositoryList)
|
||||
public CsvConnectionsSerializerMremotengFormat(SaveFilter saveFilter,
|
||||
ICredentialRepositoryList credentialRepositoryList)
|
||||
{
|
||||
saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
credentialRepositoryList.ThrowIfNull(nameof(credentialRepositoryList));
|
||||
@@ -54,9 +55,11 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
sb.Append("Password;");
|
||||
if (_saveFilter.SaveDomain)
|
||||
sb.Append("Domain;");
|
||||
sb.Append("Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectClipboard;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;");
|
||||
sb.Append(
|
||||
"Hostname;Protocol;PuttySession;Port;ConnectToConsole;UseCredSsp;RenderingEngine;ICAEncryptionStrength;RDPAuthenticationLevel;LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectClipboard;RedirectSmartCards;RedirectSound;RedirectKeys;PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;VNCProxyPort;VNCProxyUsername;VNCProxyPassword;VNCColors;VNCSmartSizeMode;VNCViewOnly;RDGatewayUsageMethod;RDGatewayHostname;RDGatewayUseConnectionCredentials;RDGatewayUsername;RDGatewayPassword;RDGatewayDomain;");
|
||||
if (_saveFilter.SaveInheritance)
|
||||
sb.Append("InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectClipboard;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality");
|
||||
sb.Append(
|
||||
"InheritCacheBitmaps;InheritColors;InheritDescription;InheritDisplayThemes;InheritDisplayWallpaper;InheritEnableFontSmoothing;InheritEnableDesktopComposition;InheritDomain;InheritIcon;InheritPanel;InheritPassword;InheritPort;InheritProtocol;InheritPuttySession;InheritRedirectDiskDrives;InheritRedirectKeys;InheritRedirectPorts;InheritRedirectPrinters;InheritRedirectClipboard;InheritRedirectSmartCards;InheritRedirectSound;InheritResolution;InheritAutomaticResize;InheritUseConsoleSession;InheritUseCredSsp;InheritRenderingEngine;InheritUsername;InheritICAEncryptionStrength;InheritRDPAuthenticationLevel;InheritLoadBalanceInfo;InheritPreExtApp;InheritPostExtApp;InheritMacAddress;InheritUserField;InheritExtApp;InheritVNCCompression;InheritVNCEncoding;InheritVNCAuthMode;InheritVNCProxyType;InheritVNCProxyIP;InheritVNCProxyPort;InheritVNCProxyUsername;InheritVNCProxyPassword;InheritVNCColors;InheritVNCSmartSizeMode;InheritVNCViewOnly;InheritRDGatewayUsageMethod;InheritRDGatewayHostname;InheritRDGatewayUseConnectionCredentials;InheritRDGatewayUsername;InheritRDGatewayPassword;InheritRDGatewayDomain;InheritRDPAlertIdleTimeout;InheritRDPMinutesToIdleTimeout;InheritSoundQuality");
|
||||
}
|
||||
|
||||
private void SerializeNodesRecursive(ConnectionInfo node, StringBuilder sb)
|
||||
@@ -81,12 +84,12 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.Append(FormatForCsv(con.Name))
|
||||
.Append(FormatForCsv(con.ConstantID))
|
||||
.Append(FormatForCsv(con.Parent?.ConstantID ?? ""))
|
||||
.Append(FormatForCsv(con.GetTreeNodeType()))
|
||||
.Append(FormatForCsv(con.Description))
|
||||
.Append(FormatForCsv(con.Icon))
|
||||
.Append(FormatForCsv(con.Panel));
|
||||
.Append(FormatForCsv(con.ConstantID))
|
||||
.Append(FormatForCsv(con.Parent?.ConstantID ?? ""))
|
||||
.Append(FormatForCsv(con.GetTreeNodeType()))
|
||||
.Append(FormatForCsv(con.Description))
|
||||
.Append(FormatForCsv(con.Icon))
|
||||
.Append(FormatForCsv(con.Panel));
|
||||
|
||||
if (_saveFilter.SaveUsername)
|
||||
sb.Append(FormatForCsv(con.Username));
|
||||
@@ -98,112 +101,112 @@ namespace mRemoteNG.Config.Serializers.Csv
|
||||
sb.Append(FormatForCsv(con.Domain));
|
||||
|
||||
sb.Append(FormatForCsv(con.Hostname))
|
||||
.Append(FormatForCsv(con.Protocol))
|
||||
.Append(FormatForCsv(con.PuttySession))
|
||||
.Append(FormatForCsv(con.Port))
|
||||
.Append(FormatForCsv(con.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.UseCredSsp))
|
||||
.Append(FormatForCsv(con.RenderingEngine))
|
||||
.Append(FormatForCsv(con.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Colors))
|
||||
.Append(FormatForCsv(con.Resolution))
|
||||
.Append(FormatForCsv(con.AutomaticResize))
|
||||
.Append(FormatForCsv(con.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.DisplayThemes))
|
||||
.Append(FormatForCsv(con.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.CacheBitmaps))
|
||||
.Append(FormatForCsv(con.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.RedirectPorts))
|
||||
.Append(FormatForCsv(con.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.RedirectClipboard))
|
||||
.Append(FormatForCsv(con.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.RedirectSound))
|
||||
.Append(FormatForCsv(con.RedirectKeys))
|
||||
.Append(FormatForCsv(con.PreExtApp))
|
||||
.Append(FormatForCsv(con.PostExtApp))
|
||||
.Append(FormatForCsv(con.MacAddress))
|
||||
.Append(FormatForCsv(con.UserField))
|
||||
.Append(FormatForCsv(con.ExtApp))
|
||||
.Append(FormatForCsv(con.VNCCompression))
|
||||
.Append(FormatForCsv(con.VNCEncoding))
|
||||
.Append(FormatForCsv(con.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.VNCProxyType))
|
||||
.Append(FormatForCsv(con.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.VNCColors))
|
||||
.Append(FormatForCsv(con.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.RDGatewayDomain));
|
||||
.Append(FormatForCsv(con.Protocol))
|
||||
.Append(FormatForCsv(con.PuttySession))
|
||||
.Append(FormatForCsv(con.Port))
|
||||
.Append(FormatForCsv(con.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.UseCredSsp))
|
||||
.Append(FormatForCsv(con.RenderingEngine))
|
||||
.Append(FormatForCsv(con.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Colors))
|
||||
.Append(FormatForCsv(con.Resolution))
|
||||
.Append(FormatForCsv(con.AutomaticResize))
|
||||
.Append(FormatForCsv(con.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.DisplayThemes))
|
||||
.Append(FormatForCsv(con.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.CacheBitmaps))
|
||||
.Append(FormatForCsv(con.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.RedirectPorts))
|
||||
.Append(FormatForCsv(con.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.RedirectClipboard))
|
||||
.Append(FormatForCsv(con.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.RedirectSound))
|
||||
.Append(FormatForCsv(con.RedirectKeys))
|
||||
.Append(FormatForCsv(con.PreExtApp))
|
||||
.Append(FormatForCsv(con.PostExtApp))
|
||||
.Append(FormatForCsv(con.MacAddress))
|
||||
.Append(FormatForCsv(con.UserField))
|
||||
.Append(FormatForCsv(con.ExtApp))
|
||||
.Append(FormatForCsv(con.VNCCompression))
|
||||
.Append(FormatForCsv(con.VNCEncoding))
|
||||
.Append(FormatForCsv(con.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.VNCProxyType))
|
||||
.Append(FormatForCsv(con.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.VNCColors))
|
||||
.Append(FormatForCsv(con.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.RDGatewayDomain));
|
||||
|
||||
|
||||
if (!_saveFilter.SaveInheritance)
|
||||
return;
|
||||
|
||||
sb.Append(FormatForCsv(con.Inheritance.CacheBitmaps))
|
||||
.Append(FormatForCsv(con.Inheritance.Colors))
|
||||
.Append(FormatForCsv(con.Inheritance.Description))
|
||||
.Append(FormatForCsv(con.Inheritance.DisplayThemes))
|
||||
.Append(FormatForCsv(con.Inheritance.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.Inheritance.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.Inheritance.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.Inheritance.Domain))
|
||||
.Append(FormatForCsv(con.Inheritance.Icon))
|
||||
.Append(FormatForCsv(con.Inheritance.Panel))
|
||||
.Append(FormatForCsv(con.Inheritance.Password))
|
||||
.Append(FormatForCsv(con.Inheritance.Port))
|
||||
.Append(FormatForCsv(con.Inheritance.Protocol))
|
||||
.Append(FormatForCsv(con.Inheritance.PuttySession))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectKeys))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPorts))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectClipboard))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSound))
|
||||
.Append(FormatForCsv(con.Inheritance.Resolution))
|
||||
.Append(FormatForCsv(con.Inheritance.AutomaticResize))
|
||||
.Append(FormatForCsv(con.Inheritance.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.Inheritance.UseCredSsp))
|
||||
.Append(FormatForCsv(con.Inheritance.RenderingEngine))
|
||||
.Append(FormatForCsv(con.Inheritance.Username))
|
||||
.Append(FormatForCsv(con.Inheritance.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.Inheritance.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Inheritance.PreExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.PostExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.MacAddress))
|
||||
.Append(FormatForCsv(con.Inheritance.UserField))
|
||||
.Append(FormatForCsv(con.Inheritance.ExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCCompression))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCEncoding))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyType))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCColors))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayDomain))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPAlertIdleTimeout))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPMinutesToIdleTimeout))
|
||||
.Append(FormatForCsv(con.Inheritance.SoundQuality));
|
||||
.Append(FormatForCsv(con.Inheritance.Colors))
|
||||
.Append(FormatForCsv(con.Inheritance.Description))
|
||||
.Append(FormatForCsv(con.Inheritance.DisplayThemes))
|
||||
.Append(FormatForCsv(con.Inheritance.DisplayWallpaper))
|
||||
.Append(FormatForCsv(con.Inheritance.EnableFontSmoothing))
|
||||
.Append(FormatForCsv(con.Inheritance.EnableDesktopComposition))
|
||||
.Append(FormatForCsv(con.Inheritance.Domain))
|
||||
.Append(FormatForCsv(con.Inheritance.Icon))
|
||||
.Append(FormatForCsv(con.Inheritance.Panel))
|
||||
.Append(FormatForCsv(con.Inheritance.Password))
|
||||
.Append(FormatForCsv(con.Inheritance.Port))
|
||||
.Append(FormatForCsv(con.Inheritance.Protocol))
|
||||
.Append(FormatForCsv(con.Inheritance.PuttySession))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectDiskDrives))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectKeys))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPorts))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectPrinters))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectClipboard))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSmartCards))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectSound))
|
||||
.Append(FormatForCsv(con.Inheritance.Resolution))
|
||||
.Append(FormatForCsv(con.Inheritance.AutomaticResize))
|
||||
.Append(FormatForCsv(con.Inheritance.UseConsoleSession))
|
||||
.Append(FormatForCsv(con.Inheritance.UseCredSsp))
|
||||
.Append(FormatForCsv(con.Inheritance.RenderingEngine))
|
||||
.Append(FormatForCsv(con.Inheritance.Username))
|
||||
.Append(FormatForCsv(con.Inheritance.ICAEncryptionStrength))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPAuthenticationLevel))
|
||||
.Append(FormatForCsv(con.Inheritance.LoadBalanceInfo))
|
||||
.Append(FormatForCsv(con.Inheritance.PreExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.PostExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.MacAddress))
|
||||
.Append(FormatForCsv(con.Inheritance.UserField))
|
||||
.Append(FormatForCsv(con.Inheritance.ExtApp))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCCompression))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCEncoding))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCAuthMode))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyType))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyIP))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyPort))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyUsername))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCProxyPassword))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCColors))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCSmartSizeMode))
|
||||
.Append(FormatForCsv(con.Inheritance.VNCViewOnly))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUsageMethod))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayHostname))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUseConnectionCredentials))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayUsername))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayPassword))
|
||||
.Append(FormatForCsv(con.Inheritance.RDGatewayDomain))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPAlertIdleTimeout))
|
||||
.Append(FormatForCsv(con.Inheritance.RDPMinutesToIdleTimeout))
|
||||
.Append(FormatForCsv(con.Inheritance.SoundQuality));
|
||||
}
|
||||
|
||||
private string FormatForCsv(object value)
|
||||
|
||||
@@ -54,20 +54,21 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
private ConnectionInfo DeserializeConnectionInfo(DataRow row)
|
||||
{
|
||||
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
PopulateConnectionInfoFromDatarow(row, connectionInfo);
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
private ContainerInfo DeserializeContainerInfo(DataRow row)
|
||||
{
|
||||
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var containerInfo = new ContainerInfo(containerId);
|
||||
PopulateConnectionInfoFromDatarow(row, containerInfo);
|
||||
return containerInfo;
|
||||
@@ -93,14 +94,22 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
connectionInfo.Port = (int)dataRow["Port"];
|
||||
connectionInfo.UseConsoleSession = (bool)dataRow["ConnectToConsole"];
|
||||
connectionInfo.UseCredSsp = (bool)dataRow["UseCredSsp"];
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine), (string)dataRow["RenderingEngine"]);
|
||||
connectionInfo.ICAEncryptionStrength = (IcaProtocol.EncryptionStrength)Enum.Parse(typeof(IcaProtocol.EncryptionStrength), (string)dataRow["ICAEncryptionStrength"]);
|
||||
connectionInfo.RDPAuthenticationLevel = (RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine),
|
||||
(string)dataRow["RenderingEngine"]);
|
||||
connectionInfo.ICAEncryptionStrength =
|
||||
(IcaProtocol.EncryptionStrength)Enum.Parse(typeof(IcaProtocol.EncryptionStrength),
|
||||
(string)dataRow["ICAEncryptionStrength"]);
|
||||
connectionInfo.RDPAuthenticationLevel =
|
||||
(RdpProtocol.AuthenticationLevel)Enum.Parse(typeof(RdpProtocol.AuthenticationLevel),
|
||||
(string)dataRow["RDPAuthenticationLevel"]);
|
||||
connectionInfo.RDPMinutesToIdleTimeout = (int)dataRow["RDPMinutesToIdleTimeout"];
|
||||
connectionInfo.RDPAlertIdleTimeout = (bool)dataRow["RDPAlertIdleTimeout"];
|
||||
connectionInfo.LoadBalanceInfo = (string)dataRow["LoadBalanceInfo"];
|
||||
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors) ,(string)dataRow["Colors"]);
|
||||
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), (string)dataRow["Resolution"]);
|
||||
connectionInfo.Colors =
|
||||
(RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), (string)dataRow["Colors"]);
|
||||
connectionInfo.Resolution =
|
||||
(RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions),
|
||||
(string)dataRow["Resolution"]);
|
||||
connectionInfo.AutomaticResize = (bool)dataRow["AutomaticResize"];
|
||||
connectionInfo.DisplayWallpaper = (bool)dataRow["DisplayWallpaper"];
|
||||
connectionInfo.DisplayThemes = (bool)dataRow["DisplayThemes"];
|
||||
@@ -112,28 +121,44 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
connectionInfo.RedirectPrinters = (bool)dataRow["RedirectPrinters"];
|
||||
connectionInfo.RedirectClipboard = (bool)dataRow["RedirectClipboard"];
|
||||
connectionInfo.RedirectSmartCards = (bool)dataRow["RedirectSmartCards"];
|
||||
connectionInfo.RedirectSound = (RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), (string)dataRow["RedirectSound"]);
|
||||
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality), (string)dataRow["SoundQuality"]);
|
||||
connectionInfo.RedirectSound =
|
||||
(RdpProtocol.RDPSounds)Enum.Parse(typeof(RdpProtocol.RDPSounds), (string)dataRow["RedirectSound"]);
|
||||
connectionInfo.SoundQuality = (RdpProtocol.RDPSoundQuality)Enum.Parse(typeof(RdpProtocol.RDPSoundQuality),
|
||||
(string)dataRow["SoundQuality"]);
|
||||
connectionInfo.RedirectKeys = (bool)dataRow["RedirectKeys"];
|
||||
connectionInfo.PreExtApp = (string)dataRow["PreExtApp"];
|
||||
connectionInfo.PostExtApp = (string)dataRow["PostExtApp"];
|
||||
connectionInfo.MacAddress = (string)dataRow["MacAddress"];
|
||||
connectionInfo.UserField = (string)dataRow["UserField"];
|
||||
connectionInfo.ExtApp = (string)dataRow["ExtApp"];
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression), (string)dataRow["VNCCompression"]);
|
||||
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding) ,(string)dataRow["VNCEncoding"]);
|
||||
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), (string)dataRow["VNCAuthMode"]);
|
||||
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), (string)dataRow["VNCProxyType"]);
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression),
|
||||
(string)dataRow["VNCCompression"]);
|
||||
connectionInfo.VNCEncoding =
|
||||
(ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding), (string)dataRow["VNCEncoding"]);
|
||||
connectionInfo.VNCAuthMode =
|
||||
(ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), (string)dataRow["VNCAuthMode"]);
|
||||
connectionInfo.VNCProxyType =
|
||||
(ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), (string)dataRow["VNCProxyType"]);
|
||||
connectionInfo.VNCProxyIP = (string)dataRow["VNCProxyIP"];
|
||||
connectionInfo.VNCProxyPort = (int)dataRow["VNCProxyPort"];
|
||||
connectionInfo.VNCProxyUsername = (string)dataRow["VNCProxyUsername"];
|
||||
connectionInfo.VNCProxyPassword = DecryptValue((string)dataRow["VNCProxyPassword"]);
|
||||
connectionInfo.VNCColors = (ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), (string)dataRow["VNCColors"]);
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), (string)dataRow["VNCSmartSizeMode"]);
|
||||
connectionInfo.VNCColors =
|
||||
(ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), (string)dataRow["VNCColors"]);
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode),
|
||||
(string)dataRow
|
||||
["VNCSmartSizeMode"]);
|
||||
connectionInfo.VNCViewOnly = (bool)dataRow["VNCViewOnly"];
|
||||
connectionInfo.RDGatewayUsageMethod = (RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
|
||||
connectionInfo.RDGatewayUsageMethod =
|
||||
(RdpProtocol.RDGatewayUsageMethod)Enum.Parse(typeof(RdpProtocol.RDGatewayUsageMethod),
|
||||
(string)dataRow["RDGatewayUsageMethod"]);
|
||||
connectionInfo.RDGatewayHostname = (string)dataRow["RDGatewayHostname"];
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = (RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RdpProtocol.RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
|
||||
connectionInfo.RDGatewayUseConnectionCredentials =
|
||||
(RdpProtocol.RDGatewayUseConnectionCredentials)Enum.Parse(
|
||||
typeof(RdpProtocol.
|
||||
RDGatewayUseConnectionCredentials),
|
||||
(string)dataRow
|
||||
["RDGatewayUseConnectionCredentials"]);
|
||||
connectionInfo.RDGatewayUsername = (string)dataRow["RDGatewayUsername"];
|
||||
connectionInfo.RDGatewayPassword = DecryptValue((string)dataRow["RDGatewayPassword"]);
|
||||
connectionInfo.RDGatewayDomain = (string)dataRow["RDGatewayDomain"];
|
||||
@@ -189,7 +214,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
connectionInfo.Inheritance.VNCViewOnly = (bool)dataRow["InheritVNCViewOnly"];
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod = (bool)dataRow["InheritRDGatewayUsageMethod"];
|
||||
connectionInfo.Inheritance.RDGatewayHostname = (bool)dataRow["InheritRDGatewayHostname"];
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials = (bool)dataRow["InheritRDGatewayUseConnectionCredentials"];
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials =
|
||||
(bool)dataRow["InheritRDGatewayUseConnectionCredentials"];
|
||||
connectionInfo.Inheritance.RDGatewayUsername = (bool)dataRow["InheritRDGatewayUsername"];
|
||||
connectionInfo.Inheritance.RDGatewayPassword = (bool)dataRow["InheritRDGatewayPassword"];
|
||||
connectionInfo.Inheritance.RDGatewayDomain = (bool)dataRow["InheritRDGatewayDomain"];
|
||||
@@ -219,14 +245,16 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
var id = (string) row["ConstantID"];
|
||||
var id = (string)row["ConstantID"];
|
||||
var connectionInfo = connectionList.First(node => node.ConstantID == id);
|
||||
var parentId = (string) row["ParentID"];
|
||||
var parentId = (string)row["ParentID"];
|
||||
if (parentId == "0" || connectionList.All(node => node.ConstantID != parentId))
|
||||
rootNode.AddChild(connectionInfo);
|
||||
else
|
||||
(connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo);
|
||||
(connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(
|
||||
connectionInfo);
|
||||
}
|
||||
|
||||
return connectionTreeModel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Security;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.MsSql
|
||||
{
|
||||
public class DataTableSerializer : ISerializer<ConnectionInfo,DataTable>
|
||||
public class DataTableSerializer : ISerializer<ConnectionInfo, DataTable>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
@@ -23,7 +23,9 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
|
||||
public Version Version { get; } = new Version(2, 7);
|
||||
|
||||
public DataTableSerializer(SaveFilter saveFilter, ICryptographyProvider cryptographyProvider, SecureString encryptionKey)
|
||||
public DataTableSerializer(SaveFilter saveFilter,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey)
|
||||
{
|
||||
_saveFilter = saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
@@ -190,7 +192,7 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
|
||||
private void SetPrimaryKey(DataTable dataTable)
|
||||
{
|
||||
dataTable.PrimaryKey = new[] { dataTable.Columns["ConstantID"] };
|
||||
dataTable.PrimaryKey = new[] {dataTable.Columns["ConstantID"]};
|
||||
}
|
||||
|
||||
private void SerializeNodesRecursive(ConnectionInfo connectionInfo)
|
||||
@@ -214,14 +216,15 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["ParentID"] = connectionInfo.Parent?.ConstantID ?? "";
|
||||
dataRow["PositionID"] = _currentNodeIndex;
|
||||
dataRow["LastChange"] = (SqlDateTime)DateTime.Now;
|
||||
dataRow["Expanded"] = false; // TODO: this column can eventually be removed. we now save this property locally
|
||||
dataRow["Expanded"] =
|
||||
false; // TODO: this column can eventually be removed. we now save this property locally
|
||||
dataRow["Description"] = connectionInfo.Description;
|
||||
dataRow["Icon"] = connectionInfo.Icon;
|
||||
dataRow["Panel"] = connectionInfo.Panel;
|
||||
dataRow["Username"] = _saveFilter.SaveUsername ? connectionInfo.Username : "";
|
||||
dataRow["DomainName"] = _saveFilter.SaveDomain ? connectionInfo.Domain : "";
|
||||
dataRow["Password"] = _saveFilter.SavePassword
|
||||
? _cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)
|
||||
dataRow["Password"] = _saveFilter.SavePassword
|
||||
? _cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)
|
||||
: "";
|
||||
dataRow["Hostname"] = connectionInfo.Hostname;
|
||||
dataRow["Protocol"] = connectionInfo.Protocol;
|
||||
@@ -251,7 +254,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["RedirectSound"] = connectionInfo.RedirectSound;
|
||||
dataRow["SoundQuality"] = connectionInfo.SoundQuality;
|
||||
dataRow["RedirectKeys"] = connectionInfo.RedirectKeys;
|
||||
dataRow["Connected"] = false; // TODO: this column can eventually be removed. we now save this property locally
|
||||
dataRow["Connected"] =
|
||||
false; // TODO: this column can eventually be removed. we now save this property locally
|
||||
dataRow["PreExtApp"] = connectionInfo.PreExtApp;
|
||||
dataRow["PostExtApp"] = connectionInfo.PostExtApp;
|
||||
dataRow["MacAddress"] = connectionInfo.MacAddress;
|
||||
@@ -264,14 +268,16 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["VNCProxyIP"] = connectionInfo.VNCProxyIP;
|
||||
dataRow["VNCProxyPort"] = connectionInfo.VNCProxyPort;
|
||||
dataRow["VNCProxyUsername"] = connectionInfo.VNCProxyUsername;
|
||||
dataRow["VNCProxyPassword"] = _cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey);
|
||||
dataRow["VNCProxyPassword"] =
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey);
|
||||
dataRow["VNCColors"] = connectionInfo.VNCColors;
|
||||
dataRow["VNCSmartSizeMode"] = connectionInfo.VNCSmartSizeMode;
|
||||
dataRow["VNCViewOnly"] = connectionInfo.VNCViewOnly;
|
||||
dataRow["RDGatewayUsageMethod"] = connectionInfo.RDGatewayUsageMethod;
|
||||
dataRow["RDGatewayHostname"] = connectionInfo.RDGatewayHostname;
|
||||
dataRow["RDGatewayUseConnectionCredentials"] = connectionInfo.RDGatewayUseConnectionCredentials;
|
||||
dataRow["RDGatewayUsername"] = _cryptographyProvider.Encrypt(connectionInfo.RDGatewayUsername, _encryptionKey);
|
||||
dataRow["RDGatewayUsername"] =
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayUsername, _encryptionKey);
|
||||
dataRow["RDGatewayPassword"] = connectionInfo.RDGatewayPassword;
|
||||
dataRow["RDGatewayDomain"] = connectionInfo.RDGatewayDomain;
|
||||
if (_saveFilter.SaveInheritance)
|
||||
@@ -327,7 +333,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["InheritVNCViewOnly"] = connectionInfo.Inheritance.VNCViewOnly;
|
||||
dataRow["InheritRDGatewayUsageMethod"] = connectionInfo.Inheritance.RDGatewayUsageMethod;
|
||||
dataRow["InheritRDGatewayHostname"] = connectionInfo.Inheritance.RDGatewayHostname;
|
||||
dataRow["InheritRDGatewayUseConnectionCredentials"] = connectionInfo.Inheritance.RDGatewayUseConnectionCredentials;
|
||||
dataRow["InheritRDGatewayUseConnectionCredentials"] =
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials;
|
||||
dataRow["InheritRDGatewayUsername"] = connectionInfo.Inheritance.RDGatewayUsername;
|
||||
dataRow["InheritRDGatewayPassword"] = connectionInfo.Inheritance.RDGatewayPassword;
|
||||
dataRow["InheritRDGatewayDomain"] = connectionInfo.Inheritance.RDGatewayDomain;
|
||||
@@ -390,6 +397,7 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
dataRow["InheritRDGatewayPassword"] = false;
|
||||
dataRow["InheritRDGatewayDomain"] = false;
|
||||
}
|
||||
|
||||
_dataTable.Rows.Add(dataRow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/// </summary>
|
||||
public bool Expanded { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ using System.Xml.Linq;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.MsSql
|
||||
{
|
||||
public class LocalConnectionPropertiesXmlSerializer :
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>,
|
||||
public class LocalConnectionPropertiesXmlSerializer :
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>,
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>>
|
||||
{
|
||||
public Version Version { get; } = new Version(1, 0);
|
||||
@@ -17,10 +17,10 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
public string Serialize(IEnumerable<LocalConnectionPropertiesModel> models)
|
||||
{
|
||||
var localConnections = models
|
||||
.Select(m => new XElement("Node",
|
||||
new XAttribute("ConnectionId", m.ConnectionId),
|
||||
new XAttribute("Connected", m.Connected),
|
||||
new XAttribute("Expanded", m.Expanded)));
|
||||
.Select(m => new XElement("Node",
|
||||
new XAttribute("ConnectionId", m.ConnectionId),
|
||||
new XAttribute("Connected", m.Connected),
|
||||
new XAttribute("Expanded", m.Expanded)));
|
||||
|
||||
var root = new XElement("LocalConnections", localConnections);
|
||||
var xdoc = new XDocument(new XDeclaration("1.0", "utf-8", null), root);
|
||||
@@ -34,20 +34,21 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
|
||||
var xdoc = XDocument.Parse(serializedData);
|
||||
return xdoc
|
||||
.Descendants("Node")
|
||||
.Where(e => e.Attribute("ConnectionId") != null)
|
||||
.Select(e => new LocalConnectionPropertiesModel
|
||||
{
|
||||
ConnectionId = e.Attribute("ConnectionId")?.Value,
|
||||
Connected = bool.Parse(e.Attribute("Connected")?.Value ?? "False"),
|
||||
Expanded = bool.Parse(e.Attribute("Expanded")?.Value ?? "False")
|
||||
});
|
||||
.Descendants("Node")
|
||||
.Where(e => e.Attribute("ConnectionId") != null)
|
||||
.Select(e => new LocalConnectionPropertiesModel
|
||||
{
|
||||
ConnectionId = e.Attribute("ConnectionId")?.Value,
|
||||
Connected = bool.Parse(e.Attribute("Connected")?.Value ?? "False"),
|
||||
Expanded = bool.Parse(e.Attribute("Expanded")?.Value ?? "False")
|
||||
});
|
||||
}
|
||||
|
||||
private static string WriteXmlToString(XNode xmlDocument)
|
||||
{
|
||||
string xmlString;
|
||||
var xmlWriterSettings = new XmlWriterSettings { Indent = true, IndentChars = " ", Encoding = Encoding.UTF8 };
|
||||
var xmlWriterSettings = new XmlWriterSettings
|
||||
{Indent = true, IndentChars = " ", Encoding = Encoding.UTF8};
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var xmlTextWriter = XmlWriter.Create(memoryStream, xmlWriterSettings))
|
||||
{
|
||||
@@ -57,7 +58,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
xmlString = streamReader.ReadToEnd();
|
||||
}
|
||||
|
||||
return xmlString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,4 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
public bool Export { get; set; }
|
||||
public Version ConfVersion { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,8 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
Name = sqlDataReader["Name"] as string ?? "",
|
||||
Protected = sqlDataReader["Protected"] as string ?? "",
|
||||
Export = (bool)sqlDataReader["Export"],
|
||||
ConfVersion = new Version(Convert.ToString(sqlDataReader["confVersion"], CultureInfo.InvariantCulture))
|
||||
ConfVersion =
|
||||
new Version(Convert.ToString(sqlDataReader["confVersion"], CultureInfo.InvariantCulture))
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -42,6 +43,7 @@ namespace mRemoteNG.Config.Serializers.MsSql
|
||||
if (sqlDataReader != null && !sqlDataReader.IsClosed)
|
||||
sqlDataReader.Close();
|
||||
}
|
||||
|
||||
return metaData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Xml.Linq;
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class XmlConnectionNodeSerializer26 : ISerializer<ConnectionInfo,XElement>
|
||||
public class XmlConnectionNodeSerializer26 : ISerializer<ConnectionInfo, XElement>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
@@ -16,7 +16,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
public Version Version { get; } = new Version(2, 6);
|
||||
|
||||
public XmlConnectionNodeSerializer26(ICryptographyProvider cryptographyProvider, SecureString encryptionKey, SaveFilter saveFilter)
|
||||
public XmlConnectionNodeSerializer26(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter)
|
||||
{
|
||||
if (cryptographyProvider == null)
|
||||
throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
@@ -51,15 +53,16 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("Id", connectionInfo.ConstantID));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("Username", connectionInfo.Username)
|
||||
: new XAttribute("Username", ""));
|
||||
? new XAttribute("Username", connectionInfo.Username)
|
||||
: new XAttribute("Username", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("Domain", connectionInfo.Domain)
|
||||
: new XAttribute("Domain", ""));
|
||||
? new XAttribute("Domain", connectionInfo.Domain)
|
||||
: new XAttribute("Domain", ""));
|
||||
|
||||
if (_saveFilter.SavePassword && !connectionInfo.Inheritance.Password)
|
||||
element.Add(new XAttribute("Password", _cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)));
|
||||
element.Add(new XAttribute("Password",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)));
|
||||
else
|
||||
element.Add(new XAttribute("Password", ""));
|
||||
|
||||
@@ -67,31 +70,42 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
|
||||
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
|
||||
element.Add(new XAttribute("Port", connectionInfo.Port));
|
||||
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("ConnectToConsole",
|
||||
connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RenderingEngine", connectionInfo.RenderingEngine));
|
||||
element.Add(new XAttribute("ICAEncryptionStrength", connectionInfo.ICAEncryptionStrength));
|
||||
element.Add(new XAttribute("RDPAuthenticationLevel", connectionInfo.RDPAuthenticationLevel));
|
||||
element.Add(new XAttribute("RDPMinutesToIdleTimeout", connectionInfo.RDPMinutesToIdleTimeout));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout",
|
||||
connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("LoadBalanceInfo", connectionInfo.LoadBalanceInfo));
|
||||
element.Add(new XAttribute("Colors", connectionInfo.Colors));
|
||||
element.Add(new XAttribute("Resolution", connectionInfo.Resolution));
|
||||
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("AutomaticResize",
|
||||
connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper",
|
||||
connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing",
|
||||
connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition",
|
||||
connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives",
|
||||
connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard", connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters",
|
||||
connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard",
|
||||
connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards",
|
||||
connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString()));
|
||||
element.Add(new XAttribute("SoundQuality", connectionInfo.SoundQuality.ToString()));
|
||||
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected",
|
||||
(connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("PreExtApp", connectionInfo.PreExtApp));
|
||||
element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp));
|
||||
element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress));
|
||||
@@ -105,93 +119,163 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("VNCProxyPort", connectionInfo.VNCProxyPort));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
|
||||
element.Add(new XAttribute("VNCColors", connectionInfo.VNCColors));
|
||||
element.Add(new XAttribute("VNCSmartSizeMode", connectionInfo.VNCSmartSizeMode));
|
||||
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDGatewayUsageMethod", connectionInfo.RDGatewayUsageMethod));
|
||||
element.Add(new XAttribute("RDGatewayHostname", connectionInfo.RDGatewayHostname));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials", connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials",
|
||||
connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword, _encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
}
|
||||
|
||||
private void SetInheritanceAttributes(XContainer element, IInheritable connectionInfo)
|
||||
{
|
||||
if (_saveFilter.SaveInheritance)
|
||||
{
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritCacheBitmaps",
|
||||
connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors",
|
||||
connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription",
|
||||
connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes",
|
||||
connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper",
|
||||
connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing",
|
||||
connectionInfo
|
||||
.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition",
|
||||
connectionInfo
|
||||
.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain",
|
||||
connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(
|
||||
new XAttribute("InheritIcon",
|
||||
connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel",
|
||||
connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword",
|
||||
connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(
|
||||
new XAttribute("InheritPort",
|
||||
connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol",
|
||||
connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession",
|
||||
connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives",
|
||||
connectionInfo
|
||||
.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys",
|
||||
connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts",
|
||||
connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters",
|
||||
connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards",
|
||||
connectionInfo
|
||||
.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound",
|
||||
connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality",
|
||||
connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution",
|
||||
connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize",
|
||||
connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession",
|
||||
connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp",
|
||||
connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine",
|
||||
connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername",
|
||||
connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength",
|
||||
connectionInfo
|
||||
.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel",
|
||||
connectionInfo
|
||||
.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout",
|
||||
connectionInfo
|
||||
.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout",
|
||||
connectionInfo
|
||||
.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo",
|
||||
connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp",
|
||||
connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp",
|
||||
connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress",
|
||||
connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField",
|
||||
connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp",
|
||||
connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression",
|
||||
connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding",
|
||||
connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode",
|
||||
connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType",
|
||||
connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP",
|
||||
connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort",
|
||||
connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername",
|
||||
connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword",
|
||||
connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors",
|
||||
connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode",
|
||||
connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly",
|
||||
connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod",
|
||||
connectionInfo
|
||||
.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname",
|
||||
connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials",
|
||||
connectionInfo
|
||||
.Inheritance.RDGatewayUseConnectionCredentials.ToString()
|
||||
.ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername",
|
||||
connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword",
|
||||
connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain",
|
||||
connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -213,7 +297,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSound", falseString));
|
||||
element.Add(new XAttribute("InheritSoundQuality", falseString));
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Xml.Linq;
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class XmlConnectionNodeSerializer27 : ISerializer<ConnectionInfo,XElement>
|
||||
public class XmlConnectionNodeSerializer27 : ISerializer<ConnectionInfo, XElement>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
@@ -17,7 +17,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
public Version Version { get; } = new Version(2, 7);
|
||||
|
||||
public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider, SecureString encryptionKey, SaveFilter saveFilter)
|
||||
public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter)
|
||||
{
|
||||
if (cryptographyProvider == null)
|
||||
throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
@@ -54,15 +56,16 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
if (!Runtime.UseCredentialManager)
|
||||
{
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("Username", connectionInfo.Username)
|
||||
: new XAttribute("Username", ""));
|
||||
? new XAttribute("Username", connectionInfo.Username)
|
||||
: new XAttribute("Username", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("Domain", connectionInfo.Domain)
|
||||
: new XAttribute("Domain", ""));
|
||||
? new XAttribute("Domain", connectionInfo.Domain)
|
||||
: new XAttribute("Domain", ""));
|
||||
|
||||
if (_saveFilter.SavePassword && !connectionInfo.Inheritance.Password)
|
||||
element.Add(new XAttribute("Password", _cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)));
|
||||
element.Add(new XAttribute("Password",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.Password, _encryptionKey)));
|
||||
else
|
||||
element.Add(new XAttribute("Password", ""));
|
||||
}
|
||||
@@ -71,31 +74,42 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
|
||||
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
|
||||
element.Add(new XAttribute("Port", connectionInfo.Port));
|
||||
element.Add(new XAttribute("ConnectToConsole", connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("ConnectToConsole",
|
||||
connectionInfo.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("UseCredSsp", connectionInfo.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RenderingEngine", connectionInfo.RenderingEngine));
|
||||
element.Add(new XAttribute("ICAEncryptionStrength", connectionInfo.ICAEncryptionStrength));
|
||||
element.Add(new XAttribute("RDPAuthenticationLevel", connectionInfo.RDPAuthenticationLevel));
|
||||
element.Add(new XAttribute("RDPMinutesToIdleTimeout", connectionInfo.RDPMinutesToIdleTimeout));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout", connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDPAlertIdleTimeout",
|
||||
connectionInfo.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("LoadBalanceInfo", connectionInfo.LoadBalanceInfo));
|
||||
element.Add(new XAttribute("Colors", connectionInfo.Colors));
|
||||
element.Add(new XAttribute("Resolution", connectionInfo.Resolution));
|
||||
element.Add(new XAttribute("AutomaticResize", connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper", connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("AutomaticResize",
|
||||
connectionInfo.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayWallpaper",
|
||||
connectionInfo.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("DisplayThemes", connectionInfo.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing", connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition", connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableFontSmoothing",
|
||||
connectionInfo.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("EnableDesktopComposition",
|
||||
connectionInfo.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("CacheBitmaps", connectionInfo.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives", connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectDiskDrives",
|
||||
connectionInfo.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPorts", connectionInfo.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters", connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard", connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards", connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectPrinters",
|
||||
connectionInfo.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectClipboard",
|
||||
connectionInfo.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSmartCards",
|
||||
connectionInfo.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RedirectSound", connectionInfo.RedirectSound.ToString()));
|
||||
element.Add(new XAttribute("SoundQuality", connectionInfo.SoundQuality.ToString()));
|
||||
element.Add(new XAttribute("RedirectKeys", connectionInfo.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected", (connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("Connected",
|
||||
(connectionInfo.OpenConnections.Count > 0).ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("PreExtApp", connectionInfo.PreExtApp));
|
||||
element.Add(new XAttribute("PostExtApp", connectionInfo.PostExtApp));
|
||||
element.Add(new XAttribute("MacAddress", connectionInfo.MacAddress));
|
||||
@@ -109,94 +123,165 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("VNCProxyPort", connectionInfo.VNCProxyPort));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
? new XAttribute("VNCProxyUsername", connectionInfo.VNCProxyUsername)
|
||||
: new XAttribute("VNCProxyUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword, _encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
? new XAttribute("VNCProxyPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.VNCProxyPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("VNCProxyPassword", ""));
|
||||
|
||||
element.Add(new XAttribute("VNCColors", connectionInfo.VNCColors));
|
||||
element.Add(new XAttribute("VNCSmartSizeMode", connectionInfo.VNCSmartSizeMode));
|
||||
element.Add(new XAttribute("VNCViewOnly", connectionInfo.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("RDGatewayUsageMethod", connectionInfo.RDGatewayUsageMethod));
|
||||
element.Add(new XAttribute("RDGatewayHostname", connectionInfo.RDGatewayHostname));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials", connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
element.Add(new XAttribute("RDGatewayUseConnectionCredentials",
|
||||
connectionInfo.RDGatewayUseConnectionCredentials));
|
||||
|
||||
element.Add(_saveFilter.SaveUsername
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
? new XAttribute("RDGatewayUsername", connectionInfo.RDGatewayUsername)
|
||||
: new XAttribute("RDGatewayUsername", ""));
|
||||
|
||||
element.Add(_saveFilter.SavePassword
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword, _encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
? new XAttribute("RDGatewayPassword",
|
||||
_cryptographyProvider.Encrypt(connectionInfo.RDGatewayPassword,
|
||||
_encryptionKey))
|
||||
: new XAttribute("RDGatewayPassword", ""));
|
||||
|
||||
element.Add(_saveFilter.SaveDomain
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
? new XAttribute("RDGatewayDomain", connectionInfo.RDGatewayDomain)
|
||||
: new XAttribute("RDGatewayDomain", ""));
|
||||
}
|
||||
|
||||
private void SetInheritanceAttributes(XContainer element, IInheritable connectionInfo)
|
||||
{
|
||||
if (_saveFilter.SaveInheritance)
|
||||
{
|
||||
element.Add(new XAttribute("InheritCacheBitmaps", connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors", connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription", connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes", connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper", connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing", connectionInfo.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition", connectionInfo.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain", connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritIcon", connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel", connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword", connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPort", connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol", connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession", connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", connectionInfo.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard", connectionInfo.Inheritance.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", connectionInfo.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound", connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality", connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution", connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize", connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession", connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp", connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine", connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername", connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength", connectionInfo.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel", connectionInfo.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout", connectionInfo.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout", connectionInfo.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo", connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp", connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp", connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress", connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField", connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp", connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression", connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding", connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode", connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType", connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP", connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort", connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername", connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword", connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors", connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode", connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly", connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod", connectionInfo.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname", connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials", connectionInfo.Inheritance.RDGatewayUseConnectionCredentials.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername", connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword", connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain", connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritCacheBitmaps",
|
||||
connectionInfo.Inheritance.CacheBitmaps.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritColors",
|
||||
connectionInfo.Inheritance.Colors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDescription",
|
||||
connectionInfo.Inheritance.Description.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayThemes",
|
||||
connectionInfo.Inheritance.DisplayThemes.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDisplayWallpaper",
|
||||
connectionInfo.Inheritance.DisplayWallpaper.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableFontSmoothing",
|
||||
connectionInfo
|
||||
.Inheritance.EnableFontSmoothing.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritEnableDesktopComposition",
|
||||
connectionInfo
|
||||
.Inheritance.EnableDesktopComposition.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritDomain",
|
||||
connectionInfo.Inheritance.Domain.ToString().ToLowerInvariant()));
|
||||
element.Add(
|
||||
new XAttribute("InheritIcon",
|
||||
connectionInfo.Inheritance.Icon.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPanel",
|
||||
connectionInfo.Inheritance.Panel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPassword",
|
||||
connectionInfo.Inheritance.Password.ToString().ToLowerInvariant()));
|
||||
element.Add(
|
||||
new XAttribute("InheritPort",
|
||||
connectionInfo.Inheritance.Port.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritProtocol",
|
||||
connectionInfo.Inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPuttySession",
|
||||
connectionInfo.Inheritance.PuttySession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives",
|
||||
connectionInfo
|
||||
.Inheritance.RedirectDiskDrives.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectKeys",
|
||||
connectionInfo.Inheritance.RedirectKeys.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPorts",
|
||||
connectionInfo.Inheritance.RedirectPorts.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters",
|
||||
connectionInfo.Inheritance.RedirectPrinters.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard",
|
||||
connectionInfo.Inheritance.RedirectClipboard.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards",
|
||||
connectionInfo
|
||||
.Inheritance.RedirectSmartCards.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRedirectSound",
|
||||
connectionInfo.Inheritance.RedirectSound.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritSoundQuality",
|
||||
connectionInfo.Inheritance.SoundQuality.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritResolution",
|
||||
connectionInfo.Inheritance.Resolution.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritAutomaticResize",
|
||||
connectionInfo.Inheritance.AutomaticResize.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseConsoleSession",
|
||||
connectionInfo.Inheritance.UseConsoleSession.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUseCredSsp",
|
||||
connectionInfo.Inheritance.UseCredSsp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRenderingEngine",
|
||||
connectionInfo.Inheritance.RenderingEngine.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUsername",
|
||||
connectionInfo.Inheritance.Username.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritICAEncryptionStrength",
|
||||
connectionInfo
|
||||
.Inheritance.ICAEncryptionStrength.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAuthenticationLevel",
|
||||
connectionInfo
|
||||
.Inheritance.RDPAuthenticationLevel.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPMinutesToIdleTimeout",
|
||||
connectionInfo
|
||||
.Inheritance.RDPMinutesToIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDPAlertIdleTimeout",
|
||||
connectionInfo
|
||||
.Inheritance.RDPAlertIdleTimeout.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritLoadBalanceInfo",
|
||||
connectionInfo.Inheritance.LoadBalanceInfo.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPreExtApp",
|
||||
connectionInfo.Inheritance.PreExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritPostExtApp",
|
||||
connectionInfo.Inheritance.PostExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritMacAddress",
|
||||
connectionInfo.Inheritance.MacAddress.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritUserField",
|
||||
connectionInfo.Inheritance.UserField.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritExtApp",
|
||||
connectionInfo.Inheritance.ExtApp.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCCompression",
|
||||
connectionInfo.Inheritance.VNCCompression.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCEncoding",
|
||||
connectionInfo.Inheritance.VNCEncoding.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCAuthMode",
|
||||
connectionInfo.Inheritance.VNCAuthMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyType",
|
||||
connectionInfo.Inheritance.VNCProxyType.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyIP",
|
||||
connectionInfo.Inheritance.VNCProxyIP.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPort",
|
||||
connectionInfo.Inheritance.VNCProxyPort.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyUsername",
|
||||
connectionInfo.Inheritance.VNCProxyUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCProxyPassword",
|
||||
connectionInfo.Inheritance.VNCProxyPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCColors",
|
||||
connectionInfo.Inheritance.VNCColors.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCSmartSizeMode",
|
||||
connectionInfo.Inheritance.VNCSmartSizeMode.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritVNCViewOnly",
|
||||
connectionInfo.Inheritance.VNCViewOnly.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsageMethod",
|
||||
connectionInfo
|
||||
.Inheritance.RDGatewayUsageMethod.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayHostname",
|
||||
connectionInfo.Inheritance.RDGatewayHostname.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUseConnectionCredentials",
|
||||
connectionInfo
|
||||
.Inheritance.RDGatewayUseConnectionCredentials.ToString()
|
||||
.ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayUsername",
|
||||
connectionInfo.Inheritance.RDGatewayUsername.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayPassword",
|
||||
connectionInfo.Inheritance.RDGatewayPassword.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("InheritRDGatewayDomain",
|
||||
connectionInfo.Inheritance.RDGatewayDomain.ToString().ToLowerInvariant()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -218,8 +303,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
element.Add(new XAttribute("InheritRedirectDiskDrives", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectKeys", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPorts", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectPrinters", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectClipboard", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSmartCards", falseString));
|
||||
element.Add(new XAttribute("InheritRedirectSound", falseString));
|
||||
element.Add(new XAttribute("InheritSoundQuality", falseString));
|
||||
|
||||
@@ -56,11 +56,12 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
connectionTreeModel.AddRootNode(_rootNodeInfo);
|
||||
|
||||
|
||||
|
||||
if (_confVersion > 1.3)
|
||||
{
|
||||
var protectedString = _xmlDocument.DocumentElement?.Attributes["Protected"].Value;
|
||||
if (!_decryptor.ConnectionsFileIsAuthentic(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()))
|
||||
if (!_decryptor.ConnectionsFileIsAuthentic(protectedString,
|
||||
_rootNodeInfo.PasswordString.ConvertToSecureString()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -103,7 +104,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private void ValidateConnectionFileVersion()
|
||||
{
|
||||
if (_xmlDocument.DocumentElement != null && _xmlDocument.DocumentElement.HasAttribute("ConfVersion"))
|
||||
_confVersion = Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"].Value.Replace(",", "."), CultureInfo.InvariantCulture);
|
||||
_confVersion =
|
||||
Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"].Value.Replace(",", "."),
|
||||
CultureInfo.InvariantCulture);
|
||||
else
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strOldConffile);
|
||||
|
||||
@@ -115,19 +118,22 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private void ShowIncompatibleVersionDialogBox()
|
||||
{
|
||||
CTaskDialog.ShowTaskDialogBox(
|
||||
FrmMain.Default,
|
||||
Application.ProductName,
|
||||
"Incompatible connection file format",
|
||||
$"The format of this connection file is not supported. Please upgrade to a newer version of {Application.ProductName}.",
|
||||
string.Format("{1}{0}File Format Version: {2}{0}Highest Supported Version: {3}", Environment.NewLine, ConnectionFileName, _confVersion, MaxSupportedConfVersion),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
ETaskDialogButtons.Ok,
|
||||
ESysIcons.Error,
|
||||
ESysIcons.Error
|
||||
);
|
||||
FrmMain.Default,
|
||||
Application.ProductName,
|
||||
"Incompatible connection file format",
|
||||
$"The format of this connection file is not supported. Please upgrade to a newer version of {Application.ProductName}.",
|
||||
string
|
||||
.Format("{1}{0}File Format Version: {2}{0}Highest Supported Version: {3}",
|
||||
Environment.NewLine,
|
||||
ConnectionFileName, _confVersion, MaxSupportedConfVersion),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
ETaskDialogButtons.Ok,
|
||||
ESysIcons.Error,
|
||||
ESysIcons.Error
|
||||
);
|
||||
}
|
||||
|
||||
private void InitializeRootNode(XmlElement connectionsRootElement)
|
||||
@@ -152,7 +158,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
}
|
||||
else
|
||||
{
|
||||
_decryptor = new XmlConnectionsDecryptor(_rootNodeInfo) { AuthenticationRequestor = AuthenticationRequestor };
|
||||
_decryptor = new XmlConnectionsDecryptor(_rootNodeInfo)
|
||||
{AuthenticationRequestor = AuthenticationRequestor};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +181,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
break;
|
||||
case TreeNodeType.Container:
|
||||
var containerInfo = new ContainerInfo();
|
||||
|
||||
|
||||
if (_confVersion >= 0.9)
|
||||
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode));
|
||||
if (_confVersion >= 0.8)
|
||||
@@ -200,10 +207,10 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
if (xmlnode?.Attributes == null)
|
||||
return null;
|
||||
|
||||
var connectionId = xmlnode.GetAttributeAsString("Id");
|
||||
var connectionId = xmlnode.GetAttributeAsString("Id");
|
||||
if (string.IsNullOrWhiteSpace(connectionId))
|
||||
connectionId = Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -258,7 +265,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
if (_confVersion < 0.7)
|
||||
{
|
||||
connectionInfo.Port = xmlnode.GetAttributeAsBool("UseVNC")
|
||||
connectionInfo.Port = xmlnode.GetAttributeAsBool("UseVNC")
|
||||
? xmlnode.GetAttributeAsInt("VNCPort")
|
||||
: xmlnode.GetAttributeAsInt("RDPPort");
|
||||
}
|
||||
@@ -274,6 +281,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
else
|
||||
connectionInfo.Port = (int)RdpProtocol.Defaults.Port;
|
||||
}
|
||||
|
||||
connectionInfo.UseConsoleSession = false;
|
||||
}
|
||||
|
||||
@@ -287,7 +295,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
else
|
||||
{
|
||||
connectionInfo.RedirectDiskDrives = false;
|
||||
connectionInfo.RedirectPrinters = false;
|
||||
connectionInfo.RedirectPrinters = false;
|
||||
connectionInfo.RedirectPorts = false;
|
||||
connectionInfo.RedirectSmartCards = false;
|
||||
}
|
||||
@@ -352,14 +360,17 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
connectionInfo.Inheritance.Port = xmlnode.GetAttributeAsBool("InheritPort");
|
||||
connectionInfo.Inheritance.Protocol = xmlnode.GetAttributeAsBool("InheritProtocol");
|
||||
connectionInfo.Inheritance.PuttySession = xmlnode.GetAttributeAsBool("InheritPuttySession");
|
||||
connectionInfo.Inheritance.RedirectDiskDrives = xmlnode.GetAttributeAsBool("InheritRedirectDiskDrives");
|
||||
connectionInfo.Inheritance.RedirectDiskDrives =
|
||||
xmlnode.GetAttributeAsBool("InheritRedirectDiskDrives");
|
||||
connectionInfo.Inheritance.RedirectKeys = xmlnode.GetAttributeAsBool("InheritRedirectKeys");
|
||||
connectionInfo.Inheritance.RedirectPorts = xmlnode.GetAttributeAsBool("InheritRedirectPorts");
|
||||
connectionInfo.Inheritance.RedirectPrinters = xmlnode.GetAttributeAsBool("InheritRedirectPrinters");
|
||||
connectionInfo.Inheritance.RedirectSmartCards = xmlnode.GetAttributeAsBool("InheritRedirectSmartCards");
|
||||
connectionInfo.Inheritance.RedirectSmartCards =
|
||||
xmlnode.GetAttributeAsBool("InheritRedirectSmartCards");
|
||||
connectionInfo.Inheritance.RedirectSound = xmlnode.GetAttributeAsBool("InheritRedirectSound");
|
||||
connectionInfo.Inheritance.Resolution = xmlnode.GetAttributeAsBool("InheritResolution");
|
||||
connectionInfo.Inheritance.UseConsoleSession = xmlnode.GetAttributeAsBool("InheritUseConsoleSession");
|
||||
connectionInfo.Inheritance.UseConsoleSession =
|
||||
xmlnode.GetAttributeAsBool("InheritUseConsoleSession");
|
||||
|
||||
if (!Runtime.UseCredentialManager || _confVersion <= 2.6) // 1.3 - 2.6
|
||||
{
|
||||
@@ -367,6 +378,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
connectionInfo.Inheritance.Password = xmlnode.GetAttributeAsBool("InheritPassword");
|
||||
connectionInfo.Inheritance.Username = xmlnode.GetAttributeAsBool("InheritUsername");
|
||||
}
|
||||
|
||||
connectionInfo.Icon = xmlnode.GetAttributeAsString("Icon");
|
||||
connectionInfo.Panel = xmlnode.GetAttributeAsString("Panel");
|
||||
}
|
||||
@@ -385,8 +397,10 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 1.6)
|
||||
{
|
||||
connectionInfo.ICAEncryptionStrength = xmlnode.GetAttributeAsEnum<IcaProtocol.EncryptionStrength>("ICAEncryptionStrength");
|
||||
connectionInfo.Inheritance.ICAEncryptionStrength = xmlnode.GetAttributeAsBool("InheritICAEncryptionStrength");
|
||||
connectionInfo.ICAEncryptionStrength =
|
||||
xmlnode.GetAttributeAsEnum<IcaProtocol.EncryptionStrength>("ICAEncryptionStrength");
|
||||
connectionInfo.Inheritance.ICAEncryptionStrength =
|
||||
xmlnode.GetAttributeAsBool("InheritICAEncryptionStrength");
|
||||
connectionInfo.PreExtApp = xmlnode.GetAttributeAsString("PreExtApp");
|
||||
connectionInfo.PostExtApp = xmlnode.GetAttributeAsString("PostExtApp");
|
||||
connectionInfo.Inheritance.PreExtApp = xmlnode.GetAttributeAsBool("InheritPreExtApp");
|
||||
@@ -395,16 +409,19 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 1.7)
|
||||
{
|
||||
connectionInfo.VNCCompression = xmlnode.GetAttributeAsEnum<ProtocolVNC.Compression>("VNCCompression");
|
||||
connectionInfo.VNCCompression =
|
||||
xmlnode.GetAttributeAsEnum<ProtocolVNC.Compression>("VNCCompression");
|
||||
connectionInfo.VNCEncoding = xmlnode.GetAttributeAsEnum<ProtocolVNC.Encoding>("VNCEncoding");
|
||||
connectionInfo.VNCAuthMode = xmlnode.GetAttributeAsEnum<ProtocolVNC.AuthMode>("VNCAuthMode");
|
||||
connectionInfo.VNCProxyType = xmlnode.GetAttributeAsEnum<ProtocolVNC.ProxyType>("VNCProxyType");
|
||||
connectionInfo.VNCProxyIP = xmlnode.GetAttributeAsString("VNCProxyIP");
|
||||
connectionInfo.VNCProxyPort = xmlnode.GetAttributeAsInt("VNCProxyPort");
|
||||
connectionInfo.VNCProxyUsername = xmlnode.GetAttributeAsString("VNCProxyUsername");
|
||||
connectionInfo.VNCProxyPassword = _decryptor.Decrypt(xmlnode.GetAttributeAsString("VNCProxyPassword"));
|
||||
connectionInfo.VNCProxyPassword =
|
||||
_decryptor.Decrypt(xmlnode.GetAttributeAsString("VNCProxyPassword"));
|
||||
connectionInfo.VNCColors = xmlnode.GetAttributeAsEnum<ProtocolVNC.Colors>("VNCColors");
|
||||
connectionInfo.VNCSmartSizeMode = xmlnode.GetAttributeAsEnum<ProtocolVNC.SmartSizeMode>("VNCSmartSizeMode");
|
||||
connectionInfo.VNCSmartSizeMode =
|
||||
xmlnode.GetAttributeAsEnum<ProtocolVNC.SmartSizeMode>("VNCSmartSizeMode");
|
||||
connectionInfo.VNCViewOnly = xmlnode.GetAttributeAsBool("VNCViewOnly");
|
||||
connectionInfo.Inheritance.VNCCompression = xmlnode.GetAttributeAsBool("InheritVNCCompression");
|
||||
connectionInfo.Inheritance.VNCEncoding = xmlnode.GetAttributeAsBool("InheritVNCEncoding");
|
||||
@@ -421,13 +438,16 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 1.8)
|
||||
{
|
||||
connectionInfo.RDPAuthenticationLevel = xmlnode.GetAttributeAsEnum<RdpProtocol.AuthenticationLevel>("RDPAuthenticationLevel");
|
||||
connectionInfo.Inheritance.RDPAuthenticationLevel = xmlnode.GetAttributeAsBool("InheritRDPAuthenticationLevel");
|
||||
connectionInfo.RDPAuthenticationLevel =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.AuthenticationLevel>("RDPAuthenticationLevel");
|
||||
connectionInfo.Inheritance.RDPAuthenticationLevel =
|
||||
xmlnode.GetAttributeAsBool("InheritRDPAuthenticationLevel");
|
||||
}
|
||||
|
||||
if (_confVersion >= 1.9)
|
||||
{
|
||||
connectionInfo.RenderingEngine = xmlnode.GetAttributeAsEnum<HTTPBase.RenderingEngine>("RenderingEngine");
|
||||
connectionInfo.RenderingEngine =
|
||||
xmlnode.GetAttributeAsEnum<HTTPBase.RenderingEngine>("RenderingEngine");
|
||||
connectionInfo.MacAddress = xmlnode.GetAttributeAsString("MacAddress");
|
||||
connectionInfo.Inheritance.RenderingEngine = xmlnode.GetAttributeAsBool("InheritRenderingEngine");
|
||||
connectionInfo.Inheritance.MacAddress = xmlnode.GetAttributeAsBool("InheritMacAddress");
|
||||
@@ -448,19 +468,28 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
if (_confVersion >= 2.2)
|
||||
{
|
||||
// Get settings
|
||||
connectionInfo.RDGatewayUsageMethod = xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUsageMethod>("RDGatewayUsageMethod");
|
||||
connectionInfo.RDGatewayUsageMethod =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUsageMethod>("RDGatewayUsageMethod");
|
||||
connectionInfo.RDGatewayHostname = xmlnode.GetAttributeAsString("RDGatewayHostname");
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUseConnectionCredentials>("RDGatewayUseConnectionCredentials");
|
||||
connectionInfo.RDGatewayUseConnectionCredentials =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.RDGatewayUseConnectionCredentials>(
|
||||
"RDGatewayUseConnectionCredentials");
|
||||
connectionInfo.RDGatewayUsername = xmlnode.GetAttributeAsString("RDGatewayUsername");
|
||||
connectionInfo.RDGatewayPassword = _decryptor.Decrypt(xmlnode.GetAttributeAsString("RDGatewayPassword"));
|
||||
connectionInfo.RDGatewayPassword =
|
||||
_decryptor.Decrypt(xmlnode.GetAttributeAsString("RDGatewayPassword"));
|
||||
connectionInfo.RDGatewayDomain = xmlnode.GetAttributeAsString("RDGatewayDomain");
|
||||
|
||||
// Get inheritance settings
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod = xmlnode.GetAttributeAsBool("InheritRDGatewayUsageMethod");
|
||||
connectionInfo.Inheritance.RDGatewayHostname = xmlnode.GetAttributeAsBool("InheritRDGatewayHostname");
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials = xmlnode.GetAttributeAsBool("InheritRDGatewayUseConnectionCredentials");
|
||||
connectionInfo.Inheritance.RDGatewayUsername = xmlnode.GetAttributeAsBool("InheritRDGatewayUsername");
|
||||
connectionInfo.Inheritance.RDGatewayPassword = xmlnode.GetAttributeAsBool("InheritRDGatewayPassword");
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayUsageMethod");
|
||||
connectionInfo.Inheritance.RDGatewayHostname =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayHostname");
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayUseConnectionCredentials");
|
||||
connectionInfo.Inheritance.RDGatewayUsername =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayUsername");
|
||||
connectionInfo.Inheritance.RDGatewayPassword =
|
||||
xmlnode.GetAttributeAsBool("InheritRDGatewayPassword");
|
||||
connectionInfo.Inheritance.RDGatewayDomain = xmlnode.GetAttributeAsBool("InheritRDGatewayDomain");
|
||||
}
|
||||
|
||||
@@ -471,8 +500,10 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
connectionInfo.EnableDesktopComposition = xmlnode.GetAttributeAsBool("EnableDesktopComposition");
|
||||
|
||||
// Get inheritance settings
|
||||
connectionInfo.Inheritance.EnableFontSmoothing = xmlnode.GetAttributeAsBool("InheritEnableFontSmoothing");
|
||||
connectionInfo.Inheritance.EnableDesktopComposition = xmlnode.GetAttributeAsBool("InheritEnableDesktopComposition");
|
||||
connectionInfo.Inheritance.EnableFontSmoothing =
|
||||
xmlnode.GetAttributeAsBool("InheritEnableFontSmoothing");
|
||||
connectionInfo.Inheritance.EnableDesktopComposition =
|
||||
xmlnode.GetAttributeAsBool("InheritEnableDesktopComposition");
|
||||
}
|
||||
|
||||
if (_confVersion >= 2.4)
|
||||
@@ -491,22 +522,30 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
|
||||
if (_confVersion >= 2.6)
|
||||
{
|
||||
connectionInfo.SoundQuality = xmlnode.GetAttributeAsEnum<RdpProtocol.RDPSoundQuality>("SoundQuality");
|
||||
connectionInfo.SoundQuality =
|
||||
xmlnode.GetAttributeAsEnum<RdpProtocol.RDPSoundQuality>("SoundQuality");
|
||||
connectionInfo.Inheritance.SoundQuality = xmlnode.GetAttributeAsBool("InheritSoundQuality");
|
||||
connectionInfo.RDPMinutesToIdleTimeout = xmlnode.GetAttributeAsInt("RDPMinutesToIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPMinutesToIdleTimeout = xmlnode.GetAttributeAsBool("InheritRDPMinutesToIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPMinutesToIdleTimeout =
|
||||
xmlnode.GetAttributeAsBool("InheritRDPMinutesToIdleTimeout");
|
||||
connectionInfo.RDPAlertIdleTimeout = xmlnode.GetAttributeAsBool("RDPAlertIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPAlertIdleTimeout = xmlnode.GetAttributeAsBool("InheritRDPAlertIdleTimeout");
|
||||
connectionInfo.Inheritance.RDPAlertIdleTimeout =
|
||||
xmlnode.GetAttributeAsBool("InheritRDPAlertIdleTimeout");
|
||||
}
|
||||
if(_confVersion >= 2.7)
|
||||
|
||||
if (_confVersion >= 2.7)
|
||||
{
|
||||
connectionInfo.RedirectClipboard = xmlnode.GetAttributeAsBool("RedirectClipboard");
|
||||
connectionInfo.Inheritance.RedirectClipboard = xmlnode.GetAttributeAsBool("InheritRedirectClipboard");
|
||||
connectionInfo.Inheritance.RedirectClipboard =
|
||||
xmlnode.GetAttributeAsBool("InheritRedirectClipboard");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strGetConnectionInfoFromXmlFailed, connectionInfo.Name, ConnectionFileName, ex.Message));
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
string.Format(Language.strGetConnectionInfoFromXmlFailed,
|
||||
connectionInfo.Name, ConnectionFileName,
|
||||
ex.Message));
|
||||
}
|
||||
|
||||
return connectionInfo;
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private SecureString _encryptionKey;
|
||||
private readonly ISerializer<ConnectionInfo, XElement> _connectionNodeSerializer;
|
||||
|
||||
public XmlConnectionsDocumentCompiler(ICryptographyProvider cryptographyProvider, ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
public XmlConnectionsDocumentCompiler(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
{
|
||||
if (cryptographyProvider == null)
|
||||
throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
@@ -43,7 +44,9 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
var xmlDeclaration = new XDeclaration("1.0", "utf-8", null);
|
||||
var xmlDocument = new XDocument(xmlDeclaration, rootElement);
|
||||
if (fullFileEncryption)
|
||||
xmlDocument = new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument, _encryptionKey);
|
||||
xmlDocument =
|
||||
new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument,
|
||||
_encryptionKey);
|
||||
return xmlDocument;
|
||||
}
|
||||
|
||||
@@ -55,6 +58,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
newElement = CompileConnectionInfoNode(serializationTarget);
|
||||
parentElement.Add(newElement);
|
||||
}
|
||||
|
||||
var serializationTargetAsContainer = serializationTarget as ContainerInfo;
|
||||
if (serializationTargetAsContainer == null) return;
|
||||
foreach (var child in serializationTargetAsContainer.Children)
|
||||
@@ -79,7 +83,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
private XElement CompileRootNode(RootNodeInfo rootNodeInfo, bool fullFileEncryption)
|
||||
{
|
||||
var rootNodeSerializer = new XmlRootNodeSerializer();
|
||||
return rootNodeSerializer.SerializeRootNodeInfo(rootNodeInfo, _cryptographyProvider, _connectionNodeSerializer.Version, fullFileEncryption);
|
||||
return rootNodeSerializer.SerializeRootNodeInfo(rootNodeInfo, _cryptographyProvider,
|
||||
_connectionNodeSerializer.Version, fullFileEncryption);
|
||||
}
|
||||
|
||||
private XElement CompileConnectionInfoNode(ConnectionInfo connectionInfo)
|
||||
|
||||
@@ -12,7 +12,8 @@ using System.Xml.Linq;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlConnectionsSerializer : ISerializer<ConnectionTreeModel,string>, ISerializer<ConnectionInfo, string>
|
||||
public class XmlConnectionsSerializer : ISerializer<ConnectionTreeModel, string>,
|
||||
ISerializer<ConnectionInfo, string>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly ISerializer<ConnectionInfo, XElement> _connectionNodeSerializer;
|
||||
@@ -20,7 +21,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
public Version Version => _connectionNodeSerializer.Version;
|
||||
public bool UseFullEncryption { get; set; }
|
||||
|
||||
public XmlConnectionsSerializer(ICryptographyProvider cryptographyProvider, ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
public XmlConnectionsSerializer(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider;
|
||||
_connectionNodeSerializer = connectionNodeSerializer;
|
||||
@@ -42,7 +44,8 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
var xml = "";
|
||||
try
|
||||
{
|
||||
var documentCompiler = new XmlConnectionsDocumentCompiler(_cryptographyProvider, _connectionNodeSerializer);
|
||||
var documentCompiler =
|
||||
new XmlConnectionsDocumentCompiler(_cryptographyProvider, _connectionNodeSerializer);
|
||||
var xmlDocument = documentCompiler.CompileDocument(serializationTarget, UseFullEncryption);
|
||||
xml = WriteXmlToString(xmlDocument);
|
||||
}
|
||||
@@ -50,13 +53,15 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace("SaveToXml failed", ex);
|
||||
}
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
private static string WriteXmlToString(XNode xmlDocument)
|
||||
{
|
||||
string xmlString;
|
||||
var xmlWriterSettings = new XmlWriterSettings { Indent = true, IndentChars = " ", Encoding = Encoding.UTF8 };
|
||||
var xmlWriterSettings = new XmlWriterSettings
|
||||
{Indent = true, IndentChars = " ", Encoding = Encoding.UTF8};
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var xmlTextWriter = XmlWriter.Create(memoryStream, xmlWriterSettings))
|
||||
{
|
||||
@@ -66,6 +71,7 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
xmlString = streamReader.ReadToEnd();
|
||||
}
|
||||
|
||||
return xmlString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return defaultValue;
|
||||
|
||||
return bool.TryParse(value, out var valueAsBool)
|
||||
return bool.TryParse(value, out var valueAsBool)
|
||||
? valueAsBool
|
||||
: defaultValue;
|
||||
}
|
||||
@@ -28,8 +28,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return defaultValue;
|
||||
|
||||
return int.TryParse(value, out var valueAsBool)
|
||||
? valueAsBool
|
||||
return int.TryParse(value, out var valueAsBool)
|
||||
? valueAsBool
|
||||
: defaultValue;
|
||||
}
|
||||
|
||||
@@ -45,4 +45,4 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
: defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,27 +7,28 @@ namespace mRemoteNG.Config.Serializers.Xml
|
||||
{
|
||||
public class XmlRootNodeSerializer
|
||||
{
|
||||
public XElement SerializeRootNodeInfo(
|
||||
RootNodeInfo rootNodeInfo,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
Version version,
|
||||
bool fullFileEncryption = false)
|
||||
public XElement SerializeRootNodeInfo(RootNodeInfo rootNodeInfo,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
Version version,
|
||||
bool fullFileEncryption = false)
|
||||
{
|
||||
XNamespace xmlNamespace = "http://mremoteng.org";
|
||||
var element = new XElement(xmlNamespace + "Connections");
|
||||
element.Add(new XAttribute(XNamespace.Xmlns+"mrng", xmlNamespace));
|
||||
element.Add(new XAttribute(XNamespace.Xmlns + "mrng", xmlNamespace));
|
||||
element.Add(new XAttribute(XName.Get("Name"), rootNodeInfo.Name));
|
||||
element.Add(new XAttribute(XName.Get("Export"), "false"));
|
||||
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
|
||||
element.Add(new XAttribute(XName.Get("Export"), "false"));
|
||||
element.Add(new XAttribute(XName.Get("EncryptionEngine"), cryptographyProvider.CipherEngine));
|
||||
element.Add(new XAttribute(XName.Get("BlockCipherMode"), cryptographyProvider.CipherMode));
|
||||
element.Add(new XAttribute(XName.Get("KdfIterations"), cryptographyProvider.KeyDerivationIterations));
|
||||
element.Add(new XAttribute(XName.Get("FullFileEncryption"), fullFileEncryption.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute(XName.Get("FullFileEncryption"),
|
||||
fullFileEncryption.ToString().ToLowerInvariant()));
|
||||
element.Add(CreateProtectedAttribute(rootNodeInfo, cryptographyProvider));
|
||||
element.Add(new XAttribute(XName.Get("ConfVersion"), version.ToString(2)));
|
||||
return element;
|
||||
}
|
||||
|
||||
private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo, ICryptographyProvider cryptographyProvider)
|
||||
private XAttribute CreateProtectedAttribute(RootNodeInfo rootNodeInfo,
|
||||
ICryptographyProvider cryptographyProvider)
|
||||
{
|
||||
var attribute = new XAttribute(XName.Get("Protected"), "");
|
||||
var plainText = rootNodeInfo.Password ? "ThisIsProtected" : "ThisIsNotProtected";
|
||||
|
||||
@@ -12,7 +12,9 @@ namespace mRemoteNG.Config.Serializers.CredentialProviderSerializer
|
||||
private readonly ISecureSerializer<IEnumerable<ICredentialRecord>, string> _serializer;
|
||||
private readonly ISecureDeserializer<string, IEnumerable<ICredentialRecord>> _deserializer;
|
||||
|
||||
public CredentialRepositoryListDeserializer(ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer, ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
public CredentialRepositoryListDeserializer(
|
||||
ISecureSerializer<IEnumerable<ICredentialRecord>, string> serializer,
|
||||
ISecureDeserializer<string, IEnumerable<ICredentialRecord>> deserializer)
|
||||
{
|
||||
if (serializer == null)
|
||||
throw new ArgumentNullException(nameof(serializer));
|
||||
|
||||
@@ -13,14 +13,14 @@ namespace mRemoteNG.Config.Serializers.CredentialProviderSerializer
|
||||
{
|
||||
var xmlDocument = new XDocument(new XDeclaration("1.0", "utf-8", null));
|
||||
var rootElement = new XElement("CredentialRepositories",
|
||||
from provider in credentialProviderCatalog
|
||||
select new XElement("CredentialRepository",
|
||||
new XAttribute("Id", provider.Config.Id),
|
||||
new XAttribute("TypeName", provider.Config.TypeName),
|
||||
new XAttribute("Title", provider.Config.Title),
|
||||
new XAttribute("Source", provider.Config.Source)
|
||||
)
|
||||
);
|
||||
from provider in credentialProviderCatalog
|
||||
select new XElement("CredentialRepository",
|
||||
new XAttribute("Id", provider.Config.Id),
|
||||
new XAttribute("TypeName", provider.Config.TypeName),
|
||||
new XAttribute("Title", provider.Config.Title),
|
||||
new XAttribute("Source", provider.Config.Source)
|
||||
)
|
||||
);
|
||||
xmlDocument.Add(rootElement);
|
||||
var declaration = xmlDocument.Declaration.ToString();
|
||||
var documentBody = xmlDocument.ToString();
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
{
|
||||
private readonly IDeserializer<string, IEnumerable<ICredentialRecord>> _baseDeserializer;
|
||||
|
||||
public XmlCredentialPasswordDecryptorDecorator(IDeserializer<string, IEnumerable<ICredentialRecord>> baseDeserializer)
|
||||
public XmlCredentialPasswordDecryptorDecorator(
|
||||
IDeserializer<string, IEnumerable<ICredentialRecord>> baseDeserializer)
|
||||
{
|
||||
if (baseDeserializer == null)
|
||||
throw new ArgumentNullException(nameof(baseDeserializer));
|
||||
@@ -39,10 +40,13 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
var decryptedPassword = cryptoProvider.Decrypt(passwordAttribute.Value, key);
|
||||
passwordAttribute.SetValue(decryptedPassword);
|
||||
}
|
||||
|
||||
return xdoc.ToString();
|
||||
}
|
||||
|
||||
private void DecryptAuthHeader(XElement rootElement, ICryptographyProvider cryptographyProvider, SecureString key)
|
||||
private void DecryptAuthHeader(XElement rootElement,
|
||||
ICryptographyProvider cryptographyProvider,
|
||||
SecureString key)
|
||||
{
|
||||
var authAttribute = rootElement.Attribute("Auth");
|
||||
if (authAttribute == null)
|
||||
|
||||
@@ -12,7 +12,9 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
private readonly ISerializer<IEnumerable<ICredentialRecord>, string> _baseSerializer;
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
|
||||
public XmlCredentialPasswordEncryptorDecorator(ICryptographyProvider cryptographyProvider, ISerializer<IEnumerable<ICredentialRecord>, string> baseSerializer)
|
||||
public XmlCredentialPasswordEncryptorDecorator(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<IEnumerable<ICredentialRecord>, string>
|
||||
baseSerializer)
|
||||
{
|
||||
if (baseSerializer == null)
|
||||
throw new ArgumentNullException(nameof(baseSerializer));
|
||||
@@ -45,6 +47,7 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
var encryptedPassword = _cryptographyProvider.Encrypt(passwordAttribute.Value, encryptionKey);
|
||||
passwordAttribute.Value = encryptedPassword;
|
||||
}
|
||||
|
||||
return xdoc.Declaration + Environment.NewLine + xdoc;
|
||||
}
|
||||
|
||||
@@ -53,7 +56,9 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
xdoc.Root?.SetAttributeValue("EncryptionEngine", _cryptographyProvider.CipherEngine);
|
||||
xdoc.Root?.SetAttributeValue("BlockCipherMode", _cryptographyProvider.CipherMode);
|
||||
xdoc.Root?.SetAttributeValue("KdfIterations", _cryptographyProvider.KeyDerivationIterations);
|
||||
xdoc.Root?.SetAttributeValue("Auth", _cryptographyProvider.Encrypt(RandomGenerator.RandomString(20), encryptionKey));
|
||||
xdoc.Root?.SetAttributeValue("Auth",
|
||||
_cryptographyProvider.Encrypt(RandomGenerator.RandomString(20),
|
||||
encryptionKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,14 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
ValidateSchemaVersion(rootElement);
|
||||
|
||||
var credentials = from element in xdoc.Descendants("Credential")
|
||||
select new CredentialRecord(Guid.Parse(element.Attribute("Id")?.Value ?? Guid.NewGuid().ToString()))
|
||||
{
|
||||
Title = element.Attribute("Title")?.Value ?? "",
|
||||
Username = element.Attribute("Username")?.Value ?? "",
|
||||
Password = element.Attribute("Password")?.Value.ConvertToSecureString(),
|
||||
Domain = element.Attribute("Domain")?.Value ?? ""
|
||||
};
|
||||
select new CredentialRecord(Guid.Parse(element.Attribute("Id")?.Value ??
|
||||
Guid.NewGuid().ToString()))
|
||||
{
|
||||
Title = element.Attribute("Title")?.Value ?? "",
|
||||
Username = element.Attribute("Username")?.Value ?? "",
|
||||
Password = element.Attribute("Password")?.Value.ConvertToSecureString(),
|
||||
Domain = element.Attribute("Domain")?.Value ?? ""
|
||||
};
|
||||
return credentials.ToArray();
|
||||
}
|
||||
|
||||
@@ -33,7 +34,8 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
{
|
||||
var docSchemaVersion = rootElement?.Attribute("SchemaVersion")?.Value;
|
||||
if (docSchemaVersion != SchemaVersion)
|
||||
throw new Exception($"The schema version of this document is not supported by this class. Document Version: {docSchemaVersion} Supported Version: {SchemaVersion}");
|
||||
throw new Exception(
|
||||
$"The schema version of this document is not supported by this class. Document Version: {docSchemaVersion} Supported Version: {SchemaVersion}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,18 +14,20 @@ namespace mRemoteNG.Config.Serializers.CredentialSerializer
|
||||
public string Serialize(IEnumerable<ICredentialRecord> credentialRecords)
|
||||
{
|
||||
var xdoc = new XDocument(
|
||||
new XElement("Credentials",
|
||||
new XAttribute("SchemaVersion", Version.ToString(2)),
|
||||
from r in credentialRecords
|
||||
select new XElement("Credential",
|
||||
new XAttribute("Id", r.Id),
|
||||
new XAttribute("Title", r.Title),
|
||||
new XAttribute("Username", r.Username),
|
||||
new XAttribute("Domain", r.Domain),
|
||||
new XAttribute("Password", r.Password.ConvertToUnsecureString())
|
||||
)
|
||||
)
|
||||
)
|
||||
new XElement("Credentials",
|
||||
new XAttribute("SchemaVersion", Version.ToString(2)),
|
||||
from r in credentialRecords
|
||||
select new XElement("Credential",
|
||||
new XAttribute("Id", r.Id),
|
||||
new XAttribute("Title", r.Title),
|
||||
new XAttribute("Username", r.Username),
|
||||
new XAttribute("Domain", r.Domain),
|
||||
new XAttribute("Password",
|
||||
r.Password
|
||||
.ConvertToUnsecureString())
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
Declaration = new XDeclaration("1.0", "utf-8", null)
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
ldapSearcher.SearchRoot = new DirectoryEntry(ldapPath);
|
||||
ldapSearcher.Filter = ldapFilter;
|
||||
ldapSearcher.SearchScope = SearchScope.OneLevel;
|
||||
ldapSearcher.PropertiesToLoad.AddRange(new[] { "securityEquals", "cn", "objectClass" });
|
||||
ldapSearcher.PropertiesToLoad.AddRange(new[] {"securityEquals", "cn", "objectClass"});
|
||||
|
||||
var ldapResults = ldapSearcher.FindAll();
|
||||
foreach (SearchResult ldapResult in ldapResults)
|
||||
@@ -65,7 +65,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
if (directoryEntry.Properties["objectClass"].Contains("organizationalUnit"))
|
||||
{
|
||||
// check/continue here so we don't create empty connection objects
|
||||
if(!_importSubOu) continue;
|
||||
if (!_importSubOu) continue;
|
||||
|
||||
// TODO - this is a circular call. A deserializer should not call an importer
|
||||
ActiveDirectoryImporter.Import(ldapResult.Path, parentContainer, _importSubOu);
|
||||
@@ -79,7 +79,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.", ex);
|
||||
Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.",
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
ImportRootOrContainer(rootNode, root);
|
||||
}
|
||||
|
||||
|
||||
return connectionTreeModel;
|
||||
}
|
||||
|
||||
@@ -66,16 +66,19 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
throw (new FileFormatException($"Unrecognized root node type ({xmlNodeType})."));
|
||||
}
|
||||
|
||||
break;
|
||||
case "container":
|
||||
if (string.Compare(xmlNodeType, "folder", StringComparison.OrdinalIgnoreCase) != 0)
|
||||
{
|
||||
throw (new FileFormatException($"Unrecognized root node type ({xmlNodeType})."));
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
// ReSharper disable once LocalizableElement
|
||||
throw (new ArgumentException("Argument must be either a root or a container node.", nameof(xmlNode)));
|
||||
throw (new ArgumentException("Argument must be either a root or a container node.",
|
||||
nameof(xmlNode)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
var connectionInfo = new ConnectionInfo();
|
||||
foreach (var line in rdcFileContent.Split(Environment.NewLine.ToCharArray()))
|
||||
{
|
||||
var parts = line.Split(new[] { ':' }, 3);
|
||||
var parts = line.Split(new[] {':'}, 3);
|
||||
if (parts.Length < 3)
|
||||
{
|
||||
continue;
|
||||
@@ -29,6 +29,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
SetConnectionInfoParameter(connectionInfo, key, value);
|
||||
}
|
||||
|
||||
root.AddChild(connectionInfo);
|
||||
|
||||
return connectionTreeModel;
|
||||
@@ -74,12 +75,15 @@ namespace mRemoteNG.Config.Serializers
|
||||
connectionInfo.Colors = RdpProtocol.RDPColors.Colors32Bit;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case "bitmapcachepersistenable":
|
||||
connectionInfo.CacheBitmaps = value == "1";
|
||||
break;
|
||||
case "screen mode id":
|
||||
connectionInfo.Resolution = value == "2" ? RdpProtocol.RDPResolutions.Fullscreen : RdpProtocol.RDPResolutions.FitToWindow;
|
||||
connectionInfo.Resolution = value == "2"
|
||||
? RdpProtocol.RDPResolutions.Fullscreen
|
||||
: RdpProtocol.RDPResolutions.FitToWindow;
|
||||
break;
|
||||
case "connect to console":
|
||||
connectionInfo.UseConsoleSession = value == "1";
|
||||
@@ -124,6 +128,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
connectionInfo.RedirectSound = RdpProtocol.RDPSounds.DoNotPlay;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case "loadbalanceinfo":
|
||||
connectionInfo.LoadBalanceInfo = value;
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
// Program Version 2.2 wraps all setting inside the Properties tags
|
||||
containerPropertiesNode = containerPropertiesNode.SelectSingleNode("./properties");
|
||||
}
|
||||
|
||||
var newContainer = new ContainerInfo();
|
||||
var connectionInfo = ConnectionInfoFromXml(containerPropertiesNode);
|
||||
newContainer.CopyFrom(connectionInfo);
|
||||
@@ -113,8 +114,10 @@ namespace mRemoteNG.Config.Serializers
|
||||
// Program Version 2.7 wraps these properties
|
||||
containerPropertiesNode = containerPropertiesNode.SelectSingleNode("./properties");
|
||||
}
|
||||
|
||||
newContainer.Name = containerPropertiesNode?.SelectSingleNode("./name")?.InnerText ?? Language.strNewFolder;
|
||||
newContainer.IsExpanded = bool.Parse(containerPropertiesNode?.SelectSingleNode("./expanded")?.InnerText ?? "false");
|
||||
newContainer.IsExpanded =
|
||||
bool.Parse(containerPropertiesNode?.SelectSingleNode("./expanded")?.InnerText ?? "false");
|
||||
parentContainer.AddChild(newContainer);
|
||||
return newContainer;
|
||||
}
|
||||
@@ -131,9 +134,11 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
|
||||
var propertiesNode = xmlNode.SelectSingleNode("./properties");
|
||||
if (_schemaVersion == 1) propertiesNode = xmlNode; // Version 2.2 defines the container name at the root instead
|
||||
if (_schemaVersion == 1)
|
||||
propertiesNode = xmlNode; // Version 2.2 defines the container name at the root instead
|
||||
connectionInfo.Hostname = propertiesNode?.SelectSingleNode("./name")?.InnerText ?? "";
|
||||
connectionInfo.Name = propertiesNode?.SelectSingleNode("./displayName")?.InnerText ?? connectionInfo.Hostname;
|
||||
connectionInfo.Name =
|
||||
propertiesNode?.SelectSingleNode("./displayName")?.InnerText ?? connectionInfo.Hostname;
|
||||
connectionInfo.Description = propertiesNode?.SelectSingleNode("./comment")?.InnerText ?? string.Empty;
|
||||
|
||||
var logonCredentialsNode = xmlNode.SelectSingleNode("./logonCredentials");
|
||||
@@ -144,8 +149,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
var passwordNode = logonCredentialsNode.SelectSingleNode("./password");
|
||||
if (_schemaVersion == 1) // Version 2.2 allows clear text passwords
|
||||
{
|
||||
connectionInfo.Password = passwordNode?.Attributes?["storeAsClearText"]?.Value == "True"
|
||||
? passwordNode.InnerText
|
||||
connectionInfo.Password = passwordNode?.Attributes?["storeAsClearText"]?.Value == "True"
|
||||
? passwordNode.InnerText
|
||||
: DecryptRdcManPassword(passwordNode?.InnerText);
|
||||
}
|
||||
else
|
||||
@@ -165,7 +170,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
var connectionSettingsNode = xmlNode.SelectSingleNode("./connectionSettings");
|
||||
if (connectionSettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.UseConsoleSession = bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole")?.InnerText ?? "false");
|
||||
connectionInfo.UseConsoleSession =
|
||||
bool.Parse(connectionSettingsNode.SelectSingleNode("./connectToConsole")?.InnerText ?? "false");
|
||||
// ./startProgram
|
||||
// ./workingDir
|
||||
connectionInfo.Port = Convert.ToInt32(connectionSettingsNode.SelectSingleNode("./port")?.InnerText);
|
||||
@@ -179,12 +185,17 @@ namespace mRemoteNG.Config.Serializers
|
||||
var gatewaySettingsNode = xmlNode.SelectSingleNode("./gatewaySettings");
|
||||
if (gatewaySettingsNode?.Attributes?["inherit"]?.Value == "None")
|
||||
{
|
||||
connectionInfo.RDGatewayUsageMethod = gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True" ? RdpProtocol.RDGatewayUsageMethod.Always : RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
connectionInfo.RDGatewayUsageMethod =
|
||||
gatewaySettingsNode.SelectSingleNode("./enabled")?.InnerText == "True"
|
||||
? RdpProtocol.RDGatewayUsageMethod.Always
|
||||
: RdpProtocol.RDGatewayUsageMethod.Never;
|
||||
connectionInfo.RDGatewayHostname = gatewaySettingsNode.SelectSingleNode("./hostName")?.InnerText;
|
||||
connectionInfo.RDGatewayUsername = gatewaySettingsNode.SelectSingleNode("./userName")?.InnerText;
|
||||
|
||||
var passwordNode = gatewaySettingsNode.SelectSingleNode("./password");
|
||||
connectionInfo.RDGatewayPassword = passwordNode?.Attributes?["storeAsClearText"]?.Value == "True" ? passwordNode.InnerText : DecryptRdcManPassword(passwordNode?.InnerText);
|
||||
connectionInfo.RDGatewayPassword = passwordNode?.Attributes?["storeAsClearText"]?.Value == "True"
|
||||
? passwordNode.InnerText
|
||||
: DecryptRdcManPassword(passwordNode?.InnerText);
|
||||
|
||||
connectionInfo.RDGatewayDomain = gatewaySettingsNode.SelectSingleNode("./domain")?.InnerText;
|
||||
// ./logonMethod
|
||||
@@ -206,7 +217,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
var resolutionString = remoteDesktopNode.SelectSingleNode("./size")?.InnerText.Replace(" ", "");
|
||||
try
|
||||
{
|
||||
connectionInfo.Resolution = (RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions), "Res" + resolutionString);
|
||||
connectionInfo.Resolution =
|
||||
(RdpProtocol.RDPResolutions)Enum.Parse(typeof(RdpProtocol.RDPResolutions),
|
||||
"Res" + resolutionString);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
@@ -225,7 +238,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
var colorDepth = remoteDesktopNode.SelectSingleNode("./colorDepth")?.InnerText;
|
||||
if (colorDepth != null)
|
||||
connectionInfo.Colors = (RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), colorDepth);
|
||||
connectionInfo.Colors =
|
||||
(RdpProtocol.RDPColors)Enum.Parse(typeof(RdpProtocol.RDPColors), colorDepth);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -274,11 +288,16 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
|
||||
// ./redirectClipboard
|
||||
connectionInfo.RedirectDiskDrives = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectDrives")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPorts = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPorts")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPrinters = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPrinters")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectSmartCards = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectSmartCards")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectClipboard = bool.Parse(localResourcesNode?.SelectSingleNode("./redirectClipboard")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectDiskDrives =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectDrives")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPorts =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPorts")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectPrinters =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectPrinters")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectSmartCards =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectSmartCards")?.InnerText ?? "false");
|
||||
connectionInfo.RedirectClipboard =
|
||||
bool.Parse(localResourcesNode?.SelectSingleNode("./redirectClipboard")?.InnerText ?? "false");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -330,7 +349,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
try
|
||||
{
|
||||
var plaintextData = ProtectedData.Unprotect(Convert.FromBase64String(ciphertext), new byte[] { }, DataProtectionScope.LocalMachine);
|
||||
var plaintextData = ProtectedData.Unprotect(Convert.FromBase64String(ciphertext), new byte[] { },
|
||||
DataProtectionScope.LocalMachine);
|
||||
var charArray = Encoding.Unicode.GetChars(plaintextData);
|
||||
return new string(charArray);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
new SqlVersion23To24Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion24To25Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion25To26Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion26To27Upgrader(_sqlDatabaseConnector),
|
||||
new SqlVersion26To27Upgrader(_sqlDatabaseConnector),
|
||||
};
|
||||
|
||||
foreach (var upgrader in dbUpgraders)
|
||||
@@ -52,11 +52,16 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
isVerified = true;
|
||||
|
||||
if (isVerified == false)
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strErrorBadDatabaseVersion, databaseVersion, GeneralAppInfo.ProductName));
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
string.Format(Language.strErrorBadDatabaseVersion,
|
||||
databaseVersion,
|
||||
GeneralAppInfo.ProductName));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strErrorVerifyDatabaseVersionFailed, ex.Message));
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
string.Format(Language.strErrorVerifyDatabaseVersionFailed,
|
||||
ex.Message));
|
||||
}
|
||||
|
||||
return isVerified;
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.2 to version 2.3.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.2 to version 2.3.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD EnableFontSmoothing bit NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.3 to version 2.4.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.3 to version 2.4.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD UseCredSsp bit NOT NULL DEFAULT 1,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.4 to version 2.5.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.4 to version 2.5.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD LoadBalanceInfo varchar (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.5 to version 2.6.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.5 to version 2.6.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD RDPMinutesToIdleTimeout int NOT NULL DEFAULT 0,
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace mRemoteNG.Config.Serializers.Versioning
|
||||
|
||||
public Version Upgrade()
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.6 to version 2.7.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
"Upgrading database from version 2.6 to version 2.7.");
|
||||
const string sqlText = @"
|
||||
ALTER TABLE tblCons
|
||||
ADD RedirectClipboard bit NOT NULL DEFAULT 0,
|
||||
@@ -38,4 +39,4 @@ UPDATE tblRoot
|
||||
return new Version(2, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
_rootNodeInfo = rootNodeInfo;
|
||||
}
|
||||
|
||||
public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine, BlockCipherModes blockCipherMode, RootNodeInfo rootNodeInfo)
|
||||
public XmlConnectionsDecryptor(BlockCipherEngines blockCipherEngine,
|
||||
BlockCipherModes blockCipherMode,
|
||||
RootNodeInfo rootNodeInfo)
|
||||
{
|
||||
_cryptographyProvider = new CryptoProviderFactory(blockCipherEngine, blockCipherMode).Build();
|
||||
_rootNodeInfo = rootNodeInfo;
|
||||
@@ -37,7 +39,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
public string Decrypt(string plainText)
|
||||
{
|
||||
return plainText == "" ? "" : _cryptographyProvider.Decrypt(plainText, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
return plainText == ""
|
||||
? ""
|
||||
: _cryptographyProvider.Decrypt(plainText, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
}
|
||||
|
||||
public string LegacyFullFileDecrypt(string xml)
|
||||
@@ -50,7 +54,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
try
|
||||
{
|
||||
decryptedContent = _cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
decryptedContent =
|
||||
_cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
notDecr = decryptedContent == xml;
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -62,7 +67,8 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
if (Authenticate(xml, _rootNodeInfo.PasswordString.ConvertToSecureString()))
|
||||
{
|
||||
decryptedContent = _cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
decryptedContent =
|
||||
_cryptographyProvider.Decrypt(xml, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
notDecr = false;
|
||||
}
|
||||
|
||||
@@ -82,12 +88,17 @@ namespace mRemoteNG.Config.Serializers
|
||||
var connectionsFileIsNotEncrypted = false;
|
||||
try
|
||||
{
|
||||
connectionsFileIsNotEncrypted = _cryptographyProvider.Decrypt(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()) == "ThisIsNotProtected";
|
||||
connectionsFileIsNotEncrypted =
|
||||
_cryptographyProvider.Decrypt(protectedString,
|
||||
_rootNodeInfo.PasswordString.ConvertToSecureString()) ==
|
||||
"ThisIsNotProtected";
|
||||
}
|
||||
catch (EncryptionException)
|
||||
{
|
||||
}
|
||||
return connectionsFileIsNotEncrypted || Authenticate(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
|
||||
return connectionsFileIsNotEncrypted ||
|
||||
Authenticate(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString());
|
||||
}
|
||||
|
||||
private bool Authenticate(string cipherText, SecureString password)
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
|
||||
#if !PORTABLE
|
||||
var oldPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + GeneralAppInfo.ProductName + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
var oldPath =
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + GeneralAppInfo.ProductName + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
#endif
|
||||
var newPath = SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
if (File.Exists(newPath))
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly ISerializer<DockPanel, string> _dockPanelSerializer;
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public DockPanelLayoutSaver(ISerializer<DockPanel, string> dockPanelSerializer, IDataProvider<string> dataProvider)
|
||||
public DockPanelLayoutSaver(ISerializer<DockPanel, string> dockPanelSerializer,
|
||||
IDataProvider<string> dataProvider)
|
||||
{
|
||||
if (dockPanelSerializer == null)
|
||||
throw new ArgumentNullException(nameof(dockPanelSerializer));
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace mRemoteNG.Config.Settings
|
||||
memoryStream.Position = 0;
|
||||
xdoc = XDocument.Load(memoryStream, LoadOptions.SetBaseUri);
|
||||
}
|
||||
|
||||
return $"{xdoc.Declaration}{Environment.NewLine}{xdoc}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
|
||||
public ExternalAppsLoader(FrmMain mainForm, MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
public ExternalAppsLoader(FrmMain mainForm,
|
||||
MessageCollector messageCollector,
|
||||
ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
@@ -34,13 +36,15 @@ namespace mRemoteNG.Config.Settings
|
||||
public void LoadExternalAppsFromXML()
|
||||
{
|
||||
#if !PORTABLE
|
||||
var oldPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), GeneralAppInfo.ProductName, SettingsFileInfo.ExtAppsFilesName);
|
||||
var oldPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), GeneralAppInfo.ProductName, SettingsFileInfo.ExtAppsFilesName);
|
||||
#endif
|
||||
var newPath = Path.Combine(SettingsFileInfo.SettingsPath, SettingsFileInfo.ExtAppsFilesName);
|
||||
var xDom = new XmlDocument();
|
||||
if (File.Exists(newPath))
|
||||
{
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {newPath}", true);
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {newPath}",
|
||||
true);
|
||||
xDom.Load(newPath);
|
||||
}
|
||||
#if !PORTABLE
|
||||
@@ -53,13 +57,15 @@ namespace mRemoteNG.Config.Settings
|
||||
#endif
|
||||
else
|
||||
{
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not FIND file!");
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Loading External Apps failed: Could not FIND file!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (xDom.DocumentElement == null)
|
||||
{
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not LOAD file!");
|
||||
_messageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"Loading External Apps failed: Could not LOAD file!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,7 +99,9 @@ namespace mRemoteNG.Config.Settings
|
||||
extA.ShowOnToolbar = bool.Parse(xEl.Attributes["ShowOnToolbar"].Value);
|
||||
}
|
||||
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}", true);
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
$"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}",
|
||||
true);
|
||||
Runtime.ExternalToolsService.ExternalTools.Add(extA);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
var xmlTextWriter =
|
||||
new XmlTextWriter(SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.ExtAppsFilesName,
|
||||
Encoding.UTF8)
|
||||
Encoding.UTF8)
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
Indentation = 4
|
||||
|
||||
@@ -9,5 +9,6 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
#else
|
||||
public class ChooseProvider : LocalFileSettingsProvider
|
||||
#endif
|
||||
{ }
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ using System.Windows.Forms;
|
||||
using System.Collections.Specialized;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
//using mRemoteNG.App;
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Providers
|
||||
@@ -43,7 +44,9 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
private const string _className = "PortableSettingsProvider";
|
||||
private XmlDocument _xmlDocument;
|
||||
|
||||
private string _filePath => Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? throw new InvalidOperationException(), $"{ApplicationName}.settings");
|
||||
private string _filePath =>
|
||||
Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? throw new InvalidOperationException(),
|
||||
$"{ApplicationName}.settings");
|
||||
|
||||
private XmlNode _localSettingsNode => GetSettingsNode(_localSettingsNodeName);
|
||||
|
||||
@@ -109,7 +112,8 @@ namespace mRemoteNG.Config.Settings.Providers
|
||||
}
|
||||
}
|
||||
|
||||
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
|
||||
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context,
|
||||
SettingsPropertyCollection collection)
|
||||
{
|
||||
var values = new SettingsPropertyValueCollection();
|
||||
|
||||
|
||||
@@ -16,25 +16,24 @@ using mRemoteNG.UI.Forms;
|
||||
namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
public class SettingsLoader
|
||||
{
|
||||
{
|
||||
private readonly ExternalAppsLoader _externalAppsLoader;
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly MenuStrip _mainMenu;
|
||||
private readonly MenuStrip _mainMenu;
|
||||
private readonly QuickConnectToolStrip _quickConnectToolStrip;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
private readonly MultiSshToolStrip _multiSshToolStrip;
|
||||
private readonly MultiSshToolStrip _multiSshToolStrip;
|
||||
|
||||
private FrmMain MainForm { get; }
|
||||
|
||||
|
||||
public SettingsLoader(
|
||||
FrmMain mainForm,
|
||||
MessageCollector messageCollector,
|
||||
QuickConnectToolStrip quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
MenuStrip mainMenu)
|
||||
{
|
||||
public SettingsLoader(FrmMain mainForm,
|
||||
MessageCollector messageCollector,
|
||||
QuickConnectToolStrip quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
MenuStrip mainMenu)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
if (messageCollector == null)
|
||||
@@ -45,45 +44,46 @@ namespace mRemoteNG.Config.Settings
|
||||
throw new ArgumentNullException(nameof(externalToolsToolStrip));
|
||||
if (multiSshToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(multiSshToolStrip));
|
||||
if (mainMenu == null)
|
||||
throw new ArgumentNullException(nameof(mainMenu));
|
||||
if (mainMenu == null)
|
||||
throw new ArgumentNullException(nameof(mainMenu));
|
||||
|
||||
MainForm = mainForm;
|
||||
_messageCollector = messageCollector;
|
||||
_quickConnectToolStrip = quickConnectToolStrip;
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
_multiSshToolStrip = multiSshToolStrip;
|
||||
_mainMenu = mainMenu;
|
||||
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector, _externalToolsToolStrip);
|
||||
_messageCollector = messageCollector;
|
||||
_quickConnectToolStrip = quickConnectToolStrip;
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
_multiSshToolStrip = multiSshToolStrip;
|
||||
_mainMenu = mainMenu;
|
||||
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector, _externalToolsToolStrip);
|
||||
}
|
||||
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void LoadSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureSettingsAreSavedInNewestVersion();
|
||||
|
||||
SetSupportedCulture();
|
||||
SetSupportedCulture();
|
||||
SetApplicationWindowPositionAndSize();
|
||||
SetKioskMode();
|
||||
|
||||
SetPuttyPath();
|
||||
SetShowSystemTrayIcon();
|
||||
SetAutoSave();
|
||||
LoadExternalAppsFromXml();
|
||||
LoadExternalAppsFromXml();
|
||||
SetAlwaysShowPanelTabs();
|
||||
|
||||
if (mRemoteNG.Settings.Default.ResetToolbars)
|
||||
|
||||
if (mRemoteNG.Settings.Default.ResetToolbars)
|
||||
SetToolbarsDefault();
|
||||
else
|
||||
else
|
||||
LoadToolbarsFromSettings();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Loading settings failed", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetAlwaysShowPanelTabs()
|
||||
{
|
||||
@@ -91,14 +91,15 @@ namespace mRemoteNG.Config.Settings
|
||||
FrmMain.Default.pnlDock.DocumentStyle = DocumentStyle.DockingWindow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetSupportedCulture()
|
||||
{
|
||||
if (mRemoteNG.Settings.Default.OverrideUICulture == "" ||
|
||||
!SupportedCultures.IsNameSupported(mRemoteNG.Settings.Default.OverrideUICulture)) return;
|
||||
Thread.CurrentThread.CurrentUICulture = new CultureInfo(mRemoteNG.Settings.Default.OverrideUICulture);
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Override Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}", true);
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg,
|
||||
$"Override Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}",
|
||||
true);
|
||||
}
|
||||
|
||||
private void SetApplicationWindowPositionAndSize()
|
||||
@@ -163,7 +164,9 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
private static void SetPuttyPath()
|
||||
{
|
||||
PuttyBase.PuttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath ? mRemoteNG.Settings.Default.CustomPuttyPath : GeneralAppInfo.PuttyPath;
|
||||
PuttyBase.PuttyPath = mRemoteNG.Settings.Default.UseCustomPuttyPath
|
||||
? mRemoteNG.Settings.Default.CustomPuttyPath
|
||||
: GeneralAppInfo.PuttyPath;
|
||||
}
|
||||
|
||||
private void EnsureSettingsAreSavedInNewestVersion()
|
||||
@@ -183,6 +186,7 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
_messageCollector.AddExceptionMessage("Settings.Upgrade() failed", ex);
|
||||
}
|
||||
|
||||
mRemoteNG.Settings.Default.DoUpgrade = false;
|
||||
|
||||
// Clear pending update flag
|
||||
@@ -191,21 +195,21 @@ namespace mRemoteNG.Config.Settings
|
||||
mRemoteNG.Settings.Default.UpdatePending = false;
|
||||
}
|
||||
|
||||
private void SetToolbarsDefault()
|
||||
{
|
||||
ToolStripPanelFromString("top").Join(_quickConnectToolStrip, new Point(300, 0));
|
||||
private void SetToolbarsDefault()
|
||||
{
|
||||
ToolStripPanelFromString("top").Join(_quickConnectToolStrip, new Point(300, 0));
|
||||
_quickConnectToolStrip.Visible = true;
|
||||
ToolStripPanelFromString("bottom").Join(_externalToolsToolStrip, new Point(3, 0));
|
||||
ToolStripPanelFromString("bottom").Join(_externalToolsToolStrip, new Point(3, 0));
|
||||
_externalToolsToolStrip.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolbarsFromSettings()
|
||||
{
|
||||
private void LoadToolbarsFromSettings()
|
||||
{
|
||||
ResetAllToolbarLocations();
|
||||
AddMainMenuPanel();
|
||||
AddMainMenuPanel();
|
||||
AddExternalAppsPanel();
|
||||
AddQuickConnectPanel();
|
||||
AddMultiSshPanel();
|
||||
AddQuickConnectPanel();
|
||||
AddMultiSshPanel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -213,74 +217,75 @@ namespace mRemoteNG.Config.Settings
|
||||
/// Since all toolbars start in this temp panel, no toolbar load
|
||||
/// can be blocked by pre-existing toolbars.
|
||||
/// </summary>
|
||||
private void ResetAllToolbarLocations()
|
||||
{
|
||||
var tempToolStrip = new ToolStripPanel();
|
||||
private void ResetAllToolbarLocations()
|
||||
{
|
||||
var tempToolStrip = new ToolStripPanel();
|
||||
tempToolStrip.Join(_mainMenu);
|
||||
tempToolStrip.Join(_quickConnectToolStrip);
|
||||
tempToolStrip.Join(_externalToolsToolStrip);
|
||||
tempToolStrip.Join(_multiSshToolStrip);
|
||||
tempToolStrip.Join(_quickConnectToolStrip);
|
||||
tempToolStrip.Join(_externalToolsToolStrip);
|
||||
tempToolStrip.Join(_multiSshToolStrip);
|
||||
}
|
||||
|
||||
private void AddMainMenuPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_mainMenu);
|
||||
private void AddMainMenuPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_mainMenu);
|
||||
var toolStripPanel = ToolStripPanelFromString("top");
|
||||
toolStripPanel.Join(_mainMenu, new Point(3, 0));
|
||||
toolStripPanel.Join(_mainMenu, new Point(3, 0));
|
||||
}
|
||||
|
||||
private void AddQuickConnectPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_quickConnectToolStrip);
|
||||
private void AddQuickConnectPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_quickConnectToolStrip);
|
||||
_quickConnectToolStrip.Visible = mRemoteNG.Settings.Default.QuickyTBVisible;
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.QuickyTBParentDock);
|
||||
toolStripPanel.Join(_quickConnectToolStrip, mRemoteNG.Settings.Default.QuickyTBLocation);
|
||||
}
|
||||
|
||||
private void AddExternalAppsPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_externalToolsToolStrip);
|
||||
}
|
||||
|
||||
private void AddExternalAppsPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_externalToolsToolStrip);
|
||||
_externalToolsToolStrip.Visible = mRemoteNG.Settings.Default.ExtAppsTBVisible;
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.ExtAppsTBParentDock);
|
||||
toolStripPanel.Join(_externalToolsToolStrip, mRemoteNG.Settings.Default.ExtAppsTBLocation);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddMultiSshPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_multiSshToolStrip);
|
||||
_multiSshToolStrip.Visible = mRemoteNG.Settings.Default.MultiSshToolbarVisible;
|
||||
private void AddMultiSshPanel()
|
||||
{
|
||||
SetToolstripGripStyle(_multiSshToolStrip);
|
||||
_multiSshToolStrip.Visible = mRemoteNG.Settings.Default.MultiSshToolbarVisible;
|
||||
var toolStripPanel = ToolStripPanelFromString(mRemoteNG.Settings.Default.MultiSshToolbarParentDock);
|
||||
toolStripPanel.Join(_multiSshToolStrip, mRemoteNG.Settings.Default.MultiSshToolbarLocation);
|
||||
}
|
||||
|
||||
private void SetToolstripGripStyle(ToolStrip toolbar)
|
||||
{
|
||||
toolbar.GripStyle = mRemoteNG.Settings.Default.LockToolbars
|
||||
? ToolStripGripStyle.Hidden
|
||||
: ToolStripGripStyle.Visible;
|
||||
}
|
||||
|
||||
private ToolStripPanel ToolStripPanelFromString(string panel)
|
||||
{
|
||||
switch (panel.ToLower())
|
||||
{
|
||||
case "top":
|
||||
return MainForm.tsContainer.TopToolStripPanel;
|
||||
case "bottom":
|
||||
return MainForm.tsContainer.BottomToolStripPanel;
|
||||
case "left":
|
||||
return MainForm.tsContainer.LeftToolStripPanel;
|
||||
case "right":
|
||||
return MainForm.tsContainer.RightToolStripPanel;
|
||||
default:
|
||||
return MainForm.tsContainer.TopToolStripPanel;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadExternalAppsFromXml()
|
||||
{
|
||||
private void SetToolstripGripStyle(ToolStrip toolbar)
|
||||
{
|
||||
toolbar.GripStyle = mRemoteNG.Settings.Default.LockToolbars
|
||||
? ToolStripGripStyle.Hidden
|
||||
: ToolStripGripStyle.Visible;
|
||||
}
|
||||
|
||||
private ToolStripPanel ToolStripPanelFromString(string panel)
|
||||
{
|
||||
switch (panel.ToLower())
|
||||
{
|
||||
case "top":
|
||||
return MainForm.tsContainer.TopToolStripPanel;
|
||||
case "bottom":
|
||||
return MainForm.tsContainer.BottomToolStripPanel;
|
||||
case "left":
|
||||
return MainForm.tsContainer.LeftToolStripPanel;
|
||||
case "right":
|
||||
return MainForm.tsContainer.RightToolStripPanel;
|
||||
default:
|
||||
return MainForm.tsContainer.TopToolStripPanel;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadExternalAppsFromXml()
|
||||
{
|
||||
_externalAppsLoader.LoadExternalAppsFromXML();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user